@dbsp/core 1.11.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  import * as _dbsp_types from '@dbsp/types';
2
2
  import { PseudoColumnMetadata, RecursiveMetadata, RelationIR, RelationKind, AdapterCapabilities, Adapter, BaseAdapter, DDLGeneratingAdapter, ExecutingAdapter, IntrospectingAdapter, RawSqlAdapter, StreamingAdapter, TransactionalAdapter, ColumnType, WhereIntent, OnDeleteAction, ModelIR, DbCasing, QueryIntent, PlanOptions, PlanReport, RecursiveIntent, RecursivePlanOptions, RecursivePlanReport, TableIR, EnumIR, SequenceIR, AmbiguityCheckResult, DialectCapabilities, DDLFeature, DDLFeatureVersionRange, SelectIntent, IncludeIntent, AggregateIntent, OrderByIntent, SortDirection, InsertIntent, InsertFromIntent, UpdateIntent, BatchUpdateIntent, DeleteIntent, UpsertIntent, UpsertFromIntent, Dump, SetOperationIntent, LockStrength, LockWaitPolicy, DumpMeta, JoinIntent, UnnestCteIntent, CteQueryIntent, CompileOptions, CompiledQuery, MutationIntent as MutationIntent$1, DumpSequenceStep, UpsertConflictTarget, UpsertConflictAction, RawCteIntent, TruncateOptions, VacuumOptions, AlterColumnOptions, CreateIndexOptions, DropIndexOptions, IndexInfo, ExpressionIntent, ComparisonOperator, WhereSubqueryIntent, SubqueryRefIntent, WhereAndIntent, WhereAnyIntent, WhereComparisonIntent, WhereRelationFilterIntent, RecursiveExistsOptions, WhereExistsIntent, WhereInIntent, WhereNullIntent, WhereLikeIntent, WhereNotIntent, WhereNotExistsIntent, WhereOrIntent, WhereRawExistsIntent, WhereRawNotExistsIntent, WhereExpressionIntent, AggOrderByArg, RelationType as RelationType$1, Cardinality, FeatureWarning, UnsupportedFeatureBehavior, FeatureBehaviorConfig, RangeValue, WhereRangeIntent, SubqueryIncludeInfo } from '@dbsp/types';
3
- export { Adapter, AdapterCapabilities, AdapterLogger, AdapterStreamOptions, AdjacencyTraversal, AggregateExpressionIntent, AggregateFunction, AggregateIntent, AggregateWindowFunction, AliasIncludedColumnsMode, AlterColumnOptions, AmbiguityCheckResult, ArrayOperator, BaseAdapter, CTEDefinition, Cardinality, CaseExpressionIntent, CoalesceExpressionIntent, ColumnAliasIntent, ColumnExpressionIntent, ColumnIR, ColumnType, CommonColumnType, ComparisonExpressionIntent, ComparisonOperator, CompileOnlyAdapter, CompileOptions, CompileResultWithIncludes, CompiledQuery, CompilingAdapter, CreateIndexOptions, CustomTraversal, DDLGeneratingAdapter, DbCasing, DecisionType, DeleteIntent, DialectCapabilities, DialectName, DropIndexOptions, DuckDBColumnType, Dump, DumpMeta, EdgeTableTraversal, EmitJoinClause, ExecutingAdapter, ExpressionIntent, FilterStrategy, ForeignKeyIR, IncludeIntent, IncludeStrategy, IndexColumnDef, IndexIR, IndexInfo, IndexMethod, InsertFromIntent, InsertIntent, IntrospectingAdapter, IsTypeSupported, JoinDefault, JoinIntent, LiteralExpressionIntent, LogicalOperator, MSSQLColumnType, ModelIR, MutationIntent, MySQLColumnType, NullOperator, NullsPosition, OffsetWindowFunction, OnDeleteAction, Optionality, OrderByIntent, PartitionIR, PlanDecision, PlanOptions, PlanReport, PlanWarning, PlanWarningCode, PostgresColumnType, PostgresOnlyColumnType, PseudoColumnExpressionIntent, PseudoColumnMetadata, PseudoColumnTraversal, QueryIntent, RangeOperator, RangeValue, RankingWindowFunction, RawExpressionIntent, RawSqlAdapter, RecursiveAdvancedOptions, RecursiveDedupe, RecursiveDirection, RecursiveEmitOptions, RecursiveExistsOptions, RecursiveIntent, RecursiveMetadata, RecursiveNodeIdExpr, RecursivePlanOptions, RecursivePlanReport, RecursiveTrackOptions, RecursiveTraversal, RelationColumnIntent, RelationIR, RelationKind, RelationOperator, RelationType, ResolvedIncludeStrategy, SQLiteColumnType, ScalarSubqueryIntent, SelectAggregateIntent, SelectAllIntent, SelectFieldsIntent, SelectIntent, SelectWithExpressionsIntent, SortDirection, StreamingAdapter, StringOperator, SubqueryIncludeInfo, SubqueryRefIntent, SupportedColumnTypes, TableIR, TransactionalAdapter, TruncateOptions, UpdateIntent, UpsertConflictAction, UpsertConflictTarget, UpsertFromIntent, UpsertIntent, VacuumOptions, WhereAndIntent, WhereAnyIntent, WhereComparisonIntent, WhereExistsIntent, WhereInIntent, WhereIntent, WhereLikeIntent, WhereNotExistsIntent, WhereNotIntent, WhereNullIntent, WhereOrIntent, WhereRangeIntent, WhereRelationFilterIntent, WhereSubqueryIntent, WindowFunction, WindowIntent, WindowOrderBy, getNodeIdAlias, isAdjacencyTraversal, isAggregateWindowFunction, isCoalesceExpression, isColumnAliasExpression, isCustomTraversal, isDeleteIntent, isEdgeTableTraversal, isInsertIntent, isMutationIntent, isRankingWindowFunction, isRawExpression, isRecursiveIntent, isRelationColumnExpression, isSelectAggregate, isSelectAll, isSelectFields, isSelectWithExpressions, isSubqueryRef, isUpdateIntent, isUpsertIntent, isWhereAnd, isWhereAny, isWhereComparison, isWhereExists, isWhereIn, isWhereLike, isWhereLogical, isWhereNot, isWhereNotExists, isWhereNull, isWhereOr, isWhereRange, isWhereRelationBased, isWhereRelationFilter, isWhereSubquery, isWindowIntent } from '@dbsp/types';
3
+ export { Adapter, AdapterCapabilities, AdapterLogger, AdapterStreamOptions, AdjacencyTraversal, AggregateExpressionIntent, AggregateFunction, AggregateIntent, AggregateWindowFunction, AliasIncludedColumnsMode, AlterColumnOptions, AmbiguityCheckResult, ArrayOperator, BaseAdapter, CTEDefinition, Cardinality, CaseExpressionIntent, CoalesceExpressionIntent, ColumnAliasIntent, ColumnExpressionIntent, ColumnIR, ColumnType, CommonColumnType, ComparisonExpressionIntent, ComparisonOperator, CompileOnlyAdapter, CompileOptions, CompileResultWithIncludes, CompiledQuery, CompilingAdapter, CreateIndexOptions, CustomTraversal, DDLGeneratingAdapter, DbCasing, DecisionType, DeleteIntent, DialectCapabilities, DialectName, DropIndexOptions, DuckDBColumnType, Dump, DumpMeta, EdgeTableTraversal, EmitJoinClause, ExecutingAdapter, ExpressionIntent, FilterStrategy, ForeignKeyIR, IncludeIntent, IncludeStrategy, IndexColumnDef, IndexIR, IndexInfo, IndexMethod, InsertFromIntent, InsertIntent, IntrospectingAdapter, IsTypeSupported, JoinDefault, JoinIntent, LiteralExpressionIntent, LogicalOperator, MSSQLColumnType, ModelIR, MutationIntent, MySQLColumnType, NullOperator, NullsPosition, OffsetWindowFunction, OnDeleteAction, Optionality, OrderByIntent, PartitionIR, PlanDecision, PlanOptions, PlanReport, PlanWarning, PlanWarningCode, PostgresColumnType, PostgresOnlyColumnType, PseudoColumnExpressionIntent, PseudoColumnMetadata, PseudoColumnTraversal, QueryIntent, RangeOperator, RangeValue, RankingWindowFunction, RawExpressionIntent, RawSqlAdapter, RecursiveAdvancedOptions, RecursiveDedupe, RecursiveDirection, RecursiveEmitOptions, RecursiveExistsOptions, RecursiveIntent, RecursiveMetadata, RecursiveNodeIdExpr, RecursivePlanOptions, RecursivePlanReport, RecursiveTrackOptions, RecursiveTraversal, RelationColumnIntent, RelationIR, RelationKind, RelationOperator, RelationType, ResolvedIncludeStrategy, SQLiteColumnType, SelectAggregateIntent, SelectAllIntent, SelectFieldsIntent, SelectIntent, SelectWithExpressionsIntent, SortDirection, StreamingAdapter, StringOperator, SubqueryIncludeInfo, SubqueryRefIntent, SupportedColumnTypes, TableIR, TransactionalAdapter, TruncateOptions, UpdateIntent, UpsertConflictAction, UpsertConflictTarget, UpsertFromIntent, UpsertIntent, VacuumOptions, WhereAndIntent, WhereAnyIntent, WhereComparisonIntent, WhereExistsIntent, WhereInIntent, WhereIntent, WhereLikeIntent, WhereNotExistsIntent, WhereNotIntent, WhereNullIntent, WhereOrIntent, WhereRangeIntent, WhereRelationFilterIntent, WhereSubqueryIntent, WindowFunction, WindowIntent, WindowOrderBy, getNodeIdAlias, isAdjacencyTraversal, isAggregateWindowFunction, isCoalesceExpression, isColumnAliasExpression, isCustomTraversal, isDeleteIntent, isEdgeTableTraversal, isInsertIntent, isMutationIntent, isRankingWindowFunction, isRawExpression, isRecursiveIntent, isRelationColumnExpression, isSelectAggregate, isSelectAll, isSelectFields, isSelectWithExpressions, isSubqueryRef, isUpdateIntent, isUpsertIntent, isWhereAnd, isWhereAny, isWhereComparison, isWhereExists, isWhereIn, isWhereLike, isWhereLogical, isWhereNot, isWhereNotExists, isWhereNull, isWhereOr, isWhereRange, isWhereRelationBased, isWhereRelationFilter, isWhereSubquery, isWindowIntent } from '@dbsp/types';
4
4
  import { NqlCompilerOptions } from '@dbsp/nql';
5
- import * as v from 'valibot';
6
5
 
7
6
  /**
8
7
  * @module model-ir
@@ -560,12 +559,12 @@ declare function isAliasedColumn(value: unknown): value is AliasedColumn<string,
560
559
  * Supported column types in schema definitions.
561
560
  * Matches SchemaColumnType from schema.ts.
562
561
  */
563
- type SchemaColumnType$2 = 'string' | 'text' | 'uuid' | 'number' | 'integer' | 'decimal' | 'bigint' | 'boolean' | 'date' | 'time' | 'datetime' | 'timestamp' | 'json' | 'jsonb' | 'daterange' | 'tsrange' | 'tstzrange' | 'int4range' | 'int8range' | 'numrange';
562
+ type SchemaColumnType$1 = 'string' | 'text' | 'uuid' | 'number' | 'integer' | 'decimal' | 'bigint' | 'boolean' | 'date' | 'time' | 'datetime' | 'timestamp' | 'json' | 'jsonb' | 'daterange' | 'tsrange' | 'tstzrange' | 'int4range' | 'int8range' | 'numrange';
564
563
  /**
565
564
  * Column definition - short form or long form.
566
565
  */
567
- type ColumnDef$1 = SchemaColumnType$2 | {
568
- type: SchemaColumnType$2;
566
+ type ColumnDef$1 = SchemaColumnType$1 | {
567
+ type: SchemaColumnType$1;
569
568
  nullable?: boolean;
570
569
  unique?: boolean;
571
570
  primaryKey?: boolean;
@@ -609,8 +608,8 @@ type IsRef<T> = T extends {
609
608
  /**
610
609
  * Extract the column type from a ColumnDef.
611
610
  */
612
- type ExtractColumnType$1<C> = C extends SchemaColumnType$2 ? C : C extends {
613
- type: infer T extends SchemaColumnType$2;
611
+ type ExtractColumnType$1<C> = C extends SchemaColumnType$1 ? C : C extends {
612
+ type: infer T extends SchemaColumnType$1;
614
613
  } ? T : never;
615
614
  /**
616
615
  * Check if a column is nullable.
@@ -621,7 +620,7 @@ type IsNullable$1<C> = C extends {
621
620
  /**
622
621
  * Map schema column types to TypeScript types.
623
622
  */
624
- type MapColumnTypeToTS<T extends SchemaColumnType$2> = T extends 'string' | 'text' | 'uuid' ? string : T extends 'number' | 'integer' | 'decimal' ? number : T extends 'bigint' ? bigint : T extends 'boolean' ? boolean : T extends 'date' | 'time' | 'datetime' | 'timestamp' ? Date : T extends 'json' | 'jsonb' ? unknown : T extends 'daterange' | 'tsrange' | 'tstzrange' | 'int4range' | 'int8range' | 'numrange' ? unknown : unknown;
623
+ type MapColumnTypeToTS<T extends SchemaColumnType$1> = T extends 'string' | 'text' | 'uuid' ? string : T extends 'number' | 'integer' | 'decimal' ? number : T extends 'bigint' ? bigint : T extends 'boolean' ? boolean : T extends 'date' | 'time' | 'datetime' | 'timestamp' ? Date : T extends 'json' | 'jsonb' ? unknown : T extends 'daterange' | 'tsrange' | 'tstzrange' | 'int4range' | 'int8range' | 'numrange' ? unknown : unknown;
625
624
  /**
626
625
  * Infer the TypeScript type for a column definition.
627
626
  */
@@ -659,13 +658,13 @@ type GetRefTarget<TRef> = TRef extends {
659
658
  /**
660
659
  * Infer the row type for a table (used for relation target types).
661
660
  */
662
- type InferRowType$1<TTable extends TableDef$1> = {
661
+ type InferRowType<TTable extends TableDef$1> = {
663
662
  [K in keyof ExtractColumns<TTable> as K extends string ? K : never]: InferColumnTSType<TTable[K]>;
664
663
  };
665
664
  /**
666
665
  * Build RelationRef for a local relation (belongsTo - FK in this table).
667
666
  */
668
- type BuildLocalRelation<_TColName extends string, TRef extends RefDefinition$1, TSchema extends SchemaDefinition$1> = GetRefTarget<TRef> extends keyof TSchema ? RelationRef<GetRefTarget<TRef> & string, InferRowType$1<TSchema[GetRefTarget<TRef>]> | null, 'belongsTo', InferRowType$1<TSchema[GetRefTarget<TRef>]>> : never;
667
+ type BuildLocalRelation<_TColName extends string, TRef extends RefDefinition$1, TSchema extends SchemaDefinition$1> = GetRefTarget<TRef> extends keyof TSchema ? RelationRef<GetRefTarget<TRef> & string, InferRowType<TSchema[GetRefTarget<TRef>]> | null, 'belongsTo', InferRowType<TSchema[GetRefTarget<TRef>]>> : never;
669
668
  /**
670
669
  * Build local relations (belongsTo) for a table.
671
670
  */
@@ -682,7 +681,7 @@ type FindInverseRelations<TName extends string, TSchema extends SchemaDefinition
682
681
  inverse: infer I extends string;
683
682
  };
684
683
  } ? I : TTable extends `${string}s` ? TTable : `${TTable & string}s` : never : never;
685
- }[keyof TSchema[TTable]] : never]: TTable extends string ? RelationRef<TTable, Array<InferRowType$1<TSchema[TTable]>>, 'hasMany', InferRowType$1<TSchema[TTable]>> : never;
684
+ }[keyof TSchema[TTable]] : never]: TTable extends string ? RelationRef<TTable, Array<InferRowType<TSchema[TTable]>>, 'hasMany', InferRowType<TSchema[TTable]>> : never;
686
685
  };
687
686
  /**
688
687
  * Combine local and inverse relations for a table.
@@ -717,8 +716,8 @@ type InferTables<TSchema extends SchemaDefinition$1> = {
717
716
  /**
718
717
  * ARCH-005: Unified Schema API
719
718
  *
720
- * Replaces defineSchema(), TypedSchema, and GeneratedSchema with a single
721
- * schema() + ref() API. Relations are auto-inferred from FK declarations.
719
+ * Provides the schema() + ref() API. Relations are auto-inferred from FK
720
+ * declarations.
722
721
  *
723
722
  * @example
724
723
  * ```typescript
@@ -735,12 +734,12 @@ type InferTables<TSchema extends SchemaDefinition$1> = {
735
734
  * Supported column types in schema definitions.
736
735
  * Maps to ColumnType from ModelIR.
737
736
  */
738
- type SchemaColumnType$1 = ColumnType;
737
+ type SchemaColumnType = ColumnType;
739
738
  /**
740
739
  * Column definition - short form (just type) or long form (with options).
741
740
  */
742
- type ColumnDef = SchemaColumnType$1 | {
743
- type: SchemaColumnType$1;
741
+ type ColumnDef = SchemaColumnType | {
742
+ type: SchemaColumnType;
744
743
  dbType?: string;
745
744
  nullable?: boolean;
746
745
  unique?: boolean;
@@ -843,17 +842,36 @@ interface SchemaIndexOptions {
843
842
  columns: string[];
844
843
  /** Whether this is a unique index */
845
844
  unique?: boolean;
845
+ /**
846
+ * PG15+ — for a UNIQUE index, treat NULLs as not distinct
847
+ * (`NULLS NOT DISTINCT`); true is rejected for non-unique indexes. Emitted
848
+ * as declared; coherent server-version capability gating for all index
849
+ * features is tracked together in #245.
850
+ */
851
+ nullsNotDistinct?: boolean;
846
852
  /** Custom index name (auto-generated if not provided) */
847
853
  name?: string;
848
854
  /** Index access method (default: btree). E.g. 'gin', 'gist', 'hnsw', 'bm25' */
849
855
  method?: string;
850
856
  /** Partial index predicate (WHERE clause) */
851
857
  where?: string;
858
+ /**
859
+ * Non-key columns to include (INCLUDE clause, PG11+).
860
+ * Emitted as declared; coherent server-version capability gating for all
861
+ * index features is tracked together in #245.
862
+ */
863
+ include?: string[];
852
864
  /** Per-column operator class overrides. Key = column name, value = opclass name */
853
865
  opclass?: Record<string, string>;
854
866
  /** Index storage parameters (WITH clause). Key = param name, value = param value */
855
867
  with?: Record<string, string>;
856
868
  }
869
+ interface SchemaIndexValidationInput {
870
+ readonly columns: readonly string[];
871
+ readonly unique?: boolean;
872
+ readonly nullsNotDistinct?: boolean;
873
+ readonly name?: string;
874
+ }
857
875
  interface SchemaTableOptions {
858
876
  /** Indexes for this table (simple, composite, partial, GIN, HNSW, BM25, etc.) */
859
877
  indexes?: SchemaIndexOptions[];
@@ -1022,12 +1040,12 @@ interface InferredRangeValue<T> {
1022
1040
  /**
1023
1041
  * Maps a ColumnType string to its TypeScript type.
1024
1042
  */
1025
- type InferColumnType<T extends SchemaColumnType$1> = T extends 'string' | 'text' | 'uuid' ? string : T extends 'number' | 'integer' | 'decimal' ? number : T extends 'bigint' ? bigint : T extends 'boolean' ? boolean : T extends 'date' | 'time' | 'datetime' | 'timestamp' ? Date : T extends 'json' | 'jsonb' ? JsonValue : T extends 'daterange' ? InferredRangeValue<Date> : T extends 'tsrange' | 'tstzrange' ? InferredRangeValue<Date> : T extends 'int4range' | 'int8range' ? InferredRangeValue<number> : T extends 'numrange' ? InferredRangeValue<number> : unknown;
1043
+ type InferColumnType<T extends SchemaColumnType> = T extends 'string' | 'text' | 'uuid' ? string : T extends 'number' | 'integer' | 'decimal' ? number : T extends 'bigint' ? bigint : T extends 'boolean' ? boolean : T extends 'date' | 'time' | 'datetime' | 'timestamp' ? Date : T extends 'json' | 'jsonb' ? JsonValue : T extends 'daterange' ? InferredRangeValue<Date> : T extends 'tsrange' | 'tstzrange' ? InferredRangeValue<Date> : T extends 'int4range' | 'int8range' ? InferredRangeValue<number> : T extends 'numrange' ? InferredRangeValue<number> : unknown;
1026
1044
  /**
1027
1045
  * Extracts the type string from a ColumnDef (handles short and long forms).
1028
1046
  */
1029
- type ExtractColumnType<C extends ColumnDef> = C extends SchemaColumnType$1 ? C : C extends {
1030
- type: infer T extends SchemaColumnType$1;
1047
+ type ExtractColumnType<C extends ColumnDef> = C extends SchemaColumnType ? C : C extends {
1048
+ type: infer T extends SchemaColumnType;
1031
1049
  } ? T : never;
1032
1050
  /**
1033
1051
  * Checks if a ColumnDef is nullable.
@@ -1156,11 +1174,12 @@ declare function schema<T extends SchemaDefinition>(definition: T, constraints?:
1156
1174
  /**
1157
1175
  * Validation error during schema conversion.
1158
1176
  */
1159
- declare class SchemaValidationError$1 extends Error {
1177
+ declare class SchemaValidationError extends Error {
1160
1178
  readonly table?: string | undefined;
1161
1179
  readonly column?: string | undefined;
1162
1180
  constructor(message: string, table?: string | undefined, column?: string | undefined);
1163
1181
  }
1182
+ declare function validateSchemaIndexOptions(tableName: string, idx: SchemaIndexValidationInput): void;
1164
1183
  /**
1165
1184
  * Converts a schema definition to ModelIR.
1166
1185
  *
@@ -1212,339 +1231,8 @@ interface IntrospectableAdapter {
1212
1231
  declare function getSchemaFromDb<T extends SchemaDefinition = SchemaDefinition>(adapter: IntrospectableAdapter, options?: GetSchemaFromDbOptions): Promise<Schema<T>>;
1213
1232
 
1214
1233
  /**
1215
- * Schema DSL Types
1216
- *
1217
- * Input types for defineSchema() - the user-facing schema definition DSL.
1218
- * These types are simpler than the IR types and serve as the "source of truth"
1219
- * for schema definitions before they're processed into ModelIR.
1220
- *
1221
- * Migrated from @dbsp/schema/types.ts as part of ARCH-003.
1222
- */
1223
-
1224
- /**
1225
- * Supported column types in the schema DSL.
1226
- * Maps to database types during DDL generation.
1227
- */
1228
- type SchemaColumnType = 'uuid' | 'string' | 'text' | 'integer' | 'bigint' | 'decimal' | 'boolean' | 'timestamp' | 'date' | 'time' | 'json' | 'jsonb' | 'daterange' | 'tsrange' | 'tstzrange' | 'int4range' | 'int8range' | 'numrange';
1229
- /** Foreign key delete behavior */
1230
- type SchemaOnDeleteAction = 'CASCADE' | 'SET NULL' | 'RESTRICT' | 'NO ACTION';
1231
- /**
1232
- * Foreign key reference definition.
1233
- * When present, takes priority over convention-based FK detection.
1234
- */
1235
- interface SchemaForeignKeyReference {
1236
- /** Target schema name (omit for same-schema references) */
1237
- readonly schema?: string;
1238
- /** Target table name */
1239
- table: string;
1240
- /** Target column name (defaults to 'id') */
1241
- column?: string;
1242
- /** Delete behavior (CASCADE, SET NULL, RESTRICT, NO ACTION) */
1243
- onDelete?: SchemaOnDeleteAction;
1244
- /**
1245
- * Custom role name for parent direction in self-referential FKs.
1246
- * Required when table has multiple self-referential FKs.
1247
- * Example: parentRole: 'manager' for managerId FK
1248
- * @default 'parent' (for single self-ref FK)
1249
- */
1250
- parentRole?: string;
1251
- /**
1252
- * Custom role name for child direction in self-referential FKs.
1253
- * Required when table has multiple self-referential FKs.
1254
- * Example: childRole: 'subordinates' for managerId FK
1255
- * @default 'children' or pluralized parentRole (for single self-ref FK)
1256
- */
1257
- childRole?: string;
1258
- }
1259
- /**
1260
- * Column definition in the schema DSL.
1261
- */
1262
- interface SchemaColumnDefinition {
1263
- /** Column data type */
1264
- type: SchemaColumnType;
1265
- /** Whether the column is the primary key */
1266
- primaryKey?: boolean;
1267
- /** Whether the column allows NULL values */
1268
- nullable?: boolean;
1269
- /** Whether the column has a unique constraint */
1270
- unique?: boolean;
1271
- /** Default value (e.g., 'now()', 'gen_random_uuid()', 0, true) */
1272
- default?: string | number | boolean;
1273
- /** Explicit foreign key reference (takes priority over conventions) */
1274
- references?: SchemaForeignKeyReference;
1275
- /** Create an index on this column (true for auto-name, string for custom name) */
1276
- index?: boolean | string;
1277
- }
1278
- /**
1279
- * Table definition: mapping of column names to their definitions.
1234
+ * Naming and self-reference convention helpers.
1280
1235
  */
1281
- type SchemaTableDefinition = Record<string, SchemaColumnDefinition>;
1282
- /**
1283
- * All tables in the schema.
1284
- */
1285
- type SchemaTablesDefinition = Record<string, SchemaTableDefinition>;
1286
- /**
1287
- * Index definition for composite indexes.
1288
- */
1289
- interface SchemaIndexDefinition {
1290
- /** Columns included in the index */
1291
- columns: string[];
1292
- /** Whether this is a unique index */
1293
- unique?: boolean;
1294
- /** Custom index name (auto-generated if not provided) */
1295
- name?: string;
1296
- }
1297
- /**
1298
- * Index configuration by table.
1299
- */
1300
- type SchemaIndexesDefinition = Record<string, SchemaIndexDefinition[]>;
1301
- /**
1302
- * Relation kinds for discriminated union.
1303
- */
1304
- type SchemaRelationKind = 'belongsTo' | 'hasMany' | 'manyToMany';
1305
- /**
1306
- * Strategy for including related data in queries.
1307
- * - 'join': Use SQL JOIN (default for belongsTo)
1308
- * - 'subquery': Execute subquery query
1309
- * - 'cte': Use Common Table Expression
1310
- * - 'lateral': Use LATERAL JOIN
1311
- * - 'json_agg': Use JSON aggregation
1312
- * - 'auto': Let planner decide based on relation type
1313
- */
1314
- type SchemaIncludeStrategy = 'join' | 'subquery' | 'cte' | 'lateral' | 'json_agg' | 'auto';
1315
- /**
1316
- * Base properties shared by all relation types.
1317
- */
1318
- interface SchemaRelationBase {
1319
- /** Target table name */
1320
- target: string;
1321
- /** Include strategy hint for the planner */
1322
- includeStrategy?: SchemaIncludeStrategy;
1323
- }
1324
- /**
1325
- * BelongsTo relation: source table has FK to target table.
1326
- * Example: posts.author → users (posts.authorId references users.id)
1327
- */
1328
- interface SchemaBelongsToRelation extends SchemaRelationBase {
1329
- kind: 'belongsTo';
1330
- /** Foreign key column in the source table */
1331
- foreignKey: string;
1332
- /** Target column (defaults to 'id') */
1333
- targetKey?: string;
1334
- }
1335
- /**
1336
- * HasMany relation: target table has FK to source table.
1337
- * Example: users.posts → posts (posts.authorId references users.id)
1338
- */
1339
- interface SchemaHasManyRelation extends SchemaRelationBase {
1340
- kind: 'hasMany';
1341
- /** Foreign key column in the target table */
1342
- foreignKey: string;
1343
- /** Source column (defaults to 'id') */
1344
- sourceKey?: string;
1345
- }
1346
- /**
1347
- * ManyToMany relation: junction table connects source and target.
1348
- * Example: posts ↔ categories via post_categories
1349
- */
1350
- interface SchemaManyToManyRelation extends SchemaRelationBase {
1351
- kind: 'manyToMany';
1352
- /** Junction table name */
1353
- through: string;
1354
- /** FK column in junction pointing to source */
1355
- sourceFk: string;
1356
- /** FK column in junction pointing to target */
1357
- targetFk: string;
1358
- }
1359
- /**
1360
- * Union of all relation types.
1361
- * Use `kind` field for type narrowing.
1362
- */
1363
- type SchemaRelationDefinition = SchemaBelongsToRelation | SchemaHasManyRelation | SchemaManyToManyRelation;
1364
- /**
1365
- * Explicit relations mapping.
1366
- * Keys are 'sourceTable.relationName' format.
1367
- */
1368
- type SchemaRelationsDefinition = Record<string, SchemaRelationDefinition>;
1369
- /**
1370
- * Strategy hint for filtering on to-many relations.
1371
- */
1372
- type SchemaFilterStrategy = 'exists' | 'join';
1373
- /**
1374
- * Cardinality hint for relation traversal.
1375
- */
1376
- type SchemaCardinality = 'one' | 'many';
1377
- /**
1378
- * Hint definition for a specific relation path.
1379
- */
1380
- interface SchemaHintDefinition {
1381
- /** Preferred filter strategy */
1382
- defaultStrategy?: SchemaFilterStrategy;
1383
- /** Expected cardinality */
1384
- cardinality?: SchemaCardinality;
1385
- }
1386
- /**
1387
- * All hints, keyed by 'table.relation' path.
1388
- */
1389
- type SchemaHintsDefinition = Record<string, SchemaHintDefinition>;
1390
- /**
1391
- * Convention settings for automatic FK detection and naming.
1392
- */
1393
- interface SchemaConventionsDefinition {
1394
- /**
1395
- * Pattern for foreign key column names.
1396
- * {singular} is replaced with singular table name.
1397
- * @default '{singular}Id'
1398
- */
1399
- fkPattern?: string;
1400
- /**
1401
- * Whether to auto-pluralize relation names.
1402
- * @default true
1403
- */
1404
- pluralize?: boolean;
1405
- /**
1406
- * Column names recognized as timestamps.
1407
- * @default ['createdAt', 'updatedAt']
1408
- */
1409
- timestamps?: string[];
1410
- /**
1411
- * Automatically create indexes on foreign key columns.
1412
- * FK columns are frequently used in JOINs, so indexing is a best practice.
1413
- * @default true
1414
- */
1415
- fkAutoIndex?: boolean;
1416
- }
1417
- /**
1418
- * Complete schema definition input for defineSchema() wrapped form.
1419
- * Prefer the new hybrid API: defineSchema(tables, config?)
1420
- */
1421
- interface SchemaDefinitionInput<T extends SchemaTablesDefinition = SchemaTablesDefinition> {
1422
- /** Table definitions */
1423
- tables: T;
1424
- /** Explicit relation definitions (override auto-detected) */
1425
- relations?: SchemaRelationsDefinition;
1426
- /** Planner hints */
1427
- hints?: SchemaHintsDefinition;
1428
- /** Convention configuration */
1429
- conventions?: SchemaConventionsDefinition;
1430
- }
1431
- /**
1432
- * Per-table default filters applied to all queries.
1433
- * Commonly used for soft delete filtering.
1434
- */
1435
- type SchemaDefaultFilters = {
1436
- [tableName: string]: WhereIntent;
1437
- };
1438
- /**
1439
- * Configuration options for defineSchema (new API).
1440
- */
1441
- interface SchemaConfigInput {
1442
- /** Explicit relation definitions (override auto-detected) */
1443
- relations?: SchemaRelationsDefinition;
1444
- /** Planner hints */
1445
- hints?: SchemaHintsDefinition;
1446
- /** Convention configuration */
1447
- conventions?: SchemaConventionsDefinition;
1448
- /** Table-level index definitions (composite indexes) */
1449
- indexes?: SchemaIndexesDefinition;
1450
- /**
1451
- * Default filters applied automatically to all queries on each table.
1452
- * Use for soft delete (`isNull('deletedAt')`), multi-tenant, or active filtering.
1453
- * Override per-query with `.withoutDefaultFilters()`.
1454
- */
1455
- defaultFilters?: SchemaDefaultFilters;
1456
- }
1457
- /**
1458
- * Resolved schema with all relations (explicit + inferred).
1459
- * This is the output of defineSchema().
1460
- */
1461
- interface ResolvedSchema<T extends SchemaTablesDefinition = SchemaTablesDefinition> {
1462
- /** Original table definitions */
1463
- tables: T;
1464
- /** All relations (explicit + auto-detected) */
1465
- relations: SchemaRelationsDefinition;
1466
- /** Planner hints */
1467
- hints: SchemaHintsDefinition;
1468
- /** Resolved conventions with defaults applied */
1469
- conventions: Required<SchemaConventionsDefinition>;
1470
- /** Table-level index definitions */
1471
- indexes: SchemaIndexesDefinition;
1472
- /** Default filters per table (e.g., soft delete) */
1473
- defaultFilters: SchemaDefaultFilters;
1474
- }
1475
- /**
1476
- * Type guard for BelongsTo relation.
1477
- */
1478
- declare function isBelongsTo(rel: SchemaRelationDefinition): rel is SchemaBelongsToRelation;
1479
- /**
1480
- * Type guard for HasMany relation.
1481
- */
1482
- declare function isHasMany(rel: SchemaRelationDefinition): rel is SchemaHasManyRelation;
1483
- /**
1484
- * Type guard for ManyToMany relation.
1485
- */
1486
- declare function isManyToMany(rel: SchemaRelationDefinition): rel is SchemaManyToManyRelation;
1487
-
1488
- /**
1489
- * Schema DSL - defineSchema() function
1490
- *
1491
- * Main entry point for defining the schema Source of Truth.
1492
- * Merges explicit definitions with convention-inferred relations.
1493
- *
1494
- * Migrated from @dbsp/schema/define.ts as part of ARCH-003.
1495
- */
1496
-
1497
- /**
1498
- * Define a schema with tables, relations, hints, and conventions.
1499
- *
1500
- * @example Simple - just tables
1501
- * ```typescript
1502
- * const schema = defineSchema({
1503
- * users: {
1504
- * id: { type: 'uuid', primaryKey: true },
1505
- * name: { type: 'string', nullable: false },
1506
- * },
1507
- * posts: {
1508
- * id: { type: 'uuid', primaryKey: true },
1509
- * authorId: { type: 'uuid', references: { table: 'users' } },
1510
- * },
1511
- * });
1512
- * ```
1513
- *
1514
- * @example With config
1515
- * ```typescript
1516
- * const schema = defineSchema(
1517
- * {
1518
- * users: { id: { type: 'uuid', primaryKey: true } },
1519
- * roles: { id: { type: 'uuid', primaryKey: true } },
1520
- * },
1521
- * {
1522
- * relations: {...}
1523
- * }
1524
- * );
1525
- * ```
1526
- */
1527
- declare function defineSchema<T extends SchemaTablesDefinition>(tables: T, config?: SchemaConfigInput): ResolvedSchema<T>;
1528
- /**
1529
- * Error thrown when schema validation fails.
1530
- */
1531
- declare class SchemaValidationError extends Error {
1532
- constructor(message: string);
1533
- }
1534
-
1535
- /**
1536
- * Schema Convention Inference
1537
- *
1538
- * Detects foreign keys and M:N relations using:
1539
- * 1. Explicit `references` (highest priority)
1540
- * 2. Convention patterns (fallback)
1541
- *
1542
- * M:N auto-detection: tables with exactly 2 FKs and no business columns.
1543
- *
1544
- * Migrated from @dbsp/schema/conventions.ts as part of ARCH-003.
1545
- */
1546
-
1547
- declare const DEFAULT_CONVENTIONS: Required<SchemaConventionsDefinition>;
1548
1236
  /**
1549
1237
  * Convert table name to singular form.
1550
1238
  * Simple heuristic: remove trailing 's' if present.
@@ -1574,49 +1262,6 @@ declare function capitalize(name: string): string;
1574
1262
  * Decapitalize first letter.
1575
1263
  */
1576
1264
  declare function decapitalize(name: string): string;
1577
- interface DetectedFK {
1578
- /** Column name in source table */
1579
- column: string;
1580
- /** Target table name */
1581
- targetTable: string;
1582
- /** Inferred relation name (e.g., 'author' from 'authorId') */
1583
- inferredName: string;
1584
- /** Whether this was explicitly defined via `references` */
1585
- explicit: boolean;
1586
- /** Target column (from references.column or default 'id') */
1587
- targetColumn: string;
1588
- /** Custom parent role for self-ref FKs (from parentRole or inferred) */
1589
- parentRole?: string;
1590
- /** Custom child role for self-ref FKs (from childRole or inferred) */
1591
- childRole?: string;
1592
- }
1593
- /**
1594
- * Detect foreign keys in a table.
1595
- * Priority: explicit `references` > convention pattern.
1596
- */
1597
- declare function detectForeignKeys(tableName: string, table: SchemaTableDefinition, conventions: Required<SchemaConventionsDefinition>, tableNames: Set<string>): DetectedFK[];
1598
- interface DetectedManyToMany {
1599
- /** Junction table name */
1600
- junction: string;
1601
- /** First table in the M:N relation */
1602
- tableA: string;
1603
- /** Second table in the M:N relation */
1604
- tableB: string;
1605
- /** FK column pointing to tableA */
1606
- fkA: string;
1607
- /** FK column pointing to tableB */
1608
- fkB: string;
1609
- }
1610
- /**
1611
- * Detect pure M:N junction tables.
1612
- * Criteria: exactly 2 FK columns, no business columns.
1613
- */
1614
- declare function detectManyToMany(tables: SchemaTablesDefinition, conventions: Required<SchemaConventionsDefinition>, tableNames: Set<string>): DetectedManyToMany[];
1615
- /**
1616
- * Infer all relations from table definitions.
1617
- * Returns a map of 'sourceTable.relationName' → RelationDefinition.
1618
- */
1619
- declare function inferRelationsFromSchema(tables: SchemaTablesDefinition, conventions: Required<SchemaConventionsDefinition>, explicitRelations?: SchemaRelationsDefinition): SchemaRelationsDefinition;
1620
1265
 
1621
1266
  /**
1622
1267
  * @module planner
@@ -4220,401 +3865,6 @@ declare class RawCteQueryBuilder<TResult = unknown> {
4220
3865
  */
4221
3866
  declare function createRawCteBuilder<TResult = unknown>(cteName: string, options: RecursiveOptions, adapter?: Adapter, schemaName?: string): RawCteQueryBuilder<TResult>;
4222
3867
 
4223
- /**
4224
- * ARCH-002 Block 6: Schema Bridge
4225
- *
4226
- * Converts generated schema (from dbsp generate manifest) to ModelIR.
4227
- * This enables sync createOrm usage with codegen-first schemas.
4228
- */
4229
-
4230
- /**
4231
- * Column type in generated schema.
4232
- */
4233
- type GeneratedColumnType = 'string' | 'text' | 'number' | 'integer' | 'bigint' | 'decimal' | 'boolean' | 'date' | 'timestamp' | 'datetime' | 'time' | 'json' | 'jsonb' | 'uuid' | 'daterange' | 'tstzrange' | 'int4range' | 'tsrange' | 'int8range' | 'numrange';
4234
- /**
4235
- * Column definition in generated schema.
4236
- */
4237
- interface GeneratedColumn {
4238
- readonly type: GeneratedColumnType;
4239
- readonly primaryKey?: boolean;
4240
- readonly nullable?: boolean;
4241
- readonly unique?: boolean;
4242
- readonly autoIncrement?: boolean;
4243
- readonly default?: string;
4244
- readonly references?: {
4245
- readonly schema?: string;
4246
- readonly table: string;
4247
- readonly column?: string;
4248
- readonly onDelete?: OnDeleteAction;
4249
- /** Create an index on this FK column (matches ColumnDefinitionSchema index field) */
4250
- readonly index?: boolean;
4251
- /** Role name for parent traversal in self-ref hierarchies (e.g., 'parent') */
4252
- readonly parentRole?: string;
4253
- /** Role name for child traversal in self-ref hierarchies (e.g., 'children') */
4254
- readonly childRole?: string;
4255
- };
4256
- /** Create an index on this column (true for auto-name, string for custom name) */
4257
- readonly index?: boolean | string;
4258
- }
4259
- /**
4260
- * Table definition in generated schema.
4261
- */
4262
- interface GeneratedForeignKey {
4263
- readonly columns: readonly string[];
4264
- readonly references: {
4265
- readonly schema?: string;
4266
- readonly table: string;
4267
- readonly columns: readonly string[];
4268
- };
4269
- readonly onDelete?: OnDeleteAction;
4270
- readonly onUpdate?: OnDeleteAction;
4271
- }
4272
- interface GeneratedIndex {
4273
- readonly columns: readonly string[];
4274
- readonly unique?: boolean;
4275
- readonly name?: string;
4276
- }
4277
- interface GeneratedTableWithConfig {
4278
- readonly columns: Record<string, GeneratedColumn>;
4279
- readonly primaryKey?: string | readonly string[];
4280
- readonly foreignKeys?: readonly GeneratedForeignKey[];
4281
- readonly indexes?: readonly GeneratedIndex[];
4282
- }
4283
- type GeneratedFlatTable = Record<string, GeneratedColumn>;
4284
- type GeneratedTable = GeneratedFlatTable | GeneratedTableWithConfig;
4285
- /**
4286
- * Relation kind in generated schema (discriminated union).
4287
- */
4288
- type GeneratedRelationKind = 'belongsTo' | 'hasMany' | 'manyToMany';
4289
- /**
4290
- * Include strategy for relations.
4291
- */
4292
- type GeneratedIncludeStrategy = 'join' | 'subquery' | 'cte' | 'lateral' | 'json_agg' | 'auto';
4293
- /**
4294
- * BelongsTo relation in generated schema.
4295
- */
4296
- interface GeneratedBelongsTo {
4297
- readonly kind: 'belongsTo';
4298
- readonly target: string;
4299
- readonly foreignKey: string | readonly string[];
4300
- readonly targetKey?: string | readonly string[];
4301
- readonly includeStrategy?: GeneratedIncludeStrategy;
4302
- }
4303
- /**
4304
- * HasMany relation in generated schema.
4305
- */
4306
- interface GeneratedHasMany {
4307
- readonly kind: 'hasMany';
4308
- readonly target: string;
4309
- readonly foreignKey: string | readonly string[];
4310
- readonly sourceKey?: string | readonly string[];
4311
- readonly includeStrategy?: GeneratedIncludeStrategy;
4312
- readonly cardinality?: 'one' | 'many';
4313
- }
4314
- /**
4315
- * ManyToMany relation in generated schema.
4316
- */
4317
- interface GeneratedManyToMany {
4318
- readonly kind: 'manyToMany';
4319
- readonly target: string;
4320
- readonly through: string;
4321
- readonly sourceFk: string;
4322
- readonly targetFk: string;
4323
- readonly includeStrategy?: GeneratedIncludeStrategy;
4324
- }
4325
- /**
4326
- * Relation definition in generated schema.
4327
- */
4328
- type GeneratedRelation = GeneratedBelongsTo | GeneratedHasMany | GeneratedManyToMany;
4329
- /**
4330
- * Hint definition in generated schema.
4331
- */
4332
- interface GeneratedHint {
4333
- readonly defaultStrategy?: 'exists' | 'join';
4334
- readonly cardinality?: 'one' | 'many';
4335
- }
4336
- /**
4337
- * Conventions in generated schema.
4338
- */
4339
- interface GeneratedConventions {
4340
- readonly fkPattern: string;
4341
- readonly pluralize: boolean;
4342
- readonly timestamps: readonly string[];
4343
- readonly fkAutoIndex: boolean;
4344
- }
4345
- /**
4346
- * Complete generated schema (output of dbsp generate manifest).
4347
- *
4348
- * @typeParam TTables - The tables type, preserving literal table names for autocomplete.
4349
- * When using `as const` on your schema definition, table names will be preserved.
4350
- *
4351
- * @example
4352
- * ```typescript
4353
- * const schema = {
4354
- * tables: {
4355
- * users: { id: { type: 'uuid', primaryKey: true }, name: { type: 'string' } },
4356
- * posts: { id: { type: 'uuid', primaryKey: true }, title: { type: 'string' } },
4357
- * },
4358
- * relations: {},
4359
- * hints: {},
4360
- * conventions: { fkPattern: '{singular}Id', pluralize: true, timestamps: [], fkAutoIndex: true },
4361
- * } as const satisfies GeneratedSchema;
4362
- *
4363
- * // TypeScript knows: keyof typeof schema.tables = 'users' | 'posts'
4364
- * ```
4365
- */
4366
- interface GeneratedSchema<TTables extends Record<string, GeneratedTable> = Record<string, GeneratedTable>> {
4367
- readonly tables: TTables;
4368
- readonly relations: Record<string, GeneratedRelation>;
4369
- readonly hints: Record<string, GeneratedHint>;
4370
- readonly conventions: GeneratedConventions;
4371
- }
4372
- /**
4373
- * Map a GeneratedColumnType to its TypeScript runtime type.
4374
- */
4375
- type ColumnTypeToTS<T extends GeneratedColumnType> = T extends 'string' | 'text' | 'uuid' ? string : T extends 'number' | 'integer' | 'decimal' ? number : T extends 'bigint' ? bigint : T extends 'boolean' ? boolean : T extends 'date' | 'timestamp' | 'datetime' ? Date : T extends 'time' ? string : T extends 'json' | 'jsonb' ? unknown : T extends 'daterange' | 'tstzrange' | 'int4range' | 'tsrange' | 'int8range' | 'numrange' ? string : never;
4376
- /**
4377
- * Infer the TypeScript row type from a GeneratedTable definition.
4378
- */
4379
- type GeneratedColumnsOf<T extends GeneratedTable> = T extends GeneratedTableWithConfig ? T['columns'] : T;
4380
- type InferRowType<T extends GeneratedTable> = {
4381
- [K in keyof GeneratedColumnsOf<T>]: GeneratedColumnsOf<T>[K] extends GeneratedColumn ? GeneratedColumnsOf<T>[K]['nullable'] extends true ? ColumnTypeToTS<GeneratedColumnsOf<T>[K]['type']> | null : ColumnTypeToTS<GeneratedColumnsOf<T>[K]['type']> : never;
4382
- };
4383
- /**
4384
- * Infer the database type from a GeneratedSchema.
4385
- * Maps each table name to its row type.
4386
- *
4387
- * @example
4388
- * ```typescript
4389
- * const schema = { tables: { users: { id: { type: 'uuid' } } } } as const satisfies GeneratedSchema;
4390
- * type DB = InferDBFromSchema<typeof schema>;
4391
- * // DB = { users: { id: string } }
4392
- * ```
4393
- */
4394
- type InferDBFromSchema<S extends GeneratedSchema> = {
4395
- [TableName in keyof S['tables'] & string]: InferRowType<S['tables'][TableName]>;
4396
- };
4397
- /**
4398
- * Build a ModelIR from a generated schema.
4399
- *
4400
- * This is the main entry point for the schema bridge.
4401
- * It converts the output of `dbsp generate manifest` into a ModelIR
4402
- * that can be used with createOrm.
4403
- *
4404
- * @example
4405
- * ```typescript
4406
- * import { schema } from './generated/dbsp/schema';
4407
- * import { buildModelFromSchema, createOrm } from '@dbsp/core';
4408
- *
4409
- * const model = buildModelFromSchema(schema);
4410
- * const orm = createOrm({ model, adapter });
4411
- * ```
4412
- */
4413
- declare function buildModelFromSchema(schema: GeneratedSchema): ModelIR;
4414
- /**
4415
- * Build ModelIR directly from ResolvedSchema.
4416
- *
4417
- * Combines the conversion steps: ResolvedSchema → GeneratedSchema → ModelIR.
4418
- * This is the canonical path for creating ModelIR from user-defined schemas.
4419
- *
4420
- * @example
4421
- * ```typescript
4422
- * import { defineSchema, buildModelFromResolvedSchema } from '@dbsp/core';
4423
- *
4424
- * const schema = defineSchema({ users: { ... } }, { relations: { ... } });
4425
- * const model = buildModelFromResolvedSchema(schema);
4426
- * ```
4427
- */
4428
- declare function buildModelFromResolvedSchema(schema: ResolvedSchema): ModelIR;
4429
- /**
4430
- * Type guard for GeneratedSchema.
4431
- *
4432
- * Note: Both GeneratedSchema and ResolvedSchema have the same structure,
4433
- * so this check will return true for both. Use `isResolvedSchema()` to
4434
- * specifically detect ResolvedSchema (from @dbsp/schema).
4435
- */
4436
- declare function isGeneratedSchema(value: unknown): value is GeneratedSchema;
4437
- /**
4438
- * Type guard for ResolvedSchema (from @dbsp/schema).
4439
- *
4440
- * Detects ResolvedSchema by checking for PostgreSQL-specific column types
4441
- * like 'time' and 'jsonb' that only exist in ResolvedSchema.
4442
- *
4443
- * Note: If the schema has no such types, this may return false even for
4444
- * a valid ResolvedSchema. In that case, the schema can be used directly
4445
- * as a GeneratedSchema since both have the same structure.
4446
- */
4447
- declare function isResolvedSchema(value: unknown): boolean;
4448
- /**
4449
- * Normalize a schema input to GeneratedSchema.
4450
- *
4451
- * This function accepts either a GeneratedSchema or a ResolvedSchema
4452
- * and returns a GeneratedSchema. If the input is already a GeneratedSchema,
4453
- * it is returned as-is. If it's a ResolvedSchema, it is converted.
4454
- *
4455
- * This is the recommended way to accept schemas in APIs that need to
4456
- * support both schema formats transparently.
4457
- *
4458
- * @param input - Either a GeneratedSchema or ResolvedSchema
4459
- * @returns GeneratedSchema (possibly converted from ResolvedSchema)
4460
- * @throws Error if the input is not a valid schema
4461
- *
4462
- * @example
4463
- * ```typescript
4464
- * import { normalizeSchema } from '@dbsp/core';
4465
- *
4466
- * // Works with GeneratedSchema (from codegen)
4467
- * const schema1 = normalizeSchema(generatedSchema);
4468
- *
4469
- * // Works with ResolvedSchema (from defineSchema())
4470
- * const schema2 = normalizeSchema(resolvedSchema);
4471
- * ```
4472
- */
4473
- declare function normalizeSchema(input: unknown): GeneratedSchema;
4474
- /**
4475
- * Complete ResolvedSchema validation schema
4476
- */
4477
- declare const ResolvedSchemaValidation: v.ObjectSchema<{
4478
- readonly tables: v.SchemaWithPipe<readonly [v.UnknownSchema, v.CheckAction<unknown, "Schema keys must not include prototype-pollution names (__proto__, constructor, prototype)">, v.RecordSchema<v.StringSchema<undefined>, v.UnionSchema<[v.ObjectSchema<{
4479
- readonly columns: v.SchemaWithPipe<readonly [v.UnknownSchema, v.CheckAction<unknown, "Schema keys must not include prototype-pollution names (__proto__, constructor, prototype)">, v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
4480
- readonly type: v.PicklistSchema<["uuid", "string", "text", "integer", "bigint", "decimal", "boolean", "timestamp", "date", "time", "json", "jsonb", "daterange", "tstzrange", "int4range", "tsrange", "int8range", "numrange"], undefined>;
4481
- readonly primaryKey: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
4482
- readonly nullable: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
4483
- readonly unique: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
4484
- readonly autoIncrement: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
4485
- readonly default: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.BooleanSchema<undefined>], undefined>, undefined>;
4486
- readonly references: v.OptionalSchema<v.ObjectSchema<{
4487
- readonly schema: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TransformAction<string, string | undefined>]>, undefined>;
4488
- readonly table: v.StringSchema<undefined>;
4489
- readonly column: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
4490
- readonly onDelete: v.OptionalSchema<v.PicklistSchema<readonly ["CASCADE", "SET NULL", "SET DEFAULT", "RESTRICT", "NO ACTION"], undefined>, undefined>;
4491
- readonly index: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
4492
- readonly parentRole: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
4493
- readonly childRole: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
4494
- }, undefined>, undefined>;
4495
- readonly index: v.OptionalSchema<v.UnionSchema<[v.BooleanSchema<undefined>, v.StringSchema<undefined>], undefined>, undefined>;
4496
- }, undefined>, undefined>]>;
4497
- readonly primaryKey: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>, undefined>;
4498
- readonly foreignKeys: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
4499
- readonly columns: v.ArraySchema<v.StringSchema<undefined>, undefined>;
4500
- readonly references: v.ObjectSchema<{
4501
- readonly schema: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TransformAction<string, string | undefined>]>, undefined>;
4502
- readonly table: v.StringSchema<undefined>;
4503
- readonly columns: v.ArraySchema<v.StringSchema<undefined>, undefined>;
4504
- }, undefined>;
4505
- readonly onDelete: v.OptionalSchema<v.PicklistSchema<readonly ["CASCADE", "SET NULL", "SET DEFAULT", "RESTRICT", "NO ACTION"], undefined>, undefined>;
4506
- readonly onUpdate: v.OptionalSchema<v.PicklistSchema<readonly ["CASCADE", "SET NULL", "SET DEFAULT", "RESTRICT", "NO ACTION"], undefined>, undefined>;
4507
- }, undefined>, undefined>, undefined>;
4508
- readonly indexes: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
4509
- readonly columns: v.ArraySchema<v.StringSchema<undefined>, undefined>;
4510
- readonly unique: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
4511
- readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
4512
- }, undefined>, undefined>, undefined>;
4513
- }, undefined>, v.SchemaWithPipe<readonly [v.UnknownSchema, v.CheckAction<unknown, "Schema keys must not include prototype-pollution names (__proto__, constructor, prototype)">, v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
4514
- readonly type: v.PicklistSchema<["uuid", "string", "text", "integer", "bigint", "decimal", "boolean", "timestamp", "date", "time", "json", "jsonb", "daterange", "tstzrange", "int4range", "tsrange", "int8range", "numrange"], undefined>;
4515
- readonly primaryKey: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
4516
- readonly nullable: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
4517
- readonly unique: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
4518
- readonly autoIncrement: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
4519
- readonly default: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.BooleanSchema<undefined>], undefined>, undefined>;
4520
- readonly references: v.OptionalSchema<v.ObjectSchema<{
4521
- readonly schema: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TransformAction<string, string | undefined>]>, undefined>;
4522
- readonly table: v.StringSchema<undefined>;
4523
- readonly column: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
4524
- readonly onDelete: v.OptionalSchema<v.PicklistSchema<readonly ["CASCADE", "SET NULL", "SET DEFAULT", "RESTRICT", "NO ACTION"], undefined>, undefined>;
4525
- readonly index: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
4526
- readonly parentRole: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
4527
- readonly childRole: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
4528
- }, undefined>, undefined>;
4529
- readonly index: v.OptionalSchema<v.UnionSchema<[v.BooleanSchema<undefined>, v.StringSchema<undefined>], undefined>, undefined>;
4530
- }, undefined>, undefined>]>], undefined>, undefined>]>;
4531
- readonly relations: v.SchemaWithPipe<readonly [v.UnknownSchema, v.CheckAction<unknown, "Schema keys must not include prototype-pollution names (__proto__, constructor, prototype)">, v.RecordSchema<v.StringSchema<undefined>, v.VariantSchema<"kind", [v.ObjectSchema<{
4532
- readonly kind: v.LiteralSchema<"belongsTo", undefined>;
4533
- readonly target: v.StringSchema<undefined>;
4534
- readonly foreignKey: v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>;
4535
- readonly targetKey: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>, undefined>;
4536
- readonly includeStrategy: v.OptionalSchema<v.PicklistSchema<["join", "subquery", "cte", "lateral", "json_agg", "auto"], undefined>, undefined>;
4537
- }, undefined>, v.ObjectSchema<{
4538
- readonly kind: v.LiteralSchema<"hasMany", undefined>;
4539
- readonly target: v.StringSchema<undefined>;
4540
- readonly foreignKey: v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>;
4541
- readonly sourceKey: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>], undefined>, undefined>;
4542
- readonly includeStrategy: v.OptionalSchema<v.PicklistSchema<["join", "subquery", "cte", "lateral", "json_agg", "auto"], undefined>, undefined>;
4543
- }, undefined>, v.ObjectSchema<{
4544
- readonly kind: v.LiteralSchema<"manyToMany", undefined>;
4545
- readonly target: v.StringSchema<undefined>;
4546
- readonly through: v.StringSchema<undefined>;
4547
- readonly sourceFk: v.StringSchema<undefined>;
4548
- readonly targetFk: v.StringSchema<undefined>;
4549
- readonly includeStrategy: v.OptionalSchema<v.PicklistSchema<["join", "subquery", "cte", "lateral", "json_agg", "auto"], undefined>, undefined>;
4550
- }, undefined>], undefined>, undefined>]>;
4551
- readonly hints: v.SchemaWithPipe<readonly [v.UnknownSchema, v.CheckAction<unknown, "Schema keys must not include prototype-pollution names (__proto__, constructor, prototype)">, v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
4552
- readonly defaultStrategy: v.OptionalSchema<v.PicklistSchema<["exists", "join"], undefined>, undefined>;
4553
- readonly cardinality: v.OptionalSchema<v.PicklistSchema<["one", "many"], undefined>, undefined>;
4554
- }, undefined>, undefined>]>;
4555
- readonly conventions: v.ObjectSchema<{
4556
- readonly fkPattern: v.StringSchema<undefined>;
4557
- readonly pluralize: v.BooleanSchema<undefined>;
4558
- readonly timestamps: v.ArraySchema<v.StringSchema<undefined>, undefined>;
4559
- readonly fkAutoIndex: v.BooleanSchema<undefined>;
4560
- }, undefined>;
4561
- readonly indexes: v.OptionalSchema<v.SchemaWithPipe<readonly [v.UnknownSchema, v.CheckAction<unknown, "Schema keys must not include prototype-pollution names (__proto__, constructor, prototype)">, v.RecordSchema<v.StringSchema<undefined>, v.ArraySchema<v.ObjectSchema<{
4562
- readonly columns: v.ArraySchema<v.StringSchema<undefined>, undefined>;
4563
- readonly unique: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
4564
- readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
4565
- }, undefined>, undefined>, undefined>]>, undefined>;
4566
- }, undefined>;
4567
- /**
4568
- * Type inferred from ResolvedSchemaValidation
4569
- */
4570
- type ValidatedResolvedSchema = v.InferOutput<typeof ResolvedSchemaValidation>;
4571
- /**
4572
- * Result of schema conversion.
4573
- */
4574
- type SchemaConversionResult = {
4575
- success: true;
4576
- schema: GeneratedSchema;
4577
- } | {
4578
- success: false;
4579
- errors: v.BaseIssue<unknown>[];
4580
- };
4581
- /**
4582
- * Convert a ResolvedSchema (from @dbsp/schema) to GeneratedSchema.
4583
- *
4584
- * This function validates the input using Valibot and then converts the
4585
- * schema structure to the format expected by createOrm().
4586
- *
4587
- * @param input - The ResolvedSchema to convert (output of defineSchema())
4588
- * @returns Conversion result with either the converted schema or validation errors
4589
- *
4590
- * @example
4591
- * ```typescript
4592
- * import { defineSchema } from '@dbsp/schema';
4593
- * import { resolvedSchemaToGeneratedSchema, createOrm } from '@dbsp/core';
4594
- *
4595
- * const resolved = defineSchema({ tables: { users: { id: { type: 'uuid' } } } });
4596
- * const result = resolvedSchemaToGeneratedSchema(resolved);
4597
- *
4598
- * if (result.success) {
4599
- * const orm = createOrm({ schema: result.schema, adapter });
4600
- * } else {
4601
- * console.error('Schema validation failed:', result.errors);
4602
- * }
4603
- * ```
4604
- */
4605
- declare function resolvedSchemaToGeneratedSchema(input: unknown): SchemaConversionResult;
4606
- /**
4607
- * Assert and convert a ResolvedSchema to GeneratedSchema.
4608
- *
4609
- * Throws an error if validation fails. Use this when you're confident
4610
- * the input is valid and want cleaner code without result checking.
4611
- *
4612
- * @param input - The ResolvedSchema to convert
4613
- * @returns The converted GeneratedSchema
4614
- * @throws Error if validation fails
4615
- */
4616
- declare function assertResolvedSchemaToGeneratedSchema(input: unknown): GeneratedSchema;
4617
-
4618
3868
  /**
4619
3869
  * Type definitions for table-scoped DDL operations.
4620
3870
  *
@@ -4665,9 +3915,9 @@ type TableDDL = {
4665
3915
  */
4666
3916
  /**
4667
3917
  * Union type for all ORM options.
4668
- * Prefer specific option types (OrmOptionsWithModel, OrmOptionsWithSchema, OrmOptionsWithAdapter).
3918
+ * Prefer specific option types (OrmOptionsWithModel, OrmOptionsWithAdapter).
4669
3919
  */
4670
- type OrmOptions<DB = unknown> = OrmOptionsWithModel<DB> | OrmOptionsWithSchema<GeneratedSchema, DB> | OrmOptionsWithAdapter<DB>;
3920
+ type OrmOptions<DB = unknown> = OrmOptionsWithModel<DB> | OrmOptionsWithAdapter<DB>;
4671
3921
  /**
4672
3922
  * Base options shared by all ORM option variants.
4673
3923
  */
@@ -4722,30 +3972,11 @@ interface OrmOptionsBase<DB = unknown> {
4722
3972
  }
4723
3973
  /**
4724
3974
  * OrmOptions with explicit model (sync creation).
4725
- * Prefer OrmOptionsWithSchema for codegen-first approach.
4726
3975
  */
4727
3976
  interface OrmOptionsWithModel<DB = unknown> extends OrmOptionsBase<DB> {
4728
3977
  readonly model: ModelIR;
4729
3978
  readonly schema?: never;
4730
3979
  }
4731
- /**
4732
- * OrmOptions with generated schema (sync creation, codegen-first).
4733
- * Preferred approach for ARCH-002 codegen-first architecture.
4734
- *
4735
- * @typeParam TSchema - The schema type (inferred from schema value)
4736
- * @typeParam DB - The database type (inferred from TSchema when possible)
4737
- *
4738
- * @example
4739
- * ```typescript
4740
- * const schema = { tables: { users: { id: { type: 'uuid' } } } } as const satisfies GeneratedSchema;
4741
- * const orm = createOrm({ schema, adapter });
4742
- * // DB is inferred as { users: { id: string } }
4743
- * ```
4744
- */
4745
- interface OrmOptionsWithSchema<TSchema extends GeneratedSchema = GeneratedSchema, DB = InferDBFromSchema<TSchema>> extends OrmOptionsBase<DB> {
4746
- readonly schema: TSchema;
4747
- readonly model?: never;
4748
- }
4749
3980
  /**
4750
3981
  * OrmOptions without model, requires adapter for auto-introspection (async creation).
4751
3982
  */
@@ -4757,7 +3988,7 @@ interface OrmOptionsWithAdapter<DB = unknown> extends OrmOptionsBase<DB> {
4757
3988
  /**
4758
3989
  * ORM instance created by createOrm().
4759
3990
  *
4760
- * @typeParam DB - Database schema type (Kysely-like).
3991
+ * @typeParam DB - Database row map type.
4761
3992
  * Keys are table names, values are row types.
4762
3993
  * When provided, query() method provides autocomplete for table names
4763
3994
  * and infers result types automatically.
@@ -4781,18 +4012,17 @@ interface OrmOptionsWithAdapter<DB = unknown> extends OrmOptionsBase<DB> {
4781
4012
  /**
4782
4013
  * PUBLIC ORM instance type — the interface consumers see from createOrm().
4783
4014
  *
4784
- * String-based table entry points (select, insert, update, delete, upsert) are
4785
- * intentionally absent. Use the typed TableRef-based methods instead:
4786
- * - `orm.from(table)` — SELECT
4787
- * - `orm.into(table)` — INSERT
4788
- * - `orm.modify(table)` — UPDATE
4789
- * - `orm.removeFrom(table)` — DELETE
4790
- * - `orm.upsertInto(table)` — UPSERT (INSERT ... ON CONFLICT)
4015
+ * SELECT queries can start from either first-class table entry point:
4016
+ * - `orm.select(name)` - concise table-name form
4017
+ * - `orm.from(table)` - TableRef form with column-level types
4791
4018
  *
4792
- * Internal code (NQL, planner, tests) that needs string-based access should
4793
- * cast to `OrmInstanceInternal<DB>`.
4019
+ * Mutations use the typed TableRef-based methods:
4020
+ * - `orm.into(table)` - INSERT
4021
+ * - `orm.modify(table)` - UPDATE
4022
+ * - `orm.removeFrom(table)` - DELETE
4023
+ * - `orm.upsertInto(table)` - UPSERT (INSERT ... ON CONFLICT)
4794
4024
  *
4795
- * @typeParam DB - Database schema type (Kysely-like).
4025
+ * @typeParam DB - Database row map type.
4796
4026
  * Keys are table names, values are row types.
4797
4027
  *
4798
4028
  * @example
@@ -4810,7 +4040,7 @@ interface OrmOptionsWithAdapter<DB = unknown> extends OrmOptionsBase<DB> {
4810
4040
  *
4811
4041
  * @example
4812
4042
  * ```typescript
4813
- * // With Schema wrapper (from schema() / defineSchema())
4043
+ * // With Schema wrapper from schema()
4814
4044
  * const db = schema({ users: { id: 'integer', name: 'string' } });
4815
4045
  * type MyOrm = OrmOf<typeof db>; // unwraps Schema<T> → InferDB<T>
4816
4046
  *
@@ -4873,7 +4103,26 @@ interface OrmInstance<DB = Record<string, unknown>> {
4873
4103
  [K in keyof DB & string]: TableRef<K, RowToColumnRefs<K, DB[K]>, any> & TableDDL;
4874
4104
  };
4875
4105
  /**
4876
- * Start a type-safe SELECT query from a TableRef.
4106
+ * Start building a SELECT query from a table name (string-based API).
4107
+ *
4108
+ * This is the ordinary table-name API used throughout guides and examples.
4109
+ * Use `orm.from(orm.tables.<table>)` when you want the stricter TableRef-based
4110
+ * form with column-level type information for filters, ordering, and result
4111
+ * inference.
4112
+ *
4113
+ * @typeParam K - Table name (inferred from DB keys when typed)
4114
+ * @typeParam TResult - Override result type (defaults to DB[K])
4115
+ * @param from - The root table name to select from
4116
+ * @returns A QueryBuilder for constructing the select
4117
+ */
4118
+ select<K extends keyof DB & string, TResult = DB[K]>(from: K): QueryBuilder<TResult>;
4119
+ /**
4120
+ * Start building a SELECT query from a typed TableRef.
4121
+ *
4122
+ * This is the stricter table-reference API. Use it when you want column refs
4123
+ * from `orm.tables.<table>` to carry column-level types into filters and other
4124
+ * query clauses. Use `orm.select('<table>')` when the shorter table-name form is
4125
+ * enough.
4877
4126
  *
4878
4127
  * @typeParam TTable - The TableRef type (inferred from the argument)
4879
4128
  * @param table - A TableRef from `orm.tables`
@@ -4887,18 +4136,6 @@ interface OrmInstance<DB = Record<string, unknown>> {
4887
4136
  *
4888
4137
  * @since DX-040-SURFACE
4889
4138
  */
4890
- /**
4891
- * Start building a SELECT query from a table name (string-based API).
4892
- *
4893
- * @deprecated Use `orm.from(orm.tables.<table>)` for type-safe queries.
4894
- * String-based select is kept for backward compatibility and test convenience.
4895
- *
4896
- * @typeParam K - Table name (inferred from DB keys when typed)
4897
- * @typeParam TResult - Override result type (defaults to DB[K])
4898
- * @param from - The root table name to select from
4899
- * @returns A QueryBuilder for constructing the select
4900
- */
4901
- select<K extends keyof DB & string, TResult = DB[K]>(from: K): QueryBuilder<TResult>;
4902
4139
  from<TTable extends TableRef<any, any, any>>(table: TTable): QueryBuilder<InferTableRow<TTable>>;
4903
4140
  /**
4904
4141
  * Start a SELECT query from a BatchValuesRef source (unnest-backed virtual table).
@@ -6267,10 +5504,10 @@ declare function coalesce(fields: readonly string[], as: string): ExpressionSpec
6267
5504
  */
6268
5505
  declare function raw(sqlFragment: string, as: string): ExpressionSpec;
6269
5506
  /**
6270
- * Creates a column alias expression using native Kysely API.
5507
+ * Creates a column alias expression as a typed dbsp expression intent.
6271
5508
  * Preferred over raw() for simple column aliasing as it's type-safe and dialect-portable.
6272
5509
  *
6273
- * Uses Kysely's `eb.ref(column).as(alias)` internally - no raw SQL.
5510
+ * Compilers render the alias from structured column and alias fields - no raw SQL.
6274
5511
  *
6275
5512
  * @param column - Column name to select
6276
5513
  * @param alias - Alias for the result column
@@ -6295,8 +5532,8 @@ declare function col(column: string, alias: string): ExpressionSpec;
6295
5532
  * Creates a relation column expression for selecting a column from a related table.
6296
5533
  * Auto-creates JOINs via the include mechanism and selects with custom alias.
6297
5534
  *
6298
- * Uses native Kysely API internally - no raw SQL. The compiler resolves the relation
6299
- * to its join alias and uses `eb.ref(alias.column).as(as)`.
5535
+ * Uses structured relation-column intent - no raw SQL. The compiler resolves the
5536
+ * relation to its join alias and renders a dialect-specific aliased column.
6300
5537
  *
6301
5538
  * @param relation - Relation path to traverse (dot-separated for multi-level)
6302
5539
  * @param column - Column name to select from the target relation
@@ -7328,7 +6565,7 @@ declare function pipeOnErrorHooks(...hooks: OnErrorHook[]): OnErrorHook;
7328
6565
  /**
7329
6566
  * DX-023: Lightweight ModelIR Definition
7330
6567
  *
7331
- * Provides a simplified API for defining relations when using Kysely's Database type.
6568
+ * Provides a simplified API for defining relations from a database row map type.
7332
6569
  * Instead of verbose column definitions, developers can focus solely on relations
7333
6570
  * using shorthand syntax with automatic FK inference.
7334
6571
  *
@@ -7759,7 +6996,7 @@ interface SimplifiedOrmOptions<T extends SchemaDefinition = SchemaDefinition> {
7759
6996
  /**
7760
6997
  * Create an ORM instance with the specified configuration.
7761
6998
  *
7762
- * @typeParam DB - Database schema type (Kysely-like).
6999
+ * @typeParam DB - Database row map type.
7763
7000
  * Keys are table names, values are row types.
7764
7001
  * When provided, query() provides autocomplete and type inference.
7765
7002
  *
@@ -8382,4 +7619,4 @@ declare const assertIntentHasOrderBy: (result: AssertionQueryResult, expected: b
8382
7619
  */
8383
7620
  declare function runAssertions(blocks: AssertionBlock[], results: AssertionQueryResult[], queries: string[], hasDb?: boolean): AssertionSummary;
8384
7621
 
8385
- export { ASSERTION_TYPES, AdapterRequiredError, type AdjacencyOptions, type AfterMutationHook, type AfterQueryHook, type AggregateOptions, type AliasedColumn, type AliasedExprColumn, type AllColumns, AmbiguousPlanError, AmbiguousRelationError, type Assertion, type AssertionBlock, type AssertionOutcome, type AssertionQueryResult, type AssertionSummary, type AssertionType, BRAND, type BatchValuesOptions, type BatchValuesRef, type BeforeMutationHook, type BeforeQueryHook, type BrandKey, COLUMN_META, type CardinalityShorthand, CaseBuilder, type CaseValue, type ColumnDef, type ColumnMetaKey, ColumnNotFoundError, type ColumnRef, type ColumnSpec, type ColumnTypeToTS, CteBuilder, type CteDump, CteQueryBuilder, type CursorPaginateOptions, type CursorPaginatedResult, DEFAULT_CONVENTIONS, DEFAULT_FEATURE_CHECKERS, DUCKDB_CAPABILITIES, type DefaultFilters, type DefineModelOptions, DeleteBuilder, type DistinctField, type DumpMetaInput, type EdgeTableOptions, type EmitWarningOptions, ErrorCode, type ErrorHookContext, Errors, ExecutionError, type ExprInput, ExpressionRef, type ExpressionSpec, type FeatureChecker, type FeatureUsage, type FilterOperators, type FilterValue, type FullTextSearchField, type FullTextSearchOptions, type GeneratedBelongsTo, type GeneratedColumn, type GeneratedColumnType, type GeneratedConventions, type GeneratedHasMany, type GeneratedHint, type GeneratedManyToMany, type GeneratedRelation, type GeneratedRelationKind, type GeneratedSchema, type GeneratedTable, type GetSchemaFromDbOptions, type HierarchyOptions, type HookErrorHandler, type HookManager, type HookPriority, type HydrateOptions, IRREGULAR_PLURALS, type IncludeOptions, type IncludeOptionsWithRecursive, type InferColumn, type InferColumnType, type InferColumnTypes, type InferDB, type InferDBFromSchema, type InferRefColumn, type InferRow, type InferRowType, type InferSchemaDB, type InferTableRow, type InferTables, type InferredRangeValue, InsertBuilder, IntentBuilder, type IntentBuilderState, type IntentSummary, InvalidOperationError, InvalidRelationDefinitionError, type JoinOptions, type JsonValue, type LightweightRelationsDef, type ListHierarchyOptions, type ListIndexOptions, type Logger, MSSQL_CAPABILITIES, MYSQL_CAPABILITIES, ModelIRImpl, type MutationDump, type MutationHookContext, type MutationOperation, NamingConventionMismatchError, type NegotiationResult, type NestedInclude, type SchemaColumnType$1 as NewSchemaColumnType, NotFoundError, type NqlBuilder, type NqlRawFragment, type NqlTag, type OnErrorHook, type OrderByInput, type OrderByRecord, type OrderBySpec, type OrmInstance, type OrmOf, type OrmOptions, type OrmOptionsWithAdapter, type OrmOptionsWithModel, type OrmOptionsWithSchema, POSTGRESQL_CAPABILITIES, type PaginateOptions, type PaginatedResult, type ParseError, type ParseResult, type ParsedRelationDef, type ParsedRelationKey, type PathOptions, type PrioritizedHook, type QueryAssertionResult, type QueryBuilder, type QueryHookContext, type QueryResultType, RELATION_META, type RangeType, RawCteQueryBuilder, type RecursiveDump, type RecursiveIncludeConfig, type RecursiveOptions, RecursiveShapeMismatchError, type RefDefinition, type RefOptions, type RelationHints, type RelationKey, type RelationMetaKey, RelationNotFoundError, type RelationObjectDef, type RelationPathIncludeNode, type RelationPathUsage, type RelationRef, type RelationShorthand, type RelationTupleDef, type ResolvedSchema, ResolvedSchemaValidation, ResultHydrator, SQLITE_CAPABILITIES, SQL_RAW_MARKER, type Schema, type SchemaBelongsToRelation, type SchemaCardinality, type SchemaColumnDefinition, type SchemaColumnType, type SchemaConfigInput, type SchemaConstraints, type SchemaConventionsDefinition, type SchemaConversionResult, type SchemaDefinition, type SchemaDefinitionInput, SchemaValidationError$1 as SchemaError, type SchemaExtras, type SchemaFilterStrategy, type SchemaForeignKeyReference, type SchemaHasManyRelation, type SchemaHintDefinition, type SchemaHintsDefinition, type SchemaIndexDefinition, type SchemaIndexOptions, type SchemaIndexesDefinition, type SchemaManyToManyRelation, type SchemaOnDeleteAction, type SchemaOptions, type SchemaRelationDefinition, type SchemaRelationKind, type SchemaRelationsDefinition, type SchemaTableDefinition, type SchemaTableOptions, type SchemaTablesDefinition, SchemaValidationError, type SelectField, type SelfRefRoles, type SetOperationBuilder, type SimplifiedOrmOptions, type SqlRawExpression, type StreamOptions, SubqueryBuilder, SubqueryExpression, TABLE_META, type TableAssertionData, type TableDDL, type TableDef, type TableIndexes, type TableMetaKey, TableNotFoundError, type TableRef, type TraversalDirection, UnhandledTypeInDialect, UnknownDialectError, UnsafeOperationError, UnsupportedCapabilityError, UnsupportedFeatureError, UnsupportedStrategyError, UpdateBuilder, UpsertBuilder, type ValidatedResolvedSchema, type WarningCategory, type WhereFilter, WindowBuilder, aggOrderBy, and, any, array, arrayAgg, assertCapability, assertContains, assertDbColumnExists, assertDbOutput, assertDbRowsEquals, assertDbRowsMax, assertDbRowsMin, assertDbValueEquals, assertEquals, assertIntentHasGroupBy, assertIntentHasOrderBy, assertIntentHasWhere, assertIntentTable, assertIntentType, assertIntentWith, assertMatches, assertParamsEquals, assertParamsLength, assertParamsType, assertParamsValue, assertResolvedSchemaToGeneratedSchema, assertSQLColumn, assertSQLEquals, assertSQLJoin, assertSQLTable, assertSuccess, assertTypeSupported, batchValues, buildModelFromResolvedSchema, buildModelFromSchema, capitalize, caseWhen, cast, coalesce, col, composeAfterMutationHooks, composeAfterQueryHooks, composeBeforeMutationHooks, composeBeforeQueryHooks, composeOnErrorHooks, countDistinctRelationPathsByName, createDialectCapabilities, createHookManager, createNqlTag, createOrm, createPseudoColumnMetadata, createRawCteBuilder, createRecursiveMetadata, decapitalize, defaultLogger, defineModel, defineSchema, denseRank, deriveRelationPathFromIntentPath, detectForeignKeys, detectManyToMany, distinct, emitWarning, eq, every, exists, ref as exprRef, extendDialect, extractPseudoColumnKeywords, findClosestMatch, fn, fullTextSearch, getAvailableDialects, getDialectCapabilities, getLogger, getRelationKind, getSchemaFromDb, gt, gte, inArray, inSubquery, inferForeignKey, inferRelationsFromSchema, isAliasedColumn, isAllColumns, isBatchValuesRef, isBelongsTo, isCardinalityShorthand, isColumnRef, isDistinctField, isDistinctFrom, isExpressionSpec, isGeneratedSchema, isHasMany, isKnownDialect, isManyToMany, isNotNull, isNull, isOverallSuccess, isRecursiveIncludeOptions, isRecursiveRelation, isRef, isRelationObjectDef, isRelationRef, isRelationTupleDef, isResolvedSchema, isSelfReferential, isSqlRaw, isSubqueryExpression, isTableRef, isWhereIntent, lag, lead, like, literal, lt, lte, namedArg, negotiateFeatures, neq, none, normalizeSQL, normalizeSchema, not, notExists, nqlRaw, objectToWhereIntent, op, or, outerRef, param, parseAssertionFile, parseRelationDef, parseRelationKey, pipeAfterMutationHooks, pipeAfterQueryHooks, pipeBeforeMutationHooks, pipeBeforeQueryHooks, pipeOnErrorHooks, plan, planRecursive, pluralize, rangeContainedBy, rangeContains, rangeOverlaps, rank, raw, rawExists, rawNotExists, ref$1 as ref, registerDialect, relationColumn, requiresDatabase, resetLogger, resolveQueryIndex, resolvedSchemaToGeneratedSchema, rowNumber, runAssertions, schema, schemaToModelIR, setLogger, silentLogger, singularize, some, sortByPriority, sql, star, stringAgg, subquery, supportsDDLGeneration, supportsExecution, supportsIntrospection, supportsRawSql, supportsStreaming, supportsTransactions, textScore, unary, validateAssertionBlocks, validateRecursiveInclude, validateRecursiveShape, validateTypeName, wAvg, wCount, wMax, wMin, wSum, withPriority };
7622
+ export { ASSERTION_TYPES, AdapterRequiredError, type AdjacencyOptions, type AfterMutationHook, type AfterQueryHook, type AggregateOptions, type AliasedColumn, type AliasedExprColumn, type AllColumns, AmbiguousPlanError, AmbiguousRelationError, type Assertion, type AssertionBlock, type AssertionOutcome, type AssertionQueryResult, type AssertionSummary, type AssertionType, BRAND, type BatchValuesOptions, type BatchValuesRef, type BeforeMutationHook, type BeforeQueryHook, type BrandKey, COLUMN_META, type CardinalityShorthand, CaseBuilder, type CaseValue, type ColumnDef, type ColumnMetaKey, ColumnNotFoundError, type ColumnRef, type ColumnSpec, CteBuilder, type CteDump, CteQueryBuilder, type CursorPaginateOptions, type CursorPaginatedResult, DEFAULT_FEATURE_CHECKERS, DUCKDB_CAPABILITIES, type DefaultFilters, type DefineModelOptions, DeleteBuilder, type DistinctField, type DumpMetaInput, type EdgeTableOptions, type EmitWarningOptions, ErrorCode, type ErrorHookContext, Errors, ExecutionError, type ExprInput, ExpressionRef, type ExpressionSpec, type FeatureChecker, type FeatureUsage, type FilterOperators, type FilterValue, type FullTextSearchField, type FullTextSearchOptions, type GetSchemaFromDbOptions, type HierarchyOptions, type HookErrorHandler, type HookManager, type HookPriority, type HydrateOptions, IRREGULAR_PLURALS, type IncludeOptions, type IncludeOptionsWithRecursive, type InferColumn, type InferColumnType, type InferColumnTypes, type InferDB, type InferRefColumn, type InferRow, type InferSchemaDB, type InferTableRow, type InferTables, type InferredRangeValue, InsertBuilder, IntentBuilder, type IntentBuilderState, type IntentSummary, InvalidOperationError, InvalidRelationDefinitionError, type JoinOptions, type JsonValue, type LightweightRelationsDef, type ListHierarchyOptions, type ListIndexOptions, type Logger, MSSQL_CAPABILITIES, MYSQL_CAPABILITIES, ModelIRImpl, type MutationDump, type MutationHookContext, type MutationOperation, NamingConventionMismatchError, type NegotiationResult, type NestedInclude, type SchemaColumnType as NewSchemaColumnType, NotFoundError, type NqlBuilder, type NqlRawFragment, type NqlTag, type OnErrorHook, type OrderByInput, type OrderByRecord, type OrderBySpec, type OrmInstance, type OrmOf, type OrmOptions, type OrmOptionsWithAdapter, type OrmOptionsWithModel, POSTGRESQL_CAPABILITIES, type PaginateOptions, type PaginatedResult, type ParseError, type ParseResult, type ParsedRelationDef, type ParsedRelationKey, type PathOptions, type PrioritizedHook, type QueryAssertionResult, type QueryBuilder, type QueryHookContext, type QueryResultType, RELATION_META, type RangeType, RawCteQueryBuilder, type RecursiveDump, type RecursiveIncludeConfig, type RecursiveOptions, RecursiveShapeMismatchError, type RefDefinition, type RefOptions, type RelationHints, type RelationKey, type RelationMetaKey, RelationNotFoundError, type RelationObjectDef, type RelationPathIncludeNode, type RelationPathUsage, type RelationRef, type RelationShorthand, type RelationTupleDef, ResultHydrator, SQLITE_CAPABILITIES, SQL_RAW_MARKER, type Schema, type SchemaColumnType, type SchemaConstraints, type SchemaDefinition, SchemaValidationError as SchemaError, type SchemaExtras, type SchemaIndexOptions, type SchemaIndexValidationInput, type SchemaOptions, type SchemaTableOptions, SchemaValidationError, type SelectField, type SelfRefRoles, type SetOperationBuilder, type SimplifiedOrmOptions, type SqlRawExpression, type StreamOptions, SubqueryBuilder, SubqueryExpression, TABLE_META, type TableAssertionData, type TableDDL, type TableDef, type TableIndexes, type TableMetaKey, TableNotFoundError, type TableRef, type TraversalDirection, UnhandledTypeInDialect, UnknownDialectError, UnsafeOperationError, UnsupportedCapabilityError, UnsupportedFeatureError, UnsupportedStrategyError, UpdateBuilder, UpsertBuilder, type WarningCategory, type WhereFilter, WindowBuilder, aggOrderBy, and, any, array, arrayAgg, assertCapability, assertContains, assertDbColumnExists, assertDbOutput, assertDbRowsEquals, assertDbRowsMax, assertDbRowsMin, assertDbValueEquals, assertEquals, assertIntentHasGroupBy, assertIntentHasOrderBy, assertIntentHasWhere, assertIntentTable, assertIntentType, assertIntentWith, assertMatches, assertParamsEquals, assertParamsLength, assertParamsType, assertParamsValue, assertSQLColumn, assertSQLEquals, assertSQLJoin, assertSQLTable, assertSuccess, assertTypeSupported, batchValues, capitalize, caseWhen, cast, coalesce, col, composeAfterMutationHooks, composeAfterQueryHooks, composeBeforeMutationHooks, composeBeforeQueryHooks, composeOnErrorHooks, countDistinctRelationPathsByName, createDialectCapabilities, createHookManager, createNqlTag, createOrm, createPseudoColumnMetadata, createRawCteBuilder, createRecursiveMetadata, decapitalize, defaultLogger, defineModel, denseRank, deriveRelationPathFromIntentPath, distinct, emitWarning, eq, every, exists, ref as exprRef, extendDialect, extractPseudoColumnKeywords, findClosestMatch, fn, fullTextSearch, getAvailableDialects, getDialectCapabilities, getLogger, getRelationKind, getSchemaFromDb, gt, gte, inArray, inSubquery, inferForeignKey, isAliasedColumn, isAllColumns, isBatchValuesRef, isCardinalityShorthand, isColumnRef, isDistinctField, isDistinctFrom, isExpressionSpec, isKnownDialect, isNotNull, isNull, isOverallSuccess, isRecursiveIncludeOptions, isRecursiveRelation, isRef, isRelationObjectDef, isRelationRef, isRelationTupleDef, isSelfReferential, isSqlRaw, isSubqueryExpression, isTableRef, isWhereIntent, lag, lead, like, literal, lt, lte, namedArg, negotiateFeatures, neq, none, normalizeSQL, not, notExists, nqlRaw, objectToWhereIntent, op, or, outerRef, param, parseAssertionFile, parseRelationDef, parseRelationKey, pipeAfterMutationHooks, pipeAfterQueryHooks, pipeBeforeMutationHooks, pipeBeforeQueryHooks, pipeOnErrorHooks, plan, planRecursive, pluralize, rangeContainedBy, rangeContains, rangeOverlaps, rank, raw, rawExists, rawNotExists, ref$1 as ref, registerDialect, relationColumn, requiresDatabase, resetLogger, resolveQueryIndex, rowNumber, runAssertions, schema, schemaToModelIR, setLogger, silentLogger, singularize, some, sortByPriority, sql, star, stringAgg, subquery, supportsDDLGeneration, supportsExecution, supportsIntrospection, supportsRawSql, supportsStreaming, supportsTransactions, textScore, unary, validateAssertionBlocks, validateRecursiveInclude, validateRecursiveShape, validateSchemaIndexOptions, validateTypeName, wAvg, wCount, wMax, wMin, wSum, withPriority };