@snowtop/ent 0.2.5 → 0.2.6

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 (97) hide show
  1. package/action/action.js +5 -5
  2. package/action/executor.d.ts +1 -1
  3. package/action/executor.js +4 -4
  4. package/action/experimental_action.js +5 -5
  5. package/action/operations.js +17 -7
  6. package/action/orchestrator.d.ts +2 -2
  7. package/action/orchestrator.js +17 -7
  8. package/action/privacy.d.ts +2 -2
  9. package/action/relative_value.js +3 -3
  10. package/auth/auth.d.ts +0 -1
  11. package/auth/auth.js +4 -5
  12. package/core/base.js +5 -5
  13. package/core/clause.js +76 -67
  14. package/core/config.d.ts +1 -1
  15. package/core/config.js +22 -9
  16. package/core/context.d.ts +0 -1
  17. package/core/convert.d.ts +0 -1
  18. package/core/convert.js +16 -17
  19. package/core/date.js +1 -2
  20. package/core/db.js +17 -7
  21. package/core/ent.d.ts +2 -0
  22. package/core/ent.js +127 -92
  23. package/core/global_schema.js +6 -7
  24. package/core/loaders/assoc_count_loader.d.ts +2 -2
  25. package/core/loaders/assoc_count_loader.js +17 -7
  26. package/core/loaders/assoc_edge_loader.d.ts +2 -2
  27. package/core/loaders/assoc_edge_loader.js +44 -20
  28. package/core/loaders/cache_utils.d.ts +1 -0
  29. package/core/loaders/cache_utils.js +28 -0
  30. package/core/loaders/index.d.ts +1 -0
  31. package/core/loaders/index.js +4 -1
  32. package/core/loaders/loader.d.ts +2 -0
  33. package/core/loaders/loader.js +20 -3
  34. package/core/loaders/object_loader.d.ts +6 -4
  35. package/core/loaders/object_loader.js +86 -48
  36. package/core/loaders/query_loader.d.ts +2 -2
  37. package/core/loaders/query_loader.js +25 -9
  38. package/core/loaders/raw_count_loader.d.ts +2 -2
  39. package/core/loaders/raw_count_loader.js +22 -10
  40. package/core/logger.js +6 -7
  41. package/core/privacy.d.ts +2 -2
  42. package/core/privacy.js +4 -5
  43. package/core/query/assoc_query.js +17 -7
  44. package/core/query/query.js +17 -7
  45. package/core/query/shared_assoc_test.js +1 -2
  46. package/core/query_impl.js +4 -5
  47. package/core/viewer.d.ts +2 -2
  48. package/graphql/graphql_field_helpers.js +22 -22
  49. package/graphql/mutations/union.js +1 -2
  50. package/graphql/node_resolver.js +7 -7
  51. package/graphql/query/shared_assoc_test.js +1 -2
  52. package/graphql/scalars/date.js +8 -3
  53. package/graphql/scalars/time.d.ts +1 -1
  54. package/imports/dataz/example1/_auth.js +14 -10
  55. package/imports/index.js +18 -9
  56. package/index.js +17 -7
  57. package/names/names.js +61 -18
  58. package/package.json +14 -17
  59. package/parse_schema/parse.js +2 -3
  60. package/schema/binary_field.js +3 -3
  61. package/schema/field.js +45 -35
  62. package/schema/json_field.js +7 -7
  63. package/schema/schema.js +12 -12
  64. package/schema/struct_field.js +4 -4
  65. package/schema/union_field.js +3 -3
  66. package/scripts/custom_compiler.js +17 -7
  67. package/scripts/custom_graphql.js +17 -7
  68. package/scripts/fix_action_exports.js +17 -7
  69. package/scripts/move_types.js +17 -7
  70. package/scripts/read_schema.js +17 -7
  71. package/testutils/action/complex_schemas.js +28 -18
  72. package/testutils/builder.d.ts +1 -1
  73. package/testutils/builder.js +7 -7
  74. package/testutils/db/fixture.js +1 -2
  75. package/testutils/db/temp_db.js +54 -44
  76. package/testutils/db/value.js +3 -4
  77. package/testutils/db_mock.js +12 -0
  78. package/testutils/ent-graphql-tests/index.d.ts +3 -3
  79. package/testutils/ent-graphql-tests/index.js +27 -18
  80. package/testutils/fake_data/const.js +2 -2
  81. package/testutils/fake_data/fake_contact.js +20 -10
  82. package/testutils/fake_data/fake_event.js +20 -10
  83. package/testutils/fake_data/fake_tag.js +21 -11
  84. package/testutils/fake_data/fake_user.js +21 -11
  85. package/testutils/fake_data/test_helpers.js +17 -17
  86. package/testutils/fake_data/user_query.js +19 -9
  87. package/testutils/parse_sql.js +151 -43
  88. package/testutils/query.js +2 -3
  89. package/testutils/soft_delete.js +17 -7
  90. package/testutils/test_edge_global_schema.js +17 -7
  91. package/testutils/write.js +20 -11
  92. package/tsc/ast.js +27 -18
  93. package/tsc/compilerOptions.js +22 -13
  94. package/tsc/move_generated.js +18 -9
  95. package/tsc/transform.js +18 -9
  96. package/tsc/transform_action.js +17 -7
  97. package/tsc/transform_schema.js +17 -7
package/core/clause.js CHANGED
@@ -15,16 +15,83 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.JSONKeyInList = exports.JSONBKeyInList = exports.JSONKeyExists = exports.JSONPathValuePredicate = exports.JSONObjectFieldKeyAsText = exports.JSONObjectFieldKeyASJSON = exports.sensitiveValue = exports.TsVectorWebsearchToTsQuery = exports.TsVectorPhraseToTsQuery = exports.TsVectorPlainToTsQuery = exports.TsVectorColTsQuery = exports.WebsearchToTsQuery = exports.PhraseToTsQuery = exports.PlainToTsQuery = exports.TsQuery = exports.DBTypeNotIn = exports.TextNotIn = exports.IntegerNotIn = exports.UuidNotIn = exports.DBTypeIn = exports.TextIn = exports.IntegerIn = exports.UuidIn = exports.In = exports.OrOptional = exports.Or = exports.AndOptional = exports.And = exports.LessEq = exports.GreaterEq = exports.Less = exports.Greater = exports.NotEq = exports.ContainsIgnoreCase = exports.EndsWithIgnoreCase = exports.StartsWithIgnoreCase = exports.Contains = exports.EndsWith = exports.StartsWith = exports.Eq = exports.ArrayNotEq = exports.ArrayEq = exports.PostgresArrayNotOverlaps = exports.PostgresArrayOverlaps = exports.PostgresArrayNotContains = exports.PostgresArrayNotContainsValue = exports.PostgresArrayContains = exports.PostgresArrayContainsValue = exports.notInClause = exports.inClause = void 0;
27
- exports.Expression = exports.getCombinedClause = exports.Modulo = exports.Divide = exports.Multiply = exports.Subtract = exports.Add = exports.PaginationMultipleColsQuery = exports.PaginationUnboundColsQuery = exports.PaginationMultipleColsSubQuery = void 0;
36
+ exports.notInClause = exports.inClause = void 0;
37
+ exports.PostgresArrayContainsValue = PostgresArrayContainsValue;
38
+ exports.PostgresArrayContains = PostgresArrayContains;
39
+ exports.PostgresArrayNotContainsValue = PostgresArrayNotContainsValue;
40
+ exports.PostgresArrayNotContains = PostgresArrayNotContains;
41
+ exports.PostgresArrayOverlaps = PostgresArrayOverlaps;
42
+ exports.PostgresArrayNotOverlaps = PostgresArrayNotOverlaps;
43
+ exports.ArrayEq = ArrayEq;
44
+ exports.ArrayNotEq = ArrayNotEq;
45
+ exports.Eq = Eq;
46
+ exports.StartsWith = StartsWith;
47
+ exports.EndsWith = EndsWith;
48
+ exports.Contains = Contains;
49
+ exports.StartsWithIgnoreCase = StartsWithIgnoreCase;
50
+ exports.EndsWithIgnoreCase = EndsWithIgnoreCase;
51
+ exports.ContainsIgnoreCase = ContainsIgnoreCase;
52
+ exports.NotEq = NotEq;
53
+ exports.Greater = Greater;
54
+ exports.Less = Less;
55
+ exports.GreaterEq = GreaterEq;
56
+ exports.LessEq = LessEq;
57
+ exports.And = And;
58
+ exports.AndOptional = AndOptional;
59
+ exports.Or = Or;
60
+ exports.OrOptional = OrOptional;
61
+ exports.In = In;
62
+ exports.UuidIn = UuidIn;
63
+ exports.IntegerIn = IntegerIn;
64
+ exports.TextIn = TextIn;
65
+ exports.DBTypeIn = DBTypeIn;
66
+ exports.UuidNotIn = UuidNotIn;
67
+ exports.IntegerNotIn = IntegerNotIn;
68
+ exports.TextNotIn = TextNotIn;
69
+ exports.DBTypeNotIn = DBTypeNotIn;
70
+ exports.TsQuery = TsQuery;
71
+ exports.PlainToTsQuery = PlainToTsQuery;
72
+ exports.PhraseToTsQuery = PhraseToTsQuery;
73
+ exports.WebsearchToTsQuery = WebsearchToTsQuery;
74
+ exports.TsVectorColTsQuery = TsVectorColTsQuery;
75
+ exports.TsVectorPlainToTsQuery = TsVectorPlainToTsQuery;
76
+ exports.TsVectorPhraseToTsQuery = TsVectorPhraseToTsQuery;
77
+ exports.TsVectorWebsearchToTsQuery = TsVectorWebsearchToTsQuery;
78
+ exports.sensitiveValue = sensitiveValue;
79
+ exports.JSONObjectFieldKeyASJSON = JSONObjectFieldKeyASJSON;
80
+ exports.JSONObjectFieldKeyAsText = JSONObjectFieldKeyAsText;
81
+ exports.JSONPathValuePredicate = JSONPathValuePredicate;
82
+ exports.JSONKeyExists = JSONKeyExists;
83
+ exports.JSONBKeyInList = JSONBKeyInList;
84
+ exports.JSONKeyInList = JSONKeyInList;
85
+ exports.PaginationMultipleColsSubQuery = PaginationMultipleColsSubQuery;
86
+ exports.PaginationUnboundColsQuery = PaginationUnboundColsQuery;
87
+ exports.PaginationMultipleColsQuery = PaginationMultipleColsQuery;
88
+ exports.Add = Add;
89
+ exports.Subtract = Subtract;
90
+ exports.Multiply = Multiply;
91
+ exports.Divide = Divide;
92
+ exports.Modulo = Modulo;
93
+ exports.getCombinedClause = getCombinedClause;
94
+ exports.Expression = Expression;
28
95
  const db_1 = __importStar(require("./db"));
29
96
  const query_impl_1 = require("./query_impl");
30
97
  function isSensitive(val) {
@@ -522,7 +589,6 @@ class websearchTosQueryClause extends tsQueryClause {
522
589
  function PostgresArrayContainsValue(col, value, overrideAlias) {
523
590
  return new postgresArrayOperator(col, value, "@>", { overrideAlias });
524
591
  }
525
- exports.PostgresArrayContainsValue = PostgresArrayContainsValue;
526
592
  /**
527
593
  * creates a clause to determine if every item in the list is stored in the array stored in the column in the db
528
594
  * only works with postgres gin indexes
@@ -531,7 +597,6 @@ exports.PostgresArrayContainsValue = PostgresArrayContainsValue;
531
597
  function PostgresArrayContains(col, value, overrideAlias) {
532
598
  return new postgresArrayOperatorList(col, value, "@>", { overrideAlias });
533
599
  }
534
- exports.PostgresArrayContains = PostgresArrayContains;
535
600
  /**
536
601
  * creates a clause to determine if the given value is NOT contained in the array stored in the column in the db
537
602
  * only works with postgres gin indexes
@@ -543,7 +608,6 @@ function PostgresArrayNotContainsValue(col, value, overrideAlias) {
543
608
  overrideAlias,
544
609
  });
545
610
  }
546
- exports.PostgresArrayNotContainsValue = PostgresArrayNotContainsValue;
547
611
  /**
548
612
  * creates a clause to determine if every item in the list is NOT stored in the array stored in the column in the db
549
613
  * only works with postgres gin indexes
@@ -555,7 +619,6 @@ function PostgresArrayNotContains(col, value, overrideAlias) {
555
619
  overrideAlias,
556
620
  });
557
621
  }
558
- exports.PostgresArrayNotContains = PostgresArrayNotContains;
559
622
  /**
560
623
  * creates a clause to determine if the arrays overlap, that is, do they have any elements in common
561
624
  * only works with postgres gin indexes
@@ -566,7 +629,6 @@ function PostgresArrayOverlaps(col, value, overrideAlias) {
566
629
  overrideAlias,
567
630
  });
568
631
  }
569
- exports.PostgresArrayOverlaps = PostgresArrayOverlaps;
570
632
  /**
571
633
  * creates a clause to determine if the arrays do not overlap, that is, do they have any elements in common
572
634
  * only works with postgres gin indexes
@@ -578,91 +640,75 @@ function PostgresArrayNotOverlaps(col, value, overrideAlias) {
578
640
  overrideAlias,
579
641
  });
580
642
  }
581
- exports.PostgresArrayNotOverlaps = PostgresArrayNotOverlaps;
582
643
  /**
583
644
  * @deprecated use PostgresArrayContainsValue
584
645
  */
585
646
  function ArrayEq(col, value) {
586
647
  return new arraySimpleClause(col, value, "=");
587
648
  }
588
- exports.ArrayEq = ArrayEq;
589
649
  /**
590
650
  * @deprecated use PostgresNotArrayContains
591
651
  */
592
652
  function ArrayNotEq(col, value) {
593
653
  return new arraySimpleClause(col, value, "!=");
594
654
  }
595
- exports.ArrayNotEq = ArrayNotEq;
596
655
  function Eq(col, value, overrideAlias) {
597
656
  return new simpleClause(col, value, "=", {
598
657
  handleNull: new isNullClause(col, overrideAlias),
599
658
  overrideAlias,
600
659
  });
601
660
  }
602
- exports.Eq = Eq;
603
661
  function StartsWith(col, value, overrideAlias) {
604
662
  return new simpleClause(col, `${value}%`, "LIKE", {
605
663
  overrideAlias,
606
664
  });
607
665
  }
608
- exports.StartsWith = StartsWith;
609
666
  function EndsWith(col, value, overrideAlias) {
610
667
  return new simpleClause(col, `%${value}`, "LIKE", {
611
668
  overrideAlias,
612
669
  });
613
670
  }
614
- exports.EndsWith = EndsWith;
615
671
  function Contains(col, value, overrideAlias) {
616
672
  return new simpleClause(col, `%${value}%`, "LIKE", {
617
673
  overrideAlias,
618
674
  });
619
675
  }
620
- exports.Contains = Contains;
621
676
  function StartsWithIgnoreCase(col, value, overrideAlias) {
622
677
  return new simpleClause(col, `${value}%`, "ILIKE", {
623
678
  overrideAlias,
624
679
  });
625
680
  }
626
- exports.StartsWithIgnoreCase = StartsWithIgnoreCase;
627
681
  function EndsWithIgnoreCase(col, value, overrideAlias) {
628
682
  return new simpleClause(col, `%${value}`, "ILIKE", { overrideAlias });
629
683
  }
630
- exports.EndsWithIgnoreCase = EndsWithIgnoreCase;
631
684
  function ContainsIgnoreCase(col, value, overrideAlias) {
632
685
  return new simpleClause(col, `%${value}%`, "ILIKE", {
633
686
  overrideAlias,
634
687
  });
635
688
  }
636
- exports.ContainsIgnoreCase = ContainsIgnoreCase;
637
689
  function NotEq(col, value, overrideAlias) {
638
690
  return new simpleClause(col, value, "!=", {
639
691
  handleNull: new isNotNullClause(col, overrideAlias),
640
692
  overrideAlias,
641
693
  });
642
694
  }
643
- exports.NotEq = NotEq;
644
695
  function Greater(col, value, overrideAlias) {
645
696
  return new simpleClause(col, value, ">", {
646
697
  overrideAlias,
647
698
  });
648
699
  }
649
- exports.Greater = Greater;
650
700
  function Less(col, value, overrideAlias) {
651
701
  return new simpleClause(col, value, "<", { overrideAlias });
652
702
  }
653
- exports.Less = Less;
654
703
  function GreaterEq(col, value, overrideAlias) {
655
704
  return new simpleClause(col, value, ">=", { overrideAlias });
656
705
  }
657
- exports.GreaterEq = GreaterEq;
658
706
  function LessEq(col, value, overrideAlias) {
659
707
  return new simpleClause(col, value, "<=", { overrideAlias });
660
708
  }
661
- exports.LessEq = LessEq;
662
709
  function And(...args) {
663
710
  return new compositeClause(args, " AND ");
664
711
  }
665
- exports.And = And;
666
712
  function AndOptional(...args) {
667
713
  // @ts-ignore
668
714
  let filtered = args.filter((v) => v !== undefined);
@@ -671,11 +717,9 @@ function AndOptional(...args) {
671
717
  }
672
718
  return And(...filtered);
673
719
  }
674
- exports.AndOptional = AndOptional;
675
720
  function Or(...args) {
676
721
  return new compositeClause(args, " OR ");
677
722
  }
678
- exports.Or = Or;
679
723
  function OrOptional(...args) {
680
724
  // @ts-ignore
681
725
  let filtered = args.filter((v) => v !== undefined);
@@ -684,7 +728,6 @@ function OrOptional(...args) {
684
728
  }
685
729
  return Or(...filtered);
686
730
  }
687
- exports.OrOptional = OrOptional;
688
731
  function In(...args) {
689
732
  if (args.length < 2) {
690
733
  throw new Error(`invalid args passed to In`);
@@ -695,19 +738,15 @@ function In(...args) {
695
738
  }
696
739
  return new inClause(args[0], args.slice(1));
697
740
  }
698
- exports.In = In;
699
741
  function UuidIn(col, values, overrideAlias) {
700
742
  return new inClause(col, values, "uuid", overrideAlias);
701
743
  }
702
- exports.UuidIn = UuidIn;
703
744
  function IntegerIn(col, values, overrideAlias) {
704
745
  return new inClause(col, values, "integer", overrideAlias);
705
746
  }
706
- exports.IntegerIn = IntegerIn;
707
747
  function TextIn(col, values, overrideAlias) {
708
748
  return new inClause(col, values, "text", overrideAlias);
709
749
  }
710
- exports.TextIn = TextIn;
711
750
  /*
712
751
  * if not uuid or text, pass the db type that can be used to cast this query
713
752
  * if we end up with a large list of ids
@@ -715,19 +754,15 @@ exports.TextIn = TextIn;
715
754
  function DBTypeIn(col, values, typ, overrideAlias) {
716
755
  return new inClause(col, values, typ, overrideAlias);
717
756
  }
718
- exports.DBTypeIn = DBTypeIn;
719
757
  function UuidNotIn(col, values, overrideAlias) {
720
758
  return new notInClause(col, values, "uuid", overrideAlias);
721
759
  }
722
- exports.UuidNotIn = UuidNotIn;
723
760
  function IntegerNotIn(col, values, overrideAlias) {
724
761
  return new notInClause(col, values, "integer", overrideAlias);
725
762
  }
726
- exports.IntegerNotIn = IntegerNotIn;
727
763
  function TextNotIn(col, values, overrideAlias) {
728
764
  return new notInClause(col, values, "text", overrideAlias);
729
765
  }
730
- exports.TextNotIn = TextNotIn;
731
766
  /*
732
767
  * if not uuid or text, pass the db type that can be used to cast this query
733
768
  * if we end up with a large list of ids
@@ -735,7 +770,6 @@ exports.TextNotIn = TextNotIn;
735
770
  function DBTypeNotIn(col, values, typ, overrideAlias) {
736
771
  return new notInClause(col, values, typ, overrideAlias);
737
772
  }
738
- exports.DBTypeNotIn = DBTypeNotIn;
739
773
  // if string defaults to english
740
774
  // https://www.postgresql.org/docs/current/textsearch-controls.html#TEXTSEARCH-PARSING-QUERIES
741
775
  // to_tsquery
@@ -745,25 +779,20 @@ exports.DBTypeNotIn = DBTypeNotIn;
745
779
  function TsQuery(col, val, overrideAlias) {
746
780
  return new tsQueryClause(col, val, { overrideAlias });
747
781
  }
748
- exports.TsQuery = TsQuery;
749
782
  function PlainToTsQuery(col, val, overrideAlias) {
750
783
  return new plainToTsQueryClause(col, val, { overrideAlias });
751
784
  }
752
- exports.PlainToTsQuery = PlainToTsQuery;
753
785
  function PhraseToTsQuery(col, val, overrideAlias) {
754
786
  return new phraseToTsQueryClause(col, val, { overrideAlias });
755
787
  }
756
- exports.PhraseToTsQuery = PhraseToTsQuery;
757
788
  function WebsearchToTsQuery(col, val, overrideAlias) {
758
789
  return new websearchTosQueryClause(col, val, { overrideAlias });
759
790
  }
760
- exports.WebsearchToTsQuery = WebsearchToTsQuery;
761
791
  // TsVectorColTsQuery is used when the column is not a tsvector field e.g.
762
792
  // when there's an index just on the field and is not a combination of multiple fields
763
793
  function TsVectorColTsQuery(col, val, overrideAlias) {
764
794
  return new tsQueryClause(col, val, { tsVectorCol: true, overrideAlias });
765
795
  }
766
- exports.TsVectorColTsQuery = TsVectorColTsQuery;
767
796
  // TsVectorPlainToTsQuery is used when the column is not a tsvector field e.g.
768
797
  // when there's an index just on the field and is not a combination of multiple fields
769
798
  // TODO do these 4 need TsQuery because would be nice to have language?
@@ -774,7 +803,6 @@ function TsVectorPlainToTsQuery(col, val, overrideAlias) {
774
803
  overrideAlias,
775
804
  });
776
805
  }
777
- exports.TsVectorPlainToTsQuery = TsVectorPlainToTsQuery;
778
806
  // TsVectorPhraseToTsQuery is used when the column is not a tsvector field e.g.
779
807
  // when there's an index just on the field and is not a combination of multiple fields
780
808
  function TsVectorPhraseToTsQuery(col, val, overrideAlias) {
@@ -783,7 +811,6 @@ function TsVectorPhraseToTsQuery(col, val, overrideAlias) {
783
811
  overrideAlias,
784
812
  });
785
813
  }
786
- exports.TsVectorPhraseToTsQuery = TsVectorPhraseToTsQuery;
787
814
  // TsVectorWebsearchToTsQuery is used when the column is not a tsvector field e.g.
788
815
  // when there's an index just on the field and is not a combination of multiple fields
789
816
  function TsVectorWebsearchToTsQuery(col, val, overrideAlias) {
@@ -792,7 +819,6 @@ function TsVectorWebsearchToTsQuery(col, val, overrideAlias) {
792
819
  overrideAlias,
793
820
  });
794
821
  }
795
- exports.TsVectorWebsearchToTsQuery = TsVectorWebsearchToTsQuery;
796
822
  // TODO would be nice to support this with building blocks but not supporting for now
797
823
  // AND: foo & bar,
798
824
  // OR: foo | bar
@@ -812,7 +838,6 @@ function sensitiveValue(val) {
812
838
  },
813
839
  };
814
840
  }
815
- exports.sensitiveValue = sensitiveValue;
816
841
  // These don't return Clauses but return helpful things that can be passed to clauses
817
842
  // https://www.postgresql.org/docs/12/functions-json.html#FUNCTIONS-JSON-OP-TABLE
818
843
  // see test in db_clause.test.ts
@@ -821,12 +846,10 @@ function JSONObjectFieldKeyASJSON(col, field, overrideAlias) {
821
846
  // type as keyof T to make it easier to use in other queries
822
847
  return `${renderCol(col, overrideAlias)}->'${field}'`;
823
848
  }
824
- exports.JSONObjectFieldKeyASJSON = JSONObjectFieldKeyASJSON;
825
849
  function JSONObjectFieldKeyAsText(col, field, overrideAlias) {
826
850
  // type as keyof T to make it easier to use in other queries
827
851
  return `${renderCol(col, overrideAlias)}->>'${field}'`;
828
852
  }
829
- exports.JSONObjectFieldKeyAsText = JSONObjectFieldKeyAsText;
830
853
  class jSONPathValuePredicateClause {
831
854
  constructor(col, path, value, pred, overrideAlias) {
832
855
  this.col = col;
@@ -870,7 +893,6 @@ class jSONPathValuePredicateClause {
870
893
  function JSONPathValuePredicate(dbCol, path, val, pred, overrideAlias) {
871
894
  return new jSONPathValuePredicateClause(dbCol, path, val, pred, overrideAlias);
872
895
  }
873
- exports.JSONPathValuePredicate = JSONPathValuePredicate;
874
896
  function JSONKeyExists(dbCol, val, overrideAlias) {
875
897
  return new simpleClause(dbCol, val, "?", {
876
898
  // TODO ola: does isNullClause make sense here???
@@ -878,7 +900,6 @@ function JSONKeyExists(dbCol, val, overrideAlias) {
878
900
  overrideAlias,
879
901
  });
880
902
  }
881
- exports.JSONKeyExists = JSONKeyExists;
882
903
  function JSONBKeyInList(dbCol, jsonCol, val, overrideAlias) {
883
904
  const opts = {
884
905
  fields: ["1"],
@@ -890,7 +911,6 @@ function JSONBKeyInList(dbCol, jsonCol, val, overrideAlias) {
890
911
  };
891
912
  return new existsQueryClause(opts);
892
913
  }
893
- exports.JSONBKeyInList = JSONBKeyInList;
894
914
  function JSONKeyInList(dbCol, jsonCol, val, overrideAlias) {
895
915
  const opts = {
896
916
  fields: ["1"],
@@ -902,7 +922,6 @@ function JSONKeyInList(dbCol, jsonCol, val, overrideAlias) {
902
922
  };
903
923
  return new existsQueryClause(opts);
904
924
  }
905
- exports.JSONKeyInList = JSONKeyInList;
906
925
  // TODO need a better name for this lol
907
926
  // this assumes we're doing the same direction twice which isn't necessarily accurate in the future...
908
927
  class paginationMultipleColumnsSubQueryClause {
@@ -946,7 +965,6 @@ class paginationMultipleColumnsSubQueryClause {
946
965
  function PaginationMultipleColsSubQuery(col, op, tableName, uniqueCol, val, overrideAlias) {
947
966
  return new paginationMultipleColumnsSubQueryClause(col, op, tableName, uniqueCol, val, overrideAlias);
948
967
  }
949
- exports.PaginationMultipleColsSubQuery = PaginationMultipleColsSubQuery;
950
968
  /**
951
969
  * When paginating over multiple ordered columns, we need to construct a nested
952
970
  * set of clauses to correctly filter. The resulting query will be structured as
@@ -1019,13 +1037,11 @@ function PaginationUnboundColsQuery(ordering) {
1019
1037
  });
1020
1038
  return nesting;
1021
1039
  }
1022
- exports.PaginationUnboundColsQuery = PaginationUnboundColsQuery;
1023
1040
  function PaginationMultipleColsQuery(sortCol, cursorCol, less, // if true, <, if false, >
1024
1041
  sortValue, cursorValue, overrideAlias) {
1025
1042
  const clauseFn = less ? Less : Greater;
1026
1043
  return And(Or(clauseFn(sortCol, sortValue, overrideAlias), And(Eq(sortCol, sortValue, overrideAlias), clauseFn(cursorCol, cursorValue, overrideAlias))));
1027
1044
  }
1028
- exports.PaginationMultipleColsQuery = PaginationMultipleColsQuery;
1029
1045
  // These 5 are used on the RHS of an expression
1030
1046
  function Add(col, value, overrideAlias) {
1031
1047
  return new simpleClause(col, value, "+", {
@@ -1033,35 +1049,30 @@ function Add(col, value, overrideAlias) {
1033
1049
  overrideAlias,
1034
1050
  });
1035
1051
  }
1036
- exports.Add = Add;
1037
1052
  function Subtract(col, value, overrideAlias) {
1038
1053
  return new simpleClause(col, value, "-", {
1039
1054
  handleNull: new isNullClause(col, overrideAlias),
1040
1055
  overrideAlias,
1041
1056
  });
1042
1057
  }
1043
- exports.Subtract = Subtract;
1044
1058
  function Multiply(col, value, overrideAlias) {
1045
1059
  return new simpleClause(col, value, "*", {
1046
1060
  handleNull: new isNullClause(col, overrideAlias),
1047
1061
  overrideAlias,
1048
1062
  });
1049
1063
  }
1050
- exports.Multiply = Multiply;
1051
1064
  function Divide(col, value, overrideAlias) {
1052
1065
  return new simpleClause(col, value, "/", {
1053
1066
  handleNull: new isNullClause(col, overrideAlias),
1054
1067
  overrideAlias,
1055
1068
  });
1056
1069
  }
1057
- exports.Divide = Divide;
1058
1070
  function Modulo(col, value, overrideAlias) {
1059
1071
  return new simpleClause(col, value, "%", {
1060
1072
  handleNull: new isNullClause(col, overrideAlias),
1061
1073
  overrideAlias,
1062
1074
  });
1063
1075
  }
1064
- exports.Modulo = Modulo;
1065
1076
  function getCombinedClause(options, cls, checkIntersection = false) {
1066
1077
  if (options.clause) {
1067
1078
  let optionClause;
@@ -1093,8 +1104,6 @@ function getCombinedClause(options, cls, checkIntersection = false) {
1093
1104
  }
1094
1105
  return cls;
1095
1106
  }
1096
- exports.getCombinedClause = getCombinedClause;
1097
1107
  function Expression(expression) {
1098
1108
  return new simpleExpression(expression);
1099
1109
  }
1100
- exports.Expression = Expression;
package/core/config.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { Database, DBDict } from "./db";
3
2
  type logType = "query" | "warn" | "info" | "error" | "debug";
4
3
  declare enum graphqlMutationName {
@@ -20,6 +19,7 @@ export interface Config {
20
19
  log?: logType | logType[];
21
20
  logQueryWithError?: boolean;
22
21
  defaultConnectionLimit?: number;
22
+ loaderMaxBatchSize?: number;
23
23
  }
24
24
  export interface ConfigWithCodegen extends Config {
25
25
  codegen?: CodegenConfig;
package/core/config.js CHANGED
@@ -15,24 +15,35 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
37
  };
28
38
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.loadConfig = void 0;
39
+ exports.loadConfig = loadConfig;
30
40
  const fs = __importStar(require("fs"));
31
41
  const js_yaml_1 = require("js-yaml");
32
42
  const db_1 = __importDefault(require("./db"));
33
43
  const path = __importStar(require("path"));
34
44
  const logger_1 = require("./logger");
35
45
  const ent_1 = require("./ent");
46
+ const loader_1 = require("./loaders/loader");
36
47
  // ent.config.ts eventually. for now ent.yml
37
48
  // or ent.yml?
38
49
  var graphqlMutationName;
@@ -65,6 +76,9 @@ function setConfig(cfg) {
65
76
  if (cfg.defaultConnectionLimit) {
66
77
  (0, ent_1.setDefaultLimit)(cfg.defaultConnectionLimit);
67
78
  }
79
+ if (cfg.loaderMaxBatchSize !== undefined) {
80
+ (0, loader_1.setLoaderMaxBatchSize)(cfg.loaderMaxBatchSize);
81
+ }
68
82
  }
69
83
  function isBuffer(b) {
70
84
  return b.write !== undefined;
@@ -105,4 +119,3 @@ function loadConfig(file) {
105
119
  throw e;
106
120
  }
107
121
  }
108
- exports.loadConfig = loadConfig;
package/core/context.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { IncomingMessage, ServerResponse } from "http";
3
2
  import { Data, Loader, LoaderWithLoadMany, QueryOptions, Viewer } from "./base";
4
3
  import { Context } from "./base";
package/core/convert.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  export declare function convertDate(val: any): Date;
3
2
  export declare function convertNullableDate(val: any): Date | null;
4
3
  export declare function convertBool(val: any): boolean;
package/core/convert.js CHANGED
@@ -1,6 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convertNullableTextToBuffer = exports.convertTextToBuffer = exports.convertNullableJSONList = exports.convertJSONList = exports.convertNullableJSON = exports.convertJSON = exports.convertNullableBoolList = exports.convertBoolList = exports.convertNullableDateList = exports.convertDateList = exports.convertNullableList = exports.convertList = exports.convertNullableBool = exports.convertBool = exports.convertNullableDate = exports.convertDate = void 0;
3
+ exports.convertDate = convertDate;
4
+ exports.convertNullableDate = convertNullableDate;
5
+ exports.convertBool = convertBool;
6
+ exports.convertNullableBool = convertNullableBool;
7
+ exports.convertList = convertList;
8
+ exports.convertNullableList = convertNullableList;
9
+ exports.convertDateList = convertDateList;
10
+ exports.convertNullableDateList = convertNullableDateList;
11
+ exports.convertBoolList = convertBoolList;
12
+ exports.convertNullableBoolList = convertNullableBoolList;
13
+ exports.convertJSON = convertJSON;
14
+ exports.convertNullableJSON = convertNullableJSON;
15
+ exports.convertJSONList = convertJSONList;
16
+ exports.convertNullableJSONList = convertNullableJSONList;
17
+ exports.convertTextToBuffer = convertTextToBuffer;
18
+ exports.convertNullableTextToBuffer = convertNullableTextToBuffer;
4
19
  const luxon_1 = require("luxon");
5
20
  // these are needed to deal with SQLite having different types stored in the db vs the representation
6
21
  // gotten back from the db/needed in ent land
@@ -17,14 +32,12 @@ function convertDate(val) {
17
32
  // assume date
18
33
  return val;
19
34
  }
20
- exports.convertDate = convertDate;
21
35
  function convertNullableDate(val) {
22
36
  if (val === null) {
23
37
  return null;
24
38
  }
25
39
  return convertDate(val);
26
40
  }
27
- exports.convertNullableDate = convertNullableDate;
28
41
  function convertBool(val) {
29
42
  if (typeof val === "number") {
30
43
  // assume 1 or 0
@@ -33,14 +46,12 @@ function convertBool(val) {
33
46
  // assume boolean
34
47
  return val;
35
48
  }
36
- exports.convertBool = convertBool;
37
49
  function convertNullableBool(val) {
38
50
  if (val === null) {
39
51
  return null;
40
52
  }
41
53
  return convertBool(val);
42
54
  }
43
- exports.convertNullableBool = convertNullableBool;
44
55
  function convertList(val, conv) {
45
56
  if (Array.isArray(val)) {
46
57
  return val;
@@ -57,7 +68,6 @@ function convertList(val, conv) {
57
68
  }
58
69
  return res;
59
70
  }
60
- exports.convertList = convertList;
61
71
  function convertNullableList(val, conv) {
62
72
  // undefined can happen with unsafe ents
63
73
  if (val === null || val === undefined) {
@@ -65,56 +75,45 @@ function convertNullableList(val, conv) {
65
75
  }
66
76
  return convertList(val, conv);
67
77
  }
68
- exports.convertNullableList = convertNullableList;
69
78
  function convertDateList(val) {
70
79
  return convertList(val, convertDate);
71
80
  }
72
- exports.convertDateList = convertDateList;
73
81
  function convertNullableDateList(val) {
74
82
  return convertNullableList(val, convertDate);
75
83
  }
76
- exports.convertNullableDateList = convertNullableDateList;
77
84
  function convertBoolList(val) {
78
85
  return convertList(val, convertBool);
79
86
  }
80
- exports.convertBoolList = convertBoolList;
81
87
  function convertNullableBoolList(val) {
82
88
  return convertNullableList(val, convertBool);
83
89
  }
84
- exports.convertNullableBoolList = convertNullableBoolList;
85
90
  function convertJSON(val) {
86
91
  if (typeof val === "string") {
87
92
  return JSON.parse(val);
88
93
  }
89
94
  return val;
90
95
  }
91
- exports.convertJSON = convertJSON;
92
96
  function convertNullableJSON(val) {
93
97
  if (val === null) {
94
98
  return val;
95
99
  }
96
100
  return convertJSON(val);
97
101
  }
98
- exports.convertNullableJSON = convertNullableJSON;
99
102
  function convertJSONList(val) {
100
103
  return convertList(val, convertJSON);
101
104
  }
102
- exports.convertJSONList = convertJSONList;
103
105
  function convertNullableJSONList(val) {
104
106
  return convertNullableList(val, convertJSON);
105
107
  }
106
- exports.convertNullableJSONList = convertNullableJSONList;
107
108
  function convertTextToBuffer(val) {
108
109
  if (typeof val === "string") {
109
110
  return Buffer.from(val, "base64");
110
111
  }
111
112
  return val;
112
113
  }
113
- exports.convertTextToBuffer = convertTextToBuffer;
114
114
  function convertNullableTextToBuffer(val) {
115
115
  if (val == null) {
116
116
  return val;
117
117
  }
118
118
  return convertTextToBuffer(val);
119
119
  }
120
- exports.convertNullableTextToBuffer = convertNullableTextToBuffer;
package/core/date.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseDate = void 0;
3
+ exports.parseDate = parseDate;
4
4
  const luxon_1 = require("luxon");
5
5
  function parseDate(val, throwErr) {
6
6
  let dt;
@@ -27,4 +27,3 @@ function parseDate(val, throwErr) {
27
27
  }
28
28
  return dt;
29
29
  }
30
- exports.parseDate = parseDate;