@dbsp/adapter-pgsql 5.0.0 → 6.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.
@@ -1,8 +1,9 @@
1
- import { q as PgLedgerTarget, T as TransitionJournalQueryable, av as PgOrderedLedgerLocks, aw as PgLedgerShapeAllowance, ax as PgLedgerPhysicalShapeOutcome, a5 as readPgLedgerScopeCurrency } from './outcome-protocol-CACJDzli.js';
2
- export { ay as PgCommitAcknowledgementAmbiguousError, az as appendPgLedgerClaim, aA as appendPgLedgerClaimGroup, aB as appendPgLedgerProgress, aC as appendPgLedgerRelease, aD as appendPgLedgerResolution, aE as appendPgLedgerResolutionGroup, aF as appendPgOutcomeResolution, aG as classifyPgLedgerPhysicalShape, aH as createPgLedgerShapeAllowance, aI as executePgDestructiveOutcome, aJ as lockPgJournalRun, aK as openPgOutcomeClaim, aL as openPgOutcomeClaimGroup, aM as readPgLedgerReservationsForPair, aN as recoverPgAdmittedReaddressPair, aO as recoverPgOutcomeClaim, aP as resolvePgDestructiveOutcome, aQ as resolvePgOutcomeClaimGroup } from './outcome-protocol-CACJDzli.js';
3
- import '@dbsp/core';
1
+ import { ad as PgLedgerTarget, T as TransitionJournalQueryable, bX as PgOrderedLedgerLocks, bY as PgLedgerShapeAllowance, bZ as PgLedgerPhysicalShapeOutcome, bx as readPgLedgerScopeCurrency, c as PgPhysicalModel, P as PgLockedRun, a as PgOutcomeCheckpointObserver } from './outcome-protocol-Dw5DYhnA.js';
2
+ export { b_ as ComparePgsqlDatabaseSchemaOptions, b$ as ComparePgsqlDeclaredAdoptionSchemaInput, c0 as CompareSchemataOptions, c1 as ConvergePgBaseOptions, c2 as ConvergePgCheckOptions, b as ConvergePgOptions, c3 as GenerateDDLOptions, c4 as MigrationSQLOptions, a1 as PgApplicationStepTx, c5 as PgCommitAcknowledgementAmbiguousError, a3 as PgConvergeApplicationStep, a4 as PgConvergeAssertStep, e as PgConvergeCheckResult, a5 as PgConvergeInitializationFailure, a6 as PgConvergeOnceStep, a7 as PgConvergePlannedStep, a9 as PgConvergeRefusalChange, aa as PgConvergeRefusalError, d as PgConvergeResult, c6 as PgsqlAdoptionComparisonExecutor, c7 as appendPgLedgerClaim, c8 as appendPgLedgerClaimGroup, c9 as appendPgLedgerProgress, ca as appendPgLedgerRelease, cb as appendPgLedgerResolution, cc as appendPgLedgerResolutionGroup, cd as appendPgOutcomeResolution, ce as classifyPgLedgerPhysicalShape, cf as collectReferencedKeyRemovalConflicts, cg as comparePgsqlDatabaseSchema, ch as comparePgsqlDeclaredAdoptionSchema, ci as compareSchemata, cj as convergePg, ck as createPgLedgerShapeAllowance, cl as createPgsqlDeclaredAdoptionStep, cm as createPgsqlDeclaredSequenceAdoptionStep, cn as executePgDestructiveOutcome, co as generateDDL, cp as generateDownSQL, cq as generateMigrationSQL, cr as lockPgJournalRun, cs as modelForDeclaredAdoption, ct as openPgOutcomeClaim, cu as openPgOutcomeClaimGroup, cv as pgsqlDeclaredAdoptionDeclaration, cw as pgsqlDeclaredSequenceAdoptionDeclaration, cx as readPgLedgerReservationsForPair, cy as recoverPgAdmittedReaddressPair, cz as recoverPgOutcomeClaim, cA as resolvePgDestructiveOutcome, cB as resolvePgOutcomeClaimGroup } from './outcome-protocol-Dw5DYhnA.js';
3
+ import { InProcessProvenPlan, ValidatedManagedStepManifest } from '@dbsp/core';
4
+ import { TransitionRunMetadata, ProvenPlanShape, TransitionRunJournal, TransitionRunAuthorization, TransitionSessionClient, ModelIR, CompareOutcome, PlanAssessment, ObservationContext, ApplyResult, ApplyPolicy, ScopedApprovalSet, NormalizedManagedStep } from '@dbsp/types';
5
+ import { Pool, PoolClient } from 'pg';
4
6
  import '@dbsp/core/internal';
5
- import '@dbsp/types';
6
7
 
7
8
  declare const postLockAdmissionEvidenceBrand: unique symbol;
8
9
  /**
@@ -31,4 +32,142 @@ type PostLockAdmissionEvidenceSeams = {
31
32
  declare function createPostLockAdmissionEvidence(executor: TransitionJournalQueryable, locks: PgOrderedLedgerLocks, seams?: PostLockAdmissionEvidenceSeams, allowance?: PgLedgerShapeAllowance): Promise<PostLockAdmissionEvidence>;
32
33
  declare function isPostLockAdmissionEvidence(value: unknown): value is PostLockAdmissionEvidence;
33
34
 
34
- export { PgLedgerPhysicalShapeOutcome, PgLedgerShapeAllowance, type PostLockAdmissionEvidence, createPostLockAdmissionEvidence, isPostLockAdmissionEvidence };
35
+ /** Reads the live schema from a short-lived adapter-owned PostgreSQL session. */
36
+ type PgLiveSchemaReader = (client: TransitionSessionClient, schema: string | undefined) => Promise<ModelIR>;
37
+ interface PlanPgTransitionRunOptions {
38
+ /** False proves and binds a durable plan but leaves no journal record. */
39
+ readonly persist?: boolean;
40
+ /** Lets a caller prepare an inspection view before durable persistence. */
41
+ readonly beforePersist?: (plan: InProcessProvenPlan, proofContext: ObservationContext) => void | Promise<void>;
42
+ }
43
+ type PgTransitionPlanResult = {
44
+ readonly kind: 'proven';
45
+ readonly compare: CompareOutcome;
46
+ readonly assessment: PlanAssessment;
47
+ readonly plan: InProcessProvenPlan;
48
+ readonly run: TransitionRunMetadata;
49
+ readonly proofContext: ObservationContext;
50
+ } | {
51
+ readonly kind: 'no-drift' | 'blocked' | 'inapplicable';
52
+ readonly compare: CompareOutcome;
53
+ readonly assessment: PlanAssessment;
54
+ };
55
+ /** The run id is available even when PostgreSQL cannot confirm persistence. */
56
+ declare class PgTransitionRunPersistenceIndeterminateError extends Error {
57
+ readonly run: TransitionRunMetadata;
58
+ readonly compare: CompareOutcome;
59
+ readonly assessment: PlanAssessment;
60
+ readonly persistenceError: unknown;
61
+ constructor(run: TransitionRunMetadata, compare: CompareOutcome, assessment: PlanAssessment, persistenceError: unknown);
62
+ }
63
+ /**
64
+ * Proves, binds, and optionally persists one PostgreSQL transition run.
65
+ * The reader sees only an adapter-owned introspection lease; all journal,
66
+ * evidence, and contract sessions are opened and released here.
67
+ */
68
+ declare function planPgTransitionRun(physical: PgPhysicalModel, readLiveSchema: PgLiveSchemaReader, pool: Pool, options?: PlanPgTransitionRunOptions): Promise<PgTransitionPlanResult>;
69
+ type PgTransitionRunApplyResult = {
70
+ readonly kind: 'busy';
71
+ } | {
72
+ readonly kind: 'settled';
73
+ readonly result: ApplyResult;
74
+ };
75
+ interface ApplyPgTransitionRunOptions {
76
+ /**
77
+ * Chooses a durable authorization record from a freshly read journal. Before
78
+ * core may execute, the adapter holds the run-row lock while it commits that
79
+ * exact record to this run's authorization stream, unless the same record was
80
+ * already present. The fresh read, choice, and commit share one transaction.
81
+ */
82
+ readonly authorize: (input: {
83
+ readonly run: TransitionRunMetadata;
84
+ readonly plan: ProvenPlanShape;
85
+ readonly current: TransitionRunJournal;
86
+ }) => Promise<TransitionRunAuthorization>;
87
+ }
88
+ /** Applies one already-persisted, non-generator PostgreSQL transition run. */
89
+ declare function applyPgTransitionRun(pool: Pool, runId: string, policy: ApplyPolicy, expectedPlanDigest: string, options: ApplyPgTransitionRunOptions): Promise<PgTransitionRunApplyResult>;
90
+
91
+ type GeneratorExecutionExecutor = Pool | Pick<PoolClient, 'query' | 'release'>;
92
+ type GeneratorExecutionResult = {
93
+ readonly outcome: 'completed';
94
+ } | {
95
+ readonly outcome: 'partially-applied';
96
+ readonly detail: string;
97
+ readonly completedStepKeys: readonly string[];
98
+ readonly notStartedStepKeys: readonly string[];
99
+ } | {
100
+ readonly outcome: 'selection-incomplete';
101
+ readonly detail: string;
102
+ } | {
103
+ readonly outcome: 'adoption-refused';
104
+ readonly detail: string;
105
+ } | {
106
+ readonly outcome: 'readdress-unsupported';
107
+ readonly detail: string;
108
+ } | {
109
+ readonly outcome: 'readdress-refused';
110
+ readonly detail: string;
111
+ } | {
112
+ readonly outcome: 'destructive-authority-refused';
113
+ readonly detail: string;
114
+ /** The exact live authority that remained withheld at admission. */
115
+ readonly refusal?: {
116
+ readonly withheldAuthority: string;
117
+ };
118
+ } | {
119
+ readonly outcome: 'prior-step-events-refusal';
120
+ readonly detail: string;
121
+ } | {
122
+ readonly outcome: 'recovery-required';
123
+ readonly claimId: string;
124
+ readonly detail: string;
125
+ } | {
126
+ readonly outcome: 'transport-ambiguous';
127
+ readonly detail: string;
128
+ } | {
129
+ readonly outcome: 'execution-failed';
130
+ readonly detail: string;
131
+ };
132
+ /**
133
+ * Executes the in-memory, just-presented generator material. It never reads
134
+ * a generator run back by id: that persisted row remains review-only.
135
+ */
136
+ declare function executeGeneratorPlan(input: {
137
+ /**
138
+ * A pg pool or checked-out PoolClient. A connected standalone pg.Client is
139
+ * deliberately unsupported: although session-pinned, it has no release(),
140
+ * and the pool/client distinction must not try to connect it again.
141
+ */
142
+ readonly pool: GeneratorExecutionExecutor;
143
+ /** Bound by apply after validating the persisted durable manifest. */
144
+ readonly manifest?: ValidatedManagedStepManifest;
145
+ /** @deprecated Compatibility shim for direct fixtures; it is validated before use. */
146
+ readonly plan?: {
147
+ readonly steps: readonly unknown[];
148
+ };
149
+ readonly planDigest: string;
150
+ readonly schema: string;
151
+ /** Preserve scopes and trust roots until admission; never reduce to classes. */
152
+ readonly approval?: ScopedApprovalSet;
153
+ /** Durable witness minted while apply holds this run's journal lock. */
154
+ readonly run: PgLockedRun;
155
+ /** Appends the run-to-attempt mapping before any ledger claim may be opened. */
156
+ readonly recordAttempt: (executionId: string) => Promise<void>;
157
+ /** Test-only admitted-path observation; absent from every CLI invocation. */
158
+ readonly observer?: PgOutcomeCheckpointObserver;
159
+ /** Contiguous fresh-object steps that must commit as one PostgreSQL transaction. */
160
+ readonly atomicCreationGroup?: readonly string[];
161
+ /**
162
+ * Converge supplies its lock-holding canonical comparison here. The
163
+ * callback receives both the preflight executor and the executor inside the
164
+ * admitted outcome transaction, so adoption never escapes that session.
165
+ */
166
+ readonly verifyDeclaredAdoptionShape?: (executor: TransitionJournalQueryable, step: NormalizedManagedStep) => Promise<boolean>;
167
+ /** @deprecated Compatibility shim for old direct fixtures. */
168
+ readonly accepts?: readonly string[];
169
+ readonly replaces?: readonly string[];
170
+ readonly runId: string;
171
+ }): Promise<GeneratorExecutionResult>;
172
+
173
+ export { type ApplyPgTransitionRunOptions, type GeneratorExecutionResult, PgLedgerPhysicalShapeOutcome, PgLedgerShapeAllowance, type PgLiveSchemaReader, type PgTransitionPlanResult, type PgTransitionRunApplyResult, PgTransitionRunPersistenceIndeterminateError, type PlanPgTransitionRunOptions, type PostLockAdmissionEvidence, applyPgTransitionRun, createPostLockAdmissionEvidence, executeGeneratorPlan, isPostLockAdmissionEvidence, planPgTransitionRun };
package/dist/internal.js CHANGED
@@ -1,5 +1,7 @@
1
1
  import {
2
2
  PgCommitAcknowledgementAmbiguousError,
3
+ PgConvergeRefusalError,
4
+ PgTransitionRunPersistenceIndeterminateError,
3
5
  appendPgLedgerClaim,
4
6
  appendPgLedgerClaimGroup,
5
7
  appendPgLedgerProgress,
@@ -7,22 +9,40 @@ import {
7
9
  appendPgLedgerResolution,
8
10
  appendPgLedgerResolutionGroup,
9
11
  appendPgOutcomeResolution,
12
+ applyPgTransitionRun,
10
13
  classifyPgLedgerPhysicalShape,
14
+ collectReferencedKeyRemovalConflicts,
15
+ comparePgsqlDatabaseSchema2 as comparePgsqlDatabaseSchema,
16
+ comparePgsqlDeclaredAdoptionSchema,
17
+ compareSchemata,
18
+ convergePg,
11
19
  createPgLedgerShapeAllowance,
20
+ createPgsqlDeclaredAdoptionStep,
21
+ createPgsqlDeclaredSequenceAdoptionStep,
12
22
  createPostLockAdmissionEvidence,
23
+ executeGeneratorPlan,
13
24
  executePgDestructiveOutcome,
25
+ generateDDL,
26
+ generateDownSQL,
27
+ generateMigrationSQL,
14
28
  isPostLockAdmissionEvidence,
15
29
  lockPgJournalRun,
30
+ modelForDeclaredAdoption,
16
31
  openPgOutcomeClaim,
17
32
  openPgOutcomeClaimGroup,
33
+ pgsqlDeclaredAdoptionDeclaration,
34
+ pgsqlDeclaredSequenceAdoptionDeclaration,
35
+ planPgTransitionRun,
18
36
  readPgLedgerReservationsForPair,
19
37
  recoverPgAdmittedReaddressPair,
20
38
  recoverPgOutcomeClaim,
21
39
  resolvePgDestructiveOutcome,
22
40
  resolvePgOutcomeClaimGroup
23
- } from "./chunk-KZ3NLIZ5.js";
41
+ } from "./chunk-NXGMFZ4E.js";
24
42
  export {
25
43
  PgCommitAcknowledgementAmbiguousError,
44
+ PgConvergeRefusalError,
45
+ PgTransitionRunPersistenceIndeterminateError,
26
46
  appendPgLedgerClaim,
27
47
  appendPgLedgerClaimGroup,
28
48
  appendPgLedgerProgress,
@@ -30,14 +50,30 @@ export {
30
50
  appendPgLedgerResolution,
31
51
  appendPgLedgerResolutionGroup,
32
52
  appendPgOutcomeResolution,
53
+ applyPgTransitionRun,
33
54
  classifyPgLedgerPhysicalShape,
55
+ collectReferencedKeyRemovalConflicts,
56
+ comparePgsqlDatabaseSchema,
57
+ comparePgsqlDeclaredAdoptionSchema,
58
+ compareSchemata,
59
+ convergePg,
34
60
  createPgLedgerShapeAllowance,
61
+ createPgsqlDeclaredAdoptionStep,
62
+ createPgsqlDeclaredSequenceAdoptionStep,
35
63
  createPostLockAdmissionEvidence,
64
+ executeGeneratorPlan,
36
65
  executePgDestructiveOutcome,
66
+ generateDDL,
67
+ generateDownSQL,
68
+ generateMigrationSQL,
37
69
  isPostLockAdmissionEvidence,
38
70
  lockPgJournalRun,
71
+ modelForDeclaredAdoption,
39
72
  openPgOutcomeClaim,
40
73
  openPgOutcomeClaimGroup,
74
+ pgsqlDeclaredAdoptionDeclaration,
75
+ pgsqlDeclaredSequenceAdoptionDeclaration,
76
+ planPgTransitionRun,
41
77
  readPgLedgerReservationsForPair,
42
78
  recoverPgAdmittedReaddressPair,
43
79
  recoverPgOutcomeClaim,