joist-core 2.5.0-next.21 → 2.5.0-next.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/build/EntityManager.cjs +15 -3
  2. package/build/EntityManager.cjs.map +1 -1
  3. package/build/EntityManager.d.cts +3 -3
  4. package/build/EntityManager.d.cts.map +1 -1
  5. package/build/EntityManager.d.mts +3 -3
  6. package/build/EntityManager.d.mts.map +1 -1
  7. package/build/EntityManager.js +15 -3
  8. package/build/EntityManager.js.map +1 -1
  9. package/build/PluginManager.cjs +6 -0
  10. package/build/PluginManager.cjs.map +1 -1
  11. package/build/PluginManager.d.cts +10 -0
  12. package/build/PluginManager.d.cts.map +1 -1
  13. package/build/PluginManager.d.mts +10 -0
  14. package/build/PluginManager.d.mts.map +1 -1
  15. package/build/PluginManager.js +6 -0
  16. package/build/PluginManager.js.map +1 -1
  17. package/build/index.cjs +10 -3
  18. package/build/index.cjs.map +1 -1
  19. package/build/index.d.cts +9 -7
  20. package/build/index.d.cts.map +1 -1
  21. package/build/index.d.mts +9 -7
  22. package/build/index.d.mts.map +1 -1
  23. package/build/index.js +6 -4
  24. package/build/index.js.map +1 -1
  25. package/build/queries/ConditionBuilder.cjs +2 -1
  26. package/build/queries/ConditionBuilder.cjs.map +1 -1
  27. package/build/queries/ConditionBuilder.d.cts +9 -1
  28. package/build/queries/ConditionBuilder.d.cts.map +1 -1
  29. package/build/queries/ConditionBuilder.d.mts +9 -1
  30. package/build/queries/ConditionBuilder.d.mts.map +1 -1
  31. package/build/queries/ConditionBuilder.js +2 -2
  32. package/build/queries/ConditionBuilder.js.map +1 -1
  33. package/build/queries/conditions.cjs.map +1 -1
  34. package/build/queries/conditions.d.cts +4 -1
  35. package/build/queries/conditions.d.cts.map +1 -1
  36. package/build/queries/conditions.d.mts +4 -1
  37. package/build/queries/conditions.d.mts.map +1 -1
  38. package/build/queries/conditions.js.map +1 -1
  39. package/build/queries/sql/Expr.cjs +79 -134
  40. package/build/queries/sql/Expr.cjs.map +1 -1
  41. package/build/queries/sql/Expr.d.cts +26 -34
  42. package/build/queries/sql/Expr.d.cts.map +1 -1
  43. package/build/queries/sql/Expr.d.mts +26 -34
  44. package/build/queries/sql/Expr.d.mts.map +1 -1
  45. package/build/queries/sql/Expr.js +80 -133
  46. package/build/queries/sql/Expr.js.map +1 -1
  47. package/build/queries/sql/ParsedQuery.cjs +119 -0
  48. package/build/queries/sql/ParsedQuery.cjs.map +1 -0
  49. package/build/queries/sql/ParsedQuery.d.cts +105 -0
  50. package/build/queries/sql/ParsedQuery.d.cts.map +1 -0
  51. package/build/queries/sql/ParsedQuery.d.mts +105 -0
  52. package/build/queries/sql/ParsedQuery.d.mts.map +1 -0
  53. package/build/queries/sql/ParsedQuery.js +116 -0
  54. package/build/queries/sql/ParsedQuery.js.map +1 -0
  55. package/build/queries/sql/ParsedSqlExpression.cjs +74 -0
  56. package/build/queries/sql/ParsedSqlExpression.cjs.map +1 -0
  57. package/build/queries/sql/ParsedSqlExpression.d.cts +65 -0
  58. package/build/queries/sql/ParsedSqlExpression.d.cts.map +1 -0
  59. package/build/queries/sql/ParsedSqlExpression.d.mts +65 -0
  60. package/build/queries/sql/ParsedSqlExpression.d.mts.map +1 -0
  61. package/build/queries/sql/ParsedSqlExpression.js +69 -0
  62. package/build/queries/sql/ParsedSqlExpression.js.map +1 -0
  63. package/build/queries/sql/Tables.cjs +61 -46
  64. package/build/queries/sql/Tables.cjs.map +1 -1
  65. package/build/queries/sql/Tables.d.cts.map +1 -1
  66. package/build/queries/sql/Tables.d.mts.map +1 -1
  67. package/build/queries/sql/Tables.js +61 -46
  68. package/build/queries/sql/Tables.js.map +1 -1
  69. package/build/queries/sql/execute.cjs +45 -62
  70. package/build/queries/sql/execute.cjs.map +1 -1
  71. package/build/queries/sql/execute.d.cts +4 -3
  72. package/build/queries/sql/execute.d.cts.map +1 -1
  73. package/build/queries/sql/execute.d.mts +4 -3
  74. package/build/queries/sql/execute.d.mts.map +1 -1
  75. package/build/queries/sql/execute.js +47 -64
  76. package/build/queries/sql/execute.js.map +1 -1
  77. package/build/queries/sql/expressions/arrayAgg.cjs +14 -15
  78. package/build/queries/sql/expressions/arrayAgg.cjs.map +1 -1
  79. package/build/queries/sql/expressions/arrayAgg.d.cts +3 -2
  80. package/build/queries/sql/expressions/arrayAgg.d.cts.map +1 -1
  81. package/build/queries/sql/expressions/arrayAgg.d.mts +3 -2
  82. package/build/queries/sql/expressions/arrayAgg.d.mts.map +1 -1
  83. package/build/queries/sql/expressions/arrayAgg.js +15 -16
  84. package/build/queries/sql/expressions/arrayAgg.js.map +1 -1
  85. package/build/queries/sql/expressions/case.cjs +11 -16
  86. package/build/queries/sql/expressions/case.cjs.map +1 -1
  87. package/build/queries/sql/expressions/case.d.cts +3 -2
  88. package/build/queries/sql/expressions/case.d.cts.map +1 -1
  89. package/build/queries/sql/expressions/case.d.mts +3 -2
  90. package/build/queries/sql/expressions/case.d.mts.map +1 -1
  91. package/build/queries/sql/expressions/case.js +11 -16
  92. package/build/queries/sql/expressions/case.js.map +1 -1
  93. package/build/queries/sql/expressions/coalesce.cjs.map +1 -1
  94. package/build/queries/sql/expressions/coalesce.d.cts +3 -2
  95. package/build/queries/sql/expressions/coalesce.d.cts.map +1 -1
  96. package/build/queries/sql/expressions/coalesce.d.mts +3 -2
  97. package/build/queries/sql/expressions/coalesce.d.mts.map +1 -1
  98. package/build/queries/sql/expressions/coalesce.js.map +1 -1
  99. package/build/queries/sql/expressions/expression.cjs +10 -12
  100. package/build/queries/sql/expressions/expression.cjs.map +1 -1
  101. package/build/queries/sql/expressions/expression.d.cts +4 -3
  102. package/build/queries/sql/expressions/expression.d.cts.map +1 -1
  103. package/build/queries/sql/expressions/expression.d.mts +4 -3
  104. package/build/queries/sql/expressions/expression.d.mts.map +1 -1
  105. package/build/queries/sql/expressions/expression.js +11 -13
  106. package/build/queries/sql/expressions/expression.js.map +1 -1
  107. package/build/queries/sql/expressions/greatest.cjs.map +1 -1
  108. package/build/queries/sql/expressions/greatest.d.cts +3 -2
  109. package/build/queries/sql/expressions/greatest.d.cts.map +1 -1
  110. package/build/queries/sql/expressions/greatest.d.mts +3 -2
  111. package/build/queries/sql/expressions/greatest.d.mts.map +1 -1
  112. package/build/queries/sql/expressions/greatest.js.map +1 -1
  113. package/build/queries/sql/expressions/least.cjs.map +1 -1
  114. package/build/queries/sql/expressions/least.d.cts +3 -2
  115. package/build/queries/sql/expressions/least.d.cts.map +1 -1
  116. package/build/queries/sql/expressions/least.d.mts +3 -2
  117. package/build/queries/sql/expressions/least.d.mts.map +1 -1
  118. package/build/queries/sql/expressions/least.js.map +1 -1
  119. package/build/queries/sql/expressions/nullIf.cjs.map +1 -1
  120. package/build/queries/sql/expressions/nullIf.d.cts +3 -2
  121. package/build/queries/sql/expressions/nullIf.d.cts.map +1 -1
  122. package/build/queries/sql/expressions/nullIf.d.mts +3 -2
  123. package/build/queries/sql/expressions/nullIf.d.mts.map +1 -1
  124. package/build/queries/sql/expressions/nullIf.js.map +1 -1
  125. package/build/queries/sql/query.cjs +168 -381
  126. package/build/queries/sql/query.cjs.map +1 -1
  127. package/build/queries/sql/query.d.cts +44 -45
  128. package/build/queries/sql/query.d.cts.map +1 -1
  129. package/build/queries/sql/query.d.mts +44 -45
  130. package/build/queries/sql/query.d.mts.map +1 -1
  131. package/build/queries/sql/query.js +172 -383
  132. package/build/queries/sql/query.js.map +1 -1
  133. package/build/queries/sql/renderSql.cjs +321 -0
  134. package/build/queries/sql/renderSql.cjs.map +1 -0
  135. package/build/queries/sql/renderSql.d.cts +14 -0
  136. package/build/queries/sql/renderSql.d.cts.map +1 -0
  137. package/build/queries/sql/renderSql.d.mts +14 -0
  138. package/build/queries/sql/renderSql.d.mts.map +1 -0
  139. package/build/queries/sql/renderSql.js +318 -0
  140. package/build/queries/sql/renderSql.js.map +1 -0
  141. package/package.json +2 -2
package/build/index.d.mts CHANGED
@@ -43,6 +43,8 @@ import { ActualFactoryOpts, ColumnsOf, EntityOf, FactoryExtrasOf, FieldsOf, Filt
43
43
  import { AliasAssigner } from "./queries/sql/AliasAssigner.mjs";
44
44
  import { JoinTree } from "./queries/sql/JoinTree.mjs";
45
45
  import { AndCondition, ConditionGroup, DomainPredicate, OrCondition, PredicateBrand, SqlCondition, SqlPredicate } from "./queries/conditions.mjs";
46
+ import { CaseElse, CaseWhen } from "./queries/sql/expressions/case.mjs";
47
+ import { ExprFromInput, ExprInput } from "./queries/sql/expressions/types.mjs";
46
48
  import { Alias, AliasBrand, AliasColumn, AliasMgmt, EntityAlias, PolyAlias, PrimitiveAlias, alias, aliases, getAliasMetadata, getAliasMgmt, getMaybeCtiAlias, isAlias, newAliasProxy } from "./queries/find/Aliases.mjs";
47
49
  import { CollectionJoin, EntityColumn, PolyReference, PrimitiveColumn, ReferenceColumn, ReferenceJoin, Table, TableBrand, TableFilter, TableFor, TableMgmt, TableSourceBrand, TableSourceMgmt, getTableMetadata, getTableMgmt, isTable, newTableProxy, table, tableMgmt, tables } from "./queries/sql/Tables.mjs";
48
50
  import { CustomColumnConfig, CustomColumnInput, CustomColumnInputs, CustomColumnType, CustomTable, CustomTableDefinition, CustomTableFor, declareTable } from "./queries/sql/custom.mjs";
@@ -56,7 +58,6 @@ import { EntityMetrics, EntityMetricsSnapshot, EvaluationStats } from "./metrics
56
58
  import { DeleteStatement, ExecuteResult, InsertStatement, InsertValues, MutationReturning, MutationStatement, UpdateStatement, UpdateValues } from "./queries/sql/execute.mjs";
57
59
  import { EnumMetadata } from "./EnumMetadata.mjs";
58
60
  import { ArrayAggOptions, Expr, ExprBrand, ExprLike, InnerJoin, LeftJoin, exprBrand } from "./queries/sql/Expr.mjs";
59
- import { DeleteOp, InsertFixup, InsertOp, OpColumn, UpdateOp, generateOps } from "./drivers/EntityWriter.mjs";
60
61
  import { expr } from "./queries/sql/expressions/expression.mjs";
61
62
  import { skipCondition } from "./queries/skipCondition.mjs";
62
63
  import { EntityOrId, HintNode } from "./loading/HintTree.mjs";
@@ -64,9 +65,11 @@ import { InstanceData } from "./InstanceData.mjs";
64
65
  import { JoinColumnValue, JoinRow, JoinRowOperation, ManyToManyLike } from "./flush/JoinRows.mjs";
65
66
  import { PendingChange, PendingCreate, PendingDelete, PendingM2M, PendingUpdate } from "./flush/PendingChanges.mjs";
66
67
  import { Plugin } from "./PluginManager.mjs";
68
+ import { BoundValue, ColumnSql, ConditionSql, ExpressionCondition as ExpressionCondition$1, JoinedSql, ParsedSql, ParsedSqlCondition, QuerySql, RawSql, SqlPart, StarSql, columnSql, joinSql, visitSql } from "./queries/sql/ParsedSqlExpression.mjs";
69
+ import { ParsedExecuteQuery, ParsedReadQuery, ParsedSelectQuery, ParsedSetQuery, QueryExpressionClause, QueryExpressionContext, visitQuery, visitQueryExpressions } from "./queries/sql/ParsedQuery.mjs";
70
+ import { DeleteOp, InsertFixup, InsertOp, OpColumn, UpdateOp, generateOps } from "./drivers/EntityWriter.mjs";
71
+ import { CheckScope, Clauses, EntityQuery, ExistsQuery, ExpressionOrderBy, MaybeNull, NameOf, NotWidened, OrderByDirection, OrderByKeys, ParsedCteSource, ParsedQuerySource, ParsedSource, ParsedTableSource, Query, QueryArg, QueryCondition, QueryJoin, QueryJoinInput, QueryJoinList, QueryRow, QuerySelect, QuerySource, QueryTable, QueryTableBrand, QueryValue, RecursiveOptions, ResolvedJoins, ScalarQuery, SetQuery, Subquery, SubqueryBrand, WithInput, WithSource, entityQueryBrand, query, queryMaybe, recursiveQuery, sql, subqueryBrand } from "./queries/sql/query.mjs";
67
72
  import { CrossJoinTable, JoinTable, LateralJoinTable, ParsedCteClause, ParsedFindQuery, ParsedGroupBy, ParsedOrderBy, ParsedSelect, ParsedTable, PrimaryTable, addTablePerClassJoinsAndClassTag, findFilterField, getTables, maybeAddIdNotNulls, maybeAddOrderBy, parseAlias, parseFindQuery } from "./queries/find/QueryParser.mjs";
68
- import { CaseElse, CaseWhen } from "./queries/sql/expressions/case.mjs";
69
- import { ExprFromInput, ExprInput } from "./queries/sql/expressions/types.mjs";
70
73
  import { buildCteSql, buildRawQuery } from "./queries/find/buildFindQuery.mjs";
71
74
  import { ColumnCondition, ExistsCondition, ParsedExpressionCondition, ParsedExpressionFilter, ParsedValueFilter, RawCondition } from "./queries/parsedConditions.mjs";
72
75
  import { ParsedEntityFilter, makeLike, mapToDb, parseEntityFilter, parseValueFilter } from "./queries/valueFilters.mjs";
@@ -77,8 +80,8 @@ import { PojoRowData, RowData, emptyRowData } from "./RowData.mjs";
77
80
  import { JoinRowTodo, Todo } from "./flush/Todo.mjs";
78
81
  import { Changes, EntityChanges, EnumCollectionFieldStatus, FieldStatus, ManyToManyFieldStatus, ManyToOneFieldStatus, OneToManyFieldStatus, PrimitiveFieldStatus, newChangesProxy } from "./changes.mjs";
79
82
  import { ConfigApi, EntityHook, resetBootFlag } from "./config.mjs";
80
- import { GuardTransitionMatch, OnTransitionMatch, TransitionTable } from "./transitions.mjs";
81
83
  import { Driver, DriverQueryResult } from "./drivers/Driver.mjs";
84
+ import { GuardTransitionMatch, OnTransitionMatch, TransitionTable } from "./transitions.mjs";
82
85
  import { configureMetadata, getConstructorFromTaggedId, getMetadataForTable, getMetadataForType, maybeGetConstructorFromReference } from "./configure.mjs";
83
86
  import { driverApi } from "./drivers/driverApi.mjs";
84
87
  import "./drivers/index.mjs";
@@ -91,13 +94,12 @@ import { setFactoryWriter } from "./logging/FactoryLogger.mjs";
91
94
  import { FieldLogger, FieldLoggerWatch, WriteFn, noopFieldLogger } from "./logging/FieldLogger.mjs";
92
95
  import { ReactionLogger, setReactionLogging } from "./logging/ReactionLogger.mjs";
93
96
  import { lazyField } from "./newEntity.mjs";
94
- import { FactoryEntityOpt, FactoryOpts, defaultValue, factories, getTestIndex, isFactoryCreation, maybeBranchValue, maybeNew, maybeNewPoly, newTestInstance, noValue, setFactoryLogging, testIndex } from "./newTestInstance.mjs";
95
97
  import { IdAssigner, RandomUuidAssigner, SequenceIdAssigner, TestUuidAssigner } from "./drivers/IdAssigner.mjs";
98
+ import { FactoryEntityOpt, FactoryOpts, defaultValue, factories, getTestIndex, isFactoryCreation, maybeBranchValue, maybeNew, maybeNewPoly, newTestInstance, noValue, setFactoryLogging, testIndex } from "./newTestInstance.mjs";
96
99
  import { deepNormalizeHint, normalizeHint } from "./normalizeHints.mjs";
97
100
  import { ImmutableEntitiesPlugin } from "./plugins/ImmutableEntitiesPlugin.mjs";
98
101
  import { JoinResult, PreloadHydrator, PreloadPlugin } from "./plugins/PreloadPlugin.mjs";
99
102
  import { JsonAggregatePreloader } from "./preloading/JsonAggregatePreloader.mjs";
100
- import { CheckScope, Clauses, EntityQuery, ExistsQuery, ExpressionOrderBy, MaybeNull, NameOf, NotWidened, OrderByDirection, OrderByKeys, Query, QueryArg, QueryCondition, QueryJoin, QueryJoinInput, QueryJoinList, QueryRow, QuerySelect, QuerySource, QueryTable, QueryTableBrand, QueryValue, RecursiveOptions, ResolvedJoins, ScalarQuery, SetQuery, Subquery, SubqueryBrand, WithInput, WithSource, entityQueryBrand, query, queryMaybe, recursiveQuery, sql, subqueryBrand } from "./queries/sql/query.mjs";
101
103
  import { Reactable, Reacted, ReactiveHint, ReactiveTarget, convertToLoadHint, isTypeOrSubType, reverseReactiveHint } from "./reactivity/reactiveHints.mjs";
102
104
  import "./relations/index.mjs";
103
105
  import { GenericError, ValidationCode, ValidationError, ValidationErrors, ValidationRule, ValidationRuleInternal, ValidationRuleResult, cannotBeChanged, cannotBeUpdated, maxValueRule, minValueRule, mustBeSubType, newRequiredLazyFieldRule, newRequiredRule, rangeValueRule } from "./rules.mjs";
@@ -178,5 +180,5 @@ export declare function failNoIdYet(entity: string): never;
178
180
  * See https://github.com/microsoft/TypeScript/issues/43368
179
181
  */
180
182
  export declare function isNewEntity<T extends Entity>(entity: T): entity is New<T>;
181
- export { type ActualFactoryOpts, type Alias, AliasAssigner, type AliasBrand, type AliasColumn, AliasFn, type AliasMgmt, type AndCondition, type ArrayAggOptions, type AsyncMethod, type AsyncProperty, AsyncPropertyImpl, BaseEntity, BigIntSerde, BooleanFilter, BooleanGraphQLFilter, type CaseElse, type CaseWhen, Changes, type CheckScope, type Clauses, CloneOverrides, CloneOverridesCallback, ClonePostClone, CloneSkipIf, type Collection, type CollectionJoin, Column, type ColumnCondition, ColumnDescriptors, type ColumnsOf, ConditionBuilder, type ConditionGroup, ConfigApi, CrossJoinTable, CustomCollection, type CustomColumnConfig, type CustomColumnInput, type CustomColumnInputs, type CustomColumnType, CustomJsonKeyHint, CustomReference, CustomSerde, CustomSerdeAdapter, type CustomTable, type CustomTableDefinition, type CustomTableFor, DateSerde, DecimalToNumberSerde, type DeepNew, type DeepPartialOrNull, DeleteOp, type DeleteStatement, type DomainPredicate, type Driver, type DriverQueryResult, type Entity, type EntityAlias, EntityChanges, type EntityColumn, EntityConstructor, type EntityField, type EntityFields, EntityFilter, EntityFilterObject, EntityGraphQLFilter, type EntityHook, EntityKeyJsonHint, EntityManager, EntityManagerHook, EntityManagerHookOptions, EntityManagerInternalApi, EntityManagerMode, EntityManagerOpts, EntityMetadata, EntityMetrics, type EntityMetricsSnapshot, type EntityOf, type EntityOrId, type EntityQuery, EnumArrayFieldSerde, type EnumCollection, EnumCollectionFieldStatus, EnumCollectionImpl, EnumField, EnumFieldSerde, type EnumMetadata, type EvaluationStats, type ExecuteResult, type ExistsCondition, type ExistsQuery, type Expr, type ExprBrand, type ExprFromInput, type ExprInput, type ExprLike, ExpressionCondition, ExpressionFilter, type ExpressionOrderBy, type FactoryEntityOpt, type FactoryExtrasOf, type FactoryOpts, FailedFlushError, Field, FieldColumn, FieldLogger, FieldLoggerWatch, FieldSerde, FieldStatus, type FieldsOf, FilterAndSettings, type FilterOf, FilterWithAlias, FindCountFilterOptions, FindFilter, FindFilterOptions, FindGqlFilterOptions, FindOperation, FlushOptions, type GenericError, GraphQLFilterAndSettings, type GraphQLFilterOf, GraphQLFilterWithAlias, type GuardTransitionMatch, type HintNode, IdAssigner, IdOf, type IdType, ImmutableEntitiesPlugin, type InheritanceTypeOf, type InnerJoin, InsertFixup, InsertOp, type InsertStatement, type InsertValues, InstanceData, type JoinColumnValue, type JoinResult, type JoinRow, JoinRowOperation, type JoinRowTodo, JoinTable, type JoinTree, JsonAggregatePreloader, JsonHint, JsonPayload, JsonSerde, Jsonable, JsonableValue, KeySerde, type LargeCollection, LargeOneToManyField, LateralJoinTable, type LazyField, LazyFieldImpl, type LeftJoin, Lens, type LoadHint, type Loadable, type Loaded, type LoadedCollection, type LoadedEnumCollection, type LoadedMethod, type LoadedProperty, type LoadedReadOnlyCollection, type LoadedReference, LoaderCache, ManyToManyCollection, ManyToManyEnumField, ManyToManyField, ManyToManyFieldStatus, ManyToManyLargeCollection, type ManyToManyLike, ManyToOneField, ManyToOneFieldStatus, type ManyToOneReference, ManyToOneReferenceImpl, type MarkLoaded, MaybeAbstractEntityConstructor, type MaybeNull, type MutationReturning, type MutationStatement, type NameOf, NestedJsonHint, type NestedLoadHint, type New, NotFoundError, type NotWidened, type OnTransitionMatch, OneToManyCollection, OneToManyField, OneToManyFieldStatus, OneToManyLargeCollection, OneToOneField, type OneToOneReference, OneToOneReferenceImpl, OpColumn, Operator, type OptIdsOf, type OptsOf, type OrCondition, OrderBy, type OrderByDirection, type OrderByKeys, type OrderOf, ParsedCteClause, type ParsedEntityFilter, type ParsedExpressionCondition, type ParsedExpressionFilter, ParsedFindQuery, ParsedGroupBy, ParsedOrderBy, ParsedSelect, ParsedTable, type ParsedValueFilter, type PendingChange, type PendingCreate, type PendingDelete, type PendingM2M, type PendingUpdate, PlainDateSerde, PlainDateTimeSerde, PlainTimeSerde, Plugin, PojoRowData, type PolyAlias, PolyComponent, type PolyReference, PolymorphicField, PolymorphicFieldComponent, PolymorphicKeySerde, type PolymorphicReference, PolymorphicReferenceImpl, type PredicateBrand, type PreloadHydrator, type PreloadPlugin, PrimaryKeyField, PrimaryTable, type PrimitiveAlias, type PrimitiveColumn, PrimitiveField, PrimitiveFieldStatus, PrimitiveSerde, type Property, PropertyImpl, type Query, type QueryArg, type QueryCondition, type QueryJoin, type QueryJoinInput, type QueryJoinList, type QueryRow, type QuerySelect, type QuerySource, type QueryTable, type QueryTableBrand, type QueryValue, RandomUuidAssigner, type RawCondition, type Reactable, type Reacted, ReactionLogger, type ReactiveField, type ReactiveGetter, type ReactiveHint, type ReactiveManyToMany, ReactiveManyToManyImpl, type ReactiveManyToManyOtherSide, ReactiveManyToManyOtherSideImpl, type ReactiveReference, ReactiveReferenceImpl, type ReactiveTarget, type ReadDrift, ReadDriftError, type ReadOnlyCollection, ReadOnlyError, RecursiveCycleError, type RecursiveOptions, type Reference, type ReferenceColumn, type ReferenceJoin, type Relation, type RelationsIn, type RelationsOf, type ResolvedJoins, ResolvedScope, type RootTypeNameOf, RowData, type RuntimeConfig, ScalarCodec, type ScalarQuery, Scope, ScopeFilterFragment, ScopeFn, ScopeJoinFilter, ScopeQuery, SequenceIdAssigner, SerdeField, type SetQuery, type SettableFields, SimpleFieldSerde, type SqlCondition, type SqlPredicate, StubbedRelation, type Subquery, type SubqueryBrand, SubqueryRenderer, SuperstructSerde, type Table, type TableBrand, type TableFilter, type TableFor, type TableMgmt, type TableSourceBrand, type TableSourceMgmt, TaggedId, Temporal, TestUuidAssigner, TimestampCodec, TimestampFields, TimestampSerde, ToJsonHint, Todo, TooManyError, type TransitionTable, type TypeMap, type TypeMapEntry, type TypeNameOf, UniqueFilter, UnknownProperty, UpdateOp, type UpdateStatement, type UpdateValues, ValidationCode, type ValidationError, ValidationErrors, type ValidationRule, type ValidationRuleInternal, type ValidationRuleResult, ValueFilter, ValueGraphQLFilter, VectorSerde, type WithInput, type WithLoaded, type WithSource, WriteFn, ZodSerde, ZonedDateTimeSerde, abbreviation, addTablePerClassJoinsAndClassTag, alias, aliases, appendStack, asNew, assertIdIsTagged, assertIdsAreTagged, assertLoaded, assertNever, buildCteSql, buildRawQuery, buildUnnestCte, buildValueCondition, buildWhereClause, cannotBeChanged, cannotBeUpdated, cleanSql, cleanStringValue, configureMetadata, convertToLoadHint, createRowFromEntityData, deTagId, deTagIds, declareTable, deepNormalizeHint, defaultValue, driverAfterBegin, driverAfterCommit, driverApi, driverBeforeBegin, driverBeforeCommit, emptyRowData, ensureLoaded, ensureRectangularArraySizes, ensureTagged, ensureWithLoaded, entityQueryBrand, expr, exprBrand, factories, fail, failIfAnyRejected, filterSoftDeletes, findFilterField, generateOps, getAliasMetadata, getAliasMgmt, getBaseAndSelfMetas, getBaseMeta, getBaseSelfAndSubMetas, getConstructorFromTaggedId, getDefaultEntityLimit, getEmInternalApi, getField, getInstanceData, getLazyFields, getLens, getLensPath, getMaybeCtiAlias, getMetadata, getMetadataForField, getMetadataForTable, getMetadataForType, getProperties, getRuntimeConfig, getSubMetas, getTableMetadata, getTableMgmt, getTables, getTestIndex, hasAsyncMethod, hasAsyncProperty, hasAsyncReactiveField, hasCustomCollection, hasCustomReference, hasEnumCollection, hasLargeMany, hasLargeManyToMany, hasLazyField, hasMany, hasManyDerived, hasManyThrough, hasManyToMany, hasOne, hasOneDerived, hasOnePolymorphic, hasOneThrough, hasOneToOne, hasProperty, hasReactiveAsyncMethod, hasReactiveField, hasReactiveGetter, hasReactiveManyToMany, hasReactiveManyToManyOtherSide, hasReactiveProperty, hasReactiveReference, hasRecursiveChildren, hasRecursiveM2m, hasRecursiveParents, hasSerde, hasVisibilityHook, indexBy, invokeRule, isAlias, isAllSqlPaths, isAsyncProperty, isAsyncReactiveField, isChangeableField, isCollection, isCollectionField, isDefined, isEntity, isFactoryCreation, isFieldSet, isId, isInTrustedContext, isKey, isLazyField, isLensLoaded, isLensLoadedPath, isLoaded, isLoadedAsyncProperty, isLoadedCollection, isLoadedLazyField, isLoadedOneToOneReference, isLoadedProperty, isLoadedReadOnlyCollection, isLoadedReference, isManyToManyEnumField, isManyToManyField, isManyToOneField, isManyToOneReference, isNew, isOneToManyField, isOneToOneField, isOneToOneReference, isPolymorphicField, isPolymorphicReference, isProperty, isReactiveField, isReactiveGetter, isReactiveManyToMany, isReactiveManyToManyOtherSide, isReactiveReference, isReadOnlyCollection, isReference, isReferenceField, isRelation, isScope, isScopeJoinFilter, isSelectAllFilter, isTable, isTaggedId, isTypeOrSubType, keyToNumber, keyToTaggedId, kq, kqDot, kqStar, lazyExcludedSelects, lazyField, lensPathToLoadHint, lensToLoadHint, lensToPath, loadLens, loadLensPath, makeLike, mapPathsToTarget, mapToDb, maxValueRule, maybeAddIdNotNulls, maybeAddNotSoftDeleted, maybeAddOrderBy, maybeBranchValue, maybeGetConstructorFromReference, maybeNew, maybeNewPoly, maybePopulateThen, maybeRequireTemporal, maybeResolveReferenceToId, mergeFindOptions, minValueRule, mustBeSubType, newAliasProxy, newChangesProxy, newPgConnectionConfig, newRequiredLazyFieldRule, newRequiredRule, newScopeFn, newTableProxy, newTestInstance, noValue, noopFieldLogger, normalizeHint, nowUTC, opToFn, operators, optimizeCollectionJoins, parseAlias, parseEntityFilter, parseFindQuery, parseValueFilter, partition, plainDateMapper, plainDateTimeMapper, plainTimeMapper, polymorphicField, query, queryMaybe, rangeValueRule, recursiveQuery, requireTemporal, resetBootFlag, resetDefaultEntityLimit, resolveScope, reverseReactiveHint, runInTrustedContext, sameEntity, sameReference, setDefaultEntityLimit, setFactoryLogging, setFactoryWriter, setField, setLastNow, setReactionLogging, setRuntimeConfig, setTaggedIdDelimiter, skipCondition, sql, stiSubtypeFilter, subqueryBrand, table, tableMgmt, tables, tagFromId, tagId, tagIds, taggedIdPrefix, testIndex, toIdOf, toJSON, toTaggedId, unsafeDeTagIds, unsafeLoaded, updatePartial, upsert, visitConditions, withLoaded, zeroTo, zonedDateTimeMapper };
183
+ export { type ActualFactoryOpts, type Alias, AliasAssigner, type AliasBrand, type AliasColumn, AliasFn, type AliasMgmt, type AndCondition, type ArrayAggOptions, type AsyncMethod, type AsyncProperty, AsyncPropertyImpl, BaseEntity, BigIntSerde, BooleanFilter, BooleanGraphQLFilter, type BoundValue, type CaseElse, type CaseWhen, Changes, type CheckScope, type Clauses, CloneOverrides, CloneOverridesCallback, ClonePostClone, CloneSkipIf, type Collection, type CollectionJoin, Column, type ColumnCondition, ColumnDescriptors, type ColumnSql, type ColumnsOf, ConditionBuilder, type ConditionGroup, type ConditionSql, ConfigApi, CrossJoinTable, CustomCollection, type CustomColumnConfig, type CustomColumnInput, type CustomColumnInputs, type CustomColumnType, CustomJsonKeyHint, CustomReference, CustomSerde, CustomSerdeAdapter, type CustomTable, type CustomTableDefinition, type CustomTableFor, DateSerde, DecimalToNumberSerde, type DeepNew, type DeepPartialOrNull, DeleteOp, type DeleteStatement, type DomainPredicate, type Driver, type DriverQueryResult, type Entity, type EntityAlias, EntityChanges, type EntityColumn, EntityConstructor, type EntityField, type EntityFields, EntityFilter, EntityFilterObject, EntityGraphQLFilter, type EntityHook, EntityKeyJsonHint, EntityManager, EntityManagerHook, EntityManagerHookOptions, EntityManagerInternalApi, EntityManagerMode, EntityManagerOpts, EntityMetadata, EntityMetrics, type EntityMetricsSnapshot, type EntityOf, type EntityOrId, type EntityQuery, EnumArrayFieldSerde, type EnumCollection, EnumCollectionFieldStatus, EnumCollectionImpl, EnumField, EnumFieldSerde, type EnumMetadata, type EvaluationStats, type ExecuteResult, type ExistsCondition, type ExistsQuery, type Expr, type ExprBrand, type ExprFromInput, type ExprInput, type ExprLike, ExpressionCondition, ExpressionFilter, type ExpressionOrderBy, type FactoryEntityOpt, type FactoryExtrasOf, type FactoryOpts, FailedFlushError, Field, FieldColumn, FieldLogger, FieldLoggerWatch, FieldSerde, FieldStatus, type FieldsOf, FilterAndSettings, type FilterOf, FilterWithAlias, FindCountFilterOptions, FindFilter, FindFilterOptions, FindGqlFilterOptions, FindOperation, FlushOptions, type GenericError, GraphQLFilterAndSettings, type GraphQLFilterOf, GraphQLFilterWithAlias, type GuardTransitionMatch, type HintNode, IdAssigner, IdOf, type IdType, ImmutableEntitiesPlugin, type InheritanceTypeOf, type InnerJoin, InsertFixup, InsertOp, type InsertStatement, type InsertValues, InstanceData, type JoinColumnValue, type JoinResult, type JoinRow, JoinRowOperation, type JoinRowTodo, JoinTable, type JoinTree, type JoinedSql, JsonAggregatePreloader, JsonHint, JsonPayload, JsonSerde, Jsonable, JsonableValue, KeySerde, type LargeCollection, LargeOneToManyField, LateralJoinTable, type LazyField, LazyFieldImpl, type LeftJoin, Lens, type LoadHint, type Loadable, type Loaded, type LoadedCollection, type LoadedEnumCollection, type LoadedMethod, type LoadedProperty, type LoadedReadOnlyCollection, type LoadedReference, LoaderCache, ManyToManyCollection, ManyToManyEnumField, ManyToManyField, ManyToManyFieldStatus, ManyToManyLargeCollection, type ManyToManyLike, ManyToOneField, ManyToOneFieldStatus, type ManyToOneReference, ManyToOneReferenceImpl, type MarkLoaded, MaybeAbstractEntityConstructor, type MaybeNull, type MutationReturning, type MutationStatement, type NameOf, NestedJsonHint, type NestedLoadHint, type New, NotFoundError, type NotWidened, type OnTransitionMatch, OneToManyCollection, OneToManyField, OneToManyFieldStatus, OneToManyLargeCollection, OneToOneField, type OneToOneReference, OneToOneReferenceImpl, OpColumn, Operator, type OptIdsOf, type OptsOf, type OrCondition, OrderBy, type OrderByDirection, type OrderByKeys, type OrderOf, ParsedCteClause, type ParsedCteSource, type ParsedEntityFilter, type ParsedExecuteQuery, type ParsedExpressionCondition, type ParsedExpressionFilter, ParsedFindQuery, ParsedGroupBy, ParsedOrderBy, type ParsedQuerySource, type ParsedReadQuery, ParsedSelect, type ParsedSelectQuery, type ParsedSetQuery, type ParsedSource, type ParsedSql, type ParsedSqlCondition, ParsedTable, type ParsedTableSource, type ParsedValueFilter, type PendingChange, type PendingCreate, type PendingDelete, type PendingM2M, type PendingUpdate, PlainDateSerde, PlainDateTimeSerde, PlainTimeSerde, Plugin, PojoRowData, type PolyAlias, PolyComponent, type PolyReference, PolymorphicField, PolymorphicFieldComponent, PolymorphicKeySerde, type PolymorphicReference, PolymorphicReferenceImpl, type PredicateBrand, type PreloadHydrator, type PreloadPlugin, PrimaryKeyField, PrimaryTable, type PrimitiveAlias, type PrimitiveColumn, PrimitiveField, PrimitiveFieldStatus, PrimitiveSerde, type Property, PropertyImpl, type Query, type QueryArg, type QueryCondition, type QueryExpressionClause, type QueryExpressionContext, type QueryJoin, type QueryJoinInput, type QueryJoinList, type QueryRow, type QuerySelect, type QuerySource, type QuerySql, type QueryTable, type QueryTableBrand, type QueryValue, RandomUuidAssigner, type RawCondition, type RawSql, type Reactable, type Reacted, ReactionLogger, type ReactiveField, type ReactiveGetter, type ReactiveHint, type ReactiveManyToMany, ReactiveManyToManyImpl, type ReactiveManyToManyOtherSide, ReactiveManyToManyOtherSideImpl, type ReactiveReference, ReactiveReferenceImpl, type ReactiveTarget, type ReadDrift, ReadDriftError, type ReadOnlyCollection, ReadOnlyError, RecursiveCycleError, type RecursiveOptions, type Reference, type ReferenceColumn, type ReferenceJoin, type Relation, type RelationsIn, type RelationsOf, type ResolvedJoins, ResolvedScope, type RootTypeNameOf, RowData, type RuntimeConfig, ScalarCodec, type ScalarQuery, Scope, ScopeFilterFragment, ScopeFn, ScopeJoinFilter, ScopeQuery, SequenceIdAssigner, SerdeField, type SetQuery, type SettableFields, SimpleFieldSerde, type SqlCondition, type ExpressionCondition$1 as SqlExpressionCondition, type SqlPart, type SqlPredicate, type StarSql, StubbedRelation, type Subquery, type SubqueryBrand, SubqueryRenderer, SuperstructSerde, type Table, type TableBrand, type TableFilter, type TableFor, type TableMgmt, type TableSourceBrand, type TableSourceMgmt, TaggedId, Temporal, TestUuidAssigner, TimestampCodec, TimestampFields, TimestampSerde, ToJsonHint, Todo, TooManyError, type TransitionTable, type TypeMap, type TypeMapEntry, type TypeNameOf, UniqueFilter, UnknownProperty, UpdateOp, type UpdateStatement, type UpdateValues, ValidationCode, type ValidationError, ValidationErrors, type ValidationRule, type ValidationRuleInternal, type ValidationRuleResult, ValueFilter, ValueGraphQLFilter, VectorSerde, type WithInput, type WithLoaded, type WithSource, WriteFn, ZodSerde, ZonedDateTimeSerde, abbreviation, addTablePerClassJoinsAndClassTag, alias, aliases, appendStack, asNew, assertIdIsTagged, assertIdsAreTagged, assertLoaded, assertNever, buildCteSql, buildRawQuery, buildUnnestCte, buildValueCondition, buildWhereClause, cannotBeChanged, cannotBeUpdated, cleanSql, cleanStringValue, columnSql, configureMetadata, convertToLoadHint, createRowFromEntityData, deTagId, deTagIds, declareTable, deepNormalizeHint, defaultValue, driverAfterBegin, driverAfterCommit, driverApi, driverBeforeBegin, driverBeforeCommit, emptyRowData, ensureLoaded, ensureRectangularArraySizes, ensureTagged, ensureWithLoaded, entityQueryBrand, expr, exprBrand, factories, fail, failIfAnyRejected, filterSoftDeletes, findFilterField, generateOps, getAliasMetadata, getAliasMgmt, getBaseAndSelfMetas, getBaseMeta, getBaseSelfAndSubMetas, getConstructorFromTaggedId, getDefaultEntityLimit, getEmInternalApi, getField, getInstanceData, getLazyFields, getLens, getLensPath, getMaybeCtiAlias, getMetadata, getMetadataForField, getMetadataForTable, getMetadataForType, getProperties, getRuntimeConfig, getSubMetas, getTableMetadata, getTableMgmt, getTables, getTestIndex, hasAsyncMethod, hasAsyncProperty, hasAsyncReactiveField, hasCustomCollection, hasCustomReference, hasEnumCollection, hasLargeMany, hasLargeManyToMany, hasLazyField, hasMany, hasManyDerived, hasManyThrough, hasManyToMany, hasOne, hasOneDerived, hasOnePolymorphic, hasOneThrough, hasOneToOne, hasProperty, hasReactiveAsyncMethod, hasReactiveField, hasReactiveGetter, hasReactiveManyToMany, hasReactiveManyToManyOtherSide, hasReactiveProperty, hasReactiveReference, hasRecursiveChildren, hasRecursiveM2m, hasRecursiveParents, hasSerde, hasVisibilityHook, indexBy, invokeRule, isAlias, isAllSqlPaths, isAsyncProperty, isAsyncReactiveField, isChangeableField, isCollection, isCollectionField, isDefined, isEntity, isFactoryCreation, isFieldSet, isId, isInTrustedContext, isKey, isLazyField, isLensLoaded, isLensLoadedPath, isLoaded, isLoadedAsyncProperty, isLoadedCollection, isLoadedLazyField, isLoadedOneToOneReference, isLoadedProperty, isLoadedReadOnlyCollection, isLoadedReference, isManyToManyEnumField, isManyToManyField, isManyToOneField, isManyToOneReference, isNew, isOneToManyField, isOneToOneField, isOneToOneReference, isPolymorphicField, isPolymorphicReference, isProperty, isReactiveField, isReactiveGetter, isReactiveManyToMany, isReactiveManyToManyOtherSide, isReactiveReference, isReadOnlyCollection, isReference, isReferenceField, isRelation, isScope, isScopeJoinFilter, isSelectAllFilter, isTable, isTaggedId, isTypeOrSubType, joinSql, keyToNumber, keyToTaggedId, kq, kqDot, kqStar, lazyExcludedSelects, lazyField, lensPathToLoadHint, lensToLoadHint, lensToPath, loadLens, loadLensPath, makeLike, mapPathsToTarget, mapToDb, maxValueRule, maybeAddIdNotNulls, maybeAddNotSoftDeleted, maybeAddOrderBy, maybeBranchValue, maybeGetConstructorFromReference, maybeNew, maybeNewPoly, maybePopulateThen, maybeRequireTemporal, maybeResolveReferenceToId, mergeFindOptions, minValueRule, mustBeSubType, newAliasProxy, newChangesProxy, newPgConnectionConfig, newRequiredLazyFieldRule, newRequiredRule, newScopeFn, newTableProxy, newTestInstance, noValue, noopFieldLogger, normalizeHint, nowUTC, opToFn, operators, optimizeCollectionJoins, parseAlias, parseEntityFilter, parseFindQuery, parseValueFilter, partition, plainDateMapper, plainDateTimeMapper, plainTimeMapper, polymorphicField, query, queryMaybe, rangeValueRule, recursiveQuery, requireTemporal, resetBootFlag, resetDefaultEntityLimit, resolveScope, reverseReactiveHint, runInTrustedContext, sameEntity, sameReference, setDefaultEntityLimit, setFactoryLogging, setFactoryWriter, setField, setLastNow, setReactionLogging, setRuntimeConfig, setTaggedIdDelimiter, skipCondition, sql, stiSubtypeFilter, subqueryBrand, table, tableMgmt, tables, tagFromId, tagId, tagIds, taggedIdPrefix, testIndex, toIdOf, toJSON, toTaggedId, unsafeDeTagIds, unsafeLoaded, updatePartial, upsert, visitConditions, visitQuery, visitQueryExpressions, visitSql, withLoaded, zeroTo, zonedDateTimeMapper };
182
184
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBA0Ba;;;;;qBACA;;;UA8RH,UAAU;EAClB,QAAQ;;YAGE,OAAO,GAAG,WAAW,IAAI,UAAU;;;;;;;;;;;;;;;wBAgB/B,QAAQ,UAAU,QAChC,QAAQ,GACR,QAAQ,QAAQ,OAAO,iBACvB;EAAS;EAAmB;;;;;;;;;wBAoBd,OAAO,UAAU,QAC/B,MAAM,eAAe,IACrB,QAAQ,GACR,aACA,aACA,mBACA;wBA+Dc,iBAAiB,QAAQ,QAAQ;;YAOrC,cAAc,QACvB,WAAW,KAAK,EAAE;wBAGL,gBAAgB,UAAU,QAAQ,QAAQ;wBAC1C,gBAAgB,UAAU,QAAQ,MAAM,kBAAkB;wBAO1D,aAAa,QAAQ,SAAS;wBAM9B,mBAAmB,QAAQ,kBAAkB;;wBAO7C,eAAe,UAAU,QAAQ,MAAM,+BAA+B,KAAK,kBAAkB;;;;;;;;qBAWhG,kBAAkB;;wBAGf,YAAY;;;;;;wBASZ,YAAY,UAAU,QAAQ,QAAQ,IAAI,UAAU,IAAI"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBA0Ba;;;;;qBACA;;;UAyTH,UAAU;EAClB,QAAQ;;YAGE,OAAO,GAAG,WAAW,IAAI,UAAU;;;;;;;;;;;;;;;wBAgB/B,QAAQ,UAAU,QAChC,QAAQ,GACR,QAAQ,QAAQ,OAAO,iBACvB;EAAS;EAAmB;;;;;;;;;wBAoBd,OAAO,UAAU,QAC/B,MAAM,eAAe,IACrB,QAAQ,GACR,aACA,aACA,mBACA;wBA+Dc,iBAAiB,QAAQ,QAAQ;;YAOrC,cAAc,QACvB,WAAW,KAAK,EAAE;wBAGL,gBAAgB,UAAU,QAAQ,QAAQ;wBAC1C,gBAAgB,UAAU,QAAQ,MAAM,kBAAkB;wBAO1D,aAAa,QAAQ,SAAS;wBAM9B,mBAAmB,QAAQ,kBAAkB;;wBAO7C,eAAe,UAAU,QAAQ,MAAM,+BAA+B,KAAK,kBAAkB;;;;;;;;qBAWhG,kBAAkB;;wBAGf,YAAY;;;;;;wBASZ,YAAY,UAAU,QAAQ,QAAQ,IAAI,UAAU,IAAI"}
package/build/index.js CHANGED
@@ -40,17 +40,17 @@ import { AliasAssigner } from "./queries/sql/AliasAssigner.js";
40
40
  import { alias, aliases, getAliasMetadata, getAliasMgmt, getMaybeCtiAlias, isAlias, newAliasProxy } from "./queries/find/Aliases.js";
41
41
  import { getTableMetadata, getTableMgmt, isTable, newTableProxy, table, tableMgmt, tables } from "./queries/sql/Tables.js";
42
42
  import { declareTable } from "./queries/sql/custom.js";
43
+ import { ConditionBuilder } from "./queries/ConditionBuilder.js";
44
+ import { mergeFindOptions } from "./queries/find/EntityFilter.js";
43
45
  import { OneToManyCollection, hasMany } from "./relations/OneToManyCollection.js";
44
46
  import { ManyToOneReferenceImpl, hasOne, isManyToOneReference } from "./relations/ManyToOneReference.js";
45
47
  import { OneToManyLargeCollection, hasLargeMany } from "./relations/OneToManyLargeCollection.js";
46
48
  import { ReactiveReferenceImpl, hasReactiveReference, isReactiveReference } from "./relations/ReactiveReference.js";
47
49
  import { OneToOneReferenceImpl, hasOneToOne, isLoadedOneToOneReference, isOneToOneReference } from "./relations/OneToOneReference.js";
48
50
  import { PolymorphicReferenceImpl, hasOnePolymorphic, isPolymorphicReference } from "./relations/PolymorphicReference.js";
49
- import { ConditionBuilder } from "./queries/ConditionBuilder.js";
51
+ import { opToFn, operators } from "./queries/find/EntityGraphQLFilter.js";
50
52
  import { ReactiveManyToManyImpl, hasReactiveManyToMany, isReactiveManyToMany } from "./relations/ReactiveManyToMany.js";
51
53
  import { ReactiveManyToManyOtherSideImpl, hasReactiveManyToManyOtherSide, isReactiveManyToManyOtherSide } from "./relations/ReactiveManyToManyOtherSide.js";
52
- import { mergeFindOptions } from "./queries/find/EntityFilter.js";
53
- import { opToFn, operators } from "./queries/find/EntityGraphQLFilter.js";
54
54
  import { ReadDriftError } from "./flush/ReadDrift.js";
55
55
  import { EntityMetrics } from "./metrics/EntityMetrics.js";
56
56
  import { exprBrand } from "./queries/sql/Expr.js";
@@ -59,6 +59,8 @@ import { skipCondition } from "./queries/skipCondition.js";
59
59
  import { InstanceData } from "./InstanceData.js";
60
60
  import { JoinRowOperation } from "./flush/JoinRows.js";
61
61
  import { Plugin } from "./PluginManager.js";
62
+ import { columnSql, joinSql, visitSql } from "./queries/sql/ParsedSqlExpression.js";
63
+ import { visitQuery, visitQueryExpressions } from "./queries/sql/ParsedQuery.js";
62
64
  import { addTablePerClassJoinsAndClassTag, findFilterField, getTables, maybeAddIdNotNulls, maybeAddOrderBy, parseAlias, parseFindQuery } from "./queries/find/QueryParser.js";
63
65
  import { buildCteSql, buildRawQuery } from "./queries/find/buildFindQuery.js";
64
66
  import { makeLike, mapToDb, parseEntityFilter, parseValueFilter } from "./queries/valueFilters.js";
@@ -200,6 +202,6 @@ function failNoIdYet(entity) {
200
202
  function isNewEntity(entity) {
201
203
  return entity.isNewEntity;
202
204
  }
203
- export { AliasAssigner, AsyncPropertyImpl, BaseEntity, BigIntSerde, Column, ConditionBuilder, ConfigApi, CustomCollection, CustomReference, CustomSerdeAdapter, DateSerde, DecimalToNumberSerde, EntityManager, EntityMetrics, EnumArrayFieldSerde, EnumCollectionImpl, EnumFieldSerde, FailedFlushError, FieldColumn, FieldLogger, ImmutableEntitiesPlugin, InstanceData, JoinRowOperation, JsonAggregatePreloader, JsonSerde, KeySerde, LazyFieldImpl, ManyToManyCollection, ManyToManyLargeCollection, ManyToOneReferenceImpl, NoIdError, NotFoundError, OneToManyCollection, OneToManyLargeCollection, OneToOneReferenceImpl, PlainDateSerde, PlainDateTimeSerde, PlainTimeSerde, Plugin, PojoRowData, PolyComponent, PolymorphicKeySerde, PolymorphicReferenceImpl, PrimitiveSerde, PropertyImpl, RandomUuidAssigner, ReactionLogger, ReactiveManyToManyImpl, ReactiveManyToManyOtherSideImpl, ReactiveReferenceImpl, ReadDriftError, ReadOnlyError, RecursiveCycleError, SequenceIdAssigner, SimpleFieldSerde, StubbedRelation, SuperstructSerde, Temporal, TestUuidAssigner, Todo, TooManyError, UnknownProperty, ValidationCode, ValidationErrors, VectorSerde, ZodSerde, ZonedDateTimeSerde, abbreviation, addTablePerClassJoinsAndClassTag, alias, aliases, appendStack, asConcreteCstr, asNew, assertIdIsTagged, assertIdsAreTagged, assertLoaded, assertNever, buildCteSql, buildRawQuery, buildUnnestCte, buildValueCondition, buildWhereClause, cannotBeChanged, cannotBeUpdated, cleanSql, cleanStringValue, configureMetadata, convertToLoadHint, createRowFromEntityData, deTagId, deTagIds, declareTable, deepNormalizeHint, defaultValue, driverAfterBegin, driverAfterCommit, driverApi, driverBeforeBegin, driverBeforeCommit, emptyRowData, ensureLoaded, ensureNotDeleted, ensureRectangularArraySizes, ensureTagged, ensureWithLoaded, entityQueryBrand, expr, exprBrand, factories, fail, failIfAnyRejected, failNoIdYet, filterSoftDeletes, findFilterField, generateOps, getAliasMetadata, getAliasMgmt, getBaseAndSelfMetas, getBaseMeta, getBaseSelfAndSubMetas, getConstructorFromTaggedId, getDefaultEntityLimit, getEmInternalApi, getField, getInstanceData, getLazyFields, getLens, getLensPath, getMaybeCtiAlias, getMetadata, getMetadataForField, getMetadataForTable, getMetadataForType, getProperties, getRelationEntries, getRelations, getRequiredKeys, getRuntimeConfig, getSubMetas, getTableMetadata, getTableMgmt, getTables, getTestIndex, hasAsyncMethod, hasAsyncProperty, hasAsyncReactiveField, hasCustomCollection, hasCustomReference, hasEnumCollection, hasLargeMany, hasLargeManyToMany, hasLazyField, hasMany, hasManyDerived, hasManyThrough, hasManyToMany, hasOne, hasOneDerived, hasOnePolymorphic, hasOneThrough, hasOneToOne, hasProperty, hasReactiveAsyncMethod, hasReactiveField, hasReactiveGetter, hasReactiveManyToMany, hasReactiveManyToManyOtherSide, hasReactiveProperty, hasReactiveReference, hasRecursiveChildren, hasRecursiveM2m, hasRecursiveParents, hasSerde, hasVisibilityHook, indexBy, internals, invokeRule, isAlias, isAllSqlPaths, isAsyncProperty, isAsyncReactiveField, isChangeableField, isCollection, isCollectionField, isDefined, isEntity, isFactoryCreation, isFieldSet, isId, isInTrustedContext, isKey, isLazyField, isLensLoaded, isLensLoadedPath, isLoaded, isLoadedAsyncProperty, isLoadedCollection, isLoadedLazyField, isLoadedOneToOneReference, isLoadedProperty, isLoadedReadOnlyCollection, isLoadedReference, isManyToManyEnumField, isManyToManyField, isManyToOneField, isManyToOneReference, isNew, isNewEntity, isOneToManyField, isOneToOneField, isOneToOneReference, isPolymorphicField, isPolymorphicReference, isProperty, isReactiveField, isReactiveGetter, isReactiveManyToMany, isReactiveManyToManyOtherSide, isReactiveReference, isReadOnlyCollection, isReference, isReferenceField, isRelation, isScope, isScopeJoinFilter, isSelectAllFilter, isTable, isTaggedId, isTypeOrSubType, keyToNumber, keyToTaggedId, kq, kqDot, kqStar, lazyExcludedSelects, lazyField, lensPathToLoadHint, lensToLoadHint, lensToPath, loadLens, loadLensPath, makeLike, mapPathsToTarget, mapToDb, maxValueRule, maybeAddIdNotNulls, maybeAddNotSoftDeleted, maybeAddOrderBy, maybeBranchValue, maybeGetConstructorFromReference, maybeNew, maybeNewPoly, maybePopulateThen, maybeRequireTemporal, maybeResolveReferenceToId, mergeFindOptions, minValueRule, mustBeSubType, newAliasProxy, newChangesProxy, newPgConnectionConfig, newRequiredLazyFieldRule, newRequiredRule, newScopeFn, newTableProxy, newTestInstance, noValue, noopFieldLogger, normalizeHint, nowUTC, opToFn, operators, optimizeCollectionJoins, parseAlias, parseEntityFilter, parseFindQuery, parseValueFilter, partition, plainDateMapper, plainDateTimeMapper, plainTimeMapper, polymorphicField, query, queryMaybe, rangeValueRule, recursiveQuery, requireTemporal, resetBootFlag, resetDefaultEntityLimit, resolveScope, reverseReactiveHint, runInTrustedContext, sameEntity, sameReference, setDefaultEntityLimit, setFactoryLogging, setFactoryWriter, setField, setLastNow, setOpt, setOpts, setReactionLogging, setRuntimeConfig, setTaggedIdDelimiter, skipCondition, sql, stiSubtypeFilter, subqueryBrand, table, tableMgmt, tables, tagFromId, tagId, tagIds, taggedIdPrefix, testIndex, testing, toIdOf, toJSON, toTaggedId, unsafeDeTagIds, unsafeLoaded, updatePartial, upsert, visitConditions, withLoaded, zeroTo, zonedDateTimeMapper };
205
+ export { AliasAssigner, AsyncPropertyImpl, BaseEntity, BigIntSerde, Column, ConditionBuilder, ConfigApi, CustomCollection, CustomReference, CustomSerdeAdapter, DateSerde, DecimalToNumberSerde, EntityManager, EntityMetrics, EnumArrayFieldSerde, EnumCollectionImpl, EnumFieldSerde, FailedFlushError, FieldColumn, FieldLogger, ImmutableEntitiesPlugin, InstanceData, JoinRowOperation, JsonAggregatePreloader, JsonSerde, KeySerde, LazyFieldImpl, ManyToManyCollection, ManyToManyLargeCollection, ManyToOneReferenceImpl, NoIdError, NotFoundError, OneToManyCollection, OneToManyLargeCollection, OneToOneReferenceImpl, PlainDateSerde, PlainDateTimeSerde, PlainTimeSerde, Plugin, PojoRowData, PolyComponent, PolymorphicKeySerde, PolymorphicReferenceImpl, PrimitiveSerde, PropertyImpl, RandomUuidAssigner, ReactionLogger, ReactiveManyToManyImpl, ReactiveManyToManyOtherSideImpl, ReactiveReferenceImpl, ReadDriftError, ReadOnlyError, RecursiveCycleError, SequenceIdAssigner, SimpleFieldSerde, StubbedRelation, SuperstructSerde, Temporal, TestUuidAssigner, Todo, TooManyError, UnknownProperty, ValidationCode, ValidationErrors, VectorSerde, ZodSerde, ZonedDateTimeSerde, abbreviation, addTablePerClassJoinsAndClassTag, alias, aliases, appendStack, asConcreteCstr, asNew, assertIdIsTagged, assertIdsAreTagged, assertLoaded, assertNever, buildCteSql, buildRawQuery, buildUnnestCte, buildValueCondition, buildWhereClause, cannotBeChanged, cannotBeUpdated, cleanSql, cleanStringValue, columnSql, configureMetadata, convertToLoadHint, createRowFromEntityData, deTagId, deTagIds, declareTable, deepNormalizeHint, defaultValue, driverAfterBegin, driverAfterCommit, driverApi, driverBeforeBegin, driverBeforeCommit, emptyRowData, ensureLoaded, ensureNotDeleted, ensureRectangularArraySizes, ensureTagged, ensureWithLoaded, entityQueryBrand, expr, exprBrand, factories, fail, failIfAnyRejected, failNoIdYet, filterSoftDeletes, findFilterField, generateOps, getAliasMetadata, getAliasMgmt, getBaseAndSelfMetas, getBaseMeta, getBaseSelfAndSubMetas, getConstructorFromTaggedId, getDefaultEntityLimit, getEmInternalApi, getField, getInstanceData, getLazyFields, getLens, getLensPath, getMaybeCtiAlias, getMetadata, getMetadataForField, getMetadataForTable, getMetadataForType, getProperties, getRelationEntries, getRelations, getRequiredKeys, getRuntimeConfig, getSubMetas, getTableMetadata, getTableMgmt, getTables, getTestIndex, hasAsyncMethod, hasAsyncProperty, hasAsyncReactiveField, hasCustomCollection, hasCustomReference, hasEnumCollection, hasLargeMany, hasLargeManyToMany, hasLazyField, hasMany, hasManyDerived, hasManyThrough, hasManyToMany, hasOne, hasOneDerived, hasOnePolymorphic, hasOneThrough, hasOneToOne, hasProperty, hasReactiveAsyncMethod, hasReactiveField, hasReactiveGetter, hasReactiveManyToMany, hasReactiveManyToManyOtherSide, hasReactiveProperty, hasReactiveReference, hasRecursiveChildren, hasRecursiveM2m, hasRecursiveParents, hasSerde, hasVisibilityHook, indexBy, internals, invokeRule, isAlias, isAllSqlPaths, isAsyncProperty, isAsyncReactiveField, isChangeableField, isCollection, isCollectionField, isDefined, isEntity, isFactoryCreation, isFieldSet, isId, isInTrustedContext, isKey, isLazyField, isLensLoaded, isLensLoadedPath, isLoaded, isLoadedAsyncProperty, isLoadedCollection, isLoadedLazyField, isLoadedOneToOneReference, isLoadedProperty, isLoadedReadOnlyCollection, isLoadedReference, isManyToManyEnumField, isManyToManyField, isManyToOneField, isManyToOneReference, isNew, isNewEntity, isOneToManyField, isOneToOneField, isOneToOneReference, isPolymorphicField, isPolymorphicReference, isProperty, isReactiveField, isReactiveGetter, isReactiveManyToMany, isReactiveManyToManyOtherSide, isReactiveReference, isReadOnlyCollection, isReference, isReferenceField, isRelation, isScope, isScopeJoinFilter, isSelectAllFilter, isTable, isTaggedId, isTypeOrSubType, joinSql, keyToNumber, keyToTaggedId, kq, kqDot, kqStar, lazyExcludedSelects, lazyField, lensPathToLoadHint, lensToLoadHint, lensToPath, loadLens, loadLensPath, makeLike, mapPathsToTarget, mapToDb, maxValueRule, maybeAddIdNotNulls, maybeAddNotSoftDeleted, maybeAddOrderBy, maybeBranchValue, maybeGetConstructorFromReference, maybeNew, maybeNewPoly, maybePopulateThen, maybeRequireTemporal, maybeResolveReferenceToId, mergeFindOptions, minValueRule, mustBeSubType, newAliasProxy, newChangesProxy, newPgConnectionConfig, newRequiredLazyFieldRule, newRequiredRule, newScopeFn, newTableProxy, newTestInstance, noValue, noopFieldLogger, normalizeHint, nowUTC, opToFn, operators, optimizeCollectionJoins, parseAlias, parseEntityFilter, parseFindQuery, parseValueFilter, partition, plainDateMapper, plainDateTimeMapper, plainTimeMapper, polymorphicField, query, queryMaybe, rangeValueRule, recursiveQuery, requireTemporal, resetBootFlag, resetDefaultEntityLimit, resolveScope, reverseReactiveHint, runInTrustedContext, sameEntity, sameReference, setDefaultEntityLimit, setFactoryLogging, setFactoryWriter, setField, setLastNow, setOpt, setOpts, setReactionLogging, setRuntimeConfig, setTaggedIdDelimiter, skipCondition, sql, stiSubtypeFilter, subqueryBrand, table, tableMgmt, tables, tagFromId, tagId, tagIds, taggedIdPrefix, testIndex, testing, toIdOf, toJSON, toTaggedId, unsafeDeTagIds, unsafeLoaded, updatePartial, upsert, visitConditions, visitQuery, visitQueryExpressions, visitSql, withLoaded, zeroTo, zonedDateTimeMapper };
204
206
 
205
207
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { getInstanceData } from \"src/BaseEntity.ts\";\nimport { getDefaultDependencies } from \"src/defaults.ts\";\nimport { type Entity } from \"src/Entity.ts\";\nimport { type EntityConstructor, type MaybeAbstractEntityConstructor, getEmInternalApi } from \"src/EntityManager.ts\";\nimport { type EntityMetadata, getBaseMeta, getMetadata } from \"src/EntityMetadata.ts\";\nimport { getField, setField } from \"src/fields.ts\";\nimport { getProperties } from \"src/getProperties.ts\";\nimport type { New } from \"src/loading/loadHints.ts\";\nimport { isAllSqlPaths } from \"src/loading/loadLens.ts\";\nimport { FactoryInitialValue } from \"src/newTestInstance.ts\";\nimport { partitionHint } from \"src/preloading/partitionHint.ts\";\nimport { buildWhereClause } from \"src/queries/renderConditions.ts\";\nimport { AbstractRelationImpl } from \"src/relations/AbstractRelationImpl.ts\";\nimport { AsyncReactiveFieldImpl } from \"src/relations/AsyncReactiveField.ts\";\nimport {\n isAsyncProperty,\n isAsyncReactiveField,\n isLazyField,\n isProperty,\n isReactiveField,\n isReactiveGetter,\n} from \"src/relations/index.ts\";\nimport { ReactiveFieldImpl } from \"src/relations/ReactiveField.ts\";\nimport { type OptsOf } from \"src/typeMap.ts\";\nimport { fail } from \"src/utils.ts\";\n\nexport const testing = { isAllSqlPaths, getDefaultDependencies, partitionHint };\nexport const internals = { buildWhereClause };\nexport { newPgConnectionConfig } from \"joist-utils\";\nexport { AliasAssigner } from \"src/queries/sql/AliasAssigner.ts\";\nexport type { JoinTree } from \"src/queries/sql/JoinTree.ts\";\nexport {\n type AndCondition,\n type ConditionGroup,\n type DomainPredicate,\n type OrCondition,\n type PredicateBrand,\n type SqlCondition,\n type SqlPredicate,\n} from \"src/queries/conditions.ts\";\n// Domain aliases belong to em.find; physical table expressions belong to em.query/em.execute.\nexport {\n alias,\n aliases,\n getAliasMetadata,\n getAliasMgmt,\n getMaybeCtiAlias,\n isAlias,\n newAliasProxy,\n type Alias,\n type AliasBrand,\n type AliasMgmt,\n type AliasColumn,\n type EntityAlias,\n type PolyAlias,\n type PrimitiveAlias,\n} from \"src/queries/find/Aliases.ts\";\nexport {\n table,\n tables,\n tableMgmt,\n getTableMetadata,\n getTableMgmt,\n isTable,\n newTableProxy,\n type Table,\n type TableFilter,\n type TableBrand,\n type TableSourceBrand,\n type TableFor,\n type TableMgmt,\n type TableSourceMgmt,\n type ReferenceJoin,\n type PrimitiveColumn,\n type EntityColumn,\n type ReferenceColumn,\n type CollectionJoin,\n type PolyReference,\n} from \"src/queries/sql/Tables.ts\";\nexport {\n declareTable,\n type CustomColumnConfig,\n type CustomColumnInput,\n type CustomColumnInputs,\n type CustomColumnType,\n type CustomTable,\n type CustomTableDefinition,\n type CustomTableFor,\n} from \"src/queries/sql/custom.ts\";\nexport { BaseEntity, getInstanceData } from \"src/BaseEntity.ts\";\nexport { ConditionBuilder } from \"src/queries/ConditionBuilder.ts\";\nexport { type Entity, type IdType, isEntity } from \"src/Entity.ts\";\nexport type * from \"src/EntityFields.ts\";\nexport * from \"src/queries/find/EntityFilter.ts\";\nexport * from \"src/queries/find/EntityGraphQLFilter.ts\";\nexport * from \"src/EntityManager.ts\";\nexport { ReadDriftError, type ReadDrift } from \"src/flush/ReadDrift.ts\";\nexport { EntityMetrics, type EntityMetricsSnapshot, type EvaluationStats } from \"src/metrics/EntityMetrics.ts\";\nexport * from \"src/EntityMetadata.ts\";\nexport type {\n DeleteStatement,\n ExecuteResult,\n InsertStatement,\n InsertValues,\n MutationReturning,\n MutationStatement,\n UpdateStatement,\n UpdateValues,\n} from \"src/queries/sql/execute.ts\";\nexport type { EnumMetadata } from \"src/EnumMetadata.ts\";\n// `em.query`'s expression surface. Only the user-facing types are re-exported: the runtime half\n// (BaseExpr, asNode, deferredCondition, the FnExpr/TemplateExpr node classes) stays internal to\n// joist-core, so `toSql`/`decode`/`encode` never show up as something a user could call.\nexport {\n type ArrayAggOptions,\n type Expr,\n type ExprBrand,\n exprBrand,\n type ExprLike,\n type InnerJoin,\n type LeftJoin,\n} from \"src/queries/sql/Expr.ts\";\nexport {\n expr,\n type CaseElse,\n type CaseWhen,\n type ExprFromInput,\n type ExprInput,\n} from \"src/queries/sql/expressions/expression.ts\";\nexport { skipCondition } from \"src/queries/skipCondition.ts\";\nexport type { EntityOrId, HintNode } from \"src/loading/HintTree.ts\";\nexport { InstanceData } from \"src/InstanceData.ts\";\nexport { type JoinColumnValue, type JoinRow, JoinRowOperation, type ManyToManyLike } from \"src/flush/JoinRows.ts\";\nexport type * from \"src/flush/PendingChanges.ts\";\nexport { Plugin } from \"src/PluginManager.ts\";\nexport * from \"src/queries/find/QueryParser.ts\";\nexport * from \"src/queries/find/buildFindQuery.ts\";\nexport * from \"src/queries/renderConditions.ts\";\nexport type {\n ColumnCondition,\n ExistsCondition,\n ParsedExpressionCondition,\n ParsedExpressionFilter,\n ParsedValueFilter,\n RawCondition,\n} from \"src/queries/parsedConditions.ts\";\nexport {\n type ParsedEntityFilter,\n makeLike,\n mapToDb,\n parseEntityFilter,\n parseValueFilter,\n} from \"src/queries/valueFilters.ts\";\nexport {\n filterSoftDeletes,\n lazyExcludedSelects,\n maybeAddNotSoftDeleted,\n stiSubtypeFilter,\n} from \"src/queries/entityQueryUtils.ts\";\nexport * from \"src/queries/find/QueryParser.collectionJoins.ts\";\nexport { visitConditions } from \"src/queries/find/QueryVisitor.ts\";\nexport * from \"src/RowData.ts\";\nexport { type JoinRowTodo, Todo } from \"src/flush/Todo.ts\";\nexport * from \"src/changes.ts\";\nexport { ConfigApi, type EntityHook, resetBootFlag } from \"src/config.ts\";\nexport { type GuardTransitionMatch, type OnTransitionMatch, type TransitionTable } from \"src/transitions.ts\";\nexport {\n configureMetadata,\n getConstructorFromTaggedId,\n getMetadataForTable,\n getMetadataForType,\n maybeGetConstructorFromReference,\n} from \"src/configure.ts\";\nexport { driverApi } from \"src/drivers/driverApi.ts\";\nexport * from \"src/drivers/index.ts\";\nexport { getField, isChangeableField, isFieldSet, setField } from \"src/fields.ts\";\nexport * from \"src/getProperties.ts\";\nexport * from \"src/json.ts\";\nexport * from \"src/keys.ts\";\nexport { kq, kqDot, kqStar } from \"src/queries/sql/keywords.ts\";\nexport {\n assertLoaded,\n type DeepNew,\n ensureLoaded,\n isLoaded,\n isNew,\n type Loadable,\n type Loaded,\n type LoadHint,\n type MarkLoaded,\n maybePopulateThen,\n type NestedLoadHint,\n type New,\n type RelationsIn,\n unsafeLoaded,\n} from \"src/loading/loadHints.ts\";\nexport * from \"src/loading/loadLens.ts\";\nexport { setFactoryWriter } from \"src/logging/FactoryLogger.ts\";\nexport * from \"src/logging/FieldLogger.ts\";\nexport { ReactionLogger, setReactionLogging } from \"src/logging/ReactionLogger.ts\";\nexport { lazyField } from \"src/newEntity.ts\";\nexport {\n defaultValue,\n factories,\n type FactoryEntityOpt,\n type FactoryOpts,\n getTestIndex,\n isFactoryCreation,\n maybeBranchValue,\n maybeNew,\n maybeNewPoly,\n newTestInstance,\n noValue,\n setFactoryLogging,\n testIndex,\n} from \"src/newTestInstance.ts\";\nexport { deepNormalizeHint, normalizeHint } from \"src/normalizeHints.ts\";\nexport { ImmutableEntitiesPlugin } from \"src/plugins/ImmutableEntitiesPlugin.ts\";\nexport type { JoinResult, PreloadHydrator, PreloadPlugin } from \"src/plugins/PreloadPlugin.ts\";\nexport { JsonAggregatePreloader } from \"src/preloading/JsonAggregatePreloader.ts\";\n// `em.query`'s query surface; the parse pipeline (SubqueryHandle, parseRootQuery, Plan) stays internal\nexport {\n type CheckScope,\n type Clauses,\n type EntityQuery,\n type ExpressionOrderBy,\n type ExistsQuery,\n entityQueryBrand,\n type MaybeNull,\n type NameOf,\n type NotWidened,\n type OrderByDirection,\n type OrderByKeys,\n type Query,\n type QueryArg,\n type QueryCondition,\n type QueryJoin,\n type QueryJoinInput,\n type QueryJoinList,\n type QueryRow,\n type QuerySelect,\n type QuerySource,\n type QueryValue,\n recursiveQuery,\n type RecursiveOptions,\n type ResolvedJoins,\n type ScalarQuery,\n type SetQuery,\n query,\n queryMaybe,\n sql,\n type QueryTable,\n type QueryTableBrand,\n type Subquery,\n type SubqueryBrand,\n subqueryBrand,\n type WithInput,\n type WithSource,\n} from \"src/queries/sql/query.ts\";\nexport {\n convertToLoadHint,\n isTypeOrSubType,\n type Reactable,\n type Reacted,\n type ReactiveHint,\n type ReactiveTarget,\n reverseReactiveHint,\n} from \"src/reactivity/reactiveHints.ts\";\nexport * from \"src/relations/index.ts\";\nexport {\n cannotBeChanged,\n cannotBeUpdated,\n type GenericError,\n maxValueRule,\n minValueRule,\n mustBeSubType,\n newRequiredLazyFieldRule,\n newRequiredRule,\n rangeValueRule,\n ValidationCode,\n type ValidationError,\n ValidationErrors,\n type ValidationRule,\n type ValidationRuleInternal,\n type ValidationRuleResult,\n} from \"src/rules.ts\";\nexport { getRuntimeConfig, setRuntimeConfig, type RuntimeConfig } from \"src/runtimeConfig.ts\";\nexport { nowUTC } from \"src/nowUTC.ts\";\nexport * from \"src/serde/serde.ts\";\nexport * from \"src/serde/columns.ts\";\nexport * from \"src/serde/fieldSerde.ts\";\nexport * from \"src/queries/find/scopes.ts\";\nexport { maybeRequireTemporal, requireTemporal, Temporal } from \"src/serde/temporal.ts\";\nexport * from \"src/serde/temporalMappers.ts\";\nexport { isInTrustedContext, runInTrustedContext } from \"src/trusted.ts\";\nexport type * from \"src/typeMap.ts\";\nexport { buildUnnestCte, ensureRectangularArraySizes } from \"src/queries/unnest.ts\";\nexport { type DeepPartialOrNull, updatePartial, upsert } from \"src/upsert.ts\";\nexport {\n abbreviation,\n asNew,\n assertNever,\n cleanSql,\n cleanStringValue,\n fail,\n failIfAnyRejected,\n indexBy,\n partition,\n zeroTo,\n} from \"src/utils.ts\";\nexport { ensureWithLoaded, StubbedRelation, type WithLoaded, withLoaded } from \"src/loading/withLoaded.ts\";\n\n// https://spin.atomicobject.com/2018/01/15/typescript-flexible-nominal-typing/\ninterface Flavoring<FlavorT> {\n _type?: FlavorT;\n}\n\nexport type Flavor<T, FlavorT> = T & Flavoring<FlavorT>;\n\n/**\n * Sets each value in `values` on the current entity.\n *\n * The default behavior is that passing a value as either `null` or `undefined` will set\n * the field as `undefined`, i.e. automatic `null` to `undefined` conversion.\n *\n * However, if you pass `ignoreUndefined: true`, then any opt that is `undefined` will be treated\n * as \"do not set\", and `null` will still mean \"set to `undefined`\". This is useful for implementing\n * APIs were an input of `undefined` means \"do not set / noop\" and `null` means \"unset\".\n *\n * Note that constructors _always_ call this method, but if the call is coming from `em.hydrate`, we\n * use `values` being a primary key to short-circuit and let hydration callers assign the values\n * returned by the serde `fromRow` methods.\n */\nexport function setOpts<T extends Entity>(\n entity: T,\n values: Partial<OptsOf<T>> | undefined,\n opts?: { partial?: boolean; calledFromConstructor?: boolean },\n): void {\n const { calledFromConstructor = false, partial } = opts || {};\n // If `values` is undefined, we're being called by `createPartial` that will do its\n // own opt handling, but we still want the sync defaults applied after this opts handling.\n if (values !== undefined) {\n const meta = getMetadata(entity);\n for (const [key, _value] of Object.entries(values as {})) {\n setOpt(meta, entity, key, _value, partial, calledFromConstructor);\n }\n }\n}\n\n/**\n * Applies some standard behavior & protections to `entity[key] = value`. I.e.\n *\n * - We don't set over AsyncProperties/relations/etc., and instead call current.set(value)\n * - We catch missing/invalid field names\n * - We handle FactoryInitialValues\n */\nexport function setOpt<T extends Entity>(\n meta: EntityMetadata<T>,\n entity: T,\n key: string,\n _value: any,\n partial = false,\n calledFromConstructor = false,\n): void {\n const field = meta.allFields[key];\n if (!field) {\n // Allow setting non-field properties like fullName setters\n const prop = getProperties(meta)[key];\n if (!prop) {\n throw new Error(`Unknown field ${key}`);\n }\n }\n\n // If partial is set, we treat undefined as a noop\n if (partial && _value === undefined) return;\n // Ignore the STI discriminator, em.register will set this accordingly\n if (meta.inheritanceType === \"sti\" && getBaseMeta(meta).stiDiscriminatorField === key) return;\n\n // We let optional opts fields be `| null` for convenience, and convert to undefined.\n const value = _value === null ? undefined : _value;\n\n // Use `getField` to side-step `id` blowing up on new entities that are setting an\n // explicit id. Read configured fields as internal so applying opts does not mark the entity for read locking.\n // Otherwise use `entity[key]` to get back the relation.\n const current = key === \"id\" || field?.assertUnchanged ? getField(entity, key, true) : (entity as any)[key];\n\n if (current instanceof AbstractRelationImpl) {\n if (calledFromConstructor) {\n current.setFromOpts(value);\n } else {\n current.set(value);\n }\n } else if (isLazyField(current)) {\n current.set(value);\n } else if (isProperty(current) || isAsyncProperty(current) || isReactiveGetter(current)) {\n throw new Error(`Invalid argument, cannot set over ${key} ${current.constructor.name}`);\n } else if (isReactiveField(current) || isAsyncReactiveField(current)) {\n if (value instanceof FactoryInitialValue) {\n if (current instanceof ReactiveFieldImpl) {\n current.setFactoryValue(value.value);\n } else if (current instanceof AsyncReactiveFieldImpl) {\n current.setFactoryValue(value.value);\n } else {\n throw new Error(`Unhandled case ${current.constructor.name}`);\n }\n } else {\n throw new Error(`Invalid argument, cannot set over ${key} ${current.constructor.name}`);\n }\n } else if (value instanceof FactoryInitialValue) {\n // A factory's `withStatus`-style opt: trust the created value, so its `addTransitionReaction`s don't fire\n (entity as any)[key] = value.value;\n getEmInternalApi(entity.em).rm.forgetCreationTransition(entity, key);\n } else {\n // If setting an explicit id, go through setField, otherwise use\n // `entity[key]` to set the value directly to that we go through setters.\n if (key === \"id\" && entity.isNewEntity) {\n // Reject ID changes even before insertion: they would invalidate identity-map entries and cached ID conversions.\n if (current !== undefined && current !== value) fail(`Cannot change assigned id of ${meta.type}`);\n setField(entity, key, value);\n } else {\n (entity as any)[key] = value;\n }\n }\n}\n\nexport function ensureNotDeleted(entity: Entity, ignore?: \"pending\"): void {\n if (entity.isDeletedEntity && (ignore === undefined || getInstanceData(entity).isDeletedAndFlushed)) {\n fail(`${entity} is marked as deleted`);\n }\n}\n\n/** Adds `null` to every key in `T` to accept partial-update-style input. */\nexport type PartialOrNull<T> = {\n [P in keyof T]?: T[P] | null;\n};\n\nexport function getRequiredKeys<T extends Entity>(entity: T): string[];\nexport function getRequiredKeys<T extends Entity>(type: EntityConstructor<T>): string[];\nexport function getRequiredKeys<T extends Entity>(entityOrType: T | EntityConstructor<T>): string[] {\n return Object.values(getMetadata(entityOrType as any).fields)\n .filter((f) => f.required)\n .map((f) => f.fieldName);\n}\n\nexport function getRelations(entity: Entity): AbstractRelationImpl<any, any>[] {\n return Object.entries(getProperties(getMetadata(entity)))\n .filter(([, v]) => v instanceof AbstractRelationImpl)\n .map(([name]) => (entity as any)[name]);\n}\n\nexport function getRelationEntries(entity: Entity): [string, AbstractRelationImpl<any, any>][] {\n return Object.entries(getProperties(getMetadata(entity)))\n .filter(([, v]) => v instanceof AbstractRelationImpl)\n .map(([name]) => [name, (entity as any)[name]]);\n}\n\n/** Casts a \"maybe abstract\" cstr to a concrete cstr when the calling code knows it's safe. */\nexport function asConcreteCstr<T extends Entity>(cstr: MaybeAbstractEntityConstructor<T>): EntityConstructor<T> {\n return cstr as any;\n}\n\n/**\n * Thrown when `.id` is accessed on an entity that does not have an id yet.\n *\n * For Postgres, entities are actually allowed to have ids pre-INSERT, if you call\n * `em.assignNewIds()`. Other databases typically require INSERTs to trigger the auto\n * id assignment.\n */\nexport class NoIdError extends Error {}\n\n/** Throws a `NoIdError` for `entity`, i.e. because `id` was called before being saved. */\nexport function failNoIdYet(entity: string): never {\n throw new NoIdError(`${entity} has no id yet`);\n}\n\n/**\n * Add a static function since getters can't have type guards.\n *\n * See https://github.com/microsoft/TypeScript/issues/43368\n */\nexport function isNewEntity<T extends Entity>(entity: T): entity is New<T> {\n return entity.isNewEntity;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,UAAU;CAAE;CAAe;CAAwB;AAAc;AAC9E,MAAa,YAAY,EAAE,iBAAiB;;;;;;;;;;;;;;;AAkT5C,SAAgB,QACd,QACA,QACA,MACM;CACN,MAAM,EAAE,wBAAwB,OAAO,YAAY,QAAQ,CAAC;CAG5D,IAAI,WAAW,KAAA,GAAW;EACxB,MAAM,OAAO,YAAY,MAAM;EAC/B,KAAK,MAAM,CAAC,KAAK,WAAW,OAAO,QAAQ,MAAY,GACrD,OAAO,MAAM,QAAQ,KAAK,QAAQ,SAAS,qBAAqB;CAEpE;AACF;;;;;;;;AASA,SAAgB,OACd,MACA,QACA,KACA,QACA,UAAU,OACV,wBAAwB,OAClB;CACN,MAAM,QAAQ,KAAK,UAAU;CAC7B,IAAI,CAAC,OAGC;MAAA,CADS,cAAc,IAAI,CAAC,CAAC,MAE/B,MAAM,IAAI,MAAM,iBAAiB,KAAK;CAAA;CAK1C,IAAI,WAAW,WAAW,KAAA,GAAW;CAErC,IAAI,KAAK,oBAAoB,SAAS,YAAY,IAAI,CAAC,CAAC,0BAA0B,KAAK;CAGvF,MAAM,QAAQ,WAAW,OAAO,KAAA,IAAY;CAK5C,MAAM,UAAU,QAAQ,QAAQ,OAAO,kBAAkB,SAAS,QAAQ,KAAK,IAAI,IAAK,OAAe;CAEvG,IAAI,mBAAmB,sBAAsB;EAC3C,IAAI,uBACF,QAAQ,YAAY,KAAK;OAEzB,QAAQ,IAAI,KAAK;CAErB,OAAO,IAAI,YAAY,OAAO,GAC5B,QAAQ,IAAI,KAAK;MACZ,IAAI,WAAW,OAAO,KAAK,gBAAgB,OAAO,KAAK,iBAAiB,OAAO,GACpF,MAAM,IAAI,MAAM,qCAAqC,IAAI,GAAG,QAAQ,YAAY,MAAM;MACjF,IAAI,gBAAgB,OAAO,KAAK,qBAAqB,OAAO,GAAG;EACpE,IAAI,iBAAiB,qBAAqB;GACxC,IAAI,mBAAmB,mBACrB,QAAQ,gBAAgB,MAAM,KAAK;QAC9B,IAAI,mBAAmB,wBAC5B,QAAQ,gBAAgB,MAAM,KAAK;QAEnC,MAAM,IAAI,MAAM,kBAAkB,QAAQ,YAAY,MAAM;EAEhE,OACE,MAAM,IAAI,MAAM,qCAAqC,IAAI,GAAG,QAAQ,YAAY,MAAM;CAE1F,OAAO,IAAI,iBAAiB,qBAAqB;EAE/C,OAAgB,OAAO,MAAM;EAC7B,iBAAiB,OAAO,EAAE,CAAC,CAAC,GAAG,yBAAyB,QAAQ,GAAG;CACrE,OAGE,IAAI,QAAQ,QAAQ,OAAO,aAAa;EAEtC,IAAI,YAAY,KAAA,KAAa,YAAY,OAAO,KAAK,gCAAgC,KAAK,MAAM;EAChG,SAAS,QAAQ,KAAK,KAAK;CAC7B,OACE,OAAgB,OAAO;AAG7B;AAEA,SAAgB,iBAAiB,QAAgB,QAA0B;CACzE,IAAI,OAAO,oBAAoB,WAAW,KAAA,KAAa,gBAAgB,MAAM,CAAC,CAAC,sBAC7E,KAAK,GAAG,OAAO,sBAAsB;AAEzC;AASA,SAAgB,gBAAkC,cAAkD;CAClG,OAAO,OAAO,OAAO,YAAY,YAAmB,CAAC,CAAC,MAAM,CAAC,CAC1D,QAAQ,MAAM,EAAE,QAAQ,CAAC,CACzB,KAAK,MAAM,EAAE,SAAS;AAC3B;AAEA,SAAgB,aAAa,QAAkD;CAC7E,OAAO,OAAO,QAAQ,cAAc,YAAY,MAAM,CAAC,CAAC,CAAC,CACtD,QAAQ,GAAG,OAAO,aAAa,oBAAoB,CAAC,CACpD,KAAK,CAAC,UAAW,OAAe,KAAK;AAC1C;AAEA,SAAgB,mBAAmB,QAA4D;CAC7F,OAAO,OAAO,QAAQ,cAAc,YAAY,MAAM,CAAC,CAAC,CAAC,CACtD,QAAQ,GAAG,OAAO,aAAa,oBAAoB,CAAC,CACpD,KAAK,CAAC,UAAU,CAAC,MAAO,OAAe,KAAK,CAAC;AAClD;;AAGA,SAAgB,eAAiC,MAA+D;CAC9G,OAAO;AACT;;;;;;;;AASA,IAAa,YAAb,cAA+B,MAAM,CAAC;;AAGtC,SAAgB,YAAY,QAAuB;CACjD,MAAM,IAAI,UAAU,GAAG,OAAO,eAAe;AAC/C;;;;;;AAOA,SAAgB,YAA8B,QAA6B;CACzE,OAAO,OAAO;AAChB"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { getInstanceData } from \"src/BaseEntity.ts\";\nimport { getDefaultDependencies } from \"src/defaults.ts\";\nimport { type Entity } from \"src/Entity.ts\";\nimport { type EntityConstructor, type MaybeAbstractEntityConstructor, getEmInternalApi } from \"src/EntityManager.ts\";\nimport { type EntityMetadata, getBaseMeta, getMetadata } from \"src/EntityMetadata.ts\";\nimport { getField, setField } from \"src/fields.ts\";\nimport { getProperties } from \"src/getProperties.ts\";\nimport type { New } from \"src/loading/loadHints.ts\";\nimport { isAllSqlPaths } from \"src/loading/loadLens.ts\";\nimport { FactoryInitialValue } from \"src/newTestInstance.ts\";\nimport { partitionHint } from \"src/preloading/partitionHint.ts\";\nimport { buildWhereClause } from \"src/queries/renderConditions.ts\";\nimport { AbstractRelationImpl } from \"src/relations/AbstractRelationImpl.ts\";\nimport { AsyncReactiveFieldImpl } from \"src/relations/AsyncReactiveField.ts\";\nimport {\n isAsyncProperty,\n isAsyncReactiveField,\n isLazyField,\n isProperty,\n isReactiveField,\n isReactiveGetter,\n} from \"src/relations/index.ts\";\nimport { ReactiveFieldImpl } from \"src/relations/ReactiveField.ts\";\nimport { type OptsOf } from \"src/typeMap.ts\";\nimport { fail } from \"src/utils.ts\";\n\nexport const testing = { isAllSqlPaths, getDefaultDependencies, partitionHint };\nexport const internals = { buildWhereClause };\nexport { newPgConnectionConfig } from \"joist-utils\";\nexport { AliasAssigner } from \"src/queries/sql/AliasAssigner.ts\";\nexport type { JoinTree } from \"src/queries/sql/JoinTree.ts\";\nexport {\n type AndCondition,\n type ConditionGroup,\n type DomainPredicate,\n type OrCondition,\n type PredicateBrand,\n type SqlCondition,\n type SqlPredicate,\n} from \"src/queries/conditions.ts\";\n// Domain aliases belong to em.find; physical table expressions belong to em.query/em.execute.\nexport {\n alias,\n aliases,\n getAliasMetadata,\n getAliasMgmt,\n getMaybeCtiAlias,\n isAlias,\n newAliasProxy,\n type Alias,\n type AliasBrand,\n type AliasMgmt,\n type AliasColumn,\n type EntityAlias,\n type PolyAlias,\n type PrimitiveAlias,\n} from \"src/queries/find/Aliases.ts\";\nexport {\n table,\n tables,\n tableMgmt,\n getTableMetadata,\n getTableMgmt,\n isTable,\n newTableProxy,\n type Table,\n type TableFilter,\n type TableBrand,\n type TableSourceBrand,\n type TableFor,\n type TableMgmt,\n type TableSourceMgmt,\n type ReferenceJoin,\n type PrimitiveColumn,\n type EntityColumn,\n type ReferenceColumn,\n type CollectionJoin,\n type PolyReference,\n} from \"src/queries/sql/Tables.ts\";\nexport {\n declareTable,\n type CustomColumnConfig,\n type CustomColumnInput,\n type CustomColumnInputs,\n type CustomColumnType,\n type CustomTable,\n type CustomTableDefinition,\n type CustomTableFor,\n} from \"src/queries/sql/custom.ts\";\nexport { BaseEntity, getInstanceData } from \"src/BaseEntity.ts\";\nexport { ConditionBuilder } from \"src/queries/ConditionBuilder.ts\";\nexport { type Entity, type IdType, isEntity } from \"src/Entity.ts\";\nexport type * from \"src/EntityFields.ts\";\nexport * from \"src/queries/find/EntityFilter.ts\";\nexport * from \"src/queries/find/EntityGraphQLFilter.ts\";\nexport * from \"src/EntityManager.ts\";\nexport { ReadDriftError, type ReadDrift } from \"src/flush/ReadDrift.ts\";\nexport { EntityMetrics, type EntityMetricsSnapshot, type EvaluationStats } from \"src/metrics/EntityMetrics.ts\";\nexport * from \"src/EntityMetadata.ts\";\nexport type {\n DeleteStatement,\n ExecuteResult,\n InsertStatement,\n InsertValues,\n MutationReturning,\n MutationStatement,\n UpdateStatement,\n UpdateValues,\n} from \"src/queries/sql/execute.ts\";\nexport type { EnumMetadata } from \"src/EnumMetadata.ts\";\n// `em.query`'s expression surface. Only the user-facing types are re-exported: the runtime half\n// (BaseExpr, asNode, deferredCondition, the FnExpr/TemplateExpr node classes) stays internal to\n// joist-core, so `parseSql`/`decode`/`encode` never show up as something a user could call.\nexport {\n type ArrayAggOptions,\n type Expr,\n type ExprBrand,\n exprBrand,\n type ExprLike,\n type InnerJoin,\n type LeftJoin,\n} from \"src/queries/sql/Expr.ts\";\nexport {\n expr,\n type CaseElse,\n type CaseWhen,\n type ExprFromInput,\n type ExprInput,\n} from \"src/queries/sql/expressions/expression.ts\";\nexport { skipCondition } from \"src/queries/skipCondition.ts\";\nexport type { EntityOrId, HintNode } from \"src/loading/HintTree.ts\";\nexport { InstanceData } from \"src/InstanceData.ts\";\nexport { type JoinColumnValue, type JoinRow, JoinRowOperation, type ManyToManyLike } from \"src/flush/JoinRows.ts\";\nexport type * from \"src/flush/PendingChanges.ts\";\nexport { Plugin } from \"src/PluginManager.ts\";\nexport {\n type ParsedSql,\n type ColumnSql,\n type StarSql,\n type BoundValue,\n type SqlPart,\n type ParsedSqlCondition,\n type RawSql,\n type JoinedSql,\n type QuerySql,\n type ConditionSql,\n type ExpressionCondition as SqlExpressionCondition,\n joinSql,\n columnSql,\n visitSql,\n} from \"src/queries/sql/ParsedSqlExpression.ts\";\nexport {\n visitQuery,\n visitQueryExpressions,\n type QueryExpressionContext,\n type QueryExpressionClause,\n type ParsedReadQuery,\n type ParsedSelectQuery,\n type ParsedSetQuery,\n type ParsedExecuteQuery,\n} from \"src/queries/sql/ParsedQuery.ts\";\nexport type { ParsedSource, ParsedTableSource, ParsedCteSource, ParsedQuerySource } from \"src/queries/sql/query.ts\";\nexport * from \"src/queries/find/QueryParser.ts\";\nexport * from \"src/queries/find/buildFindQuery.ts\";\nexport * from \"src/queries/renderConditions.ts\";\nexport type {\n ColumnCondition,\n ExistsCondition,\n ParsedExpressionCondition,\n ParsedExpressionFilter,\n ParsedValueFilter,\n RawCondition,\n} from \"src/queries/parsedConditions.ts\";\nexport {\n type ParsedEntityFilter,\n makeLike,\n mapToDb,\n parseEntityFilter,\n parseValueFilter,\n} from \"src/queries/valueFilters.ts\";\nexport {\n filterSoftDeletes,\n lazyExcludedSelects,\n maybeAddNotSoftDeleted,\n stiSubtypeFilter,\n} from \"src/queries/entityQueryUtils.ts\";\nexport * from \"src/queries/find/QueryParser.collectionJoins.ts\";\nexport { visitConditions } from \"src/queries/find/QueryVisitor.ts\";\nexport * from \"src/RowData.ts\";\nexport { type JoinRowTodo, Todo } from \"src/flush/Todo.ts\";\nexport * from \"src/changes.ts\";\nexport { ConfigApi, type EntityHook, resetBootFlag } from \"src/config.ts\";\nexport { type GuardTransitionMatch, type OnTransitionMatch, type TransitionTable } from \"src/transitions.ts\";\nexport {\n configureMetadata,\n getConstructorFromTaggedId,\n getMetadataForTable,\n getMetadataForType,\n maybeGetConstructorFromReference,\n} from \"src/configure.ts\";\nexport { driverApi } from \"src/drivers/driverApi.ts\";\nexport * from \"src/drivers/index.ts\";\nexport { getField, isChangeableField, isFieldSet, setField } from \"src/fields.ts\";\nexport * from \"src/getProperties.ts\";\nexport * from \"src/json.ts\";\nexport * from \"src/keys.ts\";\nexport { kq, kqDot, kqStar } from \"src/queries/sql/keywords.ts\";\nexport {\n assertLoaded,\n type DeepNew,\n ensureLoaded,\n isLoaded,\n isNew,\n type Loadable,\n type Loaded,\n type LoadHint,\n type MarkLoaded,\n maybePopulateThen,\n type NestedLoadHint,\n type New,\n type RelationsIn,\n unsafeLoaded,\n} from \"src/loading/loadHints.ts\";\nexport * from \"src/loading/loadLens.ts\";\nexport { setFactoryWriter } from \"src/logging/FactoryLogger.ts\";\nexport * from \"src/logging/FieldLogger.ts\";\nexport { ReactionLogger, setReactionLogging } from \"src/logging/ReactionLogger.ts\";\nexport { lazyField } from \"src/newEntity.ts\";\nexport {\n defaultValue,\n factories,\n type FactoryEntityOpt,\n type FactoryOpts,\n getTestIndex,\n isFactoryCreation,\n maybeBranchValue,\n maybeNew,\n maybeNewPoly,\n newTestInstance,\n noValue,\n setFactoryLogging,\n testIndex,\n} from \"src/newTestInstance.ts\";\nexport { deepNormalizeHint, normalizeHint } from \"src/normalizeHints.ts\";\nexport { ImmutableEntitiesPlugin } from \"src/plugins/ImmutableEntitiesPlugin.ts\";\nexport type { JoinResult, PreloadHydrator, PreloadPlugin } from \"src/plugins/PreloadPlugin.ts\";\nexport { JsonAggregatePreloader } from \"src/preloading/JsonAggregatePreloader.ts\";\n// `em.query`'s query surface; the parse pipeline (SubqueryHandle, parseRootQuery, Plan) stays internal\nexport {\n type CheckScope,\n type Clauses,\n type EntityQuery,\n type ExpressionOrderBy,\n type ExistsQuery,\n entityQueryBrand,\n type MaybeNull,\n type NameOf,\n type NotWidened,\n type OrderByDirection,\n type OrderByKeys,\n type Query,\n type QueryArg,\n type QueryCondition,\n type QueryJoin,\n type QueryJoinInput,\n type QueryJoinList,\n type QueryRow,\n type QuerySelect,\n type QuerySource,\n type QueryValue,\n recursiveQuery,\n type RecursiveOptions,\n type ResolvedJoins,\n type ScalarQuery,\n type SetQuery,\n query,\n queryMaybe,\n sql,\n type QueryTable,\n type QueryTableBrand,\n type Subquery,\n type SubqueryBrand,\n subqueryBrand,\n type WithInput,\n type WithSource,\n} from \"src/queries/sql/query.ts\";\nexport {\n convertToLoadHint,\n isTypeOrSubType,\n type Reactable,\n type Reacted,\n type ReactiveHint,\n type ReactiveTarget,\n reverseReactiveHint,\n} from \"src/reactivity/reactiveHints.ts\";\nexport * from \"src/relations/index.ts\";\nexport {\n cannotBeChanged,\n cannotBeUpdated,\n type GenericError,\n maxValueRule,\n minValueRule,\n mustBeSubType,\n newRequiredLazyFieldRule,\n newRequiredRule,\n rangeValueRule,\n ValidationCode,\n type ValidationError,\n ValidationErrors,\n type ValidationRule,\n type ValidationRuleInternal,\n type ValidationRuleResult,\n} from \"src/rules.ts\";\nexport { getRuntimeConfig, setRuntimeConfig, type RuntimeConfig } from \"src/runtimeConfig.ts\";\nexport { nowUTC } from \"src/nowUTC.ts\";\nexport * from \"src/serde/serde.ts\";\nexport * from \"src/serde/columns.ts\";\nexport * from \"src/serde/fieldSerde.ts\";\nexport * from \"src/queries/find/scopes.ts\";\nexport { maybeRequireTemporal, requireTemporal, Temporal } from \"src/serde/temporal.ts\";\nexport * from \"src/serde/temporalMappers.ts\";\nexport { isInTrustedContext, runInTrustedContext } from \"src/trusted.ts\";\nexport type * from \"src/typeMap.ts\";\nexport { buildUnnestCte, ensureRectangularArraySizes } from \"src/queries/unnest.ts\";\nexport { type DeepPartialOrNull, updatePartial, upsert } from \"src/upsert.ts\";\nexport {\n abbreviation,\n asNew,\n assertNever,\n cleanSql,\n cleanStringValue,\n fail,\n failIfAnyRejected,\n indexBy,\n partition,\n zeroTo,\n} from \"src/utils.ts\";\nexport { ensureWithLoaded, StubbedRelation, type WithLoaded, withLoaded } from \"src/loading/withLoaded.ts\";\n\n// https://spin.atomicobject.com/2018/01/15/typescript-flexible-nominal-typing/\ninterface Flavoring<FlavorT> {\n _type?: FlavorT;\n}\n\nexport type Flavor<T, FlavorT> = T & Flavoring<FlavorT>;\n\n/**\n * Sets each value in `values` on the current entity.\n *\n * The default behavior is that passing a value as either `null` or `undefined` will set\n * the field as `undefined`, i.e. automatic `null` to `undefined` conversion.\n *\n * However, if you pass `ignoreUndefined: true`, then any opt that is `undefined` will be treated\n * as \"do not set\", and `null` will still mean \"set to `undefined`\". This is useful for implementing\n * APIs were an input of `undefined` means \"do not set / noop\" and `null` means \"unset\".\n *\n * Note that constructors _always_ call this method, but if the call is coming from `em.hydrate`, we\n * use `values` being a primary key to short-circuit and let hydration callers assign the values\n * returned by the serde `fromRow` methods.\n */\nexport function setOpts<T extends Entity>(\n entity: T,\n values: Partial<OptsOf<T>> | undefined,\n opts?: { partial?: boolean; calledFromConstructor?: boolean },\n): void {\n const { calledFromConstructor = false, partial } = opts || {};\n // If `values` is undefined, we're being called by `createPartial` that will do its\n // own opt handling, but we still want the sync defaults applied after this opts handling.\n if (values !== undefined) {\n const meta = getMetadata(entity);\n for (const [key, _value] of Object.entries(values as {})) {\n setOpt(meta, entity, key, _value, partial, calledFromConstructor);\n }\n }\n}\n\n/**\n * Applies some standard behavior & protections to `entity[key] = value`. I.e.\n *\n * - We don't set over AsyncProperties/relations/etc., and instead call current.set(value)\n * - We catch missing/invalid field names\n * - We handle FactoryInitialValues\n */\nexport function setOpt<T extends Entity>(\n meta: EntityMetadata<T>,\n entity: T,\n key: string,\n _value: any,\n partial = false,\n calledFromConstructor = false,\n): void {\n const field = meta.allFields[key];\n if (!field) {\n // Allow setting non-field properties like fullName setters\n const prop = getProperties(meta)[key];\n if (!prop) {\n throw new Error(`Unknown field ${key}`);\n }\n }\n\n // If partial is set, we treat undefined as a noop\n if (partial && _value === undefined) return;\n // Ignore the STI discriminator, em.register will set this accordingly\n if (meta.inheritanceType === \"sti\" && getBaseMeta(meta).stiDiscriminatorField === key) return;\n\n // We let optional opts fields be `| null` for convenience, and convert to undefined.\n const value = _value === null ? undefined : _value;\n\n // Use `getField` to side-step `id` blowing up on new entities that are setting an\n // explicit id. Read configured fields as internal so applying opts does not mark the entity for read locking.\n // Otherwise use `entity[key]` to get back the relation.\n const current = key === \"id\" || field?.assertUnchanged ? getField(entity, key, true) : (entity as any)[key];\n\n if (current instanceof AbstractRelationImpl) {\n if (calledFromConstructor) {\n current.setFromOpts(value);\n } else {\n current.set(value);\n }\n } else if (isLazyField(current)) {\n current.set(value);\n } else if (isProperty(current) || isAsyncProperty(current) || isReactiveGetter(current)) {\n throw new Error(`Invalid argument, cannot set over ${key} ${current.constructor.name}`);\n } else if (isReactiveField(current) || isAsyncReactiveField(current)) {\n if (value instanceof FactoryInitialValue) {\n if (current instanceof ReactiveFieldImpl) {\n current.setFactoryValue(value.value);\n } else if (current instanceof AsyncReactiveFieldImpl) {\n current.setFactoryValue(value.value);\n } else {\n throw new Error(`Unhandled case ${current.constructor.name}`);\n }\n } else {\n throw new Error(`Invalid argument, cannot set over ${key} ${current.constructor.name}`);\n }\n } else if (value instanceof FactoryInitialValue) {\n // A factory's `withStatus`-style opt: trust the created value, so its `addTransitionReaction`s don't fire\n (entity as any)[key] = value.value;\n getEmInternalApi(entity.em).rm.forgetCreationTransition(entity, key);\n } else {\n // If setting an explicit id, go through setField, otherwise use\n // `entity[key]` to set the value directly to that we go through setters.\n if (key === \"id\" && entity.isNewEntity) {\n // Reject ID changes even before insertion: they would invalidate identity-map entries and cached ID conversions.\n if (current !== undefined && current !== value) fail(`Cannot change assigned id of ${meta.type}`);\n setField(entity, key, value);\n } else {\n (entity as any)[key] = value;\n }\n }\n}\n\nexport function ensureNotDeleted(entity: Entity, ignore?: \"pending\"): void {\n if (entity.isDeletedEntity && (ignore === undefined || getInstanceData(entity).isDeletedAndFlushed)) {\n fail(`${entity} is marked as deleted`);\n }\n}\n\n/** Adds `null` to every key in `T` to accept partial-update-style input. */\nexport type PartialOrNull<T> = {\n [P in keyof T]?: T[P] | null;\n};\n\nexport function getRequiredKeys<T extends Entity>(entity: T): string[];\nexport function getRequiredKeys<T extends Entity>(type: EntityConstructor<T>): string[];\nexport function getRequiredKeys<T extends Entity>(entityOrType: T | EntityConstructor<T>): string[] {\n return Object.values(getMetadata(entityOrType as any).fields)\n .filter((f) => f.required)\n .map((f) => f.fieldName);\n}\n\nexport function getRelations(entity: Entity): AbstractRelationImpl<any, any>[] {\n return Object.entries(getProperties(getMetadata(entity)))\n .filter(([, v]) => v instanceof AbstractRelationImpl)\n .map(([name]) => (entity as any)[name]);\n}\n\nexport function getRelationEntries(entity: Entity): [string, AbstractRelationImpl<any, any>][] {\n return Object.entries(getProperties(getMetadata(entity)))\n .filter(([, v]) => v instanceof AbstractRelationImpl)\n .map(([name]) => [name, (entity as any)[name]]);\n}\n\n/** Casts a \"maybe abstract\" cstr to a concrete cstr when the calling code knows it's safe. */\nexport function asConcreteCstr<T extends Entity>(cstr: MaybeAbstractEntityConstructor<T>): EntityConstructor<T> {\n return cstr as any;\n}\n\n/**\n * Thrown when `.id` is accessed on an entity that does not have an id yet.\n *\n * For Postgres, entities are actually allowed to have ids pre-INSERT, if you call\n * `em.assignNewIds()`. Other databases typically require INSERTs to trigger the auto\n * id assignment.\n */\nexport class NoIdError extends Error {}\n\n/** Throws a `NoIdError` for `entity`, i.e. because `id` was called before being saved. */\nexport function failNoIdYet(entity: string): never {\n throw new NoIdError(`${entity} has no id yet`);\n}\n\n/**\n * Add a static function since getters can't have type guards.\n *\n * See https://github.com/microsoft/TypeScript/issues/43368\n */\nexport function isNewEntity<T extends Entity>(entity: T): entity is New<T> {\n return entity.isNewEntity;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,UAAU;CAAE;CAAe;CAAwB;AAAc;AAC9E,MAAa,YAAY,EAAE,iBAAiB;;;;;;;;;;;;;;;AA6U5C,SAAgB,QACd,QACA,QACA,MACM;CACN,MAAM,EAAE,wBAAwB,OAAO,YAAY,QAAQ,CAAC;CAG5D,IAAI,WAAW,KAAA,GAAW;EACxB,MAAM,OAAO,YAAY,MAAM;EAC/B,KAAK,MAAM,CAAC,KAAK,WAAW,OAAO,QAAQ,MAAY,GACrD,OAAO,MAAM,QAAQ,KAAK,QAAQ,SAAS,qBAAqB;CAEpE;AACF;;;;;;;;AASA,SAAgB,OACd,MACA,QACA,KACA,QACA,UAAU,OACV,wBAAwB,OAClB;CACN,MAAM,QAAQ,KAAK,UAAU;CAC7B,IAAI,CAAC,OAGC;MAAA,CADS,cAAc,IAAI,CAAC,CAAC,MAE/B,MAAM,IAAI,MAAM,iBAAiB,KAAK;CAAA;CAK1C,IAAI,WAAW,WAAW,KAAA,GAAW;CAErC,IAAI,KAAK,oBAAoB,SAAS,YAAY,IAAI,CAAC,CAAC,0BAA0B,KAAK;CAGvF,MAAM,QAAQ,WAAW,OAAO,KAAA,IAAY;CAK5C,MAAM,UAAU,QAAQ,QAAQ,OAAO,kBAAkB,SAAS,QAAQ,KAAK,IAAI,IAAK,OAAe;CAEvG,IAAI,mBAAmB,sBAAsB;EAC3C,IAAI,uBACF,QAAQ,YAAY,KAAK;OAEzB,QAAQ,IAAI,KAAK;CAErB,OAAO,IAAI,YAAY,OAAO,GAC5B,QAAQ,IAAI,KAAK;MACZ,IAAI,WAAW,OAAO,KAAK,gBAAgB,OAAO,KAAK,iBAAiB,OAAO,GACpF,MAAM,IAAI,MAAM,qCAAqC,IAAI,GAAG,QAAQ,YAAY,MAAM;MACjF,IAAI,gBAAgB,OAAO,KAAK,qBAAqB,OAAO,GAAG;EACpE,IAAI,iBAAiB,qBAAqB;GACxC,IAAI,mBAAmB,mBACrB,QAAQ,gBAAgB,MAAM,KAAK;QAC9B,IAAI,mBAAmB,wBAC5B,QAAQ,gBAAgB,MAAM,KAAK;QAEnC,MAAM,IAAI,MAAM,kBAAkB,QAAQ,YAAY,MAAM;EAEhE,OACE,MAAM,IAAI,MAAM,qCAAqC,IAAI,GAAG,QAAQ,YAAY,MAAM;CAE1F,OAAO,IAAI,iBAAiB,qBAAqB;EAE/C,OAAgB,OAAO,MAAM;EAC7B,iBAAiB,OAAO,EAAE,CAAC,CAAC,GAAG,yBAAyB,QAAQ,GAAG;CACrE,OAGE,IAAI,QAAQ,QAAQ,OAAO,aAAa;EAEtC,IAAI,YAAY,KAAA,KAAa,YAAY,OAAO,KAAK,gCAAgC,KAAK,MAAM;EAChG,SAAS,QAAQ,KAAK,KAAK;CAC7B,OACE,OAAgB,OAAO;AAG7B;AAEA,SAAgB,iBAAiB,QAAgB,QAA0B;CACzE,IAAI,OAAO,oBAAoB,WAAW,KAAA,KAAa,gBAAgB,MAAM,CAAC,CAAC,sBAC7E,KAAK,GAAG,OAAO,sBAAsB;AAEzC;AASA,SAAgB,gBAAkC,cAAkD;CAClG,OAAO,OAAO,OAAO,YAAY,YAAmB,CAAC,CAAC,MAAM,CAAC,CAC1D,QAAQ,MAAM,EAAE,QAAQ,CAAC,CACzB,KAAK,MAAM,EAAE,SAAS;AAC3B;AAEA,SAAgB,aAAa,QAAkD;CAC7E,OAAO,OAAO,QAAQ,cAAc,YAAY,MAAM,CAAC,CAAC,CAAC,CACtD,QAAQ,GAAG,OAAO,aAAa,oBAAoB,CAAC,CACpD,KAAK,CAAC,UAAW,OAAe,KAAK;AAC1C;AAEA,SAAgB,mBAAmB,QAA4D;CAC7F,OAAO,OAAO,QAAQ,cAAc,YAAY,MAAM,CAAC,CAAC,CAAC,CACtD,QAAQ,GAAG,OAAO,aAAa,oBAAoB,CAAC,CACpD,KAAK,CAAC,UAAU,CAAC,MAAO,OAAe,KAAK,CAAC;AAClD;;AAGA,SAAgB,eAAiC,MAA+D;CAC9G,OAAO;AACT;;;;;;;;AASA,IAAa,YAAb,cAA+B,MAAM,CAAC;;AAGtC,SAAgB,YAAY,QAAuB;CACjD,MAAM,IAAI,UAAU,GAAG,OAAO,eAAe;AAC/C;;;;;;AAOA,SAAgB,YAA8B,QAA6B;CACzE,OAAO,OAAO;AAChB"}
@@ -88,7 +88,7 @@ var ConditionBuilder = class {
88
88
  };
89
89
  }
90
90
  };
91
- /** Parses user-facing `{ and: ... }` or `{ or: ... }` into a `ParsedExpressionFilter`. */
91
+ /** Parses user-facing `{ and: ... }` or `{ or: ... }` into a `ParsedConditionGroup`. */
92
92
  function parseExpression(expression) {
93
93
  const [op, expressions] = "and" in expression && expression.and ? ["and", expression.and] : "or" in expression && expression.or ? ["or", expression.or] : require_utils.fail(`Invalid expression ${expression}`);
94
94
  const conditions = expressions.map((exp) => exp && ("and" in exp || "or" in exp) ? parseExpression(exp) : exp);
@@ -101,5 +101,6 @@ function parseExpression(expression) {
101
101
  };
102
102
  }
103
103
  exports.ConditionBuilder = ConditionBuilder;
104
+ exports.parseExpression = parseExpression;
104
105
 
105
106
  //# sourceMappingURL=ConditionBuilder.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConditionBuilder.cjs","names":["mapToDb","fail","partition","skipCondition","isDefined"],"sources":["../../src/queries/ConditionBuilder.ts"],"sourcesContent":["import { isDefined } from \"src/EntityManager.ts\";\nimport type { ConditionGroup, ConditionInput } from \"src/queries/conditions.ts\";\nimport type {\n ColumnCondition,\n ParsedExpressionCondition,\n ParsedExpressionFilter,\n ParsedValueFilter,\n RawCondition,\n} from \"src/queries/parsedConditions.ts\";\nimport { skipCondition } from \"src/queries/skipCondition.ts\";\nimport { mapToDb } from \"src/queries/valueFilters.ts\";\nimport type { Column } from \"src/serde/columns.ts\";\nimport { fail, partition } from \"src/utils.ts\";\n\ntype PartialSome<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;\n\n/** Converts domain-level values like string ids/enums into their db equivalent. */\nexport class ConditionBuilder {\n /** Simple, single-column conditions, which will be AND-d together. */\n private conditions: (ColumnCondition | RawCondition)[] = [];\n /** Complex expressions, which will also be AND-d together with `conditions`. */\n private expressions: ParsedExpressionFilter[] = [];\n\n /** Accepts a raw user-facing DSL filter, and parses it into a `ParsedExpressionFilter`. */\n maybeAddExpression(expression: ConditionGroup<ConditionInput>): void {\n const parsed = parseExpression(expression);\n if (parsed) this.expressions.push(parsed);\n }\n\n /** Adds an already-db-level condition to the simple conditions list. */\n addSimpleCondition(condition: ColumnCondition): void {\n this.conditions.push(condition);\n }\n\n /** Adds an already-db-level condition to the simple conditions list. */\n addRawCondition(condition: PartialSome<RawCondition, \"kind\" | \"bindings\">): void {\n this.conditions.push({\n kind: \"raw\",\n bindings: [],\n ...condition,\n });\n }\n\n /** Adds an already-db-level expression to the expressions list. */\n addParsedExpression(parsed: ParsedExpressionFilter): void {\n this.expressions.push(parsed);\n }\n\n /**\n * Adds a user-facing `ParsedValueFilter` to the inline conditions.\n *\n * Unless it's something like `in: [a1, null]`, in which case we split it into two `is-null` and `in` conditions.\n */\n addValueFilter(alias: string, column: Column, filter: ParsedValueFilter<any>): void {\n if (filter.kind === \"in\" && filter.value.includes(null)) {\n // If the filter contains a null, we need to split it into an `is-null` and `in` condition\n const isNull = {\n kind: \"column\",\n alias,\n column: column.columnName,\n dbType: column.dbType,\n cond: { kind: \"is-null\" },\n } satisfies ColumnCondition;\n const inValues = {\n kind: \"column\",\n alias,\n column: column.columnName,\n dbType: column.dbType,\n cond: {\n kind: \"in\",\n // Filter out the nulls from the in condition\n value: filter.value.filter((v) => v !== null).map((v) => column.mapToDb(v)),\n },\n } satisfies ColumnCondition;\n // Now OR them back together\n this.expressions.push({ kind: \"exp\", op: \"or\", conditions: [isNull, inValues] });\n } else {\n const cond = {\n kind: \"column\",\n alias,\n column: column.columnName,\n dbType: column.dbType,\n // Rewrite the user-facing domain values to db values\n cond: mapToDb(column, filter),\n } satisfies ColumnCondition;\n this.conditions.push(cond);\n }\n }\n\n /** Combines our collected `conditions` and `expressions` into a single `ParsedExpressionFilter`. */\n toExpressionFilter(): ParsedExpressionFilter | undefined {\n const { expressions, conditions } = this;\n const allSimple: ParsedExpressionCondition[] = [...conditions];\n if (allSimple.length === 0 && expressions.length === 1) {\n // If no inline conditions, and just 1 opt expression, just use that\n return expressions[0];\n } else if (expressions.length === 1 && expressions[0].op === \"and\") {\n // Merge the 1 `AND` expression with the other simple conditions\n return { kind: \"exp\", op: \"and\", conditions: [...allSimple, ...expressions[0].conditions] };\n } else if (allSimple.length > 0 || expressions.length > 0) {\n // Combine the conditions within the `em.find` join literal & the `conditions` as ANDs\n return { kind: \"exp\", op: \"and\", conditions: [...allSimple, ...expressions] };\n }\n return undefined;\n }\n}\n\n/** Parses user-facing `{ and: ... }` or `{ or: ... }` into a `ParsedExpressionFilter`. */\nfunction parseExpression(expression: ConditionGroup<ConditionInput>): ParsedExpressionFilter | undefined {\n // Look for `{ and: [...] }` or `{ or: [...] }`\n const [op, expressions] =\n \"and\" in expression && expression.and\n ? [\"and\" as const, expression.and]\n : \"or\" in expression && expression.or\n ? [\"or\" as const, expression.or]\n : fail(`Invalid expression ${expression}`);\n // Potentially recurse into nested expressions\n const conditions = expressions.map((exp) => (exp && (\"and\" in exp || \"or\" in exp) ? parseExpression(exp) : exp));\n const [skip, valid] = partition(conditions, (cond) => cond === undefined || cond === skipCondition);\n if ((skip.length > 0 && expression.pruneIfUndefined === \"any\") || valid.length === 0) {\n return undefined;\n }\n return { kind: \"exp\", op, conditions: valid.filter(isDefined) };\n}\n"],"mappings":";;;;;;;AAiBA,IAAa,mBAAb,MAA8B;;CAE5B,aAAyD,CAAC;;CAE1D,cAAgD,CAAC;;CAGjD,mBAAmB,YAAkD;EACnE,MAAM,SAAS,gBAAgB,UAAU;EACzC,IAAI,QAAQ,KAAK,YAAY,KAAK,MAAM;CAC1C;;CAGA,mBAAmB,WAAkC;EACnD,KAAK,WAAW,KAAK,SAAS;CAChC;;CAGA,gBAAgB,WAAiE;EAC/E,KAAK,WAAW,KAAK;GACnB,MAAM;GACN,UAAU,CAAC;GACX,GAAG;EACL,CAAC;CACH;;CAGA,oBAAoB,QAAsC;EACxD,KAAK,YAAY,KAAK,MAAM;CAC9B;;;;;;CAOA,eAAe,OAAe,QAAgB,QAAsC;EAClF,IAAI,OAAO,SAAS,QAAQ,OAAO,MAAM,SAAS,IAAI,GAAG;GAEvD,MAAM,SAAS;IACb,MAAM;IACN;IACA,QAAQ,OAAO;IACf,QAAQ,OAAO;IACf,MAAM,EAAE,MAAM,UAAU;GAC1B;GACA,MAAM,WAAW;IACf,MAAM;IACN;IACA,QAAQ,OAAO;IACf,QAAQ,OAAO;IACf,MAAM;KACJ,MAAM;KAEN,OAAO,OAAO,MAAM,QAAQ,MAAM,MAAM,IAAI,CAAC,CAAC,KAAK,MAAM,OAAO,QAAQ,CAAC,CAAC;IAC5E;GACF;GAEA,KAAK,YAAY,KAAK;IAAE,MAAM;IAAO,IAAI;IAAM,YAAY,CAAC,QAAQ,QAAQ;GAAE,CAAC;EACjF,OAAO;GACL,MAAM,OAAO;IACX,MAAM;IACN;IACA,QAAQ,OAAO;IACf,QAAQ,OAAO;IAEf,MAAMA,6BAAAA,QAAQ,QAAQ,MAAM;GAC9B;GACA,KAAK,WAAW,KAAK,IAAI;EAC3B;CACF;;CAGA,qBAAyD;EACvD,MAAM,EAAE,aAAa,eAAe;EACpC,MAAM,YAAyC,CAAC,GAAG,UAAU;EAC7D,IAAI,UAAU,WAAW,KAAK,YAAY,WAAW,GAEnD,OAAO,YAAY;OACd,IAAI,YAAY,WAAW,KAAK,YAAY,EAAE,CAAC,OAAO,OAE3D,OAAO;GAAE,MAAM;GAAO,IAAI;GAAO,YAAY,CAAC,GAAG,WAAW,GAAG,YAAY,EAAE,CAAC,UAAU;EAAE;OACrF,IAAI,UAAU,SAAS,KAAK,YAAY,SAAS,GAEtD,OAAO;GAAE,MAAM;GAAO,IAAI;GAAO,YAAY,CAAC,GAAG,WAAW,GAAG,WAAW;EAAE;CAGhF;AACF;;AAGA,SAAS,gBAAgB,YAAgF;CAEvG,MAAM,CAAC,IAAI,eACT,SAAS,cAAc,WAAW,MAC9B,CAAC,OAAgB,WAAW,GAAG,IAC/B,QAAQ,cAAc,WAAW,KAC/B,CAAC,MAAe,WAAW,EAAE,IAC7BC,cAAAA,KAAK,sBAAsB,YAAY;CAE/C,MAAM,aAAa,YAAY,KAAK,QAAS,QAAQ,SAAS,OAAO,QAAQ,OAAO,gBAAgB,GAAG,IAAI,GAAI;CAC/G,MAAM,CAAC,MAAM,SAASC,cAAAA,UAAU,aAAa,SAAS,SAAS,KAAA,KAAa,SAASC,8BAAAA,aAAa;CAClG,IAAK,KAAK,SAAS,KAAK,WAAW,qBAAqB,SAAU,MAAM,WAAW,GACjF;CAEF,OAAO;EAAE,MAAM;EAAO;EAAI,YAAY,MAAM,OAAOC,sBAAAA,SAAS;CAAE;AAChE"}
1
+ {"version":3,"file":"ConditionBuilder.cjs","names":["mapToDb","fail","partition","skipCondition","isDefined"],"sources":["../../src/queries/ConditionBuilder.ts"],"sourcesContent":["import { isDefined } from \"src/EntityManager.ts\";\nimport type { ConditionGroup, ConditionInput, ConditionTree } from \"src/queries/conditions.ts\";\nimport type {\n ColumnCondition,\n ParsedExpressionCondition,\n ParsedExpressionFilter,\n ParsedValueFilter,\n RawCondition,\n} from \"src/queries/parsedConditions.ts\";\nimport { skipCondition } from \"src/queries/skipCondition.ts\";\nimport { mapToDb } from \"src/queries/valueFilters.ts\";\nimport type { Column } from \"src/serde/columns.ts\";\nimport { fail, partition } from \"src/utils.ts\";\n\ntype PartialSome<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;\n\n/** Converts domain-level values like string ids/enums into their db equivalent. */\nexport class ConditionBuilder {\n /** Simple, single-column conditions, which will be AND-d together. */\n private conditions: (ColumnCondition | RawCondition)[] = [];\n /** Complex expressions, which will also be AND-d together with `conditions`. */\n private expressions: ParsedExpressionFilter[] = [];\n\n /** Accepts a raw user-facing DSL filter, and parses it into a `ParsedExpressionFilter`. */\n maybeAddExpression(expression: ConditionGroup<ConditionInput>): void {\n const parsed = parseExpression<ColumnCondition | RawCondition>(expression);\n if (parsed) this.expressions.push(parsed);\n }\n\n /** Adds an already-db-level condition to the simple conditions list. */\n addSimpleCondition(condition: ColumnCondition): void {\n this.conditions.push(condition);\n }\n\n /** Adds an already-db-level condition to the simple conditions list. */\n addRawCondition(condition: PartialSome<RawCondition, \"kind\" | \"bindings\">): void {\n this.conditions.push({\n kind: \"raw\",\n bindings: [],\n ...condition,\n });\n }\n\n /** Adds an already-db-level expression to the expressions list. */\n addParsedExpression(parsed: ParsedExpressionFilter): void {\n this.expressions.push(parsed);\n }\n\n /**\n * Adds a user-facing `ParsedValueFilter` to the inline conditions.\n *\n * Unless it's something like `in: [a1, null]`, in which case we split it into two `is-null` and `in` conditions.\n */\n addValueFilter(alias: string, column: Column, filter: ParsedValueFilter<any>): void {\n if (filter.kind === \"in\" && filter.value.includes(null)) {\n // If the filter contains a null, we need to split it into an `is-null` and `in` condition\n const isNull = {\n kind: \"column\",\n alias,\n column: column.columnName,\n dbType: column.dbType,\n cond: { kind: \"is-null\" },\n } satisfies ColumnCondition;\n const inValues = {\n kind: \"column\",\n alias,\n column: column.columnName,\n dbType: column.dbType,\n cond: {\n kind: \"in\",\n // Filter out the nulls from the in condition\n value: filter.value.filter((v) => v !== null).map((v) => column.mapToDb(v)),\n },\n } satisfies ColumnCondition;\n // Now OR them back together\n this.expressions.push({ kind: \"exp\", op: \"or\", conditions: [isNull, inValues] });\n } else {\n const cond = {\n kind: \"column\",\n alias,\n column: column.columnName,\n dbType: column.dbType,\n // Rewrite the user-facing domain values to db values\n cond: mapToDb(column, filter),\n } satisfies ColumnCondition;\n this.conditions.push(cond);\n }\n }\n\n /** Combines our collected `conditions` and `expressions` into a single `ParsedExpressionFilter`. */\n toExpressionFilter(): ParsedExpressionFilter | undefined {\n const { expressions, conditions } = this;\n const allSimple: ParsedExpressionCondition[] = [...conditions];\n if (allSimple.length === 0 && expressions.length === 1) {\n // If no inline conditions, and just 1 opt expression, just use that\n return expressions[0];\n } else if (expressions.length === 1 && expressions[0].op === \"and\") {\n // Merge the 1 `AND` expression with the other simple conditions\n return { kind: \"exp\", op: \"and\", conditions: [...allSimple, ...expressions[0].conditions] };\n } else if (allSimple.length > 0 || expressions.length > 0) {\n // Combine the conditions within the `em.find` join literal & the `conditions` as ANDs\n return { kind: \"exp\", op: \"and\", conditions: [...allSimple, ...expressions] };\n }\n return undefined;\n }\n}\n\n/** A normalized boolean group. */\nexport interface ParsedConditionGroup<C> {\n kind: \"exp\";\n op: \"and\" | \"or\";\n conditions: (C | ParsedConditionGroup<C>)[];\n}\n\n/** Parses user-facing `{ and: ... }` or `{ or: ... }` into a `ParsedConditionGroup`. */\nexport function parseExpression<C extends object>(\n expression: ConditionGroup<ConditionTree<C>>,\n): ParsedConditionGroup<C> | undefined {\n // Look for `{ and: [...] }` or `{ or: [...] }`\n const [op, expressions] =\n \"and\" in expression && expression.and\n ? [\"and\" as const, expression.and]\n : \"or\" in expression && expression.or\n ? [\"or\" as const, expression.or]\n : fail(`Invalid expression ${expression}`);\n // Potentially recurse into nested expressions\n const conditions = expressions.map((exp) =>\n exp && (\"and\" in exp || \"or\" in exp)\n ? parseExpression<C>(exp as ConditionGroup<ConditionTree<C>>)\n : (exp as C | undefined),\n );\n const [skip, valid] = partition(conditions, (cond) => cond === undefined || cond === skipCondition);\n if ((skip.length > 0 && expression.pruneIfUndefined === \"any\") || valid.length === 0) {\n return undefined;\n }\n return { kind: \"exp\", op, conditions: valid.filter(isDefined) };\n}\n"],"mappings":";;;;;;;AAiBA,IAAa,mBAAb,MAA8B;;CAE5B,aAAyD,CAAC;;CAE1D,cAAgD,CAAC;;CAGjD,mBAAmB,YAAkD;EACnE,MAAM,SAAS,gBAAgD,UAAU;EACzE,IAAI,QAAQ,KAAK,YAAY,KAAK,MAAM;CAC1C;;CAGA,mBAAmB,WAAkC;EACnD,KAAK,WAAW,KAAK,SAAS;CAChC;;CAGA,gBAAgB,WAAiE;EAC/E,KAAK,WAAW,KAAK;GACnB,MAAM;GACN,UAAU,CAAC;GACX,GAAG;EACL,CAAC;CACH;;CAGA,oBAAoB,QAAsC;EACxD,KAAK,YAAY,KAAK,MAAM;CAC9B;;;;;;CAOA,eAAe,OAAe,QAAgB,QAAsC;EAClF,IAAI,OAAO,SAAS,QAAQ,OAAO,MAAM,SAAS,IAAI,GAAG;GAEvD,MAAM,SAAS;IACb,MAAM;IACN;IACA,QAAQ,OAAO;IACf,QAAQ,OAAO;IACf,MAAM,EAAE,MAAM,UAAU;GAC1B;GACA,MAAM,WAAW;IACf,MAAM;IACN;IACA,QAAQ,OAAO;IACf,QAAQ,OAAO;IACf,MAAM;KACJ,MAAM;KAEN,OAAO,OAAO,MAAM,QAAQ,MAAM,MAAM,IAAI,CAAC,CAAC,KAAK,MAAM,OAAO,QAAQ,CAAC,CAAC;IAC5E;GACF;GAEA,KAAK,YAAY,KAAK;IAAE,MAAM;IAAO,IAAI;IAAM,YAAY,CAAC,QAAQ,QAAQ;GAAE,CAAC;EACjF,OAAO;GACL,MAAM,OAAO;IACX,MAAM;IACN;IACA,QAAQ,OAAO;IACf,QAAQ,OAAO;IAEf,MAAMA,6BAAAA,QAAQ,QAAQ,MAAM;GAC9B;GACA,KAAK,WAAW,KAAK,IAAI;EAC3B;CACF;;CAGA,qBAAyD;EACvD,MAAM,EAAE,aAAa,eAAe;EACpC,MAAM,YAAyC,CAAC,GAAG,UAAU;EAC7D,IAAI,UAAU,WAAW,KAAK,YAAY,WAAW,GAEnD,OAAO,YAAY;OACd,IAAI,YAAY,WAAW,KAAK,YAAY,EAAE,CAAC,OAAO,OAE3D,OAAO;GAAE,MAAM;GAAO,IAAI;GAAO,YAAY,CAAC,GAAG,WAAW,GAAG,YAAY,EAAE,CAAC,UAAU;EAAE;OACrF,IAAI,UAAU,SAAS,KAAK,YAAY,SAAS,GAEtD,OAAO;GAAE,MAAM;GAAO,IAAI;GAAO,YAAY,CAAC,GAAG,WAAW,GAAG,WAAW;EAAE;CAGhF;AACF;;AAUA,SAAgB,gBACd,YACqC;CAErC,MAAM,CAAC,IAAI,eACT,SAAS,cAAc,WAAW,MAC9B,CAAC,OAAgB,WAAW,GAAG,IAC/B,QAAQ,cAAc,WAAW,KAC/B,CAAC,MAAe,WAAW,EAAE,IAC7BC,cAAAA,KAAK,sBAAsB,YAAY;CAE/C,MAAM,aAAa,YAAY,KAAK,QAClC,QAAQ,SAAS,OAAO,QAAQ,OAC5B,gBAAmB,GAAuC,IACzD,GACP;CACA,MAAM,CAAC,MAAM,SAASC,cAAAA,UAAU,aAAa,SAAS,SAAS,KAAA,KAAa,SAASC,8BAAAA,aAAa;CAClG,IAAK,KAAK,SAAS,KAAK,WAAW,qBAAqB,SAAU,MAAM,WAAW,GACjF;CAEF,OAAO;EAAE,MAAM;EAAO;EAAI,YAAY,MAAM,OAAOC,sBAAAA,SAAS;CAAE;AAChE"}
@@ -1,4 +1,4 @@
1
- import { ConditionGroup, ConditionInput } from "./conditions.cjs";
1
+ import { ConditionGroup, ConditionInput, ConditionTree } from "./conditions.cjs";
2
2
  import { ColumnCondition, ParsedExpressionFilter, ParsedValueFilter, RawCondition } from "./parsedConditions.cjs";
3
3
  import { Column } from "../serde/columns.cjs";
4
4
  type PartialSome<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
@@ -25,5 +25,13 @@ export declare class ConditionBuilder {
25
25
  /** Combines our collected `conditions` and `expressions` into a single `ParsedExpressionFilter`. */
26
26
  toExpressionFilter(): ParsedExpressionFilter | undefined;
27
27
  }
28
+ /** A normalized boolean group. */
29
+ export interface ParsedConditionGroup<C> {
30
+ kind: "exp";
31
+ op: "and" | "or";
32
+ conditions: (C | ParsedConditionGroup<C>)[];
33
+ }
34
+ /** Parses user-facing `{ and: ... }` or `{ or: ... }` into a `ParsedConditionGroup`. */
35
+ export declare function parseExpression<C extends object>(expression: ConditionGroup<ConditionTree<C>>): ParsedConditionGroup<C> | undefined;
28
36
  export {};
29
37
  //# sourceMappingURL=ConditionBuilder.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConditionBuilder.d.cts","names":[],"sources":["../../src/queries/ConditionBuilder.ts"],"mappings":";;;KAcK,YAAY,GAAG,gBAAgB,KAAK,KAAK,GAAG,KAAK,QAAQ,KAAK,GAAG;;qBAGzD;;UAEH;;UAEA;;EAGR,mBAAmB,YAAY,eAAe;;EAM9C,mBAAmB,WAAW;;EAK9B,gBAAgB,WAAW,YAAY;;EASvC,oBAAoB,QAAQ;;;;;;EAS5B,eAAe,eAAe,QAAQ,QAAQ,QAAQ;;EAqCtD,sBAAsB"}
1
+ {"version":3,"file":"ConditionBuilder.d.cts","names":[],"sources":["../../src/queries/ConditionBuilder.ts"],"mappings":";;;KAcK,YAAY,GAAG,gBAAgB,KAAK,KAAK,GAAG,KAAK,QAAQ,KAAK,GAAG;;qBAGzD;;UAEH;;UAEA;;EAGR,mBAAmB,YAAY,eAAe;;EAM9C,mBAAmB,WAAW;;EAK9B,gBAAgB,WAAW,YAAY;;EASvC,oBAAoB,QAAQ;;;;;;EAS5B,eAAe,eAAe,QAAQ,QAAQ,QAAQ;;EAqCtD,sBAAsB;;;iBAkBP,qBAAqB;EACpC;EACA;EACA,aAAa,IAAI,qBAAqB;;;wBAIxB,gBAAgB,kBAC9B,YAAY,eAAe,cAAc,MACxC,qBAAqB"}
@@ -1,4 +1,4 @@
1
- import { ConditionGroup, ConditionInput } from "./conditions.mjs";
1
+ import { ConditionGroup, ConditionInput, ConditionTree } from "./conditions.mjs";
2
2
  import { ColumnCondition, ParsedExpressionFilter, ParsedValueFilter, RawCondition } from "./parsedConditions.mjs";
3
3
  import { Column } from "../serde/columns.mjs";
4
4
  type PartialSome<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
@@ -25,5 +25,13 @@ export declare class ConditionBuilder {
25
25
  /** Combines our collected `conditions` and `expressions` into a single `ParsedExpressionFilter`. */
26
26
  toExpressionFilter(): ParsedExpressionFilter | undefined;
27
27
  }
28
+ /** A normalized boolean group. */
29
+ export interface ParsedConditionGroup<C> {
30
+ kind: "exp";
31
+ op: "and" | "or";
32
+ conditions: (C | ParsedConditionGroup<C>)[];
33
+ }
34
+ /** Parses user-facing `{ and: ... }` or `{ or: ... }` into a `ParsedConditionGroup`. */
35
+ export declare function parseExpression<C extends object>(expression: ConditionGroup<ConditionTree<C>>): ParsedConditionGroup<C> | undefined;
28
36
  export {};
29
37
  //# sourceMappingURL=ConditionBuilder.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConditionBuilder.d.mts","names":[],"sources":["../../src/queries/ConditionBuilder.ts"],"mappings":";;;KAcK,YAAY,GAAG,gBAAgB,KAAK,KAAK,GAAG,KAAK,QAAQ,KAAK,GAAG;;qBAGzD;;UAEH;;UAEA;;EAGR,mBAAmB,YAAY,eAAe;;EAM9C,mBAAmB,WAAW;;EAK9B,gBAAgB,WAAW,YAAY;;EASvC,oBAAoB,QAAQ;;;;;;EAS5B,eAAe,eAAe,QAAQ,QAAQ,QAAQ;;EAqCtD,sBAAsB"}
1
+ {"version":3,"file":"ConditionBuilder.d.mts","names":[],"sources":["../../src/queries/ConditionBuilder.ts"],"mappings":";;;KAcK,YAAY,GAAG,gBAAgB,KAAK,KAAK,GAAG,KAAK,QAAQ,KAAK,GAAG;;qBAGzD;;UAEH;;UAEA;;EAGR,mBAAmB,YAAY,eAAe;;EAM9C,mBAAmB,WAAW;;EAK9B,gBAAgB,WAAW,YAAY;;EASvC,oBAAoB,QAAQ;;;;;;EAS5B,eAAe,eAAe,QAAQ,QAAQ,QAAQ;;EAqCtD,sBAAsB;;;iBAkBP,qBAAqB;EACpC;EACA;EACA,aAAa,IAAI,qBAAqB;;;wBAIxB,gBAAgB,kBAC9B,YAAY,eAAe,cAAc,MACxC,qBAAqB"}
@@ -87,7 +87,7 @@ var ConditionBuilder = class {
87
87
  };
88
88
  }
89
89
  };
90
- /** Parses user-facing `{ and: ... }` or `{ or: ... }` into a `ParsedExpressionFilter`. */
90
+ /** Parses user-facing `{ and: ... }` or `{ or: ... }` into a `ParsedConditionGroup`. */
91
91
  function parseExpression(expression) {
92
92
  const [op, expressions] = "and" in expression && expression.and ? ["and", expression.and] : "or" in expression && expression.or ? ["or", expression.or] : fail(`Invalid expression ${expression}`);
93
93
  const conditions = expressions.map((exp) => exp && ("and" in exp || "or" in exp) ? parseExpression(exp) : exp);
@@ -99,6 +99,6 @@ function parseExpression(expression) {
99
99
  conditions: valid.filter(isDefined)
100
100
  };
101
101
  }
102
- export { ConditionBuilder };
102
+ export { ConditionBuilder, parseExpression };
103
103
 
104
104
  //# sourceMappingURL=ConditionBuilder.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConditionBuilder.js","names":[],"sources":["../../src/queries/ConditionBuilder.ts"],"sourcesContent":["import { isDefined } from \"src/EntityManager.ts\";\nimport type { ConditionGroup, ConditionInput } from \"src/queries/conditions.ts\";\nimport type {\n ColumnCondition,\n ParsedExpressionCondition,\n ParsedExpressionFilter,\n ParsedValueFilter,\n RawCondition,\n} from \"src/queries/parsedConditions.ts\";\nimport { skipCondition } from \"src/queries/skipCondition.ts\";\nimport { mapToDb } from \"src/queries/valueFilters.ts\";\nimport type { Column } from \"src/serde/columns.ts\";\nimport { fail, partition } from \"src/utils.ts\";\n\ntype PartialSome<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;\n\n/** Converts domain-level values like string ids/enums into their db equivalent. */\nexport class ConditionBuilder {\n /** Simple, single-column conditions, which will be AND-d together. */\n private conditions: (ColumnCondition | RawCondition)[] = [];\n /** Complex expressions, which will also be AND-d together with `conditions`. */\n private expressions: ParsedExpressionFilter[] = [];\n\n /** Accepts a raw user-facing DSL filter, and parses it into a `ParsedExpressionFilter`. */\n maybeAddExpression(expression: ConditionGroup<ConditionInput>): void {\n const parsed = parseExpression(expression);\n if (parsed) this.expressions.push(parsed);\n }\n\n /** Adds an already-db-level condition to the simple conditions list. */\n addSimpleCondition(condition: ColumnCondition): void {\n this.conditions.push(condition);\n }\n\n /** Adds an already-db-level condition to the simple conditions list. */\n addRawCondition(condition: PartialSome<RawCondition, \"kind\" | \"bindings\">): void {\n this.conditions.push({\n kind: \"raw\",\n bindings: [],\n ...condition,\n });\n }\n\n /** Adds an already-db-level expression to the expressions list. */\n addParsedExpression(parsed: ParsedExpressionFilter): void {\n this.expressions.push(parsed);\n }\n\n /**\n * Adds a user-facing `ParsedValueFilter` to the inline conditions.\n *\n * Unless it's something like `in: [a1, null]`, in which case we split it into two `is-null` and `in` conditions.\n */\n addValueFilter(alias: string, column: Column, filter: ParsedValueFilter<any>): void {\n if (filter.kind === \"in\" && filter.value.includes(null)) {\n // If the filter contains a null, we need to split it into an `is-null` and `in` condition\n const isNull = {\n kind: \"column\",\n alias,\n column: column.columnName,\n dbType: column.dbType,\n cond: { kind: \"is-null\" },\n } satisfies ColumnCondition;\n const inValues = {\n kind: \"column\",\n alias,\n column: column.columnName,\n dbType: column.dbType,\n cond: {\n kind: \"in\",\n // Filter out the nulls from the in condition\n value: filter.value.filter((v) => v !== null).map((v) => column.mapToDb(v)),\n },\n } satisfies ColumnCondition;\n // Now OR them back together\n this.expressions.push({ kind: \"exp\", op: \"or\", conditions: [isNull, inValues] });\n } else {\n const cond = {\n kind: \"column\",\n alias,\n column: column.columnName,\n dbType: column.dbType,\n // Rewrite the user-facing domain values to db values\n cond: mapToDb(column, filter),\n } satisfies ColumnCondition;\n this.conditions.push(cond);\n }\n }\n\n /** Combines our collected `conditions` and `expressions` into a single `ParsedExpressionFilter`. */\n toExpressionFilter(): ParsedExpressionFilter | undefined {\n const { expressions, conditions } = this;\n const allSimple: ParsedExpressionCondition[] = [...conditions];\n if (allSimple.length === 0 && expressions.length === 1) {\n // If no inline conditions, and just 1 opt expression, just use that\n return expressions[0];\n } else if (expressions.length === 1 && expressions[0].op === \"and\") {\n // Merge the 1 `AND` expression with the other simple conditions\n return { kind: \"exp\", op: \"and\", conditions: [...allSimple, ...expressions[0].conditions] };\n } else if (allSimple.length > 0 || expressions.length > 0) {\n // Combine the conditions within the `em.find` join literal & the `conditions` as ANDs\n return { kind: \"exp\", op: \"and\", conditions: [...allSimple, ...expressions] };\n }\n return undefined;\n }\n}\n\n/** Parses user-facing `{ and: ... }` or `{ or: ... }` into a `ParsedExpressionFilter`. */\nfunction parseExpression(expression: ConditionGroup<ConditionInput>): ParsedExpressionFilter | undefined {\n // Look for `{ and: [...] }` or `{ or: [...] }`\n const [op, expressions] =\n \"and\" in expression && expression.and\n ? [\"and\" as const, expression.and]\n : \"or\" in expression && expression.or\n ? [\"or\" as const, expression.or]\n : fail(`Invalid expression ${expression}`);\n // Potentially recurse into nested expressions\n const conditions = expressions.map((exp) => (exp && (\"and\" in exp || \"or\" in exp) ? parseExpression(exp) : exp));\n const [skip, valid] = partition(conditions, (cond) => cond === undefined || cond === skipCondition);\n if ((skip.length > 0 && expression.pruneIfUndefined === \"any\") || valid.length === 0) {\n return undefined;\n }\n return { kind: \"exp\", op, conditions: valid.filter(isDefined) };\n}\n"],"mappings":";;;;;;AAiBA,IAAa,mBAAb,MAA8B;;CAE5B,aAAyD,CAAC;;CAE1D,cAAgD,CAAC;;CAGjD,mBAAmB,YAAkD;EACnE,MAAM,SAAS,gBAAgB,UAAU;EACzC,IAAI,QAAQ,KAAK,YAAY,KAAK,MAAM;CAC1C;;CAGA,mBAAmB,WAAkC;EACnD,KAAK,WAAW,KAAK,SAAS;CAChC;;CAGA,gBAAgB,WAAiE;EAC/E,KAAK,WAAW,KAAK;GACnB,MAAM;GACN,UAAU,CAAC;GACX,GAAG;EACL,CAAC;CACH;;CAGA,oBAAoB,QAAsC;EACxD,KAAK,YAAY,KAAK,MAAM;CAC9B;;;;;;CAOA,eAAe,OAAe,QAAgB,QAAsC;EAClF,IAAI,OAAO,SAAS,QAAQ,OAAO,MAAM,SAAS,IAAI,GAAG;GAEvD,MAAM,SAAS;IACb,MAAM;IACN;IACA,QAAQ,OAAO;IACf,QAAQ,OAAO;IACf,MAAM,EAAE,MAAM,UAAU;GAC1B;GACA,MAAM,WAAW;IACf,MAAM;IACN;IACA,QAAQ,OAAO;IACf,QAAQ,OAAO;IACf,MAAM;KACJ,MAAM;KAEN,OAAO,OAAO,MAAM,QAAQ,MAAM,MAAM,IAAI,CAAC,CAAC,KAAK,MAAM,OAAO,QAAQ,CAAC,CAAC;IAC5E;GACF;GAEA,KAAK,YAAY,KAAK;IAAE,MAAM;IAAO,IAAI;IAAM,YAAY,CAAC,QAAQ,QAAQ;GAAE,CAAC;EACjF,OAAO;GACL,MAAM,OAAO;IACX,MAAM;IACN;IACA,QAAQ,OAAO;IACf,QAAQ,OAAO;IAEf,MAAM,QAAQ,QAAQ,MAAM;GAC9B;GACA,KAAK,WAAW,KAAK,IAAI;EAC3B;CACF;;CAGA,qBAAyD;EACvD,MAAM,EAAE,aAAa,eAAe;EACpC,MAAM,YAAyC,CAAC,GAAG,UAAU;EAC7D,IAAI,UAAU,WAAW,KAAK,YAAY,WAAW,GAEnD,OAAO,YAAY;OACd,IAAI,YAAY,WAAW,KAAK,YAAY,EAAE,CAAC,OAAO,OAE3D,OAAO;GAAE,MAAM;GAAO,IAAI;GAAO,YAAY,CAAC,GAAG,WAAW,GAAG,YAAY,EAAE,CAAC,UAAU;EAAE;OACrF,IAAI,UAAU,SAAS,KAAK,YAAY,SAAS,GAEtD,OAAO;GAAE,MAAM;GAAO,IAAI;GAAO,YAAY,CAAC,GAAG,WAAW,GAAG,WAAW;EAAE;CAGhF;AACF;;AAGA,SAAS,gBAAgB,YAAgF;CAEvG,MAAM,CAAC,IAAI,eACT,SAAS,cAAc,WAAW,MAC9B,CAAC,OAAgB,WAAW,GAAG,IAC/B,QAAQ,cAAc,WAAW,KAC/B,CAAC,MAAe,WAAW,EAAE,IAC7B,KAAK,sBAAsB,YAAY;CAE/C,MAAM,aAAa,YAAY,KAAK,QAAS,QAAQ,SAAS,OAAO,QAAQ,OAAO,gBAAgB,GAAG,IAAI,GAAI;CAC/G,MAAM,CAAC,MAAM,SAAS,UAAU,aAAa,SAAS,SAAS,KAAA,KAAa,SAAS,aAAa;CAClG,IAAK,KAAK,SAAS,KAAK,WAAW,qBAAqB,SAAU,MAAM,WAAW,GACjF;CAEF,OAAO;EAAE,MAAM;EAAO;EAAI,YAAY,MAAM,OAAO,SAAS;CAAE;AAChE"}
1
+ {"version":3,"file":"ConditionBuilder.js","names":[],"sources":["../../src/queries/ConditionBuilder.ts"],"sourcesContent":["import { isDefined } from \"src/EntityManager.ts\";\nimport type { ConditionGroup, ConditionInput, ConditionTree } from \"src/queries/conditions.ts\";\nimport type {\n ColumnCondition,\n ParsedExpressionCondition,\n ParsedExpressionFilter,\n ParsedValueFilter,\n RawCondition,\n} from \"src/queries/parsedConditions.ts\";\nimport { skipCondition } from \"src/queries/skipCondition.ts\";\nimport { mapToDb } from \"src/queries/valueFilters.ts\";\nimport type { Column } from \"src/serde/columns.ts\";\nimport { fail, partition } from \"src/utils.ts\";\n\ntype PartialSome<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;\n\n/** Converts domain-level values like string ids/enums into their db equivalent. */\nexport class ConditionBuilder {\n /** Simple, single-column conditions, which will be AND-d together. */\n private conditions: (ColumnCondition | RawCondition)[] = [];\n /** Complex expressions, which will also be AND-d together with `conditions`. */\n private expressions: ParsedExpressionFilter[] = [];\n\n /** Accepts a raw user-facing DSL filter, and parses it into a `ParsedExpressionFilter`. */\n maybeAddExpression(expression: ConditionGroup<ConditionInput>): void {\n const parsed = parseExpression<ColumnCondition | RawCondition>(expression);\n if (parsed) this.expressions.push(parsed);\n }\n\n /** Adds an already-db-level condition to the simple conditions list. */\n addSimpleCondition(condition: ColumnCondition): void {\n this.conditions.push(condition);\n }\n\n /** Adds an already-db-level condition to the simple conditions list. */\n addRawCondition(condition: PartialSome<RawCondition, \"kind\" | \"bindings\">): void {\n this.conditions.push({\n kind: \"raw\",\n bindings: [],\n ...condition,\n });\n }\n\n /** Adds an already-db-level expression to the expressions list. */\n addParsedExpression(parsed: ParsedExpressionFilter): void {\n this.expressions.push(parsed);\n }\n\n /**\n * Adds a user-facing `ParsedValueFilter` to the inline conditions.\n *\n * Unless it's something like `in: [a1, null]`, in which case we split it into two `is-null` and `in` conditions.\n */\n addValueFilter(alias: string, column: Column, filter: ParsedValueFilter<any>): void {\n if (filter.kind === \"in\" && filter.value.includes(null)) {\n // If the filter contains a null, we need to split it into an `is-null` and `in` condition\n const isNull = {\n kind: \"column\",\n alias,\n column: column.columnName,\n dbType: column.dbType,\n cond: { kind: \"is-null\" },\n } satisfies ColumnCondition;\n const inValues = {\n kind: \"column\",\n alias,\n column: column.columnName,\n dbType: column.dbType,\n cond: {\n kind: \"in\",\n // Filter out the nulls from the in condition\n value: filter.value.filter((v) => v !== null).map((v) => column.mapToDb(v)),\n },\n } satisfies ColumnCondition;\n // Now OR them back together\n this.expressions.push({ kind: \"exp\", op: \"or\", conditions: [isNull, inValues] });\n } else {\n const cond = {\n kind: \"column\",\n alias,\n column: column.columnName,\n dbType: column.dbType,\n // Rewrite the user-facing domain values to db values\n cond: mapToDb(column, filter),\n } satisfies ColumnCondition;\n this.conditions.push(cond);\n }\n }\n\n /** Combines our collected `conditions` and `expressions` into a single `ParsedExpressionFilter`. */\n toExpressionFilter(): ParsedExpressionFilter | undefined {\n const { expressions, conditions } = this;\n const allSimple: ParsedExpressionCondition[] = [...conditions];\n if (allSimple.length === 0 && expressions.length === 1) {\n // If no inline conditions, and just 1 opt expression, just use that\n return expressions[0];\n } else if (expressions.length === 1 && expressions[0].op === \"and\") {\n // Merge the 1 `AND` expression with the other simple conditions\n return { kind: \"exp\", op: \"and\", conditions: [...allSimple, ...expressions[0].conditions] };\n } else if (allSimple.length > 0 || expressions.length > 0) {\n // Combine the conditions within the `em.find` join literal & the `conditions` as ANDs\n return { kind: \"exp\", op: \"and\", conditions: [...allSimple, ...expressions] };\n }\n return undefined;\n }\n}\n\n/** A normalized boolean group. */\nexport interface ParsedConditionGroup<C> {\n kind: \"exp\";\n op: \"and\" | \"or\";\n conditions: (C | ParsedConditionGroup<C>)[];\n}\n\n/** Parses user-facing `{ and: ... }` or `{ or: ... }` into a `ParsedConditionGroup`. */\nexport function parseExpression<C extends object>(\n expression: ConditionGroup<ConditionTree<C>>,\n): ParsedConditionGroup<C> | undefined {\n // Look for `{ and: [...] }` or `{ or: [...] }`\n const [op, expressions] =\n \"and\" in expression && expression.and\n ? [\"and\" as const, expression.and]\n : \"or\" in expression && expression.or\n ? [\"or\" as const, expression.or]\n : fail(`Invalid expression ${expression}`);\n // Potentially recurse into nested expressions\n const conditions = expressions.map((exp) =>\n exp && (\"and\" in exp || \"or\" in exp)\n ? parseExpression<C>(exp as ConditionGroup<ConditionTree<C>>)\n : (exp as C | undefined),\n );\n const [skip, valid] = partition(conditions, (cond) => cond === undefined || cond === skipCondition);\n if ((skip.length > 0 && expression.pruneIfUndefined === \"any\") || valid.length === 0) {\n return undefined;\n }\n return { kind: \"exp\", op, conditions: valid.filter(isDefined) };\n}\n"],"mappings":";;;;;;AAiBA,IAAa,mBAAb,MAA8B;;CAE5B,aAAyD,CAAC;;CAE1D,cAAgD,CAAC;;CAGjD,mBAAmB,YAAkD;EACnE,MAAM,SAAS,gBAAgD,UAAU;EACzE,IAAI,QAAQ,KAAK,YAAY,KAAK,MAAM;CAC1C;;CAGA,mBAAmB,WAAkC;EACnD,KAAK,WAAW,KAAK,SAAS;CAChC;;CAGA,gBAAgB,WAAiE;EAC/E,KAAK,WAAW,KAAK;GACnB,MAAM;GACN,UAAU,CAAC;GACX,GAAG;EACL,CAAC;CACH;;CAGA,oBAAoB,QAAsC;EACxD,KAAK,YAAY,KAAK,MAAM;CAC9B;;;;;;CAOA,eAAe,OAAe,QAAgB,QAAsC;EAClF,IAAI,OAAO,SAAS,QAAQ,OAAO,MAAM,SAAS,IAAI,GAAG;GAEvD,MAAM,SAAS;IACb,MAAM;IACN;IACA,QAAQ,OAAO;IACf,QAAQ,OAAO;IACf,MAAM,EAAE,MAAM,UAAU;GAC1B;GACA,MAAM,WAAW;IACf,MAAM;IACN;IACA,QAAQ,OAAO;IACf,QAAQ,OAAO;IACf,MAAM;KACJ,MAAM;KAEN,OAAO,OAAO,MAAM,QAAQ,MAAM,MAAM,IAAI,CAAC,CAAC,KAAK,MAAM,OAAO,QAAQ,CAAC,CAAC;IAC5E;GACF;GAEA,KAAK,YAAY,KAAK;IAAE,MAAM;IAAO,IAAI;IAAM,YAAY,CAAC,QAAQ,QAAQ;GAAE,CAAC;EACjF,OAAO;GACL,MAAM,OAAO;IACX,MAAM;IACN;IACA,QAAQ,OAAO;IACf,QAAQ,OAAO;IAEf,MAAM,QAAQ,QAAQ,MAAM;GAC9B;GACA,KAAK,WAAW,KAAK,IAAI;EAC3B;CACF;;CAGA,qBAAyD;EACvD,MAAM,EAAE,aAAa,eAAe;EACpC,MAAM,YAAyC,CAAC,GAAG,UAAU;EAC7D,IAAI,UAAU,WAAW,KAAK,YAAY,WAAW,GAEnD,OAAO,YAAY;OACd,IAAI,YAAY,WAAW,KAAK,YAAY,EAAE,CAAC,OAAO,OAE3D,OAAO;GAAE,MAAM;GAAO,IAAI;GAAO,YAAY,CAAC,GAAG,WAAW,GAAG,YAAY,EAAE,CAAC,UAAU;EAAE;OACrF,IAAI,UAAU,SAAS,KAAK,YAAY,SAAS,GAEtD,OAAO;GAAE,MAAM;GAAO,IAAI;GAAO,YAAY,CAAC,GAAG,WAAW,GAAG,WAAW;EAAE;CAGhF;AACF;;AAUA,SAAgB,gBACd,YACqC;CAErC,MAAM,CAAC,IAAI,eACT,SAAS,cAAc,WAAW,MAC9B,CAAC,OAAgB,WAAW,GAAG,IAC/B,QAAQ,cAAc,WAAW,KAC/B,CAAC,MAAe,WAAW,EAAE,IAC7B,KAAK,sBAAsB,YAAY;CAE/C,MAAM,aAAa,YAAY,KAAK,QAClC,QAAQ,SAAS,OAAO,QAAQ,OAC5B,gBAAmB,GAAuC,IACzD,GACP;CACA,MAAM,CAAC,MAAM,SAAS,UAAU,aAAa,SAAS,SAAS,KAAA,KAAa,SAAS,aAAa;CAClG,IAAK,KAAK,SAAS,KAAK,WAAW,qBAAqB,SAAU,MAAM,WAAW,GACjF;CAEF,OAAO;EAAE,MAAM;EAAO;EAAI,YAAY,MAAM,OAAO,SAAS;CAAE;AAChE"}
@@ -1 +1 @@
1
- {"version":3,"file":"conditions.cjs","names":[],"sources":["../../src/queries/conditions.ts"],"sourcesContent":["import type { ColumnCondition, RawCondition } from \"src/queries/parsedConditions.ts\";\n\nexport const predicateBrand: unique symbol = Symbol(\"joist.predicate\");\n\n/** Combines conditions without tying AND/OR or optional-filter pruning to either public API. */\nexport type ConditionGroup<C> = AndCondition<C> | OrCondition<C>;\n\n/** Requires every surviving condition to match. */\nexport interface AndCondition<C> {\n and: Array<C | undefined>;\n or?: never;\n pruneIfUndefined?: \"any\" | \"all\";\n}\n\n/** Requires at least one surviving condition to match. */\nexport interface OrCondition<C> {\n or: Array<C | undefined>;\n and?: never;\n pruneIfUndefined?: \"any\" | \"all\";\n}\n\n/** Identifies which API can resolve a predicate's aliases. */\nexport interface PredicateBrand<K extends \"domain\" | \"sql\"> {\n readonly [predicateBrand]: K;\n}\n\n/** A predicate built from alias(...) for em.find and scopes. */\nexport type DomainPredicate = (ColumnCondition | RawCondition) & PredicateBrand<\"domain\">;\n\n/** A predicate built from table(...), an SQL expression, or sql.condition. */\nexport type SqlPredicate = (ColumnCondition | RawCondition) & PredicateBrand<\"sql\">;\n\n/** Existing hand-written conditions remain an escape hatch, but cannot accept a foreign branded predicate. */\nexport type UnbrandedPredicate = (ColumnCondition | RawCondition) & { readonly [predicateBrand]?: never };\n\n/** SQL predicates and nested AND/OR groups, before query-specific clauses such as EXISTS are added. */\nexport type SqlCondition = AndCondition<SqlCondition> | OrCondition<SqlCondition> | SqlPredicate | UnbrandedPredicate;\n\n/** Unbranded compiler input shared by domain filtering and SQL queries after public API validation. */\nexport type ConditionInput =\n | AndCondition<ConditionInput>\n | OrCondition<ConditionInput>\n | ColumnCondition\n | RawCondition;\n\n/** Marks a newly created predicate without changing its enumerable SQL representation. */\nexport function brandPredicate<C extends object, K extends \"domain\" | \"sql\">(cond: C, kind: K): C & PredicateBrand<K> {\n return Object.defineProperty(cond, predicateBrand, { value: kind, enumerable: false }) as C & PredicateBrand<K>;\n}\n"],"mappings":";;AAEA,MAAa,iBAAgC,OAAO,iBAAiB;;AA4CrE,SAAgB,eAA6D,MAAS,MAAgC;CACpH,OAAO,OAAO,eAAe,MAAM,gBAAgB;EAAE,OAAO;EAAM,YAAY;CAAM,CAAC;AACvF"}
1
+ {"version":3,"file":"conditions.cjs","names":[],"sources":["../../src/queries/conditions.ts"],"sourcesContent":["import type { ColumnCondition, RawCondition } from \"src/queries/parsedConditions.ts\";\nimport type { DeferredCondition } from \"src/queries/sql/Expr.ts\";\n\nexport const predicateBrand: unique symbol = Symbol(\"joist.predicate\");\n\n/** Combines conditions without tying AND/OR or optional-filter pruning to either public API. */\nexport type ConditionGroup<C> = AndCondition<C> | OrCondition<C>;\n\n/** Requires every surviving condition to match. */\nexport interface AndCondition<C> {\n and: Array<C | undefined>;\n or?: never;\n pruneIfUndefined?: \"any\" | \"all\";\n}\n\n/** Requires at least one surviving condition to match. */\nexport interface OrCondition<C> {\n or: Array<C | undefined>;\n and?: never;\n pruneIfUndefined?: \"any\" | \"all\";\n}\n\n/** Identifies which API can resolve a predicate's aliases. */\nexport interface PredicateBrand<K extends \"domain\" | \"sql\"> {\n readonly [predicateBrand]: K;\n}\n\n/** A predicate built from alias(...) for em.find and scopes. */\nexport type DomainPredicate = (ColumnCondition | RawCondition) & PredicateBrand<\"domain\">;\n\n/** A predicate built from table(...), an SQL expression, or sql.condition. */\nexport type SqlPredicate = (ColumnCondition | RawCondition | DeferredCondition) & PredicateBrand<\"sql\">;\n\n/** Boolean groups shared by both em.find and em.query predicates. */\nexport type ConditionTree<C> = C | AndCondition<ConditionTree<C>> | OrCondition<ConditionTree<C>>;\n\n/** Existing hand-written conditions remain an escape hatch, but cannot accept a foreign branded predicate. */\nexport type UnbrandedPredicate = (ColumnCondition | RawCondition) & { readonly [predicateBrand]?: never };\n\n/** SQL predicates and nested AND/OR groups, before query-specific clauses such as EXISTS are added. */\nexport type SqlCondition = AndCondition<SqlCondition> | OrCondition<SqlCondition> | SqlPredicate | UnbrandedPredicate;\n\n/** Unbranded compiler input shared by domain filtering and SQL queries after public API validation. */\nexport type ConditionInput =\n | AndCondition<ConditionInput>\n | OrCondition<ConditionInput>\n | ColumnCondition\n | RawCondition;\n\n/** Marks a newly created predicate without changing its enumerable SQL representation. */\nexport function brandPredicate<C extends object, K extends \"domain\" | \"sql\">(cond: C, kind: K): C & PredicateBrand<K> {\n return Object.defineProperty(cond, predicateBrand, { value: kind, enumerable: false }) as C & PredicateBrand<K>;\n}\n"],"mappings":";;AAGA,MAAa,iBAAgC,OAAO,iBAAiB;;AA+CrE,SAAgB,eAA6D,MAAS,MAAgC;CACpH,OAAO,OAAO,eAAe,MAAM,gBAAgB;EAAE,OAAO;EAAM,YAAY;CAAM,CAAC;AACvF"}
@@ -1,4 +1,5 @@
1
1
  import { ColumnCondition, RawCondition } from "./parsedConditions.cjs";
2
+ import { DeferredCondition } from "./sql/Expr.cjs";
2
3
  export declare const predicateBrand: unique symbol;
3
4
  /** Combines conditions without tying AND/OR or optional-filter pruning to either public API. */
4
5
  export type ConditionGroup<C> = AndCondition<C> | OrCondition<C>;
@@ -21,7 +22,9 @@ export interface PredicateBrand<K extends "domain" | "sql"> {
21
22
  /** A predicate built from alias(...) for em.find and scopes. */
22
23
  export type DomainPredicate = (ColumnCondition | RawCondition) & PredicateBrand<"domain">;
23
24
  /** A predicate built from table(...), an SQL expression, or sql.condition. */
24
- export type SqlPredicate = (ColumnCondition | RawCondition) & PredicateBrand<"sql">;
25
+ export type SqlPredicate = (ColumnCondition | RawCondition | DeferredCondition) & PredicateBrand<"sql">;
26
+ /** Boolean groups shared by both em.find and em.query predicates. */
27
+ export type ConditionTree<C> = C | AndCondition<ConditionTree<C>> | OrCondition<ConditionTree<C>>;
25
28
  /** Existing hand-written conditions remain an escape hatch, but cannot accept a foreign branded predicate. */
26
29
  export type UnbrandedPredicate = (ColumnCondition | RawCondition) & {
27
30
  readonly [predicateBrand]?: never;
@@ -1 +1 @@
1
- {"version":3,"file":"conditions.d.cts","names":[],"sources":["../../src/queries/conditions.ts"],"mappings":";qBAEa;;YAGD,eAAe,KAAK,aAAa,KAAK,YAAY;;iBAG7C,aAAa;EAC5B,KAAK,MAAM;EACX;EACA;;;iBAIe,YAAY;EAC3B,IAAI,MAAM;EACV;EACA;;;iBAIe,eAAe;YACpB,iBAAiB;;;YAIjB,mBAAmB,kBAAkB,gBAAgB;;YAGrD,gBAAgB,kBAAkB,gBAAgB;;YAGlD,sBAAsB,kBAAkB;YAA4B;;;YAGpE,eAAe,aAAa,gBAAgB,YAAY,gBAAgB,eAAe;;YAGvF,iBACR,aAAa,kBACb,YAAY,kBACZ,kBACA;;wBAGY,eAAe,kBAAkB,4BAA4B,MAAM,GAAG,MAAM,IAAI,IAAI,eAAe"}
1
+ {"version":3,"file":"conditions.d.cts","names":[],"sources":["../../src/queries/conditions.ts"],"mappings":";;qBAGa;;YAGD,eAAe,KAAK,aAAa,KAAK,YAAY;;iBAG7C,aAAa;EAC5B,KAAK,MAAM;EACX;EACA;;;iBAIe,YAAY;EAC3B,IAAI,MAAM;EACV;EACA;;;iBAIe,eAAe;YACpB,iBAAiB;;;YAIjB,mBAAmB,kBAAkB,gBAAgB;;YAGrD,gBAAgB,kBAAkB,eAAe,qBAAqB;;YAGtE,cAAc,KAAK,IAAI,aAAa,cAAc,MAAM,YAAY,cAAc;;YAGlF,sBAAsB,kBAAkB;YAA4B;;;YAGpE,eAAe,aAAa,gBAAgB,YAAY,gBAAgB,eAAe;;YAGvF,iBACR,aAAa,kBACb,YAAY,kBACZ,kBACA;;wBAGY,eAAe,kBAAkB,4BAA4B,MAAM,GAAG,MAAM,IAAI,IAAI,eAAe"}
@@ -1,4 +1,5 @@
1
1
  import { ColumnCondition, RawCondition } from "./parsedConditions.mjs";
2
+ import { DeferredCondition } from "./sql/Expr.mjs";
2
3
  export declare const predicateBrand: unique symbol;
3
4
  /** Combines conditions without tying AND/OR or optional-filter pruning to either public API. */
4
5
  export type ConditionGroup<C> = AndCondition<C> | OrCondition<C>;
@@ -21,7 +22,9 @@ export interface PredicateBrand<K extends "domain" | "sql"> {
21
22
  /** A predicate built from alias(...) for em.find and scopes. */
22
23
  export type DomainPredicate = (ColumnCondition | RawCondition) & PredicateBrand<"domain">;
23
24
  /** A predicate built from table(...), an SQL expression, or sql.condition. */
24
- export type SqlPredicate = (ColumnCondition | RawCondition) & PredicateBrand<"sql">;
25
+ export type SqlPredicate = (ColumnCondition | RawCondition | DeferredCondition) & PredicateBrand<"sql">;
26
+ /** Boolean groups shared by both em.find and em.query predicates. */
27
+ export type ConditionTree<C> = C | AndCondition<ConditionTree<C>> | OrCondition<ConditionTree<C>>;
25
28
  /** Existing hand-written conditions remain an escape hatch, but cannot accept a foreign branded predicate. */
26
29
  export type UnbrandedPredicate = (ColumnCondition | RawCondition) & {
27
30
  readonly [predicateBrand]?: never;
@@ -1 +1 @@
1
- {"version":3,"file":"conditions.d.mts","names":[],"sources":["../../src/queries/conditions.ts"],"mappings":";qBAEa;;YAGD,eAAe,KAAK,aAAa,KAAK,YAAY;;iBAG7C,aAAa;EAC5B,KAAK,MAAM;EACX;EACA;;;iBAIe,YAAY;EAC3B,IAAI,MAAM;EACV;EACA;;;iBAIe,eAAe;YACpB,iBAAiB;;;YAIjB,mBAAmB,kBAAkB,gBAAgB;;YAGrD,gBAAgB,kBAAkB,gBAAgB;;YAGlD,sBAAsB,kBAAkB;YAA4B;;;YAGpE,eAAe,aAAa,gBAAgB,YAAY,gBAAgB,eAAe;;YAGvF,iBACR,aAAa,kBACb,YAAY,kBACZ,kBACA;;wBAGY,eAAe,kBAAkB,4BAA4B,MAAM,GAAG,MAAM,IAAI,IAAI,eAAe"}
1
+ {"version":3,"file":"conditions.d.mts","names":[],"sources":["../../src/queries/conditions.ts"],"mappings":";;qBAGa;;YAGD,eAAe,KAAK,aAAa,KAAK,YAAY;;iBAG7C,aAAa;EAC5B,KAAK,MAAM;EACX;EACA;;;iBAIe,YAAY;EAC3B,IAAI,MAAM;EACV;EACA;;;iBAIe,eAAe;YACpB,iBAAiB;;;YAIjB,mBAAmB,kBAAkB,gBAAgB;;YAGrD,gBAAgB,kBAAkB,eAAe,qBAAqB;;YAGtE,cAAc,KAAK,IAAI,aAAa,cAAc,MAAM,YAAY,cAAc;;YAGlF,sBAAsB,kBAAkB;YAA4B;;;YAGpE,eAAe,aAAa,gBAAgB,YAAY,gBAAgB,eAAe;;YAGvF,iBACR,aAAa,kBACb,YAAY,kBACZ,kBACA;;wBAGY,eAAe,kBAAkB,4BAA4B,MAAM,GAAG,MAAM,IAAI,IAAI,eAAe"}
@@ -1 +1 @@
1
- {"version":3,"file":"conditions.js","names":[],"sources":["../../src/queries/conditions.ts"],"sourcesContent":["import type { ColumnCondition, RawCondition } from \"src/queries/parsedConditions.ts\";\n\nexport const predicateBrand: unique symbol = Symbol(\"joist.predicate\");\n\n/** Combines conditions without tying AND/OR or optional-filter pruning to either public API. */\nexport type ConditionGroup<C> = AndCondition<C> | OrCondition<C>;\n\n/** Requires every surviving condition to match. */\nexport interface AndCondition<C> {\n and: Array<C | undefined>;\n or?: never;\n pruneIfUndefined?: \"any\" | \"all\";\n}\n\n/** Requires at least one surviving condition to match. */\nexport interface OrCondition<C> {\n or: Array<C | undefined>;\n and?: never;\n pruneIfUndefined?: \"any\" | \"all\";\n}\n\n/** Identifies which API can resolve a predicate's aliases. */\nexport interface PredicateBrand<K extends \"domain\" | \"sql\"> {\n readonly [predicateBrand]: K;\n}\n\n/** A predicate built from alias(...) for em.find and scopes. */\nexport type DomainPredicate = (ColumnCondition | RawCondition) & PredicateBrand<\"domain\">;\n\n/** A predicate built from table(...), an SQL expression, or sql.condition. */\nexport type SqlPredicate = (ColumnCondition | RawCondition) & PredicateBrand<\"sql\">;\n\n/** Existing hand-written conditions remain an escape hatch, but cannot accept a foreign branded predicate. */\nexport type UnbrandedPredicate = (ColumnCondition | RawCondition) & { readonly [predicateBrand]?: never };\n\n/** SQL predicates and nested AND/OR groups, before query-specific clauses such as EXISTS are added. */\nexport type SqlCondition = AndCondition<SqlCondition> | OrCondition<SqlCondition> | SqlPredicate | UnbrandedPredicate;\n\n/** Unbranded compiler input shared by domain filtering and SQL queries after public API validation. */\nexport type ConditionInput =\n | AndCondition<ConditionInput>\n | OrCondition<ConditionInput>\n | ColumnCondition\n | RawCondition;\n\n/** Marks a newly created predicate without changing its enumerable SQL representation. */\nexport function brandPredicate<C extends object, K extends \"domain\" | \"sql\">(cond: C, kind: K): C & PredicateBrand<K> {\n return Object.defineProperty(cond, predicateBrand, { value: kind, enumerable: false }) as C & PredicateBrand<K>;\n}\n"],"mappings":";AAEA,MAAa,iBAAgC,OAAO,iBAAiB;;AA4CrE,SAAgB,eAA6D,MAAS,MAAgC;CACpH,OAAO,OAAO,eAAe,MAAM,gBAAgB;EAAE,OAAO;EAAM,YAAY;CAAM,CAAC;AACvF"}
1
+ {"version":3,"file":"conditions.js","names":[],"sources":["../../src/queries/conditions.ts"],"sourcesContent":["import type { ColumnCondition, RawCondition } from \"src/queries/parsedConditions.ts\";\nimport type { DeferredCondition } from \"src/queries/sql/Expr.ts\";\n\nexport const predicateBrand: unique symbol = Symbol(\"joist.predicate\");\n\n/** Combines conditions without tying AND/OR or optional-filter pruning to either public API. */\nexport type ConditionGroup<C> = AndCondition<C> | OrCondition<C>;\n\n/** Requires every surviving condition to match. */\nexport interface AndCondition<C> {\n and: Array<C | undefined>;\n or?: never;\n pruneIfUndefined?: \"any\" | \"all\";\n}\n\n/** Requires at least one surviving condition to match. */\nexport interface OrCondition<C> {\n or: Array<C | undefined>;\n and?: never;\n pruneIfUndefined?: \"any\" | \"all\";\n}\n\n/** Identifies which API can resolve a predicate's aliases. */\nexport interface PredicateBrand<K extends \"domain\" | \"sql\"> {\n readonly [predicateBrand]: K;\n}\n\n/** A predicate built from alias(...) for em.find and scopes. */\nexport type DomainPredicate = (ColumnCondition | RawCondition) & PredicateBrand<\"domain\">;\n\n/** A predicate built from table(...), an SQL expression, or sql.condition. */\nexport type SqlPredicate = (ColumnCondition | RawCondition | DeferredCondition) & PredicateBrand<\"sql\">;\n\n/** Boolean groups shared by both em.find and em.query predicates. */\nexport type ConditionTree<C> = C | AndCondition<ConditionTree<C>> | OrCondition<ConditionTree<C>>;\n\n/** Existing hand-written conditions remain an escape hatch, but cannot accept a foreign branded predicate. */\nexport type UnbrandedPredicate = (ColumnCondition | RawCondition) & { readonly [predicateBrand]?: never };\n\n/** SQL predicates and nested AND/OR groups, before query-specific clauses such as EXISTS are added. */\nexport type SqlCondition = AndCondition<SqlCondition> | OrCondition<SqlCondition> | SqlPredicate | UnbrandedPredicate;\n\n/** Unbranded compiler input shared by domain filtering and SQL queries after public API validation. */\nexport type ConditionInput =\n | AndCondition<ConditionInput>\n | OrCondition<ConditionInput>\n | ColumnCondition\n | RawCondition;\n\n/** Marks a newly created predicate without changing its enumerable SQL representation. */\nexport function brandPredicate<C extends object, K extends \"domain\" | \"sql\">(cond: C, kind: K): C & PredicateBrand<K> {\n return Object.defineProperty(cond, predicateBrand, { value: kind, enumerable: false }) as C & PredicateBrand<K>;\n}\n"],"mappings":";AAGA,MAAa,iBAAgC,OAAO,iBAAiB;;AA+CrE,SAAgB,eAA6D,MAAS,MAAgC;CACpH,OAAO,OAAO,eAAe,MAAM,gBAAgB;EAAE,OAAO;EAAM,YAAY;CAAM,CAAC;AACvF"}