@carbonorm/carbonnode 3.7.5 → 3.7.7

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.
Files changed (40) hide show
  1. package/README.md +1 -1
  2. package/dist/api/orm/builders/AggregateBuilder.d.ts +1 -0
  3. package/dist/api/types/dynamicFetching.d.ts +6 -6
  4. package/dist/api/types/ormInterfaces.d.ts +2 -2
  5. package/dist/api/utils/cacheManager.d.ts +1 -1
  6. package/dist/api/utils/normalizeSingularRequest.d.ts +10 -0
  7. package/dist/index.cjs.js +180 -34
  8. package/dist/index.cjs.js.map +1 -1
  9. package/dist/index.d.ts +1 -0
  10. package/dist/index.esm.js +181 -36
  11. package/dist/index.esm.js.map +1 -1
  12. package/package.json +11 -6
  13. package/scripts/assets/handlebars/C6.test.ts.handlebars +55 -80
  14. package/scripts/assets/handlebars/C6.ts.handlebars +28 -2
  15. package/scripts/generateRestBindings.cjs +17 -6
  16. package/scripts/generateRestBindings.ts +22 -8
  17. package/src/__tests__/fixtures/c6.fixture.ts +74 -0
  18. package/src/__tests__/normalizeSingularRequest.test.ts +95 -0
  19. package/src/__tests__/sakila-db/C6.js +1487 -0
  20. package/src/__tests__/sakila-db/C6.test.ts +63 -0
  21. package/src/__tests__/sakila-db/C6.ts +2206 -0
  22. package/src/__tests__/sakila-db/sakila-data.sql +46444 -0
  23. package/src/__tests__/sakila-db/sakila-schema.sql +686 -0
  24. package/src/__tests__/sakila-db/sakila.mwb +0 -0
  25. package/src/__tests__/sakila.generated.test.ts +46 -0
  26. package/src/__tests__/sqlBuilders.complex.test.ts +134 -0
  27. package/src/__tests__/sqlBuilders.test.ts +121 -0
  28. package/src/api/convertForRequestBody.ts +1 -1
  29. package/src/api/executors/HttpExecutor.ts +23 -9
  30. package/src/api/executors/SqlExecutor.ts +14 -1
  31. package/src/api/orm/builders/AggregateBuilder.ts +3 -0
  32. package/src/api/orm/builders/ConditionBuilder.ts +34 -11
  33. package/src/api/orm/builders/PaginationBuilder.ts +10 -4
  34. package/src/api/orm/queries/SelectQueryBuilder.ts +3 -0
  35. package/src/api/orm/queries/UpdateQueryBuilder.ts +2 -1
  36. package/src/api/types/dynamicFetching.ts +8 -8
  37. package/src/api/types/ormInterfaces.ts +3 -4
  38. package/src/api/utils/cacheManager.ts +1 -1
  39. package/src/api/utils/normalizeSingularRequest.ts +138 -0
  40. package/src/index.ts +1 -0
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, __generator, __extends, __spreadArray } from 'tslib';
3
+ import { __assign, __awaiter, __generator, __spreadArray, __rest, __extends } from 'tslib';
4
4
  import { toast } from 'react-toastify';
5
5
  import namedPlaceholders from 'named-placeholders';
6
6
  import { Buffer as Buffer$1 } from 'buffer';
@@ -590,6 +590,95 @@ function removeInvalidKeys(request, c6Tables) {
590
590
  return intersection;
591
591
  }
592
592
 
593
+ /**
594
+ * Converts a singular T-shaped request into complex ORM format for GET/PUT/DELETE
595
+ * Enforces that all primary keys are present for singular syntax and that the table has PKs.
596
+ * Optionally accepts a previously removed primary key (key/value) to reconstruct WHERE.
597
+ */
598
+ function normalizeSingularRequest(requestMethod, request, restModel, removedPrimary) {
599
+ var _a, _b;
600
+ if (request == null || typeof request !== 'object')
601
+ return request;
602
+ var specialKeys = new Set([
603
+ C6Constants.SELECT,
604
+ C6Constants.UPDATE,
605
+ C6Constants.DELETE,
606
+ C6Constants.WHERE,
607
+ C6Constants.JOIN,
608
+ C6Constants.PAGINATION,
609
+ ]);
610
+ // Determine if the request is already complex (has any special key besides PAGINATION)
611
+ var keys = Object.keys(request);
612
+ var hasComplexKeys = keys.some(function (k) { return k !== C6Constants.PAGINATION && specialKeys.has(k); });
613
+ if (hasComplexKeys)
614
+ return request; // already complex
615
+ // We treat it as singular when it's not complex.
616
+ // For GET, PUT, DELETE only
617
+ if (!(requestMethod === C6Constants.GET || requestMethod === C6Constants.PUT || requestMethod === C6Constants.DELETE)) {
618
+ return request;
619
+ }
620
+ var pkShorts = Array.isArray(restModel.PRIMARY_SHORT) ? __spreadArray([], restModel.PRIMARY_SHORT, true) : [];
621
+ if (!pkShorts.length) {
622
+ throw new Error("Table (".concat(restModel.TABLE_NAME, ") has no primary key; singular request syntax is not allowed."));
623
+ }
624
+ // Build pk map from request + possibly removed primary key
625
+ var pkValues = {};
626
+ for (var _i = 0, pkShorts_1 = pkShorts; _i < pkShorts_1.length; _i++) {
627
+ var pk = pkShorts_1[_i];
628
+ var fromRequest = request[pk];
629
+ if (fromRequest !== undefined && fromRequest !== null) {
630
+ pkValues[pk] = fromRequest;
631
+ continue;
632
+ }
633
+ if (removedPrimary && removedPrimary.key === pk) {
634
+ pkValues[pk] = removedPrimary.value;
635
+ continue;
636
+ }
637
+ }
638
+ var missing = pkShorts.filter(function (pk) { return !(pk in pkValues); });
639
+ if (missing.length) {
640
+ throw new Error("Singular request requires all primary key(s) [".concat(pkShorts.join(', '), "] for table (").concat(restModel.TABLE_NAME, "). Missing: [").concat(missing.join(', '), "]"));
641
+ }
642
+ // Strip API metadata that should remain at root
643
+ var _c = request, dataInsertMultipleRows = _c.dataInsertMultipleRows, cacheResults = _c.cacheResults, fetchDependencies = _c.fetchDependencies, debug = _c.debug, success = _c.success, error = _c.error, rest = __rest(_c, ["dataInsertMultipleRows", "cacheResults", "fetchDependencies", "debug", "success", "error"]);
644
+ if (requestMethod === C6Constants.GET) {
645
+ var normalized_1 = {
646
+ WHERE: __assign({}, pkValues),
647
+ };
648
+ // Preserve pagination if any was added previously
649
+ if (request[C6Constants.PAGINATION]) {
650
+ normalized_1[C6Constants.PAGINATION] = request[C6Constants.PAGINATION];
651
+ }
652
+ return __assign(__assign({}, normalized_1), { dataInsertMultipleRows: dataInsertMultipleRows, cacheResults: cacheResults, fetchDependencies: fetchDependencies, debug: debug, success: success, error: error });
653
+ }
654
+ if (requestMethod === C6Constants.DELETE) {
655
+ var normalized_2 = (_a = {},
656
+ _a[C6Constants.DELETE] = true,
657
+ _a.WHERE = __assign({}, pkValues),
658
+ _a);
659
+ return __assign(__assign({}, normalized_2), { dataInsertMultipleRows: dataInsertMultipleRows, cacheResults: cacheResults, fetchDependencies: fetchDependencies, debug: debug, success: success, error: error });
660
+ }
661
+ // PUT
662
+ var updateBody = {};
663
+ for (var _d = 0, _e = Object.keys(rest); _d < _e.length; _d++) {
664
+ var k = _e[_d];
665
+ if (pkShorts.includes(k))
666
+ continue; // don't update PK columns
667
+ // Skip special request keys if any slipped through
668
+ if (specialKeys.has(k))
669
+ continue;
670
+ updateBody[k] = rest[k];
671
+ }
672
+ if (Object.keys(updateBody).length === 0) {
673
+ throw new Error("Singular PUT request for table (".concat(restModel.TABLE_NAME, ") must include at least one non-primary field to update."));
674
+ }
675
+ var normalized = (_b = {},
676
+ _b[C6Constants.UPDATE] = updateBody,
677
+ _b.WHERE = __assign({}, pkValues),
678
+ _b);
679
+ return __assign(__assign({}, normalized), { dataInsertMultipleRows: dataInsertMultipleRows, cacheResults: cacheResults, fetchDependencies: fetchDependencies, debug: debug, success: success, error: error });
680
+ }
681
+
593
682
  // do not remove entries from this array. It is used to track the progress of API requests.
594
683
  // position in array is important. Do not sort. To not add to begging.
595
684
  var apiRequestCache = [];
@@ -727,7 +816,7 @@ var HttpExecutor = /** @class */ (function (_super) {
727
816
  query[C6.PAGINATION][C6.LIMIT] = query[C6.PAGINATION][C6.LIMIT] || 100;
728
817
  }
729
818
  apiRequest = function () { return __awaiter(_this, void 0, void 0, function () {
730
- 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;
819
+ 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;
731
820
  var _e;
732
821
  var _this = this;
733
822
  var _f, _g, _h, _j, _k, _l;
@@ -847,6 +936,7 @@ var HttpExecutor = /** @class */ (function (_super) {
847
936
  && primaryKey in query) {
848
937
  restRequestUri += query[primaryKey] + '/';
849
938
  removedPkValue_1 = query[primaryKey];
939
+ removedPrimaryKV = { key: primaryKey, value: removedPkValue_1 };
850
940
  addBackPK = function () {
851
941
  query !== null && query !== void 0 ? query : (query = {});
852
942
  query[primaryKey] = removedPkValue_1;
@@ -875,9 +965,11 @@ var HttpExecutor = /** @class */ (function (_super) {
875
965
  var baseConfig = {
876
966
  withCredentials: withCredentials,
877
967
  };
968
+ // Normalize singular request (GET/PUT/DELETE) into complex ORM shape
969
+ var normalizedQuery = normalizeSingularRequest(requestMethod, query, restModel, removedPrimaryKV);
878
970
  switch (requestMethod) {
879
971
  case GET:
880
- return [__assign(__assign({}, baseConfig), { params: query })];
972
+ return [__assign(__assign({}, baseConfig), { params: normalizedQuery })];
881
973
  case POST:
882
974
  if (dataInsertMultipleRows !== undefined) {
883
975
  return [
@@ -887,9 +979,9 @@ var HttpExecutor = /** @class */ (function (_super) {
887
979
  }
888
980
  return [convert(query), baseConfig];
889
981
  case PUT:
890
- return [convert(query), baseConfig];
982
+ return [convert(normalizedQuery), baseConfig];
891
983
  case DELETE:
892
- return [__assign(__assign({}, baseConfig), { data: convert(query) })];
984
+ return [__assign(__assign({}, baseConfig), { data: convert(normalizedQuery) })];
893
985
  default:
894
986
  throw new Error("The request method (".concat(requestMethod, ") was not recognized."));
895
987
  }
@@ -1093,8 +1185,11 @@ var HttpExecutor = /** @class */ (function (_super) {
1093
1185
  console.log('%c Fetch Dependencies will select (' + tableToFetch + ') using GET request', 'color: #33ccff');
1094
1186
  var nextFetchDependencies = eFetchDependencies.NONE;
1095
1187
  if (fetchDependencies & eFetchDependencies.RECURSIVE) {
1096
- if (fetchDependencies & eFetchDependencies.ALL) {
1097
- 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.');
1188
+ var hasParents = !!(fetchDependencies & eFetchDependencies.PARENTS);
1189
+ var hasChildren = !!(fetchDependencies & eFetchDependencies.CHILDREN);
1190
+ if (hasParents && hasChildren) {
1191
+ throw Error('Recursive fetch with both PARENT and CHILD references would loop forever. ' +
1192
+ 'Use only one of PARENTS or CHILDREN when RECURSIVE is set.');
1098
1193
  }
1099
1194
  nextFetchDependencies = fetchDependencies;
1100
1195
  }
@@ -1207,7 +1302,9 @@ function convertHexIfBinary(_col, val, columnDef) {
1207
1302
  var AggregateBuilder = /** @class */ (function (_super) {
1208
1303
  __extends(AggregateBuilder, _super);
1209
1304
  function AggregateBuilder() {
1210
- return _super !== null && _super.apply(this, arguments) || this;
1305
+ var _this = _super !== null && _super.apply(this, arguments) || this;
1306
+ _this.selectAliases = new Set();
1307
+ return _this;
1211
1308
  }
1212
1309
  AggregateBuilder.prototype.buildAggregateField = function (field) {
1213
1310
  var _this = this;
@@ -1235,6 +1332,7 @@ var AggregateBuilder = /** @class */ (function (_super) {
1235
1332
  expr = "".concat(F, "(").concat(argList, ")");
1236
1333
  }
1237
1334
  if (alias) {
1335
+ this.selectAliases.add(alias);
1238
1336
  expr += " AS ".concat(alias);
1239
1337
  }
1240
1338
  this.config.verbose && console.log("[SELECT] ".concat(expr));
@@ -1301,12 +1399,21 @@ var ConditionBuilder = /** @class */ (function (_super) {
1301
1399
  throw new Error("Method not implemented.");
1302
1400
  };
1303
1401
  ConditionBuilder.prototype.isTableReference = function (val) {
1304
- var _a, _b, _c;
1305
- if (typeof val !== 'string' || !val.includes('.'))
1402
+ var _a, _b, _c, _d;
1403
+ if (typeof val !== 'string')
1404
+ return false;
1405
+ // Support aggregate aliases (e.g., SELECT COUNT(x) AS cnt ... HAVING cnt > 1)
1406
+ if (!val.includes('.')) {
1407
+ var isIdentifier = /^[A-Za-z_][A-Za-z0-9_]*$/.test(val);
1408
+ // selectAliases is defined in AggregateBuilder
1409
+ if (isIdentifier && ((_a = this.selectAliases) === null || _a === void 0 ? void 0 : _a.has(val))) {
1410
+ return true;
1411
+ }
1306
1412
  return false;
1307
- var _d = val.split('.'), prefix = _d[0], column = _d[1];
1308
- var tableName = (_a = this.aliasMap[prefix]) !== null && _a !== void 0 ? _a : prefix;
1309
- var table = (_c = (_b = this.config.C6) === null || _b === void 0 ? void 0 : _b.TABLES) === null || _c === void 0 ? void 0 : _c[tableName];
1413
+ }
1414
+ var _e = val.split('.'), prefix = _e[0], column = _e[1];
1415
+ var tableName = (_b = this.aliasMap[prefix]) !== null && _b !== void 0 ? _b : prefix;
1416
+ var table = (_d = (_c = this.config.C6) === null || _c === void 0 ? void 0 : _c.TABLES) === null || _d === void 0 ? void 0 : _d[tableName];
1310
1417
  if (!table || !table.COLUMNS)
1311
1418
  return false;
1312
1419
  var fullKey = "".concat(tableName, ".").concat(column);
@@ -1319,8 +1426,14 @@ var ConditionBuilder = /** @class */ (function (_super) {
1319
1426
  }
1320
1427
  };
1321
1428
  ConditionBuilder.prototype.addParam = function (params, column, value) {
1322
- var _a, _b;
1323
- var columnDef = (_b = (_a = this.config.C6[column.split('.')[0]]) === null || _a === void 0 ? void 0 : _a.TYPE_VALIDATION) === null || _b === void 0 ? void 0 : _b[column];
1429
+ var _a, _b, _c;
1430
+ // Determine column definition from C6.TABLES to support type-aware conversions (e.g., BINARY hex -> Buffer)
1431
+ var columnDef;
1432
+ if (typeof column === 'string' && column.includes('.')) {
1433
+ var tableName = column.split('.', 2)[0];
1434
+ var table = (_b = (_a = this.config.C6) === null || _a === void 0 ? void 0 : _a.TABLES) === null || _b === void 0 ? void 0 : _b[tableName];
1435
+ columnDef = (_c = table === null || table === void 0 ? void 0 : table.TYPE_VALIDATION) === null || _c === void 0 ? void 0 : _c[column];
1436
+ }
1324
1437
  var val = convertHexIfBinary(column, value, columnDef);
1325
1438
  if (this.useNamedParams) {
1326
1439
  var key = "param".concat(Object.keys(params).length);
@@ -1364,7 +1477,7 @@ var ConditionBuilder = /** @class */ (function (_super) {
1364
1477
  var leftIsCol = _this.isColumnRef(column);
1365
1478
  var leftIsRef = _this.isTableReference(column);
1366
1479
  var rightIsCol = typeof value === 'string' && _this.isColumnRef(value);
1367
- if (!leftIsCol && !rightIsCol) {
1480
+ if (!leftIsCol && !leftIsRef && !rightIsCol) {
1368
1481
  throw new Error("Potential SQL injection detected: '".concat(column, " ").concat(op, " ").concat(value, "'"));
1369
1482
  }
1370
1483
  _this.validateOperator(op);
@@ -1431,21 +1544,22 @@ var ConditionBuilder = /** @class */ (function (_super) {
1431
1544
  var parts = [];
1432
1545
  var buildFromObject = function (obj, mode) {
1433
1546
  var subParts = [];
1434
- for (var _i = 0, _a = Object.entries(obj); _i < _a.length; _i++) {
1435
- var _b = _a[_i], k = _b[0], v = _b[1];
1436
- // numeric keys represent nested OR groups
1437
- if (!isNaN(Number(k))) {
1438
- var sub = _this.buildBooleanJoinedConditions(v, false, params);
1439
- if (sub)
1440
- subParts.push(sub);
1441
- continue;
1442
- }
1547
+ var entries = Object.entries(obj);
1548
+ var nonNumeric = entries.filter(function (_a) {
1549
+ var k = _a[0];
1550
+ return isNaN(Number(k));
1551
+ });
1552
+ var numeric = entries.filter(function (_a) {
1553
+ var k = _a[0];
1554
+ return !isNaN(Number(k));
1555
+ });
1556
+ var processEntry = function (k, v) {
1443
1557
  if (typeof v === 'object' && v !== null && Object.keys(v).length === 1) {
1444
- var _c = Object.entries(v)[0], op = _c[0], val = _c[1];
1558
+ var _a = Object.entries(v)[0], op = _a[0], val = _a[1];
1445
1559
  subParts.push(addCondition(k, op, val));
1446
1560
  }
1447
1561
  else if (Array.isArray(v) && v.length >= 2 && typeof v[0] === 'string') {
1448
- var _d = v, op = _d[0], val = _d[1];
1562
+ var _b = v, op = _b[0], val = _b[1];
1449
1563
  subParts.push(addCondition(k, op, val));
1450
1564
  }
1451
1565
  else if (typeof v === 'object' && v !== null) {
@@ -1456,6 +1570,18 @@ var ConditionBuilder = /** @class */ (function (_super) {
1456
1570
  else {
1457
1571
  subParts.push(addCondition(k, '=', v));
1458
1572
  }
1573
+ };
1574
+ // Process non-numeric keys first to preserve intuitive insertion order for params
1575
+ for (var _i = 0, nonNumeric_1 = nonNumeric; _i < nonNumeric_1.length; _i++) {
1576
+ var _a = nonNumeric_1[_i], k = _a[0], v = _a[1];
1577
+ processEntry(k, v);
1578
+ }
1579
+ // Then process numeric keys (treated as grouped OR conditions)
1580
+ for (var _b = 0, numeric_1 = numeric; _b < numeric_1.length; _b++) {
1581
+ var _c = numeric_1[_b]; _c[0]; var v = _c[1];
1582
+ var sub = _this.buildBooleanJoinedConditions(v, false, params);
1583
+ if (sub)
1584
+ subParts.push(sub);
1459
1585
  }
1460
1586
  return subParts.join(" ".concat(mode ? 'AND' : 'OR', " "));
1461
1587
  };
@@ -1592,13 +1718,12 @@ var PaginationBuilder = /** @class */ (function (_super) {
1592
1718
  */
1593
1719
  PaginationBuilder.prototype.buildPaginationClause = function (pagination) {
1594
1720
  var _this = this;
1595
- var _a;
1596
1721
  var sql = "";
1597
1722
  /* -------- ORDER BY -------- */
1598
1723
  if (pagination === null || pagination === void 0 ? void 0 : pagination[C6Constants.ORDER]) {
1599
1724
  var orderParts = [];
1600
- for (var _i = 0, _b = Object.entries(pagination[C6Constants.ORDER]); _i < _b.length; _i++) {
1601
- var _c = _b[_i], key = _c[0], val = _c[1];
1725
+ for (var _i = 0, _a = Object.entries(pagination[C6Constants.ORDER]); _i < _a.length; _i++) {
1726
+ var _b = _a[_i], key = _b[0], val = _b[1];
1602
1727
  // FUNCTION CALL: val is an array of args
1603
1728
  if (Array.isArray(val)) {
1604
1729
  var args = val
@@ -1617,9 +1742,16 @@ var PaginationBuilder = /** @class */ (function (_super) {
1617
1742
  /* -------- LIMIT / OFFSET -------- */
1618
1743
  if ((pagination === null || pagination === void 0 ? void 0 : pagination[C6Constants.LIMIT]) != null) {
1619
1744
  var lim = parseInt(pagination[C6Constants.LIMIT], 10);
1620
- var page = parseInt((_a = pagination[C6Constants.PAGE]) !== null && _a !== void 0 ? _a : 1, 10);
1621
- var offset = (page - 1) * lim;
1622
- sql += " LIMIT ".concat(offset, ", ").concat(lim);
1745
+ var pageRaw = pagination[C6Constants.PAGE];
1746
+ var pageParsed = parseInt(pageRaw !== null && pageRaw !== void 0 ? pageRaw : 1, 10);
1747
+ var page = isFinite(pageParsed) && pageParsed > 1 ? pageParsed : 1;
1748
+ if (page === 1) {
1749
+ sql += " LIMIT ".concat(lim);
1750
+ }
1751
+ else {
1752
+ var offset = (page - 1) * lim;
1753
+ sql += " LIMIT ".concat(offset, ", ").concat(lim);
1754
+ }
1623
1755
  }
1624
1756
  this.config.verbose && console.log("[PAGINATION] ".concat(sql.trim()));
1625
1757
  return sql;
@@ -1637,6 +1769,10 @@ var SelectQueryBuilder = /** @class */ (function (_super) {
1637
1769
  var _a;
1638
1770
  if (isSubSelect === void 0) { isSubSelect = false; }
1639
1771
  this.aliasMap = {};
1772
+ // reset any previously collected SELECT aliases (from AggregateBuilder)
1773
+ // @ts-ignore
1774
+ if (this.selectAliases && this.selectAliases.clear)
1775
+ this.selectAliases.clear();
1640
1776
  var args = this.request;
1641
1777
  this.initAlias(table, args.JOIN);
1642
1778
  var params = this.useNamedParams ? {} : [];
@@ -1690,9 +1826,10 @@ var UpdateQueryBuilder = /** @class */ (function (_super) {
1690
1826
  if (!(C6C.UPDATE in this.request)) {
1691
1827
  throw new Error("No update data provided in the request.");
1692
1828
  }
1693
- var setClauses = Object.entries(this.request[C6C.UPDATE]).map(function (_a) {
1829
+ var setClauses = Object.entries(this.request[C6C.UPDATE])
1830
+ .map(function (_a) {
1694
1831
  var col = _a[0], val = _a[1];
1695
- return _this.addParam(params, col, val);
1832
+ return "`".concat(col, "` = ").concat(_this.addParam(params, col, val));
1696
1833
  });
1697
1834
  sql += " SET ".concat(setClauses.join(', '));
1698
1835
  if (args.WHERE) {
@@ -1724,6 +1861,14 @@ var SqlExecutor = /** @class */ (function (_super) {
1724
1861
  case 0:
1725
1862
  TABLE_NAME = this.config.restModel.TABLE_NAME;
1726
1863
  method = this.config.requestMethod;
1864
+ // Normalize singular T-shaped requests into complex ORM shape (GET/PUT/DELETE)
1865
+ try {
1866
+ this.request = normalizeSingularRequest(method, this.request, this.config.restModel, undefined);
1867
+ }
1868
+ catch (e) {
1869
+ // Surface normalization errors early
1870
+ throw e;
1871
+ }
1727
1872
  this.config.verbose && console.log("[SQL EXECUTOR] \u25B6\uFE0F Executing ".concat(method, " on table \"").concat(TABLE_NAME, "\""));
1728
1873
  this.config.verbose && console.log("[SQL EXECUTOR] \uD83E\uDDE9 Request:", this.request);
1729
1874
  _a = method;
@@ -2088,5 +2233,5 @@ function isVerbose () {
2088
2233
  return ['true', '1', 'yes', 'on'].includes(envVerbose.toLowerCase());
2089
2234
  }
2090
2235
 
2091
- export { A, AggregateBuilder, C6C, C6Constants, ConditionBuilder, DELETE, DeleteQueryBuilder, Executor, ExpressHandler, F, GET, HttpExecutor, JoinBuilder, POST, PUT, PaginationBuilder, PostQueryBuilder, SelectQueryBuilder, SqlExecutor, TestRestfulResponse, UpdateQueryBuilder, apiRequestCache, axiosInstance, bbox, checkAllRequestsComplete, checkCache, clearCache, convertForRequestBody, convertHexIfBinary, determineRuntimeJsType, distSphere, eFetchDependencies, error, fieldEq, getEnvVar, getPrimaryKeyTypes, group, info, isLocal, isNode, isTest, isVerbose, onError, onSuccess, removeInvalidKeys, removePrefixIfExists, restOrm, restRequest, sortAndSerializeQueryObject, stContains, timeout, toastOptions, toastOptionsDevs, userCustomClearCache, warn };
2236
+ export { A, AggregateBuilder, C6C, C6Constants, ConditionBuilder, DELETE, DeleteQueryBuilder, Executor, ExpressHandler, F, GET, HttpExecutor, JoinBuilder, POST, PUT, PaginationBuilder, PostQueryBuilder, SelectQueryBuilder, SqlExecutor, TestRestfulResponse, UpdateQueryBuilder, apiRequestCache, axiosInstance, bbox, checkAllRequestsComplete, checkCache, clearCache, convertForRequestBody, convertHexIfBinary, determineRuntimeJsType, distSphere, eFetchDependencies, error, fieldEq, getEnvVar, getPrimaryKeyTypes, group, info, isLocal, isNode, isTest, isVerbose, normalizeSingularRequest, onError, onSuccess, removeInvalidKeys, removePrefixIfExists, restOrm, restRequest, sortAndSerializeQueryObject, stContains, timeout, toastOptions, toastOptionsDevs, userCustomClearCache, warn };
2092
2237
  //# sourceMappingURL=index.esm.js.map