@carbonorm/carbonnode 3.6.7 → 3.7.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/README.md +15 -0
- package/dist/api/C6Constants.d.ts +2 -0
- package/dist/api/orm/queryHelpers.d.ts +2 -0
- package/dist/api/types/ormInterfaces.d.ts +4 -1
- package/dist/index.cjs.js +121 -101
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +120 -102
- package/dist/index.esm.js.map +1 -1
- package/package.json +7 -2
- package/scripts/assets/handlebars/C6.ts.handlebars +9 -41
- package/scripts/generateRestBindings.cjs +1 -1
- package/scripts/generateRestBindings.ts +1 -1
- package/scripts/setup-git-hooks.mjs +77 -0
- package/scripts/test-hooks.sh +34 -0
- package/src/api/C6Constants.ts +1 -0
- package/src/api/executors/HttpExecutor.ts +5 -2
- package/src/api/handlers/ExpressHandler.ts +1 -1
- package/src/api/orm/builders/ConditionBuilder.ts +23 -1
- package/src/api/orm/queryHelpers.ts +16 -0
- package/src/api/types/ormInterfaces.ts +6 -2
package/README.md
CHANGED
|
@@ -562,6 +562,21 @@ export default Users;
|
|
|
562
562
|
|
|
563
563
|
|
|
564
564
|
|
|
565
|
+
# Git Hooks
|
|
566
|
+
|
|
567
|
+
This project uses Git hooks to automate certain tasks:
|
|
568
|
+
|
|
569
|
+
- **pre-commit**: Builds the project before pushing to ensure only working code is pushed
|
|
570
|
+
- **post-push**: Automatically publishes to npm when the version number changes
|
|
571
|
+
|
|
572
|
+
To set up the Git hooks, run:
|
|
573
|
+
|
|
574
|
+
```bash
|
|
575
|
+
npm run hooks:setup
|
|
576
|
+
```
|
|
577
|
+
|
|
578
|
+
This will configure Git to use the hooks in the `.githooks` directory. The hooks are automatically set up when you run `npm install` as well.
|
|
579
|
+
|
|
565
580
|
# Support and Issues
|
|
566
581
|
|
|
567
582
|
Any issues found should be reported on [GitHub](https://github.com/CarbonORM/CarbonNode/issues).
|
|
@@ -100,6 +100,7 @@ export declare const C6Constants: {
|
|
|
100
100
|
ST_GEOMFROMWKB: string;
|
|
101
101
|
ST_INTERSECTS: string;
|
|
102
102
|
ST_LENGTH: string;
|
|
103
|
+
ST_MAKEENVELOPE: string;
|
|
103
104
|
ST_OVERLAPS: string;
|
|
104
105
|
ST_POINT: string;
|
|
105
106
|
ST_SETSRID: string;
|
|
@@ -254,6 +255,7 @@ export declare const C6C: {
|
|
|
254
255
|
ST_GEOMFROMWKB: string;
|
|
255
256
|
ST_INTERSECTS: string;
|
|
256
257
|
ST_LENGTH: string;
|
|
258
|
+
ST_MAKEENVELOPE: string;
|
|
257
259
|
ST_OVERLAPS: string;
|
|
258
260
|
ST_POINT: string;
|
|
259
261
|
ST_SETSRID: string;
|
|
@@ -2,3 +2,5 @@ export declare const A: (tableName: string, alias: string) => string;
|
|
|
2
2
|
export declare const F: (qualifiedCol: string, alias: string) => string;
|
|
3
3
|
export declare const fieldEq: (leftCol: string, rightCol: string, leftAlias: string, rightAlias: string) => Record<string, string>;
|
|
4
4
|
export declare const distSphere: (fromCol: string, toCol: string, fromAlias: string, toAlias: string) => any[];
|
|
5
|
+
export declare const bbox: (minLng: number, minLat: number, maxLng: number, maxLat: number) => any[];
|
|
6
|
+
export declare const stContains: (envelope: string, shape: string) => any[];
|
|
@@ -5,6 +5,7 @@ import { Modify } from "./modifyTypes";
|
|
|
5
5
|
import { JoinType, OrderDirection, SQLComparisonOperator, SQLFunction } from "./mysqlTypes";
|
|
6
6
|
import { CarbonReact } from "@carbonorm/carbonreact";
|
|
7
7
|
import { OrmGenerics } from "./ormGenerics";
|
|
8
|
+
import { restOrm } from "../restOrm";
|
|
8
9
|
export type iRestMethods = 'GET' | 'POST' | 'PUT' | 'DELETE';
|
|
9
10
|
export declare const POST = "POST";
|
|
10
11
|
export declare const PUT = "PUT";
|
|
@@ -215,7 +216,9 @@ export interface iC6Object<RestTableInterfaces extends {
|
|
|
215
216
|
[K in Extract<keyof RestTableInterfaces, string>]: C6RestfulModel<K, RestTableInterfaces[K], keyof RestTableInterfaces[K] & string>;
|
|
216
217
|
};
|
|
217
218
|
PREFIX: string;
|
|
218
|
-
|
|
219
|
+
ORM: {
|
|
220
|
+
[K in Extract<keyof RestTableInterfaces, string>]: C6RestfulModel<K, RestTableInterfaces[K], keyof RestTableInterfaces[K] & string> & ReturnType<typeof restOrm<OrmGenerics<any>>>;
|
|
221
|
+
}[];
|
|
219
222
|
[key: string]: any;
|
|
220
223
|
}
|
|
221
224
|
export interface tC6RestApi {
|
package/dist/index.cjs.js
CHANGED
|
@@ -112,6 +112,7 @@ var C6Constants = {
|
|
|
112
112
|
ST_GEOMFROMWKB: 'ST_GeomFromWKB',
|
|
113
113
|
ST_INTERSECTS: 'ST_Intersects',
|
|
114
114
|
ST_LENGTH: 'ST_Length',
|
|
115
|
+
ST_MAKEENVELOPE: 'ST_MakeEnvelope',
|
|
115
116
|
ST_OVERLAPS: 'ST_Overlaps',
|
|
116
117
|
ST_POINT: 'ST_Point',
|
|
117
118
|
ST_SETSRID: 'ST_SetSRID',
|
|
@@ -909,11 +910,11 @@ var HttpExecutor = /** @class */ (function (_super) {
|
|
|
909
910
|
// returning the promise with this then is important for tests. todo - we could make that optional.
|
|
910
911
|
// https://rapidapi.com/guides/axios-async-await
|
|
911
912
|
return [2 /*return*/, axiosActiveRequest.then(function (response) { return tslib.__awaiter(_this, void 0, void 0, function () {
|
|
912
|
-
var cacheIndex, callback, responseData_1, dependencies_1, fetchReferences_1, apiRequestPromises, _loop_1,
|
|
913
|
+
var cacheIndex, callback, responseData_1, dependencies_1, fetchReferences_1, apiRequestPromises, _loop_1, tableToFetch;
|
|
913
914
|
var _this = this;
|
|
914
|
-
var _d, _e, _f, _g
|
|
915
|
-
return tslib.__generator(this, function (
|
|
916
|
-
switch (
|
|
915
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
916
|
+
return tslib.__generator(this, function (_h) {
|
|
917
|
+
switch (_h.label) {
|
|
917
918
|
case 0:
|
|
918
919
|
// noinspection SuspiciousTypeOfGuard
|
|
919
920
|
if (typeof response.data === 'string') {
|
|
@@ -972,12 +973,12 @@ var HttpExecutor = /** @class */ (function (_super) {
|
|
|
972
973
|
else {
|
|
973
974
|
callback();
|
|
974
975
|
}
|
|
975
|
-
if (!(C6.GET === requestMethod)) return [3 /*break*/,
|
|
976
|
+
if (!(C6.GET === requestMethod)) return [3 /*break*/, 2];
|
|
976
977
|
responseData_1 = response.data;
|
|
977
|
-
returnGetNextPageFunction = 1 !== ((
|
|
978
|
-
((
|
|
978
|
+
returnGetNextPageFunction = 1 !== ((_a = query === null || query === void 0 ? void 0 : query[C6.PAGINATION]) === null || _a === void 0 ? void 0 : _a[C6.LIMIT]) &&
|
|
979
|
+
((_b = query === null || query === void 0 ? void 0 : query[C6.PAGINATION]) === null || _b === void 0 ? void 0 : _b[C6.LIMIT]) === responseData_1.rest.length;
|
|
979
980
|
if (false === isTest() || this.config.verbose) {
|
|
980
|
-
console.groupCollapsed('%c API: Response (' + requestMethod + ' ' + tableName + ') returned length (' + ((
|
|
981
|
+
console.groupCollapsed('%c API: Response (' + requestMethod + ' ' + tableName + ') returned length (' + ((_c = responseData_1.rest) === null || _c === void 0 ? void 0 : _c.length) + ') of possible (' + ((_d = query === null || query === void 0 ? void 0 : query[C6.PAGINATION]) === null || _d === void 0 ? void 0 : _d[C6.LIMIT]) + ') limit!', 'color: #0c0');
|
|
981
982
|
console.log('%c ' + requestMethod + ' ' + tableName, 'color: #0c0');
|
|
982
983
|
console.log('%c Request Data (note you may see the success and/or error prompt):', 'color: #0c0', this.request);
|
|
983
984
|
console.log('%c Response Data:', 'color: #0c0', responseData_1.rest);
|
|
@@ -992,12 +993,12 @@ var HttpExecutor = /** @class */ (function (_super) {
|
|
|
992
993
|
responseData_1.next = undefined;
|
|
993
994
|
if (true === debug
|
|
994
995
|
&& isLocal()) {
|
|
995
|
-
reactToastify.toast.success("DEVS: Response returned length (" + ((
|
|
996
|
+
reactToastify.toast.success("DEVS: Response returned length (" + ((_e = responseData_1.rest) === null || _e === void 0 ? void 0 : _e.length) + ") less than limit (" + ((_f = query === null || query === void 0 ? void 0 : query[C6.PAGINATION]) === null || _f === void 0 ? void 0 : _f[C6.LIMIT]) + ").", toastOptionsDevs);
|
|
996
997
|
}
|
|
997
998
|
}
|
|
998
999
|
if (!(fetchDependencies
|
|
999
1000
|
&& 'number' === typeof fetchDependencies
|
|
1000
|
-
&& responseData_1.rest.length > 0)) return [3 /*break*/,
|
|
1001
|
+
&& responseData_1.rest.length > 0)) return [3 /*break*/, 2];
|
|
1001
1002
|
console.groupCollapsed('%c API: Fetch Dependencies segment (' + requestMethod + ' ' + tableName + ')'
|
|
1002
1003
|
+ (fetchDependencies & exports.eFetchDependencies.CHILDREN ? ' | (CHILDREN|REFERENCED) ' : '')
|
|
1003
1004
|
+ (fetchDependencies & exports.eFetchDependencies.PARENTS ? ' | (PARENTS|REFERENCED_BY)' : '')
|
|
@@ -1068,97 +1069,77 @@ var HttpExecutor = /** @class */ (function (_super) {
|
|
|
1068
1069
|
}); });
|
|
1069
1070
|
console.log('fetchReferences', fetchReferences_1);
|
|
1070
1071
|
_loop_1 = function (tableToFetch) {
|
|
1071
|
-
var
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
console.log('%c C6ENTITY: The constraintTableName (' + tableToFetch + ') did not end with any value in referencesTables', 'color: #c00', referencesTables);
|
|
1088
|
-
return [2 /*return*/, "continue"];
|
|
1089
|
-
}
|
|
1090
|
-
console.log('%c C6ENTITY: The constraintTableName (' + tableToFetch + ') will be fetched.', 'color: #0c0');
|
|
1091
|
-
}
|
|
1092
|
-
return [4 /*yield*/, C6.IMPORT(tableToFetch)];
|
|
1093
|
-
case 1:
|
|
1094
|
-
fetchTable = _m.sent();
|
|
1095
|
-
RestApi = fetchTable.default;
|
|
1096
|
-
console.log('%c Fetch Dependencies will select (' + tableToFetch + ') using GET request', 'color: #33ccff');
|
|
1097
|
-
nextFetchDependencies = exports.eFetchDependencies.NONE;
|
|
1098
|
-
if (fetchDependencies & exports.eFetchDependencies.RECURSIVE) {
|
|
1099
|
-
if (fetchDependencies & exports.eFetchDependencies.ALL) {
|
|
1100
|
-
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.');
|
|
1101
|
-
}
|
|
1102
|
-
nextFetchDependencies = fetchDependencies;
|
|
1103
|
-
}
|
|
1104
|
-
else if (fetchDependencies & exports.eFetchDependencies.C6ENTITY) {
|
|
1105
|
-
if (tableToFetch === "carbon_carbons") {
|
|
1106
|
-
nextFetchDependencies = fetchDependencies;
|
|
1107
|
-
}
|
|
1108
|
-
else {
|
|
1109
|
-
nextFetchDependencies = fetchDependencies ^ exports.eFetchDependencies.C6ENTITY;
|
|
1110
|
-
}
|
|
1111
|
-
}
|
|
1112
|
-
console.log('fetchReferences', fetchReferences_1[tableToFetch], "Current fetchDependencies for (" + operatingTable + "):", fetchDependencies, "New fetchDependencies for (" + tableToFetch + "): ", nextFetchDependencies);
|
|
1113
|
-
// 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
|
|
1114
|
-
// it not certain that they are using carbons' entities either
|
|
1115
|
-
// this is a dynamic call to the rest api, any generated table may resolve with (RestApi)
|
|
1116
|
-
// todo - using value to avoid joins.... but. maybe this should be a parameterizable option -- think race conditions; its safer to join
|
|
1117
|
-
apiRequestPromises.push(RestApi.Get((_l = {},
|
|
1118
|
-
_l[C6.WHERE] = {
|
|
1119
|
-
0: Object.keys(fetchReferences_1[tableToFetch]).reduce(function (sum, column) {
|
|
1120
|
-
fetchReferences_1[tableToFetch][column] = fetchReferences_1[tableToFetch][column].flat(Infinity);
|
|
1121
|
-
if (0 === fetchReferences_1[tableToFetch][column].length) {
|
|
1122
|
-
console.warn('The column (' + column + ') was not found in the response data. We will not fetch.', responseData_1);
|
|
1123
|
-
return false;
|
|
1124
|
-
}
|
|
1125
|
-
sum[column] = fetchReferences_1[tableToFetch][column].length === 1
|
|
1126
|
-
? fetchReferences_1[tableToFetch][column][0]
|
|
1127
|
-
: [
|
|
1128
|
-
C6.IN, fetchReferences_1[tableToFetch][column]
|
|
1129
|
-
];
|
|
1130
|
-
return sum;
|
|
1131
|
-
}, {})
|
|
1132
|
-
},
|
|
1133
|
-
_l.fetchDependencies = nextFetchDependencies,
|
|
1134
|
-
_l)));
|
|
1135
|
-
return [2 /*return*/];
|
|
1072
|
+
var _j;
|
|
1073
|
+
if (fetchDependencies & exports.eFetchDependencies.C6ENTITY
|
|
1074
|
+
&& 'string' === typeof tableName
|
|
1075
|
+
&& tableName.endsWith("carbon_carbons")) {
|
|
1076
|
+
// todo - rethink the table ref entity system - when tables are renamed? no hooks exist in mysql
|
|
1077
|
+
// since were already filtering on column, we can assume the first row constraint is the same as the rest
|
|
1078
|
+
var referencesTables = responseData_1.rest.reduce(function (accumulator, row) {
|
|
1079
|
+
if ('entity_tag' in row && !accumulator.includes(row['entity_tag'])) {
|
|
1080
|
+
accumulator.push(row['entity_tag']);
|
|
1081
|
+
}
|
|
1082
|
+
return accumulator;
|
|
1083
|
+
}, []).map(function (entityTag) { return entityTag.split('\\').pop().toLowerCase(); });
|
|
1084
|
+
var shouldContinue = referencesTables.find(function (referencesTable) { return tableToFetch.endsWith(referencesTable); });
|
|
1085
|
+
if (!shouldContinue) {
|
|
1086
|
+
console.log('%c C6ENTITY: The constraintTableName (' + tableToFetch + ') did not end with any value in referencesTables', 'color: #c00', referencesTables);
|
|
1087
|
+
return "continue";
|
|
1136
1088
|
}
|
|
1137
|
-
|
|
1089
|
+
console.log('%c C6ENTITY: The constraintTableName (' + tableToFetch + ') will be fetched.', 'color: #0c0');
|
|
1090
|
+
}
|
|
1091
|
+
var ormKey = tableToFetch
|
|
1092
|
+
.split('_')
|
|
1093
|
+
.map(function (part) { return part.charAt(0).toUpperCase() + part.slice(1); })
|
|
1094
|
+
.join('_');
|
|
1095
|
+
var RestApi = (_g = C6.ORM[ormKey]) !== null && _g !== void 0 ? _g : new Error("Fetch Dependencies could not fund table (".concat(ormKey, ") in the set \u2209 [ ").concat(Object.keys(C6.ORM).join(', '), " ]"));
|
|
1096
|
+
console.log('%c Fetch Dependencies will select (' + tableToFetch + ') using GET request', 'color: #33ccff');
|
|
1097
|
+
var nextFetchDependencies = exports.eFetchDependencies.NONE;
|
|
1098
|
+
if (fetchDependencies & exports.eFetchDependencies.RECURSIVE) {
|
|
1099
|
+
if (fetchDependencies & exports.eFetchDependencies.ALL) {
|
|
1100
|
+
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.');
|
|
1101
|
+
}
|
|
1102
|
+
nextFetchDependencies = fetchDependencies;
|
|
1103
|
+
}
|
|
1104
|
+
else if (fetchDependencies & exports.eFetchDependencies.C6ENTITY) {
|
|
1105
|
+
if (tableToFetch === "carbon_carbons") {
|
|
1106
|
+
nextFetchDependencies = fetchDependencies;
|
|
1107
|
+
}
|
|
1108
|
+
else {
|
|
1109
|
+
nextFetchDependencies = fetchDependencies ^ exports.eFetchDependencies.C6ENTITY;
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
console.log('fetchReferences', fetchReferences_1[tableToFetch], "Current fetchDependencies for (" + operatingTable + "):", fetchDependencies, "New fetchDependencies for (" + tableToFetch + "): ", nextFetchDependencies);
|
|
1113
|
+
// 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
|
|
1114
|
+
// it not certain that they are using carbons' entities either
|
|
1115
|
+
// this is a dynamic call to the rest api, any generated table may resolve with (RestApi)
|
|
1116
|
+
// todo - using value to avoid joins.... but. maybe this should be a parameterizable option -- think race conditions; its safer to join
|
|
1117
|
+
apiRequestPromises.push(RestApi.Get((_j = {},
|
|
1118
|
+
_j[C6.WHERE] = {
|
|
1119
|
+
0: Object.keys(fetchReferences_1[tableToFetch]).reduce(function (sum, column) {
|
|
1120
|
+
fetchReferences_1[tableToFetch][column] = fetchReferences_1[tableToFetch][column].flat(Infinity);
|
|
1121
|
+
if (0 === fetchReferences_1[tableToFetch][column].length) {
|
|
1122
|
+
console.warn('The column (' + column + ') was not found in the response data. We will not fetch.', responseData_1);
|
|
1123
|
+
return false;
|
|
1124
|
+
}
|
|
1125
|
+
sum[column] = fetchReferences_1[tableToFetch][column].length === 1
|
|
1126
|
+
? fetchReferences_1[tableToFetch][column][0]
|
|
1127
|
+
: [
|
|
1128
|
+
C6.IN, fetchReferences_1[tableToFetch][column]
|
|
1129
|
+
];
|
|
1130
|
+
return sum;
|
|
1131
|
+
}, {})
|
|
1132
|
+
},
|
|
1133
|
+
_j.fetchDependencies = nextFetchDependencies,
|
|
1134
|
+
_j)));
|
|
1138
1135
|
};
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
_b.push(_c);
|
|
1143
|
-
_i = 0;
|
|
1144
|
-
_k.label = 1;
|
|
1145
|
-
case 1:
|
|
1146
|
-
if (!(_i < _b.length)) return [3 /*break*/, 4];
|
|
1147
|
-
_c = _b[_i];
|
|
1148
|
-
if (!(_c in _a)) return [3 /*break*/, 3];
|
|
1149
|
-
tableToFetch = _c;
|
|
1150
|
-
return [5 /*yield**/, _loop_1(tableToFetch)];
|
|
1151
|
-
case 2:
|
|
1152
|
-
_k.sent();
|
|
1153
|
-
_k.label = 3;
|
|
1154
|
-
case 3:
|
|
1155
|
-
_i++;
|
|
1156
|
-
return [3 /*break*/, 1];
|
|
1157
|
-
case 4:
|
|
1136
|
+
for (tableToFetch in fetchReferences_1) {
|
|
1137
|
+
_loop_1(tableToFetch);
|
|
1138
|
+
}
|
|
1158
1139
|
console.groupEnd();
|
|
1159
1140
|
return [4 /*yield*/, Promise.all(apiRequestPromises)];
|
|
1160
|
-
case
|
|
1161
|
-
|
|
1141
|
+
case 1:
|
|
1142
|
+
_h.sent();
|
|
1162
1143
|
apiRequestPromises.map(function (promise) { return tslib.__awaiter(_this, void 0, void 0, function () {
|
|
1163
1144
|
var _a, _b;
|
|
1164
1145
|
return tslib.__generator(this, function (_c) {
|
|
@@ -1176,8 +1157,8 @@ var HttpExecutor = /** @class */ (function (_super) {
|
|
|
1176
1157
|
}
|
|
1177
1158
|
});
|
|
1178
1159
|
}); });
|
|
1179
|
-
|
|
1180
|
-
case
|
|
1160
|
+
_h.label = 2;
|
|
1161
|
+
case 2:
|
|
1181
1162
|
if (debug && isLocal()) {
|
|
1182
1163
|
reactToastify.toast.success("DEVS: (" + requestMethod + ") request complete.", toastOptionsDevs);
|
|
1183
1164
|
}
|
|
@@ -1279,7 +1260,16 @@ var ConditionBuilder = /** @class */ (function (_super) {
|
|
|
1279
1260
|
C6C.IS, C6C.IS_NOT,
|
|
1280
1261
|
C6C.BETWEEN, 'NOT BETWEEN',
|
|
1281
1262
|
C6C.MATCH_AGAINST,
|
|
1282
|
-
C6C.ST_DISTANCE_SPHERE
|
|
1263
|
+
C6C.ST_DISTANCE_SPHERE,
|
|
1264
|
+
// spatial predicates
|
|
1265
|
+
C6C.ST_CONTAINS,
|
|
1266
|
+
C6C.ST_INTERSECTS,
|
|
1267
|
+
C6C.ST_WITHIN,
|
|
1268
|
+
C6C.ST_CROSSES,
|
|
1269
|
+
C6C.ST_DISJOINT,
|
|
1270
|
+
C6C.ST_EQUALS,
|
|
1271
|
+
C6C.ST_OVERLAPS,
|
|
1272
|
+
C6C.ST_TOUCHES
|
|
1283
1273
|
]);
|
|
1284
1274
|
return _this;
|
|
1285
1275
|
}
|
|
@@ -1361,6 +1351,19 @@ var ConditionBuilder = /** @class */ (function (_super) {
|
|
|
1361
1351
|
var threshold = Array.isArray(value) ? value[0] : value;
|
|
1362
1352
|
return "ST_Distance_Sphere(".concat(col1, ", ").concat(col2, ") < ").concat(_this.addParam(params, '', threshold));
|
|
1363
1353
|
}
|
|
1354
|
+
if ([
|
|
1355
|
+
C6C.ST_CONTAINS,
|
|
1356
|
+
C6C.ST_INTERSECTS,
|
|
1357
|
+
C6C.ST_WITHIN,
|
|
1358
|
+
C6C.ST_CROSSES,
|
|
1359
|
+
C6C.ST_DISJOINT,
|
|
1360
|
+
C6C.ST_EQUALS,
|
|
1361
|
+
C6C.ST_OVERLAPS,
|
|
1362
|
+
C6C.ST_TOUCHES
|
|
1363
|
+
].includes(column)) {
|
|
1364
|
+
var geom1 = op[0], geom2 = op[1];
|
|
1365
|
+
return "".concat(column, "(").concat(geom1, ", ").concat(geom2, ")");
|
|
1366
|
+
}
|
|
1364
1367
|
}
|
|
1365
1368
|
var leftIsCol = _this.isColumnRef(column);
|
|
1366
1369
|
var leftIsRef = _this.isTableReference(column);
|
|
@@ -1925,7 +1928,7 @@ function ExpressHandler(_a) {
|
|
|
1925
1928
|
payload[C6C.WHERE][primaryKeyName] = primary;
|
|
1926
1929
|
}
|
|
1927
1930
|
else {
|
|
1928
|
-
res.status(400).json({ error: "Invalid request: ".concat(method, " requires a primary key.") });
|
|
1931
|
+
res.status(400).json({ error: "Invalid request: ".concat(method, " requires a primary key (").concat(primaryKeyName, ").") });
|
|
1929
1932
|
}
|
|
1930
1933
|
break;
|
|
1931
1934
|
case 'POST':
|
|
@@ -1974,6 +1977,21 @@ var fieldEq = function (leftCol, rightCol, leftAlias, rightAlias) {
|
|
|
1974
1977
|
var distSphere = function (fromCol, toCol, fromAlias, toAlias) {
|
|
1975
1978
|
return [C6C.ST_DISTANCE_SPHERE, F(fromCol, fromAlias), F(toCol, toAlias)];
|
|
1976
1979
|
};
|
|
1980
|
+
// Build a bounding-box expression.
|
|
1981
|
+
//
|
|
1982
|
+
// Arguments must be provided in `(minLng, minLat, maxLng, maxLat)` order. The
|
|
1983
|
+
// helper does not attempt to swap or validate coordinates; if a minimum value
|
|
1984
|
+
// is greater than its corresponding maximum value, MySQL's `ST_MakeEnvelope`
|
|
1985
|
+
// returns `NULL`.
|
|
1986
|
+
var bbox = function (minLng, minLat, maxLng, maxLat) {
|
|
1987
|
+
return [C6C.ST_SRID, [C6C.ST_MAKEENVELOPE,
|
|
1988
|
+
[C6C.ST_POINT, minLng, minLat],
|
|
1989
|
+
[C6C.ST_POINT, maxLng, maxLat]], 4326];
|
|
1990
|
+
};
|
|
1991
|
+
// ST_Contains for map envelope/shape queries
|
|
1992
|
+
var stContains = function (envelope, shape) {
|
|
1993
|
+
return [C6C.ST_CONTAINS, envelope, shape];
|
|
1994
|
+
};
|
|
1977
1995
|
|
|
1978
1996
|
function determineRuntimeJsType(mysqlType) {
|
|
1979
1997
|
var base = mysqlType.toLowerCase().split('(')[0];
|
|
@@ -2096,6 +2114,7 @@ exports.SqlExecutor = SqlExecutor;
|
|
|
2096
2114
|
exports.TestRestfulResponse = TestRestfulResponse;
|
|
2097
2115
|
exports.UpdateQueryBuilder = UpdateQueryBuilder;
|
|
2098
2116
|
exports.axiosInstance = axiosInstance;
|
|
2117
|
+
exports.bbox = bbox;
|
|
2099
2118
|
exports.checkAllRequestsComplete = checkAllRequestsComplete;
|
|
2100
2119
|
exports.checkCache = checkCache;
|
|
2101
2120
|
exports.clearCache = clearCache;
|
|
@@ -2120,6 +2139,7 @@ exports.removePrefixIfExists = removePrefixIfExists;
|
|
|
2120
2139
|
exports.restOrm = restOrm;
|
|
2121
2140
|
exports.restRequest = restRequest;
|
|
2122
2141
|
exports.sortAndSerializeQueryObject = sortAndSerializeQueryObject;
|
|
2142
|
+
exports.stContains = stContains;
|
|
2123
2143
|
exports.timeout = timeout;
|
|
2124
2144
|
exports.toastOptions = toastOptions;
|
|
2125
2145
|
exports.toastOptionsDevs = toastOptionsDevs;
|