kern-orm 0.6.0 → 0.8.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.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { $ as NoRelations, $n as UpdateSet, $r as AnyTableKeys, $t as least, A as Db, Ai as TypeOptions, An as some, Ar as CompileOptions, At as DecodedFields, Bi as MergeOperators, Bn as asc, Br as compare, Bt as HelperEffect, C as BaseOperators, Ci as createStatement, Cn as UnfilteredStringAggOptions, Cr as FilteredRows, Ct as AnyRecordQuery, D as UntypedExpression, Di as Type, Dn as every, Dr as ResultByRows, Dt as AnyQuery, E as TypedExpression, Ei as TextValue, En as countDistinct, Er as QueryResult, Et as SelectionState, F as DatabaseOptions, Fi as Column, Fn as OrderKey, Fr as equalityOperators, Ft as AnyMutationQuery, Gi as OperatorSignature, Gn as RelationRefs, Gr as EmptyRecord, Gt as FollowingOperand, Hi as OperatorDefinitions, Hn as orderBy, Hr as ScalarQuery, Ht as CaseBranch, I as TransactionOptions, Ii as ColumnAttributes, In as OrderTerm, Ir as BooleanResult, It as InitialMutationState, J as SynchronousResult, Jn as ResultOf, Jr as QueryState, Jt as TypedOperandInput, K as AnyTransformedQuery, Ki as defineGenericOperator, Kn as AnySelectQuery, Kr as Grouped, Kt as NullSkippingResult, L as createDatabase, Li as KeyKind, Ln as OrderTerms, Lr as ComparisonSignature, Lt as MutationQuery, M as DbOf, Mi as TypeTransform, Mn as sum, Mr as EqualityOperators, Mt as InitialSqlQueryState, N as DbQueryState, Ni as defineType, Nn as OrderColumns, Nr as HasEquality, Nt as SqlQuery, O as AnyDb, Oi as TypeInput, On as max, Or as ValueRows, Ot as SelectQueryKind, P as Database, Pi as AnyColumn, Pn as OrderDirection, Pr as InSignature, Pt as SqlQueryState, Q as MergeRelations, Qn as InsertValues, Qr as AnyTable, Qt as greatest, R as TransactionCoordinator, Ri as ToColumn, Rn as Ordering, Rr as Operand, Rt as MutationQueryState, S as AnyExpression, Si as TransactionFailure, Sn as UnfilteredAggregateOptions, Sr as ExistsValueType, St as defineSchema, T as ExpressionOperators, Ti as BaseType, Tn as count, Tr as OneValueRows, Tt as RecordQueryState, Ui as GenericOperator, Un as ColumnRefs, Ur as TypedScalarQuery, Ut as CaseCondition, Vi as NoOperators, Vn as desc, Vr as OperandUses, Vt as defineHelper, Wi as GenericOperatorImplementation, Wn as QueryContext, Wr as ValuesQuery, Wt as CaseValue, X as TransformedQueryState, Xn as from, Xr as QueryValueType, Xt as caseWhen, Y as TransformedQuery, Yn as SelectQuery, Yr as QueryStateOf, Yt as TypedOperandOperators, Z as DeclaredRelations, Zn as ColumnValue, Zr as SelectQueryState, Zt as coalesce, _ as TextOperators, _i as ResultRows, _n as AggregateOptions, _r as ConditionOperand, _t as Schema, a as sql, ai as Selectable, an as GroupedField, ar as GroupTerm, at as RelationKeys, b as NumberTypeOperators, bi as DriverResult, bn as GroupValue, br as not, bt as SchemaTables, c as MatchResult, ci as TableKeys, cn as NestedQuery, cr as NotAKey, ct as SchemaContext, d as defineExpression, di as createTableFactory, dn as SelectionFieldTypes, dr as WhereCallback, dt as TableRelations, ei as ColumnDefinitions, en as ColumnFieldTypes, er as UpdateValues, et as OneRelationKeys, f as FALSE, fi as defineTable, fn as SelectionResult, fr as WhereCondition, ft as UsableRelation, g as TextLengthSignature, gi as ResultMode, gn as AggregateExpression, gr as Condition, gt as AnySchema, h as TextConversionSignature, hi as ResultDecodeError, hn as literal, hr as CombinedCondition, ht as one, i as param, ii as KeyColumns, in as GroupSelectionResult, ir as RowLockOptions, it as RelationKey, j as DbMutationState, ji as TypeOutput, jn as stringAgg, jr as EqualityOperator, jt as FieldTypes, k as BindOptions, ki as TypeOperators, kn as min, kr as CountValueType, kt as AnySqlQuery, l as NotAColumn, li as TableOptions, ln as SelectedFieldTypes, lr as PrimaryKeyValues, lt as SchemaRelations, m as PatternSignature, mi as RequiredRelationError, mn as Literal, mr as WhereValues, mt as many, n as SqlTemplate, ni as ColumnShape, nn as ExpressionValue, nr as GroupedState, nt as RelationDeclaration, o as ColumnRefKey, oi as Table, on as GroupedRecord, or as GroupTerms, ot as RelationKind, p as TRUE, pi as NotFoundError, pn as SelectionUses, pr as WhereFilter, pt as UsedRelation, q as NotSynchronous, qn as BoundSelectQuery, qr as InitialQueryState, qt as TypedOperand, r as identifier, ri as ColumnValues, rn as GroupOperandValue, rr as SelectedOperandType, rt as RelationDeclarations, s as MatchCheck, si as TableFactoryOptions, sn as MergeSelection, sr as KeyCheck, st as RequiredMember, t as toSnakeCase, ti as ColumnOperators, tn as ExpressionInput, tr as FilteredStateRows, tt as Relation, u as matches, ui as ToColumns, un as Selection, ur as EqValue, ut as TableContext, v as TextTypeOperators, vi as Connection, vn as CountExpression, vr as Predicate, vt as SchemaPart, w as Expression, wi as AnyType, wn as avg, wr as OneRow, wt as RecordQuery, x as orderingOperators, xi as SqlStatement, xn as StringAggOptions, xr as or, xt as Tables, y as textOperators, yi as Driver, yn as GroupAggregateExpression, yr as and, yt as SchemaPartRelations, zi as BoundOperators, zn as SelectedRefs, zr as OperandValue, zt as Helper } from "./index-CoKpXcBp.mjs";
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 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 Connection, type CountExpression, type CountValueType, type Database, type DatabaseOptions, type Db, type DbMutationState, type DbOf, type DbQueryState, type DeclaredRelations, type DecodedFields, type Driver, 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 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 InitialMutationState, type InitialQueryState, type InitialSqlQueryState, type InsertValues, 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 Predicate, type PrimaryKeyValues, type QueryContext, 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 SqlQuery, type SqlQueryState, type SqlStatement, type SqlTemplate, type StringAggOptions, type SynchronousResult, TRUE, type Table, type TableContext, type TableFactoryOptions, type TableKeys, type TableOptions, type TableRelations, type Tables, type TextConversionSignature, type TextLengthSignature, type TextOperators, type TextTypeOperators, type TextValue, type ToColumn, type ToColumns, type TransactionCoordinator, type TransactionFailure, 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 UsableRelation, type UsedRelation, type ValueRows, type ValuesQuery, type WhereCallback, type WhereCondition, type WhereFilter, type WhereValues, and, asc, avg, caseWhen, coalesce, compare, count, countDistinct, createDatabase, createStatement, createTableFactory, defineExpression, defineGenericOperator, defineHelper, defineSchema, defineTable, defineType, desc, equalityOperators, every, from, greatest, identifier, least, literal, many, matches, max, min, not, one, or, orderBy, orderingOperators, param, some, sql, stringAgg, sum, textOperators, toSnakeCase };
1
+ import { $ as TransformedQuery, $i as Column, $n as QueryContext, $r as Operand, $t as CaseValue, A as TypedExpression, Ai as defineTable, An as StringAggOptions, Ar as CombinedCondition, At as SelectionState, B as TransactionOptions, Bi as TransactionFailure, Bn as stringAgg, Br as OneValueRows, Bt as ConflictActionRequired, C as textOperators, Ci as Selectable, Cn as Literal, Cr as PrimaryKeyColumn, Ct as SchemaPartRelations, D as BaseOperators, Di as TableOptions, Dn as CountExpression, Dr as WhereCondition, Dt as AnyRecordQuery, E as AnyExpression, Ei as TableKeys, En as AggregateOptions, Er as WhereCallback, Et as defineSchema, F as DbMutationState, Fi as ResultRows, Fn as countDistinct, Fr as not, Ft as FieldTypes, Gi as Type, Gn as OrderTerm, Gr as CompileOptions, Gt as InsertMutationState, H as TransactionCoordinator, Hi as AnyType, Hn as OrderColumns, Hr as ResultByRows, Ht as ConflictTarget, I as DbOf, Ii as Connection, In as every, Ir as or, It as InitialSqlQueryState, Ji as TypeOptions, Jn as SelectedRefs, Jr as HasEquality, Jt as Helper, Ki as TypeInput, Kn as OrderTerms, Kr as EqualityOperator, Kt as MutationQuery, L as DbQueryState, Li as Driver, Ln as max, Lr as ExistsValueType, Lt as SqlQuery, M as AnyDb, Mi as RequiredRelationError, Mn as UnfilteredStringAggOptions, Mr as ConditionOperand, Mt as SelectQueryKind, N as BindOptions, Ni as ResultDecodeError, Nn as avg, Nr as Predicate, Nt as AnySqlQuery, O as Expression, Oi as ToColumns, On as GroupAggregateExpression, Or as WhereFilter, Ot as RecordQuery, P as Db, Pi as ResultMode, Pn as count, Pr as and, Pt as DecodedFields, Q as SynchronousResult, Qi as AnyColumn, Qn as ColumnRefs, Qr as ComparisonSignature, Qt as CaseCondition, R as Database, Ri as DriverResult, Rn as min, Rr as FilteredRows, Rt as SqlQueryState, S as TextTypeOperators, Si as KeyColumns, Sn as SelectionUses, Sr as NotAKey, St as SchemaPart, T as orderingOperators, Ti as TableFactoryOptions, Tn as AggregateExpression, Tr as EqValue, Tt as Tables, Ui as BaseType, Un as OrderDirection, Ur as ValueRows, Ut as InitialInsertState, V as createDatabase, Vi as createStatement, Vn as sum, Vr as QueryResult, Vt as ConflictKeyRequired, Wi as TextValue, Wn as OrderKey, Wr as CountValueType, Wt as InitialMutationState, X as AnyTransformedQuery, Xi as TypeTransform, Xn as desc, Xr as equalityOperators, Xt as defineHelper, Yi as TypeOutput, Yn as asc, Yr as InSignature, Yt as HelperEffect, Z as NotSynchronous, Zi as defineType, Zn as orderBy, Zr as BooleanResult, Zt as CaseBranch, _ as TRUE, _i as AnyTableKeys, _n as NestedQuery, _r as SelectedOperandType, _t as UsedRelation, a as sql, aa as NoOperators, ai as ValuesQuery, an as caseWhen, ar as SingletonInsertMany, at as Relation, b as TextLengthSignature, bi as ColumnShape, bn as SelectionFieldTypes, br as GroupTerms, bt as AnySchema, c as MatchResult, ca as GenericOperatorImplementation, ci as Grouped, cn as least, cr as ConflictUpdateSet, ct as RelationKey, d as defineExpression, di as QueryStateOf, dn as ExpressionValue, dr as UpdateValues, dt as RequiredMember, ea as ColumnAttributes, ei as OperandValue, en as FollowingOperand, er as RelationRefs, et as TransformedQueryState, f as ConnectionError, fi as QueryValueType, fn as GroupOperandValue, fr as UpsertValues, ft as SchemaContext, g as FALSE, gi as AnyTable, gn as MergeSelection, gr as GroupedState, gt as UsableRelation, h as toDriverError, hi as TableQueryState, hn as GroupedRecord, hr as FoundState, ht as TableRelations, i as param, ia as MergeOperators, ii as TypedScalarQuery, in as TypedOperandOperators, ir as SelectQuery, it as OneRelationKeys, j as UntypedExpression, ji as NotFoundError, jn as UnfilteredAggregateOptions, jr as Condition, jt as AnyQuery, k as ExpressionOperators, ki as createTableFactory, kn as GroupValue, kr as WhereValues, kt as RecordQueryState, l as NotAColumn, la as OperatorSignature, li as InitialQueryState, ln as ColumnFieldTypes, lr as InsertValues, lt as RelationKeys, m as QueryError, mi as SingletonQueryState, mn as GroupedField, mr as FoundQueryState, mt as TableContext, n as SqlTemplate, na as ToColumn, ni as OperandUses, nn as TypedOperand, nr as BoundSelectQuery, nt as MergeRelations, o as ColumnRefKey, oa as OperatorDefinitions, oi as EmptyRecord, on as coalesce, or as from, ot as RelationDeclaration, p as DriverErrorFields, pi as SelectQueryState, pn as GroupSelectionResult, pr as FilteredStateRows, pt as SchemaRelations, qi as TypeOperators, qn as Ordering, qr as EqualityOperators, qt as MutationQueryState, r as identifier, ra as BoundOperators, ri as ScalarQuery, rn as TypedOperandInput, rr as ResultOf, rt as NoRelations, s as MatchCheck, sa as GenericOperator, si as FoundKey, sn as greatest, sr as ColumnValue, st as RelationDeclarations, t as toSnakeCase, ta as KeyKind, ti as compare, tn as NullSkippingResult, tr as AnySelectQuery, tt as DeclaredRelations, u as matches, ua as defineGenericOperator, ui as QueryState, un as ExpressionInput, ur as UpdateSet, ut as RelationKind, v as PatternSignature, vi as ColumnDefinitions, vn as SelectedFieldTypes, vr as RowLockOptions, vt as many, w as NumberTypeOperators, wi as Table, wn as literal, wr as PrimaryKeyValues, wt as SchemaTables, x as TextOperators, xi as ColumnValues, xn as SelectionResult, xr as KeyCheck, xt as Schema, y as TextConversionSignature, yi as ColumnOperators, yn as Selection, yr as GroupTerm, yt as one, z as DatabaseOptions, zi as SqlStatement, zn as some, zr as OneRow, zt as AnyMutationQuery } from "./index-B1aH5Ht0.mjs";
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 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 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 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 Predicate, type PrimaryKeyColumn, type PrimaryKeyValues, type QueryContext, QueryError, 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 SingletonInsertMany, type SingletonQueryState, type SqlQuery, type SqlQueryState, type SqlStatement, type SqlTemplate, 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, type TransactionCoordinator, type TransactionFailure, 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, caseWhen, coalesce, compare, count, countDistinct, createDatabase, createStatement, createTableFactory, defineExpression, defineGenericOperator, defineHelper, defineSchema, defineTable, defineType, desc, equalityOperators, every, from, greatest, identifier, least, literal, many, matches, max, min, not, one, or, orderBy, orderingOperators, param, some, sql, stringAgg, sum, textOperators, toDriverError, toSnakeCase };
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { B as noOrder, C as toNode, D as isType, E as defineType, F as createNode, L as falseNode, N as defineGenericOperator, P as createList, S as toFunctionOperandNode, T as getBooleanType, U as trueNode, _ as isOperandSource, b as toCastValueNode, c as textOperators, d as orderingOperators, f as compare, g as isExpression, h as getType, k as equalityOperators, v as operandNode, x as toExpression, y as toBooleanExpression } from "./text-Cti9QLK7.mjs";
2
- import { A as not, C as countType, D as literal, E as toAggregateType, M as combineNodes, O as and, S as countProjection, T as createCountCall, _ as createTableFactory, a as defineSchema, b as RequiredRelationError, c as requireDerived, d as desc, f as orderBy, g as createStatement, h as one, i as sql, j as or, k as isColumnValues, l as addTerms, m as many, n as identifier, o as SelectQuery, p as matchColumn, r as param, s as from, t as createDatabase, u as asc, v as defineTable, w as createAggregateCall, x as ResultDecodeError, y as NotFoundError } from "./database-CP4oapsQ.mjs";
1
+ import { B as noOrder, C as toNode, D as isType, E as defineType, F as createNode, L as falseNode, N as defineGenericOperator, P as createList, S as toFunctionOperandNode, T as getBooleanType, U as trueNode, _ as isOperandSource, b as toCastValueNode, c as textOperators, d as orderingOperators, f as compare, g as isExpression, h as getType, k as equalityOperators, v as operandNode, x as toExpression, y as toBooleanExpression } from "./text-CIUxPWPl.mjs";
2
+ import { A as literal, C as RequiredRelationError, D as createAggregateCall, E as countType, F as combineNodes, M as isColumnValues, N as not, O as createCountCall, P as or, S as NotFoundError, T as countProjection, _ as many, a as identifier, b as createTableFactory, c as defineSchema, d as requireDerived, f as addTerms, g as matchColumn, h as orderBy, i as createDatabase, j as and, k as toAggregateType, l as SelectQuery, m as desc, n as QueryError, o as param, p as asc, r as toDriverError, s as sql, t as ConnectionError, u as from, v as one, w as ResultDecodeError, x as defineTable, y as createStatement } from "./driver-error-Dx5R83Rp.mjs";
3
3
  // src/expression/constants.ts
4
4
  /** Condition that always holds, such as for a branch of `and` built in code: `and(check, isAdmin ? TRUE : other)`. */
5
5
  const TRUE = /* @__PURE__ */ toExpression(trueNode, /* @__PURE__ */ getBooleanType());
@@ -157,4 +157,4 @@ const wordStart = /(?<=[\p{Ll}\p{N}])(?=\p{Lu})|(?<=\p{Lu})(?=\p{Lu}(?!s$)\p{Ll}
157
157
  function toSnakeCase(key) {
158
158
  return key.replace(wordStart, "_").toLowerCase();
159
159
  }
160
- export { FALSE, NotFoundError, RequiredRelationError, ResultDecodeError, TRUE, and, asc, avg, caseWhen, coalesce, compare, count, countDistinct, createDatabase, createStatement, createTableFactory, defineExpression, defineGenericOperator, defineHelper, defineSchema, defineTable, defineType, desc, equalityOperators, every, from, greatest, identifier, least, literal, many, matches, max, min, not, one, or, orderBy, orderingOperators, param, some, sql, stringAgg, sum, textOperators, toSnakeCase };
160
+ export { ConnectionError, FALSE, NotFoundError, QueryError, RequiredRelationError, ResultDecodeError, TRUE, and, asc, avg, caseWhen, coalesce, compare, count, countDistinct, createDatabase, createStatement, createTableFactory, defineExpression, defineGenericOperator, defineHelper, defineSchema, defineTable, defineType, desc, equalityOperators, every, from, greatest, identifier, least, literal, many, matches, max, min, not, one, or, orderBy, orderingOperators, param, some, sql, stringAgg, sum, textOperators, toDriverError, toSnakeCase };
@@ -1,4 +1,4 @@
1
- import { B as PendingTestFixture, G as createTestHelpers, H as TestHelpers, U as TestHooks, V as TestFixture, W as TestTransactionOptions, yi as Driver, z as OpenedTestFixture } from "./index-CoKpXcBp.mjs";
1
+ import { G as TestFixture, J as TestTransactionOptions, K as TestHelpers, Li as Driver, U as OpenedTestFixture, W as PendingTestFixture, Y as createTestHelpers, q as TestHooks } from "./index-B1aH5Ht0.mjs";
2
2
  /** Options of `describeDriverContract`: how to create the driver under test. */
3
3
  interface DriverContractOptions {
4
4
  /** Creates a driver over a new client of the test database with `max` connections. */
@@ -7,8 +7,6 @@ interface DriverContractOptions {
7
7
  }): Driver;
8
8
  /** Creates a driver over a new client of the test database whose parsers of result values throw; for a client without parsers, the same as `createDriver`. */
9
9
  createDriverWithFailingParsers(): Driver;
10
- /** Whether the client can close a reserved connection, so that the driver gets rid of a connection left in a transaction or lost; `false` leaves out the tests of it. */
11
- closesReservedConnections: boolean;
12
10
  }
13
11
  /**
14
12
  * Functions of a test runner that declare the tests of `describeDriverContract`.
package/dist/testing.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { n as text, t as char } from "./text-Cti9QLK7.mjs";
2
- import { O as and, a as defineSchema, g as createStatement, i as sql, r as param, t as createDatabase, v as defineTable } from "./database-CP4oapsQ.mjs";
3
- import { _ as timestamptz, a as numeric, b as array, d as jsonb, f as enumOf, g as timestamp, h as time, i as integer, l as inet, m as interval, n as bigint, p as date, r as doublePrecision, t as uuid, v as boolean, y as bytea } from "./types-DfoL8Oi9.mjs";
1
+ import { n as text, t as char } from "./text-CIUxPWPl.mjs";
2
+ import { c as defineSchema, i as createDatabase, j as and, n as QueryError, o as param, s as sql, t as ConnectionError, x as defineTable, y as createStatement } from "./driver-error-Dx5R83Rp.mjs";
3
+ import { _ as timestamptz, a as numeric, b as array, d as jsonb, f as enumOf, g as timestamp, h as time, i as integer, l as inet, m as interval, n as bigint, p as date, r as doublePrecision, t as uuid, v as boolean, y as bytea } from "./types-D3d35qR2.mjs";
4
4
  import assert from "node:assert/strict";
5
5
  // src/execution/testing.ts
6
6
  /** Creates the test helpers of a database created with `test: true`, registering fixtures with the hooks of a test runner. */
@@ -36,14 +36,14 @@ function createTestHelpers(database, hooks) {
36
36
  };
37
37
  }
38
38
  // src/execution/driver-contract.ts
39
- /** Creates helpers that run raw statements on `database`. */
40
- function createStatementRunners(database) {
39
+ /** Creates helpers that run raw statements on `target`: a database, a driver, or a reserved connection. */
40
+ function createStatementRunners(target) {
41
41
  return {
42
42
  async runStatement(text) {
43
- await database.execute(createStatement(text));
43
+ await target.execute(createStatement(text));
44
44
  },
45
45
  async selectValue(text, parameters = []) {
46
- const { rows } = await database.execute(createStatement(text, parameters));
46
+ const { rows } = await target.execute(createStatement(text, parameters));
47
47
  return rows[0][0];
48
48
  }
49
49
  };
@@ -54,12 +54,14 @@ function createStatementRunners(database) {
54
54
  * They run in the empty database of its clients and leave it unchanged.
55
55
  */
56
56
  function describeDriverContract(options, runner) {
57
- const { createDriver, createDriverWithFailingParsers, closesReservedConnections } = options;
57
+ const { createDriver, createDriverWithFailingParsers } = options;
58
58
  const { describe, it, before, after } = runner;
59
59
  describe("driver contract", () => {
60
- const database = createDatabase({ driver: createDriver({ max: 2 }) });
60
+ const driver = createDriver({ max: 2 });
61
+ const database = createDatabase({ driver });
61
62
  after(() => database.close());
62
63
  const { runStatement, selectValue } = createStatementRunners(database);
64
+ const { selectValue: selectValueOnDriver } = createStatementRunners(driver);
63
65
  it("executes a query in a transaction", async () => {
64
66
  const tag = defineTable("pg_tag_test", {
65
67
  id: integer,
@@ -91,6 +93,18 @@ function describeDriverContract(options, runner) {
91
93
  await database.script("SET LOCAL client_min_messages = warning; DROP TABLE IF EXISTS pg_statement_test");
92
94
  }
93
95
  });
96
+ it("returns every value as text", async () => {
97
+ const { rows } = await driver.execute(createStatement(`SELECT 42::integer, 12345678901234::bigint, true, '{"a":1}'::jsonb, NULL::text, ARRAY['a', 'b'], '2030-01-01 12:00'::timestamp`));
98
+ assert.deepEqual(rows, [[
99
+ "42",
100
+ "12345678901234",
101
+ "t",
102
+ "{\"a\": 1}",
103
+ null,
104
+ "{a,b}",
105
+ "2030-01-01 12:00:00"
106
+ ]]);
107
+ });
94
108
  it("keeps the values of a statement as text without the parsers of the client", async () => {
95
109
  const parsed = createDatabase({ driver: createDriverWithFailingParsers() });
96
110
  try {
@@ -110,7 +124,7 @@ function describeDriverContract(options, runner) {
110
124
  });
111
125
  it("executes a script on the pool in one implicit transaction", async () => {
112
126
  try {
113
- await assert.rejects(database.script("CREATE TABLE pg_script_pool_test (id integer); SELECT 1/0"), /division by zero/);
127
+ await assert.rejects(database.script("CREATE TABLE pg_script_pool_test (id integer); SELECT 1/0"), (error) => error instanceof QueryError && error.code === "22012");
114
128
  assert.equal(await selectValue("SELECT to_regclass('pg_script_pool_test')::text"), null);
115
129
  } finally {
116
130
  await database.script("SET LOCAL client_min_messages = warning; DROP TABLE IF EXISTS pg_script_pool_test");
@@ -156,6 +170,10 @@ function describeDriverContract(options, runner) {
156
170
  assert.equal(await selectValue("SELECT $1", ["text"]), "text");
157
171
  assert.equal(await selectValue("SELECT $1::text IS NULL", [null]), "t");
158
172
  });
173
+ it("sends a parameter as it is, whatever type PostgreSQL describes for it", async () => {
174
+ assert.equal(await selectValueOnDriver("SELECT $1::boolean", ["true"]), "t");
175
+ assert.equal(await selectValueOnDriver("SELECT $1::jsonb ->> 'a'", ["{\"a\":\"x\"}"]), "x");
176
+ });
159
177
  it("runs concurrent statements of a transaction in the order of calls", async () => {
160
178
  const values = await database.transaction(() => Promise.all([
161
179
  selectValue("SELECT set_config('kern.test', '1', true) FROM pg_sleep(0.05)"),
@@ -170,6 +188,32 @@ function describeDriverContract(options, runner) {
170
188
  "2"
171
189
  ]);
172
190
  });
191
+ it("runs the statements sent on a reserved connection before ROLLBACK inside its transaction", async () => {
192
+ const own = createDriver({ max: 1 });
193
+ try {
194
+ const connection = await own.acquire();
195
+ const { runStatement, selectValue } = createStatementRunners(connection);
196
+ let failure;
197
+ try {
198
+ await runStatement("CREATE TEMP TABLE pg_order_test (id integer)");
199
+ await runStatement("BEGIN");
200
+ await Promise.all([
201
+ runStatement("INSERT INTO pg_order_test VALUES (1)"),
202
+ runStatement("SELECT pg_sleep(0.05)"),
203
+ runStatement("INSERT INTO pg_order_test VALUES (2)"),
204
+ runStatement("ROLLBACK")
205
+ ]);
206
+ assert.equal(await selectValue("SELECT count(*) FROM pg_order_test"), "0");
207
+ } catch (error) {
208
+ failure = { error };
209
+ throw error;
210
+ } finally {
211
+ await connection.release(failure);
212
+ }
213
+ } finally {
214
+ await own.close();
215
+ }
216
+ });
173
217
  it("decodes selected expressions with their types", async () => {
174
218
  const tag = defineTable("pg_tag_test", {
175
219
  id: integer,
@@ -201,6 +245,33 @@ function describeDriverContract(options, runner) {
201
245
  length: null
202
246
  }]);
203
247
  });
248
+ it("rejects a statement that PostgreSQL rejected with QueryError and keeps its connection, on the pool and on a reserved connection", async () => {
249
+ const own = createDriver({ max: 1 });
250
+ try {
251
+ const pool = createStatementRunners(own);
252
+ await pool.runStatement("CREATE TEMP TABLE pg_unique_test (id integer CONSTRAINT pg_unique_test_key UNIQUE)");
253
+ await pool.runStatement("INSERT INTO pg_unique_test VALUES (1)");
254
+ const pid = await pool.selectValue("SELECT pg_backend_pid()");
255
+ /** Asserts that inserting a duplicate on `target` rejects with the violated constraint, and that its connection stays the same. */
256
+ async function assertRejected(target) {
257
+ const runners = createStatementRunners(target);
258
+ const error = await runners.runStatement("INSERT INTO pg_unique_test VALUES (1)").catch((error) => error);
259
+ assert.ok(error instanceof QueryError, `Expected QueryError, got ${String(error)}`);
260
+ assert.equal(error.code, "23505");
261
+ assert.equal(error.constraint, "pg_unique_test_key");
262
+ assert.equal(await runners.selectValue("SELECT pg_backend_pid()"), pid);
263
+ }
264
+ await assertRejected(own);
265
+ const connection = await own.acquire();
266
+ try {
267
+ await assertRejected(connection);
268
+ } finally {
269
+ await connection.release();
270
+ }
271
+ } finally {
272
+ await own.close();
273
+ }
274
+ });
204
275
  it("rejects a transaction whose failed statement the callback caught", async () => {
205
276
  const transaction = database.transaction(async () => {
206
277
  await runStatement("SELECT 1/0").catch(() => {});
@@ -233,7 +304,7 @@ function describeDriverContract(options, runner) {
233
304
  await driver.close();
234
305
  }
235
306
  });
236
- if (closesReservedConnections) {
307
+ if (driver.closesReservedConnections) {
237
308
  for (const [state, text] of [["an open", "SELECT 1"], ["a failed", "SELECT 1/0"]]) it(`does not return a connection in ${state} transaction to the pool`, async () => {
238
309
  const driver = createDriver({ max: 1 });
239
310
  try {
@@ -261,7 +332,48 @@ function describeDriverContract(options, runner) {
261
332
  await single.close();
262
333
  }
263
334
  });
335
+ it("rejects a statement of a transaction whose connection is lost with ConnectionError", async () => {
336
+ const own = createDriver({ max: 1 });
337
+ try {
338
+ const connection = await own.acquire();
339
+ const { runStatement, selectValue: selectValueOnConnection } = createStatementRunners(connection);
340
+ let failure;
341
+ try {
342
+ await runStatement("BEGIN");
343
+ await runStatement("CREATE TEMP TABLE pg_lost_test (id integer) ON COMMIT DROP");
344
+ const pid = await selectValueOnConnection("SELECT pg_backend_pid()");
345
+ assert.equal(await selectValue("SELECT pg_terminate_backend($1, 5000)", [pid]), "t");
346
+ await new Promise((resolve) => setTimeout(resolve, 50));
347
+ const error = await runStatement("INSERT INTO pg_lost_test VALUES (1)").catch((error) => error);
348
+ failure = { error };
349
+ assert.ok(error instanceof ConnectionError, `Expected ConnectionError, got ${String(error)}`);
350
+ } catch (error) {
351
+ failure ??= { error };
352
+ throw error;
353
+ } finally {
354
+ await connection.release(failure);
355
+ }
356
+ } finally {
357
+ await own.close();
358
+ }
359
+ });
264
360
  }
361
+ it("replaces an idle connection whose backend exited", async () => {
362
+ const own = createDriver({ max: 2 });
363
+ const held = [];
364
+ try {
365
+ for (let count = 0; count < 2; count++) held.push(await own.acquire());
366
+ const pids = [];
367
+ for (const connection of held) pids.push(await createStatementRunners(connection).selectValue("SELECT pg_backend_pid()"));
368
+ while (held.length > 0) await held.shift().release();
369
+ for (const pid of pids) assert.equal(await selectValue("SELECT pg_terminate_backend($1, 5000)", [pid]), "t");
370
+ await new Promise((resolve) => setTimeout(resolve, 50));
371
+ assert.equal(await createStatementRunners(own).selectValue("SELECT 'usable'"), "usable");
372
+ } finally {
373
+ await Promise.allSettled(held.map(async (connection) => connection.release()));
374
+ await own.close();
375
+ }
376
+ });
265
377
  it("isolates concurrent transactions on their own connections", async () => {
266
378
  const bothStarted = Promise.withResolvers();
267
379
  let startedCount = 0;
@@ -353,6 +465,24 @@ function describeDriverContract(options, runner) {
353
465
  assert.equal(await query, "slept");
354
466
  assert.deepEqual(settled, ["query", "database"]);
355
467
  });
468
+ it("rejects a statement, a script, and a connection requested right after it starts with ConnectionError", async () => {
469
+ const driver = createDriver({ max: 1 });
470
+ const held = await driver.acquire();
471
+ const closing = driver.close();
472
+ const acquiring = driver.acquire();
473
+ const rejections = [
474
+ assert.rejects(driver.execute(createStatement("SELECT 1")), ConnectionError),
475
+ assert.rejects(driver.executeScript("SELECT 1"), ConnectionError),
476
+ assert.rejects(acquiring, ConnectionError)
477
+ ];
478
+ acquiring.then((connection) => connection.release()).catch(() => {});
479
+ await held.release();
480
+ try {
481
+ await Promise.all(rejections);
482
+ } finally {
483
+ await closing;
484
+ }
485
+ });
356
486
  });
357
487
  describe("in test transactions", () => {
358
488
  const database = createDatabase({
@@ -240,6 +240,7 @@ function createType(state) {
240
240
  withParameters: (format) => derive({ formatSqlType: format }),
241
241
  ...formatSqlType && { with: (...parameters) => derive({ sqlType: formatSqlType(...parameters) }) },
242
242
  nullable: () => derive({ isNullable: true }),
243
+ of: () => type,
243
244
  columnName: (name) => new Column(type, {
244
245
  name,
245
246
  keyKind: void 0,
@@ -1,4 +1,4 @@
1
- import { A as hasEquality, E as defineType, T as getBooleanType, a as stringifyJson, d as orderingOperators, i as formatTypeName, k as equalityOperators, l as defineNumberType, o as decodeBytea, s as encodeBytea, u as getIntegerType } from "./text-Cti9QLK7.mjs";
1
+ import { A as hasEquality, E as defineType, T as getBooleanType, a as stringifyJson, d as orderingOperators, i as formatTypeName, k as equalityOperators, l as defineNumberType, o as decodeBytea, s as encodeBytea, u as getIntegerType } from "./text-CIUxPWPl.mjs";
2
2
  // src/type/builtins/array.ts
3
3
  /**
4
4
  * Creates a one-dimensional array type of `element` values.
@@ -196,10 +196,7 @@ function enumOf(name, _values) {
196
196
  return defineType({
197
197
  sqlType: name,
198
198
  castType: name
199
- }).transform({
200
- decode: (value) => value,
201
- encode: (value) => value
202
- }).withOperators(orderingOperators);
199
+ }).withOperators(orderingOperators).of();
203
200
  }
204
201
  // src/type/builtins/json.ts
205
202
  function createJsonType(sqlType) {
@@ -208,16 +205,10 @@ function createJsonType(sqlType) {
208
205
  encode: stringifyJson
209
206
  });
210
207
  }
211
- function addShape(type) {
212
- return Object.freeze({
213
- ...type,
214
- of: () => type
215
- });
216
- }
217
208
  /** `json` values; `json.of<T>()` declares their shape. PostgreSQL has no `=` for `json`, so its expressions have no `eq`, `ne`, or `in`. */
218
- const json = /* @__PURE__ */ addShape(/* @__PURE__ */ createJsonType("json"));
209
+ const json = /* @__PURE__ */ createJsonType("json");
219
210
  /** `jsonb` values; `jsonb.of<T>()` declares their shape. */
220
- const jsonb = /* @__PURE__ */ addShape(/* @__PURE__ */ createJsonType("jsonb").withOperators(equalityOperators));
211
+ const jsonb = /* @__PURE__ */ createJsonType("jsonb").withOperators(equalityOperators);
221
212
  // src/type/builtins/network.ts
222
213
  /** IP address with an optional netmask as a string, such as `192.168.0.1`. */
223
214
  const inet = /* @__PURE__ */ defineType({ sqlType: "inet" }).withOperators(orderingOperators);
package/dist/types.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { Bi as MergeOperators, Di as Type, Hi as OperatorDefinitions, Lr as ComparisonSignature, Mr as EqualityOperators, Nr as HasEquality, Pr as InSignature, S as AnyExpression, Ti as BaseType, Ui as GenericOperator, Vi as NoOperators, _ as TextOperators, b as NumberTypeOperators, jr as EqualityOperator, v as TextTypeOperators } from "./index-CoKpXcBp.mjs";
1
+ import { E as AnyExpression, Gi as Type, Jr as HasEquality, Kr as EqualityOperator, Qr as ComparisonSignature, S as TextTypeOperators, Ui as BaseType, Yr as InSignature, aa as NoOperators, ia as MergeOperators, oa as OperatorDefinitions, qr as EqualityOperators, sa as GenericOperator, w as NumberTypeOperators, x as TextOperators } from "./index-B1aH5Ht0.mjs";
2
2
  /**
3
3
  * Creates a one-dimensional array type of `element` values.
4
4
  *
@@ -71,15 +71,10 @@ declare function enumOf<const Values extends readonly string[]>(name: string, _v
71
71
  gt: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
72
72
  gte: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
73
73
  }>, undefined>;
74
- /** JSON type of `unknown` values with operators `O` and `of`, which declares their shape. */
75
- type JsonType<O extends OperatorDefinitions = NoOperators> = Type<unknown, unknown, O> & {
76
- /** Declares the shape of the values, which is not validated at runtime. */
77
- of<T>(): Type<T, T, O>;
78
- };
79
74
  /** `json` values; `json.of<T>()` declares their shape. PostgreSQL has no `=` for `json`, so its expressions have no `eq`, `ne`, or `in`. */
80
- export declare const json: JsonType<NoOperators>;
75
+ export declare const json: BaseType<unknown, {}, NoOperators, undefined>;
81
76
  /** `jsonb` values; `jsonb.of<T>()` declares their shape. */
82
- export declare const jsonb: JsonType<MergeOperators<NoOperators, EqualityOperators>>;
77
+ export declare const jsonb: BaseType<unknown, {}, MergeOperators<NoOperators, EqualityOperators>, undefined>;
83
78
  /** IP address with an optional netmask as a string, such as `192.168.0.1`. */
84
79
  export declare const inet: BaseType<string, string, MergeOperators<NoOperators, {
85
80
  eq: EqualityOperator<ComparisonSignature>;
package/dist/types.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { n as text, r as varchar, t as char } from "./text-Cti9QLK7.mjs";
2
- import { _ as timestamptz, a as numeric, b as array, c as cidr, d as jsonb, f as enumOf, g as timestamp, h as time, i as integer, l as inet, m as interval, n as bigint, o as real, p as date, r as doublePrecision, s as smallint, t as uuid, u as json, v as boolean, y as bytea } from "./types-DfoL8Oi9.mjs";
1
+ import { n as text, r as varchar, t as char } from "./text-CIUxPWPl.mjs";
2
+ import { _ as timestamptz, a as numeric, b as array, c as cidr, d as jsonb, f as enumOf, g as timestamp, h as time, i as integer, l as inet, m as interval, n as bigint, o as real, p as date, r as doublePrecision, s as smallint, t as uuid, u as json, v as boolean, y as bytea } from "./types-D3d35qR2.mjs";
3
3
  export { array, bigint, boolean, bytea, char, cidr, date, doublePrecision, enumOf as enum, inet, integer, interval, json, jsonb, numeric, real, smallint, text, time, timestamp, timestamptz, uuid, varchar };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kern-orm",
3
- "version": "0.6.0",
3
+ "version": "0.8.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",
@@ -42,13 +42,7 @@
42
42
  },
43
43
  "devDependencies": {
44
44
  "@kern-orm/postgres-js": "workspace:*",
45
- "kern-orm-0.2.0": "https://registry.npmjs.org/kern-orm/-/kern-orm-0.2.0.tgz",
46
- "kern-orm-0.3.0": "https://registry.npmjs.org/kern-orm/-/kern-orm-0.3.0.tgz",
47
- "migrations-published": "https://registry.npmjs.org/@kern-orm/migrations/-/migrations-0.3.1.tgz",
48
- "node-postgres-published": "https://registry.npmjs.org/@kern-orm/node-postgres/-/node-postgres-0.1.0.tgz",
49
45
  "postgres": "catalog:",
50
- "postgres-js-published": "https://registry.npmjs.org/@kern-orm/postgres-js/-/postgres-js-0.1.2.tgz",
51
- "postgres-js-v3-published": "https://registry.npmjs.org/@kern-orm/postgres-js-v3/-/postgres-js-v3-0.1.2.tgz",
52
46
  "typescript-6": "catalog:"
53
47
  },
54
48
  "engines": {