@carbonorm/carbonnode 3.7.13 → 3.7.14
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/handlers/createTestServer.d.ts +8 -0
- package/dist/api/types/ormInterfaces.d.ts +1 -1
- package/dist/index.cjs.js +133 -121
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.esm.js +134 -123
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/expressServer.e2e.test.ts +94 -0
- package/src/__tests__/sakila-db/C6.js +1 -1
- package/src/__tests__/sakila-db/C6.ts +1 -1
- package/src/api/executors/HttpExecutor.ts +11 -5
- package/src/api/handlers/createTestServer.ts +15 -0
- package/src/api/types/ormInterfaces.ts +2 -1
- package/src/index.ts +2 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Express } from "express";
|
|
2
|
+
import { Pool } from "mysql2/promise";
|
|
3
|
+
import { iC6Object } from "api/types/ormInterfaces";
|
|
4
|
+
export declare function createTestServer({ C6, mysqlPool }: {
|
|
5
|
+
C6: iC6Object;
|
|
6
|
+
mysqlPool: Pool;
|
|
7
|
+
}): Express;
|
|
8
|
+
export default createTestServer;
|
|
@@ -109,7 +109,7 @@ export interface iC6RestResponse<RestData> {
|
|
|
109
109
|
}
|
|
110
110
|
export interface iGetC6RestResponse<ResponseDataType extends {
|
|
111
111
|
[key: string]: any;
|
|
112
|
-
}, ResponseDataOverrides = {}> extends iC6RestResponse<Modify<ResponseDataType, ResponseDataOverrides>
|
|
112
|
+
}, ResponseDataOverrides = {}> extends iC6RestResponse<Modify<ResponseDataType, ResponseDataOverrides>[]> {
|
|
113
113
|
next?: () => Promise<DetermineResponseDataType<"GET", ResponseDataType, ResponseDataOverrides>>;
|
|
114
114
|
}
|
|
115
115
|
export type DetermineResponseDataType<Method extends iRestMethods, RestTableInterface extends {
|
package/dist/index.cjs.js
CHANGED
|
@@ -6,6 +6,7 @@ var tslib = require('tslib');
|
|
|
6
6
|
var reactToastify = require('react-toastify');
|
|
7
7
|
var namedPlaceholders = require('named-placeholders');
|
|
8
8
|
var buffer = require('buffer');
|
|
9
|
+
var express = require('express');
|
|
9
10
|
|
|
10
11
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
11
12
|
var C6Constants = {
|
|
@@ -623,6 +624,122 @@ function sortAndSerializeQueryObject(tables, query) {
|
|
|
623
624
|
return tables + ' ' + JSON.stringify(orderedQuery);
|
|
624
625
|
}
|
|
625
626
|
|
|
627
|
+
/**
|
|
628
|
+
* Converts a singular T-shaped request into complex ORM format for GET/PUT/DELETE
|
|
629
|
+
* Enforces that all primary keys are present for singular syntax and that the table has PKs.
|
|
630
|
+
* Optionally accepts a previously removed primary key (key/value) to reconstruct WHERE.
|
|
631
|
+
*/
|
|
632
|
+
function normalizeSingularRequest(requestMethod, request, restModel, removedPrimary) {
|
|
633
|
+
var _a, _b;
|
|
634
|
+
var _c;
|
|
635
|
+
if (request == null || typeof request !== 'object')
|
|
636
|
+
return request;
|
|
637
|
+
var specialKeys = new Set([
|
|
638
|
+
C6Constants.SELECT,
|
|
639
|
+
C6Constants.UPDATE,
|
|
640
|
+
C6Constants.DELETE,
|
|
641
|
+
C6Constants.WHERE,
|
|
642
|
+
C6Constants.JOIN,
|
|
643
|
+
C6Constants.PAGINATION,
|
|
644
|
+
]);
|
|
645
|
+
// Determine if the request is already complex (has any special key besides PAGINATION)
|
|
646
|
+
var keys = Object.keys(request);
|
|
647
|
+
var hasComplexKeys = keys.some(function (k) { return k !== C6Constants.PAGINATION && specialKeys.has(k); });
|
|
648
|
+
if (hasComplexKeys)
|
|
649
|
+
return request; // already complex
|
|
650
|
+
// We treat it as singular when it's not complex.
|
|
651
|
+
// For GET, PUT, DELETE only
|
|
652
|
+
if (!(requestMethod === C6Constants.GET || requestMethod === C6Constants.PUT || requestMethod === C6Constants.DELETE)) {
|
|
653
|
+
return request;
|
|
654
|
+
}
|
|
655
|
+
var pkShorts = Array.isArray(restModel.PRIMARY_SHORT) ? tslib.__spreadArray([], restModel.PRIMARY_SHORT, true) : [];
|
|
656
|
+
var pkFulls = Array.isArray(restModel.PRIMARY) ? tslib.__spreadArray([], restModel.PRIMARY, true) : [];
|
|
657
|
+
var resolveShortKey = function (key) {
|
|
658
|
+
var _a;
|
|
659
|
+
var cols = restModel.COLUMNS || {};
|
|
660
|
+
return (_a = cols[key]) !== null && _a !== void 0 ? _a : key;
|
|
661
|
+
};
|
|
662
|
+
if (!pkShorts.length) {
|
|
663
|
+
// For GET requests, do not enforce primary key presence; treat as a collection query.
|
|
664
|
+
if (requestMethod === C6Constants.GET)
|
|
665
|
+
return request;
|
|
666
|
+
throw new Error("Table (".concat(restModel.TABLE_NAME, ") has no primary key; singular request syntax is not allowed."));
|
|
667
|
+
}
|
|
668
|
+
// Build pk map from request + possibly removed primary key (accept short or fully-qualified keys)
|
|
669
|
+
var pkValues = {};
|
|
670
|
+
var requestObj = request;
|
|
671
|
+
var _loop_1 = function (pkShort) {
|
|
672
|
+
// 1) direct short key
|
|
673
|
+
var value = requestObj[pkShort];
|
|
674
|
+
if (value === undefined) {
|
|
675
|
+
// 2) fully-qualified key matching this short key (from PRIMARY list or by concatenation)
|
|
676
|
+
var fqCandidate_1 = "".concat(restModel.TABLE_NAME, ".").concat(pkShort);
|
|
677
|
+
var fqKey = (_c = pkFulls.find(function (fq) { return fq === fqCandidate_1 || fq.endsWith(".".concat(pkShort)); })) !== null && _c !== void 0 ? _c : fqCandidate_1;
|
|
678
|
+
value = requestObj[fqKey];
|
|
679
|
+
}
|
|
680
|
+
if (value === undefined && removedPrimary) {
|
|
681
|
+
// 3) removedPrimary may provide either short or fully-qualified key
|
|
682
|
+
var removedKeyShort = resolveShortKey(removedPrimary.key);
|
|
683
|
+
if (removedKeyShort === pkShort)
|
|
684
|
+
value = removedPrimary.value;
|
|
685
|
+
}
|
|
686
|
+
if (value !== undefined && value !== null) {
|
|
687
|
+
pkValues[pkShort] = value;
|
|
688
|
+
}
|
|
689
|
+
};
|
|
690
|
+
for (var _i = 0, pkShorts_1 = pkShorts; _i < pkShorts_1.length; _i++) {
|
|
691
|
+
var pkShort = pkShorts_1[_i];
|
|
692
|
+
_loop_1(pkShort);
|
|
693
|
+
}
|
|
694
|
+
var missing = pkShorts.filter(function (pk) { return !(pk in pkValues); });
|
|
695
|
+
if (missing.length) {
|
|
696
|
+
// For GET requests, if not all PKs are provided, treat as a collection query and leave as-is.
|
|
697
|
+
if (requestMethod === C6Constants.GET) {
|
|
698
|
+
return request;
|
|
699
|
+
}
|
|
700
|
+
throw new Error("Singular request requires all primary key(s) [".concat(pkShorts.join(', '), "] for table (").concat(restModel.TABLE_NAME, "). Missing: [").concat(missing.join(', '), "]"));
|
|
701
|
+
}
|
|
702
|
+
// Strip API metadata that should remain at root
|
|
703
|
+
var _d = request, dataInsertMultipleRows = _d.dataInsertMultipleRows, cacheResults = _d.cacheResults, fetchDependencies = _d.fetchDependencies, debug = _d.debug, success = _d.success, error = _d.error, rest = tslib.__rest(_d, ["dataInsertMultipleRows", "cacheResults", "fetchDependencies", "debug", "success", "error"]);
|
|
704
|
+
if (requestMethod === C6Constants.GET) {
|
|
705
|
+
var normalized_1 = {
|
|
706
|
+
WHERE: tslib.__assign({}, pkValues),
|
|
707
|
+
};
|
|
708
|
+
// Preserve pagination if any was added previously
|
|
709
|
+
if (request[C6Constants.PAGINATION]) {
|
|
710
|
+
normalized_1[C6Constants.PAGINATION] = request[C6Constants.PAGINATION];
|
|
711
|
+
}
|
|
712
|
+
return tslib.__assign(tslib.__assign({}, normalized_1), { dataInsertMultipleRows: dataInsertMultipleRows, cacheResults: cacheResults, fetchDependencies: fetchDependencies, debug: debug, success: success, error: error });
|
|
713
|
+
}
|
|
714
|
+
if (requestMethod === C6Constants.DELETE) {
|
|
715
|
+
var normalized_2 = (_a = {},
|
|
716
|
+
_a[C6Constants.DELETE] = true,
|
|
717
|
+
_a.WHERE = tslib.__assign({}, pkValues),
|
|
718
|
+
_a);
|
|
719
|
+
return tslib.__assign(tslib.__assign({}, normalized_2), { dataInsertMultipleRows: dataInsertMultipleRows, cacheResults: cacheResults, fetchDependencies: fetchDependencies, debug: debug, success: success, error: error });
|
|
720
|
+
}
|
|
721
|
+
// PUT
|
|
722
|
+
var updateBody = {};
|
|
723
|
+
for (var _e = 0, _f = Object.keys(rest); _e < _f.length; _e++) {
|
|
724
|
+
var k = _f[_e];
|
|
725
|
+
// Skip special request keys if any slipped through
|
|
726
|
+
if (specialKeys.has(k))
|
|
727
|
+
continue;
|
|
728
|
+
var shortKey = resolveShortKey(k);
|
|
729
|
+
if (pkShorts.includes(shortKey))
|
|
730
|
+
continue; // don't update PK columns (short or fully qualified)
|
|
731
|
+
updateBody[shortKey] = rest[k];
|
|
732
|
+
}
|
|
733
|
+
if (Object.keys(updateBody).length === 0) {
|
|
734
|
+
throw new Error("Singular PUT request for table (".concat(restModel.TABLE_NAME, ") must include at least one non-primary field to update."));
|
|
735
|
+
}
|
|
736
|
+
var normalized = (_b = {},
|
|
737
|
+
_b[C6Constants.UPDATE] = updateBody,
|
|
738
|
+
_b.WHERE = tslib.__assign({}, pkValues),
|
|
739
|
+
_b);
|
|
740
|
+
return tslib.__assign(tslib.__assign({}, normalized), { dataInsertMultipleRows: dataInsertMultipleRows, cacheResults: cacheResults, fetchDependencies: fetchDependencies, debug: debug, success: success, error: error });
|
|
741
|
+
}
|
|
742
|
+
|
|
626
743
|
var HttpExecutor = /** @class */ (function (_super) {
|
|
627
744
|
tslib.__extends(HttpExecutor, _super);
|
|
628
745
|
function HttpExecutor() {
|
|
@@ -684,7 +801,6 @@ var HttpExecutor = /** @class */ (function (_super) {
|
|
|
684
801
|
switch (_b.label) {
|
|
685
802
|
case 0:
|
|
686
803
|
_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;
|
|
687
|
-
console.log('this.config', this.config);
|
|
688
804
|
return [4 /*yield*/, this.runLifecycleHooks("beforeProcessing", {
|
|
689
805
|
config: this.config,
|
|
690
806
|
request: this.request,
|
|
@@ -730,7 +846,7 @@ var HttpExecutor = /** @class */ (function (_super) {
|
|
|
730
846
|
query[C6.PAGINATION][C6.LIMIT] = query[C6.PAGINATION][C6.LIMIT] || 100;
|
|
731
847
|
}
|
|
732
848
|
apiRequest = function () { return tslib.__awaiter(_this, void 0, void 0, function () {
|
|
733
|
-
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;
|
|
849
|
+
var _a, debug, _b, cacheResults, dataInsertMultipleRows, success, _c, fetchDependencies, _d, error, querySerialized, cacheResult, cachingConfirmed, cacheCheck, cacheCheck, addBackPK, removedPrimaryKV, apiResponse, returnGetNextPageFunction, restRequestUri, needsConditionOrPrimaryCheck, TABLES, primaryKey, removedPkValue_1, axiosActiveRequest;
|
|
734
850
|
var _e;
|
|
735
851
|
var _this = this;
|
|
736
852
|
var _f, _g, _h, _j, _k, _l;
|
|
@@ -850,6 +966,7 @@ var HttpExecutor = /** @class */ (function (_super) {
|
|
|
850
966
|
&& primaryKey in query) {
|
|
851
967
|
restRequestUri += query[primaryKey] + '/';
|
|
852
968
|
removedPkValue_1 = query[primaryKey];
|
|
969
|
+
removedPrimaryKV = { key: primaryKey, value: removedPkValue_1 };
|
|
853
970
|
addBackPK = function () {
|
|
854
971
|
query !== null && query !== void 0 ? query : (query = {});
|
|
855
972
|
query[primaryKey] = removedPkValue_1;
|
|
@@ -878,8 +995,8 @@ var HttpExecutor = /** @class */ (function (_super) {
|
|
|
878
995
|
var baseConfig = {
|
|
879
996
|
withCredentials: withCredentials,
|
|
880
997
|
};
|
|
881
|
-
//
|
|
882
|
-
var normalizedQuery = query;
|
|
998
|
+
// Normalize singular request (GET/PUT/DELETE) into complex ORM shape
|
|
999
|
+
var normalizedQuery = normalizeSingularRequest(requestMethod, query, restModel, removedPrimaryKV);
|
|
883
1000
|
switch (requestMethod) {
|
|
884
1001
|
case GET:
|
|
885
1002
|
return [tslib.__assign(tslib.__assign({}, baseConfig), { params: normalizedQuery })];
|
|
@@ -1082,7 +1199,7 @@ var HttpExecutor = /** @class */ (function (_super) {
|
|
|
1082
1199
|
accumulator.push(row['entity_tag']);
|
|
1083
1200
|
}
|
|
1084
1201
|
return accumulator;
|
|
1085
|
-
}, []).map(function (entityTag) { return entityTag.split('\\').pop().toLowerCase(); });
|
|
1202
|
+
}, []).map(function (entityTag) { var _a, _b; return (_b = (_a = entityTag.split('\\')) === null || _a === void 0 ? void 0 : _a.pop()) === null || _b === void 0 ? void 0 : _b.toLowerCase(); });
|
|
1086
1203
|
var shouldContinue = referencesTables.find(function (referencesTable) { return tableToFetch.endsWith(referencesTable); });
|
|
1087
1204
|
if (!shouldContinue) {
|
|
1088
1205
|
console.log('%c C6ENTITY: The constraintTableName (' + tableToFetch + ') did not end with any value in referencesTables', 'color: #c00', referencesTables);
|
|
@@ -1765,122 +1882,6 @@ var UpdateQueryBuilder = /** @class */ (function (_super) {
|
|
|
1765
1882
|
return UpdateQueryBuilder;
|
|
1766
1883
|
}(PaginationBuilder));
|
|
1767
1884
|
|
|
1768
|
-
/**
|
|
1769
|
-
* Converts a singular T-shaped request into complex ORM format for GET/PUT/DELETE
|
|
1770
|
-
* Enforces that all primary keys are present for singular syntax and that the table has PKs.
|
|
1771
|
-
* Optionally accepts a previously removed primary key (key/value) to reconstruct WHERE.
|
|
1772
|
-
*/
|
|
1773
|
-
function normalizeSingularRequest(requestMethod, request, restModel, removedPrimary) {
|
|
1774
|
-
var _a, _b;
|
|
1775
|
-
var _c;
|
|
1776
|
-
if (request == null || typeof request !== 'object')
|
|
1777
|
-
return request;
|
|
1778
|
-
var specialKeys = new Set([
|
|
1779
|
-
C6Constants.SELECT,
|
|
1780
|
-
C6Constants.UPDATE,
|
|
1781
|
-
C6Constants.DELETE,
|
|
1782
|
-
C6Constants.WHERE,
|
|
1783
|
-
C6Constants.JOIN,
|
|
1784
|
-
C6Constants.PAGINATION,
|
|
1785
|
-
]);
|
|
1786
|
-
// Determine if the request is already complex (has any special key besides PAGINATION)
|
|
1787
|
-
var keys = Object.keys(request);
|
|
1788
|
-
var hasComplexKeys = keys.some(function (k) { return k !== C6Constants.PAGINATION && specialKeys.has(k); });
|
|
1789
|
-
if (hasComplexKeys)
|
|
1790
|
-
return request; // already complex
|
|
1791
|
-
// We treat it as singular when it's not complex.
|
|
1792
|
-
// For GET, PUT, DELETE only
|
|
1793
|
-
if (!(requestMethod === C6Constants.GET || requestMethod === C6Constants.PUT || requestMethod === C6Constants.DELETE)) {
|
|
1794
|
-
return request;
|
|
1795
|
-
}
|
|
1796
|
-
var pkShorts = Array.isArray(restModel.PRIMARY_SHORT) ? tslib.__spreadArray([], restModel.PRIMARY_SHORT, true) : [];
|
|
1797
|
-
var pkFulls = Array.isArray(restModel.PRIMARY) ? tslib.__spreadArray([], restModel.PRIMARY, true) : [];
|
|
1798
|
-
var resolveShortKey = function (key) {
|
|
1799
|
-
var _a;
|
|
1800
|
-
var cols = restModel.COLUMNS || {};
|
|
1801
|
-
return (_a = cols[key]) !== null && _a !== void 0 ? _a : key;
|
|
1802
|
-
};
|
|
1803
|
-
if (!pkShorts.length) {
|
|
1804
|
-
// For GET requests, do not enforce primary key presence; treat as a collection query.
|
|
1805
|
-
if (requestMethod === C6Constants.GET)
|
|
1806
|
-
return request;
|
|
1807
|
-
throw new Error("Table (".concat(restModel.TABLE_NAME, ") has no primary key; singular request syntax is not allowed."));
|
|
1808
|
-
}
|
|
1809
|
-
// Build pk map from request + possibly removed primary key (accept short or fully-qualified keys)
|
|
1810
|
-
var pkValues = {};
|
|
1811
|
-
var requestObj = request;
|
|
1812
|
-
var _loop_1 = function (pkShort) {
|
|
1813
|
-
// 1) direct short key
|
|
1814
|
-
var value = requestObj[pkShort];
|
|
1815
|
-
if (value === undefined) {
|
|
1816
|
-
// 2) fully-qualified key matching this short key (from PRIMARY list or by concatenation)
|
|
1817
|
-
var fqCandidate_1 = "".concat(restModel.TABLE_NAME, ".").concat(pkShort);
|
|
1818
|
-
var fqKey = (_c = pkFulls.find(function (fq) { return fq === fqCandidate_1 || fq.endsWith(".".concat(pkShort)); })) !== null && _c !== void 0 ? _c : fqCandidate_1;
|
|
1819
|
-
value = requestObj[fqKey];
|
|
1820
|
-
}
|
|
1821
|
-
if (value === undefined && removedPrimary) {
|
|
1822
|
-
// 3) removedPrimary may provide either short or fully-qualified key
|
|
1823
|
-
var removedKeyShort = resolveShortKey(removedPrimary.key);
|
|
1824
|
-
if (removedKeyShort === pkShort)
|
|
1825
|
-
value = removedPrimary.value;
|
|
1826
|
-
}
|
|
1827
|
-
if (value !== undefined && value !== null) {
|
|
1828
|
-
pkValues[pkShort] = value;
|
|
1829
|
-
}
|
|
1830
|
-
};
|
|
1831
|
-
for (var _i = 0, pkShorts_1 = pkShorts; _i < pkShorts_1.length; _i++) {
|
|
1832
|
-
var pkShort = pkShorts_1[_i];
|
|
1833
|
-
_loop_1(pkShort);
|
|
1834
|
-
}
|
|
1835
|
-
var missing = pkShorts.filter(function (pk) { return !(pk in pkValues); });
|
|
1836
|
-
if (missing.length) {
|
|
1837
|
-
// For GET requests, if not all PKs are provided, treat as a collection query and leave as-is.
|
|
1838
|
-
if (requestMethod === C6Constants.GET) {
|
|
1839
|
-
return request;
|
|
1840
|
-
}
|
|
1841
|
-
throw new Error("Singular request requires all primary key(s) [".concat(pkShorts.join(', '), "] for table (").concat(restModel.TABLE_NAME, "). Missing: [").concat(missing.join(', '), "]"));
|
|
1842
|
-
}
|
|
1843
|
-
// Strip API metadata that should remain at root
|
|
1844
|
-
var _d = request, dataInsertMultipleRows = _d.dataInsertMultipleRows, cacheResults = _d.cacheResults, fetchDependencies = _d.fetchDependencies, debug = _d.debug, success = _d.success, error = _d.error, rest = tslib.__rest(_d, ["dataInsertMultipleRows", "cacheResults", "fetchDependencies", "debug", "success", "error"]);
|
|
1845
|
-
if (requestMethod === C6Constants.GET) {
|
|
1846
|
-
var normalized_1 = {
|
|
1847
|
-
WHERE: tslib.__assign({}, pkValues),
|
|
1848
|
-
};
|
|
1849
|
-
// Preserve pagination if any was added previously
|
|
1850
|
-
if (request[C6Constants.PAGINATION]) {
|
|
1851
|
-
normalized_1[C6Constants.PAGINATION] = request[C6Constants.PAGINATION];
|
|
1852
|
-
}
|
|
1853
|
-
return tslib.__assign(tslib.__assign({}, normalized_1), { dataInsertMultipleRows: dataInsertMultipleRows, cacheResults: cacheResults, fetchDependencies: fetchDependencies, debug: debug, success: success, error: error });
|
|
1854
|
-
}
|
|
1855
|
-
if (requestMethod === C6Constants.DELETE) {
|
|
1856
|
-
var normalized_2 = (_a = {},
|
|
1857
|
-
_a[C6Constants.DELETE] = true,
|
|
1858
|
-
_a.WHERE = tslib.__assign({}, pkValues),
|
|
1859
|
-
_a);
|
|
1860
|
-
return tslib.__assign(tslib.__assign({}, normalized_2), { dataInsertMultipleRows: dataInsertMultipleRows, cacheResults: cacheResults, fetchDependencies: fetchDependencies, debug: debug, success: success, error: error });
|
|
1861
|
-
}
|
|
1862
|
-
// PUT
|
|
1863
|
-
var updateBody = {};
|
|
1864
|
-
for (var _e = 0, _f = Object.keys(rest); _e < _f.length; _e++) {
|
|
1865
|
-
var k = _f[_e];
|
|
1866
|
-
// Skip special request keys if any slipped through
|
|
1867
|
-
if (specialKeys.has(k))
|
|
1868
|
-
continue;
|
|
1869
|
-
var shortKey = resolveShortKey(k);
|
|
1870
|
-
if (pkShorts.includes(shortKey))
|
|
1871
|
-
continue; // don't update PK columns (short or fully qualified)
|
|
1872
|
-
updateBody[shortKey] = rest[k];
|
|
1873
|
-
}
|
|
1874
|
-
if (Object.keys(updateBody).length === 0) {
|
|
1875
|
-
throw new Error("Singular PUT request for table (".concat(restModel.TABLE_NAME, ") must include at least one non-primary field to update."));
|
|
1876
|
-
}
|
|
1877
|
-
var normalized = (_b = {},
|
|
1878
|
-
_b[C6Constants.UPDATE] = updateBody,
|
|
1879
|
-
_b.WHERE = tslib.__assign({}, pkValues),
|
|
1880
|
-
_b);
|
|
1881
|
-
return tslib.__assign(tslib.__assign({}, normalized), { dataInsertMultipleRows: dataInsertMultipleRows, cacheResults: cacheResults, fetchDependencies: fetchDependencies, debug: debug, success: success, error: error });
|
|
1882
|
-
}
|
|
1883
|
-
|
|
1884
1885
|
var SqlExecutor = /** @class */ (function (_super) {
|
|
1885
1886
|
tslib.__extends(SqlExecutor, _super);
|
|
1886
1887
|
function SqlExecutor() {
|
|
@@ -2139,6 +2140,16 @@ function ExpressHandler(_a) {
|
|
|
2139
2140
|
}); };
|
|
2140
2141
|
}
|
|
2141
2142
|
|
|
2143
|
+
function createTestServer(_a) {
|
|
2144
|
+
var C6 = _a.C6, mysqlPool = _a.mysqlPool;
|
|
2145
|
+
var app = express();
|
|
2146
|
+
app.set('query parser', 'extended');
|
|
2147
|
+
app.use(express.json());
|
|
2148
|
+
app.all("/rest/:table", ExpressHandler({ C6: C6, mysqlPool: mysqlPool }));
|
|
2149
|
+
app.all("/rest/:table/:primary", ExpressHandler({ C6: C6, mysqlPool: mysqlPool }));
|
|
2150
|
+
return app;
|
|
2151
|
+
}
|
|
2152
|
+
|
|
2142
2153
|
// Alias a table name with a given alias
|
|
2143
2154
|
var A = function (tableName, alias) {
|
|
2144
2155
|
return "".concat(tableName, " ").concat(alias);
|
|
@@ -2301,6 +2312,7 @@ exports.checkCache = checkCache;
|
|
|
2301
2312
|
exports.clearCache = clearCache;
|
|
2302
2313
|
exports.convertForRequestBody = convertForRequestBody;
|
|
2303
2314
|
exports.convertHexIfBinary = convertHexIfBinary;
|
|
2315
|
+
exports.createTestServer = createTestServer;
|
|
2304
2316
|
exports.determineRuntimeJsType = determineRuntimeJsType;
|
|
2305
2317
|
exports.distSphere = distSphere;
|
|
2306
2318
|
exports.error = error;
|