@carbonorm/carbonnode 3.1.2 → 3.2.0

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.
@@ -1,10 +1,10 @@
1
1
  import { OrmGenerics } from "../types/ormGenerics";
2
- import { apiReturn, DetermineResponseDataType, iRest, iRestReactiveLifecycle, RequestQueryBody } from "../types/ormInterfaces";
2
+ import { DetermineResponseDataType, iRest, iRestReactiveLifecycle, RequestQueryBody } from "../types/ormInterfaces";
3
3
  export declare abstract class Executor<G extends OrmGenerics> {
4
4
  protected config: iRest<G['RestShortTableName'], G['RestTableInterface'], G['PrimaryKey']>;
5
5
  protected request: RequestQueryBody<G['RequestMethod'], G['RestTableInterface'], G['CustomAndRequiredFields'], G['RequestTableOverrides']>;
6
6
  protected useNamedParams: boolean;
7
7
  constructor(config: iRest<G['RestShortTableName'], G['RestTableInterface'], G['PrimaryKey']>, request: RequestQueryBody<G['RequestMethod'], G['RestTableInterface'], G['CustomAndRequiredFields'], G['RequestTableOverrides']>, useNamedParams?: boolean);
8
- abstract execute(): Promise<apiReturn<DetermineResponseDataType<G['RequestMethod'], G['RestTableInterface']>>>;
8
+ abstract execute(): Promise<DetermineResponseDataType<G['RequestMethod'], G['RestTableInterface']>>;
9
9
  runLifecycleHooks<Phase extends keyof iRestReactiveLifecycle<G>>(phase: Phase, args: Parameters<NonNullable<iRestReactiveLifecycle<G>[Phase]>[string]>[0]): Promise<void>;
10
10
  }
@@ -1,10 +1,10 @@
1
1
  import { AxiosResponse } from "axios";
2
2
  import { OrmGenerics } from "../types/ormGenerics";
3
- import { apiReturn, DetermineResponseDataType, RequestQueryBody } from "../types/ormInterfaces";
3
+ import { DetermineResponseDataType, RequestQueryBody } from "../types/ormInterfaces";
4
4
  import { Executor } from "./Executor";
5
5
  export declare class HttpExecutor<G extends OrmGenerics> extends Executor<G> {
6
6
  putState(response: AxiosResponse<DetermineResponseDataType<G['RequestMethod'], G['RestTableInterface']>>, request: RequestQueryBody<G['RequestMethod'], G['RestTableInterface'], G['CustomAndRequiredFields'], G['RequestTableOverrides']>, callback: () => void): void;
7
7
  postState(response: AxiosResponse<DetermineResponseDataType<G['RequestMethod'], G['RestTableInterface']>>, request: RequestQueryBody<G['RequestMethod'], G['RestTableInterface'], G['CustomAndRequiredFields'], G['RequestTableOverrides']>, callback: () => void): void;
8
8
  deleteState(_response: AxiosResponse<DetermineResponseDataType<G['RequestMethod'], G['RestTableInterface']>>, request: RequestQueryBody<G['RequestMethod'], G['RestTableInterface'], G['CustomAndRequiredFields'], G['RequestTableOverrides']>, callback: () => void): void;
9
- execute(): Promise<apiReturn<DetermineResponseDataType<G['RequestMethod'], G['RestTableInterface']>>>;
9
+ execute(): Promise<DetermineResponseDataType<G['RequestMethod'], G['RestTableInterface']>>;
10
10
  }
@@ -1,9 +1,9 @@
1
1
  import { OrmGenerics } from "../types/ormGenerics";
2
- import { apiReturn, DetermineResponseDataType } from "../types/ormInterfaces";
2
+ import { DetermineResponseDataType } from "../types/ormInterfaces";
3
3
  import { ResultSetHeader } from 'mysql2/promise';
4
4
  import { Executor } from "./Executor";
5
5
  export declare class SqlExecutor<G extends OrmGenerics> extends Executor<G> {
6
- execute(): Promise<apiReturn<DetermineResponseDataType<G['RequestMethod'], G['RestTableInterface']>>>;
6
+ execute(): Promise<DetermineResponseDataType<G['RequestMethod'], G['RestTableInterface']>>;
7
7
  private withConnection;
8
8
  serialize: (row: any) => {
9
9
  [k: string]: unknown;
@@ -1,8 +1,8 @@
1
1
  import { OrmGenerics } from "../../types/ormGenerics";
2
- import { apiReturn, DetermineResponseDataType } from "../../types/ormInterfaces";
2
+ import { DetermineResponseDataType } from "../../types/ormInterfaces";
3
3
  import { AggregateBuilder } from "./AggregateBuilder";
4
4
  export declare class ConditionBuilder<G extends OrmGenerics> extends AggregateBuilder<G> {
5
- execute(): Promise<apiReturn<DetermineResponseDataType<G['RequestMethod'], G['RestTableInterface']>>>;
5
+ execute(): Promise<DetermineResponseDataType<G['RequestMethod'], G['RestTableInterface']>>;
6
6
  private readonly OPERATORS;
7
7
  private validateOperator;
8
8
  private addParam;
@@ -1,5 +1,18 @@
1
1
  import { OrmGenerics } from "../../types/ormGenerics";
2
2
  import { JoinBuilder } from "./JoinBuilder";
3
3
  export declare class PaginationBuilder<G extends OrmGenerics> extends JoinBuilder<G> {
4
+ /**
5
+ * MySQL ORDER/LIMIT/OFFSET generator.
6
+ *
7
+ * Accepted structures:
8
+ * ```ts
9
+ * ORDER: {
10
+ * // simple column with direction
11
+ * [property_units.UNIT_ID]: "DESC",
12
+ * // function call (array of arguments)
13
+ * [C6Constants.ST_DISTANCE_SPHERE]: [property_units.LOCATION, F(property_units.LOCATION, "pu_target")]
14
+ * }
15
+ * ```
16
+ */
4
17
  buildPaginationClause(pagination: any): string;
5
18
  }
@@ -1,5 +1,5 @@
1
1
  import { OrmGenerics } from "./types/ormGenerics";
2
2
  import { iRest } from "./types/ormInterfaces";
3
3
  export declare function restOrm<G extends Omit<OrmGenerics, "requestMethod">>(config: () => Omit<iRest<G['RestShortTableName'], G['RestTableInterface'], G['PrimaryKey']>, "requestMethod">): {
4
- [k: string]: (request: import("./types/ormInterfaces").RequestQueryBody<G["RequestMethod"], G["RestTableInterface"], G["CustomAndRequiredFields"], G["RequestTableOverrides"]>) => Promise<import("./types/ormInterfaces").apiReturn<import("./types/ormInterfaces").DetermineResponseDataType<G["RequestMethod"], G["RestTableInterface"]>>>;
4
+ [k: string]: (request: import("./types/ormInterfaces").RequestQueryBody<G["RequestMethod"], G["RestTableInterface"], G["CustomAndRequiredFields"], G["RequestTableOverrides"]>) => Promise<import("./types/ormInterfaces").DetermineResponseDataType<G["RequestMethod"], G["RestTableInterface"]>>;
5
5
  };
@@ -1,6 +1,6 @@
1
1
  import { OrmGenerics } from "./types/ormGenerics";
2
- import { apiReturn, DetermineResponseDataType, iRest, RequestQueryBody } from "./types/ormInterfaces";
2
+ import { DetermineResponseDataType, iRest, RequestQueryBody } from "./types/ormInterfaces";
3
3
  /**
4
4
  * Facade: routes API calls to SQL or HTTP executors based on runtime context.
5
5
  */
6
- export default function restRequest<G extends OrmGenerics>(configX: (() => iRest<G['RestTableInterface'], G['RestShortTableName'], G['PrimaryKey']>) | iRest<G['RestShortTableName'], G['RestTableInterface'], G['PrimaryKey']>): (request: RequestQueryBody<G["RequestMethod"], G["RestTableInterface"], G["CustomAndRequiredFields"], G["RequestTableOverrides"]>) => Promise<apiReturn<DetermineResponseDataType<G["RequestMethod"], G["RestTableInterface"]>>>;
6
+ export default function restRequest<G extends OrmGenerics>(configX: (() => iRest<G['RestTableInterface'], G['RestShortTableName'], G['PrimaryKey']>) | iRest<G['RestShortTableName'], G['RestTableInterface'], G['PrimaryKey']>): (request: RequestQueryBody<G["RequestMethod"], G["RestTableInterface"], G["CustomAndRequiredFields"], G["RequestTableOverrides"]>) => Promise<DetermineResponseDataType<G["RequestMethod"], G["RestTableInterface"]>>;
@@ -71,7 +71,7 @@ export type iAPI<T extends {
71
71
  }> = T & {
72
72
  dataInsertMultipleRows?: T[];
73
73
  cacheResults?: boolean;
74
- fetchDependencies?: number | eFetchDependencies | Awaited<apiReturn<iGetC6RestResponse<any>>>[];
74
+ fetchDependencies?: number | eFetchDependencies | Awaited<iGetC6RestResponse<any>>[];
75
75
  debug?: boolean;
76
76
  success?: string | ((r: AxiosResponse) => string | void);
77
77
  error?: string | ((r: AxiosResponse) => string | void);
@@ -106,11 +106,14 @@ export interface iC6RestResponse<RestData> {
106
106
  session?: any;
107
107
  sql?: any;
108
108
  }
109
- export type iGetC6RestResponse<ResponseDataType, ResponseDataOverrides = {}> = iC6RestResponse<Modify<ResponseDataType, ResponseDataOverrides> | Modify<ResponseDataType, ResponseDataOverrides>[]>;
110
- export type apiReturn<Response> = null | undefined | Response | (Response extends iPutC6RestResponse | iDeleteC6RestResponse | iPostC6RestResponse ? null : () => apiReturn<Response>);
109
+ export interface iGetC6RestResponse<ResponseDataType extends {
110
+ [key: string]: any;
111
+ }, ResponseDataOverrides = {}> extends iC6RestResponse<Modify<ResponseDataType, ResponseDataOverrides> | Modify<ResponseDataType, ResponseDataOverrides>[]> {
112
+ next?: () => Promise<DetermineResponseDataType<"GET", ResponseDataType, ResponseDataOverrides>>;
113
+ }
111
114
  export type DetermineResponseDataType<Method extends iRestMethods, RestTableInterface extends {
112
115
  [key: string]: any;
113
- }> = Method extends 'POST' ? iPostC6RestResponse<RestTableInterface> : Method extends 'GET' ? iGetC6RestResponse<RestTableInterface> : Method extends 'PUT' ? iPutC6RestResponse<RestTableInterface> : Method extends 'DELETE' ? iDeleteC6RestResponse<RestTableInterface> : never;
116
+ }, ResponseDataOverrides = {}> = null | undefined | (Method extends 'POST' ? iPostC6RestResponse<RestTableInterface> : Method extends 'GET' ? iGetC6RestResponse<RestTableInterface, ResponseDataOverrides> : Method extends 'PUT' ? iPutC6RestResponse<RestTableInterface> : Method extends 'DELETE' ? iDeleteC6RestResponse<RestTableInterface> : never);
114
117
  export interface iRest<RestShortTableName extends string = any, RestTableInterface extends Record<string, any> = any, PrimaryKey extends keyof RestTableInterface & string = keyof RestTableInterface & string> {
115
118
  C6: iC6Object;
116
119
  axios?: AxiosInstance;
@@ -193,10 +196,10 @@ export interface iDynamicApiImport<RestData extends {
193
196
  export interface iRestApiFunctions<RestData extends {
194
197
  [key: string]: any;
195
198
  } = any> {
196
- Delete: (request?: RequestQueryBody<'DELETE', RestData>) => apiReturn<iDeleteC6RestResponse<RestData>>;
197
- Post: (request?: RequestQueryBody<'POST', RestData>) => apiReturn<iPostC6RestResponse<RestData>>;
198
- Get: (request?: RequestQueryBody<'GET', RestData>) => apiReturn<iGetC6RestResponse<RestData>>;
199
- Put: (request?: RequestQueryBody<'PUT', RestData>) => apiReturn<iPutC6RestResponse<RestData>>;
199
+ Delete: (request?: RequestQueryBody<'DELETE', RestData>) => iDeleteC6RestResponse<RestData>;
200
+ Post: (request?: RequestQueryBody<'POST', RestData>) => iPostC6RestResponse<RestData>;
201
+ Get: (request?: RequestQueryBody<'GET', RestData>) => iGetC6RestResponse<RestData>;
202
+ Put: (request?: RequestQueryBody<'PUT', RestData>) => iPutC6RestResponse<RestData>;
200
203
  }
201
204
  export interface iC6Object<RestShortTableName extends string = any, RestTableInterface extends {
202
205
  [key: string]: any;
package/dist/index.cjs.js CHANGED
@@ -899,9 +899,9 @@ var HttpExecutor = /** @class */ (function (_super) {
899
899
  return [2 /*return*/, axiosActiveRequest.then(function (response) { return tslib.__awaiter(_this, void 0, void 0, function () {
900
900
  var cacheIndex, callback, responseData_1, dependencies_1, fetchReferences_1, apiRequestPromises, _loop_1, _a, _b, _c, _i, tableToFetch;
901
901
  var _this = this;
902
- var _d, _e, _f, _g, _h, _j, _k;
903
- return tslib.__generator(this, function (_l) {
904
- switch (_l.label) {
902
+ var _d, _e, _f, _g, _h, _j;
903
+ return tslib.__generator(this, function (_k) {
904
+ switch (_k.label) {
905
905
  case 0:
906
906
  // noinspection SuspiciousTypeOfGuard
907
907
  if (typeof response.data === 'string') {
@@ -913,6 +913,7 @@ var HttpExecutor = /** @class */ (function (_super) {
913
913
  }
914
914
  if (cachingConfirmed) {
915
915
  cacheIndex = exports.apiRequestCache.findIndex(function (cache) { return cache.requestArgumentsSerialized === querySerialized; });
916
+ // TODO - currently nonthing is setting this correctly
916
917
  exports.apiRequestCache[cacheIndex].final = false === returnGetNextPageFunction;
917
918
  // only cache get method requests
918
919
  exports.apiRequestCache[cacheIndex].response = response;
@@ -938,7 +939,7 @@ var HttpExecutor = /** @class */ (function (_super) {
938
939
  if (undefined !== reactBootstrap && response) {
939
940
  switch (requestMethod) {
940
941
  case GET:
941
- reactBootstrap.updateRestfulObjectArrays({
942
+ response.data && reactBootstrap.updateRestfulObjectArrays({
942
943
  dataOrCallback: Array.isArray(response.data.rest) ? response.data.rest : [response.data.rest],
943
944
  stateKey: this.config.restModel.TABLE_NAME,
944
945
  uniqueObjectId: this.config.restModel.PRIMARY_SHORT,
@@ -968,14 +969,19 @@ var HttpExecutor = /** @class */ (function (_super) {
968
969
  console.log('%c ' + requestMethod + ' ' + tableName, 'color: #0c0');
969
970
  console.log('%c Request Data (note you may see the success and/or error prompt):', 'color: #0c0', this.request);
970
971
  console.log('%c Response Data:', 'color: #0c0', responseData_1.rest);
971
- 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);
972
+ console.log('%c Will return get next page function:' + (returnGetNextPageFunction ? '' : ' (Will not return with explicit limit 1 set)'), 'color: #0c0', true === returnGetNextPageFunction);
972
973
  console.trace();
973
974
  console.groupEnd();
974
975
  }
975
- if (false === returnGetNextPageFunction
976
- && true === debug
977
- && isLocal()) {
978
- reactToastify.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);
976
+ if (false === returnGetNextPageFunction) {
977
+ responseData_1.next = apiRequest;
978
+ }
979
+ else {
980
+ responseData_1.next = undefined;
981
+ if (true === debug
982
+ && isLocal()) {
983
+ reactToastify.toast.success("DEVS: Response returned length (" + ((_h = responseData_1.rest) === null || _h === void 0 ? void 0 : _h.length) + ") less than limit (" + ((_j = query === null || query === void 0 ? void 0 : query[C6.PAGINATION]) === null || _j === void 0 ? void 0 : _j[C6.LIMIT]) + ").", toastOptionsDevs);
984
+ }
979
985
  }
980
986
  if (!(fetchDependencies
981
987
  && 'number' === typeof fetchDependencies
@@ -989,6 +995,7 @@ var HttpExecutor = /** @class */ (function (_super) {
989
995
  console.trace(); // hidden in collapsed group
990
996
  console.groupEnd();
991
997
  dependencies_1 = {};
998
+ // Remember this is a binary bitwise operation, so we can check for multiple dependencies at once
992
999
  if (fetchDependencies & exports.eFetchDependencies.C6ENTITY) {
993
1000
  dependencies_1 = operatingTable.endsWith("carbon_carbons")
994
1001
  ? tslib.__assign(tslib.__assign({}, fetchDependencies & exports.eFetchDependencies.CHILDREN // REFERENCED === CHILDREN
@@ -1050,9 +1057,9 @@ var HttpExecutor = /** @class */ (function (_super) {
1050
1057
  console.log('fetchReferences', fetchReferences_1);
1051
1058
  _loop_1 = function (tableToFetch) {
1052
1059
  var referencesTables, shouldContinue, fetchTable, RestApi, nextFetchDependencies;
1053
- var _m;
1054
- return tslib.__generator(this, function (_o) {
1055
- switch (_o.label) {
1060
+ var _l;
1061
+ return tslib.__generator(this, function (_m) {
1062
+ switch (_m.label) {
1056
1063
  case 0:
1057
1064
  if (fetchDependencies & exports.eFetchDependencies.C6ENTITY
1058
1065
  && 'string' === typeof tableName
@@ -1072,7 +1079,7 @@ var HttpExecutor = /** @class */ (function (_super) {
1072
1079
  }
1073
1080
  return [4 /*yield*/, C6.IMPORT(tableToFetch)];
1074
1081
  case 1:
1075
- fetchTable = _o.sent();
1082
+ fetchTable = _m.sent();
1076
1083
  RestApi = fetchTable.default;
1077
1084
  console.log('%c Fetch Dependencies will select (' + tableToFetch + ') using GET request', 'color: #33ccff');
1078
1085
  nextFetchDependencies = exports.eFetchDependencies.NONE;
@@ -1095,8 +1102,8 @@ var HttpExecutor = /** @class */ (function (_super) {
1095
1102
  // it not certain that they are using carbons' entities either
1096
1103
  // this is a dynamic call to the rest api, any generated table may resolve with (RestApi)
1097
1104
  // todo - using value to avoid joins.... but. maybe this should be a parameterizable option -- think race conditions; its safer to join
1098
- apiRequestPromises.push(RestApi.Get((_m = {},
1099
- _m[C6.WHERE] = {
1105
+ apiRequestPromises.push(RestApi.Get((_l = {},
1106
+ _l[C6.WHERE] = {
1100
1107
  0: Object.keys(fetchReferences_1[tableToFetch]).reduce(function (sum, column) {
1101
1108
  fetchReferences_1[tableToFetch][column] = fetchReferences_1[tableToFetch][column].flat(Infinity);
1102
1109
  if (0 === fetchReferences_1[tableToFetch][column].length) {
@@ -1111,8 +1118,8 @@ var HttpExecutor = /** @class */ (function (_super) {
1111
1118
  return sum;
1112
1119
  }, {})
1113
1120
  },
1114
- _m.fetchDependencies = nextFetchDependencies,
1115
- _m)));
1121
+ _l.fetchDependencies = nextFetchDependencies,
1122
+ _l)));
1116
1123
  return [2 /*return*/];
1117
1124
  }
1118
1125
  });
@@ -1122,7 +1129,7 @@ var HttpExecutor = /** @class */ (function (_super) {
1122
1129
  for (_c in _a)
1123
1130
  _b.push(_c);
1124
1131
  _i = 0;
1125
- _l.label = 1;
1132
+ _k.label = 1;
1126
1133
  case 1:
1127
1134
  if (!(_i < _b.length)) return [3 /*break*/, 4];
1128
1135
  _c = _b[_i];
@@ -1130,8 +1137,8 @@ var HttpExecutor = /** @class */ (function (_super) {
1130
1137
  tableToFetch = _c;
1131
1138
  return [5 /*yield**/, _loop_1(tableToFetch)];
1132
1139
  case 2:
1133
- _l.sent();
1134
- _l.label = 3;
1140
+ _k.sent();
1141
+ _k.label = 3;
1135
1142
  case 3:
1136
1143
  _i++;
1137
1144
  return [3 /*break*/, 1];
@@ -1139,7 +1146,7 @@ var HttpExecutor = /** @class */ (function (_super) {
1139
1146
  console.groupEnd();
1140
1147
  return [4 /*yield*/, Promise.all(apiRequestPromises)];
1141
1148
  case 5:
1142
- _l.sent();
1149
+ _k.sent();
1143
1150
  apiRequestPromises.map(function (promise) { return tslib.__awaiter(_this, void 0, void 0, function () {
1144
1151
  var _a, _b;
1145
1152
  return tslib.__generator(this, function (_c) {
@@ -1157,15 +1164,16 @@ var HttpExecutor = /** @class */ (function (_super) {
1157
1164
  }
1158
1165
  });
1159
1166
  }); });
1160
- _l.label = 6;
1167
+ _k.label = 6;
1161
1168
  case 6:
1162
1169
  if (debug && isLocal()) {
1163
1170
  reactToastify.toast.success("DEVS: (" + requestMethod + ") request complete.", toastOptionsDevs);
1164
1171
  }
1172
+ // this is the literal axios return
1165
1173
  return [2 /*return*/, response];
1166
1174
  }
1167
1175
  });
1168
- }); }).then(function (response) { return response.data; })];
1176
+ }); }).then(function (response) { return response.data; })]; // this escapes from axios context
1169
1177
  }
1170
1178
  catch (throwableError) {
1171
1179
  if (isTest()) {
@@ -1363,18 +1371,44 @@ var PaginationBuilder = /** @class */ (function (_super) {
1363
1371
  function PaginationBuilder() {
1364
1372
  return _super !== null && _super.apply(this, arguments) || this;
1365
1373
  }
1374
+ /**
1375
+ * MySQL ORDER/LIMIT/OFFSET generator.
1376
+ *
1377
+ * Accepted structures:
1378
+ * ```ts
1379
+ * ORDER: {
1380
+ * // simple column with direction
1381
+ * [property_units.UNIT_ID]: "DESC",
1382
+ * // function call (array of arguments)
1383
+ * [C6Constants.ST_DISTANCE_SPHERE]: [property_units.LOCATION, F(property_units.LOCATION, "pu_target")]
1384
+ * }
1385
+ * ```
1386
+ */
1366
1387
  PaginationBuilder.prototype.buildPaginationClause = function (pagination) {
1367
1388
  var _this = this;
1368
1389
  var _a;
1369
- var sql = '';
1390
+ var sql = "";
1391
+ /* -------- ORDER BY -------- */
1370
1392
  if (pagination === null || pagination === void 0 ? void 0 : pagination[C6Constants.ORDER]) {
1371
- var orderParts = Object.entries(pagination[C6Constants.ORDER])
1372
- .map(function (_a) {
1373
- var col = _a[0], dir = _a[1];
1374
- return "".concat(Array.isArray(col) ? _this.buildAggregateField(col) : col, " ").concat(String(dir).toUpperCase());
1375
- });
1376
- sql += " ORDER BY ".concat(orderParts.join(', '));
1393
+ var orderParts = [];
1394
+ for (var _i = 0, _b = Object.entries(pagination[C6Constants.ORDER]); _i < _b.length; _i++) {
1395
+ var _c = _b[_i], key = _c[0], val = _c[1];
1396
+ // FUNCTION CALL: val is an array of args
1397
+ if (Array.isArray(val)) {
1398
+ var args = val
1399
+ .map(function (arg) { return Array.isArray(arg) ? _this.buildAggregateField(arg) : String(arg); })
1400
+ .join(", ");
1401
+ orderParts.push("".concat(key, "(").concat(args, ")"));
1402
+ }
1403
+ // SIMPLE COLUMN + DIR (ASC/DESC)
1404
+ else {
1405
+ orderParts.push("".concat(key, " ").concat(String(val).toUpperCase()));
1406
+ }
1407
+ }
1408
+ if (orderParts.length)
1409
+ sql += " ORDER BY ".concat(orderParts.join(", "));
1377
1410
  }
1411
+ /* -------- LIMIT / OFFSET -------- */
1378
1412
  if ((pagination === null || pagination === void 0 ? void 0 : pagination[C6Constants.LIMIT]) != null) {
1379
1413
  var lim = parseInt(pagination[C6Constants.LIMIT], 10);
1380
1414
  var page = parseInt((_a = pagination[C6Constants.PAGE]) !== null && _a !== void 0 ? _a : 1, 10);