@snowtop/ent 0.2.4 → 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.
- package/action/action.js +5 -5
- package/action/executor.d.ts +1 -1
- package/action/executor.js +4 -4
- package/action/experimental_action.d.ts +7 -4
- package/action/experimental_action.js +18 -8
- package/action/operations.js +17 -7
- package/action/orchestrator.d.ts +10 -2
- package/action/orchestrator.js +29 -31
- package/action/privacy.d.ts +2 -2
- package/action/relative_value.js +3 -3
- package/auth/auth.d.ts +0 -1
- package/auth/auth.js +4 -5
- package/core/base.js +5 -5
- package/core/clause.js +76 -67
- package/core/config.d.ts +1 -1
- package/core/config.js +22 -9
- package/core/context.d.ts +0 -1
- package/core/convert.d.ts +0 -1
- package/core/convert.js +16 -17
- package/core/date.js +1 -2
- package/core/db.js +17 -7
- package/core/ent.d.ts +2 -0
- package/core/ent.js +127 -92
- package/core/global_schema.js +6 -7
- package/core/loaders/assoc_count_loader.d.ts +2 -2
- package/core/loaders/assoc_count_loader.js +17 -7
- package/core/loaders/assoc_edge_loader.d.ts +2 -2
- package/core/loaders/assoc_edge_loader.js +44 -20
- package/core/loaders/cache_utils.d.ts +1 -0
- package/core/loaders/cache_utils.js +28 -0
- package/core/loaders/index.d.ts +1 -0
- package/core/loaders/index.js +4 -1
- package/core/loaders/loader.d.ts +2 -0
- package/core/loaders/loader.js +20 -3
- package/core/loaders/object_loader.d.ts +6 -4
- package/core/loaders/object_loader.js +86 -48
- package/core/loaders/query_loader.d.ts +2 -2
- package/core/loaders/query_loader.js +25 -9
- package/core/loaders/raw_count_loader.d.ts +2 -2
- package/core/loaders/raw_count_loader.js +22 -10
- package/core/logger.js +6 -7
- package/core/privacy.d.ts +2 -2
- package/core/privacy.js +4 -5
- package/core/query/assoc_query.js +17 -7
- package/core/query/query.js +17 -7
- package/core/query/shared_assoc_test.js +1 -2
- package/core/query_impl.js +4 -5
- package/core/viewer.d.ts +2 -2
- package/graphql/graphql_field_helpers.js +22 -22
- package/graphql/mutations/union.js +1 -2
- package/graphql/node_resolver.js +7 -7
- package/graphql/query/shared_assoc_test.js +1 -2
- package/graphql/scalars/date.js +8 -3
- package/graphql/scalars/time.d.ts +1 -1
- package/imports/dataz/example1/_auth.js +14 -10
- package/imports/index.js +18 -9
- package/index.js +17 -7
- package/names/names.js +61 -18
- package/package.json +14 -17
- package/parse_schema/parse.js +2 -3
- package/schema/binary_field.js +3 -3
- package/schema/field.js +45 -35
- package/schema/json_field.js +7 -7
- package/schema/schema.js +12 -12
- package/schema/struct_field.js +4 -4
- package/schema/union_field.js +3 -3
- package/scripts/custom_compiler.js +17 -7
- package/scripts/custom_graphql.js +17 -7
- package/scripts/fix_action_exports.js +17 -7
- package/scripts/move_types.js +17 -7
- package/scripts/read_schema.js +17 -7
- package/testutils/action/complex_schemas.js +28 -18
- package/testutils/builder.d.ts +1 -1
- package/testutils/builder.js +7 -7
- package/testutils/db/fixture.js +1 -2
- package/testutils/db/temp_db.js +54 -44
- package/testutils/db/value.js +3 -4
- package/testutils/db_mock.js +12 -0
- package/testutils/ent-graphql-tests/index.d.ts +3 -3
- package/testutils/ent-graphql-tests/index.js +27 -18
- package/testutils/fake_data/const.js +2 -2
- package/testutils/fake_data/fake_contact.js +20 -10
- package/testutils/fake_data/fake_event.js +20 -10
- package/testutils/fake_data/fake_tag.js +21 -11
- package/testutils/fake_data/fake_user.js +21 -11
- package/testutils/fake_data/test_helpers.js +17 -17
- package/testutils/fake_data/user_query.js +19 -9
- package/testutils/parse_sql.js +151 -43
- package/testutils/query.js +2 -3
- package/testutils/soft_delete.js +17 -7
- package/testutils/test_edge_global_schema.js +17 -7
- package/testutils/write.js +20 -11
- package/tsc/ast.js +27 -18
- package/tsc/compilerOptions.js +22 -13
- package/tsc/move_generated.js +18 -9
- package/tsc/transform.js +18 -9
- package/tsc/transform_action.js +17 -7
- 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 (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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.
|
|
27
|
-
exports.
|
|
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 (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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 =
|
|
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
package/core/convert.d.ts
CHANGED
package/core/convert.js
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
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 =
|
|
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;
|