@dbsp/adapter-pgsql 3.5.0 → 4.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/chunk-KZ3NLIZ5.js +13043 -0
- package/dist/chunk-KZ3NLIZ5.js.map +1 -0
- package/dist/index.d.ts +577 -231
- package/dist/index.js +13729 -15117
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +34 -0
- package/dist/internal.js +47 -0
- package/dist/internal.js.map +1 -0
- package/dist/outcome-protocol-CACJDzli.d.ts +1088 -0
- package/package.json +7 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import * as _dbsp_core from '@dbsp/core';
|
|
2
|
-
import { IndexInfo, TruncateOptions, VacuumOptions, AlterColumnOptions, CreateIndexOptions, DropIndexOptions, ExpressionRef, ModelIR as ModelIR$1,
|
|
2
|
+
import { IndexInfo, TruncateOptions, VacuumOptions, AlterColumnOptions, CreateIndexOptions, DropIndexOptions, ExpressionRef, ModelIR as ModelIR$1, ValidatedManagedStepManifest, ExecutionCoordinator, CapabilityDescriptor } from '@dbsp/core';
|
|
3
3
|
export { normalizeSQL } from '@dbsp/core';
|
|
4
4
|
import * as _dbsp_types from '@dbsp/types';
|
|
5
|
-
import { DialectCapabilities, ModelIR, ColumnListInput, ParamIntent, JsonAggOrderByEntry, IndexIR, HierarchyIR, Adapter, DbCasing, 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, ColumnIR, MutationReturningItem, WhereIntent, OutputDescriptor, QueryIntent, OperationKindRef, SemanticArtifactRef, ProvenPlanShape, PostgreSqlObservationTargetIdentity, ExecutionContract, TransitionSessionClient,
|
|
5
|
+
import { DialectCapabilities, ModelIR, ColumnListInput, ParamIntent, JsonAggOrderByEntry, IndexIR, HierarchyIR, Adapter, DbCasing, 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, ColumnIR, MutationReturningItem, WhereIntent, OutputDescriptor, QueryIntent, LedgerHome, LedgerAddress, LedgerPayload, ScopedApprovalSet, NormalizedManagedStep, LedgerChainMember, OperationKindRef, SemanticArtifactRef, ProvenPlanShape, PostgreSqlObservationTargetIdentity, ExecutionContract, TransitionSessionClient, TransitionLessor, ExclusiveTransitionTarget, ObservationIssuer, ObservationRequest, ObservationContext, EvidenceObservation, TypeRef, ExpressionValue, CollationRef, LogicalIdentity, PhysicalOperation, OperationEffectAssessment, FingerprintManifest, DurableIntentRecord, IssuedObservation, ApplyGuard, AdvisoryObservation, TransactionalCompletionRecord, StepJournal, UnsafeNativeFragment, ResourceAddress, ExecutableAssertion, Assumption, TransitionRule, TransitionCompositionFact, TrustRoot, RequiredEnumLabelIR, TableReaddressDeclaration, LedgerReservationRow, LedgerRefusal, ContainmentClosureDestructiveOutcome, LedgerClaimKind } from '@dbsp/types';
|
|
6
6
|
import * as _pgsql_types from '@pgsql/types';
|
|
7
7
|
import { Node, OnConflictClause, ParamRef } from '@pgsql/types';
|
|
8
|
+
import { C as ChangeKind, a as CompareSchemataOptions, S as SchemaDiff, T as TransitionJournalQueryable, P as PgLockedRun, b as PgOutcomeCheckpointObserver } from './outcome-protocol-CACJDzli.js';
|
|
9
|
+
export { D as DiffSummary, E as ExpressionCanonicalizationUnavailableError, G as GeneratedPostcondition, c as GeneratedPostconditionBindingAddress, d as GeneratedPostconditionBindingResolutionError, e as GeneratedPostconditionProofInFlightError, f as GeneratedPostconditionReplanRequiredError, g as GeneratedPostconditionSession, h as GeneratedPostconditionSessionDeactivatedError, i as GeneratedPostconditionWorkInFlightError, j as PG_LEDGER_SHAPE_VERSION, k as PgAdmittedOperation, l as PgAdmittedOperationResult, m as PgCatalogueIdentityQueryable, n as PgLedgerLockResult, o as PgLedgerScopeCurrency, p as PgLedgerStorageUnsupportedError, q as PgLedgerTarget, r as PgOutcomeCheckpoint, s as PgOutcomeClaimRequest, t as PgOutcomeExecutionRequest, u as PgOutcomeNonTransactionalRequest, v as PgOutcomeReadBackFactory, w as PgOutcomeRecoveryRequest, x as PgOutcomeRecoveryResult, y as PgOutcomeResolution, z as PgOutcomeResolutionAppendResult, A as PgOutcomeResult, B as PgOutcomeTransactionalRequest, F as PgReinitializePreflightOptions, H as PgReinitializePreflightPool, I as SchemaChange, J as TransitionRunIdentityMismatchError, K as acquirePgLedgerLocks, L as appendIntentJournal, M as appendTransitionAuthorization, N as assertDeclarableChangeKind, O as assertGeneratedPostconditionSession, Q as compareSchemata, R as createPgTransitionRunPersister, U as createPgsqlGeneratedManagedStep, V as decodeGeneratedPostcondition, W as decodeGeneratedPostconditionPayload, X as ensureDbspMetaLedger, Y as ensurePgLedger, Z as ensurePgLedgerStorageVersion, _ as ensureTransitionJournal, $ as executePgAdmittedOperation, a0 as generatedPostconditionDigest, a1 as generatedPostconditionForChange, a2 as readPgCatalogueIdentity, a3 as readPgLedgerMarker, a4 as readPgLedgerReservationsForExecution, a5 as readPgLedgerScopeCurrency, a6 as readPgOutcomeRecoveryReadBack, a7 as readTransitionJournal, a8 as readVerifiedPgLedgerReservationsForPair, a9 as recordPgLedgerIdentity, aa as renderCreateDbspMetaSchemaSql, ab as renderCreateLedgerEventTableSql, ac as renderCreateLedgerIdentityTableSql, ad as renderCreateLedgerImmutabilityFunctionSql, ae as renderCreateLedgerImmutabilityTriggerSql, af as renderCreateLedgerMarkerTableSql, ag as renderCreateLedgerReservationTableSql, ah as renderCreateLedgerTerminalMemberIndexSql, ai as renderCreateTransitionAuthorizationTableSql, aj as renderCreateTransitionJournalTableSql, ak as renderCreateTransitionRunPlanTableSql, al as renderCreateTransitionRunTableSql, am as runPgReinitializePreflight, an as toGeneratedPostconditionBindingAddress, ao as validatePgLedgerRuntimeIntegrity, ap as verifyGeneratedCheckPostcondition, aq as verifyGeneratedColumnPostcondition, ar as verifyGeneratedIdentityPostcondition, as as verifyGeneratedIndexPostcondition, at as verifyGeneratedTablePostcondition, au as withGeneratedPostconditionSession } from './outcome-protocol-CACJDzli.js';
|
|
8
10
|
import { Pool, PoolClient } from 'pg';
|
|
11
|
+
import '@dbsp/core/internal';
|
|
9
12
|
|
|
10
13
|
/**
|
|
11
14
|
* Default primary key column name used as convention fallback
|
|
@@ -728,6 +731,8 @@ declare class PlanCompiler {
|
|
|
728
731
|
*/
|
|
729
732
|
declare function compilePlan(plan: SimplifiedPlanReport, options?: CompilerOptions): CompiledResult;
|
|
730
733
|
|
|
734
|
+
declare function dbTypesEqual(a: string, b: string): boolean;
|
|
735
|
+
|
|
731
736
|
type IndexRenderKey = {
|
|
732
737
|
readonly column?: string | undefined;
|
|
733
738
|
readonly expression?: string | undefined;
|
|
@@ -744,6 +749,8 @@ type IndexRenderSpec = {
|
|
|
744
749
|
readonly nullsNotDistinct?: boolean | undefined;
|
|
745
750
|
readonly with?: Readonly<Record<string, unknown>> | undefined;
|
|
746
751
|
readonly where?: string | undefined;
|
|
752
|
+
/** The in-process index value that owns a deparsed `where` predicate. */
|
|
753
|
+
readonly whereSource?: IndexIR | undefined;
|
|
747
754
|
readonly concurrently?: boolean | undefined;
|
|
748
755
|
readonly ifNotExists?: boolean | undefined;
|
|
749
756
|
};
|
|
@@ -803,7 +810,7 @@ interface GenerateDDLOptions {
|
|
|
803
810
|
* @returns Array of DDL statements in dependency order
|
|
804
811
|
*/
|
|
805
812
|
declare function generateDDL(schema: ModelIR, options?: GenerateDDLOptions): string[];
|
|
806
|
-
declare function generateCreateIndex(tableName: string, idx: IndexIR, schemaName: string | undefined, naming: NamingPlugin, context?: IndexCapabilityContext): string;
|
|
813
|
+
declare function generateCreateIndex(tableName: string, idx: IndexIR, schemaName: string | undefined, naming: NamingPlugin, context?: IndexCapabilityContext, ifNotExists?: boolean): string;
|
|
807
814
|
/**
|
|
808
815
|
* Returns whether the PostgreSQL DDL generator can emit this IndexIR.
|
|
809
816
|
*
|
|
@@ -813,6 +820,25 @@ declare function generateCreateIndex(tableName: string, idx: IndexIR, schemaName
|
|
|
813
820
|
*/
|
|
814
821
|
declare function canGenerateCreateIndex(tableName: string, idx: IndexIR, schemaName?: string | undefined, naming?: NamingPlugin): boolean;
|
|
815
822
|
|
|
823
|
+
/** EFF-04's closed generated-mutation result domain. */
|
|
824
|
+
type GeneratedMutationClassification = 'non-destructive' | 'removal' | 'data-destructive'
|
|
825
|
+
/** A table rename is executed only by the paired re-address protocol. */
|
|
826
|
+
| 'paired-readdress';
|
|
827
|
+
/**
|
|
828
|
+
* Total, fail-closed classifier for generator mutations. `string` is deliberate:
|
|
829
|
+
* a newly-added ChangeKind cannot silently become safe before this table names it.
|
|
830
|
+
*/
|
|
831
|
+
declare function classifyGeneratedMutation(kind: ChangeKind | string, change?: {
|
|
832
|
+
readonly destructive?: boolean;
|
|
833
|
+
}): GeneratedMutationClassification;
|
|
834
|
+
declare function isGeneratedMutationDestructive(kind: ChangeKind | string, change?: {
|
|
835
|
+
readonly destructive?: boolean;
|
|
836
|
+
}): boolean;
|
|
837
|
+
/** All removal statements remain generator-only; no transition operation maps one. */
|
|
838
|
+
declare function refusesRecordedPlanRemoval(kind: ChangeKind | string, change?: {
|
|
839
|
+
readonly destructive?: boolean;
|
|
840
|
+
}): boolean;
|
|
841
|
+
|
|
816
842
|
/**
|
|
817
843
|
* PostgreSQL Schema Introspection (ADAPTER-006)
|
|
818
844
|
*
|
|
@@ -957,6 +983,23 @@ declare class PgsqlTransactionTimeoutError extends Error {
|
|
|
957
983
|
readonly dbspTransactionTimeout = true;
|
|
958
984
|
constructor(cause: unknown, timeout: PgsqlTransactionTimeoutParameter);
|
|
959
985
|
}
|
|
986
|
+
/**
|
|
987
|
+
* Raised when the single safe unnamed replay after a prepared-statement
|
|
988
|
+
* infrastructure failure also fails. `message` is always the safe constant
|
|
989
|
+
* `Prepared statement recovery replay failed.`; `cause` is the replay error;
|
|
990
|
+
* `infrastructureError` is the original infrastructure error; and
|
|
991
|
+
* `admissionFingerprint` identifies the admitted statement. DBSP-authored
|
|
992
|
+
* messages carry no parameter values; preserved upstream errors, including the
|
|
993
|
+
* standard Error `cause`, are unsanitized.
|
|
994
|
+
*/
|
|
995
|
+
declare class PgsqlPreparedStatementReplayError extends Error {
|
|
996
|
+
readonly admissionFingerprint: string;
|
|
997
|
+
readonly infrastructureError: unknown;
|
|
998
|
+
readonly dbspPreparedStatementReplay = true;
|
|
999
|
+
readonly originalInfrastructureError: unknown;
|
|
1000
|
+
readonly originalError: unknown;
|
|
1001
|
+
constructor(admissionFingerprint: string, infrastructureError: unknown, cause: unknown);
|
|
1002
|
+
}
|
|
960
1003
|
/**
|
|
961
1004
|
* Options for PgsqlAdapter.
|
|
962
1005
|
*/
|
|
@@ -988,10 +1031,45 @@ interface PgsqlAdapterOptions {
|
|
|
988
1031
|
*/
|
|
989
1032
|
readonly preparedStatements?: boolean | PgsqlPreparedStatementsOptions;
|
|
990
1033
|
}
|
|
991
|
-
interface
|
|
1034
|
+
interface PgsqlPoolAdapterOptionsBase extends PgsqlAdapterOptions {
|
|
992
1035
|
readonly borrowedClient?: false;
|
|
993
1036
|
}
|
|
1037
|
+
type PgsqlPoolAdapterOptions = (PgsqlPoolAdapterOptionsBase & {
|
|
1038
|
+
readonly replayInvalidatedPlans?: false | undefined;
|
|
1039
|
+
}) | (Omit<PgsqlPoolAdapterOptionsBase, 'preparedStatements'> & {
|
|
1040
|
+
readonly preparedStatements: true | PgsqlPreparedStatementsOptions;
|
|
1041
|
+
/**
|
|
1042
|
+
* Enable one unnamed replay after `0A000`/`RevalidateCachedQuery` only when
|
|
1043
|
+
* you assert that your statements do not invoke functions performing
|
|
1044
|
+
* effectful work before nested prepared-statement operations. This requires
|
|
1045
|
+
* `preparedStatements: true` (or a prepared-statements options object).
|
|
1046
|
+
*
|
|
1047
|
+
* Replay snapshots JSON-like values (finite numbers, strings, booleans,
|
|
1048
|
+
* `null`, arrays, plain or null-prototype objects) and clean `Date`/`Buffer`
|
|
1049
|
+
* instances. It excludes non-finite numbers, `undefined`, `bigint`, functions,
|
|
1050
|
+
* proxies, cycles, sparse arrays, accessors, symbol-valued
|
|
1051
|
+
* parameters, symbol keys on plain objects, exotic prototypes, custom built-ins,
|
|
1052
|
+
* and values with their own node-postgres
|
|
1053
|
+
* `toPostgres` behavior.
|
|
1054
|
+
* Serialization-irrelevant symbol metadata on arrays and Buffers is ignored.
|
|
1055
|
+
* The detached snapshot covers later mutations to the supplied value graph,
|
|
1056
|
+
* not built-in prototypes, timezone state, or node-postgres serialization
|
|
1057
|
+
* configuration; a process-global `toPostgres` or `toJSON` installed while
|
|
1058
|
+
* the call is in flight is outside the guarantee. Each capture or replay copy
|
|
1059
|
+
* is independently limited to 64 Ki visited values, 16 MiB of UTF-8 strings,
|
|
1060
|
+
* and 16 MiB of Buffer data. An ineligible or over-budget value still receives
|
|
1061
|
+
* the initial named submission, but disables transparent replay.
|
|
1062
|
+
* These budgets bound copied nodes and payload bytes; enumerating a plain
|
|
1063
|
+
* object's existing property table is proportional to the caller's own object.
|
|
1064
|
+
*
|
|
1065
|
+
* Replay needs the adapter-owned serialized physical client available from a
|
|
1066
|
+
* pool; it is therefore not supported by borrowed or compile-only adapters.
|
|
1067
|
+
*/
|
|
1068
|
+
readonly replayInvalidatedPlans: true;
|
|
1069
|
+
});
|
|
994
1070
|
interface PgsqlBorrowedClientAdapterOptions extends PgsqlAdapterOptions {
|
|
1071
|
+
/** Replay is only available to a pool-owned pinned scope. */
|
|
1072
|
+
readonly replayInvalidatedPlans?: never;
|
|
995
1073
|
/** This connection belongs to the caller. dbsp never releases it. */
|
|
996
1074
|
readonly borrowedClient: true;
|
|
997
1075
|
/**
|
|
@@ -1021,6 +1099,10 @@ interface PgsqlBorrowedClientAdapterOptions extends PgsqlAdapterOptions {
|
|
|
1021
1099
|
*/
|
|
1022
1100
|
readonly managedTransactions?: true;
|
|
1023
1101
|
}
|
|
1102
|
+
/** Options for a connectionless adapter, which cannot own replay serialization. */
|
|
1103
|
+
interface PgsqlCompileOnlyAdapterOptions extends PgsqlAdapterOptions {
|
|
1104
|
+
readonly replayInvalidatedPlans?: never;
|
|
1105
|
+
}
|
|
1024
1106
|
/**
|
|
1025
1107
|
* Adapter implementation for PostgreSQL using native pg driver.
|
|
1026
1108
|
*
|
|
@@ -1051,6 +1133,7 @@ declare class PgsqlAdapter<DB = unknown> implements Adapter<DB> {
|
|
|
1051
1133
|
private readonly naming;
|
|
1052
1134
|
private readonly model;
|
|
1053
1135
|
private readonly logger;
|
|
1136
|
+
private readonly replayInvalidatedPlans;
|
|
1054
1137
|
private readonly preparedStatements;
|
|
1055
1138
|
private readonly preparedStatementRegistry;
|
|
1056
1139
|
private readonly _capabilities;
|
|
@@ -1068,10 +1151,9 @@ declare class PgsqlAdapter<DB = unknown> implements Adapter<DB> {
|
|
|
1068
1151
|
* or nothing at all for compile-only mode
|
|
1069
1152
|
* @param options - configuration; declares connection ownership
|
|
1070
1153
|
*/
|
|
1071
|
-
constructor(pool?: Pool | undefined, options?: PgsqlPoolAdapterOptions);
|
|
1072
1154
|
constructor(pool: Pool, options?: PgsqlPoolAdapterOptions);
|
|
1073
1155
|
constructor(client: PoolClient, options: PgsqlBorrowedClientAdapterOptions);
|
|
1074
|
-
constructor(pool
|
|
1156
|
+
constructor(pool?: undefined, options?: PgsqlCompileOnlyAdapterOptions);
|
|
1075
1157
|
/**
|
|
1076
1158
|
* Shared compilation dependencies — built lazily from adapter fields.
|
|
1077
1159
|
* Passed to compiler sub-modules instead of `this`.
|
|
@@ -1096,6 +1178,8 @@ declare class PgsqlAdapter<DB = unknown> implements Adapter<DB> {
|
|
|
1096
1178
|
get capabilities(): AdapterCapabilities;
|
|
1097
1179
|
/** Per-instance connection state, distinct from PostgreSQL capabilities. */
|
|
1098
1180
|
get connectionAvailability(): ConnectionAvailability;
|
|
1181
|
+
/** Side-effect-free execution availability for core feature detection. */
|
|
1182
|
+
executionAvailable(): boolean;
|
|
1099
1183
|
/** PostgreSQL dialect capabilities for planner strategy selection */
|
|
1100
1184
|
get dialectCapabilities(): DialectCapabilities;
|
|
1101
1185
|
/**
|
|
@@ -1104,6 +1188,13 @@ declare class PgsqlAdapter<DB = unknown> implements Adapter<DB> {
|
|
|
1104
1188
|
get dbCasing(): DbCasing;
|
|
1105
1189
|
/**
|
|
1106
1190
|
* Get the underlying pg Pool or borrowed PoolClient instance.
|
|
1191
|
+
*
|
|
1192
|
+
* Exposing raw access from a pool-owned dbsp-managed scope permanently taints that
|
|
1193
|
+
* physical client: external callers can queue commands outside dbsp's statement
|
|
1194
|
+
* lock, so replay is disabled and dbsp destroys the client at scope release.
|
|
1195
|
+
* Expect pool churn; session state on that exposed connection does not survive the
|
|
1196
|
+
* release. A borrowed client remains caller-owned: dbsp never releases it, and the
|
|
1197
|
+
* caller decides its fate after raw exposure.
|
|
1107
1198
|
*/
|
|
1108
1199
|
getPoolInstance(): Pool | PoolClient;
|
|
1109
1200
|
/**
|
|
@@ -1210,8 +1301,8 @@ declare class PgsqlAdapter<DB = unknown> implements Adapter<DB> {
|
|
|
1210
1301
|
* Execute a query and return rows plus PostgreSQL result metadata.
|
|
1211
1302
|
* Results are transformed to use model naming convention (e.g., snake_case → camelCase)
|
|
1212
1303
|
*/
|
|
1213
|
-
executeWithMeta
|
|
1214
|
-
readonly rows:
|
|
1304
|
+
executeWithMeta(query: CompiledQuery): Promise<{
|
|
1305
|
+
readonly rows: readonly unknown[];
|
|
1215
1306
|
readonly rowCount: number;
|
|
1216
1307
|
readonly command?: string;
|
|
1217
1308
|
}>;
|
|
@@ -1425,6 +1516,13 @@ declare class PgsqlAdapter<DB = unknown> implements Adapter<DB> {
|
|
|
1425
1516
|
get inTransaction(): boolean;
|
|
1426
1517
|
private adapterManagedScopeIsLive;
|
|
1427
1518
|
private shouldProtectBorrowedClientTransaction;
|
|
1519
|
+
/**
|
|
1520
|
+
* An idle ReadyForQuery status says nothing about commands another owner has
|
|
1521
|
+
* already queued on a PoolClient. Only a dbsp-created pinned scope both owns
|
|
1522
|
+
* the checked-out physical client and holds its statement lock across the
|
|
1523
|
+
* failed named execution and any unnamed replay.
|
|
1524
|
+
*/
|
|
1525
|
+
private ownsSerializedClientForPreparedStatementReplay;
|
|
1428
1526
|
private executeQueryProtectingOpenTransaction;
|
|
1429
1527
|
private executeConnectionStatement;
|
|
1430
1528
|
private executeConnectionStatementUnlocked;
|
|
@@ -1539,7 +1637,7 @@ declare function createPgsqlAdapter<DB = unknown>(client: PoolClient, options: P
|
|
|
1539
1637
|
* console.log(dump.sql);
|
|
1540
1638
|
* ```
|
|
1541
1639
|
*/
|
|
1542
|
-
declare function createPgsqlCompileOnlyAdapter<DB = unknown>(options?:
|
|
1640
|
+
declare function createPgsqlCompileOnlyAdapter<DB = unknown>(options?: PgsqlCompileOnlyAdapterOptions): PgsqlAdapter<DB>;
|
|
1543
1641
|
|
|
1544
1642
|
interface CheckConstraintCanonicalizationWarning {
|
|
1545
1643
|
readonly table: string;
|
|
@@ -1561,7 +1659,18 @@ interface ColumnDefaultCanonicalizationWarning {
|
|
|
1561
1659
|
/** Present when the default could not be paired with the opposite model side. */
|
|
1562
1660
|
readonly side?: 'desired' | 'database';
|
|
1563
1661
|
}
|
|
1564
|
-
|
|
1662
|
+
interface IndexPredicateCanonicalizationWarning {
|
|
1663
|
+
readonly table: string;
|
|
1664
|
+
readonly kind: 'index_predicate';
|
|
1665
|
+
readonly name: string;
|
|
1666
|
+
readonly message: string;
|
|
1667
|
+
readonly cause: unknown;
|
|
1668
|
+
readonly outcome: 'unavailable' | 'rejected' | 'refused';
|
|
1669
|
+
/** Predicate fallback always compares both complete models raw. */
|
|
1670
|
+
readonly comparison: 'raw';
|
|
1671
|
+
readonly side?: 'desired' | 'database';
|
|
1672
|
+
}
|
|
1673
|
+
type ExpressionCanonicalizationWarning = CheckConstraintCanonicalizationWarning | ColumnDefaultCanonicalizationWarning | IndexPredicateCanonicalizationWarning;
|
|
1565
1674
|
interface CanonicalizeCheckConstraintsOptions {
|
|
1566
1675
|
/** Database schema that owns the target tables and target-scoped enum types. */
|
|
1567
1676
|
readonly schemaName?: string;
|
|
@@ -1573,6 +1682,8 @@ interface CanonicalizeCheckConstraintsOptions {
|
|
|
1573
1682
|
readonly requireCanonicalization?: boolean;
|
|
1574
1683
|
/** Skip CHECK scratch work when the caller's dialect does not support CHECK DDL. */
|
|
1575
1684
|
readonly canonicalizeCheckConstraints?: boolean;
|
|
1685
|
+
/** Capabilities used to generate the migration this scope is staging for. */
|
|
1686
|
+
readonly dialectCapabilities?: DialectCapabilities;
|
|
1576
1687
|
}
|
|
1577
1688
|
declare class CheckConstraintCanonicalizationError extends Error {
|
|
1578
1689
|
readonly table: string;
|
|
@@ -1591,108 +1702,11 @@ declare class ColumnDefaultCanonicalizationError extends Error {
|
|
|
1591
1702
|
*/
|
|
1592
1703
|
declare function canonicalizeCheckConstraints(adapter: RollbackOnlyPgsqlScope, desired: ModelIR, dbModel: ModelIR, options?: CanonicalizeCheckConstraintsOptions): Promise<ModelIR>;
|
|
1593
1704
|
|
|
1594
|
-
/**
|
|
1595
|
-
* Schema Comparison Engine (DDL-PROV Block 1)
|
|
1596
|
-
*
|
|
1597
|
-
* Compares two ModelIRs (schema definition vs database state)
|
|
1598
|
-
* and produces a structured diff of changes needed.
|
|
1599
|
-
*
|
|
1600
|
-
* @module schema-diff
|
|
1601
|
-
*/
|
|
1602
|
-
|
|
1603
|
-
type ChangeKind = 'create_table' | 'drop_table' | 'add_column' | 'drop_column' | 'alter_column_type' | 'alter_column_nullable' | 'alter_column_default' | 'alter_column_unique' | 'add_primary_key' | 'drop_primary_key' | 'add_foreign_key' | 'drop_foreign_key' | 'alter_foreign_key' | 'validate_constraint' | 'create_index' | 'drop_index' | 'add_check_constraint' | 'drop_check_constraint' | 'create_enum' | 'alter_enum_add_value' | 'drop_enum' | 'alter_column_collation' | 'alter_column_identity' | 'add_comment' | 'drop_comment' | 'create_extension' | 'drop_extension' | 'create_sequence' | 'alter_sequence' | 'drop_sequence' | 'enable_rls' | 'disable_rls' | 'create_policy' | 'drop_policy';
|
|
1604
|
-
interface SchemaChange {
|
|
1605
|
-
readonly kind: ChangeKind;
|
|
1606
|
-
readonly table: string;
|
|
1607
|
-
readonly column?: string;
|
|
1608
|
-
readonly destructive: boolean;
|
|
1609
|
-
readonly details: string;
|
|
1610
|
-
/** Additional metadata for SQL generation */
|
|
1611
|
-
readonly meta?: Readonly<Record<string, unknown>>;
|
|
1612
|
-
}
|
|
1613
|
-
interface DiffSummary {
|
|
1614
|
-
readonly tables: {
|
|
1615
|
-
readonly added: number;
|
|
1616
|
-
readonly dropped: number;
|
|
1617
|
-
};
|
|
1618
|
-
readonly columns: {
|
|
1619
|
-
readonly added: number;
|
|
1620
|
-
readonly dropped: number;
|
|
1621
|
-
readonly altered: number;
|
|
1622
|
-
};
|
|
1623
|
-
readonly indexes: {
|
|
1624
|
-
readonly added: number;
|
|
1625
|
-
readonly dropped: number;
|
|
1626
|
-
};
|
|
1627
|
-
readonly constraints: {
|
|
1628
|
-
readonly added: number;
|
|
1629
|
-
readonly dropped: number;
|
|
1630
|
-
readonly altered: number;
|
|
1631
|
-
};
|
|
1632
|
-
}
|
|
1633
|
-
interface SchemaDiff {
|
|
1634
|
-
readonly changes: readonly SchemaChange[];
|
|
1635
|
-
readonly hasDestructive: boolean;
|
|
1636
|
-
readonly summary: DiffSummary;
|
|
1637
|
-
}
|
|
1638
|
-
interface CompareSchemataOptions {
|
|
1639
|
-
/**
|
|
1640
|
-
* Database naming convention.
|
|
1641
|
-
* When set, schema model names (camelCase) are converted to DB format
|
|
1642
|
-
* (e.g. snake_case) before comparison with the introspected model.
|
|
1643
|
-
*/
|
|
1644
|
-
dbCasing?: DbCasing;
|
|
1645
|
-
/** Dialect capabilities — comparisons for unsupported features will be skipped */
|
|
1646
|
-
readonly dialectCapabilities?: DialectCapabilities;
|
|
1647
|
-
/**
|
|
1648
|
-
* When `true`, extensions present in the live DB but absent from the model
|
|
1649
|
-
* schema are silently ignored — no `drop_extension` change is emitted for them.
|
|
1650
|
-
* Only extensions explicitly declared in the model are managed (created if missing).
|
|
1651
|
-
*
|
|
1652
|
-
* Use this when the database image pre-installs extensions that the application
|
|
1653
|
-
* schema does not own (e.g. pgvector, pg_search bundled in a custom Postgres image).
|
|
1654
|
-
* Default: `false` (full-sync behaviour — unmanaged DB extensions produce a
|
|
1655
|
-
* `drop_extension` entry).
|
|
1656
|
-
*/
|
|
1657
|
-
readonly ignoreUnmanagedExtensions?: boolean;
|
|
1658
|
-
/**
|
|
1659
|
-
* Strict compile-only mode for callers that require convergence guarantees.
|
|
1660
|
-
*
|
|
1661
|
-
* `compareSchemata()` is intentionally pure and cannot ask PostgreSQL to
|
|
1662
|
-
* canonicalise raw-SQL expression surfaces. By default it keeps the historic
|
|
1663
|
-
* best-effort verbatim comparison for column defaults, CHECK expressions,
|
|
1664
|
-
* partial-index predicates, and index expressions. Set this flag to throw when either model
|
|
1665
|
-
* contains one of those surfaces so a caller cannot accidentally rely on a
|
|
1666
|
-
* compile-only diff for a convergence-sensitive check.
|
|
1667
|
-
*
|
|
1668
|
-
* Live PostgreSQL callers should use `comparePgsqlDatabaseSchema()`, which
|
|
1669
|
-
* canonicalises CHECK constraint expressions and column defaults before calling this function.
|
|
1670
|
-
* Under that live mode, every default surface considered under this option is
|
|
1671
|
-
* either canonicalised as a pair or explicitly refused. This does not prove
|
|
1672
|
-
* that the resulting migration is executable.
|
|
1673
|
-
* Partial-index predicates and index expressions are not canonicalised by the
|
|
1674
|
-
* live helper and are rejected there when this strict flag is set.
|
|
1675
|
-
*/
|
|
1676
|
-
readonly requireExpressionCanonicalization?: boolean;
|
|
1677
|
-
}
|
|
1678
|
-
declare class ExpressionCanonicalizationUnavailableError extends Error {
|
|
1679
|
-
readonly surfaces: readonly string[];
|
|
1680
|
-
constructor(surfaces: readonly string[]);
|
|
1681
|
-
}
|
|
1682
|
-
/**
|
|
1683
|
-
* Compare two ModelIRs and produce a structured diff.
|
|
1684
|
-
*
|
|
1685
|
-
* @param schema - The desired schema (from definition)
|
|
1686
|
-
* @param db - The current database state (from introspection)
|
|
1687
|
-
* @param options - Optional comparison settings (e.g. dbCasing)
|
|
1688
|
-
* @returns SchemaDiff with all changes needed to bring DB in sync with schema
|
|
1689
|
-
*/
|
|
1690
|
-
declare function compareSchemata(schema: ModelIR, db: ModelIR, options?: CompareSchemataOptions): SchemaDiff;
|
|
1691
|
-
|
|
1692
1705
|
interface ComparePgsqlDatabaseSchemaOptions extends CompareSchemataOptions, SchemaScopeOptions {
|
|
1693
1706
|
/**
|
|
1694
|
-
* Whether to canonicalise PostgreSQL CHECK constraint expressions
|
|
1695
|
-
* comparing. Defaults to `true`.
|
|
1707
|
+
* Whether to canonicalise PostgreSQL CHECK constraint expressions, column defaults, and predicates on column-keyed
|
|
1708
|
+
* partial indexes before comparing. Defaults to `true`. Expression-keyed
|
|
1709
|
+
* partial-index predicates are reported as unavailable. Set to `false` only for compatibility with
|
|
1696
1710
|
* legacy raw-string live diffs.
|
|
1697
1711
|
*
|
|
1698
1712
|
* Live canonicalisation creates temporary scratch tables inside an adapter
|
|
@@ -1710,7 +1724,7 @@ interface ComparePgsqlDatabaseSchemaOptions extends CompareSchemataOptions, Sche
|
|
|
1710
1724
|
readonly onExpressionCanonicalizationWarning?: (warning: ExpressionCanonicalizationWarning) => void;
|
|
1711
1725
|
/**
|
|
1712
1726
|
* Diff that the caller just applied before this live re-diff. Used only when
|
|
1713
|
-
*
|
|
1727
|
+
* expression surfaces are compared by raw text to fail loudly if the exact same
|
|
1714
1728
|
* expression-surface drift appears again after re-introspection.
|
|
1715
1729
|
*/
|
|
1716
1730
|
readonly previouslyAppliedDiff?: SchemaDiff;
|
|
@@ -1739,12 +1753,61 @@ declare class CheckConstraintNewEnumValueError extends Error {
|
|
|
1739
1753
|
readonly table: string;
|
|
1740
1754
|
readonly constraint: string;
|
|
1741
1755
|
readonly addedEnumValues: readonly AddedEnumValue[];
|
|
1742
|
-
|
|
1743
|
-
|
|
1756
|
+
constructor(table: string, constraint: string, addedEnumValues: readonly AddedEnumValue[]);
|
|
1757
|
+
}
|
|
1758
|
+
/** A raw partial-index predicate and added enum values cannot share one migration. */
|
|
1759
|
+
declare class PartialIndexPredicateNewEnumValueError extends Error {
|
|
1760
|
+
readonly addedEnumValues: readonly AddedEnumValue[];
|
|
1761
|
+
constructor(addedEnumValues: readonly AddedEnumValue[]);
|
|
1762
|
+
}
|
|
1763
|
+
/** #454: Predicate canonicalization is not implemented for indexes with expression keys. */
|
|
1764
|
+
declare class ExpressionKeyedIndexPredicateCanonicalizationUnsupportedError extends Error {
|
|
1765
|
+
readonly predicates: readonly {
|
|
1766
|
+
readonly side: 'desired' | 'database';
|
|
1767
|
+
readonly table: string;
|
|
1768
|
+
readonly index: string;
|
|
1769
|
+
}[];
|
|
1770
|
+
constructor(predicates: readonly {
|
|
1771
|
+
readonly side: 'desired' | 'database';
|
|
1772
|
+
readonly table: string;
|
|
1773
|
+
readonly index: string;
|
|
1774
|
+
}[]);
|
|
1775
|
+
}
|
|
1776
|
+
/**
|
|
1777
|
+
* A raw partial-index predicate cannot be proven to converge after PostgreSQL
|
|
1778
|
+
* deparses it, so emitting its CREATE statement is unsafe.
|
|
1779
|
+
*/
|
|
1780
|
+
declare class RawIndexPredicateFallbackError extends Error {
|
|
1781
|
+
constructor(cause?: unknown);
|
|
1782
|
+
}
|
|
1783
|
+
declare class IndexPredicateCanonicalizationError extends Error {
|
|
1784
|
+
readonly rejectedPredicates: readonly {
|
|
1785
|
+
readonly side: 'desired' | 'database';
|
|
1786
|
+
readonly table: string;
|
|
1787
|
+
readonly index: string;
|
|
1788
|
+
readonly reason?: unknown;
|
|
1789
|
+
}[];
|
|
1790
|
+
/**
|
|
1791
|
+
* Enum values added by this migration are diagnostic candidates only. They
|
|
1792
|
+
* are collected from the schema diff, never matched to a rejected index.
|
|
1793
|
+
*/
|
|
1794
|
+
readonly addedEnumValues: readonly AddedEnumValue[];
|
|
1795
|
+
constructor(rejectedPredicates: readonly {
|
|
1796
|
+
readonly side: 'desired' | 'database';
|
|
1797
|
+
readonly table: string;
|
|
1798
|
+
readonly index: string;
|
|
1799
|
+
readonly reason?: unknown;
|
|
1800
|
+
}[],
|
|
1801
|
+
/**
|
|
1802
|
+
* Enum values added by this migration are diagnostic candidates only. They
|
|
1803
|
+
* are collected from the schema diff, never matched to a rejected index.
|
|
1804
|
+
*/
|
|
1805
|
+
addedEnumValues?: readonly AddedEnumValue[]);
|
|
1744
1806
|
}
|
|
1745
1807
|
/**
|
|
1746
1808
|
* Live PostgreSQL schema diff: introspect, canonicalise desired CHECK
|
|
1747
|
-
* constraint expressions
|
|
1809
|
+
* constraint expressions, column defaults, and predicates on column-keyed
|
|
1810
|
+
* partial indexes through PostgreSQL, then call the pure synchronous
|
|
1748
1811
|
* schema comparator.
|
|
1749
1812
|
*
|
|
1750
1813
|
* If CHECK canonicalisation falls back while the same diff adds a plausibly
|
|
@@ -1754,9 +1817,9 @@ declare class CheckConstraintNewEnumValueError extends Error {
|
|
|
1754
1817
|
* that cannot run. Apply the enum addition by itself first, then add or update
|
|
1755
1818
|
* the CHECK constraint in a later migration.
|
|
1756
1819
|
*
|
|
1757
|
-
*
|
|
1758
|
-
*
|
|
1759
|
-
*
|
|
1820
|
+
* Index expressions are intentionally not canonicalised here; partial-index
|
|
1821
|
+
* predicates on expression-keyed indexes are reported as unavailable and are
|
|
1822
|
+
* therefore rejected by strict mode. They need their own key-shape substrate.
|
|
1760
1823
|
*/
|
|
1761
1824
|
declare function comparePgsqlDatabaseSchema(adapter: PgsqlAdapter, desired: ModelIR, options?: ComparePgsqlDatabaseSchemaOptions): Promise<SchemaDiff>;
|
|
1762
1825
|
declare function assertNoRepeatedExpressionSurfaceDrift(previouslyAppliedDiff: SchemaDiff, currentDiff: SchemaDiff, rawExpressionSurfaces?: ReadonlySet<string>): void;
|
|
@@ -1816,101 +1879,6 @@ declare function generateMigrationSQL(diff: SchemaDiff, options?: MigrationSQLOp
|
|
|
1816
1879
|
*/
|
|
1817
1880
|
declare function generateDownSQL(diff: SchemaDiff, options?: MigrationSQLOptions): readonly string[];
|
|
1818
1881
|
|
|
1819
|
-
/**
|
|
1820
|
-
* Migration File Format v2 — UP + DOWN sections.
|
|
1821
|
-
*
|
|
1822
|
-
* File format:
|
|
1823
|
-
* -- dbsp:destructive: true|false
|
|
1824
|
-
* <UP statements>;
|
|
1825
|
-
* -- DOWN
|
|
1826
|
-
* <DOWN statements>;
|
|
1827
|
-
*
|
|
1828
|
-
* The separator `-- DOWN` must be on its own line (SC-25).
|
|
1829
|
-
*
|
|
1830
|
-
* @module ddl/migration-file
|
|
1831
|
-
*/
|
|
1832
|
-
|
|
1833
|
-
/**
|
|
1834
|
-
* Result of parsing a migration file's UP/DOWN sections.
|
|
1835
|
-
*/
|
|
1836
|
-
interface ParsedMigrationFile {
|
|
1837
|
-
readonly upStatements: readonly string[];
|
|
1838
|
-
readonly downStatements: readonly string[];
|
|
1839
|
-
readonly hasDown: boolean;
|
|
1840
|
-
readonly destructive?: boolean | undefined;
|
|
1841
|
-
}
|
|
1842
|
-
/**
|
|
1843
|
-
* Generate a migration file content with UP and DOWN sections.
|
|
1844
|
-
*/
|
|
1845
|
-
declare function generateMigrationFile(diff: SchemaDiff, options?: MigrationSQLOptions & {
|
|
1846
|
-
name?: string;
|
|
1847
|
-
}): string;
|
|
1848
|
-
/**
|
|
1849
|
-
* Parse a migration file into UP and DOWN sections.
|
|
1850
|
-
* Separator: `^\s*-- DOWN\s*$` (strict regex, own line only — SC-25)
|
|
1851
|
-
*/
|
|
1852
|
-
declare function parseMigrationFile(content: string): ParsedMigrationFile;
|
|
1853
|
-
/**
|
|
1854
|
-
* Check if SQL statements contain destructive operations.
|
|
1855
|
-
* Destructive: DROP TABLE, DROP COLUMN, lossy ALTER COLUMN TYPE
|
|
1856
|
-
*/
|
|
1857
|
-
declare function isDestructiveDown(downStatements: readonly string[]): boolean;
|
|
1858
|
-
|
|
1859
|
-
/**
|
|
1860
|
-
* Migration Tracker — `_dbsp_migrations` table CRUD.
|
|
1861
|
-
*
|
|
1862
|
-
* Manages the tracking table that records which migrations
|
|
1863
|
-
* have been applied to a database.
|
|
1864
|
-
*/
|
|
1865
|
-
|
|
1866
|
-
interface MigrationRecord {
|
|
1867
|
-
/** Migration filename (e.g., "0001_create_users.sql") */
|
|
1868
|
-
readonly name: string;
|
|
1869
|
-
/** SHA-256 checksum of the migration file content */
|
|
1870
|
-
readonly checksum: string;
|
|
1871
|
-
/** When the migration was applied */
|
|
1872
|
-
readonly appliedAt: Date;
|
|
1873
|
-
/** Schema version at time of this migration */
|
|
1874
|
-
readonly schemaVersion: number;
|
|
1875
|
-
/** Whether this migration contains destructive changes */
|
|
1876
|
-
readonly destructive: boolean;
|
|
1877
|
-
}
|
|
1878
|
-
/**
|
|
1879
|
-
* Execute a callback under the migration advisory lock using a pinned client.
|
|
1880
|
-
* The lock is held for the duration of the callback.
|
|
1881
|
-
*
|
|
1882
|
-
* Intentional latent-bug fix: session-level advisory locks are not freed by
|
|
1883
|
-
* returning a PoolClient to pg's pool. If unlock fails, PgsqlAdapter destroys the
|
|
1884
|
-
* session instead of returning a possibly lock-holding connection to the pool.
|
|
1885
|
-
*/
|
|
1886
|
-
declare function withMigrationLock<T>(pool: Pool, fn: (client: PoolClient) => Promise<T>): Promise<T>;
|
|
1887
|
-
/**
|
|
1888
|
-
* Ensure the migrations tracking table exists.
|
|
1889
|
-
* Auto-migrates existing tables that lack `schema_version`/`destructive` columns,
|
|
1890
|
-
* and backfills `schema_version` by `applied_at` order for rows still at 0.
|
|
1891
|
-
*/
|
|
1892
|
-
declare function ensureMigrationsTable(pool: Pool): Promise<void>;
|
|
1893
|
-
/**
|
|
1894
|
-
* Get all applied migrations, ordered by name.
|
|
1895
|
-
*/
|
|
1896
|
-
declare function getAppliedMigrations(pool: Pool): Promise<readonly MigrationRecord[]>;
|
|
1897
|
-
/**
|
|
1898
|
-
* Record a migration as applied.
|
|
1899
|
-
*/
|
|
1900
|
-
declare function recordMigration(pool: Pool, name: string, checksum: string, schemaVersion: number, destructive: boolean): Promise<void>;
|
|
1901
|
-
/**
|
|
1902
|
-
* Check if a specific migration has been applied.
|
|
1903
|
-
*/
|
|
1904
|
-
declare function isMigrationApplied(pool: Pool, name: string): Promise<boolean>;
|
|
1905
|
-
/**
|
|
1906
|
-
* Get the next schema version number (max + 1, or 1 if no migrations).
|
|
1907
|
-
*/
|
|
1908
|
-
declare function getNextSchemaVersion(pool: Pool): Promise<number>;
|
|
1909
|
-
/**
|
|
1910
|
-
* Remove a migration record (for rollback).
|
|
1911
|
-
*/
|
|
1912
|
-
declare function removeMigrationRecord(pool: Pool, name: string): Promise<void>;
|
|
1913
|
-
|
|
1914
1882
|
/**
|
|
1915
1883
|
* Type Mapping - Maps ModelIR ColumnType to PostgreSQL data types
|
|
1916
1884
|
*
|
|
@@ -2779,6 +2747,91 @@ declare function buildStreamingStatements(query: Node, config?: StreamConfig): {
|
|
|
2779
2747
|
close: Node;
|
|
2780
2748
|
};
|
|
2781
2749
|
|
|
2750
|
+
type PgAdoptionResult = {
|
|
2751
|
+
readonly outcome: 'completed';
|
|
2752
|
+
} | {
|
|
2753
|
+
readonly outcome: 'no-op';
|
|
2754
|
+
} | {
|
|
2755
|
+
readonly outcome: 'adoption-refused';
|
|
2756
|
+
readonly detail: string;
|
|
2757
|
+
} | {
|
|
2758
|
+
readonly outcome: 'execution-failed';
|
|
2759
|
+
readonly detail: string;
|
|
2760
|
+
} | {
|
|
2761
|
+
readonly outcome: 'recovery-required';
|
|
2762
|
+
readonly claimId: string;
|
|
2763
|
+
readonly detail: string;
|
|
2764
|
+
} | {
|
|
2765
|
+
readonly outcome: 'transport-ambiguous';
|
|
2766
|
+
readonly detail: string;
|
|
2767
|
+
};
|
|
2768
|
+
type PgAdoptionPreflightResult = {
|
|
2769
|
+
readonly outcome: 'ready';
|
|
2770
|
+
} | {
|
|
2771
|
+
readonly outcome: 'no-op';
|
|
2772
|
+
} | {
|
|
2773
|
+
readonly outcome: 'adoption-refused';
|
|
2774
|
+
readonly detail: string;
|
|
2775
|
+
} | {
|
|
2776
|
+
readonly outcome: 'execution-failed';
|
|
2777
|
+
readonly detail: string;
|
|
2778
|
+
};
|
|
2779
|
+
interface PgDeclaredAdoptionInput {
|
|
2780
|
+
readonly executor: TransitionJournalQueryable;
|
|
2781
|
+
readonly home: LedgerHome;
|
|
2782
|
+
readonly address: LedgerAddress;
|
|
2783
|
+
readonly declaration: LedgerPayload;
|
|
2784
|
+
/** Identity observed while the digest-covered adoption plan was reviewed. */
|
|
2785
|
+
readonly expectedCatalogueIdentity: NonNullable<LedgerAddress['catalogueIdentity']>;
|
|
2786
|
+
readonly shapeMatches: (executor: TransitionJournalQueryable) => Promise<boolean>;
|
|
2787
|
+
}
|
|
2788
|
+
interface PgPersistedDeclaredAdoptionInput extends PgDeclaredAdoptionInput {
|
|
2789
|
+
/** Locked durable identity and its full reviewed manifest from apply. */
|
|
2790
|
+
readonly run: PgLockedRun;
|
|
2791
|
+
readonly manifest: ValidatedManagedStepManifest;
|
|
2792
|
+
readonly recomputedPlanDigest: string;
|
|
2793
|
+
readonly approval: ScopedApprovalSet;
|
|
2794
|
+
/** Attempt namespace journaled before this lifecycle can open a claim. */
|
|
2795
|
+
readonly executionId: string;
|
|
2796
|
+
/** Exact digest-covered step; adoption never constructs a standalone plan. */
|
|
2797
|
+
readonly step: NormalizedManagedStep;
|
|
2798
|
+
/** Test-only admitted-path observation; absent from normal callers. */
|
|
2799
|
+
readonly observer?: PgOutcomeCheckpointObserver;
|
|
2800
|
+
}
|
|
2801
|
+
/**
|
|
2802
|
+
* Inspect a declared adoption without opening its adopt-intent claim.
|
|
2803
|
+
*
|
|
2804
|
+
* The generator executes this pass for every declared adoption before it opens
|
|
2805
|
+
* any claim for ordinary schema work. A changed shape or physical identity is
|
|
2806
|
+
* therefore reported as the actionable adoption refusal, rather than being
|
|
2807
|
+
* hidden behind an unrelated destructive-authority refusal.
|
|
2808
|
+
*/
|
|
2809
|
+
declare function preflightPgDeclaredAdoption(input: PgDeclaredAdoptionInput): Promise<PgAdoptionPreflightResult>;
|
|
2810
|
+
/**
|
|
2811
|
+
* The caller supplies the already-established live shape comparison. This
|
|
2812
|
+
* adapter owns the identity read and the only append path, so a matching shape
|
|
2813
|
+
* can never be turned into an adoption without a live catalogue identity.
|
|
2814
|
+
*/
|
|
2815
|
+
declare function executePgDeclaredAdoption(input: PgPersistedDeclaredAdoptionInput): Promise<PgAdoptionResult>;
|
|
2816
|
+
|
|
2817
|
+
interface PgLedgerAddressChain {
|
|
2818
|
+
readonly ledger: LedgerHome;
|
|
2819
|
+
readonly address: LedgerAddress;
|
|
2820
|
+
/** Every member is returned so the core projector can diagnose malformed chains. */
|
|
2821
|
+
readonly events: readonly LedgerChainMember[];
|
|
2822
|
+
/** Undefined means there is no unique terminal member; it is never inferred by row order. */
|
|
2823
|
+
readonly terminalMember?: LedgerChainMember;
|
|
2824
|
+
}
|
|
2825
|
+
/** Finds a terminal by predecessor topology only; callers must not use row position. */
|
|
2826
|
+
declare function findPgLedgerTerminalMember(events: readonly LedgerChainMember[]): LedgerChainMember | undefined;
|
|
2827
|
+
/**
|
|
2828
|
+
* Reads one address without imposing an insertion order. The resulting full
|
|
2829
|
+
* chain feeds the core projection, which owns all lifecycle interpretation.
|
|
2830
|
+
*/
|
|
2831
|
+
declare function readPgLedgerAddressChain(executor: TransitionJournalQueryable, ledger: LedgerHome, address: LedgerAddress): Promise<PgLedgerAddressChain>;
|
|
2832
|
+
/** Read the durable PostgreSQL role identity for the selected terminal event. */
|
|
2833
|
+
declare function readPgLedgerControllerOid(executor: TransitionJournalQueryable, ledger: LedgerHome, address: LedgerAddress, eventId: string): Promise<string>;
|
|
2834
|
+
|
|
2782
2835
|
declare const PG_OPERATION_PACK_ARTIFACT: SemanticArtifactRef;
|
|
2783
2836
|
declare const PG_RULE_PACK_ARTIFACT: SemanticArtifactRef;
|
|
2784
2837
|
declare const PG_INTROSPECTION_ARTIFACT: SemanticArtifactRef;
|
|
@@ -2794,6 +2847,11 @@ declare const DBSP_META_SCHEMA = "dbsp_meta";
|
|
|
2794
2847
|
declare const DBSP_TRANSITION_RUN_TABLE = "dbsp_transition_run";
|
|
2795
2848
|
declare const DBSP_TRANSITION_RUN_PLAN_TABLE = "dbsp_transition_run_plan";
|
|
2796
2849
|
declare const DBSP_TRANSITION_JOURNAL_TABLE = "dbsp_transition_journal";
|
|
2850
|
+
declare const DBSP_TRANSITION_AUTHORIZATION_TABLE = "dbsp_transition_authorization";
|
|
2851
|
+
declare const DBSP_LEDGER_EVENT_TABLE = "dbsp_ledger_event";
|
|
2852
|
+
declare const DBSP_LEDGER_RESERVATION_TABLE = "dbsp_ledger_reservation";
|
|
2853
|
+
declare const DBSP_LEDGER_IDENTITY_TABLE = "dbsp_ledger_identity";
|
|
2854
|
+
declare const DBSP_LEDGER_MARKER_TABLE = "dbsp_ledger_marker";
|
|
2797
2855
|
declare const DBSP_LOGICAL_IDENTITY_TABLE = "dbsp_logical_identity";
|
|
2798
2856
|
declare const COLUMN_EXISTS_OBSERVATION = "postgresql.column.exists";
|
|
2799
2857
|
declare const ENUM_TYPE_EXISTS_OBSERVATION = "postgresql.enum-type.exists";
|
|
@@ -2803,6 +2861,33 @@ declare const ENGINE_VERSION_OBSERVATION = "postgresql.engine.version-supported"
|
|
|
2803
2861
|
declare const LOGICAL_IDENTITY_CARRIER_OBSERVATION = "postgresql.logical-identity.carrier-state";
|
|
2804
2862
|
declare const NO_NULLS_GUARD = "NO_NULLS";
|
|
2805
2863
|
|
|
2864
|
+
/** The stable command outcome for a PostgreSQL target that cannot accept writes. */
|
|
2865
|
+
declare const DATABASE_READ_ONLY_OUTCOME: "database-read-only";
|
|
2866
|
+
declare class PgDatabaseReadOnlyError extends Error {
|
|
2867
|
+
readonly code: "database-read-only";
|
|
2868
|
+
constructor(detail: string);
|
|
2869
|
+
}
|
|
2870
|
+
declare function isPgDatabaseReadOnlyError(error: unknown): error is PgDatabaseReadOnlyError;
|
|
2871
|
+
type PgDatabaseWritability = {
|
|
2872
|
+
readonly kind: 'writable';
|
|
2873
|
+
} | {
|
|
2874
|
+
readonly kind: typeof DATABASE_READ_ONLY_OUTCOME;
|
|
2875
|
+
readonly detail: string;
|
|
2876
|
+
} | {
|
|
2877
|
+
readonly kind: 'unavailable';
|
|
2878
|
+
readonly detail: string;
|
|
2879
|
+
};
|
|
2880
|
+
/**
|
|
2881
|
+
* One PostgreSQL writability classification for every managed mutation. Both
|
|
2882
|
+
* a physical standby and a session made read-only by default reach the same
|
|
2883
|
+
* outcome; an unreadable response is deliberately not treated as writable.
|
|
2884
|
+
*/
|
|
2885
|
+
declare function classifyPgDatabaseWritability(executor: TransitionJournalQueryable): Promise<PgDatabaseWritability>;
|
|
2886
|
+
/** Fail closed without replacing a PostgreSQL query failure's own words. */
|
|
2887
|
+
declare function assertPgDatabaseWritable(executor: TransitionJournalQueryable): Promise<void>;
|
|
2888
|
+
/** Preserve PostgreSQL's own failure words while normalizing SQLSTATE 25006. */
|
|
2889
|
+
declare function classifyPgWrite<T>(write: () => Promise<T>): Promise<T>;
|
|
2890
|
+
|
|
2806
2891
|
/**
|
|
2807
2892
|
* A proven operation may still be ineligible for a durable execution contract
|
|
2808
2893
|
* when its reviewed requirements cannot be derived. The CLI renders this as a
|
|
@@ -2827,7 +2912,7 @@ declare function readPgExecutionTargetFromClient(target: TransitionSessionClient
|
|
|
2827
2912
|
readonly sessionProvenance: Readonly<Record<'search_path' | 'client_encoding' | 'TimeZone', string>>;
|
|
2828
2913
|
}>;
|
|
2829
2914
|
/** Build the versioned canonical document once, while the plan is minted. */
|
|
2830
|
-
declare function createPgExecutionContract(plan: ProvenPlanShape, identity: PostgreSqlObservationTargetIdentity,
|
|
2915
|
+
declare function createPgExecutionContract(plan: ProvenPlanShape, identity: PostgreSqlObservationTargetIdentity, sessionProvenance: Readonly<Record<'search_path' | 'client_encoding' | 'TimeZone', string>>): ExecutionContract;
|
|
2831
2916
|
/** Evaluate the stored document on the leased executor, before it renders SQL. */
|
|
2832
2917
|
declare function evaluatePgExecutionContract(target: TransitionSessionClient, contract: ExecutionContract): Promise<{
|
|
2833
2918
|
readonly ok: true;
|
|
@@ -2836,23 +2921,39 @@ declare function evaluatePgExecutionContract(target: TransitionSessionClient, co
|
|
|
2836
2921
|
readonly clause: string;
|
|
2837
2922
|
readonly detail: string;
|
|
2838
2923
|
}>;
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2924
|
+
/**
|
|
2925
|
+
* The durable preflight boundary. This intentionally receives a core-minted
|
|
2926
|
+
* leased session, so SET/SHOW and the context used by the renderer are on the
|
|
2927
|
+
* exact connection that subsequently records intent and executes DDL.
|
|
2928
|
+
*/
|
|
2929
|
+
declare function preparePgExecutionSession(target: TransitionSessionClient, contract: ExecutionContract, plan: ProvenPlanShape): Promise<{
|
|
2930
|
+
readonly ok: true;
|
|
2931
|
+
readonly context: _dbsp_types.ObservationContext;
|
|
2932
|
+
} | {
|
|
2933
|
+
readonly ok: false;
|
|
2934
|
+
readonly kind: 'refused' | 'failed' | 'read-only';
|
|
2935
|
+
readonly detail: string;
|
|
2936
|
+
}>;
|
|
2937
|
+
/**
|
|
2938
|
+
* Recovery admission is intentionally narrower than apply preflight: it proves
|
|
2939
|
+
* only that recovery is reading the planned cluster, database and namespaces.
|
|
2940
|
+
* Target state may have changed, and revoked DDL authority is irrelevant to
|
|
2941
|
+
* classification.
|
|
2942
|
+
*/
|
|
2943
|
+
declare function preparePgRecoveryAdmission(target: TransitionSessionClient, contract: ExecutionContract): Promise<{
|
|
2944
|
+
readonly ok: true;
|
|
2945
|
+
readonly context: _dbsp_types.ObservationContext;
|
|
2946
|
+
} | {
|
|
2947
|
+
readonly ok: false;
|
|
2948
|
+
readonly detail: string;
|
|
2854
2949
|
}>;
|
|
2855
2950
|
|
|
2951
|
+
type PgTransitionRunLockResult<T> = {
|
|
2952
|
+
readonly kind: 'acquired';
|
|
2953
|
+
readonly value: T;
|
|
2954
|
+
} | {
|
|
2955
|
+
readonly kind: 'busy';
|
|
2956
|
+
};
|
|
2856
2957
|
type PgTransitionClientLease = {
|
|
2857
2958
|
readonly client: PoolClient;
|
|
2858
2959
|
query(sql: string, params?: unknown): Promise<{
|
|
@@ -2880,8 +2981,33 @@ type PgTransitionClientLease = {
|
|
|
2880
2981
|
* worth spending that.
|
|
2881
2982
|
*/
|
|
2882
2983
|
declare function createPgTransitionLessor(pool: Pool): TransitionLessor;
|
|
2883
|
-
/**
|
|
2984
|
+
/**
|
|
2985
|
+
* Acquire a configured PostgreSQL transition client.
|
|
2986
|
+
*
|
|
2987
|
+
* Callers that use the native adapter must pass this checked-out client with
|
|
2988
|
+
* `borrowedClient: true` and return it through `release()` when finished.
|
|
2989
|
+
*/
|
|
2884
2990
|
declare function acquirePgTransitionClient(pool: Pool): Promise<PgTransitionClientLease>;
|
|
2991
|
+
/**
|
|
2992
|
+
* Hold a session advisory lock on the same checked-out session used for every
|
|
2993
|
+
* transition segment. `pg_try_advisory_lock` makes contention an explicit
|
|
2994
|
+
* `busy` result rather than a hidden queue; releasing the client also releases
|
|
2995
|
+
* the lock if an unlock attempt itself fails.
|
|
2996
|
+
*/
|
|
2997
|
+
declare function withPgTransitionRunLock<T>(pool: Pool, runId: string, callback: (target: ExclusiveTransitionTarget) => Promise<T>): Promise<PgTransitionRunLockResult<T>>;
|
|
2998
|
+
|
|
2999
|
+
type Queryable$2 = {
|
|
3000
|
+
query(sql: string, params?: readonly unknown[]): Promise<{
|
|
3001
|
+
readonly rows: readonly Record<string, unknown>[];
|
|
3002
|
+
}>;
|
|
3003
|
+
};
|
|
3004
|
+
/**
|
|
3005
|
+
* Check every existing managed ledger before ordinary apply reaches the
|
|
3006
|
+
* execution-contract comparison. A restored plan's physical-target clause is
|
|
3007
|
+
* necessarily different too, but the ledger's fresh-ledger path is the
|
|
3008
|
+
* actionable refusal and must win that ordering.
|
|
3009
|
+
*/
|
|
3010
|
+
declare function validatePgManagedLedgerCurrency(executor: Queryable$2, plan: ProvenPlanShape): Promise<string | undefined>;
|
|
2885
3011
|
|
|
2886
3012
|
type ObservationTarget = {
|
|
2887
3013
|
readonly table: string;
|
|
@@ -2897,8 +3023,20 @@ type EnumObservationTarget = {
|
|
|
2897
3023
|
};
|
|
2898
3024
|
/** Acquire one lease, issue the observation, then release that lease. */
|
|
2899
3025
|
declare function executePgObservationFromLessor(lessor: TransitionLessor, request: ObservationRequest, context: ObservationContext): Promise<EvidenceObservation>;
|
|
3026
|
+
/**
|
|
3027
|
+
* Read context through a caller-owned lease.
|
|
3028
|
+
*
|
|
3029
|
+
* A lease rather than anything with `query()`, for the reason given on
|
|
3030
|
+
* {@link executePgObservationFromClient}: this reads the server version,
|
|
3031
|
+
* database, role and `search_path` in sequence, and a pool would answer each
|
|
3032
|
+
* from a different connection.
|
|
3033
|
+
*
|
|
3034
|
+
* Internal: the supported entry point is
|
|
3035
|
+
* {@link readPgObservationContextFromLessor}.
|
|
3036
|
+
*/
|
|
3037
|
+
declare function readPgObservationContextFromClient(target: TransitionSessionClient, schema?: string, observationTarget?: ObservationTarget | EnumObservationTarget, expectedTargetIdentity?: ObservationContext['postgresqlTargetIdentity']): Promise<ObservationContext>;
|
|
2900
3038
|
/** Acquire one lease, read context, then release that lease. */
|
|
2901
|
-
declare function readPgObservationContextFromLessor(lessor: TransitionLessor, schema?: string, observationTarget?: ObservationTarget | EnumObservationTarget, expectedTargetIdentity?: ObservationContext['postgresqlTargetIdentity']): Promise<ObservationContext>;
|
|
3039
|
+
declare function readPgObservationContextFromLessor(lessor: TransitionLessor | ExclusiveTransitionTarget, schema?: string, observationTarget?: ObservationTarget | EnumObservationTarget, expectedTargetIdentity?: ObservationContext['postgresqlTargetIdentity']): Promise<ObservationContext>;
|
|
2902
3040
|
declare function createPgObservationIssuer(): ObservationIssuer;
|
|
2903
3041
|
|
|
2904
3042
|
interface SetNotNullColumnShapeExpectation {
|
|
@@ -3084,6 +3222,19 @@ declare function createAttachLogicalIdentityOperationRuntime(): {
|
|
|
3084
3222
|
isLockTimeout(error: unknown): boolean;
|
|
3085
3223
|
};
|
|
3086
3224
|
|
|
3225
|
+
type QueryResultLike = {
|
|
3226
|
+
readonly rows: readonly Record<string, unknown>[];
|
|
3227
|
+
};
|
|
3228
|
+
type Queryable$1 = {
|
|
3229
|
+
query(sql: string, params?: readonly unknown[]): Promise<QueryResultLike>;
|
|
3230
|
+
};
|
|
3231
|
+
/**
|
|
3232
|
+
* Recovery has no authority to turn an interrupted concurrent build into an
|
|
3233
|
+
* outcome unless its postcondition is established. An invalid retained target
|
|
3234
|
+
* is deliberately reported in the operation's own admission words.
|
|
3235
|
+
*/
|
|
3236
|
+
declare function assertCreateUniqueIndexConcurrentlyRecoveryNotInvalid(executor: Queryable$1, operation: PhysicalOperation): Promise<void>;
|
|
3237
|
+
|
|
3087
3238
|
type ManualSqlPayload = {
|
|
3088
3239
|
readonly statement: UnsafeNativeFragment;
|
|
3089
3240
|
readonly blastRadius: readonly ResourceAddress[];
|
|
@@ -3522,6 +3673,201 @@ declare function createPgTransitionPack(options?: PgTransitionPackOptions): {
|
|
|
3522
3673
|
satisfiesCompositionFact: typeof satisfiesPgEnumLabelVisibleCompositionFact;
|
|
3523
3674
|
};
|
|
3524
3675
|
|
|
3676
|
+
type ReaddressRecoveryAnswer = {
|
|
3677
|
+
readonly kind: 'refused-pair';
|
|
3678
|
+
} | {
|
|
3679
|
+
readonly kind: 'pending-pair';
|
|
3680
|
+
} | {
|
|
3681
|
+
readonly kind: 'indeterminate-pair';
|
|
3682
|
+
};
|
|
3683
|
+
type PgReaddressPairRecoveryResult = {
|
|
3684
|
+
readonly kind: 'readdress-recovery-refused-pair';
|
|
3685
|
+
readonly pairId: string;
|
|
3686
|
+
} | {
|
|
3687
|
+
readonly kind: 'readdress-recovery-pending-pair';
|
|
3688
|
+
readonly pairId: string;
|
|
3689
|
+
readonly reason: string;
|
|
3690
|
+
} | {
|
|
3691
|
+
readonly kind: 'readdress-recovery-indeterminate-pair';
|
|
3692
|
+
readonly pairId: string;
|
|
3693
|
+
readonly reason: string;
|
|
3694
|
+
} | {
|
|
3695
|
+
readonly kind: 'readdress-recovery-transport-ambiguous-pair';
|
|
3696
|
+
readonly pairId: string;
|
|
3697
|
+
readonly reason: string;
|
|
3698
|
+
};
|
|
3699
|
+
/**
|
|
3700
|
+
* The pair recovery decision is deliberately tiny and exhaustive: it never
|
|
3701
|
+
* completes a DDL operation. A readable shape other than the original,
|
|
3702
|
+
* complete source closure is outside interference.
|
|
3703
|
+
*/
|
|
3704
|
+
declare function classifyPgReaddressRecovery(input: {
|
|
3705
|
+
readonly unreadable: boolean;
|
|
3706
|
+
readonly completeSourceClosure: boolean;
|
|
3707
|
+
}): ReaddressRecoveryAnswer;
|
|
3708
|
+
type PgReaddressResult = {
|
|
3709
|
+
readonly outcome: 'completed';
|
|
3710
|
+
readonly pairId: string;
|
|
3711
|
+
} | {
|
|
3712
|
+
readonly outcome: 'no-op';
|
|
3713
|
+
} | {
|
|
3714
|
+
readonly outcome: 'readdress-unsupported';
|
|
3715
|
+
readonly detail: string;
|
|
3716
|
+
} | {
|
|
3717
|
+
readonly outcome: 'readdress-refused';
|
|
3718
|
+
readonly detail: string;
|
|
3719
|
+
} | {
|
|
3720
|
+
readonly outcome: 'recovery-required';
|
|
3721
|
+
readonly claimId: string;
|
|
3722
|
+
readonly detail: string;
|
|
3723
|
+
} | {
|
|
3724
|
+
readonly outcome: 'transport-ambiguous';
|
|
3725
|
+
readonly detail: string;
|
|
3726
|
+
};
|
|
3727
|
+
interface PgPersistedReaddressInput {
|
|
3728
|
+
readonly executor: TransitionJournalQueryable;
|
|
3729
|
+
/** The durable-run witness is locked by apply before this lifecycle starts. */
|
|
3730
|
+
readonly run: PgLockedRun;
|
|
3731
|
+
readonly manifest: ValidatedManagedStepManifest;
|
|
3732
|
+
readonly recomputedPlanDigest: string;
|
|
3733
|
+
readonly approval: ScopedApprovalSet;
|
|
3734
|
+
/** Attempt namespace journaled before this lifecycle can open a claim. */
|
|
3735
|
+
readonly executionId: string;
|
|
3736
|
+
/** Exact digest-covered normalized step; this is the only operation source. */
|
|
3737
|
+
readonly step: NormalizedManagedStep;
|
|
3738
|
+
readonly database: string;
|
|
3739
|
+
readonly targetSchema: string;
|
|
3740
|
+
/** Test-only admitted-path observation; absent from normal callers. */
|
|
3741
|
+
readonly observer?: PgOutcomeCheckpointObserver;
|
|
3742
|
+
}
|
|
3743
|
+
/**
|
|
3744
|
+
* The immutable DDL material attributed to one paired table re-address.
|
|
3745
|
+
* Recovery fixtures use this same construction when they open a real
|
|
3746
|
+
* readdress-intent through outcome admission.
|
|
3747
|
+
*/
|
|
3748
|
+
declare function renderPgTableReaddressStatements(source: LedgerAddress, target: LedgerAddress): readonly string[];
|
|
3749
|
+
declare function classifyPgReaddressSupport(request: {
|
|
3750
|
+
readonly database: string;
|
|
3751
|
+
readonly targetSchema?: string;
|
|
3752
|
+
readonly executionId?: string;
|
|
3753
|
+
readonly declaration: TableReaddressDeclaration;
|
|
3754
|
+
}): PgReaddressResult | undefined;
|
|
3755
|
+
/**
|
|
3756
|
+
* Reconciles one interrupted re-address as one closure. Every live read is
|
|
3757
|
+
* complete before an append is considered, and the only closing outcome is a
|
|
3758
|
+
* verified refusal of the untouched source closure. Neither path issues DDL.
|
|
3759
|
+
*/
|
|
3760
|
+
declare function recoverPgReaddressPair(executor: TransitionJournalQueryable, input: {
|
|
3761
|
+
readonly pairId: string;
|
|
3762
|
+
readonly executionId: string;
|
|
3763
|
+
readonly reservations: readonly LedgerReservationRow[];
|
|
3764
|
+
}): Promise<PgReaddressPairRecoveryResult>;
|
|
3765
|
+
/**
|
|
3766
|
+
* Execute the ADR 0006 pair from one exact, persisted normalized step.
|
|
3767
|
+
*
|
|
3768
|
+
* This deliberately has no direct-request form: the durable run, validated
|
|
3769
|
+
* manifest, digest and reviewed lifecycle material all arrive together from
|
|
3770
|
+
* the apply lock boundary.
|
|
3771
|
+
*/
|
|
3772
|
+
declare function executePgPersistedTableReaddress(input: PgPersistedReaddressInput): Promise<PgReaddressResult>;
|
|
3773
|
+
|
|
3774
|
+
type PgReleaseResult = {
|
|
3775
|
+
readonly outcome: 'released';
|
|
3776
|
+
} | {
|
|
3777
|
+
/** A managed mutation must name a non-writable target before any release read. */
|
|
3778
|
+
readonly outcome: 'database-read-only';
|
|
3779
|
+
readonly detail: string;
|
|
3780
|
+
readonly address: LedgerAddress;
|
|
3781
|
+
} | {
|
|
3782
|
+
/** Transport/query/read-only failure; never mislabel it malformed chain. */
|
|
3783
|
+
readonly outcome: 'release-unavailable';
|
|
3784
|
+
readonly detail: string;
|
|
3785
|
+
readonly address: LedgerAddress;
|
|
3786
|
+
} | {
|
|
3787
|
+
readonly outcome: 'release-refused';
|
|
3788
|
+
readonly detail: string;
|
|
3789
|
+
readonly address: LedgerAddress;
|
|
3790
|
+
readonly refusal: LedgerRefusal;
|
|
3791
|
+
};
|
|
3792
|
+
declare function releasePgManagedAddress(input: {
|
|
3793
|
+
readonly executor: TransitionJournalQueryable;
|
|
3794
|
+
readonly home: LedgerHome;
|
|
3795
|
+
readonly address: LedgerAddress;
|
|
3796
|
+
}): Promise<PgReleaseResult>;
|
|
3797
|
+
|
|
3798
|
+
type Queryable = {
|
|
3799
|
+
query(sql: string, params?: readonly unknown[]): Promise<{
|
|
3800
|
+
readonly rows: readonly Record<string, unknown>[];
|
|
3801
|
+
}>;
|
|
3802
|
+
};
|
|
3803
|
+
interface PgRemovalEffectAddress {
|
|
3804
|
+
readonly address: LedgerAddress;
|
|
3805
|
+
/** Physical pg_depend identity retained for the reviewed closure digest. */
|
|
3806
|
+
readonly physicalIdentity?: {
|
|
3807
|
+
readonly classId?: string;
|
|
3808
|
+
readonly objectId?: string;
|
|
3809
|
+
readonly objectSubId?: string;
|
|
3810
|
+
readonly parentClassId?: string;
|
|
3811
|
+
readonly parentObjectId?: string;
|
|
3812
|
+
readonly parentObjectSubId?: string;
|
|
3813
|
+
readonly dependencyType?: string;
|
|
3814
|
+
};
|
|
3815
|
+
/** Extension members are accounted by their adopted extension parent only. */
|
|
3816
|
+
readonly extensionMember?: boolean;
|
|
3817
|
+
/**
|
|
3818
|
+
* An `i` dependency to an artifact owned by the referenced relation (row
|
|
3819
|
+
* type, its array type, toast relation, index, or constraint). It remains
|
|
3820
|
+
* cascade evidence, but is accounted by that relation rather than requiring
|
|
3821
|
+
* a separate ledger ownership lookup.
|
|
3822
|
+
*/
|
|
3823
|
+
readonly internalOwned?: boolean;
|
|
3824
|
+
}
|
|
3825
|
+
type PgRemovalEffectsClosure = {
|
|
3826
|
+
readonly kind: 'all-contained-or-managed';
|
|
3827
|
+
readonly root: LedgerAddress;
|
|
3828
|
+
readonly effects: readonly PgRemovalEffectAddress[];
|
|
3829
|
+
readonly managedDependents: readonly LedgerAddress[];
|
|
3830
|
+
/** Exact, canonical cascade set admitted under the ledger locks. */
|
|
3831
|
+
readonly closureDigest: string;
|
|
3832
|
+
} | {
|
|
3833
|
+
readonly kind: 'reaches-unmanaged';
|
|
3834
|
+
readonly root: LedgerAddress;
|
|
3835
|
+
readonly effects: readonly PgRemovalEffectAddress[];
|
|
3836
|
+
readonly unmanaged: LedgerAddress;
|
|
3837
|
+
} | {
|
|
3838
|
+
readonly kind: 'undecidable';
|
|
3839
|
+
readonly reason: string;
|
|
3840
|
+
};
|
|
3841
|
+
/**
|
|
3842
|
+
* Classifies a fully enumerated cascade. Non-declarable dependent kinds refuse
|
|
3843
|
+
* before SQL; adopted-extension members are the sole parent-accounted carveout.
|
|
3844
|
+
*/
|
|
3845
|
+
declare function classifyRemovalEffectsClosure(input: {
|
|
3846
|
+
readonly root: LedgerAddress;
|
|
3847
|
+
readonly effects: readonly PgRemovalEffectAddress[];
|
|
3848
|
+
readonly isManaged: (address: LedgerAddress) => boolean;
|
|
3849
|
+
}): PgRemovalEffectsClosure;
|
|
3850
|
+
/** Map closure results directly into the core authority's closed vocabulary. */
|
|
3851
|
+
declare function containmentAuthorityOutcome(closure: PgRemovalEffectsClosure): ContainmentClosureDestructiveOutcome;
|
|
3852
|
+
declare function reservationsForRemovalClosure(input: {
|
|
3853
|
+
readonly closure: Extract<PgRemovalEffectsClosure, {
|
|
3854
|
+
readonly kind: 'all-contained-or-managed';
|
|
3855
|
+
}>;
|
|
3856
|
+
readonly executionId: string;
|
|
3857
|
+
readonly rootClaimId: string;
|
|
3858
|
+
readonly claimKind?: LedgerClaimKind;
|
|
3859
|
+
readonly homeLedger: LedgerHome;
|
|
3860
|
+
}): readonly LedgerReservationRow[];
|
|
3861
|
+
/**
|
|
3862
|
+
* Enumerates PostgreSQL's dependency cascade before any destructive DDL. The
|
|
3863
|
+
* caller supplies ledger ownership; an unreadable catalogue is never evidence.
|
|
3864
|
+
*/
|
|
3865
|
+
declare function readPgRemovalEffectsClosure(input: {
|
|
3866
|
+
readonly executor: Queryable;
|
|
3867
|
+
readonly root: LedgerAddress;
|
|
3868
|
+
readonly isManaged: (address: LedgerAddress) => Promise<boolean>;
|
|
3869
|
+
}): Promise<PgRemovalEffectsClosure>;
|
|
3870
|
+
|
|
3525
3871
|
/**
|
|
3526
3872
|
* Identifier Validation for adapter-pgsql
|
|
3527
3873
|
*
|
|
@@ -3596,4 +3942,4 @@ declare function escapeDiagnosticText(value: string): string;
|
|
|
3596
3942
|
*/
|
|
3597
3943
|
declare function validateSqlExpression(sql: string, context: string): void;
|
|
3598
3944
|
|
|
3599
|
-
export { ADD_CHECK_RULE_ID, ALTER_AUTHORITY_OBSERVATION, ALTER_COLUMN_SET_NOT_NULL_OPERATION_KIND, ALTER_TYPE_ADD_VALUE_OPERATION_KIND, ATTACH_LOGICAL_IDENTITY_OPERATION_KIND, type AddedEnumValue, type AlterColumnSetNotNullPayload, type AlterTypeAddValuePayload, type AttachLogicalIdentityPayload, type BatchValuesJoinDecision, COLUMN_EXISTS_OBSERVATION, CamelCaseNamingPlugin, type CanonicalizeCheckConstraintsOptions,
|
|
3945
|
+
export { ADD_CHECK_RULE_ID, ALTER_AUTHORITY_OBSERVATION, ALTER_COLUMN_SET_NOT_NULL_OPERATION_KIND, ALTER_TYPE_ADD_VALUE_OPERATION_KIND, ATTACH_LOGICAL_IDENTITY_OPERATION_KIND, type AddedEnumValue, type AlterColumnSetNotNullPayload, type AlterTypeAddValuePayload, type AttachLogicalIdentityPayload, type BatchValuesJoinDecision, COLUMN_EXISTS_OBSERVATION, CamelCaseNamingPlugin, type CanonicalizeCheckConstraintsOptions, ChangeKind, CheckConstraintCanonicalizationError, type CheckConstraintCanonicalizationWarning, CheckConstraintNewEnumValueError, ColumnDefaultCanonicalizationError, type ColumnDefaultCanonicalizationWarning, type ComparePgsqlDatabaseSchemaOptions, CompareSchemataOptions, type CompiledResult, type CompilerContext, type CompilerOptions, type CompilerState, type ConflictAction, type ConflictTarget, type CursorHoldOption, type CursorOptions, type CursorScrollOption, DATABASE_READ_ONLY_OUTCOME, DBSP_LEDGER_EVENT_TABLE, DBSP_LEDGER_IDENTITY_TABLE, DBSP_LEDGER_MARKER_TABLE, DBSP_LEDGER_RESERVATION_TABLE, DBSP_LOGICAL_IDENTITY_TABLE, DBSP_META_SCHEMA, DBSP_TRANSITION_AUTHORIZATION_TABLE, DBSP_TRANSITION_JOURNAL_TABLE, DBSP_TRANSITION_RUN_PLAN_TABLE, DBSP_TRANSITION_RUN_TABLE, DEFAULT_PK_COLUMN, DEFAULT_REDACTION_PATTERNS, type Decision, type DeleteConfig, type DetectedHierarchy, ENGINE_VERSION_OBSERVATION, ENUM_ADD_VALUE_RULE_ID, ENUM_LABEL_VISIBLE_OBSERVATION, ENUM_TYPE_EXISTS_OBSERVATION, type EnumAddValueMatch, type EnumAddValueRuleOptions, type ExplainFormat, type ExplainOptions, type ExplainPlan, type ExpressionCanonicalizationWarning, type ExpressionHandler, ExpressionKeyedIndexPredicateCanonicalizationUnsupportedError, type FetchDirection, type FetchOptions, type FkColumnDerivation, type GenerateDDLOptions, type GeneratedMutationClassification, type IdentityAdoptionAsserter, IdentityNamingPlugin, type IncludeHandler, type IncludeResult, type IndexCapabilityContext, IndexFeatureUnsupportedError, IndexPredicateCanonicalizationError, type IndexRenderSpec, type InsertConfig, type IntrospectedModelIR, type IntrospectionOptions, InvalidIdentifierError, type JoinDecision, LOGICAL_IDENTITY_ADOPTION_RULE_ID, LOGICAL_IDENTITY_CARRIER_OBSERVATION, type LeafCompileFn, type LogicalIdentityAdoptionMatch, type LogicalIdentityAdoptionRuleOptions, MANUAL_SQL_OPERATION_KIND, type ManualSqlPayload, type MigrationSQLOptions, NO_NULLS_GUARD, type NamingPlugin, NonConvergentSchemaDiffError, type NonConvergentSchemaDiffSurface, PG_INTROSPECTION_ARTIFACT, PG_OPERATION_PACK_ARTIFACT, PG_RULE_PACK_ARTIFACT, type ParamRefValidationResult, PartialIndexPredicateNewEnumValueError, type PgAdoptionPreflightResult, type PgAdoptionResult, type PgAdvisoryLockKey, type PgAdvisoryLockResult, PgDatabaseReadOnlyError, type PgDatabaseWritability, type PgDeclaredAdoptionInput, PgExecutionContractDerivationError, type PgLedgerAddressChain, PgLockedRun, PgOutcomeCheckpointObserver, type PgPersistedDeclaredAdoptionInput, type PgPersistedReaddressInput, type PgReaddressPairRecoveryResult, type PgReleaseResult, type PgRemovalEffectAddress, type PgRemovalEffectsClosure, type PgTransitionClientLease, type PgTransitionPackOptions, PgsqlAdapter, type PgsqlAdapterOptions, PgsqlAdvisoryLockOptionsError, type PgsqlBorrowedClientAdapterOptions, type PgsqlCompileOnlyAdapterOptions, PgsqlPinnedConnectionAbortSignalError, type PgsqlPoolAdapterOptions, PgsqlPreparedStatementReplayError, type PgsqlPreparedStatementsOptions, PgsqlRawSqlTransactionControlError, PgsqlTransactionAbortSignalError, PgsqlTransactionAbortedCommitError, PgsqlTransactionAbortedError, PgsqlTransactionOptionsError, PgsqlTransactionTimeoutError, PlanCompiler, type PlanDecision, type PrecompiledJoinDecision, RawIndexPredicateFallbackError, type RedactionConfig, type RedactionPattern, type RollbackOnlyPgsqlScope, SET_NOT_NULL_RULE_ID, SchemaDiff, type SchemaScopeOptions, type SetNotNullMatch, type SetNotNullRuleOptions, type SetOperationResult, type SimplifiedPlanReport, type StreamConfig, type UpdateConfig, type UpsertConfig, type WhereDispatcher, type WhereHandler, acquirePgTransitionClient, assertCreateIndexSupported, assertCreateIndexesSupported, assertCreateUniqueIndexConcurrentlyRecoveryNotInvalid, assertNoRepeatedExpressionSurfaceDrift, assertPgDatabaseWritable, bm25Search, booleanSearch, boost, buildCloseCursor, buildDeclareCursor, buildExplain, buildExplainAnalyzeJson, buildExplainPlan, buildExplainVerbose, buildFetch, buildFetchAll, buildFetchFirst, buildFetchForward, buildFetchNext, buildOnConflictClause, buildStreamingStatements, camelCaseNaming, canGenerateCreateIndex, canonicalizeCheckConstraints, classifyGeneratedMutation, classifyPgDatabaseWritability, classifyPgReaddressRecovery, classifyPgReaddressSupport, classifyPgWrite, classifyRemovalEffectsClosure, collectAndValidateParamRefs, comparePgsqlDatabaseSchema, compileDelete, compileInsert, compileMutation, compilePlan, compileSetOperation, compileUpdate, compileUpsert, conditionalUpdate, containmentAuthorityOutcome, cosineDistance, createAlterColumnSetNotNullOperationRuntime, createAlterTypeAddValueOperationRuntime, createAnyExpr, createAttachLogicalIdentityOperationRuntime, createEnumAddValueRule, createEqualityExpr, createLeafCompileFn, createLogicalIdentityAdoptionRule, createManualSqlOperationRuntime, createParamRef, createPgExecutionContract, createPgObservationIssuer, createPgTransitionLessor, createPgTransitionPack, createPgsqlAdapter, createPgsqlCompileOnlyAdapter, createSetNotNullRule, createTypeCastParamRef, dbTypesEqual, defaultFkDerivation, derivePostgresqlCapabilitiesForVersion, escapeDiagnosticText, evaluatePgExecutionContract, excludedRef, executePgDeclaredAdoption, executePgObservationFromLessor, executePgPersistedTableReaddress, findPgLedgerTerminalMember, generateCreateIndex, generateCursorName, generateDDL, generateDownSQL, generateMigrationSQL, generateSeries, getNamingPluginForDbCasing, getRowEstimates, getTotalExecutionTime, identityNaming, innerProduct, introspect, isBatchValuesJoinDecision, isGeneratedMutationDestructive, isJoinDecision, isPgDatabaseReadOnlyError, isPrecompiledJoinDecision, isReservedKeyword, l2Distance, mapColumnType, mapOnDeleteAction, nextval, normalizeManualSqlPayload, parse, parseExplainJson, pgTargetIdentityMismatch, preflightPgDeclaredAdoption, preparePgExecutionSession, preparePgRecoveryAdmission, rawDistance, readPgExecutionTargetFromClient, readPgLedgerAddressChain, readPgLedgerControllerOid, readPgObservationContextFromClient, readPgObservationContextFromLessor, readPgRemovalEffectsClosure, recoverPgReaddressPair, redactParams, refusesRecordedPlanRemoval, releasePgManagedAddress, renderAlterColumnSetNotNullSql, renderAlterTypeAddValueSql, renderAttachLogicalIdentityLockSql, renderCreateIndex, renderCreateLogicalIdentityIndexesSql, renderCreateLogicalIdentitySideTableSql, renderInsertLogicalIdentitySql, renderNoNullsCheckSql, renderPgTableReaddressStatements, renderSetNotNullLockSql, reservationsForRemovalClosure, resolveLogicalName, sanitizeForDisplay, score, validateIdentifier, validateIdentifiers, validateParamRef, validatePgManagedLedgerCurrency, validateQualifiedIdentifier, validateSqlExpression, vectorDims, withPgTransitionRunLock };
|