@voltro/database 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +285 -0
- package/dist/{fileBased-DEW2BvnP.js → fileBased-Dfuv6JWP.js} +67 -67
- package/dist/index.d.ts +52 -7
- package/dist/index.js +516 -516
- package/dist/sql.d.ts +70 -15
- package/dist/sql.js +717 -674
- package/package.json +2 -2
|
@@ -617,10 +617,10 @@ var r = (e) => {
|
|
|
617
617
|
...e.validatePatchSchema === void 0 ? {} : { validatePatchSchema: e.validatePatchSchema }
|
|
618
618
|
});
|
|
619
619
|
}),
|
|
620
|
-
|
|
620
|
+
nonReactive: (() => B({
|
|
621
621
|
tableName: e.tableName,
|
|
622
622
|
fields: e.fields,
|
|
623
|
-
isReactive: !
|
|
623
|
+
isReactive: !1,
|
|
624
624
|
appliedMixins: e.appliedMixins,
|
|
625
625
|
appliedIndexes: e.appliedIndexes,
|
|
626
626
|
appliedUniques: e.appliedUniques,
|
|
@@ -664,7 +664,7 @@ var r = (e) => {
|
|
|
664
664
|
return B({
|
|
665
665
|
tableName: e,
|
|
666
666
|
fields: n,
|
|
667
|
-
isReactive: !
|
|
667
|
+
isReactive: !0,
|
|
668
668
|
appliedMixins: [],
|
|
669
669
|
appliedIndexes: [],
|
|
670
670
|
appliedUniques: [],
|
|
@@ -693,38 +693,38 @@ var r = (e) => {
|
|
|
693
693
|
let t = W.get(e);
|
|
694
694
|
if (t === void 0) throw Error(`table '${e}' is not registered. Register it by wrapping it in \`databaseHandle({ ... })\` (the usual path) or call \`registerTable(t)\` explicitly before this runs. Note a \`queryFor(t)\` query carries its own source table, so eager-loads don't hit this — this error means a reconstructed descriptor or by-name tooling reached an unregistered table.`);
|
|
695
695
|
return t;
|
|
696
|
-
},
|
|
696
|
+
}, Le = () => [...W.values()], Re = () => {
|
|
697
697
|
W.clear();
|
|
698
|
-
},
|
|
698
|
+
}, ze = (e) => W.get(e)?.isReactive !== !1, Be = (e) => ({
|
|
699
699
|
op: "count",
|
|
700
700
|
alias: e ?? "count"
|
|
701
|
-
}),
|
|
701
|
+
}), Ve = (e, t) => ({
|
|
702
702
|
op: "count-distinct",
|
|
703
703
|
column: e,
|
|
704
704
|
alias: t ?? `count_distinct_${e}`
|
|
705
|
-
}),
|
|
705
|
+
}), He = (e, t) => ({
|
|
706
706
|
op: "sum",
|
|
707
707
|
column: e,
|
|
708
708
|
alias: t ?? `sum_${e}`
|
|
709
|
-
}),
|
|
709
|
+
}), Ue = (e, t) => ({
|
|
710
710
|
op: "avg",
|
|
711
711
|
column: e,
|
|
712
712
|
alias: t ?? `avg_${e}`
|
|
713
|
-
}),
|
|
713
|
+
}), We = (e, t) => ({
|
|
714
714
|
op: "min",
|
|
715
715
|
column: e,
|
|
716
716
|
alias: t ?? `min_${e}`
|
|
717
|
-
}),
|
|
717
|
+
}), Ge = (e, t) => ({
|
|
718
718
|
op: "max",
|
|
719
719
|
column: e,
|
|
720
720
|
alias: t ?? `max_${e}`
|
|
721
|
-
}),
|
|
721
|
+
}), Ke = (e, t) => ({
|
|
722
722
|
op: "column",
|
|
723
723
|
column: e,
|
|
724
724
|
alias: t ?? e
|
|
725
|
-
}),
|
|
725
|
+
}), q = (e) => (...t) => {
|
|
726
726
|
if (t.length < 2) throw Error(`${e}: requires at least two queries`);
|
|
727
|
-
return
|
|
727
|
+
return X({
|
|
728
728
|
table: t[0].descriptor.table,
|
|
729
729
|
predicate: void 0,
|
|
730
730
|
order: [],
|
|
@@ -736,37 +736,37 @@ var r = (e) => {
|
|
|
736
736
|
queries: t.map((e) => e.descriptor)
|
|
737
737
|
}
|
|
738
738
|
});
|
|
739
|
-
},
|
|
739
|
+
}, qe = q("union"), Je = q("union-all"), Ye = q("intersect"), Xe = q("except"), J = (e) => ({ over: (t) => ({
|
|
740
740
|
...e,
|
|
741
741
|
window: t
|
|
742
|
-
}) }),
|
|
742
|
+
}) }), Ze = (e = "rowNumber") => J({
|
|
743
743
|
op: "window-row-number",
|
|
744
744
|
alias: e
|
|
745
|
-
}),
|
|
745
|
+
}), Qe = (e = "rank") => J({
|
|
746
746
|
op: "window-rank",
|
|
747
747
|
alias: e
|
|
748
|
-
}),
|
|
748
|
+
}), $e = (e = "denseRank") => J({
|
|
749
749
|
op: "window-dense-rank",
|
|
750
750
|
alias: e
|
|
751
|
-
}),
|
|
751
|
+
}), et = (e, t = 1, n) => J({
|
|
752
752
|
op: "window-lag",
|
|
753
753
|
column: e,
|
|
754
754
|
alias: n ?? `lag_${e}`,
|
|
755
755
|
offset: t
|
|
756
|
-
}),
|
|
756
|
+
}), tt = (e, t = 1, n) => J({
|
|
757
757
|
op: "window-lead",
|
|
758
758
|
column: e,
|
|
759
759
|
alias: n ?? `lead_${e}`,
|
|
760
760
|
offset: t
|
|
761
|
-
}),
|
|
761
|
+
}), nt = (e, t) => J({
|
|
762
762
|
op: "window-sum-over",
|
|
763
763
|
column: e,
|
|
764
764
|
alias: t ?? `sum_${e}_over`
|
|
765
|
-
}),
|
|
765
|
+
}), rt = (e, t) => J({
|
|
766
766
|
op: "window-avg-over",
|
|
767
767
|
column: e,
|
|
768
768
|
alias: t ?? `avg_${e}_over`
|
|
769
|
-
}),
|
|
769
|
+
}), Y = (e, t, n) => {
|
|
770
770
|
let r = n?.find((e) => e.name === t) ?? K(e)?.appliedFullText?.find((e) => e.name === t);
|
|
771
771
|
if (r === void 0) throw Error(`.matching('${t}', ...): no full-text index named '${t}' is declared on table '${e}'. Declare it with \`table(...).fullTextIndex('${t}', [columns])\` first.`);
|
|
772
772
|
return {
|
|
@@ -774,17 +774,17 @@ var r = (e) => {
|
|
|
774
774
|
...r.config === void 0 ? {} : { config: r.config },
|
|
775
775
|
...r.weights === void 0 ? {} : { weights: r.weights }
|
|
776
776
|
};
|
|
777
|
-
},
|
|
777
|
+
}, X = (e) => ({
|
|
778
778
|
descriptor: e,
|
|
779
779
|
where(t) {
|
|
780
780
|
let n = e.predicate ? { and: [e.predicate, t] } : t;
|
|
781
|
-
return
|
|
781
|
+
return X({
|
|
782
782
|
...e,
|
|
783
783
|
predicate: n
|
|
784
784
|
});
|
|
785
785
|
},
|
|
786
786
|
orderBy(t, n = "asc") {
|
|
787
|
-
return
|
|
787
|
+
return X({
|
|
788
788
|
...e,
|
|
789
789
|
order: [...e.order, {
|
|
790
790
|
column: t,
|
|
@@ -793,37 +793,37 @@ var r = (e) => {
|
|
|
793
793
|
});
|
|
794
794
|
},
|
|
795
795
|
limit(t) {
|
|
796
|
-
return
|
|
796
|
+
return X({
|
|
797
797
|
...e,
|
|
798
798
|
take: t
|
|
799
799
|
});
|
|
800
800
|
},
|
|
801
801
|
offset(t) {
|
|
802
|
-
return
|
|
802
|
+
return X({
|
|
803
803
|
...e,
|
|
804
804
|
skip: t
|
|
805
805
|
});
|
|
806
806
|
},
|
|
807
807
|
select(...t) {
|
|
808
|
-
return
|
|
808
|
+
return X({
|
|
809
809
|
...e,
|
|
810
810
|
projection: t
|
|
811
811
|
});
|
|
812
812
|
},
|
|
813
813
|
using(t) {
|
|
814
|
-
return
|
|
814
|
+
return X({
|
|
815
815
|
...e,
|
|
816
816
|
usingIndex: t
|
|
817
817
|
});
|
|
818
818
|
},
|
|
819
819
|
withDeleted() {
|
|
820
|
-
return
|
|
820
|
+
return X({
|
|
821
821
|
...e,
|
|
822
822
|
includeDeleted: !0
|
|
823
823
|
});
|
|
824
824
|
},
|
|
825
825
|
unscoped() {
|
|
826
|
-
return
|
|
826
|
+
return X({
|
|
827
827
|
...e,
|
|
828
828
|
crossTenant: !0
|
|
829
829
|
});
|
|
@@ -833,13 +833,13 @@ var r = (e) => {
|
|
|
833
833
|
...e.eager ?? {},
|
|
834
834
|
...t
|
|
835
835
|
};
|
|
836
|
-
return
|
|
836
|
+
return X({
|
|
837
837
|
...e,
|
|
838
838
|
eager: n
|
|
839
839
|
});
|
|
840
840
|
},
|
|
841
841
|
count() {
|
|
842
|
-
return
|
|
842
|
+
return X({
|
|
843
843
|
...e,
|
|
844
844
|
projection: void 0,
|
|
845
845
|
aggregations: [{
|
|
@@ -853,15 +853,15 @@ var r = (e) => {
|
|
|
853
853
|
...t,
|
|
854
854
|
alias: e
|
|
855
855
|
}));
|
|
856
|
-
return
|
|
856
|
+
return X({
|
|
857
857
|
...e,
|
|
858
858
|
projection: void 0,
|
|
859
859
|
aggregations: n
|
|
860
860
|
});
|
|
861
861
|
},
|
|
862
862
|
matching(t, n) {
|
|
863
|
-
let r =
|
|
864
|
-
return
|
|
863
|
+
let r = Y(e.table, t, e.fullTextIndexes);
|
|
864
|
+
return X({
|
|
865
865
|
...e,
|
|
866
866
|
fullTextSearch: {
|
|
867
867
|
indexName: t,
|
|
@@ -875,7 +875,7 @@ var r = (e) => {
|
|
|
875
875
|
rankBy(t) {
|
|
876
876
|
let n = e.fullTextSearch;
|
|
877
877
|
if (n === void 0) throw Error(".rankBy() requires a preceding .matching(...) clause — there is no full-text search to rank on this query.");
|
|
878
|
-
return
|
|
878
|
+
return X({
|
|
879
879
|
...e,
|
|
880
880
|
fullTextSearch: {
|
|
881
881
|
...n,
|
|
@@ -894,7 +894,7 @@ var r = (e) => {
|
|
|
894
894
|
distance: r?.distance ?? "cosine",
|
|
895
895
|
...e.annClause?.ef === void 0 ? {} : { ef: e.annClause.ef }
|
|
896
896
|
};
|
|
897
|
-
return
|
|
897
|
+
return X({
|
|
898
898
|
...e,
|
|
899
899
|
annClause: i
|
|
900
900
|
});
|
|
@@ -906,7 +906,7 @@ var r = (e) => {
|
|
|
906
906
|
distance: "cosine",
|
|
907
907
|
...e.annClause?.ef === void 0 ? {} : { ef: e.annClause.ef }
|
|
908
908
|
};
|
|
909
|
-
return
|
|
909
|
+
return X({
|
|
910
910
|
...e,
|
|
911
911
|
annClause: r,
|
|
912
912
|
take: n
|
|
@@ -919,7 +919,7 @@ var r = (e) => {
|
|
|
919
919
|
column: "",
|
|
920
920
|
distance: "cosine"
|
|
921
921
|
};
|
|
922
|
-
return
|
|
922
|
+
return X({
|
|
923
923
|
...e,
|
|
924
924
|
annClause: {
|
|
925
925
|
...n,
|
|
@@ -928,22 +928,22 @@ var r = (e) => {
|
|
|
928
928
|
});
|
|
929
929
|
},
|
|
930
930
|
use(t) {
|
|
931
|
-
return
|
|
931
|
+
return X({ ...t(e) });
|
|
932
932
|
},
|
|
933
933
|
distinct() {
|
|
934
|
-
return
|
|
934
|
+
return X({
|
|
935
935
|
...e,
|
|
936
936
|
distinct: !0
|
|
937
937
|
});
|
|
938
938
|
},
|
|
939
939
|
distinctOn(t) {
|
|
940
|
-
return
|
|
940
|
+
return X({
|
|
941
941
|
...e,
|
|
942
942
|
distinctOn: [...t]
|
|
943
943
|
});
|
|
944
944
|
},
|
|
945
945
|
as(t) {
|
|
946
|
-
return
|
|
946
|
+
return X({
|
|
947
947
|
...e,
|
|
948
948
|
alias: t
|
|
949
949
|
});
|
|
@@ -955,7 +955,7 @@ var r = (e) => {
|
|
|
955
955
|
alias: n,
|
|
956
956
|
on: r
|
|
957
957
|
}];
|
|
958
|
-
return
|
|
958
|
+
return X({
|
|
959
959
|
...e,
|
|
960
960
|
joins: a
|
|
961
961
|
});
|
|
@@ -967,7 +967,7 @@ var r = (e) => {
|
|
|
967
967
|
alias: n,
|
|
968
968
|
on: r
|
|
969
969
|
}];
|
|
970
|
-
return
|
|
970
|
+
return X({
|
|
971
971
|
...e,
|
|
972
972
|
joins: a
|
|
973
973
|
});
|
|
@@ -977,7 +977,7 @@ var r = (e) => {
|
|
|
977
977
|
outputKey: e,
|
|
978
978
|
source: t
|
|
979
979
|
}));
|
|
980
|
-
return
|
|
980
|
+
return X({
|
|
981
981
|
...e,
|
|
982
982
|
projection: void 0,
|
|
983
983
|
joinedProjection: n
|
|
@@ -986,7 +986,7 @@ var r = (e) => {
|
|
|
986
986
|
withCte(t, n) {
|
|
987
987
|
let r = e.ctes ?? [];
|
|
988
988
|
if (r.some((e) => e.name === t)) throw Error(`Query.withCte: duplicate CTE name '${t}'`);
|
|
989
|
-
return
|
|
989
|
+
return X({
|
|
990
990
|
...e,
|
|
991
991
|
ctes: [...r, {
|
|
992
992
|
name: t,
|
|
@@ -997,7 +997,7 @@ var r = (e) => {
|
|
|
997
997
|
recursiveCte(t, n) {
|
|
998
998
|
let r = e.ctes ?? [];
|
|
999
999
|
if (r.some((e) => e.name === t)) throw Error(`Query.recursiveCte: duplicate CTE name '${t}'`);
|
|
1000
|
-
return
|
|
1000
|
+
return X({
|
|
1001
1001
|
...e,
|
|
1002
1002
|
ctes: [...r, {
|
|
1003
1003
|
name: t,
|
|
@@ -1008,20 +1008,20 @@ var r = (e) => {
|
|
|
1008
1008
|
},
|
|
1009
1009
|
groupBy(t) {
|
|
1010
1010
|
let n = e.groupBy ? [...e.groupBy, ...t] : [...t];
|
|
1011
|
-
return
|
|
1011
|
+
return X({
|
|
1012
1012
|
...e,
|
|
1013
1013
|
groupBy: n
|
|
1014
1014
|
});
|
|
1015
1015
|
},
|
|
1016
1016
|
having(t) {
|
|
1017
1017
|
let n = e.having ? { and: [e.having, t] } : t;
|
|
1018
|
-
return
|
|
1018
|
+
return X({
|
|
1019
1019
|
...e,
|
|
1020
1020
|
having: n
|
|
1021
1021
|
});
|
|
1022
1022
|
},
|
|
1023
1023
|
exists() {
|
|
1024
|
-
return
|
|
1024
|
+
return X({
|
|
1025
1025
|
...e,
|
|
1026
1026
|
projection: void 0,
|
|
1027
1027
|
aggregations: [{
|
|
@@ -1032,8 +1032,8 @@ var r = (e) => {
|
|
|
1032
1032
|
});
|
|
1033
1033
|
}
|
|
1034
1034
|
});
|
|
1035
|
-
function
|
|
1036
|
-
return
|
|
1035
|
+
function Z(e) {
|
|
1036
|
+
return X({
|
|
1037
1037
|
table: e.tableName,
|
|
1038
1038
|
predicate: void 0,
|
|
1039
1039
|
order: [],
|
|
@@ -1044,7 +1044,7 @@ function Q(e) {
|
|
|
1044
1044
|
sourceTable: e
|
|
1045
1045
|
});
|
|
1046
1046
|
}
|
|
1047
|
-
var
|
|
1047
|
+
var Q = (e, t, n) => $(e, "id", t, n), $ = (e, t, n, r, i = "asc") => {
|
|
1048
1048
|
let a = [...e.order.filter((e) => e.column !== t), {
|
|
1049
1049
|
column: t,
|
|
1050
1050
|
direction: i
|
|
@@ -1059,11 +1059,11 @@ var nt = (e, t, n) => $(e, "id", t, n), $ = (e, t, n, r, i = "asc") => {
|
|
|
1059
1059
|
order: a,
|
|
1060
1060
|
take: r
|
|
1061
1061
|
};
|
|
1062
|
-
},
|
|
1062
|
+
}, it = (e) => {
|
|
1063
1063
|
let t = {};
|
|
1064
|
-
for (let [n, r] of Object.entries(e)) G(r), t[n] =
|
|
1064
|
+
for (let [n, r] of Object.entries(e)) G(r), t[n] = Z(r);
|
|
1065
1065
|
return t;
|
|
1066
|
-
},
|
|
1066
|
+
}, at = (e) => e.isView === !0, ot = (e, t, n) => {
|
|
1067
1067
|
if (v(e), n.trim().length === 0) throw Error(`view('${e}', …): the SELECT body is empty — a view must define a query.`);
|
|
1068
1068
|
let r = u(t);
|
|
1069
1069
|
for (let t of Object.keys(r)) y(e, t);
|
|
@@ -1073,7 +1073,7 @@ var nt = (e, t, n) => $(e, "id", t, n), $ = (e, t, n, r, i = "asc") => {
|
|
|
1073
1073
|
isView: !0,
|
|
1074
1074
|
viewSelect: n
|
|
1075
1075
|
};
|
|
1076
|
-
},
|
|
1076
|
+
}, st = (e) => Z({
|
|
1077
1077
|
...e,
|
|
1078
1078
|
isReactive: !1,
|
|
1079
1079
|
appliedMixins: [],
|
|
@@ -1081,7 +1081,7 @@ var nt = (e, t, n) => $(e, "id", t, n), $ = (e, t, n, r, i = "asc") => {
|
|
|
1081
1081
|
appliedUniques: [],
|
|
1082
1082
|
appliedFullText: [],
|
|
1083
1083
|
appliedChecks: []
|
|
1084
|
-
}),
|
|
1084
|
+
}), ct = (e, t, n = null) => {
|
|
1085
1085
|
let r = n === null ? V(e.tableName, t) : `${V(n, t)}.${V(e.tableName, t)}`, i = e.viewSelect.trim();
|
|
1086
1086
|
switch (t) {
|
|
1087
1087
|
case "postgres":
|
|
@@ -1091,16 +1091,16 @@ var nt = (e, t, n) => $(e, "id", t, n), $ = (e, t, n, r, i = "asc") => {
|
|
|
1091
1091
|
case "sqlite":
|
|
1092
1092
|
case "turso": return `DROP VIEW IF EXISTS ${r};\nCREATE VIEW ${r} AS ${i};`;
|
|
1093
1093
|
}
|
|
1094
|
-
},
|
|
1094
|
+
}, lt = /^[A-Za-z_][A-Za-z0-9_]*$/, ut = (e) => "$" + e.map((e) => typeof e == "number" ? `[${e}]` : lt.test(e) ? `.${e}` : `."${e.replace(/"/g, "\\\"")}"`).join(""), dt = (e) => "{" + e.map((e) => {
|
|
1095
1095
|
let t = String(e);
|
|
1096
1096
|
return /^[A-Za-z0-9_]+$/.test(t) ? t : `"${t.replace(/(["\\])/g, "\\$1")}"`;
|
|
1097
|
-
}).join(",") + "}",
|
|
1097
|
+
}).join(",") + "}", ft = (e, t, n, r = {}) => {
|
|
1098
1098
|
let i = V(e, n), a = r.numeric ?? !1;
|
|
1099
1099
|
if (n === "postgres") {
|
|
1100
|
-
let e = `(${i} #>> '${
|
|
1100
|
+
let e = `(${i} #>> '${dt(t)}'::text[])`;
|
|
1101
1101
|
return a ? `${e}::numeric` : e;
|
|
1102
1102
|
}
|
|
1103
|
-
let o =
|
|
1103
|
+
let o = ut(t);
|
|
1104
1104
|
switch (n) {
|
|
1105
1105
|
case "mysql":
|
|
1106
1106
|
case "mariadb": {
|
|
@@ -1117,10 +1117,10 @@ var nt = (e, t, n) => $(e, "id", t, n), $ = (e, t, n, r, i = "asc") => {
|
|
|
1117
1117
|
return a ? `CAST(${e} AS REAL)` : e;
|
|
1118
1118
|
}
|
|
1119
1119
|
}
|
|
1120
|
-
},
|
|
1120
|
+
}, pt = (e) => {
|
|
1121
1121
|
if (!e.id || e.id.length === 0) throw Error("migration: `id` is required + must be non-empty");
|
|
1122
1122
|
if (!e.up || !e.down) throw Error(`migration ${e.id}: both \`up\` and \`down\` must be functions`);
|
|
1123
1123
|
return e;
|
|
1124
|
-
},
|
|
1124
|
+
}, mt = /^\d{8}_\d{6}_[a-z0-9_]+\.ts$/, ht = (e) => typeof e == "object" && !!e && "id" in e && "up" in e && "down" in e && typeof e.id == "string" && typeof e.up == "function" && typeof e.down == "function";
|
|
1125
1125
|
//#endregion
|
|
1126
|
-
export {
|
|
1126
|
+
export { p as $, qe as A, r as At, V as B, Q as C, pe as Ct, Ze as D, ge as Dt, Y as E, ne as Et, K as F, De as G, Oe as H, ze as I, N as J, F as K, G as L, Le as M, oe as Mt, Re as N, de as Nt, He as O, te as Ot, Fe as P, we as Q, Ie as R, $ as S, ee as St, Qe as T, u as Tt, Ne as U, Ae as V, ke as W, P as X, Ee as Y, M as Z, Ye as _, c as _t, at as a, x as at, Ge as b, he as bt, ct as c, _e as ct, Ke as d, fe as dt, m as et, Be as f, re as ft, Xe as g, ie as gt, $e as h, l as ht, ft as i, v as it, Je as j, s as jt, nt as k, le as kt, Ue as l, ve as lt, it as m, ce as mt, ht as n, y as nt, st as o, ye as ot, Ve as p, ae as pt, I as q, pt as r, b as rt, ot as s, f as st, mt as t, be as tt, rt as u, i as ut, et as v, ue as vt, Z as w, se as wt, We as x, o as xt, tt as y, me as yt, Pe as z };
|
package/dist/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { VoidIfEmpty } from 'effect/Types';
|
|
|
11
11
|
import { YieldableError } from 'effect/Cause';
|
|
12
12
|
|
|
13
13
|
/** The framework's built-in `actors` core table. */
|
|
14
|
-
export declare const actorsTable: Table<'actors', Record<string, ColumnDefinition<unknown>>,
|
|
14
|
+
export declare const actorsTable: Table<'actors', Record<string, ColumnDefinition<unknown>>, true, never>;
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Admission decision for a NEW branch request: evict TTL-expired branches and
|
|
@@ -2603,6 +2603,23 @@ export declare const isSeedDefinition: (value: unknown) => value is SeedDefiniti
|
|
|
2603
2603
|
*/
|
|
2604
2604
|
export declare const isSqliteFamily: (dialect: DialectId) => boolean;
|
|
2605
2605
|
|
|
2606
|
+
/**
|
|
2607
|
+
* Does this table emit change events at all?
|
|
2608
|
+
*
|
|
2609
|
+
* `false` ONLY for a table that registered itself with `.nonReactive()`. An
|
|
2610
|
+
* unregistered name answers `true`, and that default is deliberate: a store
|
|
2611
|
+
* writing to a table the registry has never seen (a raw write, a framework
|
|
2612
|
+
* bootstrap before registration, a test fixture) must keep behaving exactly as
|
|
2613
|
+
* before. Silence is something an author opts into, never something a lookup
|
|
2614
|
+
* miss produces.
|
|
2615
|
+
*
|
|
2616
|
+
* Consulted by EVERY dialect store at its emit choke point. It lives here, next
|
|
2617
|
+
* to the registry that owns the answer, so the rule exists once — five copies
|
|
2618
|
+
* of `isReactive !== false` in five stores is how the postgres and mariadb
|
|
2619
|
+
* paths came to disagree about this flag in the first place.
|
|
2620
|
+
*/
|
|
2621
|
+
export declare const isTableReactive: (tableName: string) => boolean;
|
|
2622
|
+
|
|
2606
2623
|
/** Type guard: is this descriptor a read-only view (vs a base table)? */
|
|
2607
2624
|
export declare const isView: (t: TableLike) => t is View<string, Record<string, ColumnDefinition<unknown>>>;
|
|
2608
2625
|
|
|
@@ -4720,7 +4737,7 @@ export declare const sumOver: (column: string, alias?: string) => WindowBuilder;
|
|
|
4720
4737
|
*/
|
|
4721
4738
|
export declare const sweepRetention: (spec: RetentionSpec, now: number, deleteOlderThan: (table: string, timeColumn: string, cutoff: Date, batch: number, where?: Predicate) => Promise<number>, batch?: number) => Promise<number>;
|
|
4722
4739
|
|
|
4723
|
-
export declare interface Table<Name extends string, Fields extends Record<string, ColumnDefinition<unknown>>, Reactive extends boolean =
|
|
4740
|
+
export declare interface Table<Name extends string, Fields extends Record<string, ColumnDefinition<unknown>>, Reactive extends boolean = true, IxNames extends string = never> extends TableLike {
|
|
4724
4741
|
readonly tableName: Name;
|
|
4725
4742
|
readonly fields: Fields;
|
|
4726
4743
|
readonly isReactive: Reactive;
|
|
@@ -5032,14 +5049,42 @@ export declare interface Table<Name extends string, Fields extends Record<string
|
|
|
5032
5049
|
*/
|
|
5033
5050
|
primaryKey: <const F extends readonly [keyof Fields & string, keyof Fields & string, ...Array<keyof Fields & string>]>(fields: F) => Table<Name, Fields, Reactive, IxNames>;
|
|
5034
5051
|
/**
|
|
5035
|
-
*
|
|
5036
|
-
*
|
|
5037
|
-
*
|
|
5052
|
+
* Turn reactivity OFF for this table.
|
|
5053
|
+
*
|
|
5054
|
+
* Not "off across instances" — off. The table emits no change events at all:
|
|
5055
|
+
* no local subscriber fires, no cross-instance transport carries it. That is
|
|
5056
|
+
* what the name says, and a version of this that only silenced the
|
|
5057
|
+
* cross-instance half would leave every in-process subscription live on a
|
|
5058
|
+
* table declared non-reactive.
|
|
5059
|
+
*
|
|
5060
|
+
* Reactivity is the default because that is what this framework is for. The
|
|
5061
|
+
* inverse (`.reactive()`) was the API for a long time and failed in both
|
|
5062
|
+
* directions silently: written on mariadb it did nothing at all, omitted on
|
|
5063
|
+
* postgres+cdc it meant a write on one instance never reached another
|
|
5064
|
+
* instance's subscribers.
|
|
5065
|
+
*
|
|
5066
|
+
* Implemented in EVERY dialect, at the store's emit:
|
|
5067
|
+
*
|
|
5068
|
+
* memory the store's single emit point drops the event
|
|
5069
|
+
* sqlite / same, and turso reuses that store
|
|
5070
|
+
* turso
|
|
5071
|
+
* postgres also: no `REPLICA IDENTITY FULL`, no `pg_notify` trigger
|
|
5072
|
+
* mysql / also: excluded from the binlog reader's table filter
|
|
5073
|
+
* mariadb
|
|
5074
|
+
* mssql also: excluded from the Change Tracking table set
|
|
5075
|
+
*
|
|
5076
|
+
* The WRITE is unaffected — this is about notification, never persistence.
|
|
5077
|
+
*
|
|
5078
|
+
* Worth using for a genuinely hot table nobody subscribes to: an append-only
|
|
5079
|
+
* event log, a metrics sink. On postgres it also drops `REPLICA IDENTITY
|
|
5080
|
+
* FULL`, which widens every UPDATE/DELETE in the WAL. Do NOT use it on a
|
|
5081
|
+
* table a query reads — that subscription simply never fires. `voltro dev`
|
|
5082
|
+
* says so at boot.
|
|
5038
5083
|
*/
|
|
5039
|
-
|
|
5084
|
+
nonReactive: () => Table<Name, Fields, false, IxNames>;
|
|
5040
5085
|
}
|
|
5041
5086
|
|
|
5042
|
-
export declare const table: <const Name extends string, const Input extends FieldsInput>(name: Name, fields: Input) => Table<Name, FieldDefinitions<Input>,
|
|
5087
|
+
export declare const table: <const Name extends string, const Input extends FieldsInput>(name: Name, fields: Input) => Table<Name, FieldDefinitions<Input>, true, never>;
|
|
5043
5088
|
|
|
5044
5089
|
/**
|
|
5045
5090
|
* A named table-level `CHECK` constraint, set by `.check(name, expr)`.
|