pqb 0.3.2 → 0.3.3

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/index.js CHANGED
@@ -4,28 +4,28 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var pg = require('pg');
6
6
 
7
- var __defProp$p = Object.defineProperty;
7
+ var __defProp$q = Object.defineProperty;
8
8
  var __defProps$l = Object.defineProperties;
9
9
  var __getOwnPropDescs$l = Object.getOwnPropertyDescriptors;
10
- var __getOwnPropSymbols$q = Object.getOwnPropertySymbols;
11
- var __hasOwnProp$q = Object.prototype.hasOwnProperty;
12
- var __propIsEnum$q = Object.prototype.propertyIsEnumerable;
13
- var __defNormalProp$p = (obj, key, value) => key in obj ? __defProp$p(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
14
- var __spreadValues$p = (a, b) => {
10
+ var __getOwnPropSymbols$r = Object.getOwnPropertySymbols;
11
+ var __hasOwnProp$r = Object.prototype.hasOwnProperty;
12
+ var __propIsEnum$r = Object.prototype.propertyIsEnumerable;
13
+ var __defNormalProp$q = (obj, key, value) => key in obj ? __defProp$q(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
14
+ var __spreadValues$q = (a, b) => {
15
15
  for (var prop in b || (b = {}))
16
- if (__hasOwnProp$q.call(b, prop))
17
- __defNormalProp$p(a, prop, b[prop]);
18
- if (__getOwnPropSymbols$q)
19
- for (var prop of __getOwnPropSymbols$q(b)) {
20
- if (__propIsEnum$q.call(b, prop))
21
- __defNormalProp$p(a, prop, b[prop]);
16
+ if (__hasOwnProp$r.call(b, prop))
17
+ __defNormalProp$q(a, prop, b[prop]);
18
+ if (__getOwnPropSymbols$r)
19
+ for (var prop of __getOwnPropSymbols$r(b)) {
20
+ if (__propIsEnum$r.call(b, prop))
21
+ __defNormalProp$q(a, prop, b[prop]);
22
22
  }
23
23
  return a;
24
24
  };
25
25
  var __spreadProps$l = (a, b) => __defProps$l(a, __getOwnPropDescs$l(b));
26
26
  const addColumnData = (q, key, value) => {
27
27
  const cloned = Object.create(q);
28
- cloned.data = __spreadProps$l(__spreadValues$p({}, q.data), { [key]: value });
28
+ cloned.data = __spreadProps$l(__spreadValues$q({}, q.data), { [key]: value });
29
29
  return cloned;
30
30
  };
31
31
  class ColumnType {
@@ -43,12 +43,12 @@ class ColumnType {
43
43
  foreignKey(fnOrTable, column, options = {}) {
44
44
  const cloned = Object.create(this);
45
45
  if (typeof fnOrTable === "string") {
46
- cloned.data = __spreadProps$l(__spreadValues$p({}, this.data), {
47
- foreignKey: __spreadValues$p({ table: fnOrTable, columns: [column] }, options)
46
+ cloned.data = __spreadProps$l(__spreadValues$q({}, this.data), {
47
+ foreignKey: __spreadValues$q({ table: fnOrTable, columns: [column] }, options)
48
48
  });
49
49
  } else {
50
- cloned.data = __spreadProps$l(__spreadValues$p({}, this.data), {
51
- foreignKey: __spreadValues$p({ fn: fnOrTable, columns: [column] }, options)
50
+ cloned.data = __spreadProps$l(__spreadValues$q({}, this.data), {
51
+ foreignKey: __spreadValues$q({ fn: fnOrTable, columns: [column] }, options)
52
52
  });
53
53
  }
54
54
  return cloned;
@@ -80,7 +80,7 @@ class ColumnType {
80
80
  return addColumnData(this, "index", options);
81
81
  }
82
82
  unique(options = {}) {
83
- return addColumnData(this, "index", __spreadProps$l(__spreadValues$p({}, options), { unique: true }));
83
+ return addColumnData(this, "index", __spreadProps$l(__spreadValues$q({}, options), { unique: true }));
84
84
  }
85
85
  comment(comment) {
86
86
  return addColumnData(this, "comment", comment);
@@ -207,21 +207,21 @@ const addValue = (values, value) => {
207
207
  return `$${values.length}`;
208
208
  };
209
209
 
210
- var __defProp$o = Object.defineProperty;
210
+ var __defProp$p = Object.defineProperty;
211
211
  var __defProps$k = Object.defineProperties;
212
212
  var __getOwnPropDescs$k = Object.getOwnPropertyDescriptors;
213
- var __getOwnPropSymbols$p = Object.getOwnPropertySymbols;
214
- var __hasOwnProp$p = Object.prototype.hasOwnProperty;
215
- var __propIsEnum$p = Object.prototype.propertyIsEnumerable;
216
- var __defNormalProp$o = (obj, key, value) => key in obj ? __defProp$o(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
217
- var __spreadValues$o = (a, b) => {
213
+ var __getOwnPropSymbols$q = Object.getOwnPropertySymbols;
214
+ var __hasOwnProp$q = Object.prototype.hasOwnProperty;
215
+ var __propIsEnum$q = Object.prototype.propertyIsEnumerable;
216
+ var __defNormalProp$p = (obj, key, value) => key in obj ? __defProp$p(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
217
+ var __spreadValues$p = (a, b) => {
218
218
  for (var prop in b || (b = {}))
219
- if (__hasOwnProp$p.call(b, prop))
220
- __defNormalProp$o(a, prop, b[prop]);
221
- if (__getOwnPropSymbols$p)
222
- for (var prop of __getOwnPropSymbols$p(b)) {
223
- if (__propIsEnum$p.call(b, prop))
224
- __defNormalProp$o(a, prop, b[prop]);
219
+ if (__hasOwnProp$q.call(b, prop))
220
+ __defNormalProp$p(a, prop, b[prop]);
221
+ if (__getOwnPropSymbols$q)
222
+ for (var prop of __getOwnPropSymbols$q(b)) {
223
+ if (__propIsEnum$q.call(b, prop))
224
+ __defNormalProp$p(a, prop, b[prop]);
225
225
  }
226
226
  return a;
227
227
  };
@@ -311,14 +311,14 @@ const base = () => ({
311
311
  in: all.in(),
312
312
  notIn: all.notIn()
313
313
  });
314
- const numeric = () => __spreadProps$k(__spreadValues$o({}, base()), {
314
+ const numeric = () => __spreadProps$k(__spreadValues$p({}, base()), {
315
315
  lt: all.lt(),
316
316
  lte: all.lte(),
317
317
  gt: all.gt(),
318
318
  gte: all.gte(),
319
319
  between: all.between()
320
320
  });
321
- const text = () => __spreadProps$k(__spreadValues$o({}, base()), {
321
+ const text = () => __spreadProps$k(__spreadValues$p({}, base()), {
322
322
  contains: all.contains(),
323
323
  containsInsensitive: all.containsInsensitive(),
324
324
  startsWith: all.startsWith(),
@@ -326,7 +326,7 @@ const text = () => __spreadProps$k(__spreadValues$o({}, base()), {
326
326
  endsWith: all.endsWith(),
327
327
  endsWithInsensitive: all.endsWithInsensitive()
328
328
  });
329
- const json = () => __spreadProps$k(__spreadValues$o({}, base()), {
329
+ const json = () => __spreadProps$k(__spreadValues$p({}, base()), {
330
330
  jsonPath: all.jsonPath(),
331
331
  jsonSupersetOf: all.jsonSupersetOf(),
332
332
  jsonSubsetOf: all.jsonSubsetOf()
@@ -342,6 +342,12 @@ const Operators = {
342
342
  array: base()
343
343
  };
344
344
 
345
+ const defaultsKey = Symbol("defaults");
346
+ const queryTypeWithLimitOne = {
347
+ one: true,
348
+ oneOrThrow: true
349
+ };
350
+
345
351
  const pushDistinctSql = (ctx, distinct, quotedAs) => {
346
352
  ctx.sql.push("DISTINCT");
347
353
  if (distinct.length) {
@@ -694,21 +700,21 @@ const pushIn = (ands, prefix, quotedAs, values, arg) => {
694
700
  );
695
701
  };
696
702
 
697
- var __defProp$n = Object.defineProperty;
703
+ var __defProp$o = Object.defineProperty;
698
704
  var __defProps$j = Object.defineProperties;
699
705
  var __getOwnPropDescs$j = Object.getOwnPropertyDescriptors;
700
- var __getOwnPropSymbols$o = Object.getOwnPropertySymbols;
701
- var __hasOwnProp$o = Object.prototype.hasOwnProperty;
702
- var __propIsEnum$o = Object.prototype.propertyIsEnumerable;
703
- var __defNormalProp$n = (obj, key, value) => key in obj ? __defProp$n(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
704
- var __spreadValues$n = (a, b) => {
706
+ var __getOwnPropSymbols$p = Object.getOwnPropertySymbols;
707
+ var __hasOwnProp$p = Object.prototype.hasOwnProperty;
708
+ var __propIsEnum$p = Object.prototype.propertyIsEnumerable;
709
+ var __defNormalProp$o = (obj, key, value) => key in obj ? __defProp$o(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
710
+ var __spreadValues$o = (a, b) => {
705
711
  for (var prop in b || (b = {}))
706
- if (__hasOwnProp$o.call(b, prop))
707
- __defNormalProp$n(a, prop, b[prop]);
708
- if (__getOwnPropSymbols$o)
709
- for (var prop of __getOwnPropSymbols$o(b)) {
710
- if (__propIsEnum$o.call(b, prop))
711
- __defNormalProp$n(a, prop, b[prop]);
712
+ if (__hasOwnProp$p.call(b, prop))
713
+ __defNormalProp$o(a, prop, b[prop]);
714
+ if (__getOwnPropSymbols$p)
715
+ for (var prop of __getOwnPropSymbols$p(b)) {
716
+ if (__propIsEnum$p.call(b, prop))
717
+ __defNormalProp$o(a, prop, b[prop]);
712
718
  }
713
719
  return a;
714
720
  };
@@ -716,7 +722,7 @@ var __spreadProps$j = (a, b) => __defProps$j(a, __getOwnPropDescs$j(b));
716
722
  const aggregateToSql = (ctx, model, item, quotedAs) => {
717
723
  var _a;
718
724
  const sql = [`${item.function}(`];
719
- ctx = __spreadProps$j(__spreadValues$n({}, ctx), { sql });
725
+ ctx = __spreadProps$j(__spreadValues$o({}, ctx), { sql });
720
726
  const options = item.options || EMPTY_OBJECT;
721
727
  if (options.distinct && !options.withinGroup)
722
728
  sql.push("DISTINCT ");
@@ -884,7 +890,7 @@ const selectToSql = (ctx, model, query, quotedAs) => {
884
890
  }
885
891
  };
886
892
  const pushSubQuerySql = (query, as, values, list) => {
887
- const { returnType } = query.query;
893
+ const { returnType = "all" } = query.query;
888
894
  switch (returnType) {
889
895
  case "all":
890
896
  case "one":
@@ -901,7 +907,6 @@ const pushSubQuerySql = (query, as, values, list) => {
901
907
  select[0] = { selectAs: { c: first } };
902
908
  query = query._wrap(query.__model.clone());
903
909
  query._getOptional(raw(`COALESCE(json_agg("c"), '[]')`));
904
- delete query.query.take;
905
910
  break;
906
911
  }
907
912
  case "rows":
@@ -1019,22 +1024,30 @@ const havingToSql = (ctx, model, query, quotedAs) => {
1019
1024
  };
1020
1025
 
1021
1026
  const pushWithSql = (ctx, withData) => {
1022
- withData.forEach((withItem) => {
1023
- const [name, options, query] = withItem;
1024
- let inner;
1025
- if (isRaw(query)) {
1026
- inner = getRaw(query, ctx.values);
1027
- } else {
1028
- inner = query.toSql({ values: ctx.values }).text;
1029
- }
1030
- ctx.sql.push(
1031
- `WITH ${options.recursive ? "RECURSIVE " : ""}${q(name)}${options.columns ? `(${options.columns.map(q).join(", ")})` : ""} AS ${options.materialized ? "MATERIALIZED " : options.notMaterialized ? "NOT MATERIALIZED " : ""}(${inner})`
1032
- );
1033
- });
1027
+ if (!withData.length)
1028
+ return;
1029
+ ctx.sql.push(
1030
+ "WITH",
1031
+ withData.map((withItem) => {
1032
+ const [name, options, query] = withItem;
1033
+ let inner;
1034
+ if (isRaw(query)) {
1035
+ inner = getRaw(query, ctx.values);
1036
+ } else {
1037
+ inner = query.toSql({ values: ctx.values }).text;
1038
+ }
1039
+ return `${options.recursive ? "RECURSIVE " : ""}${q(name)}${options.columns ? `(${options.columns.map(q).join(", ")})` : ""} AS ${options.materialized ? "MATERIALIZED " : options.notMaterialized ? "NOT MATERIALIZED " : ""}(${inner})`;
1040
+ }).join(", ")
1041
+ );
1034
1042
  };
1035
1043
 
1044
+ const checkIfASimpleQuery = (q) => {
1045
+ if (q.returnType && q.returnType !== "all")
1046
+ return false;
1047
+ const keys = Object.keys(q);
1048
+ return !keys.some((key) => queryKeysOfNotSimpleQuery.includes(key));
1049
+ };
1036
1050
  const queryKeysOfNotSimpleQuery = [
1037
- "take",
1038
1051
  "with",
1039
1052
  "as",
1040
1053
  "from",
@@ -1076,8 +1089,7 @@ const getFrom = (model, query, values) => {
1076
1089
  return `(${sql.text})`;
1077
1090
  }
1078
1091
  const q = query.from.query;
1079
- const keys = Object.keys(q);
1080
- if (keys.some((key) => queryKeysOfNotSimpleQuery.includes(key))) {
1092
+ if (!checkIfASimpleQuery(q)) {
1081
1093
  const sql = query.from.toSql({ values });
1082
1094
  return `(${sql.text})`;
1083
1095
  }
@@ -1333,8 +1345,9 @@ const makeSql = (model, { values = [] } = {}) => {
1333
1345
  if (query.order) {
1334
1346
  pushOrderBySql(ctx, quotedAs, query.order);
1335
1347
  }
1336
- if (query.take || query.limit !== void 0) {
1337
- sql.push(`LIMIT ${addValue(values, query.take ? 1 : query.limit)}`);
1348
+ const limit = queryTypeWithLimitOne[query.returnType] ? 1 : query.limit;
1349
+ if (limit) {
1350
+ sql.push(`LIMIT ${addValue(values, limit)}`);
1338
1351
  }
1339
1352
  if (query.offset) {
1340
1353
  sql.push(`OFFSET ${addValue(values, query.offset)}`);
@@ -1355,21 +1368,21 @@ const makeSql = (model, { values = [] } = {}) => {
1355
1368
  return { text: sql.join(" "), values };
1356
1369
  };
1357
1370
 
1358
- var __defProp$m = Object.defineProperty;
1371
+ var __defProp$n = Object.defineProperty;
1359
1372
  var __defProps$i = Object.defineProperties;
1360
1373
  var __getOwnPropDescs$i = Object.getOwnPropertyDescriptors;
1361
- var __getOwnPropSymbols$n = Object.getOwnPropertySymbols;
1362
- var __hasOwnProp$n = Object.prototype.hasOwnProperty;
1363
- var __propIsEnum$n = Object.prototype.propertyIsEnumerable;
1364
- var __defNormalProp$m = (obj, key, value) => key in obj ? __defProp$m(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1365
- var __spreadValues$m = (a, b) => {
1374
+ var __getOwnPropSymbols$o = Object.getOwnPropertySymbols;
1375
+ var __hasOwnProp$o = Object.prototype.hasOwnProperty;
1376
+ var __propIsEnum$o = Object.prototype.propertyIsEnumerable;
1377
+ var __defNormalProp$n = (obj, key, value) => key in obj ? __defProp$n(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1378
+ var __spreadValues$n = (a, b) => {
1366
1379
  for (var prop in b || (b = {}))
1367
- if (__hasOwnProp$n.call(b, prop))
1368
- __defNormalProp$m(a, prop, b[prop]);
1369
- if (__getOwnPropSymbols$n)
1370
- for (var prop of __getOwnPropSymbols$n(b)) {
1371
- if (__propIsEnum$n.call(b, prop))
1372
- __defNormalProp$m(a, prop, b[prop]);
1380
+ if (__hasOwnProp$o.call(b, prop))
1381
+ __defNormalProp$n(a, prop, b[prop]);
1382
+ if (__getOwnPropSymbols$o)
1383
+ for (var prop of __getOwnPropSymbols$o(b)) {
1384
+ if (__propIsEnum$o.call(b, prop))
1385
+ __defNormalProp$n(a, prop, b[prop]);
1373
1386
  }
1374
1387
  return a;
1375
1388
  };
@@ -1389,7 +1402,7 @@ const joinTruthy = (...strings) => {
1389
1402
  return strings.filter((string) => string).join("");
1390
1403
  };
1391
1404
  const getClonedQueryData = (query) => {
1392
- const cloned = __spreadProps$i(__spreadValues$m({}, query), { [toSqlCacheKey]: void 0 });
1405
+ const cloned = __spreadProps$i(__spreadValues$n({}, query), { [toSqlCacheKey]: void 0 });
1393
1406
  for (const key in query) {
1394
1407
  if (Array.isArray(query[key])) {
1395
1408
  cloned[key] = [
@@ -1450,28 +1463,28 @@ var utils = /*#__PURE__*/Object.freeze({
1450
1463
  assignMethodsToClass: assignMethodsToClass
1451
1464
  });
1452
1465
 
1453
- var __defProp$l = Object.defineProperty;
1466
+ var __defProp$m = Object.defineProperty;
1454
1467
  var __defProps$h = Object.defineProperties;
1455
1468
  var __getOwnPropDescs$h = Object.getOwnPropertyDescriptors;
1456
- var __getOwnPropSymbols$m = Object.getOwnPropertySymbols;
1457
- var __hasOwnProp$m = Object.prototype.hasOwnProperty;
1458
- var __propIsEnum$m = Object.prototype.propertyIsEnumerable;
1459
- var __defNormalProp$l = (obj, key, value) => key in obj ? __defProp$l(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1460
- var __spreadValues$l = (a, b) => {
1469
+ var __getOwnPropSymbols$n = Object.getOwnPropertySymbols;
1470
+ var __hasOwnProp$n = Object.prototype.hasOwnProperty;
1471
+ var __propIsEnum$n = Object.prototype.propertyIsEnumerable;
1472
+ var __defNormalProp$m = (obj, key, value) => key in obj ? __defProp$m(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1473
+ var __spreadValues$m = (a, b) => {
1461
1474
  for (var prop in b || (b = {}))
1462
- if (__hasOwnProp$m.call(b, prop))
1463
- __defNormalProp$l(a, prop, b[prop]);
1464
- if (__getOwnPropSymbols$m)
1465
- for (var prop of __getOwnPropSymbols$m(b)) {
1466
- if (__propIsEnum$m.call(b, prop))
1467
- __defNormalProp$l(a, prop, b[prop]);
1475
+ if (__hasOwnProp$n.call(b, prop))
1476
+ __defNormalProp$m(a, prop, b[prop]);
1477
+ if (__getOwnPropSymbols$n)
1478
+ for (var prop of __getOwnPropSymbols$n(b)) {
1479
+ if (__propIsEnum$n.call(b, prop))
1480
+ __defNormalProp$m(a, prop, b[prop]);
1468
1481
  }
1469
1482
  return a;
1470
1483
  };
1471
1484
  var __spreadProps$h = (a, b) => __defProps$h(a, __getOwnPropDescs$h(b));
1472
1485
  const setDataValue = (item, key, value) => {
1473
1486
  const cloned = Object.create(item);
1474
- cloned.data = __spreadProps$h(__spreadValues$l({}, item.data), { [key]: value });
1487
+ cloned.data = __spreadProps$h(__spreadValues$m({}, item.data), { [key]: value });
1475
1488
  return cloned;
1476
1489
  };
1477
1490
  function min(value) {
@@ -1501,7 +1514,7 @@ const setMethods = {
1501
1514
  size,
1502
1515
  nonempty
1503
1516
  };
1504
- const stringTypeMethods = () => __spreadProps$h(__spreadValues$l({}, arrayMethods), {
1517
+ const stringTypeMethods = () => __spreadProps$h(__spreadValues$m({}, arrayMethods), {
1505
1518
  email() {
1506
1519
  return setDataValue(this, "email", true);
1507
1520
  },
@@ -1972,21 +1985,21 @@ class EnumColumn extends ColumnType {
1972
1985
  }
1973
1986
  }
1974
1987
 
1975
- var __defProp$k = Object.defineProperty;
1988
+ var __defProp$l = Object.defineProperty;
1976
1989
  var __defProps$g = Object.defineProperties;
1977
1990
  var __getOwnPropDescs$g = Object.getOwnPropertyDescriptors;
1978
- var __getOwnPropSymbols$l = Object.getOwnPropertySymbols;
1979
- var __hasOwnProp$l = Object.prototype.hasOwnProperty;
1980
- var __propIsEnum$l = Object.prototype.propertyIsEnumerable;
1981
- var __defNormalProp$k = (obj, key, value) => key in obj ? __defProp$k(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1982
- var __spreadValues$k = (a, b) => {
1991
+ var __getOwnPropSymbols$m = Object.getOwnPropertySymbols;
1992
+ var __hasOwnProp$m = Object.prototype.hasOwnProperty;
1993
+ var __propIsEnum$m = Object.prototype.propertyIsEnumerable;
1994
+ var __defNormalProp$l = (obj, key, value) => key in obj ? __defProp$l(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1995
+ var __spreadValues$l = (a, b) => {
1983
1996
  for (var prop in b || (b = {}))
1984
- if (__hasOwnProp$l.call(b, prop))
1985
- __defNormalProp$k(a, prop, b[prop]);
1986
- if (__getOwnPropSymbols$l)
1987
- for (var prop of __getOwnPropSymbols$l(b)) {
1988
- if (__propIsEnum$l.call(b, prop))
1989
- __defNormalProp$k(a, prop, b[prop]);
1997
+ if (__hasOwnProp$m.call(b, prop))
1998
+ __defNormalProp$l(a, prop, b[prop]);
1999
+ if (__getOwnPropSymbols$m)
2000
+ for (var prop of __getOwnPropSymbols$m(b)) {
2001
+ if (__propIsEnum$m.call(b, prop))
2002
+ __defNormalProp$l(a, prop, b[prop]);
1990
2003
  }
1991
2004
  return a;
1992
2005
  };
@@ -1994,42 +2007,42 @@ var __spreadProps$g = (a, b) => __defProps$g(a, __getOwnPropDescs$g(b));
1994
2007
  var __objRest$4 = (source, exclude) => {
1995
2008
  var target = {};
1996
2009
  for (var prop in source)
1997
- if (__hasOwnProp$l.call(source, prop) && exclude.indexOf(prop) < 0)
2010
+ if (__hasOwnProp$m.call(source, prop) && exclude.indexOf(prop) < 0)
1998
2011
  target[prop] = source[prop];
1999
- if (source != null && __getOwnPropSymbols$l)
2000
- for (var prop of __getOwnPropSymbols$l(source)) {
2001
- if (exclude.indexOf(prop) < 0 && __propIsEnum$l.call(source, prop))
2012
+ if (source != null && __getOwnPropSymbols$m)
2013
+ for (var prop of __getOwnPropSymbols$m(source)) {
2014
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$m.call(source, prop))
2002
2015
  target[prop] = source[prop];
2003
2016
  }
2004
2017
  return target;
2005
2018
  };
2006
2019
  const optional = (type) => {
2007
- return __spreadProps$g(__spreadValues$k({}, type), {
2008
- data: __spreadProps$g(__spreadValues$k({}, type.data), { optional: true })
2020
+ return __spreadProps$g(__spreadValues$l({}, type), {
2021
+ data: __spreadProps$g(__spreadValues$l({}, type.data), { optional: true })
2009
2022
  });
2010
2023
  };
2011
2024
  const required = (type) => {
2012
2025
  const _a = type.data, data = __objRest$4(_a, ["optional"]);
2013
- return __spreadProps$g(__spreadValues$k({}, type), {
2026
+ return __spreadProps$g(__spreadValues$l({}, type), {
2014
2027
  data
2015
2028
  });
2016
2029
  };
2017
2030
 
2018
- var __defProp$j = Object.defineProperty;
2031
+ var __defProp$k = Object.defineProperty;
2019
2032
  var __defProps$f = Object.defineProperties;
2020
2033
  var __getOwnPropDescs$f = Object.getOwnPropertyDescriptors;
2021
- var __getOwnPropSymbols$k = Object.getOwnPropertySymbols;
2022
- var __hasOwnProp$k = Object.prototype.hasOwnProperty;
2023
- var __propIsEnum$k = Object.prototype.propertyIsEnumerable;
2024
- var __defNormalProp$j = (obj, key, value) => key in obj ? __defProp$j(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2025
- var __spreadValues$j = (a, b) => {
2034
+ var __getOwnPropSymbols$l = Object.getOwnPropertySymbols;
2035
+ var __hasOwnProp$l = Object.prototype.hasOwnProperty;
2036
+ var __propIsEnum$l = Object.prototype.propertyIsEnumerable;
2037
+ var __defNormalProp$k = (obj, key, value) => key in obj ? __defProp$k(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2038
+ var __spreadValues$k = (a, b) => {
2026
2039
  for (var prop in b || (b = {}))
2027
- if (__hasOwnProp$k.call(b, prop))
2028
- __defNormalProp$j(a, prop, b[prop]);
2029
- if (__getOwnPropSymbols$k)
2030
- for (var prop of __getOwnPropSymbols$k(b)) {
2031
- if (__propIsEnum$k.call(b, prop))
2032
- __defNormalProp$j(a, prop, b[prop]);
2040
+ if (__hasOwnProp$l.call(b, prop))
2041
+ __defNormalProp$k(a, prop, b[prop]);
2042
+ if (__getOwnPropSymbols$l)
2043
+ for (var prop of __getOwnPropSymbols$l(b)) {
2044
+ if (__propIsEnum$l.call(b, prop))
2045
+ __defNormalProp$k(a, prop, b[prop]);
2033
2046
  }
2034
2047
  return a;
2035
2048
  };
@@ -2037,42 +2050,42 @@ var __spreadProps$f = (a, b) => __defProps$f(a, __getOwnPropDescs$f(b));
2037
2050
  var __objRest$3 = (source, exclude) => {
2038
2051
  var target = {};
2039
2052
  for (var prop in source)
2040
- if (__hasOwnProp$k.call(source, prop) && exclude.indexOf(prop) < 0)
2053
+ if (__hasOwnProp$l.call(source, prop) && exclude.indexOf(prop) < 0)
2041
2054
  target[prop] = source[prop];
2042
- if (source != null && __getOwnPropSymbols$k)
2043
- for (var prop of __getOwnPropSymbols$k(source)) {
2044
- if (exclude.indexOf(prop) < 0 && __propIsEnum$k.call(source, prop))
2055
+ if (source != null && __getOwnPropSymbols$l)
2056
+ for (var prop of __getOwnPropSymbols$l(source)) {
2057
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$l.call(source, prop))
2045
2058
  target[prop] = source[prop];
2046
2059
  }
2047
2060
  return target;
2048
2061
  };
2049
2062
  const nullable = (type) => {
2050
- return __spreadProps$f(__spreadValues$j({}, type), {
2051
- data: __spreadProps$f(__spreadValues$j({}, type.data), { nullable: true })
2063
+ return __spreadProps$f(__spreadValues$k({}, type), {
2064
+ data: __spreadProps$f(__spreadValues$k({}, type.data), { nullable: true })
2052
2065
  });
2053
2066
  };
2054
2067
  const notNullable = (type) => {
2055
2068
  const _a = type.data, data = __objRest$3(_a, ["nullable"]);
2056
- return __spreadProps$f(__spreadValues$j({}, type), {
2069
+ return __spreadProps$f(__spreadValues$k({}, type), {
2057
2070
  data
2058
2071
  });
2059
2072
  };
2060
2073
 
2061
- var __defProp$i = Object.defineProperty;
2074
+ var __defProp$j = Object.defineProperty;
2062
2075
  var __defProps$e = Object.defineProperties;
2063
2076
  var __getOwnPropDescs$e = Object.getOwnPropertyDescriptors;
2064
- var __getOwnPropSymbols$j = Object.getOwnPropertySymbols;
2065
- var __hasOwnProp$j = Object.prototype.hasOwnProperty;
2066
- var __propIsEnum$j = Object.prototype.propertyIsEnumerable;
2067
- var __defNormalProp$i = (obj, key, value) => key in obj ? __defProp$i(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2068
- var __spreadValues$i = (a, b) => {
2077
+ var __getOwnPropSymbols$k = Object.getOwnPropertySymbols;
2078
+ var __hasOwnProp$k = Object.prototype.hasOwnProperty;
2079
+ var __propIsEnum$k = Object.prototype.propertyIsEnumerable;
2080
+ var __defNormalProp$j = (obj, key, value) => key in obj ? __defProp$j(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2081
+ var __spreadValues$j = (a, b) => {
2069
2082
  for (var prop in b || (b = {}))
2070
- if (__hasOwnProp$j.call(b, prop))
2071
- __defNormalProp$i(a, prop, b[prop]);
2072
- if (__getOwnPropSymbols$j)
2073
- for (var prop of __getOwnPropSymbols$j(b)) {
2074
- if (__propIsEnum$j.call(b, prop))
2075
- __defNormalProp$i(a, prop, b[prop]);
2083
+ if (__hasOwnProp$k.call(b, prop))
2084
+ __defNormalProp$j(a, prop, b[prop]);
2085
+ if (__getOwnPropSymbols$k)
2086
+ for (var prop of __getOwnPropSymbols$k(b)) {
2087
+ if (__propIsEnum$k.call(b, prop))
2088
+ __defNormalProp$j(a, prop, b[prop]);
2076
2089
  }
2077
2090
  return a;
2078
2091
  };
@@ -2080,23 +2093,23 @@ var __spreadProps$e = (a, b) => __defProps$e(a, __getOwnPropDescs$e(b));
2080
2093
  var __objRest$2 = (source, exclude) => {
2081
2094
  var target = {};
2082
2095
  for (var prop in source)
2083
- if (__hasOwnProp$j.call(source, prop) && exclude.indexOf(prop) < 0)
2096
+ if (__hasOwnProp$k.call(source, prop) && exclude.indexOf(prop) < 0)
2084
2097
  target[prop] = source[prop];
2085
- if (source != null && __getOwnPropSymbols$j)
2086
- for (var prop of __getOwnPropSymbols$j(source)) {
2087
- if (exclude.indexOf(prop) < 0 && __propIsEnum$j.call(source, prop))
2098
+ if (source != null && __getOwnPropSymbols$k)
2099
+ for (var prop of __getOwnPropSymbols$k(source)) {
2100
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$k.call(source, prop))
2088
2101
  target[prop] = source[prop];
2089
2102
  }
2090
2103
  return target;
2091
2104
  };
2092
2105
  const nullish = (type) => {
2093
- return __spreadProps$e(__spreadValues$i({}, type), {
2094
- data: __spreadProps$e(__spreadValues$i({}, type.data), { nullable: true, optional: true })
2106
+ return __spreadProps$e(__spreadValues$j({}, type), {
2107
+ data: __spreadProps$e(__spreadValues$j({}, type.data), { nullable: true, optional: true })
2095
2108
  });
2096
2109
  };
2097
2110
  const notNullish = (type) => {
2098
2111
  const _a = type.data, data = __objRest$2(_a, ["nullable", "optional"]);
2099
- return __spreadProps$e(__spreadValues$i({}, type), {
2112
+ return __spreadProps$e(__spreadValues$j({}, type), {
2100
2113
  data
2101
2114
  });
2102
2115
  };
@@ -2116,21 +2129,21 @@ const union = (types) => {
2116
2129
  });
2117
2130
  };
2118
2131
 
2119
- var __defProp$h = Object.defineProperty;
2132
+ var __defProp$i = Object.defineProperty;
2120
2133
  var __defProps$d = Object.defineProperties;
2121
2134
  var __getOwnPropDescs$d = Object.getOwnPropertyDescriptors;
2122
- var __getOwnPropSymbols$i = Object.getOwnPropertySymbols;
2123
- var __hasOwnProp$i = Object.prototype.hasOwnProperty;
2124
- var __propIsEnum$i = Object.prototype.propertyIsEnumerable;
2125
- var __defNormalProp$h = (obj, key, value) => key in obj ? __defProp$h(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2126
- var __spreadValues$h = (a, b) => {
2135
+ var __getOwnPropSymbols$j = Object.getOwnPropertySymbols;
2136
+ var __hasOwnProp$j = Object.prototype.hasOwnProperty;
2137
+ var __propIsEnum$j = Object.prototype.propertyIsEnumerable;
2138
+ var __defNormalProp$i = (obj, key, value) => key in obj ? __defProp$i(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2139
+ var __spreadValues$i = (a, b) => {
2127
2140
  for (var prop in b || (b = {}))
2128
- if (__hasOwnProp$i.call(b, prop))
2129
- __defNormalProp$h(a, prop, b[prop]);
2130
- if (__getOwnPropSymbols$i)
2131
- for (var prop of __getOwnPropSymbols$i(b)) {
2132
- if (__propIsEnum$i.call(b, prop))
2133
- __defNormalProp$h(a, prop, b[prop]);
2141
+ if (__hasOwnProp$j.call(b, prop))
2142
+ __defNormalProp$i(a, prop, b[prop]);
2143
+ if (__getOwnPropSymbols$j)
2144
+ for (var prop of __getOwnPropSymbols$j(b)) {
2145
+ if (__propIsEnum$j.call(b, prop))
2146
+ __defNormalProp$i(a, prop, b[prop]);
2134
2147
  }
2135
2148
  return a;
2136
2149
  };
@@ -2162,22 +2175,22 @@ const baseTypeMethods = {
2162
2175
  return this;
2163
2176
  },
2164
2177
  transform(fn) {
2165
- return __spreadProps$d(__spreadValues$h({}, this), {
2178
+ return __spreadProps$d(__spreadValues$i({}, this), {
2166
2179
  chain: [...this.chain, ["transform", fn]]
2167
2180
  });
2168
2181
  },
2169
2182
  to(fn, type) {
2170
- return __spreadProps$d(__spreadValues$h({}, type), {
2183
+ return __spreadProps$d(__spreadValues$i({}, type), {
2171
2184
  chain: [...this.chain, ["to", fn, type], ...type.chain]
2172
2185
  });
2173
2186
  },
2174
2187
  refine(check) {
2175
- return __spreadProps$d(__spreadValues$h({}, this), {
2188
+ return __spreadProps$d(__spreadValues$i({}, this), {
2176
2189
  chain: [...this.chain, ["refine", check]]
2177
2190
  });
2178
2191
  },
2179
2192
  superRefine(check) {
2180
- return __spreadProps$d(__spreadValues$h({}, this), {
2193
+ return __spreadProps$d(__spreadValues$i({}, this), {
2181
2194
  chain: [...this.chain, ["superRefine", check]]
2182
2195
  });
2183
2196
  },
@@ -2190,7 +2203,7 @@ const baseTypeMethods = {
2190
2203
  },
2191
2204
  default(value) {
2192
2205
  const cloned = Object.create(this);
2193
- cloned.data = __spreadProps$d(__spreadValues$h({}, cloned.data), { default: value });
2206
+ cloned.data = __spreadProps$d(__spreadValues$i({}, cloned.data), { default: value });
2194
2207
  return cloned;
2195
2208
  },
2196
2209
  array() {
@@ -2198,34 +2211,34 @@ const baseTypeMethods = {
2198
2211
  }
2199
2212
  };
2200
2213
  const constructType = (type) => {
2201
- return __spreadValues$h(__spreadValues$h({}, baseTypeMethods), type);
2214
+ return __spreadValues$i(__spreadValues$i({}, baseTypeMethods), type);
2202
2215
  };
2203
2216
 
2204
- var __defProp$g = Object.defineProperty;
2217
+ var __defProp$h = Object.defineProperty;
2205
2218
  var __defProps$c = Object.defineProperties;
2206
2219
  var __getOwnPropDescs$c = Object.getOwnPropertyDescriptors;
2207
- var __getOwnPropSymbols$h = Object.getOwnPropertySymbols;
2208
- var __hasOwnProp$h = Object.prototype.hasOwnProperty;
2209
- var __propIsEnum$h = Object.prototype.propertyIsEnumerable;
2210
- var __defNormalProp$g = (obj, key, value) => key in obj ? __defProp$g(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2211
- var __spreadValues$g = (a, b) => {
2220
+ var __getOwnPropSymbols$i = Object.getOwnPropertySymbols;
2221
+ var __hasOwnProp$i = Object.prototype.hasOwnProperty;
2222
+ var __propIsEnum$i = Object.prototype.propertyIsEnumerable;
2223
+ var __defNormalProp$h = (obj, key, value) => key in obj ? __defProp$h(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2224
+ var __spreadValues$h = (a, b) => {
2212
2225
  for (var prop in b || (b = {}))
2213
- if (__hasOwnProp$h.call(b, prop))
2214
- __defNormalProp$g(a, prop, b[prop]);
2215
- if (__getOwnPropSymbols$h)
2216
- for (var prop of __getOwnPropSymbols$h(b)) {
2217
- if (__propIsEnum$h.call(b, prop))
2218
- __defNormalProp$g(a, prop, b[prop]);
2226
+ if (__hasOwnProp$i.call(b, prop))
2227
+ __defNormalProp$h(a, prop, b[prop]);
2228
+ if (__getOwnPropSymbols$i)
2229
+ for (var prop of __getOwnPropSymbols$i(b)) {
2230
+ if (__propIsEnum$i.call(b, prop))
2231
+ __defNormalProp$h(a, prop, b[prop]);
2219
2232
  }
2220
2233
  return a;
2221
2234
  };
2222
2235
  var __spreadProps$c = (a, b) => __defProps$c(a, __getOwnPropDescs$c(b));
2223
2236
  const array = (element) => {
2224
- return constructType(__spreadValues$g({
2237
+ return constructType(__spreadValues$h({
2225
2238
  dataType: "array",
2226
2239
  element,
2227
2240
  deepPartial() {
2228
- return __spreadProps$c(__spreadValues$g({}, this), {
2241
+ return __spreadProps$c(__spreadValues$h({}, this), {
2229
2242
  element: this.element.deepPartial()
2230
2243
  });
2231
2244
  },
@@ -2235,21 +2248,21 @@ const array = (element) => {
2235
2248
  }, arrayMethods));
2236
2249
  };
2237
2250
 
2238
- var __defProp$f = Object.defineProperty;
2251
+ var __defProp$g = Object.defineProperty;
2239
2252
  var __defProps$b = Object.defineProperties;
2240
2253
  var __getOwnPropDescs$b = Object.getOwnPropertyDescriptors;
2241
- var __getOwnPropSymbols$g = Object.getOwnPropertySymbols;
2242
- var __hasOwnProp$g = Object.prototype.hasOwnProperty;
2243
- var __propIsEnum$g = Object.prototype.propertyIsEnumerable;
2244
- var __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2245
- var __spreadValues$f = (a, b) => {
2254
+ var __getOwnPropSymbols$h = Object.getOwnPropertySymbols;
2255
+ var __hasOwnProp$h = Object.prototype.hasOwnProperty;
2256
+ var __propIsEnum$h = Object.prototype.propertyIsEnumerable;
2257
+ var __defNormalProp$g = (obj, key, value) => key in obj ? __defProp$g(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2258
+ var __spreadValues$g = (a, b) => {
2246
2259
  for (var prop in b || (b = {}))
2247
- if (__hasOwnProp$g.call(b, prop))
2248
- __defNormalProp$f(a, prop, b[prop]);
2249
- if (__getOwnPropSymbols$g)
2250
- for (var prop of __getOwnPropSymbols$g(b)) {
2251
- if (__propIsEnum$g.call(b, prop))
2252
- __defNormalProp$f(a, prop, b[prop]);
2260
+ if (__hasOwnProp$h.call(b, prop))
2261
+ __defNormalProp$g(a, prop, b[prop]);
2262
+ if (__getOwnPropSymbols$h)
2263
+ for (var prop of __getOwnPropSymbols$h(b)) {
2264
+ if (__propIsEnum$h.call(b, prop))
2265
+ __defNormalProp$g(a, prop, b[prop]);
2253
2266
  }
2254
2267
  return a;
2255
2268
  };
@@ -2273,7 +2286,7 @@ const discriminatedUnion = (discriminator, options) => {
2273
2286
  partial.shape[discriminator] = option.shape[discriminator];
2274
2287
  newOptionsMap.set(key, partial);
2275
2288
  });
2276
- return __spreadProps$b(__spreadValues$f({}, this), {
2289
+ return __spreadProps$b(__spreadValues$g({}, this), {
2277
2290
  options: newOptionsMap
2278
2291
  });
2279
2292
  }
@@ -2302,21 +2315,21 @@ const instanceOf = (cls) => {
2302
2315
  });
2303
2316
  };
2304
2317
 
2305
- var __defProp$e = Object.defineProperty;
2318
+ var __defProp$f = Object.defineProperty;
2306
2319
  var __defProps$a = Object.defineProperties;
2307
2320
  var __getOwnPropDescs$a = Object.getOwnPropertyDescriptors;
2308
- var __getOwnPropSymbols$f = Object.getOwnPropertySymbols;
2309
- var __hasOwnProp$f = Object.prototype.hasOwnProperty;
2310
- var __propIsEnum$f = Object.prototype.propertyIsEnumerable;
2311
- var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2312
- var __spreadValues$e = (a, b) => {
2321
+ var __getOwnPropSymbols$g = Object.getOwnPropertySymbols;
2322
+ var __hasOwnProp$g = Object.prototype.hasOwnProperty;
2323
+ var __propIsEnum$g = Object.prototype.propertyIsEnumerable;
2324
+ var __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2325
+ var __spreadValues$f = (a, b) => {
2313
2326
  for (var prop in b || (b = {}))
2314
- if (__hasOwnProp$f.call(b, prop))
2315
- __defNormalProp$e(a, prop, b[prop]);
2316
- if (__getOwnPropSymbols$f)
2317
- for (var prop of __getOwnPropSymbols$f(b)) {
2318
- if (__propIsEnum$f.call(b, prop))
2319
- __defNormalProp$e(a, prop, b[prop]);
2327
+ if (__hasOwnProp$g.call(b, prop))
2328
+ __defNormalProp$f(a, prop, b[prop]);
2329
+ if (__getOwnPropSymbols$g)
2330
+ for (var prop of __getOwnPropSymbols$g(b)) {
2331
+ if (__propIsEnum$g.call(b, prop))
2332
+ __defNormalProp$f(a, prop, b[prop]);
2320
2333
  }
2321
2334
  return a;
2322
2335
  };
@@ -2328,7 +2341,7 @@ const lazy = (fn) => {
2328
2341
  return this.typeCache || (this.typeCache = fn());
2329
2342
  },
2330
2343
  deepPartial() {
2331
- return __spreadProps$a(__spreadValues$e({}, this), {
2344
+ return __spreadProps$a(__spreadValues$f({}, this), {
2332
2345
  typeCache: void 0,
2333
2346
  getter: () => this.getter().deepPartial()
2334
2347
  });
@@ -2341,21 +2354,21 @@ const literal = (value) => constructType({
2341
2354
  value
2342
2355
  });
2343
2356
 
2344
- var __defProp$d = Object.defineProperty;
2357
+ var __defProp$e = Object.defineProperty;
2345
2358
  var __defProps$9 = Object.defineProperties;
2346
2359
  var __getOwnPropDescs$9 = Object.getOwnPropertyDescriptors;
2347
- var __getOwnPropSymbols$e = Object.getOwnPropertySymbols;
2348
- var __hasOwnProp$e = Object.prototype.hasOwnProperty;
2349
- var __propIsEnum$e = Object.prototype.propertyIsEnumerable;
2350
- var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2351
- var __spreadValues$d = (a, b) => {
2360
+ var __getOwnPropSymbols$f = Object.getOwnPropertySymbols;
2361
+ var __hasOwnProp$f = Object.prototype.hasOwnProperty;
2362
+ var __propIsEnum$f = Object.prototype.propertyIsEnumerable;
2363
+ var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2364
+ var __spreadValues$e = (a, b) => {
2352
2365
  for (var prop in b || (b = {}))
2353
- if (__hasOwnProp$e.call(b, prop))
2354
- __defNormalProp$d(a, prop, b[prop]);
2355
- if (__getOwnPropSymbols$e)
2356
- for (var prop of __getOwnPropSymbols$e(b)) {
2357
- if (__propIsEnum$e.call(b, prop))
2358
- __defNormalProp$d(a, prop, b[prop]);
2366
+ if (__hasOwnProp$f.call(b, prop))
2367
+ __defNormalProp$e(a, prop, b[prop]);
2368
+ if (__getOwnPropSymbols$f)
2369
+ for (var prop of __getOwnPropSymbols$f(b)) {
2370
+ if (__propIsEnum$f.call(b, prop))
2371
+ __defNormalProp$e(a, prop, b[prop]);
2359
2372
  }
2360
2373
  return a;
2361
2374
  };
@@ -2366,7 +2379,7 @@ const map = (keyType, valueType) => {
2366
2379
  keyType,
2367
2380
  valueType,
2368
2381
  deepPartial() {
2369
- return __spreadProps$9(__spreadValues$d({}, this), {
2382
+ return __spreadProps$9(__spreadValues$e({}, this), {
2370
2383
  keyType: this.keyType.deepPartial(),
2371
2384
  valueType: this.valueType.deepPartial()
2372
2385
  });
@@ -2392,21 +2405,21 @@ const nativeEnum = (givenEnum) => {
2392
2405
  });
2393
2406
  };
2394
2407
 
2395
- var __defProp$c = Object.defineProperty;
2408
+ var __defProp$d = Object.defineProperty;
2396
2409
  var __defProps$8 = Object.defineProperties;
2397
2410
  var __getOwnPropDescs$8 = Object.getOwnPropertyDescriptors;
2398
- var __getOwnPropSymbols$d = Object.getOwnPropertySymbols;
2399
- var __hasOwnProp$d = Object.prototype.hasOwnProperty;
2400
- var __propIsEnum$d = Object.prototype.propertyIsEnumerable;
2401
- var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2402
- var __spreadValues$c = (a, b) => {
2411
+ var __getOwnPropSymbols$e = Object.getOwnPropertySymbols;
2412
+ var __hasOwnProp$e = Object.prototype.hasOwnProperty;
2413
+ var __propIsEnum$e = Object.prototype.propertyIsEnumerable;
2414
+ var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2415
+ var __spreadValues$d = (a, b) => {
2403
2416
  for (var prop in b || (b = {}))
2404
- if (__hasOwnProp$d.call(b, prop))
2405
- __defNormalProp$c(a, prop, b[prop]);
2406
- if (__getOwnPropSymbols$d)
2407
- for (var prop of __getOwnPropSymbols$d(b)) {
2408
- if (__propIsEnum$d.call(b, prop))
2409
- __defNormalProp$c(a, prop, b[prop]);
2417
+ if (__hasOwnProp$e.call(b, prop))
2418
+ __defNormalProp$d(a, prop, b[prop]);
2419
+ if (__getOwnPropSymbols$e)
2420
+ for (var prop of __getOwnPropSymbols$e(b)) {
2421
+ if (__propIsEnum$e.call(b, prop))
2422
+ __defNormalProp$d(a, prop, b[prop]);
2410
2423
  }
2411
2424
  return a;
2412
2425
  };
@@ -2419,12 +2432,12 @@ const object = (shape) => {
2419
2432
  catchAllType: void 0,
2420
2433
  extend(add) {
2421
2434
  return object(
2422
- Object.assign(__spreadValues$c({}, this.shape), add)
2435
+ Object.assign(__spreadValues$d({}, this.shape), add)
2423
2436
  );
2424
2437
  },
2425
2438
  merge(obj) {
2426
2439
  return object(
2427
- Object.assign(__spreadValues$c({}, this.shape), obj.shape)
2440
+ Object.assign(__spreadValues$d({}, this.shape), obj.shape)
2428
2441
  );
2429
2442
  },
2430
2443
  pick(...arr) {
@@ -2442,7 +2455,7 @@ const object = (shape) => {
2442
2455
  return object(picked);
2443
2456
  },
2444
2457
  partial(...arr) {
2445
- const mapped = __spreadValues$c({}, this.shape);
2458
+ const mapped = __spreadValues$d({}, this.shape);
2446
2459
  if (arr.length) {
2447
2460
  arr.forEach((key) => {
2448
2461
  mapped[key] = mapped[key].optional();
@@ -2459,48 +2472,48 @@ const object = (shape) => {
2459
2472
  for (const key in this.shape) {
2460
2473
  newShape[key] = optional(this.shape[key].deepPartial());
2461
2474
  }
2462
- return __spreadProps$8(__spreadValues$c({}, this), {
2475
+ return __spreadProps$8(__spreadValues$d({}, this), {
2463
2476
  shape: newShape
2464
2477
  });
2465
2478
  },
2466
2479
  passthrough() {
2467
- return __spreadProps$8(__spreadValues$c({}, this), {
2480
+ return __spreadProps$8(__spreadValues$d({}, this), {
2468
2481
  unknownKeys: "passthrough"
2469
2482
  });
2470
2483
  },
2471
2484
  strict() {
2472
- return __spreadProps$8(__spreadValues$c({}, this), {
2485
+ return __spreadProps$8(__spreadValues$d({}, this), {
2473
2486
  unknownKeys: "strict"
2474
2487
  });
2475
2488
  },
2476
2489
  strip() {
2477
- return __spreadProps$8(__spreadValues$c({}, this), {
2490
+ return __spreadProps$8(__spreadValues$d({}, this), {
2478
2491
  unknownKeys: "strip"
2479
2492
  });
2480
2493
  },
2481
2494
  catchAll(type) {
2482
- return __spreadProps$8(__spreadValues$c({}, this), {
2495
+ return __spreadProps$8(__spreadValues$d({}, this), {
2483
2496
  catchAllType: type
2484
2497
  });
2485
2498
  }
2486
2499
  });
2487
2500
  };
2488
2501
 
2489
- var __defProp$b = Object.defineProperty;
2502
+ var __defProp$c = Object.defineProperty;
2490
2503
  var __defProps$7 = Object.defineProperties;
2491
2504
  var __getOwnPropDescs$7 = Object.getOwnPropertyDescriptors;
2492
- var __getOwnPropSymbols$c = Object.getOwnPropertySymbols;
2493
- var __hasOwnProp$c = Object.prototype.hasOwnProperty;
2494
- var __propIsEnum$c = Object.prototype.propertyIsEnumerable;
2495
- var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2496
- var __spreadValues$b = (a, b) => {
2505
+ var __getOwnPropSymbols$d = Object.getOwnPropertySymbols;
2506
+ var __hasOwnProp$d = Object.prototype.hasOwnProperty;
2507
+ var __propIsEnum$d = Object.prototype.propertyIsEnumerable;
2508
+ var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2509
+ var __spreadValues$c = (a, b) => {
2497
2510
  for (var prop in b || (b = {}))
2498
- if (__hasOwnProp$c.call(b, prop))
2499
- __defNormalProp$b(a, prop, b[prop]);
2500
- if (__getOwnPropSymbols$c)
2501
- for (var prop of __getOwnPropSymbols$c(b)) {
2502
- if (__propIsEnum$c.call(b, prop))
2503
- __defNormalProp$b(a, prop, b[prop]);
2511
+ if (__hasOwnProp$d.call(b, prop))
2512
+ __defNormalProp$c(a, prop, b[prop]);
2513
+ if (__getOwnPropSymbols$d)
2514
+ for (var prop of __getOwnPropSymbols$d(b)) {
2515
+ if (__propIsEnum$d.call(b, prop))
2516
+ __defNormalProp$c(a, prop, b[prop]);
2504
2517
  }
2505
2518
  return a;
2506
2519
  };
@@ -2510,7 +2523,7 @@ const any = () => {
2510
2523
  dataType: "any"
2511
2524
  });
2512
2525
  };
2513
- const bigIntMethods = __spreadValues$b({
2526
+ const bigIntMethods = __spreadValues$c({
2514
2527
  dataType: "bigint"
2515
2528
  }, numberTypeMethods);
2516
2529
  const bigint = () => {
@@ -2536,19 +2549,19 @@ const nullType = () => {
2536
2549
  dataType: "null"
2537
2550
  });
2538
2551
  };
2539
- const numberMethods = __spreadProps$7(__spreadValues$b({}, numberTypeMethods), {
2552
+ const numberMethods = __spreadProps$7(__spreadValues$c({}, numberTypeMethods), {
2540
2553
  dataType: "number"
2541
2554
  });
2542
2555
  const number = () => {
2543
2556
  return constructType(numberMethods);
2544
2557
  };
2545
- const dateMethods = __spreadProps$7(__spreadValues$b({}, dateTypeMethods), {
2558
+ const dateMethods = __spreadProps$7(__spreadValues$c({}, dateTypeMethods), {
2546
2559
  dataType: "date"
2547
2560
  });
2548
2561
  const date = () => {
2549
2562
  return constructType(dateMethods);
2550
2563
  };
2551
- const stringMethods = __spreadProps$7(__spreadValues$b({}, stringTypeMethods()), {
2564
+ const stringMethods = __spreadProps$7(__spreadValues$c({}, stringTypeMethods()), {
2552
2565
  dataType: "string"
2553
2566
  });
2554
2567
  const string = () => {
@@ -2584,21 +2597,21 @@ const scalarTypes = {
2584
2597
  void: voidType
2585
2598
  };
2586
2599
 
2587
- var __defProp$a = Object.defineProperty;
2600
+ var __defProp$b = Object.defineProperty;
2588
2601
  var __defProps$6 = Object.defineProperties;
2589
2602
  var __getOwnPropDescs$6 = Object.getOwnPropertyDescriptors;
2590
- var __getOwnPropSymbols$b = Object.getOwnPropertySymbols;
2591
- var __hasOwnProp$b = Object.prototype.hasOwnProperty;
2592
- var __propIsEnum$b = Object.prototype.propertyIsEnumerable;
2593
- var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2594
- var __spreadValues$a = (a, b) => {
2603
+ var __getOwnPropSymbols$c = Object.getOwnPropertySymbols;
2604
+ var __hasOwnProp$c = Object.prototype.hasOwnProperty;
2605
+ var __propIsEnum$c = Object.prototype.propertyIsEnumerable;
2606
+ var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2607
+ var __spreadValues$b = (a, b) => {
2595
2608
  for (var prop in b || (b = {}))
2596
- if (__hasOwnProp$b.call(b, prop))
2597
- __defNormalProp$a(a, prop, b[prop]);
2598
- if (__getOwnPropSymbols$b)
2599
- for (var prop of __getOwnPropSymbols$b(b)) {
2600
- if (__propIsEnum$b.call(b, prop))
2601
- __defNormalProp$a(a, prop, b[prop]);
2609
+ if (__hasOwnProp$c.call(b, prop))
2610
+ __defNormalProp$b(a, prop, b[prop]);
2611
+ if (__getOwnPropSymbols$c)
2612
+ for (var prop of __getOwnPropSymbols$c(b)) {
2613
+ if (__propIsEnum$c.call(b, prop))
2614
+ __defNormalProp$b(a, prop, b[prop]);
2602
2615
  }
2603
2616
  return a;
2604
2617
  };
@@ -2610,38 +2623,38 @@ function record(...args) {
2610
2623
  keyType,
2611
2624
  valueType,
2612
2625
  deepPartial() {
2613
- return __spreadProps$6(__spreadValues$a({}, this), {
2626
+ return __spreadProps$6(__spreadValues$b({}, this), {
2614
2627
  valueType: this.valueType.deepPartial()
2615
2628
  });
2616
2629
  }
2617
2630
  });
2618
2631
  }
2619
2632
 
2620
- var __defProp$9 = Object.defineProperty;
2633
+ var __defProp$a = Object.defineProperty;
2621
2634
  var __defProps$5 = Object.defineProperties;
2622
2635
  var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
2623
- var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
2624
- var __hasOwnProp$a = Object.prototype.hasOwnProperty;
2625
- var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
2626
- var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2627
- var __spreadValues$9 = (a, b) => {
2636
+ var __getOwnPropSymbols$b = Object.getOwnPropertySymbols;
2637
+ var __hasOwnProp$b = Object.prototype.hasOwnProperty;
2638
+ var __propIsEnum$b = Object.prototype.propertyIsEnumerable;
2639
+ var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2640
+ var __spreadValues$a = (a, b) => {
2628
2641
  for (var prop in b || (b = {}))
2629
- if (__hasOwnProp$a.call(b, prop))
2630
- __defNormalProp$9(a, prop, b[prop]);
2631
- if (__getOwnPropSymbols$a)
2632
- for (var prop of __getOwnPropSymbols$a(b)) {
2633
- if (__propIsEnum$a.call(b, prop))
2634
- __defNormalProp$9(a, prop, b[prop]);
2642
+ if (__hasOwnProp$b.call(b, prop))
2643
+ __defNormalProp$a(a, prop, b[prop]);
2644
+ if (__getOwnPropSymbols$b)
2645
+ for (var prop of __getOwnPropSymbols$b(b)) {
2646
+ if (__propIsEnum$b.call(b, prop))
2647
+ __defNormalProp$a(a, prop, b[prop]);
2635
2648
  }
2636
2649
  return a;
2637
2650
  };
2638
2651
  var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
2639
2652
  const set = (valueType) => {
2640
- return constructType(__spreadValues$9({
2653
+ return constructType(__spreadValues$a({
2641
2654
  dataType: "set",
2642
2655
  valueType,
2643
2656
  deepPartial() {
2644
- return __spreadProps$5(__spreadValues$9({}, this), {
2657
+ return __spreadProps$5(__spreadValues$a({}, this), {
2645
2658
  valueType: this.valueType.deepPartial()
2646
2659
  });
2647
2660
  },
@@ -2651,21 +2664,21 @@ const set = (valueType) => {
2651
2664
  }, setMethods));
2652
2665
  };
2653
2666
 
2654
- var __defProp$8 = Object.defineProperty;
2667
+ var __defProp$9 = Object.defineProperty;
2655
2668
  var __defProps$4 = Object.defineProperties;
2656
2669
  var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
2657
- var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
2658
- var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
2659
- var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
2660
- var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2661
- var __spreadValues$8 = (a, b) => {
2670
+ var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
2671
+ var __hasOwnProp$a = Object.prototype.hasOwnProperty;
2672
+ var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
2673
+ var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2674
+ var __spreadValues$9 = (a, b) => {
2662
2675
  for (var prop in b || (b = {}))
2663
- if (__hasOwnProp$9.call(b, prop))
2664
- __defNormalProp$8(a, prop, b[prop]);
2665
- if (__getOwnPropSymbols$9)
2666
- for (var prop of __getOwnPropSymbols$9(b)) {
2667
- if (__propIsEnum$9.call(b, prop))
2668
- __defNormalProp$8(a, prop, b[prop]);
2676
+ if (__hasOwnProp$a.call(b, prop))
2677
+ __defNormalProp$9(a, prop, b[prop]);
2678
+ if (__getOwnPropSymbols$a)
2679
+ for (var prop of __getOwnPropSymbols$a(b)) {
2680
+ if (__propIsEnum$a.call(b, prop))
2681
+ __defNormalProp$9(a, prop, b[prop]);
2669
2682
  }
2670
2683
  return a;
2671
2684
  };
@@ -2676,38 +2689,38 @@ const tuple = (items, rest = null) => {
2676
2689
  items,
2677
2690
  restType: rest,
2678
2691
  rest(rest2) {
2679
- return __spreadProps$4(__spreadValues$8({}, this), {
2692
+ return __spreadProps$4(__spreadValues$9({}, this), {
2680
2693
  restType: rest2
2681
2694
  });
2682
2695
  },
2683
2696
  deepPartial() {
2684
- return __spreadProps$4(__spreadValues$8({}, this), {
2697
+ return __spreadProps$4(__spreadValues$9({}, this), {
2685
2698
  items: this.items.map((item) => item.deepPartial())
2686
2699
  });
2687
2700
  }
2688
2701
  });
2689
2702
  };
2690
2703
 
2691
- var __defProp$7 = Object.defineProperty;
2704
+ var __defProp$8 = Object.defineProperty;
2692
2705
  var __defProps$3 = Object.defineProperties;
2693
2706
  var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
2694
- var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
2695
- var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
2696
- var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
2697
- var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2698
- var __spreadValues$7 = (a, b) => {
2707
+ var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
2708
+ var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
2709
+ var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
2710
+ var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2711
+ var __spreadValues$8 = (a, b) => {
2699
2712
  for (var prop in b || (b = {}))
2700
- if (__hasOwnProp$8.call(b, prop))
2701
- __defNormalProp$7(a, prop, b[prop]);
2702
- if (__getOwnPropSymbols$8)
2703
- for (var prop of __getOwnPropSymbols$8(b)) {
2704
- if (__propIsEnum$8.call(b, prop))
2705
- __defNormalProp$7(a, prop, b[prop]);
2713
+ if (__hasOwnProp$9.call(b, prop))
2714
+ __defNormalProp$8(a, prop, b[prop]);
2715
+ if (__getOwnPropSymbols$9)
2716
+ for (var prop of __getOwnPropSymbols$9(b)) {
2717
+ if (__propIsEnum$9.call(b, prop))
2718
+ __defNormalProp$8(a, prop, b[prop]);
2706
2719
  }
2707
2720
  return a;
2708
2721
  };
2709
2722
  var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
2710
- const jsonTypes = __spreadProps$3(__spreadValues$7({
2723
+ const jsonTypes = __spreadProps$3(__spreadValues$8({
2711
2724
  array,
2712
2725
  discriminatedUnion,
2713
2726
  enum: enumType,
@@ -2862,21 +2875,21 @@ const checkIfDataHasUpdatedAt = (data) => {
2862
2875
  });
2863
2876
  };
2864
2877
 
2865
- var __defProp$6 = Object.defineProperty;
2878
+ var __defProp$7 = Object.defineProperty;
2866
2879
  var __defProps$2 = Object.defineProperties;
2867
2880
  var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
2868
- var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
2869
- var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
2870
- var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
2871
- var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2872
- var __spreadValues$6 = (a, b) => {
2881
+ var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
2882
+ var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
2883
+ var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
2884
+ var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2885
+ var __spreadValues$7 = (a, b) => {
2873
2886
  for (var prop in b || (b = {}))
2874
- if (__hasOwnProp$7.call(b, prop))
2875
- __defNormalProp$6(a, prop, b[prop]);
2876
- if (__getOwnPropSymbols$7)
2877
- for (var prop of __getOwnPropSymbols$7(b)) {
2878
- if (__propIsEnum$7.call(b, prop))
2879
- __defNormalProp$6(a, prop, b[prop]);
2887
+ if (__hasOwnProp$8.call(b, prop))
2888
+ __defNormalProp$7(a, prop, b[prop]);
2889
+ if (__getOwnPropSymbols$8)
2890
+ for (var prop of __getOwnPropSymbols$8(b)) {
2891
+ if (__propIsEnum$8.call(b, prop))
2892
+ __defNormalProp$7(a, prop, b[prop]);
2880
2893
  }
2881
2894
  return a;
2882
2895
  };
@@ -2959,7 +2972,7 @@ const columnTypes = {
2959
2972
  columns: toArray(columns).map(
2960
2973
  (column) => typeof column === "string" ? { column } : column
2961
2974
  ),
2962
- options: __spreadProps$2(__spreadValues$6({}, options), { unique: true })
2975
+ options: __spreadProps$2(__spreadValues$7({}, options), { unique: true })
2963
2976
  };
2964
2977
  tableData.indexes.push(index);
2965
2978
  return emptyObject;
@@ -3004,17 +3017,17 @@ class TableSchema {
3004
3017
  }
3005
3018
  }
3006
3019
 
3007
- var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
3008
- var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
3009
- var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
3020
+ var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
3021
+ var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
3022
+ var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
3010
3023
  var __objRest$1 = (source, exclude) => {
3011
3024
  var target = {};
3012
3025
  for (var prop in source)
3013
- if (__hasOwnProp$6.call(source, prop) && exclude.indexOf(prop) < 0)
3026
+ if (__hasOwnProp$7.call(source, prop) && exclude.indexOf(prop) < 0)
3014
3027
  target[prop] = source[prop];
3015
- if (source != null && __getOwnPropSymbols$6)
3016
- for (var prop of __getOwnPropSymbols$6(source)) {
3017
- if (exclude.indexOf(prop) < 0 && __propIsEnum$6.call(source, prop))
3028
+ if (source != null && __getOwnPropSymbols$7)
3029
+ for (var prop of __getOwnPropSymbols$7(source)) {
3030
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$7.call(source, prop))
3018
3031
  target[prop] = source[prop];
3019
3032
  }
3020
3033
  return target;
@@ -3119,11 +3132,6 @@ class TransactionAdapter {
3119
3132
  }
3120
3133
  }
3121
3134
 
3122
- const removeFromQuery = (q, key) => {
3123
- if (q.query)
3124
- delete q.query[key];
3125
- return q;
3126
- };
3127
3135
  const pushQueryArray = (q, key, value) => {
3128
3136
  if (!q.query[key])
3129
3137
  q.query[key] = value;
@@ -3154,7 +3162,6 @@ const setQueryObjectValue = (q, object, key, value) => {
3154
3162
  const getValueKey = Symbol("get");
3155
3163
  const _get = (q, returnType, arg) => {
3156
3164
  q.query.returnType = returnType;
3157
- q.query.take = true;
3158
3165
  if (typeof arg === "object" && isRaw(arg)) {
3159
3166
  addParserForRawExpression(q, getValueKey, arg);
3160
3167
  q.query.select = [arg];
@@ -3206,7 +3213,7 @@ class Then {
3206
3213
  }
3207
3214
  }
3208
3215
  const handleResult = async (q, result) => {
3209
- return parseResult(q, q.query.returnType, result);
3216
+ return parseResult(q, q.query.returnType || "all", result);
3210
3217
  };
3211
3218
  const then = async (q, resolve, reject) => {
3212
3219
  let sql;
@@ -3233,7 +3240,7 @@ const then = async (q, resolve, reject) => {
3233
3240
  if (q.query.log) {
3234
3241
  logData = q.query.log.beforeQuery(sql);
3235
3242
  }
3236
- const queryResult = await q.query.adapter[queryMethodByReturnType[q.query.returnType]](sql);
3243
+ const queryResult = await q.query.adapter[queryMethodByReturnType[q.query.returnType || "all"]](sql);
3237
3244
  if (q.query.log) {
3238
3245
  q.query.log.afterQuery(sql, logData);
3239
3246
  sql = void 0;
@@ -3254,7 +3261,7 @@ const then = async (q, resolve, reject) => {
3254
3261
  reject == null ? void 0 : reject(error);
3255
3262
  }
3256
3263
  };
3257
- const parseResult = (q, returnType, result) => {
3264
+ const parseResult = (q, returnType = "all", result) => {
3258
3265
  var _a, _b;
3259
3266
  switch (returnType) {
3260
3267
  case "all": {
@@ -3361,7 +3368,7 @@ const addParserForSelectItem = (q, as, key, arg) => {
3361
3368
  const rel = arg(q);
3362
3369
  const parsers = getQueryParsers(rel);
3363
3370
  if (parsers) {
3364
- if (rel.query.take) {
3371
+ if (queryTypeWithLimitOne[rel.query.returnType]) {
3365
3372
  addParserToQuery(q.query, key, (item) => parseRecord(parsers, item));
3366
3373
  } else {
3367
3374
  addParserToQuery(
@@ -3467,21 +3474,21 @@ class Select {
3467
3474
  }
3468
3475
  }
3469
3476
 
3470
- var __defProp$5 = Object.defineProperty;
3477
+ var __defProp$6 = Object.defineProperty;
3471
3478
  var __defProps$1 = Object.defineProperties;
3472
3479
  var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
3473
- var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
3474
- var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
3475
- var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
3476
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3477
- var __spreadValues$5 = (a, b) => {
3480
+ var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
3481
+ var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
3482
+ var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
3483
+ var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3484
+ var __spreadValues$6 = (a, b) => {
3478
3485
  for (var prop in b || (b = {}))
3479
- if (__hasOwnProp$5.call(b, prop))
3480
- __defNormalProp$5(a, prop, b[prop]);
3481
- if (__getOwnPropSymbols$5)
3482
- for (var prop of __getOwnPropSymbols$5(b)) {
3483
- if (__propIsEnum$5.call(b, prop))
3484
- __defNormalProp$5(a, prop, b[prop]);
3486
+ if (__hasOwnProp$6.call(b, prop))
3487
+ __defNormalProp$6(a, prop, b[prop]);
3488
+ if (__getOwnPropSymbols$6)
3489
+ for (var prop of __getOwnPropSymbols$6(b)) {
3490
+ if (__propIsEnum$6.call(b, prop))
3491
+ __defNormalProp$6(a, prop, b[prop]);
3485
3492
  }
3486
3493
  return a;
3487
3494
  };
@@ -3506,7 +3513,7 @@ const buildAggregateSelectItem = (functionName, arg, options) => {
3506
3513
  return {
3507
3514
  function: functionName,
3508
3515
  arg,
3509
- options: __spreadProps$1(__spreadValues$5({}, options), {
3516
+ options: __spreadProps$1(__spreadValues$6({}, options), {
3510
3517
  order: (options == null ? void 0 : options.order) ? Array.isArray(options.order) ? options.order : [options.order] : void 0,
3511
3518
  filter: options == null ? void 0 : options.filter,
3512
3519
  filterOr: options == null ? void 0 : options.filterOr
@@ -3521,7 +3528,6 @@ const parseIntOrNullColumn = new IntegerColumn().parse(
3521
3528
  );
3522
3529
  const get = (q) => {
3523
3530
  q.query.returnType = "valueOrThrow";
3524
- removeFromQuery(q, "take");
3525
3531
  const select = q.query.select;
3526
3532
  if (select.length > 1) {
3527
3533
  select[0] = select[select.length - 1];
@@ -3844,8 +3850,8 @@ class Clear {
3844
3850
  _clear(...clears) {
3845
3851
  clears.forEach((clear) => {
3846
3852
  if (clear === "where") {
3847
- removeFromQuery(this, "and");
3848
- removeFromQuery(this, "or");
3853
+ delete this.query.and;
3854
+ delete this.query.or;
3849
3855
  } else if (clear === "counters") {
3850
3856
  if ("type" in this.query && this.query.type === "update") {
3851
3857
  this.query.updateData = this.query.updateData.filter((item) => {
@@ -3866,7 +3872,7 @@ class Clear {
3866
3872
  });
3867
3873
  }
3868
3874
  } else {
3869
- removeFromQuery(this, clear);
3875
+ delete this.query[clear];
3870
3876
  }
3871
3877
  });
3872
3878
  return this;
@@ -4020,19 +4026,19 @@ class From {
4020
4026
  }
4021
4027
  }
4022
4028
 
4023
- var __defProp$4 = Object.defineProperty;
4024
- var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
4025
- var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
4026
- var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
4027
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4028
- var __spreadValues$4 = (a, b) => {
4029
+ var __defProp$5 = Object.defineProperty;
4030
+ var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
4031
+ var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
4032
+ var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
4033
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4034
+ var __spreadValues$5 = (a, b) => {
4029
4035
  for (var prop in b || (b = {}))
4030
- if (__hasOwnProp$4.call(b, prop))
4031
- __defNormalProp$4(a, prop, b[prop]);
4032
- if (__getOwnPropSymbols$4)
4033
- for (var prop of __getOwnPropSymbols$4(b)) {
4034
- if (__propIsEnum$4.call(b, prop))
4035
- __defNormalProp$4(a, prop, b[prop]);
4036
+ if (__hasOwnProp$5.call(b, prop))
4037
+ __defNormalProp$5(a, prop, b[prop]);
4038
+ if (__getOwnPropSymbols$5)
4039
+ for (var prop of __getOwnPropSymbols$5(b)) {
4040
+ if (__propIsEnum$5.call(b, prop))
4041
+ __defNormalProp$5(a, prop, b[prop]);
4036
4042
  }
4037
4043
  return a;
4038
4044
  };
@@ -4040,15 +4046,15 @@ const processHavingArg = (arg) => {
4040
4046
  if ("__model" in arg || isRaw(arg)) {
4041
4047
  return arg;
4042
4048
  } else {
4043
- const processed = __spreadValues$4({}, arg);
4049
+ const processed = __spreadValues$5({}, arg);
4044
4050
  for (const fn in arg) {
4045
4051
  const data = arg[fn];
4046
4052
  if (typeof data === "object") {
4047
- processed[fn] = __spreadValues$4({}, data);
4053
+ processed[fn] = __spreadValues$5({}, data);
4048
4054
  for (const column in data) {
4049
4055
  const value = data[column];
4050
4056
  if (typeof value === "object") {
4051
- processed[fn][column] = __spreadValues$4({}, value);
4057
+ processed[fn][column] = __spreadValues$5({}, value);
4052
4058
  const options = value;
4053
4059
  if ("order" in options && options.order && !Array.isArray(options.order)) {
4054
4060
  processed[fn][column].order = [options.order];
@@ -4089,19 +4095,19 @@ class Having {
4089
4095
  }
4090
4096
  }
4091
4097
 
4092
- var __defProp$3 = Object.defineProperty;
4093
- var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
4094
- var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
4095
- var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
4096
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4097
- var __spreadValues$3 = (a, b) => {
4098
+ var __defProp$4 = Object.defineProperty;
4099
+ var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
4100
+ var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
4101
+ var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
4102
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4103
+ var __spreadValues$4 = (a, b) => {
4098
4104
  for (var prop in b || (b = {}))
4099
- if (__hasOwnProp$3.call(b, prop))
4100
- __defNormalProp$3(a, prop, b[prop]);
4101
- if (__getOwnPropSymbols$3)
4102
- for (var prop of __getOwnPropSymbols$3(b)) {
4103
- if (__propIsEnum$3.call(b, prop))
4104
- __defNormalProp$3(a, prop, b[prop]);
4105
+ if (__hasOwnProp$4.call(b, prop))
4106
+ __defNormalProp$4(a, prop, b[prop]);
4107
+ if (__getOwnPropSymbols$4)
4108
+ for (var prop of __getOwnPropSymbols$4(b)) {
4109
+ if (__propIsEnum$4.call(b, prop))
4110
+ __defNormalProp$4(a, prop, b[prop]);
4105
4111
  }
4106
4112
  return a;
4107
4113
  };
@@ -4144,7 +4150,7 @@ const createInsertCtx = (q) => ({
4144
4150
  relations: q.relations
4145
4151
  });
4146
4152
  const getInsertSingleReturnType = (q) => {
4147
- const { select, returnType } = q.query;
4153
+ const { select, returnType = "all" } = q.query;
4148
4154
  if (select) {
4149
4155
  return returnType === "all" ? "one" : returnType;
4150
4156
  } else {
@@ -4164,7 +4170,7 @@ const handleInsertOneData = (q, data, ctx) => {
4164
4170
  const columnsMap = {};
4165
4171
  const defaults = q.query.defaults;
4166
4172
  if (defaults) {
4167
- data = __spreadValues$3(__spreadValues$3({}, defaults), data);
4173
+ data = __spreadValues$4(__spreadValues$4({}, defaults), data);
4168
4174
  }
4169
4175
  processInsertItem(data, 0, ctx, columns, columnsMap);
4170
4176
  const values = [columns.map((key) => data[key])];
@@ -4175,7 +4181,7 @@ const handleInsertManyData = (q, data, ctx) => {
4175
4181
  const columnsMap = {};
4176
4182
  const defaults = q.query.defaults;
4177
4183
  if (defaults) {
4178
- data = data.map((item) => __spreadValues$3(__spreadValues$3({}, defaults), item));
4184
+ data = data.map((item) => __spreadValues$4(__spreadValues$4({}, defaults), item));
4179
4185
  }
4180
4186
  data.forEach((item, i) => {
4181
4187
  processInsertItem(item, i, ctx, columns, columnsMap);
@@ -4673,10 +4679,9 @@ class Json {
4673
4679
  const q = this._wrap(this.__model.clone());
4674
4680
  q._getOptional(
4675
4681
  raw(
4676
- this.query.take ? `row_to_json("t".*)` : `COALESCE(json_agg(row_to_json("t".*)), '[]')`
4682
+ queryTypeWithLimitOne[this.query.returnType] ? `row_to_json("t".*)` : `COALESCE(json_agg(row_to_json("t".*)), '[]')`
4677
4683
  )
4678
4684
  );
4679
- delete q.query.take;
4680
4685
  return q;
4681
4686
  }
4682
4687
  jsonSet(column, path, value, options) {
@@ -4827,6 +4832,60 @@ class QueryLog {
4827
4832
  }
4828
4833
  }
4829
4834
 
4835
+ var __defProp$3 = Object.defineProperty;
4836
+ var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
4837
+ var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
4838
+ var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
4839
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4840
+ var __spreadValues$3 = (a, b) => {
4841
+ for (var prop in b || (b = {}))
4842
+ if (__hasOwnProp$3.call(b, prop))
4843
+ __defNormalProp$3(a, prop, b[prop]);
4844
+ if (__getOwnPropSymbols$3)
4845
+ for (var prop of __getOwnPropSymbols$3(b)) {
4846
+ if (__propIsEnum$3.call(b, prop))
4847
+ __defNormalProp$3(a, prop, b[prop]);
4848
+ }
4849
+ return a;
4850
+ };
4851
+ const mergableObjects = {
4852
+ withShapes: true,
4853
+ parsers: true,
4854
+ defaults: true,
4855
+ joinedParsers: true
4856
+ };
4857
+ class MergeQueryMethods {
4858
+ merge(q) {
4859
+ return this.clone()._merge(q);
4860
+ }
4861
+ _merge(q) {
4862
+ const a = this.query;
4863
+ const b = q.query;
4864
+ for (const key in b) {
4865
+ const value = b[key];
4866
+ switch (typeof value) {
4867
+ case "boolean":
4868
+ case "string":
4869
+ case "number":
4870
+ a[key] = value;
4871
+ break;
4872
+ case "object":
4873
+ if (Array.isArray(value)) {
4874
+ a[key] = a[key] ? [...a[key], ...value] : value;
4875
+ } else if (mergableObjects[key]) {
4876
+ a[key] = a[key] ? __spreadValues$3(__spreadValues$3({}, a[key]), value) : value;
4877
+ } else {
4878
+ a[key] = value;
4879
+ }
4880
+ break;
4881
+ }
4882
+ }
4883
+ if (b.returnType)
4884
+ a.returnType = b.returnType;
4885
+ return this;
4886
+ }
4887
+ }
4888
+
4830
4889
  var __defProp$2 = Object.defineProperty;
4831
4890
  var __defProps = Object.defineProperties;
4832
4891
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
@@ -4993,7 +5052,7 @@ class Update {
4993
5052
  const relations = this.relations;
4994
5053
  const prependRelations = {};
4995
5054
  const appendRelations = {};
4996
- const originalReturnType = query.returnType;
5055
+ const originalReturnType = query.returnType || "all";
4997
5056
  for (const key in data) {
4998
5057
  if (relations[key]) {
4999
5058
  delete set[key];
@@ -5066,6 +5125,9 @@ class Update {
5066
5125
  return (q, result) => {
5067
5126
  var _a2, _b2;
5068
5127
  const all = resultOfTypeAll || result;
5128
+ if (q.query.returnType !== originalReturnType) {
5129
+ q.query.returnType = originalReturnType;
5130
+ }
5069
5131
  return (_b2 = (_a2 = relations[relationName]).nestedUpdate) == null ? void 0 : _b2.call(_a2, q, all, appendRelations[relationName]);
5070
5132
  };
5071
5133
  })
@@ -5235,7 +5297,6 @@ class QueryMethods {
5235
5297
  }
5236
5298
  _all() {
5237
5299
  this.query.returnType = "all";
5238
- removeFromQuery(this, "take");
5239
5300
  return this;
5240
5301
  }
5241
5302
  take() {
@@ -5243,7 +5304,6 @@ class QueryMethods {
5243
5304
  }
5244
5305
  _take() {
5245
5306
  this.query.returnType = "oneOrThrow";
5246
- this.query.take = true;
5247
5307
  return this;
5248
5308
  }
5249
5309
  takeOptional() {
@@ -5251,7 +5311,6 @@ class QueryMethods {
5251
5311
  }
5252
5312
  _takeOptional() {
5253
5313
  this.query.returnType = "one";
5254
- this.query.take = true;
5255
5314
  return this;
5256
5315
  }
5257
5316
  rows() {
@@ -5259,7 +5318,6 @@ class QueryMethods {
5259
5318
  }
5260
5319
  _rows() {
5261
5320
  this.query.returnType = "rows";
5262
- removeFromQuery(this, "take");
5263
5321
  return this;
5264
5322
  }
5265
5323
  pluck(select) {
@@ -5267,7 +5325,6 @@ class QueryMethods {
5267
5325
  }
5268
5326
  _pluck(select) {
5269
5327
  this.query.returnType = "pluck";
5270
- removeFromQuery(this, "take");
5271
5328
  this.query.select = [select];
5272
5329
  addParserForSelectItem(this, this.query.as || this.table, "pluck", select);
5273
5330
  return this;
@@ -5277,7 +5334,6 @@ class QueryMethods {
5277
5334
  }
5278
5335
  _exec() {
5279
5336
  this.query.returnType = "void";
5280
- removeFromQuery(this, "take");
5281
5337
  return this;
5282
5338
  }
5283
5339
  clone() {
@@ -5386,7 +5442,6 @@ class QueryMethods {
5386
5442
  const q = this._getOptional(raw("true"));
5387
5443
  q.query.notFoundDefault = false;
5388
5444
  q.query.coalesceValue = false;
5389
- delete q.query.take;
5390
5445
  return q;
5391
5446
  }
5392
5447
  truncate(options) {
@@ -5426,7 +5481,8 @@ applyMixins(QueryMethods, [
5426
5481
  QueryLog,
5427
5482
  QueryCallbacks,
5428
5483
  QueryUpsert,
5429
- QueryGet
5484
+ QueryGet,
5485
+ MergeQueryMethods
5430
5486
  ]);
5431
5487
 
5432
5488
  var __defProp = Object.defineProperty;
@@ -5470,7 +5526,6 @@ class Db {
5470
5526
  this.query = {
5471
5527
  adapter,
5472
5528
  handleResult,
5473
- returnType: "all",
5474
5529
  logger,
5475
5530
  log: logParamToLogObject(logger, options.log)
5476
5531
  };
@@ -5518,7 +5573,7 @@ const createDb = (_a) => {
5518
5573
  var _b = _a, {
5519
5574
  log,
5520
5575
  logger,
5521
- columnTypes: ct = columnTypes
5576
+ columnTypes: ct
5522
5577
  } = _b, options = __objRest(_b, [
5523
5578
  "log",
5524
5579
  "logger",
@@ -5553,8 +5608,6 @@ const createDb = (_a) => {
5553
5608
  return db;
5554
5609
  };
5555
5610
 
5556
- const defaultsKey = Symbol("defaults");
5557
-
5558
5611
  const relationQueryKey = Symbol("relationQuery");
5559
5612
  const isRequiredRelationKey = Symbol("isRequiredRelation");
5560
5613
 
@@ -5604,6 +5657,7 @@ exports.LineColumn = LineColumn;
5604
5657
  exports.LsegColumn = LsegColumn;
5605
5658
  exports.MacAddr8Column = MacAddr8Column;
5606
5659
  exports.MacAddrColumn = MacAddrColumn;
5660
+ exports.MergeQueryMethods = MergeQueryMethods;
5607
5661
  exports.MoneyColumn = MoneyColumn;
5608
5662
  exports.MoreThanOneRowError = MoreThanOneRowError;
5609
5663
  exports.NotFoundError = NotFoundError;
@@ -5663,6 +5717,7 @@ exports.aggregate1FunctionNames = aggregate1FunctionNames;
5663
5717
  exports.applyMixins = applyMixins;
5664
5718
  exports.array = array;
5665
5719
  exports.arrayToEnum = arrayToEnum;
5720
+ exports.checkIfASimpleQuery = checkIfASimpleQuery;
5666
5721
  exports.columnTypes = columnTypes;
5667
5722
  exports.columnUtils = utils;
5668
5723
  exports.constructType = constructType;
@@ -5712,13 +5767,12 @@ exports.pushQueryArray = pushQueryArray;
5712
5767
  exports.pushQueryOn = pushQueryOn;
5713
5768
  exports.pushQueryOrOn = pushQueryOrOn;
5714
5769
  exports.pushQueryValue = pushQueryValue;
5715
- exports.queryKeysOfNotSimpleQuery = queryKeysOfNotSimpleQuery;
5716
5770
  exports.queryMethodByReturnType = queryMethodByReturnType;
5771
+ exports.queryTypeWithLimitOne = queryTypeWithLimitOne;
5717
5772
  exports.quote = quote;
5718
5773
  exports.raw = raw;
5719
5774
  exports.record = record;
5720
5775
  exports.relationQueryKey = relationQueryKey;
5721
- exports.removeFromQuery = removeFromQuery;
5722
5776
  exports.required = required;
5723
5777
  exports.resetTableData = resetTableData;
5724
5778
  exports.scalarTypes = scalarTypes;