@dbsp/adapter-pgsql 6.0.0 → 7.1.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.
@@ -1,8 +1,12 @@
1
+ import * as _pgsql_types from '@pgsql/types';
2
+ import { Node } from '@pgsql/types';
1
3
  import * as _dbsp_types from '@dbsp/types';
2
- import { DialectCapabilities, IndexIR, ModelIR, DbCasing, NormalizedManagedStep, DeclarableResourceAddress, TableIR, CatalogueIdentity, SequenceIR, LedgerPayload, ResourceAddress, LedgerAddress, HierarchyIR, PhysicalNameInventory, Adapter, AdapterLogger, AdapterCapabilities, ConnectionAvailability, PlanReport, CompiledNqlQuery, CompileOptions, CompiledQuery, CompileResultWithIncludes, SubqueryIncludeInfo, ExpressionIntent, InsertIntent, InsertFromIntent, UpdateIntent, BatchUpdateIntent, DeleteIntent, UpsertIntent, UpsertFromIntent, RecursivePlanReport, CteQueryIntent, SetOperationIntent, DumpMeta, Dump, AdapterStreamOptions, PinnedConnectionOptions, TransactionOptions, LedgerHome, DurableIntentRecord, TransitionRunAuthorization, TransitionRunJournal, ProvenPlanShape, LedgerReservationRow, LedgerIdentity, LedgerChainMember, LedgerMarkerState, DeclarationSet, ReinitializePreflightReport, OutcomeClaimPlan, DestructiveDecision, LedgerEventKind, OutcomeVacancy, OutcomeProtocolRefusal, ClaimBundleStatement, ControllerIdentity, AdmittedOutcomeClaim, ClaimToken, OutcomeIndeterminateRecoveryEvidence, OutcomeRecoveryEffect, OutcomeRecoveryClassification, ScopedApprovalSet, OutcomeRecoveryReadBack, OutcomeClaimAdmission } from '@dbsp/types';
4
+ import { ModelIR, DbCasing, DialectCapabilities, IndexIR, NormalizedManagedStep, DeclarableResourceAddress, TableIR, CatalogueIdentity, SequenceIR, LedgerPayload, ResourceAddress, LedgerAddress, Adapter, AdapterLogger, AdapterCapabilities, PlanReport, CompiledNqlQuery, CompileOptions, CompiledQuery, ExpressionIntent, InsertIntent, InsertFromIntent, UpdateIntent, BatchUpdateIntent, DeleteIntent, UpsertIntent, UpsertFromIntent, RecursivePlanReport, CteQueryIntent, SetOperationIntent, DumpMeta, Dump, AdapterStreamOptions, PinnedConnectionOptions, TransactionOptions, OutputDescriptor, ColumnListInput, ParamIntent, LedgerHome, DurableIntentRecord, TransitionRunJournal, ProvenPlanShape, LedgerChainMember, DeclarationSet, OutcomeClaimPlan, DestructiveDecision, LedgerEventKind, OutcomeProtocolRefusal, ClaimBundleStatement, ControllerIdentity, AdmittedOutcomeClaim, ClaimToken, OutcomeRecoveryClassification, OutcomeRecoveryReadBack, OutcomeClaimAdmission } from '@dbsp/types';
5
+ import * as _dbsp_types_internal from '@dbsp/types/internal';
6
+ import { PhysicalNameInventory, NamingPlugin, HierarchyIR, ConnectionAvailability, JsonAggOrderByEntry, TransitionRunAuthorization, LedgerReservationRow, LedgerIdentity, LedgerMarkerState, ReinitializePreflightReport, OutcomeVacancy, OutcomeIndeterminateRecoveryEvidence, OutcomeRecoveryEffect, ScopedApprovalSet } from '@dbsp/types/internal';
3
7
  import { Pool, PoolClient } from 'pg';
4
- import { IndexInfo, TruncateOptions, VacuumOptions, AlterColumnOptions, CreateIndexOptions, DropIndexOptions, TransitionRunPersister, ValidatedManagedStepManifest } from '@dbsp/core';
5
- import { AdmittedDestructiveOutcomeClaim, DurablyLoadedRun } from '@dbsp/core/internal';
8
+ import { IndexInfo, TruncateOptions, VacuumOptions, AlterColumnOptions, CreateIndexOptions, DropIndexOptions } from '@dbsp/core';
9
+ import { TransitionRunPersister, AdmittedDestructiveOutcomeClaim, ValidatedManagedStepManifest, DurablyLoadedRun } from '@dbsp/core/internal';
6
10
 
7
11
  /**
8
12
  * Default primary key column name used as convention fallback
@@ -25,67 +29,84 @@ declare const DEFAULT_PK_COLUMN = "id";
25
29
  type FkColumnDerivation = (tableName: string, pkColumnName: string) => string;
26
30
  declare const defaultFkDerivation: FkColumnDerivation;
27
31
 
28
- /**
29
- * NamingPlugin - Identifier transformation between model and database naming conventions
30
- *
31
- * Inspired by Kysely's CamelCasePlugin architecture.
32
- * The plugin transforms identifiers bidirectionally:
33
- * - toDatabase: model name (camelCase) → database name (snake_case)
34
- * - toModel: database name (snake_case) → model name (camelCase)
35
- */
36
- /**
37
- * Interface for naming convention transformation plugins
38
- */
39
- interface NamingPlugin {
40
- /**
41
- * Transform a model identifier to database format
42
- * Example: "createdAt" → "created_at"
43
- */
44
- toDatabase(identifier: string): string;
45
- /**
46
- * Transform a database identifier to model format
47
- * Example: "created_at" → "createdAt"
48
- */
49
- toModel(identifier: string): string;
32
+ type PgPhysicalModelInput = {
33
+ readonly mode: 'logical';
34
+ readonly model: ModelIR;
35
+ readonly schema: string;
36
+ readonly dbCasing?: DbCasing;
37
+ readonly naming?: NamingPlugin;
38
+ readonly fkAutoIndex?: boolean;
39
+ } | {
40
+ readonly mode: 'physical';
41
+ readonly model: ModelIR;
42
+ readonly schema: string;
43
+ readonly fkAutoIndex?: boolean;
44
+ };
45
+ type PgPhysicalNamespace = 'pg_class' | 'pg_type' | 'column' | 'constraint' | 'policy';
46
+ interface PgPhysicalNameClaim {
47
+ readonly namespace: PgPhysicalNamespace;
48
+ readonly schema: string;
49
+ readonly table?: string;
50
+ readonly physicalName: string;
51
+ readonly logicalOrigin: string;
50
52
  }
51
- /**
52
- * Identity plugin - no transformation
53
- * Use this when model and database naming conventions match
54
- */
55
- declare class IdentityNamingPlugin implements NamingPlugin {
56
- toDatabase(identifier: string): string;
57
- toModel(identifier: string): string;
53
+ interface PgPhysicalNameCollision {
54
+ readonly namespace: PgPhysicalNamespace;
55
+ readonly schema: string;
56
+ readonly table?: string;
57
+ readonly physicalName: string;
58
+ readonly first: PgPhysicalNameClaim;
59
+ readonly second: PgPhysicalNameClaim;
58
60
  }
59
- /**
60
- * CamelCase ↔ snake_case transformation plugin
61
- *
62
- * Follows the same logic as Kysely's CamelCasePlugin:
63
- * - Handles consecutive uppercase letters (e.g., "parseJSON" → "parse_json")
64
- * - Handles numbers (e.g., "field1Name" → "field1_name")
65
- * - Preserves leading underscores
66
- */
67
- declare class CamelCaseNamingPlugin implements NamingPlugin {
68
- /**
69
- * camelCase → snake_case
70
- */
71
- toDatabase(identifier: string): string;
72
- /**
73
- * snake_case → camelCase
74
- */
75
- toModel(identifier: string): string;
61
+ declare class PgPhysicalNameCollisionError extends Error {
62
+ readonly collision: PgPhysicalNameCollision;
63
+ constructor(collision: PgPhysicalNameCollision);
64
+ get namespace(): PgPhysicalNamespace;
65
+ get schema(): string;
66
+ get table(): string | undefined;
67
+ get physicalName(): string;
68
+ get first(): PgPhysicalNameClaim;
69
+ get second(): PgPhysicalNameClaim;
76
70
  }
71
+ /** Refusal raised before a physical model starts inspecting its input model. */
72
+ declare class PgPhysicalModelInputError extends Error {
73
+ readonly reason: 'schema' | 'mode-options';
74
+ constructor(reason: 'schema' | 'mode-options');
75
+ }
76
+ interface PgPhysicalModel {
77
+ readonly mode: 'logical' | 'physical';
78
+ readonly schema: string;
79
+ readonly fkAutoIndex: boolean;
80
+ readonly model: ModelIR;
81
+ readonly inventory: PhysicalNameInventory;
82
+ readonly claims: readonly PgPhysicalNameClaim[];
83
+ }
84
+ /** Builds the sole PostgreSQL physical spelling of one model without rendering SQL. */
85
+ declare function createPgPhysicalModel(input: PgPhysicalModelInput): PgPhysicalModel;
86
+
87
+ interface DeclaredNameResolver {
88
+ readonly physicalModel: PgPhysicalModel;
89
+ table(name: string): string | undefined;
90
+ column(table: string, name: string): string | undefined;
91
+ /** Restores the declared logical column key for one emitted physical column. */
92
+ logicalColumn(table: string, physicalName: string): string | undefined;
93
+ index(table: string, name: string): string | undefined;
94
+ constraint(table: string, name: string): string | undefined;
95
+ enum(name: string): string | undefined;
96
+ /** Resolve an index only when its logical name is unique across the model. */
97
+ uniqueIndex(name: string): string | undefined;
98
+ }
99
+
100
+ declare const sqlIdentifierBrand: unique symbol;
77
101
  /**
78
- * Singleton instances for convenience
79
- */
80
- declare const identityNaming: IdentityNamingPlugin;
81
- declare const camelCaseNaming: CamelCaseNamingPlugin;
82
- /**
83
- * Get a naming plugin by DbCasing (intuitive semantics).
84
- * - `'snake_case'`: DB uses snake_case → CamelCaseNamingPlugin (transforms to camelCase)
85
- * - `'camelCase'`: DB uses camelCase → IdentityNamingPlugin (no transform)
86
- * - `'preserve'`: No transformation → IdentityNamingPlugin
102
+ * A SQL identifier whose authority has been established by the adapter.
103
+ *
104
+ * The brand is intentionally private: this module is the only place that can
105
+ * cross an untyped spelling into the SQL-identifier vocabulary.
87
106
  */
88
- declare function getNamingPluginForDbCasing(casing: 'snake_case' | 'camelCase' | 'preserve'): NamingPlugin;
107
+ type SqlIdentifier = string & {
108
+ readonly [sqlIdentifierBrand]: 'SqlIdentifier';
109
+ };
89
110
 
90
111
  type IndexRenderKey = {
91
112
  readonly column?: string | undefined;
@@ -254,7 +275,7 @@ interface CompareSchemataOptions$1 {
254
275
  * contains one of those surfaces so a caller cannot accidentally rely on a
255
276
  * compile-only diff for a convergence-sensitive check.
256
277
  *
257
- * Live PostgreSQL callers should use `comparePgsqlDatabaseSchema()`, which
278
+ * Live PostgreSQL callers should use `comparePgDatabaseSchema()`, which
258
279
  * canonicalises CHECK constraint expressions, column defaults, and partial-index predicates before calling this function.
259
280
  * Under that live mode, each side is canonicalised independently; rejected
260
281
  * predicates refuse the migration and infrastructure fallback uses both raw
@@ -493,7 +514,7 @@ declare function assertDeclarableChangeKind(kind: ChangeKind): asserts kind is E
493
514
  * plan time, so no executable generator step can later fall through to a
494
515
  * permissive "no managed address" branch.
495
516
  */
496
- declare function createPgsqlGeneratedManagedStep(input: {
517
+ declare function createPgGeneratedManagedStep(input: {
497
518
  readonly change: SchemaChange;
498
519
  readonly database: string;
499
520
  readonly schema: string;
@@ -506,22 +527,22 @@ declare function createPgsqlGeneratedManagedStep(input: {
506
527
  * The live differ is the shape comparator. Persist the exact authored table
507
528
  * shape, rather than a boolean that could later be reinterpreted.
508
529
  */
509
- declare function pgsqlDeclaredAdoptionDeclaration(table: TableIR): LedgerPayload;
530
+ declare function pgDeclaredAdoptionDeclaration(table: TableIR): LedgerPayload;
510
531
  /**
511
532
  * Create the persisted, token-gated declaration that admits an already-live
512
533
  * table into the managed ledger. It intentionally mirrors the historical
513
534
  * generator lifecycle material so CLI plans retain their byte representation.
514
535
  */
515
- declare function createPgsqlDeclaredAdoptionStep(input: {
536
+ declare function createPgDeclaredAdoptionStep(input: {
516
537
  readonly address: Address;
517
538
  readonly table: TableIR;
518
539
  readonly stepKey: string;
519
540
  readonly order: number;
520
541
  readonly catalogueIdentity: CatalogueIdentity;
521
542
  }): NormalizedManagedStep;
522
- declare function pgsqlDeclaredSequenceAdoptionDeclaration(sequence: SequenceIR): LedgerPayload;
543
+ declare function pgDeclaredSequenceAdoptionDeclaration(sequence: SequenceIR): LedgerPayload;
523
544
  /** Creates the token-gated adoption claim for a physical standalone sequence. */
524
- declare function createPgsqlDeclaredSequenceAdoptionStep(input: {
545
+ declare function createPgDeclaredSequenceAdoptionStep(input: {
525
546
  readonly address: Address;
526
547
  readonly sequence: SequenceIR;
527
548
  readonly stepKey: string;
@@ -794,7 +815,7 @@ interface IntrospectedModelIR extends ModelIR {
794
815
  * client may be sitting inside a transaction that belongs to its owner, and a
795
816
  * catalog query that fails there aborts *their* transaction. Protecting that
796
817
  * needs a savepoint, and knowing whether to take one needs the caller to say
797
- * whose transaction it is — which is what `PgsqlAdapter`'s `borrowedClient`
818
+ * whose transaction it is — which is what `PgAdapter`'s `borrowedClient`
798
819
  * declaration is for. Guessing it from the object's shape is the exact defect
799
820
  * this adapter was rewritten to remove.
800
821
  *
@@ -804,80 +825,16 @@ interface IntrospectedModelIR extends ModelIR {
804
825
  * adapter's own protected executor carries the brand. A client cannot be passed
805
826
  * here at all.
806
827
  *
807
- * So: hold a client, use `new PgsqlAdapter(client, { borrowedClient: true })`
828
+ * So: hold a client, use `new PgAdapter(client, { borrowedClient: true })`
808
829
  * and call `.introspect()` on it.
809
830
  */
810
831
  declare function introspect(pool: Pool, options?: IntrospectionOptions): Promise<IntrospectedModelIR>;
811
832
 
812
- type PgPhysicalModelInput = {
813
- readonly mode: 'logical';
814
- readonly model: ModelIR;
815
- readonly schema: string;
816
- readonly dbCasing?: DbCasing;
817
- readonly naming?: NamingPlugin;
818
- readonly fkAutoIndex?: boolean;
819
- } | {
820
- readonly mode: 'physical';
821
- readonly model: ModelIR;
822
- readonly schema: string;
823
- readonly fkAutoIndex?: boolean;
824
- };
825
- type PgPhysicalNamespace = 'pg_class' | 'pg_type' | 'column' | 'constraint' | 'policy';
826
- interface PgPhysicalNameClaim {
827
- readonly namespace: PgPhysicalNamespace;
828
- readonly schema: string;
829
- readonly table?: string;
830
- readonly physicalName: string;
831
- readonly logicalOrigin: string;
832
- }
833
- interface PgPhysicalNameCollision {
834
- readonly namespace: PgPhysicalNamespace;
835
- readonly schema: string;
836
- readonly table?: string;
837
- readonly physicalName: string;
838
- readonly first: PgPhysicalNameClaim;
839
- readonly second: PgPhysicalNameClaim;
840
- }
841
- declare class PgPhysicalNameCollisionError extends Error {
842
- readonly collision: PgPhysicalNameCollision;
843
- constructor(collision: PgPhysicalNameCollision);
844
- get namespace(): PgPhysicalNamespace;
845
- get schema(): string;
846
- get table(): string | undefined;
847
- get physicalName(): string;
848
- get first(): PgPhysicalNameClaim;
849
- get second(): PgPhysicalNameClaim;
850
- }
851
- /** Refusal raised before a physical model starts inspecting its input model. */
852
- declare class PgPhysicalModelInputError extends Error {
853
- readonly reason: 'schema' | 'mode-options';
854
- constructor(reason: 'schema' | 'mode-options');
855
- }
856
- interface PgPhysicalModel {
857
- readonly mode: 'logical' | 'physical';
858
- readonly schema: string;
859
- readonly fkAutoIndex: boolean;
860
- readonly model: ModelIR;
861
- readonly inventory: PhysicalNameInventory;
862
- readonly claims: readonly PgPhysicalNameClaim[];
863
- }
864
- /** Builds the sole PostgreSQL physical spelling of one model without rendering SQL. */
865
- declare function createPgPhysicalModel(input: PgPhysicalModelInput): PgPhysicalModel;
866
-
867
833
  type PgsqlTransactionTimeoutParameter = 'lock_timeout' | 'statement_timeout';
868
834
 
869
- /**
870
- * PgsqlAdapter - Implements the Adapter interface for PostgreSQL using native pg driver.
871
- *
872
- * This adapter wraps a pg Pool instance and provides the unified
873
- * adapter interface for the db-semantic-planner ORM.
874
- *
875
- * @module pgsql-adapter
876
- */
877
-
878
835
  declare const rollbackOnlyPgsqlScopeBrand: unique symbol;
879
836
  /** A scope minted by withScratchScope and guaranteed to roll back on success. */
880
- type RollbackOnlyPgsqlScope<DB = unknown> = PgsqlAdapter<DB> & {
837
+ type PgRollbackOnlyScope<DB = unknown> = PgAdapter<DB> & {
881
838
  readonly [rollbackOnlyPgsqlScopeBrand]: typeof rollbackOnlyPgsqlScopeBrand;
882
839
  };
883
840
  type PgAdvisoryLockKey = bigint | {
@@ -890,15 +847,15 @@ type PgAdvisoryLockResult<T> = {
890
847
  } | {
891
848
  readonly acquired: false;
892
849
  };
893
- declare class PgsqlRawSqlTransactionControlError extends Error {
850
+ declare class PgRawSqlTransactionControlError extends Error {
894
851
  readonly dbspRawSqlTransactionControl = true;
895
852
  constructor(cause: unknown);
896
853
  }
897
- declare class PgsqlTransactionAbortedCommitError extends Error {
854
+ declare class PgTransactionAbortedCommitError extends Error {
898
855
  readonly dbspTransactionAbortedCommit = true;
899
856
  constructor(cause: unknown);
900
857
  }
901
- declare class PgsqlTransactionAbortedError extends Error {
858
+ declare class PgTransactionAbortedError extends Error {
902
859
  readonly dbspTransactionAborted = true;
903
860
  constructor(cause: unknown);
904
861
  }
@@ -907,19 +864,19 @@ declare class PgsqlTransactionAbortedError extends Error {
907
864
  * `TransactionOptions.signal`. If the signal aborts while `pool.connect()` is
908
865
  * still pending, dbsp honors it only after a client is acquired.
909
866
  */
910
- declare class PgsqlTransactionAbortSignalError extends Error {
867
+ declare class PgTransactionAbortSignalError extends Error {
911
868
  readonly dbspTransactionAbortSignal = true;
912
869
  constructor();
913
870
  }
914
- declare class PgsqlPinnedConnectionAbortSignalError extends Error {
871
+ declare class PgPinnedConnectionAbortSignalError extends Error {
915
872
  readonly dbspPinnedConnectionAbortSignal = true;
916
873
  constructor();
917
874
  }
918
- declare class PgsqlTransactionOptionsError extends Error {
875
+ declare class PgTransactionOptionsError extends Error {
919
876
  readonly dbspTransactionOptions = true;
920
877
  constructor(message: string);
921
878
  }
922
- declare class PgsqlAdvisoryLockOptionsError extends Error {
879
+ declare class PgAdvisoryLockOptionsError extends Error {
923
880
  readonly dbspAdvisoryLockOptions = true;
924
881
  constructor(message: string);
925
882
  }
@@ -939,7 +896,7 @@ declare class PgsqlAdvisoryLockOptionsError extends Error {
939
896
  * `NOWAIT`; a `57014` is the configured `statement_timeout` unless the backend was
940
897
  * cancelled from outside. Inspect `cause` when that distinction matters.
941
898
  */
942
- declare class PgsqlTransactionTimeoutError extends Error {
899
+ declare class PgTransactionTimeoutError extends Error {
943
900
  readonly timeout: PgsqlTransactionTimeoutParameter;
944
901
  readonly dbspTransactionTimeout = true;
945
902
  constructor(cause: unknown, timeout: PgsqlTransactionTimeoutParameter);
@@ -953,7 +910,7 @@ declare class PgsqlTransactionTimeoutError extends Error {
953
910
  * messages carry no parameter values; preserved upstream errors, including the
954
911
  * standard Error `cause`, are unsanitized.
955
912
  */
956
- declare class PgsqlPreparedStatementReplayError extends Error {
913
+ declare class PgPreparedStatementReplayError extends Error {
957
914
  readonly admissionFingerprint: string;
958
915
  readonly infrastructureError: unknown;
959
916
  readonly dbspPreparedStatementReplay = true;
@@ -962,13 +919,13 @@ declare class PgsqlPreparedStatementReplayError extends Error {
962
919
  constructor(admissionFingerprint: string, infrastructureError: unknown, cause: unknown);
963
920
  }
964
921
  /**
965
- * Options for PgsqlAdapter.
922
+ * Options for PgAdapter.
966
923
  */
967
- interface PgsqlPreparedStatementsOptions {
924
+ interface PgPreparedStatementsOptions {
968
925
  /** Maximum distinct compiled statements admitted per executor (default: 500). */
969
926
  readonly maxStatements?: number;
970
927
  }
971
- interface PgsqlAdapterOptions {
928
+ interface PgAdapterOptions {
972
929
  /** Schema name for multi-tenant queries */
973
930
  readonly schemaName?: string;
974
931
  /**
@@ -990,15 +947,15 @@ interface PgsqlAdapterOptions {
990
947
  * Opt in to node-postgres named prepared statements for compiled queries with
991
948
  * parameters. `true` uses the default statement cap; an object overrides it.
992
949
  */
993
- readonly preparedStatements?: boolean | PgsqlPreparedStatementsOptions;
950
+ readonly preparedStatements?: boolean | PgPreparedStatementsOptions;
994
951
  }
995
- interface PgsqlPoolAdapterOptionsBase extends PgsqlAdapterOptions {
952
+ interface PgsqlPoolAdapterOptionsBase extends PgAdapterOptions {
996
953
  readonly borrowedClient?: false;
997
954
  }
998
- type PgsqlPoolAdapterOptions = (PgsqlPoolAdapterOptionsBase & {
955
+ type PgPoolAdapterOptions = (PgsqlPoolAdapterOptionsBase & {
999
956
  readonly replayInvalidatedPlans?: false | undefined;
1000
957
  }) | (Omit<PgsqlPoolAdapterOptionsBase, 'preparedStatements'> & {
1001
- readonly preparedStatements: true | PgsqlPreparedStatementsOptions;
958
+ readonly preparedStatements: true | PgPreparedStatementsOptions;
1002
959
  /**
1003
960
  * Enable one unnamed replay after `0A000`/`RevalidateCachedQuery` only when
1004
961
  * you assert that your statements do not invoke functions performing
@@ -1028,7 +985,7 @@ type PgsqlPoolAdapterOptions = (PgsqlPoolAdapterOptionsBase & {
1028
985
  */
1029
986
  readonly replayInvalidatedPlans: true;
1030
987
  });
1031
- interface PgsqlBorrowedClientAdapterOptions extends PgsqlAdapterOptions {
988
+ interface PgBorrowedClientAdapterOptions extends PgAdapterOptions {
1032
989
  /** Replay is only available to a pool-owned pinned scope. */
1033
990
  readonly replayInvalidatedPlans?: never;
1034
991
  /** This connection belongs to the caller. dbsp never releases it. */
@@ -1061,7 +1018,7 @@ interface PgsqlBorrowedClientAdapterOptions extends PgsqlAdapterOptions {
1061
1018
  readonly managedTransactions?: true;
1062
1019
  }
1063
1020
  /** Options for a connectionless adapter, which cannot own replay serialization. */
1064
- interface PgsqlCompileOnlyAdapterOptions extends PgsqlAdapterOptions {
1021
+ interface PgCompileOnlyAdapterOptions extends PgAdapterOptions {
1065
1022
  readonly replayInvalidatedPlans?: never;
1066
1023
  }
1067
1024
  /**
@@ -1072,14 +1029,14 @@ interface PgsqlCompileOnlyAdapterOptions extends PgsqlAdapterOptions {
1072
1029
  * @example
1073
1030
  * ```typescript
1074
1031
  * import { Pool } from 'pg';
1075
- * import { createPgsqlAdapter } from '@dbsp/adapter-pgsql';
1032
+ * import { createPgAdapter } from '@dbsp/adapter-pgsql';
1076
1033
  *
1077
1034
  * const pool = new Pool({ connectionString: process.env.DATABASE_URL });
1078
- * const adapter = createPgsqlAdapter(pool);
1035
+ * const adapter = createPgAdapter(pool);
1079
1036
  * const orm = createOrm({ model, adapter });
1080
1037
  * ```
1081
1038
  */
1082
- declare class PgsqlAdapter<DB = unknown> implements Adapter<DB> {
1039
+ declare class PgAdapter<DB = unknown> implements Adapter<DB> {
1083
1040
  private readonly pool;
1084
1041
  private readonly client;
1085
1042
  private readonly borrowedClient;
@@ -1091,7 +1048,6 @@ declare class PgsqlAdapter<DB = unknown> implements Adapter<DB> {
1091
1048
  private readonly scopeState;
1092
1049
  private readonly schemaName;
1093
1050
  private readonly _dbCasing;
1094
- private readonly naming;
1095
1051
  private readonly model;
1096
1052
  private readonly logger;
1097
1053
  private readonly replayInvalidatedPlans;
@@ -1101,7 +1057,7 @@ declare class PgsqlAdapter<DB = unknown> implements Adapter<DB> {
1101
1057
  private readonly defaultPk;
1102
1058
  private readonly deriveFk;
1103
1059
  /**
1104
- * Create a new PgsqlAdapter.
1060
+ * Create a new PgAdapter.
1105
1061
  *
1106
1062
  * Ownership of the connection is **declared**, never inferred. Handing over a
1107
1063
  * `PoolClient` means nothing on its own — it says the object has a `release()`
@@ -1112,22 +1068,21 @@ declare class PgsqlAdapter<DB = unknown> implements Adapter<DB> {
1112
1068
  * or nothing at all for compile-only mode
1113
1069
  * @param options - configuration; declares connection ownership
1114
1070
  */
1115
- constructor(pool: Pool, options?: PgsqlPoolAdapterOptions);
1116
- constructor(client: PoolClient, options: PgsqlBorrowedClientAdapterOptions);
1117
- constructor(pool?: undefined, options?: PgsqlCompileOnlyAdapterOptions);
1071
+ constructor(pool: Pool, options?: PgPoolAdapterOptions);
1072
+ constructor(client: PoolClient, options: PgBorrowedClientAdapterOptions);
1073
+ constructor(pool?: undefined, options?: PgCompileOnlyAdapterOptions);
1118
1074
  /**
1119
1075
  * Shared compilation dependencies — built lazily from adapter fields.
1120
1076
  * Passed to compiler sub-modules instead of `this`.
1121
1077
  */
1122
1078
  /**
1123
- * Return a new PgsqlAdapterOptions that merges current config with overrides.
1079
+ * Return a new PgAdapterOptions that merges current config with overrides.
1124
1080
  * Ensures that all configuration fields (logger, defaultPkColumnName,
1125
1081
  * deriveFkColumnName, etc.) are propagated to scoped/transactional adapters.
1126
1082
  */
1127
1083
  private cloneOptions;
1128
1084
  private buildCompileDeps;
1129
1085
  private requireNqlCompileModel;
1130
- private assertNqlBindingNamesDisjointFromTables;
1131
1086
  private compileNqlMutation;
1132
1087
  private compileNqlBundleLeafEnvelope;
1133
1088
  private compileNqlBundle;
@@ -1167,20 +1122,6 @@ declare class PgsqlAdapter<DB = unknown> implements Adapter<DB> {
1167
1122
  * before CTE emission.
1168
1123
  */
1169
1124
  compile<T = unknown>(plan: PlanReport | CompiledNqlQuery, options?: CompileOptions): CompiledQuery<T>;
1170
- /**
1171
- * Compile a plan with includes, returning subquery include metadata (DX-033).
1172
- */
1173
- compileWithIncludes<T = unknown>(plan: PlanReport, options?: CompileOptions): CompileResultWithIncludes<T>;
1174
- /**
1175
- * Compile a subquery include query for given parent IDs (DX-033).
1176
- * Generates: SELECT * FROM targetTable WHERE foreignKey IN ($1, $2, ...)
1177
- *
1178
- * @param info - Subquery include metadata
1179
- * @param parentIds - Parent record IDs to fetch related records for
1180
- * @param options - Compile options
1181
- * @returns Compiled query for fetching related records
1182
- */
1183
- compileSubqueryInclude(info: SubqueryIncludeInfo, parentIds: readonly unknown[], options?: CompileOptions): CompiledQuery;
1184
1125
  /**
1185
1126
  * Compile a FROM-less SELECT expression to SQL.
1186
1127
  *
@@ -1190,7 +1131,7 @@ declare class PgsqlAdapter<DB = unknown> implements Adapter<DB> {
1190
1131
  * @param expr - ExpressionIntent to evaluate
1191
1132
  * @returns Compiled SQL and parameters
1192
1133
  */
1193
- compileSelectExpression<T = unknown>(expr: ExpressionIntent): CompiledQuery<T>;
1134
+ compileSelectExpression<T = unknown>(expr: ExpressionIntent, options?: CompileOptions): CompiledQuery<T>;
1194
1135
  /**
1195
1136
  * Compile an insert intent to executable SQL.
1196
1137
  *
@@ -1255,12 +1196,12 @@ declare class PgsqlAdapter<DB = unknown> implements Adapter<DB> {
1255
1196
  createDump(plan: PlanReport, query: CompiledQuery, meta?: DumpMeta): Dump;
1256
1197
  /**
1257
1198
  * Execute a query and return all results.
1258
- * Results are transformed to use model naming convention (e.g., snake_case → camelCase)
1199
+ * Result labels are mapped to their logical projection keys by the compiled query.
1259
1200
  */
1260
1201
  execute<T>(query: CompiledQuery<T>): Promise<T[]>;
1261
1202
  /**
1262
1203
  * Execute a query and return rows plus PostgreSQL result metadata.
1263
- * Results are transformed to use model naming convention (e.g., snake_case → camelCase)
1204
+ * Result labels are mapped to their logical projection keys by the compiled query.
1264
1205
  */
1265
1206
  executeWithMeta(query: CompiledQuery): Promise<{
1266
1207
  readonly rows: readonly unknown[];
@@ -1268,8 +1209,7 @@ declare class PgsqlAdapter<DB = unknown> implements Adapter<DB> {
1268
1209
  readonly command?: string;
1269
1210
  }>;
1270
1211
  /**
1271
- * Transform result rows from database naming to model naming convention.
1272
- * For CamelCaseNamingPlugin: price_cents → priceCents
1212
+ * Transform result rows through the projection's returned-label map.
1273
1213
  */
1274
1214
  private transformResultRows;
1275
1215
  /**
@@ -1384,7 +1324,7 @@ declare class PgsqlAdapter<DB = unknown> implements Adapter<DB> {
1384
1324
  * Rollback here is cleanup of dbsp-created work, not a sandbox for arbitrary
1385
1325
  * session effects.
1386
1326
  */
1387
- withScratchScope<T>(fn: (adapter: RollbackOnlyPgsqlScope<DB>) => Promise<T>): Promise<T>;
1327
+ withScratchScope<T>(fn: (adapter: PgRollbackOnlyScope<DB>) => Promise<T>): Promise<T>;
1388
1328
  private createManagedClientAdapter;
1389
1329
  private createPinnedConnectionAdapter;
1390
1330
  private createChildTransactionObserver;
@@ -1433,6 +1373,7 @@ declare class PgsqlAdapter<DB = unknown> implements Adapter<DB> {
1433
1373
  /**
1434
1374
  * Create a schema-scoped adapter for multi-tenant queries.
1435
1375
  */
1376
+ getSchemaName(): string | undefined;
1436
1377
  withSchema(schemaName: string): Adapter<DB>;
1437
1378
  /**
1438
1379
  * Execute raw SQL directly.
@@ -1502,6 +1443,23 @@ declare class PgsqlAdapter<DB = unknown> implements Adapter<DB> {
1502
1443
  * non-public search_path and a pooled connection both stay correct.
1503
1444
  */
1504
1445
  private explicitSchema;
1446
+ /**
1447
+ * DDL helpers are invoked by core with declared logical names. Keep the
1448
+ * model-to-physical boundary here: core deliberately does not know about the
1449
+ * PostgreSQL physical model. Direct adapter calls without a configured model
1450
+ * remain catalog-level operations and therefore keep their supplied names.
1451
+ */
1452
+ private helperDeclaredNames;
1453
+ /**
1454
+ * Public compilation APIs receive logical model references. Do the
1455
+ * addressable inventory check at their boundary so forged/stale plans cannot
1456
+ * fall through to a coincidentally named database object. Query-local names
1457
+ * are deliberately not passed to this method.
1458
+ */
1459
+ private assertDeclaredMutationReferences;
1460
+ private assertDeclaredPlanReferences;
1461
+ private helperTableName;
1462
+ private helperColumnName;
1505
1463
  /**
1506
1464
  * List all indexes on a table by querying pg_indexes.
1507
1465
  *
@@ -1556,51 +1514,52 @@ declare class PgsqlAdapter<DB = unknown> implements Adapter<DB> {
1556
1514
  * Implements TableDDLGeneratorAdapter.generateDropIndex.
1557
1515
  */
1558
1516
  generateDropIndex(name: string, schemaName: string, options?: DropIndexOptions): string;
1517
+ generateTableDropIndex(table: string, name: string, schemaName: string, options?: DropIndexOptions): string;
1559
1518
  /**
1560
1519
  * Validate an identifier (table name, column name, schema name).
1561
1520
  */
1562
1521
  validateIdentifier(value: string, type: string): void;
1563
1522
  }
1564
1523
  /**
1565
- * Create a PgsqlAdapter from a pg Pool instance.
1524
+ * Create a PgAdapter from a pg Pool instance.
1566
1525
  *
1567
1526
  * @param pool - pg Pool instance
1568
1527
  * @param options - Optional configuration
1569
- * @returns A new PgsqlAdapter instance
1528
+ * @returns A new PgAdapter instance
1570
1529
  *
1571
1530
  * @example
1572
1531
  * ```typescript
1573
1532
  * import { Pool } from 'pg';
1574
- * import { createPgsqlAdapter } from '@dbsp/adapter-pgsql';
1533
+ * import { createPgAdapter } from '@dbsp/adapter-pgsql';
1575
1534
  *
1576
1535
  * const pool = new Pool({ connectionString: process.env.DATABASE_URL });
1577
- * const adapter = createPgsqlAdapter(pool);
1536
+ * const adapter = createPgAdapter(pool);
1578
1537
  *
1579
1538
  * // With naming convention
1580
- * const adapter = createPgsqlAdapter(pool, { dbCasing: 'snake_case' });
1539
+ * const adapter = createPgAdapter(pool, { dbCasing: 'snake_case' });
1581
1540
  * ```
1582
1541
  */
1583
- declare function createPgsqlAdapter<DB = unknown>(pool: Pool, options?: PgsqlPoolAdapterOptions): PgsqlAdapter<DB>;
1584
- declare function createPgsqlAdapter<DB = unknown>(client: PoolClient, options: PgsqlBorrowedClientAdapterOptions): PgsqlAdapter<DB>;
1542
+ declare function createPgAdapter<DB = unknown>(pool: Pool, options?: PgPoolAdapterOptions): PgAdapter<DB>;
1543
+ declare function createPgAdapter<DB = unknown>(client: PoolClient, options: PgBorrowedClientAdapterOptions): PgAdapter<DB>;
1585
1544
  /**
1586
- * Creates a connectionless PgsqlAdapter for SQL generation without a database connection.
1545
+ * Creates a connectionless PgAdapter for SQL generation without a database connection.
1587
1546
  *
1588
1547
  * All compilation methods (compile, compileInsert, etc.), createDump(), and generateDDL()
1589
- * work normally. The adapter has the full PgsqlAdapter surface; database operations refuse
1590
- * at runtime until it is constructed with a connection via createPgsqlAdapter(pool).
1548
+ * work normally. The adapter has the full PgAdapter surface; database operations refuse
1549
+ * at runtime until it is constructed with a connection via createPgAdapter(pool).
1591
1550
  *
1592
1551
  * @example
1593
1552
  * ```typescript
1594
- * import { createPgsqlCompileOnlyAdapter } from '@dbsp/adapter-pgsql';
1553
+ * import { createPgCompileOnlyAdapter } from '@dbsp/adapter-pgsql';
1595
1554
  * import { createOrm } from '@dbsp/core';
1596
1555
  *
1597
- * const adapter = createPgsqlCompileOnlyAdapter();
1556
+ * const adapter = createPgCompileOnlyAdapter();
1598
1557
  * const orm = createOrm({ model, adapter });
1599
1558
  * const dump = await orm.select('users').dump();
1600
1559
  * console.log(dump.sql);
1601
1560
  * ```
1602
1561
  */
1603
- declare function createPgsqlCompileOnlyAdapter<DB = unknown>(options?: PgsqlCompileOnlyAdapterOptions): PgsqlAdapter<DB>;
1562
+ declare function createPgCompileOnlyAdapter<DB = unknown>(options?: PgCompileOnlyAdapterOptions): PgAdapter<DB>;
1604
1563
 
1605
1564
  interface CheckConstraintCanonicalizationWarning {
1606
1565
  readonly table: string;
@@ -1663,9 +1622,9 @@ declare class ColumnDefaultCanonicalizationError extends Error {
1663
1622
  /**
1664
1623
  * Canonicalise PostgreSQL CHECK constraint expressions in a desired model.
1665
1624
  */
1666
- declare function canonicalizeCheckConstraints(adapter: RollbackOnlyPgsqlScope, desired: ModelIR, dbModel: ModelIR, options?: CanonicalizeCheckConstraintsOptions): Promise<ModelIR>;
1625
+ declare function canonicalizeCheckConstraints(adapter: PgRollbackOnlyScope, desired: ModelIR, dbModel: ModelIR, options?: CanonicalizeCheckConstraintsOptions): Promise<ModelIR>;
1667
1626
 
1668
- interface ComparePgsqlDatabaseSchemaOptions$1 extends CompareSchemataOptions$1, SchemaScopeOptions {
1627
+ interface ComparePgDatabaseSchemaOptions$1 extends CompareSchemataOptions$1, SchemaScopeOptions {
1669
1628
  /**
1670
1629
  * Whether to canonicalise PostgreSQL CHECK constraint expressions, column defaults, and predicates on column-keyed
1671
1630
  * partial indexes before comparing. Defaults to `true`. Expression-keyed
@@ -1701,8 +1660,8 @@ interface ComparePgsqlDatabaseSchemaOptions$1 extends CompareSchemataOptions$1,
1701
1660
  * seen, and the comparison then keeps only the declared physical tables (with
1702
1661
  * the relations between them), so drift on other tables is not reported.
1703
1662
  */
1704
- interface ComparePgsqlDeclaredAdoptionSchemaInput {
1705
- readonly executor: PgsqlAdoptionComparisonExecutor;
1663
+ interface ComparePgDeclaredAdoptionSchemaInput {
1664
+ readonly executor: PgAdoptionComparisonExecutor;
1706
1665
  readonly model: ModelIR;
1707
1666
  readonly schema: string;
1708
1667
  readonly dbCasing: DbCasing;
@@ -1725,7 +1684,7 @@ interface PgsqlDeclaredAdoptionOwnershipMask {
1725
1684
  readonly indexes: ReadonlySet<string>;
1726
1685
  }
1727
1686
  /** Minimal pool surface retained so callers can keep their executor opaque. */
1728
- interface PgsqlAdoptionComparisonExecutor {
1687
+ interface PgAdoptionComparisonExecutor {
1729
1688
  query(sql: string, parameters?: readonly unknown[]): Promise<{
1730
1689
  readonly rows: readonly Record<string, unknown>[];
1731
1690
  }>;
@@ -1737,7 +1696,7 @@ declare function modelForDeclaredAdoption(table: TableIR): ModelIR;
1737
1696
  * claimed session remains pinned by constructing a borrowed, transaction-aware
1738
1697
  * adapter from that exact executor.
1739
1698
  */
1740
- declare function comparePgsqlDeclaredAdoptionSchema(input: ComparePgsqlDeclaredAdoptionSchemaInput): Promise<SchemaDiff>;
1699
+ declare function comparePgDeclaredAdoptionSchema(input: ComparePgDeclaredAdoptionSchemaInput): Promise<SchemaDiff>;
1741
1700
  type NonConvergentSchemaDiffSurface = {
1742
1701
  readonly kind: 'check_constraint';
1743
1702
  readonly table: string;
@@ -1830,7 +1789,7 @@ declare class IndexPredicateCanonicalizationError extends Error {
1830
1789
  * predicates on expression-keyed indexes are reported as unavailable and are
1831
1790
  * therefore rejected by strict mode. They need their own key-shape substrate.
1832
1791
  */
1833
- declare function comparePgsqlDatabaseSchema$1(adapter: PgsqlAdapter, desired: ModelIR, options?: ComparePgsqlDatabaseSchemaOptions$1): Promise<SchemaDiff>;
1792
+ declare function comparePgDatabaseSchema$1(adapter: PgAdapter, desired: ModelIR, options?: ComparePgDatabaseSchemaOptions$1): Promise<SchemaDiff>;
1834
1793
  declare function assertNoRepeatedExpressionSurfaceDrift(previouslyAppliedDiff: SchemaDiff, currentDiff: SchemaDiff, rawExpressionSurfaces?: ReadonlySet<string>): void;
1835
1794
 
1836
1795
  /**
@@ -1901,7 +1860,7 @@ interface GenerateDDLOptions extends Omit<GenerateDDLOptions$1, 'schemaName' | '
1901
1860
  }
1902
1861
  interface CompareSchemataOptions extends Omit<CompareSchemataOptions$1, 'schema' | 'dbCasing' | 'declaredSequenceNames'> {
1903
1862
  }
1904
- interface ComparePgsqlDatabaseSchemaOptions extends Omit<ComparePgsqlDatabaseSchemaOptions$1, 'schema' | 'dbCasing' | 'declaredSequenceNames'> {
1863
+ interface ComparePgDatabaseSchemaOptions extends Omit<ComparePgDatabaseSchemaOptions$1, 'schema' | 'dbCasing' | 'declaredSequenceNames'> {
1905
1864
  }
1906
1865
  interface MigrationSQLOptions extends Omit<MigrationSQLOptions$1, 'schemaName' | 'fkAutoIndex' | 'fkAutoIndexCoverage'> {
1907
1866
  }
@@ -1910,10 +1869,381 @@ interface PgSchemaDiff extends SchemaDiff {
1910
1869
  }
1911
1870
  declare function generateDDL(physical: PgPhysicalModel, options?: GenerateDDLOptions): string[];
1912
1871
  declare function compareSchemata(desired: PgPhysicalModel, database: PgPhysicalModel, options?: CompareSchemataOptions): PgSchemaDiff;
1913
- declare function comparePgsqlDatabaseSchema(adapter: PgsqlAdapter, desired: PgPhysicalModel, options?: ComparePgsqlDatabaseSchemaOptions): Promise<PgSchemaDiff>;
1872
+ declare function comparePgDatabaseSchema(adapter: PgAdapter, desired: PgPhysicalModel, options?: ComparePgDatabaseSchemaOptions): Promise<PgSchemaDiff>;
1914
1873
  declare function generateMigrationSQL(diff: PgSchemaDiff, options?: MigrationSQLOptions): readonly string[];
1915
1874
  declare function generateDownSQL(diff: PgSchemaDiff, options?: MigrationSQLOptions): readonly string[];
1916
1875
 
1876
+ /**
1877
+ * Query-local relation authority.
1878
+ *
1879
+ * A scope is built as relations enter a query. It deliberately contains the
1880
+ * emitted identifiers, rather than a transformation policy: aliases, CTEs and VALUES
1881
+ * ranges are local SQL vocabulary and must retain their spelling verbatim.
1882
+ */
1883
+
1884
+ type RelationBindingKind = 'declared-table' | 'cte-bind' | 'join-alias' | 'batch-values' | 'generated';
1885
+ /** A local projected output, indexed both by emitted label and logical key. */
1886
+ type RelationBindingOutput = OutputDescriptor & {
1887
+ readonly outputKey: SqlIdentifier;
1888
+ readonly logicalKey: string;
1889
+ };
1890
+ type RelationBinding = {
1891
+ /** The exact identifier emitted as the relation qualifier. */
1892
+ readonly qualifier: SqlIdentifier;
1893
+ readonly kind: RelationBindingKind;
1894
+ /** Present only for a declared physical relation. */
1895
+ readonly logicalTable?: string;
1896
+ /** Present for local relations whose output list is known. */
1897
+ readonly outputs?: ReadonlyMap<SqlIdentifier, RelationBindingOutput>;
1898
+ /** Built together with `outputs`; callers never scan outputs by logical key. */
1899
+ readonly outputsByLogicalKey?: ReadonlyMap<string, RelationBindingOutput>;
1900
+ };
1901
+ type QueryScope = {
1902
+ readonly bindings: ReadonlyMap<string, RelationBinding>;
1903
+ };
1904
+ /**
1905
+ * The pre-lot-3 carrier remains only at compiler boundaries. It is converted
1906
+ * to a QueryScope there; converted lookup functions never accept it.
1907
+ */
1908
+ type BindingNameRegistry = ReadonlySet<string>;
1909
+
1910
+ declare const projectionEnvelopeBrand: unique symbol;
1911
+ type ProjectionEnvelope<T = unknown> = {
1912
+ readonly [projectionEnvelopeBrand]: true;
1913
+ readonly sql: string;
1914
+ readonly parameters: readonly unknown[];
1915
+ readonly ast?: Node;
1916
+ readonly projection: ProjectionState;
1917
+ readonly hydrationPlan?: PlanReport;
1918
+ readonly __resultType?: T;
1919
+ };
1920
+ type ProjectionState = {
1921
+ readonly kind: 'known';
1922
+ readonly outputs: ReadonlyMap<string, OutputProjection>;
1923
+ } | {
1924
+ readonly kind: 'dropped';
1925
+ readonly reason: ProjectionDropReason;
1926
+ readonly hadConvertibleSource: boolean;
1927
+ /** The left positional branch still determines PostgreSQL result labels. */
1928
+ readonly outputKeyMap?: ReadonlyMap<string, string>;
1929
+ };
1930
+ type OutputProjection = OutputDescriptor & {
1931
+ readonly logicalKey: string;
1932
+ };
1933
+
1934
+ type ProjectionDropReason = 'set-operation-positional-merge' | 'raw-recursive-cte-positional-merge' | 'unknown-raw-sql' | 'unsupported-source';
1935
+
1936
+ /** Resolves columns through the relation bindings visible in a query scope. */
1937
+
1938
+ /** Compatibility input accepted only while callers move to QueryScope. */
1939
+ type RelationTargetProjectionRegistry = ReadonlyMap<string, ProjectionEnvelope>;
1940
+ /** A query-scope binding from an emitted SQL alias to the relation it exposes. */
1941
+ type AliasColumnAuthority = ReadonlyMap<string, ResolvedRelationTarget>;
1942
+ type ResolvedRelationTarget = {
1943
+ readonly target: SqlIdentifier;
1944
+ readonly cteName?: SqlIdentifier;
1945
+ readonly logicalTable?: string;
1946
+ readonly outputs?: ReadonlyMap<string, RelationBindingOutput>;
1947
+ /** Built when the local binding enters the scope; no reference path scans outputs. */
1948
+ readonly outputsByLogicalKey?: ReadonlyMap<string, RelationBindingOutput>;
1949
+ };
1950
+
1951
+ /** Built-in include strategies, shared by the runtime registry and public types. */
1952
+ declare const INCLUDE_STRATEGIES: readonly ["join", "lateral", "json_agg", "cte"];
1953
+ /** The four strategies this adapter implements handlers for, distinct from @dbsp/types' five-member IncludeStrategy, which includes auto. */
1954
+ type IncludeHandlerStrategy = (typeof INCLUDE_STRATEGIES)[number];
1955
+ /**
1956
+ * Immutable context passed to all handlers during compilation.
1957
+ */
1958
+ interface CompilerContext {
1959
+ readonly compileCaseCondition?: (intent: _dbsp_types.WhereIntent, ctx: CompilerContext, state: CompilerState) => Node;
1960
+ readonly compileSubqueryCondition?: (intent: _dbsp_types.WhereIntent, ctx: CompilerContext, state: CompilerState) => Node;
1961
+ readonly directRootWhere?: boolean;
1962
+ readonly position?: ConditionPosition;
1963
+ readonly createWhereDispatcher?: () => WhereDispatcher;
1964
+ /** Addressed authority for model-backed identifiers. */
1965
+ readonly declaredNames?: DeclaredNameResolver;
1966
+ /** Casing policy applied when a model is unavailable. */
1967
+ readonly dbCasing?: DbCasing;
1968
+ /** Schema name for table qualification (optional) */
1969
+ readonly schema?: string;
1970
+ /** Dialect capabilities for adapter-layer SQL surface gates */
1971
+ readonly dialectCapabilities?: DialectCapabilities;
1972
+ /** Root table name for the query */
1973
+ readonly rootTable: string;
1974
+ /** Current table alias (for JOINs) */
1975
+ readonly currentAlias?: string;
1976
+ /** Final relation path/name → SQL join alias map for relation-aware expression contexts */
1977
+ readonly aliases?: ReadonlyMap<string, string>;
1978
+ /** Maximum recursive depth (default: 100) */
1979
+ readonly maxRecursiveDepth: number;
1980
+ /** Optional callback for raw SQL audit trail */
1981
+ readonly onRawSQL?: (sql: string) => void;
1982
+ /** Default primary key column name for convention fallbacks (default: 'id') */
1983
+ readonly defaultPkColumnName?: string;
1984
+ /** Convention for deriving FK column names: (tableName, pkName) => fkColumnName */
1985
+ readonly deriveFkColumnName?: FkColumnDerivation;
1986
+ /** Alias of the outer (parent) query — used for FieldRef scope:'outer' resolution in EXISTS subqueries */
1987
+ readonly outerAlias?: string;
1988
+ /** Query-local CTE/binding names that must not be schema-qualified. */
1989
+ readonly bindingNames?: BindingNameRegistry;
1990
+ /** Query-local relation authority; bindings and their outputs never hit the model resolver. */
1991
+ readonly scope?: QueryScope;
1992
+ /** Enclosing query ranges, nearest query first; excludes the current query. */
1993
+ readonly enclosingRanges?: readonly (readonly RelationBinding[])[];
1994
+ /** Ranges emitted by the current query, separate from available CTE bindings. */
1995
+ readonly queryRanges?: readonly RelationBinding[];
1996
+ /**
1997
+ * The binding that owns unqualified expression columns. New callers provide
1998
+ * this directly; the string fields above remain only at pre-lot-4 compiler
1999
+ * boundaries while they are converted to bindings.
2000
+ */
2001
+ readonly currentBinding?: RelationBinding;
2002
+ /** Known projections for visible CTE/binding relation targets. */
2003
+ readonly relationTargetProjections?: RelationTargetProjectionRegistry;
2004
+ /** Lexically visible SQL aliases that expose a known CTE projection. */
2005
+ readonly aliasColumnAuthorities?: AliasColumnAuthority;
2006
+ /**
2007
+ * Optional callback to compile a QueryIntent into an AST Node (SubLink subselect).
2008
+ * Set by PlanCompiler when compiling selectCustomExpression — enables SubqueryExpressionIntent
2009
+ * to embed a fully compiled sub-SELECT into the parent SELECT column list.
2010
+ *
2011
+ * @param query - The inner QueryIntent to compile
2012
+ * @param paramOffset - Current outer paramIndex; inner $N are renumbered by this offset
2013
+ * @returns The compiled SelectStmt AST node and the inner parameters
2014
+ */
2015
+ readonly resolvedConditions?: ReadonlyMap<_dbsp_types.WhereIntent, _dbsp_types.ResolvedCondition>;
2016
+ readonly compileSubquery?: (query: _dbsp_types.QueryIntent, paramOffset: number, parent?: CompilerContext, expression?: _dbsp_types.ExpressionIntent) => {
2017
+ ast: Node;
2018
+ parameters: readonly unknown[];
2019
+ };
2020
+ /**
2021
+ * Optional recursive compiler for NQL-origin SELECT expression values nested
2022
+ * inside handler arguments, such as coalesce(upper(name), :fallback) or
2023
+ * (price + :a) * :b.
2024
+ */
2025
+ readonly compileNqlSelectExpression?: (value: unknown, ctx: CompilerContext, state: CompilerState) => Node;
2026
+ /**
2027
+ * Optional callback to compile a custom fn() FILTER (WHERE ...) condition.
2028
+ * Set by PlanCompiler to keep WHERE-dispatcher dependencies out of expression
2029
+ * handlers while still applying FILTER in every expression position.
2030
+ */
2031
+ readonly compileCustomFnFilter?: (filterIntent: _dbsp_types.WhereIntent, ctx: CompilerContext, state: CompilerState) => Node | undefined;
2032
+ /**
2033
+ * Optional ModelIR for type-aware parameter casting.
2034
+ * When provided, WHERE comparisons emit `$N::type` to eliminate
2035
+ * PostgreSQL type inference ambiguity for nullable columns.
2036
+ */
2037
+ readonly model?: ModelIR;
2038
+ }
2039
+ /**
2040
+ * The expression boundary deliberately excludes the legacy transform policy.
2041
+ * Expressions receive addressed declared names and query scope/bindings instead.
2042
+ */
2043
+ type ExpressionCompilerContext = Omit<CompilerContext, never>;
2044
+ /**
2045
+ * Mutable state maintained during compilation.
2046
+ */
2047
+ interface CompilerState {
2048
+ /** Addressed metadata shared across contexts for this compilation. */
2049
+ addressedColumns?: Map<string, Map<string, _dbsp_types.ColumnIR | undefined>>;
2050
+ /** Collected parameters in order */
2051
+ parameters: unknown[];
2052
+ /** Current parameter index (1-based for PostgreSQL) */
2053
+ paramIndex: number;
2054
+ /** Registered CTEs for the query */
2055
+ ctes: Map<string, Node>;
2056
+ /** Table aliases in use */
2057
+ aliases: Map<string, string>;
2058
+ /** JOIN clauses accumulated */
2059
+ joins: Node[];
2060
+ }
2061
+ /**
2062
+ * Base decision interface matching core's PlanDecision structure.
2063
+ */
2064
+ interface Decision {
2065
+ readonly resolvedInclude?: _dbsp_types.ResolvedIncludeNode;
2066
+ readonly type: string;
2067
+ readonly table?: string;
2068
+ readonly column?: string;
2069
+ readonly alias?: string;
2070
+ readonly operator?: string;
2071
+ readonly value?: unknown;
2072
+ readonly paramIndex?: number;
2073
+ readonly dataType?: string;
2074
+ readonly direction?: 'ASC' | 'DESC';
2075
+ readonly nulls?: 'FIRST' | 'LAST';
2076
+ readonly joinType?: 'inner' | 'left';
2077
+ readonly sourceColumn?: ColumnListInput;
2078
+ readonly targetColumn?: ColumnListInput;
2079
+ readonly targetTable?: string;
2080
+ readonly function?: string;
2081
+ /** Apply DISTINCT to a SELECT-list aggregate (e.g. COUNT(DISTINCT col)). */
2082
+ readonly distinct?: boolean;
2083
+ readonly args?: readonly unknown[];
2084
+ readonly conditions?: readonly Decision[];
2085
+ readonly columns?: readonly string[];
2086
+ /** An include explicitly selected zero fields, distinct from legacy empty columns. */
2087
+ readonly emptyProjection?: boolean;
2088
+ /** Original include select form, retained for strategy validation. */
2089
+ readonly includeSelectForm?: string;
2090
+ readonly values?: readonly unknown[];
2091
+ readonly set?: readonly {
2092
+ column: string;
2093
+ value: unknown;
2094
+ }[];
2095
+ readonly limit?: number | ParamIntent | {
2096
+ paramIndex: number;
2097
+ };
2098
+ readonly offset?: number | ParamIntent | {
2099
+ paramIndex: number;
2100
+ };
2101
+ readonly strategy?: IncludeHandlerStrategy;
2102
+ readonly relation?: string;
2103
+ readonly relationName?: string;
2104
+ readonly relationPath?: string;
2105
+ readonly hydrationPrefix?: string;
2106
+ readonly include?: readonly Decision[];
2107
+ readonly relationType?: 'belongsTo' | 'hasMany' | 'hasOne';
2108
+ readonly foreignKey?: ColumnListInput;
2109
+ readonly parentKey?: ColumnListInput;
2110
+ readonly includeOrderBy?: readonly _dbsp_types.IncludeOrderByIntent[];
2111
+ readonly orderByFallback?: boolean;
2112
+ readonly children?: readonly Decision[];
2113
+ readonly partition?: readonly string[];
2114
+ readonly orderBy?: readonly {
2115
+ column: string;
2116
+ direction?: 'ASC' | 'DESC';
2117
+ }[] | readonly JsonAggOrderByEntry[];
2118
+ readonly frame?: string;
2119
+ readonly recursiveInclude?: _dbsp_types.IncludeRecursiveOptions;
2120
+ readonly maxDepth?: number;
2121
+ readonly pathColumn?: string;
2122
+ readonly cycleDetection?: boolean;
2123
+ readonly selectColumn?: string;
2124
+ readonly aggregate?: string;
2125
+ /**
2126
+ * Apply DISTINCT to a scalar subquery's aggregate (e.g. AVG(DISTINCT price)).
2127
+ * Deliberately NOT named `distinct` — `assertNoDroppedDecisionModifiers`
2128
+ * (subquery-emission.ts) treats a top-level `distinct === true` on ANY
2129
+ * subquery decision as an unsupported query-level DISTINCT modifier and
2130
+ * throws. This field is scoped to the aggregate projection only, so it
2131
+ * must not collide with that generic guard.
2132
+ */
2133
+ readonly aggregateDistinct?: boolean;
2134
+ readonly subqueryOperator?: string;
2135
+ readonly traversal?: string;
2136
+ readonly traversals?: readonly {
2137
+ traversal: string;
2138
+ targetColumn?: string;
2139
+ }[];
2140
+ readonly isRecursive?: boolean;
2141
+ readonly fkColumn?: string;
2142
+ readonly pkColumn?: string;
2143
+ readonly expandRelation?: string;
2144
+ readonly relationColumns?: readonly string[];
2145
+ readonly columnAliases?: Readonly<Record<string, string>>;
2146
+ readonly defaultRelationColumnLabels?: Readonly<Record<string, boolean>>;
2147
+ readonly payloadShape?: _dbsp_types.IncludePayloadShape;
2148
+ readonly jsonPath?: readonly unknown[];
2149
+ readonly jsonMode?: 'json' | 'text';
2150
+ readonly _compiledFilterWhere?: _pgsql_types.Node;
2151
+ readonly filterWhere?: _pgsql_types.Node;
2152
+ readonly expressionIntent?: unknown;
2153
+ readonly escape?: string;
2154
+ /**
2155
+ * Provenance: the ORIGINAL QueryIntent before lowering.
2156
+ * Set by every lowering site (convertIn, convertSubquery, normalizeToDecision,
2157
+ * dispatchWhere, mapInSubqueryCondition) so that `buildPredicateSubquerySelect`
2158
+ * (subquery-emission.ts) can validate the true caller intent rather than the
2159
+ * stripped-down lowered decision fields.
2160
+ *
2161
+ * Required for IN / scalar / inSubquery / notInSubquery decisions.
2162
+ * Optional on other decision types.
2163
+ */
2164
+ readonly subqueryIntent?: _dbsp_types.QueryIntent;
2165
+ }
2166
+ /**
2167
+ * Handler for WHERE clause conditions.
2168
+ * Transforms condition decisions into PostgreSQL AST expressions.
2169
+ */
2170
+ interface WhereHandler {
2171
+ /** Operator(s) this handler supports */
2172
+ readonly operators: readonly string[];
2173
+ /**
2174
+ * Compile a WHERE condition to AST.
2175
+ * @param decision The condition decision
2176
+ * @param ctx Immutable compiler context
2177
+ * @param state Mutable compiler state
2178
+ * @param dispatch Callback to compile nested conditions
2179
+ * @returns PostgreSQL AST node for the condition
2180
+ */
2181
+ compile(decision: Decision, ctx: CompilerContext, state: CompilerState, dispatch: WhereDispatcher): Node;
2182
+ }
2183
+ /**
2184
+ * Dispatcher for recursive WHERE compilation.
2185
+ * The same function object may be passed to every level of a recursive compilation, so it is an opaque callback.
2186
+ * Handlers must not use its identity to distinguish frames or carry frame-local state.
2187
+ */
2188
+ type WhereDispatcher = (decision: Decision, ctx: CompilerContext, state: CompilerState) => Node;
2189
+ /**
2190
+ * Handler for SELECT expressions.
2191
+ * Transforms expression decisions into PostgreSQL AST nodes.
2192
+ */
2193
+ interface ExpressionHandler {
2194
+ /** Expression type(s) this handler supports */
2195
+ readonly types: readonly string[];
2196
+ /**
2197
+ * Safe to use when a function name comes from NQL text.
2198
+ *
2199
+ * Raw/escape-hatch handlers must not set this. NQL-origin function names use
2200
+ * this opt-in surface only, then fall back to generic FuncCall emission.
2201
+ */
2202
+ readonly nqlSafe?: boolean;
2203
+ /**
2204
+ * Compile an expression to AST.
2205
+ * @param decision The expression decision
2206
+ * @param ctx Immutable compiler context
2207
+ * @param state Mutable compiler state
2208
+ * @returns PostgreSQL AST node for the expression
2209
+ */
2210
+ compile(decision: Decision, ctx: ExpressionCompilerContext, state: CompilerState): Node;
2211
+ }
2212
+ /**
2213
+ * Handler for include/relation strategies.
2214
+ * Transforms include decisions into PostgreSQL constructs (JOIN, LATERAL, json_agg, CTE).
2215
+ */
2216
+ interface IncludeHandler {
2217
+ /** Strategy this handler implements */
2218
+ readonly strategy: IncludeHandlerStrategy;
2219
+ /**
2220
+ * Compile an include to AST.
2221
+ * @param decision The include decision
2222
+ * @param ctx Immutable compiler context
2223
+ * @param state Mutable compiler state
2224
+ * @returns Object with modifications to apply
2225
+ */
2226
+ compile(decision: Decision, ctx: CompilerContext, state: CompilerState): IncludeResult;
2227
+ }
2228
+ /**
2229
+ * Result of include compilation.
2230
+ */
2231
+ interface IncludeResult {
2232
+ /** Additional target list items (SELECT columns) */
2233
+ targets?: Node[];
2234
+ /** JOIN to add to FROM clause */
2235
+ join?: Node;
2236
+ /** Additional JOINs for cascaded includes (e.g., flat deep nesting) */
2237
+ additionalJoins?: Node[];
2238
+ /** CTE to add to WITH clause */
2239
+ cte?: Node;
2240
+ /** Subquery for LATERAL */
2241
+ lateral?: Node;
2242
+ }
2243
+
2244
+ /** Compilation position selects the migrated root WHERE, FILTER and recursive-anchor paths; other callers retain their lowering. */
2245
+ type ConditionPosition = 'where' | 'having' | 'filter' | 'join-on' | 'recursive-anchor' | 'subquery' | 'case-when' | 'update-where' | 'delete-where' | 'upsert-guard';
2246
+
1917
2247
  /** The intentionally narrow query facade passed to application callbacks. */
1918
2248
  interface PgApplicationStepTx {
1919
2249
  query<Row extends Record<string, unknown> = Record<string, unknown>>(text: string, values?: readonly unknown[]): Promise<{
@@ -2375,7 +2705,7 @@ declare function readPgLedgerScopeCurrency(executor: TransitionJournalQueryable,
2375
2705
  * pair; callers must first establish the finite candidate homes from reviewed
2376
2706
  * material and then each home is admitted here.
2377
2707
  */
2378
- declare function readVerifiedPgLedgerReservationsForPair(executor: TransitionJournalQueryable, pairId: string, homes: readonly LedgerHome[]): Promise<readonly _dbsp_types.LedgerReservationRow[]>;
2708
+ declare function readVerifiedPgLedgerReservationsForPair(executor: TransitionJournalQueryable, pairId: string, homes: readonly LedgerHome[]): Promise<readonly _dbsp_types_internal.LedgerReservationRow[]>;
2379
2709
  /**
2380
2710
  * Runs the separately privileged reinitialize-preflight. It never invokes a
2381
2711
  * ledger append primitive: the only durable writes are additive structure,
@@ -2724,4 +3054,4 @@ declare function executePgAdmittedOperation(session: TransitionJournalQueryable,
2724
3054
  */
2725
3055
  declare function recoverPgOutcomeClaim(executor: TransitionJournalQueryable, request: PgOutcomeRecoveryRequest): Promise<PgOutcomeRecoveryResult>;
2726
3056
 
2727
- export { type PgAdvisoryLockResult as $, type AddedEnumValue as A, GeneratedPostconditionReplanRequiredError as B, type ChangeKind as C, DEFAULT_PK_COLUMN as D, ExpressionCanonicalizationUnavailableError as E, type FkColumnDerivation as F, type GeneratedPostconditionSession as G, GeneratedPostconditionSessionDeactivatedError as H, GeneratedPostconditionWorkInFlightError as I, IdentityNamingPlugin as J, type IndexCapabilityContext as K, IndexFeatureUnsupportedError as L, IndexPredicateCanonicalizationError as M, type NamingPlugin as N, type IndexRenderSpec as O, type PgLockedRun as P, type IntrospectedModelIR as Q, type IntrospectionOptions as R, type MigrationSQLOptions as S, type TransitionJournalQueryable as T, NonConvergentSchemaDiffError as U, type NonConvergentSchemaDiffSurface as V, PG_LEDGER_SHAPE_VERSION as W, PartialIndexPredicateNewEnumValueError as X, type PgAdmittedOperation as Y, type PgAdmittedOperationResult as Z, type PgAdvisoryLockKey as _, type PgOutcomeCheckpointObserver as a, assertCreateIndexesSupported as a$, type PgApplicationStepOwnedState as a0, type PgApplicationStepTx as a1, type PgCatalogueIdentityQueryable as a2, type PgConvergeApplicationStep as a3, type PgConvergeAssertStep as a4, type PgConvergeInitializationFailure as a5, type PgConvergeOnceStep as a6, type PgConvergePlannedStep as a7, type PgConvergeRefusal as a8, type PgConvergeRefusalChange as a9, type PgsqlAdapterOptions as aA, PgsqlAdvisoryLockOptionsError as aB, type PgsqlBorrowedClientAdapterOptions as aC, type PgsqlCompileOnlyAdapterOptions as aD, PgsqlPinnedConnectionAbortSignalError as aE, type PgsqlPoolAdapterOptions as aF, PgsqlPreparedStatementReplayError as aG, type PgsqlPreparedStatementsOptions as aH, PgsqlRawSqlTransactionControlError as aI, PgsqlTransactionAbortSignalError as aJ, PgsqlTransactionAbortedCommitError as aK, PgsqlTransactionAbortedError as aL, PgsqlTransactionOptionsError as aM, PgsqlTransactionTimeoutError as aN, RawIndexPredicateFallbackError as aO, type ReferencedKeyKind as aP, type ReferencedKeyRemovalConflict as aQ, ReferencedKeyRemovalError as aR, type RollbackOnlyPgsqlScope as aS, type SchemaChange as aT, type SchemaDiff as aU, type SchemaScopeOptions as aV, TransitionRunIdentityMismatchError as aW, acquirePgLedgerLocks as aX, appendIntentJournal as aY, appendTransitionAuthorization as aZ, assertCreateIndexSupported as a_, PgConvergeRefusalError as aa, type PgLedgerLockResult as ab, PgLedgerStorageUnsupportedError as ac, type PgLedgerTarget as ad, type PgOutcomeCheckpoint as ae, type PgOutcomeClaimRequest as af, type PgOutcomeExecutionRequest as ag, type PgOutcomeNonTransactionalRequest as ah, type PgOutcomeReadBackFactory as ai, type PgOutcomeRecoveryRequest as aj, type PgOutcomeRecoveryResult as ak, type PgOutcomeResolution as al, type PgOutcomeResolutionAppendResult as am, type PgOutcomeResult as an, type PgOutcomeTransactionalRequest as ao, type PgOwnedCheckState as ap, type PgPhysicalModelInput as aq, PgPhysicalModelInputError as ar, type PgPhysicalNameClaim as as, type PgPhysicalNameCollision as at, PgPhysicalNameCollisionError as au, type PgPhysicalNamespace as av, type PgReinitializePreflightOptions as aw, type PgReinitializePreflightPool as ax, type PgSchemaDiff as ay, PgsqlAdapter as az, type ConvergePgOptions as b, type ComparePgsqlDeclaredAdoptionSchemaInput as b$, assertDeclarableChangeKind as b0, assertGeneratedPostconditionSession as b1, assertNoRepeatedExpressionSurfaceDrift as b2, camelCaseNaming as b3, canGenerateCreateIndex as b4, canonicalizeCheckConstraints as b5, comparePgsqlDatabaseSchema as b6, compareSchemata as b7, createPgPhysicalModel as b8, createPgTransitionRunPersister as b9, recordPgLedgerIdentity as bA, renderCreateDbspMetaSchemaSql as bB, renderCreateIndex as bC, renderCreateLedgerEventTableSql as bD, renderCreateLedgerIdentityTableSql as bE, renderCreateLedgerImmutabilityFunctionSql as bF, renderCreateLedgerImmutabilityTriggerSql as bG, renderCreateLedgerMarkerTableSql as bH, renderCreateLedgerReservationTableSql as bI, renderCreateLedgerTerminalMemberIndexSql as bJ, renderCreateTransitionAuthorizationTableSql as bK, renderCreateTransitionJournalTableSql as bL, renderCreateTransitionRunPlanTableSql as bM, renderCreateTransitionRunTableSql as bN, runPgReinitializePreflight as bO, toGeneratedPostconditionBindingAddress as bP, validatePgLedgerRuntimeIntegrity as bQ, verifyGeneratedCheckPostcondition as bR, verifyGeneratedColumnPostcondition as bS, verifyGeneratedIdentityPostcondition as bT, verifyGeneratedIndexPostcondition as bU, verifyGeneratedTablePostcondition as bV, withGeneratedPostconditionSession as bW, type PgOrderedLedgerLocks as bX, type PgLedgerShapeAllowance as bY, type PgLedgerPhysicalShapeOutcome as bZ, type ComparePgsqlDatabaseSchemaOptions$1 as b_, createPgsqlAdapter as ba, createPgsqlCompileOnlyAdapter as bb, createPgsqlGeneratedManagedStep as bc, decodeGeneratedPostcondition as bd, decodeGeneratedPostconditionPayload as be, defaultFkDerivation as bf, ensureDbspMetaLedger as bg, ensurePgLedger as bh, ensurePgLedgerStorageVersion as bi, ensureTransitionJournal as bj, executePgAdmittedOperation as bk, generateCreateIndex as bl, generateDDL as bm, generateDownSQL as bn, generateMigrationSQL as bo, generatedPostconditionDigest as bp, generatedPostconditionForChange as bq, getNamingPluginForDbCasing as br, identityNaming as bs, introspect as bt, readPgCatalogueIdentity as bu, readPgLedgerMarker as bv, readPgLedgerReservationsForExecution as bw, readPgLedgerScopeCurrency as bx, readPgOutcomeRecoveryReadBack as by, readVerifiedPgLedgerReservationsForPair as bz, type PgPhysicalModel as c, type CompareSchemataOptions$1 as c0, type ConvergePgBaseOptions as c1, type ConvergePgCheckOptions as c2, type GenerateDDLOptions$1 as c3, type MigrationSQLOptions$1 as c4, PgCommitAcknowledgementAmbiguousError as c5, type PgsqlAdoptionComparisonExecutor as c6, appendPgLedgerClaim as c7, appendPgLedgerClaimGroup as c8, appendPgLedgerProgress as c9, resolvePgDestructiveOutcome as cA, resolvePgOutcomeClaimGroup as cB, appendPgLedgerRelease as ca, appendPgLedgerResolution as cb, appendPgLedgerResolutionGroup as cc, appendPgOutcomeResolution as cd, classifyPgLedgerPhysicalShape as ce, collectReferencedKeyRemovalConflicts as cf, comparePgsqlDatabaseSchema$1 as cg, comparePgsqlDeclaredAdoptionSchema as ch, compareSchemata$1 as ci, convergePg as cj, createPgLedgerShapeAllowance as ck, createPgsqlDeclaredAdoptionStep as cl, createPgsqlDeclaredSequenceAdoptionStep as cm, executePgDestructiveOutcome as cn, generateDDL$1 as co, generateDownSQL$1 as cp, generateMigrationSQL$1 as cq, lockPgJournalRun as cr, modelForDeclaredAdoption as cs, openPgOutcomeClaim as ct, openPgOutcomeClaimGroup as cu, pgsqlDeclaredAdoptionDeclaration as cv, pgsqlDeclaredSequenceAdoptionDeclaration as cw, readPgLedgerReservationsForPair as cx, recoverPgAdmittedReaddressPair as cy, recoverPgOutcomeClaim as cz, type PgConvergeResult as d, type PgConvergeCheckResult as e, type PgLedgerScopeCurrency as f, AutoIncrementTransitionUnsupportedError as g, CamelCaseNamingPlugin as h, type CanonicalizeCheckConstraintsOptions as i, CheckConstraintCanonicalizationError as j, type CheckConstraintCanonicalizationWarning as k, CheckConstraintNewEnumValueError as l, ColumnDefaultCanonicalizationError as m, type ColumnDefaultCanonicalizationWarning as n, type ComparePgsqlDatabaseSchemaOptions as o, type CompareSchemataOptions as p, type DetectedHierarchy as q, readTransitionJournal as r, type DiffSummary as s, type ExpressionCanonicalizationWarning as t, ExpressionKeyedIndexPredicateCanonicalizationUnsupportedError as u, type GenerateDDLOptions as v, type GeneratedPostcondition as w, type GeneratedPostconditionBindingAddress as x, GeneratedPostconditionBindingResolutionError as y, GeneratedPostconditionProofInFlightError as z };
3057
+ export { PG_LEDGER_SHAPE_VERSION as $, type AddedEnumValue as A, type GeneratedPostcondition as B, type ChangeKind as C, type Decision as D, ExpressionCanonicalizationUnavailableError as E, type FkColumnDerivation as F, type GeneratedPostconditionSession as G, type GeneratedPostconditionBindingAddress as H, GeneratedPostconditionBindingResolutionError as I, GeneratedPostconditionProofInFlightError as J, GeneratedPostconditionReplanRequiredError as K, GeneratedPostconditionSessionDeactivatedError as L, GeneratedPostconditionWorkInFlightError as M, type IncludeHandler as N, type IncludeResult as O, type ProjectionEnvelope as P, type IndexCapabilityContext as Q, IndexFeatureUnsupportedError as R, type SqlIdentifier as S, type TransitionJournalQueryable as T, IndexPredicateCanonicalizationError as U, type IndexRenderSpec as V, type IntrospectedModelIR as W, type IntrospectionOptions as X, type MigrationSQLOptions as Y, NonConvergentSchemaDiffError as Z, type NonConvergentSchemaDiffSurface as _, type CompilerContext as a, TransitionRunIdentityMismatchError as a$, PartialIndexPredicateNewEnumValueError as a0, PgAdapter as a1, type PgAdapterOptions as a2, type PgAdmittedOperation as a3, type PgAdmittedOperationResult as a4, type PgAdvisoryLockKey as a5, PgAdvisoryLockOptionsError as a6, type PgAdvisoryLockResult as a7, type PgApplicationStepOwnedState as a8, type PgApplicationStepTx as a9, type PgPhysicalModelInput as aA, PgPhysicalModelInputError as aB, type PgPhysicalNameClaim as aC, type PgPhysicalNameCollision as aD, PgPhysicalNameCollisionError as aE, type PgPhysicalNamespace as aF, PgPinnedConnectionAbortSignalError as aG, type PgPoolAdapterOptions as aH, PgPreparedStatementReplayError as aI, type PgPreparedStatementsOptions as aJ, PgRawSqlTransactionControlError as aK, type PgReinitializePreflightOptions as aL, type PgReinitializePreflightPool as aM, type PgRollbackOnlyScope as aN, type PgSchemaDiff as aO, PgTransactionAbortSignalError as aP, PgTransactionAbortedCommitError as aQ, PgTransactionAbortedError as aR, PgTransactionOptionsError as aS, PgTransactionTimeoutError as aT, RawIndexPredicateFallbackError as aU, type ReferencedKeyKind as aV, type ReferencedKeyRemovalConflict as aW, ReferencedKeyRemovalError as aX, type SchemaChange as aY, type SchemaDiff as aZ, type SchemaScopeOptions as a_, type PgBorrowedClientAdapterOptions as aa, type PgCatalogueIdentityQueryable as ab, type PgCompileOnlyAdapterOptions as ac, type PgConvergeApplicationStep as ad, type PgConvergeAssertStep as ae, type PgConvergeInitializationFailure as af, type PgConvergeOnceStep as ag, type PgConvergePlannedStep as ah, type PgConvergeRefusal as ai, type PgConvergeRefusalChange as aj, PgConvergeRefusalError as ak, type PgLedgerLockResult as al, PgLedgerStorageUnsupportedError as am, type PgLedgerTarget as an, type PgOutcomeCheckpoint as ao, type PgOutcomeClaimRequest as ap, type PgOutcomeExecutionRequest as aq, type PgOutcomeNonTransactionalRequest as ar, type PgOutcomeReadBackFactory as as, type PgOutcomeRecoveryRequest as at, type PgOutcomeRecoveryResult as au, type PgOutcomeResolution as av, type PgOutcomeResolutionAppendResult as aw, type PgOutcomeResult as ax, type PgOutcomeTransactionalRequest as ay, type PgOwnedCheckState as az, type CompilerState as b, type PgOrderedLedgerLocks as b$, type WhereDispatcher as b0, type WhereHandler as b1, acquirePgLedgerLocks as b2, appendIntentJournal as b3, appendTransitionAuthorization as b4, assertCreateIndexSupported as b5, assertCreateIndexesSupported as b6, assertDeclarableChangeKind as b7, assertGeneratedPostconditionSession as b8, assertNoRepeatedExpressionSurfaceDrift as b9, readPgLedgerReservationsForExecution as bA, readPgLedgerScopeCurrency as bB, readPgOutcomeRecoveryReadBack as bC, readVerifiedPgLedgerReservationsForPair as bD, recordPgLedgerIdentity as bE, renderCreateDbspMetaSchemaSql as bF, renderCreateIndex as bG, renderCreateLedgerEventTableSql as bH, renderCreateLedgerIdentityTableSql as bI, renderCreateLedgerImmutabilityFunctionSql as bJ, renderCreateLedgerImmutabilityTriggerSql as bK, renderCreateLedgerMarkerTableSql as bL, renderCreateLedgerReservationTableSql as bM, renderCreateLedgerTerminalMemberIndexSql as bN, renderCreateTransitionAuthorizationTableSql as bO, renderCreateTransitionJournalTableSql as bP, renderCreateTransitionRunPlanTableSql as bQ, renderCreateTransitionRunTableSql as bR, runPgReinitializePreflight as bS, toGeneratedPostconditionBindingAddress as bT, validatePgLedgerRuntimeIntegrity as bU, verifyGeneratedCheckPostcondition as bV, verifyGeneratedColumnPostcondition as bW, verifyGeneratedIdentityPostcondition as bX, verifyGeneratedIndexPostcondition as bY, verifyGeneratedTablePostcondition as bZ, withGeneratedPostconditionSession as b_, canGenerateCreateIndex as ba, canonicalizeCheckConstraints as bb, comparePgDatabaseSchema as bc, compareSchemata as bd, createPgAdapter as be, createPgCompileOnlyAdapter as bf, createPgGeneratedManagedStep as bg, createPgPhysicalModel as bh, createPgTransitionRunPersister as bi, decodeGeneratedPostcondition as bj, decodeGeneratedPostconditionPayload as bk, defaultFkDerivation as bl, ensureDbspMetaLedger as bm, ensurePgLedger as bn, ensurePgLedgerStorageVersion as bo, ensureTransitionJournal as bp, executePgAdmittedOperation as bq, generateCreateIndex as br, generateDDL as bs, generateDownSQL as bt, generateMigrationSQL as bu, generatedPostconditionDigest as bv, generatedPostconditionForChange as bw, introspect as bx, readPgCatalogueIdentity as by, readPgLedgerMarker as bz, type PgLockedRun as c, type PgLedgerShapeAllowance as c0, type PgLedgerPhysicalShapeOutcome as c1, type DeclaredNameResolver as c2, type BindingNameRegistry as c3, type QueryScope as c4, type RelationTargetProjectionRegistry as c5, type ComparePgDatabaseSchemaOptions$1 as c6, type ComparePgDeclaredAdoptionSchemaInput as c7, type CompareSchemataOptions$1 as c8, type ConvergePgBaseOptions as c9, modelForDeclaredAdoption as cA, openPgOutcomeClaim as cB, openPgOutcomeClaimGroup as cC, pgDeclaredAdoptionDeclaration as cD, pgDeclaredSequenceAdoptionDeclaration as cE, readPgLedgerReservationsForPair as cF, recoverPgAdmittedReaddressPair as cG, recoverPgOutcomeClaim as cH, resolvePgDestructiveOutcome as cI, resolvePgOutcomeClaimGroup as cJ, type ConvergePgCheckOptions as ca, type GenerateDDLOptions$1 as cb, type MigrationSQLOptions$1 as cc, type PgAdoptionComparisonExecutor as cd, PgCommitAcknowledgementAmbiguousError as ce, appendPgLedgerClaim as cf, appendPgLedgerClaimGroup as cg, appendPgLedgerProgress as ch, appendPgLedgerRelease as ci, appendPgLedgerResolution as cj, appendPgLedgerResolutionGroup as ck, appendPgOutcomeResolution as cl, classifyPgLedgerPhysicalShape as cm, collectReferencedKeyRemovalConflicts as cn, comparePgDatabaseSchema$1 as co, comparePgDeclaredAdoptionSchema as cp, compareSchemata$1 as cq, convergePg as cr, createPgDeclaredAdoptionStep as cs, createPgDeclaredSequenceAdoptionStep as ct, createPgLedgerShapeAllowance as cu, executePgDestructiveOutcome as cv, generateDDL$1 as cw, generateDownSQL$1 as cx, generateMigrationSQL$1 as cy, lockPgJournalRun as cz, type PgOutcomeCheckpointObserver as d, type ConvergePgOptions as e, type PgPhysicalModel as f, type PgConvergeResult as g, type PgConvergeCheckResult as h, type PgLedgerScopeCurrency as i, AutoIncrementTransitionUnsupportedError as j, type CanonicalizeCheckConstraintsOptions as k, CheckConstraintCanonicalizationError as l, type CheckConstraintCanonicalizationWarning as m, CheckConstraintNewEnumValueError as n, ColumnDefaultCanonicalizationError as o, type ColumnDefaultCanonicalizationWarning as p, type ComparePgDatabaseSchemaOptions as q, readTransitionJournal as r, type CompareSchemataOptions as s, DEFAULT_PK_COLUMN as t, type DetectedHierarchy as u, type DiffSummary as v, type ExpressionCanonicalizationWarning as w, type ExpressionHandler as x, ExpressionKeyedIndexPredicateCanonicalizationUnsupportedError as y, type GenerateDDLOptions as z };