kern-orm 0.12.1 → 0.13.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/dist/{index-Cv9QJ_v7.d.mts → index-CFkH9TlC.d.mts} +134 -125
- package/dist/index.d.mts +2 -2
- package/dist/types.d.mts +5 -2
- package/dist/types.mjs +4 -1
- package/package.json +2 -2
|
@@ -161,7 +161,8 @@ interface BaseType<Output, Input, Operators extends OperatorDefinitions, Paramet
|
|
|
161
161
|
/**
|
|
162
162
|
* Narrows the values of this type to `T` in TypeScript, such as to a union of strings that a `CHECK` constraint allows, or to the shape of JSON values.
|
|
163
163
|
*
|
|
164
|
-
* The values are not validated at runtime.
|
|
164
|
+
* The values are not validated at runtime.
|
|
165
|
+
* `T` must be among the values that this type both returns and accepts, and `nullable` keeps `null` apart from it.
|
|
165
166
|
*/
|
|
166
167
|
of<T extends AcceptedValues<Exclude<Output, null>, Exclude<Input, null>>>(): Type<T | AcceptedNull<Input>, T | AcceptedNull<Input>, Operators, Parameters>;
|
|
167
168
|
/** Creates a column of this type with a physical name different from the column key. */
|
|
@@ -788,19 +789,6 @@ type ToFieldRef<D, V> = D extends QueryValueType ? D extends {
|
|
|
788
789
|
* It reads `S` only in its branch, as `QueryWhereFilter` does.
|
|
789
790
|
*/
|
|
790
791
|
type QueryHavingFilter<S extends SelectQueryState> = [S] extends [unknown] ? WhereCondition<S["table"]> | ((columns: ColumnRefs<S["table"]> & RelationRefs<S["schema"]>, selected: HavingFields<S>) => WhereCondition<S["table"]>) : never;
|
|
791
|
-
/**
|
|
792
|
-
* What a query with a row lock does with a row that another transaction has locked, instead of waiting for it:
|
|
793
|
-
*
|
|
794
|
-
* - `skipLocked` leaves the row out of its result, such as to take the next free job of a queue.
|
|
795
|
-
* - `noWait` rejects with a PostgreSQL error of SQLSTATE `55P03`.
|
|
796
|
-
*/
|
|
797
|
-
type RowLockOptions = {
|
|
798
|
-
readonly noWait?: boolean;
|
|
799
|
-
readonly skipLocked?: false;
|
|
800
|
-
} | {
|
|
801
|
-
readonly noWait?: false;
|
|
802
|
-
readonly skipLocked?: boolean;
|
|
803
|
-
};
|
|
804
792
|
/** Rows mode of a query of state `S` after a filter: `FilteredRows` of a query whose row is guaranteed, and the rows of other queries. */
|
|
805
793
|
type FilteredStateRows<S extends SelectQueryState> = [S["guaranteed"]] extends [false] ? S["rows"] : [S["value"]] extends [false] ? S["result"] extends HelperFields ? S["rows"] : FilteredRows<S["rows"], false> : FilteredRows<S["rows"], S["value"]>;
|
|
806
794
|
/** State `S` after a filter, which ends the guarantee of its row. */
|
|
@@ -929,6 +917,131 @@ type OneRowQueryState = SelectQueryState & {
|
|
|
929
917
|
type OneRecordQueryState = OneRowQueryState & {
|
|
930
918
|
readonly value: false | "mapped";
|
|
931
919
|
};
|
|
920
|
+
/**
|
|
921
|
+
* State of the query that the callback of a helper of table `T` with schema context `C` receives: the fields of the query the helper is applied to, and all its rows.
|
|
922
|
+
*
|
|
923
|
+
* It is guaranteed, so that the state that the callback returns tells whether the callback ends the guarantee of the query the helper is applied to.
|
|
924
|
+
*/
|
|
925
|
+
interface HelperState<T extends AnyTable, C extends SchemaContext> extends QueryStateOf<T, C> {
|
|
926
|
+
readonly result: HelperFields<never>;
|
|
927
|
+
readonly valueType: never;
|
|
928
|
+
readonly fieldTypes: EmptyRecord;
|
|
929
|
+
readonly rows: "many";
|
|
930
|
+
readonly value: false;
|
|
931
|
+
readonly uses: never;
|
|
932
|
+
readonly guaranteed: true;
|
|
933
|
+
readonly aggregate: false;
|
|
934
|
+
}
|
|
935
|
+
/**
|
|
936
|
+
* Effect of a helper: the fields it selects and the types of their values, or whether `map` converts its rows and what it gives, its rows mode on a query of many rows, `one` after `take` or `required` and `nullable` or `optional` after the method of the same name, the relations it selects records of, and whether it keeps the guarantee of the row of a query of a required relation.
|
|
937
|
+
*
|
|
938
|
+
* `reads` are the relations of the schema of the helper among them, which its callback may read from the references of the query it is applied to, and `key` is the key of its table there.
|
|
939
|
+
*/
|
|
940
|
+
interface HelperEffect {
|
|
941
|
+
/** Whether the helper guarantees that the query is grouped. */
|
|
942
|
+
readonly grouped: boolean;
|
|
943
|
+
readonly fields: object;
|
|
944
|
+
/** Types of the values of the fields it selects, the `fieldTypes` part of the state that its callback returns, which `having` and the narrowing of grouped selections read. */
|
|
945
|
+
readonly fieldTypes: unknown;
|
|
946
|
+
/** Whether `map` converts the rows, whose fields the result no longer tells, so that `fields` are empty. */
|
|
947
|
+
readonly mapped: boolean;
|
|
948
|
+
/** What `map` gives for each row of a query the helper is applied to; `never` when `mapped` is `false`. */
|
|
949
|
+
readonly output: unknown;
|
|
950
|
+
readonly rows: ResultRows;
|
|
951
|
+
readonly uses: UsedRelation;
|
|
952
|
+
readonly reads: UsedRelation;
|
|
953
|
+
readonly key: string;
|
|
954
|
+
readonly guaranteed: boolean;
|
|
955
|
+
}
|
|
956
|
+
/** Effect of a helper whose callback returns a query of state `S`, for each state of a union. */
|
|
957
|
+
type ReadEffect<S extends SelectQueryState> = S extends SelectQueryState ? {
|
|
958
|
+
readonly grouped: S["aggregate"] extends Grouped ? true : false;
|
|
959
|
+
readonly fields: S["value"] extends "mapped" ? EmptyRecord : { [K in keyof S["result"] as K extends keyof HelperFields ? never : K]: S["result"][K]; };
|
|
960
|
+
readonly fieldTypes: S["value"] extends "mapped" ? EmptyRecord : S["fieldTypes"];
|
|
961
|
+
readonly mapped: S["value"] extends "mapped" ? true : false;
|
|
962
|
+
readonly output: S["value"] extends "mapped" ? WithoutHelperFields<S["result"]> : never;
|
|
963
|
+
readonly rows: S["rows"];
|
|
964
|
+
readonly uses: S["uses"];
|
|
965
|
+
readonly reads: Extract<UsableRelation<S["schema"]["relations"]>, S["uses"]>;
|
|
966
|
+
readonly key: S["schema"]["key"];
|
|
967
|
+
readonly guaranteed: S["guaranteed"];
|
|
968
|
+
} : never;
|
|
969
|
+
/** Error of a helper that a query does not accept, or whose callback returns a query it does not accept. */
|
|
970
|
+
interface HelperError<Message extends string> {
|
|
971
|
+
readonly error: Message;
|
|
972
|
+
}
|
|
973
|
+
/** `unknown` when every result state retains the input marker and returns records, or converts such records with `map`, or the error. */
|
|
974
|
+
type CheckResult<S extends SelectQueryState> = [S] extends [{
|
|
975
|
+
readonly result: HelperFields;
|
|
976
|
+
readonly value: false;
|
|
977
|
+
} | {
|
|
978
|
+
readonly value: "mapped";
|
|
979
|
+
readonly valueType: never;
|
|
980
|
+
}] ? unknown : HelperError<"A helper can filter, select fields, map them, and take one row, but cannot clear the selection or use get, pluck, or aggregates">;
|
|
981
|
+
/** State of a query over table `T` that accepts a helper of effect `E`. */
|
|
982
|
+
type HelperInput<T extends AnyTable, E extends HelperEffect> = QueryStateOf<T, ReadsContext<E>> & ValueCheck<E> & (true extends E["grouped"] ? {
|
|
983
|
+
readonly aggregate: false;
|
|
984
|
+
} : unknown);
|
|
985
|
+
/** Constraint of `value` of a query that accepts a helper of effect `E`. */
|
|
986
|
+
type ValueCheck<E extends HelperEffect> = [E extends HelperEffect ? keyof E["fields"] : never] extends [never] ? [Extract<E["rows"], "nullable">] extends [never] ? [E["mapped"]] extends [false] ? unknown : RecordRows<"A helper cannot apply map to a query made by get, pluck, an aggregate, or map"> : RecordRows<"A helper cannot apply nullable to a query made by get, pluck, an aggregate, or map"> : RecordRows<"A helper cannot select fields on a query made by get, pluck, an aggregate, or map">;
|
|
987
|
+
/** Constraint of a query whose rows are records, which a query of values fails with error `Message`. */
|
|
988
|
+
interface RecordRows<Message extends string> {
|
|
989
|
+
readonly value: false | HelperError<Message>;
|
|
990
|
+
}
|
|
991
|
+
/** Schema context of a query that has the relations of its schema that a helper of effect `E` may read. */
|
|
992
|
+
type ReadsContext<E extends HelperEffect> = [E["reads"]] extends [never] ? SchemaContext : SchemaContext<{ readonly [K in E["reads"]["key"]]: { readonly [N in Extract<E["reads"], {
|
|
993
|
+
readonly key: K;
|
|
994
|
+
}>["name"]]: Extract<E["reads"], {
|
|
995
|
+
readonly key: K;
|
|
996
|
+
readonly name: N;
|
|
997
|
+
}>["relation"]; }; }, E["key"]>;
|
|
998
|
+
/** State of a query of state `S` after a helper of effect `E`. */
|
|
999
|
+
type ApplyEffect<S extends SelectQueryState, E extends HelperEffect> = ApplySelectionEffect<E["grouped"] extends true ? GroupedState<S> : S, E>;
|
|
1000
|
+
/** Applies the selected fields and row effects after the grouping guaranteed by the helper. */
|
|
1001
|
+
type ApplySelectionEffect<S extends SelectQueryState, E extends HelperEffect> = ChangeState<S, {
|
|
1002
|
+
result: E["mapped"] extends true ? E["output"] : [keyof E["fields"]] extends [never] ? S["result"] : MergeSelection<S["result"], S["aggregate"] extends Grouped ? GroupedRecord<E["fields"], SelectedFieldTypesOf<E["fieldTypes"]>> : E["fields"]>;
|
|
1003
|
+
fieldTypes: SelectedFieldTypes<S["fieldTypes"], SelectedFieldTypesOf<E["fieldTypes"]>>;
|
|
1004
|
+
value: E["mapped"] extends true ? "mapped" : S["value"];
|
|
1005
|
+
aggregate: E["mapped"] extends true ? true : S["aggregate"];
|
|
1006
|
+
rows: E["rows"] extends "many" ? EffectRows<S, E> : E["rows"] extends "one" ? OneRow<EffectRows<S, E>> : E["rows"];
|
|
1007
|
+
uses: S["uses"] | E["uses"];
|
|
1008
|
+
guaranteed: E["guaranteed"] extends true ? S["guaranteed"] : false;
|
|
1009
|
+
}>;
|
|
1010
|
+
/** Rows mode of a query of state `S` after a helper of effect `E` that keeps the rows, before `take`: relaxed as after a filter when the helper ends the guarantee. */
|
|
1011
|
+
type EffectRows<S extends SelectQueryState, E extends HelperEffect> = E["guaranteed"] extends true ? S["rows"] : FilteredStateRows<S>;
|
|
1012
|
+
/**
|
|
1013
|
+
* Helper of `defineHelper` for queries over table `T`: it applies effect `E` to the query it receives with arguments `A` and returns a query of the same kind.
|
|
1014
|
+
*
|
|
1015
|
+
* Selected fields replace earlier fields under the same keys; a query made by `get`, `pluck`, an aggregate method, or `map` does not accept a helper that selects fields or maps them.
|
|
1016
|
+
* `use` of a mutation also applies a helper that only selects fields and maps them.
|
|
1017
|
+
*/
|
|
1018
|
+
type Helper<T extends AnyTable, E extends HelperEffect, A extends unknown[]> = <S extends HelperInput<T, E>, Kind extends SelectQueryKind>(query: SelectQuery<S, Kind>, ...args: A) => E extends HelperEffect ? SelectQuery<ApplyEffect<S, E>, Kind> : never;
|
|
1019
|
+
/** Helper of any table, effect, and arguments. */
|
|
1020
|
+
type AnyHelper = Helper<AnyTable, any, any>;
|
|
1021
|
+
/** Type of a record of the fields that a helper of effect `E` selects, or of what its `map` gives, for each effect of a union. */
|
|
1022
|
+
type HelperResult<E extends HelperEffect> = E extends HelperEffect ? E["mapped"] extends true ? E["output"] : E["fields"] : never;
|
|
1023
|
+
/**
|
|
1024
|
+
* Defines a reusable helper of a table that filters, selects fields, converts them with `map`, and applies `take`, `optional`, `nullable`, and `required`, used with `use` or called with a query.
|
|
1025
|
+
*
|
|
1026
|
+
* `helper` receives the query it is applied to and any further arguments, and returns the query with its clauses.
|
|
1027
|
+
* Defined with a query of a schema, such as `schema.form`, it can select the relations of the table in that schema, and applies to queries whose schema has them.
|
|
1028
|
+
* The helper returns a query of the same kind as the one it is applied to, bound to the same `Db` if any.
|
|
1029
|
+
* A helper that only selects fields and maps them also applies to an insert, an update, and a delete with their `use`, where it selects what they return; other methods fail there.
|
|
1030
|
+
*/
|
|
1031
|
+
declare function defineHelper<T extends AnyTable, R extends SelectQuery<any, SelectQueryKind>, A extends unknown[], C extends SchemaContext = NoRelations>(table: TableOrQuery<T, C>, helper: (query: SelectQuery<HelperState<T, C>, SelectQueryKind>, ...args: A) => R & CheckResult<R["types"]>): Helper<T, ReadEffect<R["types"]>, A>;
|
|
1032
|
+
/**
|
|
1033
|
+
* What a query with a row lock does with a row that another transaction has locked, instead of waiting for it:
|
|
1034
|
+
*
|
|
1035
|
+
* - `skipLocked` leaves the row out of its result, such as to take the next free job of a queue.
|
|
1036
|
+
* - `noWait` rejects with a PostgreSQL error of SQLSTATE `55P03`.
|
|
1037
|
+
*/
|
|
1038
|
+
type RowLockOptions = {
|
|
1039
|
+
readonly noWait?: boolean;
|
|
1040
|
+
readonly skipLocked?: false;
|
|
1041
|
+
} | {
|
|
1042
|
+
readonly noWait?: false;
|
|
1043
|
+
readonly skipLocked?: boolean;
|
|
1044
|
+
};
|
|
932
1045
|
/**
|
|
933
1046
|
* Value of column `K` of table `T` that an insert or an update sets: a value that its type encodes, `null` for a nullable column, an expression of its values, or a query of one such value.
|
|
934
1047
|
*
|
|
@@ -1468,8 +1581,12 @@ interface SingletonInsertMany {
|
|
|
1468
1581
|
type BoundSelectQuery<S extends SelectQueryState> = SelectQuery<S, "bound">;
|
|
1469
1582
|
/** Select query of any state and kind. */
|
|
1470
1583
|
type AnySelectQuery = SelectQuery<any, SelectQueryKind>;
|
|
1471
|
-
/**
|
|
1472
|
-
|
|
1584
|
+
/**
|
|
1585
|
+
* Type of a record of a query result, also of a query of SQL text, or of its value for a query made by `get`, `pluck`, or an aggregate method.
|
|
1586
|
+
*
|
|
1587
|
+
* Of a helper of `defineHelper`, it is the type of a record of the fields that the helper selects, or of what its `map` gives.
|
|
1588
|
+
*/
|
|
1589
|
+
type ResultOf<Q extends AnyQuery | AnySqlQuery | AnyHelper> = Q extends AnyQuery | AnySqlQuery ? Q["types"]["result"] : Q extends Helper<AnyTable, infer E, never> ? HelperResult<E> : never;
|
|
1473
1590
|
/** Table of a definition such as `defineExpression`: the table itself or a query over it with schema context `C`, such as `schema.form`. */
|
|
1474
1591
|
type TableOrQuery<T extends AnyTable, C extends SchemaContext = SchemaContext> = T | QueryOf<QueryStateOf<T, C>>;
|
|
1475
1592
|
/** Starts a query over a new occurrence of the table. */
|
|
@@ -1733,114 +1850,6 @@ declare function caseWhen<Output, Input, O extends OperatorDefinitions>(type: Ty
|
|
|
1733
1850
|
* `type` decodes the result and gives it its operators, and a plain value of a branch or of `otherwise` is cast to it, so that PostgreSQL does not take plain values for text.
|
|
1734
1851
|
*/
|
|
1735
1852
|
declare function caseWhen<Output, Input, O extends OperatorDefinitions, const B extends readonly CaseBranch<Output, Input>[], const E extends CaseValue<Output, Input>>(type: Type<Output, Input, O, any>, branches: B, otherwise: E): Expression<CaseResult<Output, B[number][1] | E>, O, Input>;
|
|
1736
|
-
/**
|
|
1737
|
-
* State of the query that the callback of a helper of table `T` with schema context `C` receives: the fields of the query the helper is applied to, and all its rows.
|
|
1738
|
-
*
|
|
1739
|
-
* It is guaranteed, so that the state that the callback returns tells whether the callback ends the guarantee of the query the helper is applied to.
|
|
1740
|
-
*/
|
|
1741
|
-
interface HelperState<T extends AnyTable, C extends SchemaContext> extends QueryStateOf<T, C> {
|
|
1742
|
-
readonly result: HelperFields<never>;
|
|
1743
|
-
readonly valueType: never;
|
|
1744
|
-
readonly fieldTypes: EmptyRecord;
|
|
1745
|
-
readonly rows: "many";
|
|
1746
|
-
readonly value: false;
|
|
1747
|
-
readonly uses: never;
|
|
1748
|
-
readonly guaranteed: true;
|
|
1749
|
-
readonly aggregate: false;
|
|
1750
|
-
}
|
|
1751
|
-
/**
|
|
1752
|
-
* Effect of a helper: the fields it selects and the types of their values, or whether `map` converts its rows and what it gives, its rows mode on a query of many rows, `one` after `take` or `required` and `nullable` or `optional` after the method of the same name, the relations it selects records of, and whether it keeps the guarantee of the row of a query of a required relation.
|
|
1753
|
-
*
|
|
1754
|
-
* `reads` are the relations of the schema of the helper among them, which its callback may read from the references of the query it is applied to, and `key` is the key of its table there.
|
|
1755
|
-
*/
|
|
1756
|
-
interface HelperEffect {
|
|
1757
|
-
/** Whether the helper guarantees that the query is grouped. */
|
|
1758
|
-
readonly grouped: boolean;
|
|
1759
|
-
readonly fields: object;
|
|
1760
|
-
/** Types of the values of the fields it selects, the `fieldTypes` part of the state that its callback returns, which `having` and the narrowing of grouped selections read. */
|
|
1761
|
-
readonly fieldTypes: unknown;
|
|
1762
|
-
/** Whether `map` converts the rows, whose fields the result no longer tells, so that `fields` are empty. */
|
|
1763
|
-
readonly mapped: boolean;
|
|
1764
|
-
/** What `map` gives for each row of a query the helper is applied to; `never` when `mapped` is `false`. */
|
|
1765
|
-
readonly output: unknown;
|
|
1766
|
-
readonly rows: ResultRows;
|
|
1767
|
-
readonly uses: UsedRelation;
|
|
1768
|
-
readonly reads: UsedRelation;
|
|
1769
|
-
readonly key: string;
|
|
1770
|
-
readonly guaranteed: boolean;
|
|
1771
|
-
}
|
|
1772
|
-
/** Effect of a helper whose callback returns a query of state `S`, for each state of a union. */
|
|
1773
|
-
type ReadEffect<S extends SelectQueryState> = S extends SelectQueryState ? {
|
|
1774
|
-
readonly grouped: S["aggregate"] extends Grouped ? true : false;
|
|
1775
|
-
readonly fields: S["value"] extends "mapped" ? EmptyRecord : { [K in keyof S["result"] as K extends keyof HelperFields ? never : K]: S["result"][K]; };
|
|
1776
|
-
readonly fieldTypes: S["value"] extends "mapped" ? EmptyRecord : S["fieldTypes"];
|
|
1777
|
-
readonly mapped: S["value"] extends "mapped" ? true : false;
|
|
1778
|
-
readonly output: S["value"] extends "mapped" ? WithoutHelperFields<S["result"]> : never;
|
|
1779
|
-
readonly rows: S["rows"];
|
|
1780
|
-
readonly uses: S["uses"];
|
|
1781
|
-
readonly reads: Extract<UsableRelation<S["schema"]["relations"]>, S["uses"]>;
|
|
1782
|
-
readonly key: S["schema"]["key"];
|
|
1783
|
-
readonly guaranteed: S["guaranteed"];
|
|
1784
|
-
} : never;
|
|
1785
|
-
/** Error of a helper that a query does not accept, or whose callback returns a query it does not accept. */
|
|
1786
|
-
interface HelperError<Message extends string> {
|
|
1787
|
-
readonly error: Message;
|
|
1788
|
-
}
|
|
1789
|
-
/** `unknown` when every result state retains the input marker and returns records, or converts such records with `map`, or the error. */
|
|
1790
|
-
type CheckResult<S extends SelectQueryState> = [S] extends [{
|
|
1791
|
-
readonly result: HelperFields;
|
|
1792
|
-
readonly value: false;
|
|
1793
|
-
} | {
|
|
1794
|
-
readonly value: "mapped";
|
|
1795
|
-
readonly valueType: never;
|
|
1796
|
-
}] ? unknown : HelperError<"A helper can filter, select fields, map them, and take one row, but cannot clear the selection or use get, pluck, or aggregates">;
|
|
1797
|
-
/** State of a query over table `T` that accepts a helper of effect `E`. */
|
|
1798
|
-
type HelperInput<T extends AnyTable, E extends HelperEffect> = QueryStateOf<T, ReadsContext<E>> & ValueCheck<E> & (true extends E["grouped"] ? {
|
|
1799
|
-
readonly aggregate: false;
|
|
1800
|
-
} : unknown);
|
|
1801
|
-
/** Constraint of `value` of a query that accepts a helper of effect `E`. */
|
|
1802
|
-
type ValueCheck<E extends HelperEffect> = [E extends HelperEffect ? keyof E["fields"] : never] extends [never] ? [Extract<E["rows"], "nullable">] extends [never] ? [E["mapped"]] extends [false] ? unknown : RecordRows<"A helper cannot apply map to a query made by get, pluck, an aggregate, or map"> : RecordRows<"A helper cannot apply nullable to a query made by get, pluck, an aggregate, or map"> : RecordRows<"A helper cannot select fields on a query made by get, pluck, an aggregate, or map">;
|
|
1803
|
-
/** Constraint of a query whose rows are records, which a query of values fails with error `Message`. */
|
|
1804
|
-
interface RecordRows<Message extends string> {
|
|
1805
|
-
readonly value: false | HelperError<Message>;
|
|
1806
|
-
}
|
|
1807
|
-
/** Schema context of a query that has the relations of its schema that a helper of effect `E` may read. */
|
|
1808
|
-
type ReadsContext<E extends HelperEffect> = [E["reads"]] extends [never] ? SchemaContext : SchemaContext<{ readonly [K in E["reads"]["key"]]: { readonly [N in Extract<E["reads"], {
|
|
1809
|
-
readonly key: K;
|
|
1810
|
-
}>["name"]]: Extract<E["reads"], {
|
|
1811
|
-
readonly key: K;
|
|
1812
|
-
readonly name: N;
|
|
1813
|
-
}>["relation"]; }; }, E["key"]>;
|
|
1814
|
-
/** State of a query of state `S` after a helper of effect `E`. */
|
|
1815
|
-
type ApplyEffect<S extends SelectQueryState, E extends HelperEffect> = ApplySelectionEffect<E["grouped"] extends true ? GroupedState<S> : S, E>;
|
|
1816
|
-
/** Applies the selected fields and row effects after the grouping guaranteed by the helper. */
|
|
1817
|
-
type ApplySelectionEffect<S extends SelectQueryState, E extends HelperEffect> = ChangeState<S, {
|
|
1818
|
-
result: E["mapped"] extends true ? E["output"] : [keyof E["fields"]] extends [never] ? S["result"] : MergeSelection<S["result"], S["aggregate"] extends Grouped ? GroupedRecord<E["fields"], SelectedFieldTypesOf<E["fieldTypes"]>> : E["fields"]>;
|
|
1819
|
-
fieldTypes: SelectedFieldTypes<S["fieldTypes"], SelectedFieldTypesOf<E["fieldTypes"]>>;
|
|
1820
|
-
value: E["mapped"] extends true ? "mapped" : S["value"];
|
|
1821
|
-
aggregate: E["mapped"] extends true ? true : S["aggregate"];
|
|
1822
|
-
rows: E["rows"] extends "many" ? EffectRows<S, E> : E["rows"] extends "one" ? OneRow<EffectRows<S, E>> : E["rows"];
|
|
1823
|
-
uses: S["uses"] | E["uses"];
|
|
1824
|
-
guaranteed: E["guaranteed"] extends true ? S["guaranteed"] : false;
|
|
1825
|
-
}>;
|
|
1826
|
-
/** Rows mode of a query of state `S` after a helper of effect `E` that keeps the rows, before `take`: relaxed as after a filter when the helper ends the guarantee. */
|
|
1827
|
-
type EffectRows<S extends SelectQueryState, E extends HelperEffect> = E["guaranteed"] extends true ? S["rows"] : FilteredStateRows<S>;
|
|
1828
|
-
/**
|
|
1829
|
-
* Helper of `defineHelper` for queries over table `T`: it applies effect `E` to the query it receives with arguments `A` and returns a query of the same kind.
|
|
1830
|
-
*
|
|
1831
|
-
* Selected fields replace earlier fields under the same keys; a query made by `get`, `pluck`, an aggregate method, or `map` does not accept a helper that selects fields or maps them.
|
|
1832
|
-
* `use` of a mutation also applies a helper that only selects fields and maps them.
|
|
1833
|
-
*/
|
|
1834
|
-
type Helper<T extends AnyTable, E extends HelperEffect, A extends unknown[]> = <S extends HelperInput<T, E>, Kind extends SelectQueryKind>(query: SelectQuery<S, Kind>, ...args: A) => E extends HelperEffect ? SelectQuery<ApplyEffect<S, E>, Kind> : never;
|
|
1835
|
-
/**
|
|
1836
|
-
* Defines a reusable helper of a table that filters, selects fields, converts them with `map`, and applies `take`, `optional`, `nullable`, and `required`, used with `use` or called with a query.
|
|
1837
|
-
*
|
|
1838
|
-
* `helper` receives the query it is applied to and any further arguments, and returns the query with its clauses.
|
|
1839
|
-
* Defined with a query of a schema, such as `schema.form`, it can select the relations of the table in that schema, and applies to queries whose schema has them.
|
|
1840
|
-
* The helper returns a query of the same kind as the one it is applied to, bound to the same `Db` if any.
|
|
1841
|
-
* A helper that only selects fields and maps them also applies to an insert, an update, and a delete with their `use`, where it selects what they return; other methods fail there.
|
|
1842
|
-
*/
|
|
1843
|
-
declare function defineHelper<T extends AnyTable, R extends SelectQuery<any, SelectQueryKind>, A extends unknown[], C extends SchemaContext = NoRelations>(table: TableOrQuery<T, C>, helper: (query: SelectQuery<HelperState<T, C>, SelectQueryKind>, ...args: A) => R & CheckResult<R["types"]>): Helper<T, ReadEffect<R["types"]>, A>;
|
|
1844
1853
|
/**
|
|
1845
1854
|
* State in types of a query that inserts, updates, or deletes rows: its table and the relations of its schema, the rows mode of the rows it changes, and its result, which is their number until a selection returns their fields or `transform` converts it.
|
|
1846
1855
|
*
|
|
@@ -2996,4 +3005,4 @@ declare function param<E extends AnyExpression, V extends (E extends AnyExpressi
|
|
|
2996
3005
|
* A run of capital letters is one word, such as `user_id` for `userID`, and digits stay in their word, such as `line2`.
|
|
2997
3006
|
*/
|
|
2998
3007
|
declare function toSnakeCase(key: string): string;
|
|
2999
|
-
export { NotAColumn as $,
|
|
3008
|
+
export { NotAColumn as $, BaseType as $i, avg as $n, WhereValues as $r, SchemaTables as $t, SqlQueryResult as A, QueryState as Ai, ExpressionInput as An, UpdateSet as Ar, DeclaredRelations as At, createDatabase as B, ColumnShape as Bi, SelectionFieldTypes as Bn, FoundState as Br, RequiredMember as Bt, ResultByRows$1 as C, ScalarQuery as Ci, TypedOperandInput as Cn, ResultOf as Cr, DbQueryState as Ct, SessionOptions$1 as D, FoundKey as Di, greatest as Dn, ColumnValue as Dr, SynchronousResult as Dt, ResultRows$1 as E, EmptyRecord as Ei, coalesce as En, from as Er, NotSynchronous as Et, TransactionConnectionError as F, TableQueryState as Fi, GroupedRecord as Fn, Helper as Fr, RelationDeclaration as Ft, toSnakeCase as G, TableFactoryOptions as Gi, AggregateExpression as Gn, KeyCheck as Gr, UsableRelation as Gt, isOutcomeUnknown as H, KeyColumns as Hi, SelectionUses as Hn, SelectedOperandType as Hr, SchemaRelations as Ht, TransactionOptions$1 as I, AnyTable as Ii, MergeSelection as In, HelperEffect as Ir, RelationDeclarations as It, param as J, ToColumns as Ji, GroupAggregateExpression as Jn, PrimaryKeyValues as Jr, one as Jt, SqlTemplate as K, TableKeys as Ki, AggregateOptions as Kn, NotAKey as Kr, UsedRelation as Kt, TypeOptions$1 as L, AnyTableKeys as Li, NestedQuery as Ln, defineHelper as Lr, RelationKey as Lt, SqlStatement$1 as M, QueryValueType as Mi, GroupOperandValue as Mn, UpsertValues as Mr, NoRelations as Mt, SqlValue as N, SelectQueryState as Ni, GroupSelectionResult as Nn, RowLockOptions as Nr, OneRelationKeys as Nt, SqlFragment$2 as O, Grouped as Oi, least as On, ConflictUpdateSet as Or, TransformedQuery as Ot, TextValue as P, SingletonQueryState as Pi, GroupedField as Pn, AnyHelper as Pr, Relation as Pt, MatchResult as Q, AnyType as Qi, UnfilteredStringAggOptions as Qn, WhereFilter as Qr, SchemaPartRelations as Qt, TypeTransform$1 as R, ColumnDefinitions as Ri, SelectedFieldTypes as Rn, FilteredStateRows as Rr, RelationKeys as Rt, QueryErrorCondition as S, OperandUses as Si, TypedOperand as Sn, BoundSelectQuery as Sr, DbOf as St, ResultMode$1 as T, ValuesQuery as Ti, caseWhen as Tn, SingletonInsertMany as Tr, AnyTransformedQuery as Tt, isQueryError as U, Selectable as Ui, Literal as Un, GroupTerm as Ur, TableContext as Ut, createStatement$1 as V, ColumnValues as Vi, SelectionResult as Vn, GroupedState as Vr, SchemaContext as Vt, toDriverError as W, Table as Wi, literal as Wn, GroupTerms as Wr, TableRelations as Wt, ColumnRefKey as X, defineTable as Xi, StringAggOptions as Xn, WhereCallback as Xr, Schema as Xt, sql as Y, createTableFactory as Yi, GroupValue as Yn, EqValue as Yr, AnySchema as Yt, MatchCheck as Z, RequiredRelationError as Zi, UnfilteredAggregateOptions as Zn, WhereCondition as Zr, SchemaPart as Zt, OneRow$1 as _, defineGenericOperator as _a, BooleanResult as _i, CaseBranch as _n, orderBy as _r, UntypedExpression as _t, Database$1 as a, AnyColumn as aa, not as ai, SelectionState as an, some as ar, TextConversionSignature as at, QueryError as b, OperandValue as bi, FollowingOperand as bn, RelationRefs as br, Db as bt, DerivableType$1 as c, KeyKind as ca, FilteredRows as ci, AnyMutationQuery as cn, OrderColumns as cr, TextTypeOperators as ct, DriverErrorFields as d, MergeOperators as da, CompileOptions as di, ConflictTarget as dn, OrderTerm as dr, orderingOperators as dt, Type as ea, CombinedCondition as ei, Tables as en, count as er, matches as et, DriverResult as f, NoOperators as fa, EqualityOperator as fi, InitialInsertState as fn, OrderTerms as fr, AnyExpression as ft, NotFoundError$1 as g, OperatorSignature as ga, equalityOperators as gi, MutationQueryState as gn, desc as gr, TypedExpression as gt, IsolationLevel as h, GenericOperatorImplementation as ha, InSignature as hi, MutationQuery as hn, asc as hr, ExpressionOperators as ht, ConnectionError as i, defineType$1 as ia, and as ii, RecordQueryState as in, min as ir, PatternSignature as it, SqlQueryState as j, QueryStateOf as ji, ExpressionValue as jn, UpdateValues as jr, MergeRelations as jt, SqlQuery$1 as k, InitialQueryState as ki, ColumnFieldTypes as kn, InsertValues as kr, TransformedQueryState as kt, DerivableTypeWithParameters as l, ToColumn as la, QueryResult as li, ConflictActionRequired as ln, OrderDirection as lr, textOperators as lt, InitialSqlQueryState$1 as m, GenericOperator as ma, HasEquality as mi, InsertMutationState as mn, SelectedRefs as mr, Expression as mt, BaseDerivableType as n, TypeOperators as na, ConditionOperand as ni, AnyRecordQuery as nn, every as nr, FALSE as nt, DatabaseOptions as o, Column as oa, or as oi, AnyQuery as on, stringAgg as or, TextLengthSignature as ot, FieldTypes as p, OperatorDefinitions as pa, EqualityOperators as pi, InitialMutationState as pn, Ordering as pr, BaseOperators as pt, identifier$1 as q, TableOptions as qi, CountExpression as qn, PrimaryKeyColumn as qr, many as qt, Connection as r, TypeOutput as ra, Predicate as ri, RecordQuery as rn, max as rr, TRUE as rt, DecodedFields as s, ColumnAttributes as sa, ExistsValueType as si, SelectQueryKind as sn, sum as sr, TextOperators as st, AnySqlQuery$1 as t, TypeInput as ta, Condition as ti, defineSchema as tn, countDistinct as tr, defineExpression as tt, Driver as u, BoundOperators as ua, CountValueType as ui, ConflictKeyRequired as un, OrderKey as ur, NumberTypeOperators as ut, OneValueRows$1 as v, ComparisonSignature as vi, CaseCondition as vn, ColumnRefs as vr, AnyDb as vt, ResultDecodeError$1 as w, TypedScalarQuery as wi, TypedOperandOperators as wn, SelectQuery as wr, bindSchema as wt, QueryErrorCode as x, compare as xi, NullSkippingResult as xn, AnySelectQuery as xr, DbMutationState as xt, PollLockOptions$1 as y, Operand as yi, CaseValue as yn, QueryContext as yr, BindOptions as yt, ValueRows$1 as z, ColumnOperators as zi, Selection as zn, FoundQueryState as zr, RelationKind as zt };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as NotAColumn, $i as
|
|
2
|
-
export { type AggregateExpression, type AggregateOptions, type AnyColumn, type AnyDb, type AnyExpression, type AnyMutationQuery, type AnyQuery, type AnyRecordQuery, type AnySchema, type AnySelectQuery, type AnySqlQuery, type AnyTable, type AnyTableKeys, type AnyTransformedQuery, type AnyType, type BaseDerivableType, type BaseOperators, type BaseType, type BindOptions, type BooleanResult, type BoundOperators, type BoundSelectQuery, type CaseBranch, type CaseCondition, type CaseValue, type Column, type ColumnAttributes, type ColumnDefinitions, type ColumnFieldTypes, type ColumnOperators, type ColumnRefKey, type ColumnRefs, type ColumnShape, type ColumnValue, type ColumnValues, type CombinedCondition, type ComparisonSignature, type CompileOptions, type Condition, type ConditionOperand, type ConflictActionRequired, type ConflictKeyRequired, type ConflictTarget, type ConflictUpdateSet, type Connection, ConnectionError, type CountExpression, type CountValueType, type Database, type DatabaseOptions, type Db, type DbMutationState, type DbOf, type DbQueryState, type DeclaredRelations, type DecodedFields, type DerivableType, type DerivableTypeWithParameters, type Driver, type DriverErrorFields, type DriverResult, type EmptyRecord, type EqValue, type EqualityOperator, type EqualityOperators, type ExistsValueType, type Expression, type ExpressionInput, type ExpressionOperators, type ExpressionValue, FALSE, type FieldTypes, type FilteredRows, type FilteredStateRows, type FollowingOperand, type FoundKey, type FoundQueryState, type FoundState, type GenericOperator, type GenericOperatorImplementation, type GroupAggregateExpression, type GroupOperandValue, type GroupSelectionResult, type GroupTerm, type GroupTerms, type GroupValue, type Grouped, type GroupedField, type GroupedRecord, type GroupedState, type HasEquality, type Helper, type HelperEffect, type InSignature, type InitialInsertState, type InitialMutationState, type InitialQueryState, type InitialSqlQueryState, type InsertMutationState, type InsertValues, type IsolationLevel, type KeyCheck, type KeyColumns, type KeyKind, type Literal, type MatchCheck, type MatchResult, type MergeOperators, type MergeRelations, type MergeSelection, type MutationQuery, type MutationQueryState, type NestedQuery, type NoOperators, type NoRelations, type NotAColumn, type NotAKey, NotFoundError, type NotSynchronous, type NullSkippingResult, type NumberTypeOperators, type OneRelationKeys, type OneRow, type OneValueRows, type Operand, type OperandUses, type OperandValue, type OperatorDefinitions, type OperatorSignature, type OrderColumns, type OrderDirection, type OrderKey, type OrderTerm, type OrderTerms, type Ordering, type PatternSignature, type PollLockOptions, type Predicate, type PrimaryKeyColumn, type PrimaryKeyValues, type QueryContext, QueryError, type QueryErrorCode, type QueryErrorCondition, type QueryResult, type QueryState, type QueryStateOf, type QueryValueType, type RecordQuery, type RecordQueryState, type Relation, type RelationDeclaration, type RelationDeclarations, type RelationKey, type RelationKeys, type RelationKind, type RelationRefs, type RequiredMember, RequiredRelationError, type ResultByRows, ResultDecodeError, type ResultMode, type ResultOf, type ResultRows, type RowLockOptions, type ScalarQuery, type Schema, type SchemaContext, type SchemaPart, type SchemaPartRelations, type SchemaRelations, type SchemaTables, type SelectQuery, type SelectQueryKind, type SelectQueryState, type Selectable, type SelectedFieldTypes, type SelectedOperandType, type SelectedRefs, type Selection, type SelectionFieldTypes, type SelectionResult, type SelectionState, type SelectionUses, type SessionOptions, type SingletonInsertMany, type SingletonQueryState, type SqlFragment, type SqlQuery, type SqlQueryResult, type SqlQueryState, type SqlStatement, type SqlTemplate, type SqlValue, type StringAggOptions, type SynchronousResult, TRUE, type Table, type TableContext, type TableFactoryOptions, type TableKeys, type TableOptions, type TableQueryState, type TableRelations, type Tables, type TextConversionSignature, type TextLengthSignature, type TextOperators, type TextTypeOperators, type TextValue, type ToColumn, type ToColumns, TransactionConnectionError, type TransactionOptions, type TransformedQuery, type TransformedQueryState, type Type, type TypeInput, type TypeOperators, type TypeOptions, type TypeOutput, type TypeTransform, type TypedExpression, type TypedOperand, type TypedOperandInput, type TypedOperandOperators, type TypedScalarQuery, type UnfilteredAggregateOptions, type UnfilteredStringAggOptions, type UntypedExpression, type UpdateSet, type UpdateValues, type UpsertValues, type UsableRelation, type UsedRelation, type ValueRows, type ValuesQuery, type WhereCallback, type WhereCondition, type WhereFilter, type WhereValues, and, asc, avg, bindSchema, caseWhen, coalesce, compare, count, countDistinct, createDatabase, createStatement, createTableFactory, defineExpression, defineGenericOperator, defineHelper, defineSchema, defineTable, defineType, desc, equalityOperators, every, from, greatest, identifier, isOutcomeUnknown, isQueryError, least, literal, many, matches, max, min, not, one, or, orderBy, orderingOperators, param, some, sql, stringAgg, sum, textOperators, toDriverError, toSnakeCase };
|
|
1
|
+
import { $ as NotAColumn, $i as BaseType, $n as avg, $r as WhereValues, $t as SchemaTables, A as SqlQueryResult, Ai as QueryState, An as ExpressionInput, Ar as UpdateSet, At as DeclaredRelations, B as createDatabase, Bi as ColumnShape, Bn as SelectionFieldTypes, Br as FoundState, Bt as RequiredMember, C as ResultByRows, Ci as ScalarQuery, Cn as TypedOperandInput, Cr as ResultOf, Ct as DbQueryState, D as SessionOptions, Di as FoundKey, Dn as greatest, Dr as ColumnValue, Dt as SynchronousResult, E as ResultRows, Ei as EmptyRecord, En as coalesce, Er as from, Et as NotSynchronous, F as TransactionConnectionError, Fi as TableQueryState, Fn as GroupedRecord, Fr as Helper, Ft as RelationDeclaration, G as toSnakeCase, Gi as TableFactoryOptions, Gn as AggregateExpression, Gr as KeyCheck, Gt as UsableRelation, H as isOutcomeUnknown, Hi as KeyColumns, Hn as SelectionUses, Hr as SelectedOperandType, Ht as SchemaRelations, I as TransactionOptions, Ii as AnyTable, In as MergeSelection, Ir as HelperEffect, It as RelationDeclarations, J as param, Ji as ToColumns, Jn as GroupAggregateExpression, Jr as PrimaryKeyValues, Jt as one, K as SqlTemplate, Ki as TableKeys, Kn as AggregateOptions, Kr as NotAKey, Kt as UsedRelation, L as TypeOptions, Li as AnyTableKeys, Ln as NestedQuery, Lr as defineHelper, Lt as RelationKey, M as SqlStatement, Mi as QueryValueType, Mn as GroupOperandValue, Mr as UpsertValues, Mt as NoRelations, N as SqlValue, Ni as SelectQueryState, Nn as GroupSelectionResult, Nr as RowLockOptions, Nt as OneRelationKeys, O as SqlFragment, Oi as Grouped, On as least, Or as ConflictUpdateSet, Ot as TransformedQuery, P as TextValue, Pi as SingletonQueryState, Pn as GroupedField, Pr as AnyHelper, Pt as Relation, Q as MatchResult, Qi as AnyType, Qn as UnfilteredStringAggOptions, Qr as WhereFilter, Qt as SchemaPartRelations, R as TypeTransform, Ri as ColumnDefinitions, Rn as SelectedFieldTypes, Rr as FilteredStateRows, Rt as RelationKeys, S as QueryErrorCondition, Si as OperandUses, Sn as TypedOperand, Sr as BoundSelectQuery, St as DbOf, T as ResultMode, Ti as ValuesQuery, Tn as caseWhen, Tr as SingletonInsertMany, Tt as AnyTransformedQuery, U as isQueryError, Ui as Selectable, Un as Literal, Ur as GroupTerm, Ut as TableContext, V as createStatement, Vi as ColumnValues, Vn as SelectionResult, Vr as GroupedState, Vt as SchemaContext, W as toDriverError, Wi as Table, Wn as literal, Wr as GroupTerms, Wt as TableRelations, X as ColumnRefKey, Xi as defineTable, Xn as StringAggOptions, Xr as WhereCallback, Xt as Schema, Y as sql, Yi as createTableFactory, Yn as GroupValue, Yr as EqValue, Yt as AnySchema, Z as MatchCheck, Zi as RequiredRelationError, Zn as UnfilteredAggregateOptions, Zr as WhereCondition, Zt as SchemaPart, _ as OneRow, _a as defineGenericOperator, _i as BooleanResult, _n as CaseBranch, _r as orderBy, _t as UntypedExpression, a as Database, aa as AnyColumn, ai as not, an as SelectionState, ar as some, at as TextConversionSignature, b as QueryError, bi as OperandValue, bn as FollowingOperand, br as RelationRefs, bt as Db, c as DerivableType, ca as KeyKind, ci as FilteredRows, cn as AnyMutationQuery, cr as OrderColumns, ct as TextTypeOperators, d as DriverErrorFields, da as MergeOperators, di as CompileOptions, dn as ConflictTarget, dr as OrderTerm, dt as orderingOperators, ea as Type, ei as CombinedCondition, en as Tables, er as count, et as matches, f as DriverResult, fa as NoOperators, fi as EqualityOperator, fn as InitialInsertState, fr as OrderTerms, ft as AnyExpression, g as NotFoundError, ga as OperatorSignature, gi as equalityOperators, gn as MutationQueryState, gr as desc, gt as TypedExpression, h as IsolationLevel, ha as GenericOperatorImplementation, hi as InSignature, hn as MutationQuery, hr as asc, ht as ExpressionOperators, i as ConnectionError, ia as defineType, ii as and, in as RecordQueryState, ir as min, it as PatternSignature, j as SqlQueryState, ji as QueryStateOf, jn as ExpressionValue, jr as UpdateValues, jt as MergeRelations, k as SqlQuery, ki as InitialQueryState, kn as ColumnFieldTypes, kr as InsertValues, kt as TransformedQueryState, l as DerivableTypeWithParameters, la as ToColumn, li as QueryResult, ln as ConflictActionRequired, lr as OrderDirection, lt as textOperators, m as InitialSqlQueryState, ma as GenericOperator, mi as HasEquality, mn as InsertMutationState, mr as SelectedRefs, mt as Expression, n as BaseDerivableType, na as TypeOperators, ni as ConditionOperand, nn as AnyRecordQuery, nr as every, nt as FALSE, o as DatabaseOptions, oa as Column, oi as or, on as AnyQuery, or as stringAgg, ot as TextLengthSignature, p as FieldTypes, pa as OperatorDefinitions, pi as EqualityOperators, pn as InitialMutationState, pr as Ordering, pt as BaseOperators, q as identifier, qi as TableOptions, qn as CountExpression, qr as PrimaryKeyColumn, qt as many, r as Connection, ra as TypeOutput, ri as Predicate, rn as RecordQuery, rr as max, rt as TRUE, s as DecodedFields, sa as ColumnAttributes, si as ExistsValueType, sn as SelectQueryKind, sr as sum, st as TextOperators, t as AnySqlQuery, ta as TypeInput, ti as Condition, tn as defineSchema, tr as countDistinct, tt as defineExpression, u as Driver, ua as BoundOperators, ui as CountValueType, un as ConflictKeyRequired, ur as OrderKey, ut as NumberTypeOperators, v as OneValueRows, vi as ComparisonSignature, vn as CaseCondition, vr as ColumnRefs, vt as AnyDb, w as ResultDecodeError, wi as TypedScalarQuery, wn as TypedOperandOperators, wr as SelectQuery, wt as bindSchema, x as QueryErrorCode, xi as compare, xn as NullSkippingResult, xr as AnySelectQuery, xt as DbMutationState, y as PollLockOptions, yi as Operand, yn as CaseValue, yr as QueryContext, yt as BindOptions, z as ValueRows, zi as ColumnOperators, zn as Selection, zr as FoundQueryState, zt as RelationKind } from "./index-CFkH9TlC.mjs";
|
|
2
|
+
export { type AggregateExpression, type AggregateOptions, type AnyColumn, type AnyDb, type AnyExpression, type AnyHelper, type AnyMutationQuery, type AnyQuery, type AnyRecordQuery, type AnySchema, type AnySelectQuery, type AnySqlQuery, type AnyTable, type AnyTableKeys, type AnyTransformedQuery, type AnyType, type BaseDerivableType, type BaseOperators, type BaseType, type BindOptions, type BooleanResult, type BoundOperators, type BoundSelectQuery, type CaseBranch, type CaseCondition, type CaseValue, type Column, type ColumnAttributes, type ColumnDefinitions, type ColumnFieldTypes, type ColumnOperators, type ColumnRefKey, type ColumnRefs, type ColumnShape, type ColumnValue, type ColumnValues, type CombinedCondition, type ComparisonSignature, type CompileOptions, type Condition, type ConditionOperand, type ConflictActionRequired, type ConflictKeyRequired, type ConflictTarget, type ConflictUpdateSet, type Connection, ConnectionError, type CountExpression, type CountValueType, type Database, type DatabaseOptions, type Db, type DbMutationState, type DbOf, type DbQueryState, type DeclaredRelations, type DecodedFields, type DerivableType, type DerivableTypeWithParameters, type Driver, type DriverErrorFields, type DriverResult, type EmptyRecord, type EqValue, type EqualityOperator, type EqualityOperators, type ExistsValueType, type Expression, type ExpressionInput, type ExpressionOperators, type ExpressionValue, FALSE, type FieldTypes, type FilteredRows, type FilteredStateRows, type FollowingOperand, type FoundKey, type FoundQueryState, type FoundState, type GenericOperator, type GenericOperatorImplementation, type GroupAggregateExpression, type GroupOperandValue, type GroupSelectionResult, type GroupTerm, type GroupTerms, type GroupValue, type Grouped, type GroupedField, type GroupedRecord, type GroupedState, type HasEquality, type Helper, type HelperEffect, type InSignature, type InitialInsertState, type InitialMutationState, type InitialQueryState, type InitialSqlQueryState, type InsertMutationState, type InsertValues, type IsolationLevel, type KeyCheck, type KeyColumns, type KeyKind, type Literal, type MatchCheck, type MatchResult, type MergeOperators, type MergeRelations, type MergeSelection, type MutationQuery, type MutationQueryState, type NestedQuery, type NoOperators, type NoRelations, type NotAColumn, type NotAKey, NotFoundError, type NotSynchronous, type NullSkippingResult, type NumberTypeOperators, type OneRelationKeys, type OneRow, type OneValueRows, type Operand, type OperandUses, type OperandValue, type OperatorDefinitions, type OperatorSignature, type OrderColumns, type OrderDirection, type OrderKey, type OrderTerm, type OrderTerms, type Ordering, type PatternSignature, type PollLockOptions, type Predicate, type PrimaryKeyColumn, type PrimaryKeyValues, type QueryContext, QueryError, type QueryErrorCode, type QueryErrorCondition, type QueryResult, type QueryState, type QueryStateOf, type QueryValueType, type RecordQuery, type RecordQueryState, type Relation, type RelationDeclaration, type RelationDeclarations, type RelationKey, type RelationKeys, type RelationKind, type RelationRefs, type RequiredMember, RequiredRelationError, type ResultByRows, ResultDecodeError, type ResultMode, type ResultOf, type ResultRows, type RowLockOptions, type ScalarQuery, type Schema, type SchemaContext, type SchemaPart, type SchemaPartRelations, type SchemaRelations, type SchemaTables, type SelectQuery, type SelectQueryKind, type SelectQueryState, type Selectable, type SelectedFieldTypes, type SelectedOperandType, type SelectedRefs, type Selection, type SelectionFieldTypes, type SelectionResult, type SelectionState, type SelectionUses, type SessionOptions, type SingletonInsertMany, type SingletonQueryState, type SqlFragment, type SqlQuery, type SqlQueryResult, type SqlQueryState, type SqlStatement, type SqlTemplate, type SqlValue, type StringAggOptions, type SynchronousResult, TRUE, type Table, type TableContext, type TableFactoryOptions, type TableKeys, type TableOptions, type TableQueryState, type TableRelations, type Tables, type TextConversionSignature, type TextLengthSignature, type TextOperators, type TextTypeOperators, type TextValue, type ToColumn, type ToColumns, TransactionConnectionError, type TransactionOptions, type TransformedQuery, type TransformedQueryState, type Type, type TypeInput, type TypeOperators, type TypeOptions, type TypeOutput, type TypeTransform, type TypedExpression, type TypedOperand, type TypedOperandInput, type TypedOperandOperators, type TypedScalarQuery, type UnfilteredAggregateOptions, type UnfilteredStringAggOptions, type UntypedExpression, type UpdateSet, type UpdateValues, type UpsertValues, type UsableRelation, type UsedRelation, type ValueRows, type ValuesQuery, type WhereCallback, type WhereCondition, type WhereFilter, type WhereValues, and, asc, avg, bindSchema, caseWhen, coalesce, compare, count, countDistinct, createDatabase, createStatement, createTableFactory, defineExpression, defineGenericOperator, defineHelper, defineSchema, defineTable, defineType, desc, equalityOperators, every, from, greatest, identifier, isOutcomeUnknown, isQueryError, least, literal, many, matches, max, min, not, one, or, orderBy, orderingOperators, param, some, sql, stringAgg, sum, textOperators, toDriverError, toSnakeCase };
|
package/dist/types.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $i as
|
|
1
|
+
import { $i as BaseType, ct as TextTypeOperators, da as MergeOperators, ea as Type, fa as NoOperators, fi as EqualityOperator, ft as AnyExpression, hi as InSignature, ma as GenericOperator, mi as HasEquality, oa as Column, pa as OperatorDefinitions, pi as EqualityOperators, st as TextOperators, ut as NumberTypeOperators, vi as ComparisonSignature } from "./index-CFkH9TlC.mjs";
|
|
2
2
|
/**
|
|
3
3
|
* Creates a one-dimensional array type of `element` values.
|
|
4
4
|
*
|
|
@@ -71,7 +71,10 @@ declare function enumOf<const Values extends readonly string[]>(name: string, va
|
|
|
71
71
|
gt: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
72
72
|
gte: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
73
73
|
}>, undefined>;
|
|
74
|
-
/**
|
|
74
|
+
/**
|
|
75
|
+
* `json` values; `json.of<T>()` declares their shape.
|
|
76
|
+
* PostgreSQL has no `=` for `json`, so its expressions have no `eq`, `ne`, or `in`.
|
|
77
|
+
*/
|
|
75
78
|
export declare const json: BaseType<unknown, {}, NoOperators, undefined>;
|
|
76
79
|
/** `jsonb` values; `jsonb.of<T>()` declares their shape. */
|
|
77
80
|
export declare const jsonb: BaseType<unknown, {}, MergeOperators<NoOperators, EqualityOperators>, undefined>;
|
package/dist/types.mjs
CHANGED
|
@@ -35,7 +35,10 @@ function enumOf(name, values) {
|
|
|
35
35
|
return defineType(dbTypes.enum(name, values)).withOperators(orderingOperators);
|
|
36
36
|
}
|
|
37
37
|
// src/type/builtins/json.ts
|
|
38
|
-
/**
|
|
38
|
+
/**
|
|
39
|
+
* `json` values; `json.of<T>()` declares their shape.
|
|
40
|
+
* PostgreSQL has no `=` for `json`, so its expressions have no `eq`, `ne`, or `in`.
|
|
41
|
+
*/
|
|
39
42
|
const json = /* @__PURE__ */ defineType(dbTypes.json);
|
|
40
43
|
/** `jsonb` values; `jsonb.of<T>()` declares their shape. */
|
|
41
44
|
const jsonb = /* @__PURE__ */ defineType(dbTypes.jsonb).withOperators(equalityOperators);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kern-orm",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "Fully typed relational query builder for PostgreSQL with ambient transactions and single-query relation loading",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"orm",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"prepublishOnly": "bun run build"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"kern-db": "^0.
|
|
48
|
+
"kern-db": "^0.5.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@kern-orm/test-harness": "workspace:*",
|