@runa-ai/runa-cli 0.5.67 → 0.5.68
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/commands/db/apply/actors.d.ts.map +1 -1
- package/dist/commands/db/apply/helpers/index.d.ts +6 -4
- package/dist/commands/db/apply/helpers/index.d.ts.map +1 -1
- package/dist/commands/db/apply/helpers/partition-acl-cleaner.d.ts +54 -0
- package/dist/commands/db/apply/helpers/partition-acl-cleaner.d.ts.map +1 -0
- package/dist/commands/db/apply/helpers/pg-schema-diff-helpers.d.ts +63 -20
- package/dist/commands/db/apply/helpers/pg-schema-diff-helpers.d.ts.map +1 -1
- package/dist/commands/db/apply/helpers/plan-validator.d.ts +17 -4
- package/dist/commands/db/apply/helpers/plan-validator.d.ts.map +1 -1
- package/dist/commands/db/apply/helpers/retry-logic.d.ts +6 -5
- package/dist/commands/db/apply/helpers/retry-logic.d.ts.map +1 -1
- package/dist/commands/db/commands/db-schema.d.ts.map +1 -1
- package/dist/index.js +2311 -1982
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actors.d.ts","sourceRoot":"","sources":["../../../../src/commands/db/apply/actors.ts"],"names":[],"mappings":"AAwCA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"actors.d.ts","sourceRoot":"","sources":["../../../../src/commands/db/apply/actors.ts"],"names":[],"mappings":"AAwCA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AA8FlD,MAAM,WAAW,WAAW;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,kDAAkD;IAClD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,oDAAoD;IACpD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iEAAiE;IACjE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,wFAAwF;IACxF,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAohCD;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB;WAExB,YAAY;eAAa,MAAM;UAAQ,KAAK,GAAG,MAAM;gCA+C9D,CAAC;AAEH;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB;WAEnB,YAAY;eAAa,MAAM;gCAqQxC,CAAC;AAkCH;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB;cACjB,MAAM,EAAE;;WACX,YAAY;eAAa,MAAM;gCAwBxC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,UAAU;aACV,OAAO;;WACT,YAAY;eAAa,MAAM;gCAmExC,CAAC"}
|
|
@@ -5,15 +5,17 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export { acquireAdvisoryLock, MIGRATION_LOCK_ID, releaseAdvisoryLock, } from './advisory-lock.js';
|
|
7
7
|
export type { FilterResult, PlanHazard, PlanStatement, ValidatedPlan } from './plan-validator.js';
|
|
8
|
-
export { filterIdempotentProtectedStatements, parsePlanOutput, validatePlanForExecution, } from './plan-validator.js';
|
|
9
|
-
export type { ParsedHazard, PgSchemaDiffPlanOptions } from './pg-schema-diff-helpers.js';
|
|
8
|
+
export { filterIdempotentProtectedStatements, isDropStatementForProtectedObject, parsePlanOutput, validatePlanForExecution, } from './plan-validator.js';
|
|
9
|
+
export type { IdempotentProtectedObjects, ParsedHazard, PartitionPrivilegeDetection, PgSchemaDiffPlanOptions, } from './pg-schema-diff-helpers.js';
|
|
10
10
|
export type { ShadowDbConfig, ShadowDbResult } from './shadow-db-manager.js';
|
|
11
|
-
export { buildAllowedHazards, detectDropTableStatements,
|
|
11
|
+
export { buildAllowedHazards, detectDropTableStatements, detectPartitionPrivilegeError, displayCheckModeResults, displayHazardsWithContext, executePgSchemaDiffPlan, filterFalsePositiveHazards, formatPartitionPrivilegeHint, getIdempotentProtectedObjects, getIdempotentProtectedTables, getIdempotentRoles, handleHazardsWithContext, handleProductionAuthzProtection, handleProductionDataProtection, isIdempotentRoleHazard, parseHazardsWithContext, PG_SCHEMA_DIFF_APPLY_TIMEOUT_MS, resetIdempotentRolesCache, verifyDatabaseConnection, verifyPgSchemaDiffBinary, } from './pg-schema-diff-helpers.js';
|
|
12
12
|
export type { PlanSqlRetryConfig, RetryConfig, RetryResult } from './retry-logic.js';
|
|
13
|
-
export { BASE_DELAY_MS, calculateBackoffDelay, DEFAULT_MAX_DELAY_MS,
|
|
13
|
+
export { BASE_DELAY_MS, calculateBackoffDelay, DEFAULT_MAX_DELAY_MS, executePlanSqlWithRetry, isLockTimeoutError, MAX_RETRIES, sleep, } from './retry-logic.js';
|
|
14
14
|
export { cleanupOrphanShadowDatabases, createShadowDbWithExtensions, needsShadowDb, } from './shadow-db-manager.js';
|
|
15
15
|
export type { DataCompatibilityResult, DataViolation, DataViolationType, } from './data-compatibility-checker.js';
|
|
16
16
|
export { checkDataCompatibility, displayDataCompatibilityResults, parseAddCheck, parseAddUnique, parseAlterType, parseCreateUniqueIndex, parseSetNotNull, } from './data-compatibility-checker.js';
|
|
17
|
+
export type { CleanPartitionAclsResult, PartitionAcl } from './partition-acl-cleaner.js';
|
|
18
|
+
export { cleanPartitionAclsForPgSchemaDiff } from './partition-acl-cleaner.js';
|
|
17
19
|
export type { DetectedPartitionStub, PrefilterResult } from './partition-prefilter.js';
|
|
18
20
|
export { prefilterPartitionStubs } from './partition-prefilter.js';
|
|
19
21
|
export type { ExpectedPartition, PartitionDrift } from './partition-validator.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/commands/db/apply/helpers/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAE5B,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAClG,OAAO,EACL,mCAAmC,EACnC,eAAe,EACf,wBAAwB,GACzB,MAAM,qBAAqB,CAAC;AAE7B,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/commands/db/apply/helpers/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAE5B,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAClG,OAAO,EACL,mCAAmC,EACnC,iCAAiC,EACjC,eAAe,EACf,wBAAwB,GACzB,MAAM,qBAAqB,CAAC;AAE7B,YAAY,EACV,0BAA0B,EAC1B,YAAY,EACZ,2BAA2B,EAC3B,uBAAuB,GACxB,MAAM,6BAA6B,CAAC;AACrC,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7E,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,6BAA6B,EAC7B,uBAAuB,EACvB,yBAAyB,EACzB,uBAAuB,EACvB,0BAA0B,EAC1B,4BAA4B,EAC5B,6BAA6B,EAC7B,4BAA4B,EAC5B,kBAAkB,EAClB,wBAAwB,EACxB,+BAA+B,EAC/B,8BAA8B,EAC9B,sBAAsB,EACtB,uBAAuB,EACvB,+BAA+B,EAC/B,yBAAyB,EACzB,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,6BAA6B,CAAC;AACrC,YAAY,EAAE,kBAAkB,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAErF,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,EACvB,kBAAkB,EAClB,WAAW,EACX,KAAK,GACN,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,4BAA4B,EAC5B,4BAA4B,EAC5B,aAAa,GACd,MAAM,wBAAwB,CAAC;AAEhC,YAAY,EACV,uBAAuB,EACvB,aAAa,EACb,iBAAiB,GAClB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,sBAAsB,EACtB,+BAA+B,EAC/B,aAAa,EACb,cAAc,EACd,cAAc,EACd,sBAAsB,EACtB,eAAe,GAChB,MAAM,iCAAiC,CAAC;AAEzC,YAAY,EAAE,wBAAwB,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AACzF,OAAO,EAAE,iCAAiC,EAAE,MAAM,4BAA4B,CAAC;AAE/E,YAAY,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AACvF,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAEnE,YAAY,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAClF,OAAO,EACL,uBAAuB,EACvB,oBAAoB,EACpB,uBAAuB,EACvB,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export interface PartitionAcl {
|
|
2
|
+
/** Qualified partition child name (e.g., "events.location_events_2026_01") */
|
|
3
|
+
childName: string;
|
|
4
|
+
/** Raw PostgreSQL ACL string (e.g., "{postgres=arwdDxt/postgres,drizzle_app=r/postgres}") */
|
|
5
|
+
acl: string;
|
|
6
|
+
/** Owner role of the partition (e.g., "postgres") */
|
|
7
|
+
owner: string;
|
|
8
|
+
}
|
|
9
|
+
export interface CleanPartitionAclsResult {
|
|
10
|
+
/** Number of partitions processed */
|
|
11
|
+
partitionsProcessed: number;
|
|
12
|
+
/** Number of REVOKE statements executed */
|
|
13
|
+
revokesExecuted: number;
|
|
14
|
+
/** Roles that had privileges revoked */
|
|
15
|
+
revokedRoles: string[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Query partition child tables that have non-null ACLs.
|
|
19
|
+
*
|
|
20
|
+
* Uses pg_inherits to find partition children, then reads relacl and relowner.
|
|
21
|
+
* Only returns partitions within the specified schemas.
|
|
22
|
+
*/
|
|
23
|
+
export declare function queryPartitionAcls(dbUrl: string, schemas: string[]): PartitionAcl[];
|
|
24
|
+
/**
|
|
25
|
+
* Parse a PostgreSQL ACL string and extract non-owner role names.
|
|
26
|
+
*
|
|
27
|
+
* PostgreSQL ACL format: {rolename=privs/grantor,...}
|
|
28
|
+
* - Empty rolename (e.g., "=r/postgres") means PUBLIC
|
|
29
|
+
* - Owner entries are skipped (owner already has implicit privileges)
|
|
30
|
+
*
|
|
31
|
+
* @returns Set of role names (PUBLIC represented as "PUBLIC")
|
|
32
|
+
*/
|
|
33
|
+
export declare function parseAclForNonOwnerRoles(acl: string, owner: string): Set<string>;
|
|
34
|
+
/**
|
|
35
|
+
* Execute REVOKE ALL statements for non-owner roles on partition children.
|
|
36
|
+
*
|
|
37
|
+
* Each REVOKE is executed individually so a single failure doesn't block others.
|
|
38
|
+
*/
|
|
39
|
+
export declare function revokePartitionAcls(dbUrl: string, partitions: PartitionAcl[]): CleanPartitionAclsResult;
|
|
40
|
+
/**
|
|
41
|
+
* Clean partition ACLs before pg-schema-diff plan execution.
|
|
42
|
+
*
|
|
43
|
+
* This is the main entry point called from actors.ts. It:
|
|
44
|
+
* 1. Queries partition children with non-null ACLs
|
|
45
|
+
* 2. Parses ACLs to find non-owner grants
|
|
46
|
+
* 3. Revokes non-owner privileges temporarily
|
|
47
|
+
*
|
|
48
|
+
* The 2nd-pass idempotent SQL re-applies the grants after pg-schema-diff.
|
|
49
|
+
*
|
|
50
|
+
* Non-fatal: any failure is logged as warning and silently ignored.
|
|
51
|
+
* This matches the safety pattern of replicateDefaultPrivileges() in shadow-db-manager.ts.
|
|
52
|
+
*/
|
|
53
|
+
export declare function cleanPartitionAclsForPgSchemaDiff(dbUrl: string, schemas: string[], verbose: boolean): void;
|
|
54
|
+
//# sourceMappingURL=partition-acl-cleaner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"partition-acl-cleaner.d.ts","sourceRoot":"","sources":["../../../../../src/commands/db/apply/helpers/partition-acl-cleaner.ts"],"names":[],"mappings":"AAiCA,MAAM,WAAW,YAAY;IAC3B,8EAA8E;IAC9E,SAAS,EAAE,MAAM,CAAC;IAClB,6FAA6F;IAC7F,GAAG,EAAE,MAAM,CAAC;IACZ,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,wBAAwB;IACvC,qCAAqC;IACrC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,2CAA2C;IAC3C,eAAe,EAAE,MAAM,CAAC;IACxB,wCAAwC;IACxC,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAeD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,YAAY,EAAE,CAyCnF;AAMD;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAwChF;AA+BD;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,YAAY,EAAE,GACzB,wBAAwB,CAwB1B;AAMD;;;;;;;;;;;;GAYG;AACH,wBAAgB,iCAAiC,CAC/C,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,EAAE,OAAO,GACf,IAAI,CA8BN"}
|
|
@@ -41,6 +41,19 @@ export declare function filterFalsePositiveHazards(hazards: ParsedHazard[], sche
|
|
|
41
41
|
* Useful for testing or when schema files change.
|
|
42
42
|
*/
|
|
43
43
|
export declare function resetIdempotentRolesCache(): void;
|
|
44
|
+
/**
|
|
45
|
+
* AI HINT: Idempotent Table Extraction
|
|
46
|
+
*
|
|
47
|
+
* Purpose: Extract table names defined in idempotent/*.sql files
|
|
48
|
+
* Use case: Filter out DROP TABLE statements for these tables from pg-schema-diff plan
|
|
49
|
+
*
|
|
50
|
+
* Pattern: Parse SQL for CREATE TABLE statements
|
|
51
|
+
* Example: CREATE TABLE location_data.location_events → ['location_data.location_events']
|
|
52
|
+
*
|
|
53
|
+
* Incident context: pg-schema-diff drops tables not in declarative/*.sql because its
|
|
54
|
+
* shadow DB doesn't contain idempotent-managed tables. This function identifies those
|
|
55
|
+
* tables so their DROP statements can be filtered from the plan output.
|
|
56
|
+
*/
|
|
44
57
|
/**
|
|
45
58
|
* Extract table names from idempotent SQL files.
|
|
46
59
|
* These tables are managed outside pg-schema-diff and must not be dropped.
|
|
@@ -48,11 +61,6 @@ export declare function resetIdempotentRolesCache(): void;
|
|
|
48
61
|
* Also merges tables from `excludeFromOrphanDetection` config.
|
|
49
62
|
*/
|
|
50
63
|
export declare function getIdempotentProtectedTables(schemasDir?: string, configExclusions?: string[]): string[];
|
|
51
|
-
/**
|
|
52
|
-
* Reset the cached idempotent tables.
|
|
53
|
-
* Useful for testing or when schema files change.
|
|
54
|
-
*/
|
|
55
|
-
export declare function resetIdempotentTablesCache(): void;
|
|
56
64
|
/**
|
|
57
65
|
* Verify pg-schema-diff binary is available.
|
|
58
66
|
*/
|
|
@@ -78,11 +86,6 @@ export interface ParsedHazard {
|
|
|
78
86
|
* Enhanced to extract the SQL statement that caused each hazard.
|
|
79
87
|
*/
|
|
80
88
|
export declare function parseHazardsWithContext(planOutput: string): ParsedHazard[];
|
|
81
|
-
/**
|
|
82
|
-
* Parse hazards from pg-schema-diff output (legacy format for compatibility).
|
|
83
|
-
* Filters out false positives (AUTHZ_UPDATE for idempotent roles).
|
|
84
|
-
*/
|
|
85
|
-
export declare function parseHazardsFromOutput(planOutput: string, schemasDir?: string): string[];
|
|
86
89
|
/**
|
|
87
90
|
* Display hazards with context and return flags.
|
|
88
91
|
*/
|
|
@@ -90,10 +93,6 @@ export declare function displayHazardsWithContext(hazards: ParsedHazard[], verbo
|
|
|
90
93
|
hasDeletesData: boolean;
|
|
91
94
|
hasAuthzUpdate: boolean;
|
|
92
95
|
};
|
|
93
|
-
/**
|
|
94
|
-
* Display hazards and return if has DELETES_DATA (legacy interface).
|
|
95
|
-
*/
|
|
96
|
-
export declare function displayHazards(hazards: string[]): boolean;
|
|
97
96
|
/**
|
|
98
97
|
* Handle production data protection for DELETES_DATA hazard.
|
|
99
98
|
*/
|
|
@@ -103,19 +102,50 @@ export declare function handleProductionDataProtection(allowDataLoss: boolean):
|
|
|
103
102
|
* RLS policy changes can silently affect security if not explicitly approved.
|
|
104
103
|
*/
|
|
105
104
|
export declare function handleProductionAuthzProtection(confirmAuthzUpdate: boolean): void;
|
|
105
|
+
/**
|
|
106
|
+
* AI HINT: Idempotent Object Extraction
|
|
107
|
+
*
|
|
108
|
+
* Purpose: Extract all object names defined in idempotent/*.sql files
|
|
109
|
+
* Use case: Filter DROP FUNCTION/TRIGGER/VIEW/TYPE/SEQUENCE from pg-schema-diff plan
|
|
110
|
+
*
|
|
111
|
+
* Pattern: Parse SQL for CREATE statements (after stripping comments)
|
|
112
|
+
* Objects created in idempotent/*.sql are invisible to pg-schema-diff's shadow DB,
|
|
113
|
+
* so pg-schema-diff generates DROP statements for them. We must filter these out.
|
|
114
|
+
*/
|
|
115
|
+
export interface IdempotentProtectedObjects {
|
|
116
|
+
tables: string[];
|
|
117
|
+
functions: string[];
|
|
118
|
+
triggers: string[];
|
|
119
|
+
views: string[];
|
|
120
|
+
types: string[];
|
|
121
|
+
sequences: string[];
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Extract all protected object names from idempotent/*.sql files.
|
|
125
|
+
*
|
|
126
|
+
* Scans for:
|
|
127
|
+
* - CREATE [OR REPLACE] FUNCTION schema.name(...)
|
|
128
|
+
* - CREATE TRIGGER name ON schema.table
|
|
129
|
+
* - CREATE [OR REPLACE] [MATERIALIZED] VIEW schema.name
|
|
130
|
+
* - CREATE TYPE schema.name
|
|
131
|
+
* - CREATE SEQUENCE schema.name
|
|
132
|
+
*
|
|
133
|
+
* Uses stripSqlComments to avoid matching inside comments.
|
|
134
|
+
*/
|
|
135
|
+
export declare function getIdempotentProtectedObjects(schemasDir?: string, configExclusions?: string[]): IdempotentProtectedObjects;
|
|
106
136
|
/**
|
|
107
137
|
* Display check mode results.
|
|
108
138
|
*/
|
|
109
|
-
export declare function displayCheckModeResults(planOutput: string
|
|
139
|
+
export declare function displayCheckModeResults(planOutput: string, filterInfo?: {
|
|
140
|
+
filteredPlanSql: string;
|
|
141
|
+
removedStatements: {
|
|
142
|
+
sql: string;
|
|
143
|
+
}[];
|
|
144
|
+
}): void;
|
|
110
145
|
/**
|
|
111
146
|
* Build list of allowed hazards based on environment and flags.
|
|
112
147
|
*/
|
|
113
148
|
export declare function buildAllowedHazards(input: DbApplyInput): string[];
|
|
114
|
-
/**
|
|
115
|
-
* Handle hazards: display, validate, and block if necessary.
|
|
116
|
-
* Enhanced with AUTHZ_UPDATE protection and context display.
|
|
117
|
-
*/
|
|
118
|
-
export declare function handleHazards(hazards: string[], input: DbApplyInput): void;
|
|
119
149
|
/**
|
|
120
150
|
* Handle hazards with enhanced context display.
|
|
121
151
|
* Use this for detailed hazard reporting with SQL context.
|
|
@@ -142,6 +172,19 @@ export declare function detectMissingExtensionType(errorOutput: string): Missing
|
|
|
142
172
|
* Format actionable hint for missing extension type errors.
|
|
143
173
|
*/
|
|
144
174
|
export declare function formatExtensionErrorHint(detection: MissingExtensionDetection): string;
|
|
175
|
+
export interface PartitionPrivilegeDetection {
|
|
176
|
+
detected: boolean;
|
|
177
|
+
errorFragment: string;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Detect "privileges on partitions: not implemented" errors in pg-schema-diff output.
|
|
181
|
+
* pg-schema-diff v1.0.5 hard-rejects partition privilege diffs in sql_generator.go.
|
|
182
|
+
*/
|
|
183
|
+
export declare function detectPartitionPrivilegeError(errorOutput: string): PartitionPrivilegeDetection;
|
|
184
|
+
/**
|
|
185
|
+
* Format actionable hint for partition privilege errors.
|
|
186
|
+
*/
|
|
187
|
+
export declare function formatPartitionPrivilegeHint(detection: PartitionPrivilegeDetection): string;
|
|
145
188
|
/**
|
|
146
189
|
* Detect DROP TABLE statements in plan output.
|
|
147
190
|
* Returns list of "schema.table" names that would be dropped.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pg-schema-diff-helpers.d.ts","sourceRoot":"","sources":["../../../../../src/commands/db/apply/helpers/pg-schema-diff-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAOH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAsBnD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"pg-schema-diff-helpers.d.ts","sourceRoot":"","sources":["../../../../../src/commands/db/apply/helpers/pg-schema-diff-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAOH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAsBnD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAsChE;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,YAAY,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CA8BzF;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,YAAY,EAAE,EACvB,UAAU,CAAC,EAAE,MAAM,GAClB;IAAE,QAAQ,EAAE,YAAY,EAAE,CAAC;IAAC,cAAc,EAAE,YAAY,EAAE,CAAA;CAAE,CAa9D;AAED;;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G,MAAM,CAmB3F;AAMD;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAWtE;AAMD;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;;;;;;;OASG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAKD,mEAAmE;AACnE,eAAO,MAAM,+BAA+B,SAAU,CAAC;AAEvD;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,MAAM,EAAE,EACxB,OAAO,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,uBAAuB,GAChC;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAoE5C"}
|
|
@@ -7,11 +7,12 @@
|
|
|
7
7
|
* Pattern: plan → Zod validation → psql execution
|
|
8
8
|
*
|
|
9
9
|
* Safety layers:
|
|
10
|
-
* 1.
|
|
10
|
+
* 1. handleHazardsWithContext() in actors.ts → blocks unapproved hazards (primary)
|
|
11
11
|
* 2. validatePlanForExecution() → defense-in-depth hazard check
|
|
12
12
|
* 3. Zod structural validation → ensures plan is well-formed
|
|
13
13
|
*/
|
|
14
14
|
import { z } from 'zod';
|
|
15
|
+
import type { IdempotentProtectedObjects } from './pg-schema-diff-helpers.js';
|
|
15
16
|
export declare const PlanHazardSchema: z.ZodObject<{
|
|
16
17
|
type: z.ZodString;
|
|
17
18
|
message: z.ZodString;
|
|
@@ -64,6 +65,14 @@ export interface FilterResult {
|
|
|
64
65
|
* are converted to regex for matching partition child tables.
|
|
65
66
|
*/
|
|
66
67
|
declare function isDropStatementForProtected(sql: string, protectedTables: string[]): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Check if a DROP FUNCTION/TRIGGER/VIEW/TYPE/SEQUENCE targets a protected object.
|
|
70
|
+
*
|
|
71
|
+
* For FUNCTION: matches schema.name (argument types stripped).
|
|
72
|
+
* For TRIGGER: matches schema.trigger_name via DROP TRIGGER name ON schema.table.
|
|
73
|
+
* For VIEW/TYPE/SEQUENCE: matches schema.name.
|
|
74
|
+
*/
|
|
75
|
+
export declare function isDropStatementForProtectedObject(sql: string, protectedObjects: IdempotentProtectedObjects): boolean;
|
|
67
76
|
/**
|
|
68
77
|
* Extract unique schema names from protected table patterns.
|
|
69
78
|
* e.g., ['location_data.events', 'accounts.clients'] → ['location_data', 'accounts']
|
|
@@ -75,17 +84,21 @@ declare function extractProtectedSchemas(protectedTables: string[]): string[];
|
|
|
75
84
|
*/
|
|
76
85
|
declare function isDropSchemaForProtected(sql: string, protectedTables: string[]): string | null;
|
|
77
86
|
/**
|
|
78
|
-
* Filter out DROP TABLE/INDEX statements targeting idempotent-managed tables
|
|
87
|
+
* Filter out DROP TABLE/INDEX statements targeting idempotent-managed tables,
|
|
88
|
+
* and optionally DROP FUNCTION/TRIGGER/VIEW/TYPE/SEQUENCE for protected objects.
|
|
79
89
|
* BLOCKS (throws error) on DROP SCHEMA targeting protected schemas.
|
|
90
|
+
*
|
|
91
|
+
* @param protectedObjects - Optional extended protection for non-table objects.
|
|
92
|
+
* When omitted, only DROP TABLE/INDEX are filtered (backward compatible).
|
|
80
93
|
*/
|
|
81
|
-
export declare function filterIdempotentProtectedStatements(plan: ValidatedPlan, protectedTables: string[]): FilterResult;
|
|
94
|
+
export declare function filterIdempotentProtectedStatements(plan: ValidatedPlan, protectedTables: string[], protectedObjects?: IdempotentProtectedObjects): FilterResult;
|
|
82
95
|
export { isDropStatementForProtected as _isDropStatementForProtected };
|
|
83
96
|
export { extractProtectedSchemas as _extractProtectedSchemas };
|
|
84
97
|
export { isDropSchemaForProtected as _isDropSchemaForProtected };
|
|
85
98
|
/**
|
|
86
99
|
* Validate that all hazards in the plan are in the allowed list.
|
|
87
100
|
*
|
|
88
|
-
* Defense-in-depth:
|
|
101
|
+
* Defense-in-depth: handleHazardsWithContext() in actors.ts is the primary check.
|
|
89
102
|
* This is a secondary safety gate right before psql execution.
|
|
90
103
|
*
|
|
91
104
|
* @throws Error if unresolved hazards are found
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan-validator.d.ts","sourceRoot":"","sources":["../../../../../src/commands/db/apply/helpers/plan-validator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"plan-validator.d.ts","sourceRoot":"","sources":["../../../../../src/commands/db/apply/helpers/plan-validator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AAM9E,eAAO,MAAM,gBAAgB;;;iBAG3B,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;iBAI9B,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;;;iBAI9B,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC1D,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAChE,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAiFhE;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,aAAa,CAgBjE;AAMD,MAAM,WAAW,YAAY;IAC3B,YAAY,EAAE,aAAa,CAAC;IAC5B,iBAAiB,EAAE,aAAa,EAAE,CAAC;CACpC;AAED;;;;;;;;;GASG;AACH,iBAAS,2BAA2B,CAAC,GAAG,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,GAAG,OAAO,CAgEpF;AAwBD;;;;;;GAMG;AACH,wBAAgB,iCAAiC,CAC/C,GAAG,EAAE,MAAM,EACX,gBAAgB,EAAE,0BAA0B,GAC3C,OAAO,CA2CT;AAED;;;GAGG;AACH,iBAAS,uBAAuB,CAAC,eAAe,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CASpE;AAED;;;GAGG;AACH,iBAAS,wBAAwB,CAAC,GAAG,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAYvF;AAED;;;;;;;GAOG;AACH,wBAAgB,mCAAmC,CACjD,IAAI,EAAE,aAAa,EACnB,eAAe,EAAE,MAAM,EAAE,EACzB,gBAAgB,CAAC,EAAE,0BAA0B,GAC5C,YAAY,CAoEd;AAGD,OAAO,EAAE,2BAA2B,IAAI,4BAA4B,EAAE,CAAC;AACvE,OAAO,EAAE,uBAAuB,IAAI,wBAAwB,EAAE,CAAC;AAC/D,OAAO,EAAE,wBAAwB,IAAI,yBAAyB,EAAE,CAAC;AAMjE;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,EAAE,GAAG,IAAI,CAehG"}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Purpose: Retry pg-schema-diff operations on lock_timeout errors
|
|
5
5
|
* Pattern: Exponential backoff with jitter (configurable max delay)
|
|
6
6
|
*/
|
|
7
|
+
import { type IdempotentProtectedObjects } from './pg-schema-diff-helpers.js';
|
|
7
8
|
export declare const MAX_RETRIES = 5;
|
|
8
9
|
export declare const BASE_DELAY_MS = 1000;
|
|
9
10
|
export declare const DEFAULT_MAX_DELAY_MS = 30000;
|
|
@@ -43,11 +44,6 @@ export declare function calculateBackoffDelay(attempt: number, maxDelayMs?: numb
|
|
|
43
44
|
* Check if error is a lock_timeout error.
|
|
44
45
|
*/
|
|
45
46
|
export declare function isLockTimeoutError(errorOutput: string): boolean;
|
|
46
|
-
/**
|
|
47
|
-
* Execute pg-schema-diff apply with retry logic.
|
|
48
|
-
* Enhanced with configurable options and metrics.
|
|
49
|
-
*/
|
|
50
|
-
export declare function executeApplyWithRetry(applyArgs: string[], verbose: boolean, config?: RetryConfig): Promise<RetryResult>;
|
|
51
47
|
/**
|
|
52
48
|
* Wrap plan SQL for execution.
|
|
53
49
|
*
|
|
@@ -78,6 +74,11 @@ export interface PlanSqlRetryConfig extends RetryConfig {
|
|
|
78
74
|
* Prevents pg-schema-diff from dropping tables it doesn't know about.
|
|
79
75
|
*/
|
|
80
76
|
protectedTables?: string[];
|
|
77
|
+
/**
|
|
78
|
+
* All objects managed by idempotent SQL — DROP statements for these are filtered.
|
|
79
|
+
* Extends table protection to functions, triggers, views, types, and sequences.
|
|
80
|
+
*/
|
|
81
|
+
protectedObjects?: IdempotentProtectedObjects;
|
|
81
82
|
}
|
|
82
83
|
/**
|
|
83
84
|
* Execute plan SQL via psql with retry logic.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retry-logic.d.ts","sourceRoot":"","sources":["../../../../../src/commands/db/apply/helpers/retry-logic.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"retry-logic.d.ts","sourceRoot":"","sources":["../../../../../src/commands/db/apply/helpers/retry-logic.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,OAAO,EAAE,KAAK,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AAS9E,eAAO,MAAM,WAAW,IAAI,CAAC;AAC7B,eAAO,MAAM,aAAa,OAAO,CAAC;AAClC,eAAO,MAAM,oBAAoB,QAAQ,CAAC;AAE1C;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,uCAAuC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yDAAyD;IACzD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kEAAkE;IAClE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oCAAoC;IACpC,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;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CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;GAEG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;iBAInC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"db-schema.d.ts","sourceRoot":"","sources":["../../../../src/commands/db/commands/db-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAiBH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;GAEG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;iBAInC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,eAAe,SA2CxB,CAAC;AAEL;;GAEG;AACH,eAAO,MAAM,YAAY,SAmErB,CAAC;AAEL;;GAEG;AACH,eAAO,MAAM,YAAY,SAgDrB,CAAC;AAEL;;GAEG;AACH,eAAO,MAAM,eAAe,SAyCxB,CAAC;AAEL;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,SAgEpB,CAAC"}
|