@schemashift/core 0.11.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +633 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +156 -1
- package/dist/index.d.ts +156 -1
- package/dist/index.js +618 -32
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -108,6 +108,7 @@ declare class ApprovalManager {
|
|
|
108
108
|
* Check if a migration has been approved.
|
|
109
109
|
*/
|
|
110
110
|
isApproved(requestId: string): boolean;
|
|
111
|
+
private isValidRequest;
|
|
111
112
|
private ensureDir;
|
|
112
113
|
}
|
|
113
114
|
|
|
@@ -297,7 +298,14 @@ declare class MigrationAuditLog {
|
|
|
297
298
|
* Clear the audit log.
|
|
298
299
|
*/
|
|
299
300
|
clear(): void;
|
|
301
|
+
/**
|
|
302
|
+
* Export a compliance report in SOC2 or HIPAA format.
|
|
303
|
+
*/
|
|
304
|
+
exportComplianceReport(format: 'soc2' | 'hipaa'): string;
|
|
305
|
+
private generateSoc2Report;
|
|
306
|
+
private generateHipaaReport;
|
|
300
307
|
private collectMetadata;
|
|
308
|
+
private isValidAuditLog;
|
|
301
309
|
private write;
|
|
302
310
|
private hashContent;
|
|
303
311
|
private getCurrentUser;
|
|
@@ -457,8 +465,13 @@ interface ComplexityEstimate {
|
|
|
457
465
|
warnings: ComplexityWarning[];
|
|
458
466
|
riskAreas: string[];
|
|
459
467
|
}
|
|
468
|
+
interface DurationEstimate {
|
|
469
|
+
label: string;
|
|
470
|
+
rangeMinutes: [number, number];
|
|
471
|
+
}
|
|
460
472
|
declare class ComplexityEstimator {
|
|
461
473
|
estimate(files: SourceFile[]): ComplexityEstimate;
|
|
474
|
+
estimateDuration(estimate: ComplexityEstimate): DurationEstimate;
|
|
462
475
|
private calculateEffort;
|
|
463
476
|
}
|
|
464
477
|
|
|
@@ -519,6 +532,28 @@ declare function validateConfig(config: SchemaShiftConfig): {
|
|
|
519
532
|
declare function shouldSuppressWarning(warning: string, filePath: string, rules: WarningSuppressionRule[]): boolean;
|
|
520
533
|
declare function loadConfig(configPath?: string): Promise<SchemaShiftConfig>;
|
|
521
534
|
|
|
535
|
+
/**
|
|
536
|
+
* Centralized constants for SchemaShift paths and defaults.
|
|
537
|
+
*/
|
|
538
|
+
/** Directory for SchemaShift state files (.schemashift/) */
|
|
539
|
+
declare const SCHEMASHIFT_DIR = ".schemashift";
|
|
540
|
+
/** Default backup directory name */
|
|
541
|
+
declare const BACKUP_DIR = ".schemashift-backup";
|
|
542
|
+
/** Config file search names (cosmiconfig) */
|
|
543
|
+
declare const CONFIG_FILE_NAMES: readonly [".schemashiftrc", ".schemashiftrc.json", ".schemashiftrc.yaml", ".schemashiftrc.yml", ".schemashiftrc.js", ".schemashiftrc.cjs"];
|
|
544
|
+
/** Default config file name for init command */
|
|
545
|
+
declare const DEFAULT_CONFIG_FILE = ".schemashiftrc.json";
|
|
546
|
+
/** Incremental state file name (inside SCHEMASHIFT_DIR) */
|
|
547
|
+
declare const INCREMENTAL_STATE_FILE = "incremental.json";
|
|
548
|
+
/** Audit log file name (inside SCHEMASHIFT_DIR) */
|
|
549
|
+
declare const AUDIT_LOG_FILE = "audit-log.json";
|
|
550
|
+
/** Schema snapshot file name (inside SCHEMASHIFT_DIR) */
|
|
551
|
+
declare const SCHEMA_SNAPSHOT_FILE = "schema-snapshot.json";
|
|
552
|
+
/** Pending approvals subdirectory (inside SCHEMASHIFT_DIR) */
|
|
553
|
+
declare const PENDING_DIR = "pending";
|
|
554
|
+
/** Test scaffolding output subdirectory (inside SCHEMASHIFT_DIR) */
|
|
555
|
+
declare const TESTS_DIR = "tests";
|
|
556
|
+
|
|
522
557
|
/**
|
|
523
558
|
* Cross-Field Validation Pattern Helpers
|
|
524
559
|
*
|
|
@@ -559,6 +594,28 @@ declare function conditionalValidation(conditionField: string, conditionValue: s
|
|
|
559
594
|
*/
|
|
560
595
|
declare function suggestCrossFieldPattern(whenCode: string): CrossFieldPattern | null;
|
|
561
596
|
|
|
597
|
+
interface UnusedSchema {
|
|
598
|
+
schemaName: string;
|
|
599
|
+
filePath: string;
|
|
600
|
+
lineNumber: number;
|
|
601
|
+
}
|
|
602
|
+
interface DeadSchemaResult {
|
|
603
|
+
unusedSchemas: UnusedSchema[];
|
|
604
|
+
totalSchemas: number;
|
|
605
|
+
summary: string;
|
|
606
|
+
}
|
|
607
|
+
/**
|
|
608
|
+
* Detects schema definitions that are never referenced elsewhere in the codebase.
|
|
609
|
+
*
|
|
610
|
+
* Scans for variable declarations that use schema library patterns (z., yup., Joi., etc.)
|
|
611
|
+
* and checks if those variables are referenced in other files.
|
|
612
|
+
*/
|
|
613
|
+
declare class DeadSchemaDetector {
|
|
614
|
+
detect(sourceFiles: SourceFile[]): DeadSchemaResult;
|
|
615
|
+
private collectSchemaDefinitions;
|
|
616
|
+
private findUnusedSchemas;
|
|
617
|
+
}
|
|
618
|
+
|
|
562
619
|
interface DependencyGraphResult {
|
|
563
620
|
/** Files sorted in dependency order (dependencies first) */
|
|
564
621
|
sortedFiles: string[];
|
|
@@ -789,6 +846,7 @@ declare class GovernanceEngine {
|
|
|
789
846
|
*/
|
|
790
847
|
registerRule(name: string, fn: GovernanceRuleFunction): void;
|
|
791
848
|
analyze(project: Project): GovernanceResult;
|
|
849
|
+
private safeRegExp;
|
|
792
850
|
private detectFileLibrary;
|
|
793
851
|
private measureNestingDepth;
|
|
794
852
|
private detectDynamicSchemas;
|
|
@@ -911,6 +969,34 @@ declare class GraphExporter {
|
|
|
911
969
|
private toMermaidId;
|
|
912
970
|
}
|
|
913
971
|
|
|
972
|
+
interface DuplicateImport {
|
|
973
|
+
source: string;
|
|
974
|
+
filePath: string;
|
|
975
|
+
lineNumber: number;
|
|
976
|
+
importedNames: string[];
|
|
977
|
+
}
|
|
978
|
+
interface DuplicateImportGroup {
|
|
979
|
+
source: string;
|
|
980
|
+
occurrences: DuplicateImport[];
|
|
981
|
+
suggestion: string;
|
|
982
|
+
}
|
|
983
|
+
interface ImportDeduplicationResult {
|
|
984
|
+
duplicateGroups: DuplicateImportGroup[];
|
|
985
|
+
totalDuplicates: number;
|
|
986
|
+
summary: string;
|
|
987
|
+
}
|
|
988
|
+
/**
|
|
989
|
+
* Detects duplicate import declarations within individual files.
|
|
990
|
+
*
|
|
991
|
+
* After migration, files may end up with multiple import statements from the
|
|
992
|
+
* same module (e.g., two `import { ... } from 'zod'` lines). This detector
|
|
993
|
+
* identifies those cases and suggests merging them.
|
|
994
|
+
*/
|
|
995
|
+
declare class ImportDeduplicator {
|
|
996
|
+
detect(sourceFiles: SourceFile[]): ImportDeduplicationResult;
|
|
997
|
+
private findDuplicatesInFile;
|
|
998
|
+
}
|
|
999
|
+
|
|
914
1000
|
interface IncrementalState {
|
|
915
1001
|
migrationId: string;
|
|
916
1002
|
from: SchemaLibrary;
|
|
@@ -937,7 +1023,13 @@ declare class IncrementalTracker {
|
|
|
937
1023
|
total: number;
|
|
938
1024
|
percent: number;
|
|
939
1025
|
} | null;
|
|
1026
|
+
/**
|
|
1027
|
+
* Get a canary batch — a percentage of remaining files, sorted simplest first.
|
|
1028
|
+
* Used for phased rollouts where you migrate a small batch, verify, then continue.
|
|
1029
|
+
*/
|
|
1030
|
+
getCanaryBatch(percent: number, fileSizes?: Map<string, number>): string[];
|
|
940
1031
|
clear(): void;
|
|
1032
|
+
private isValidState;
|
|
941
1033
|
private saveState;
|
|
942
1034
|
}
|
|
943
1035
|
|
|
@@ -1012,11 +1104,14 @@ interface NotificationResult {
|
|
|
1012
1104
|
statusCode?: number;
|
|
1013
1105
|
error?: string;
|
|
1014
1106
|
}
|
|
1107
|
+
type WebhookType = 'generic' | 'slack' | 'teams';
|
|
1015
1108
|
interface WebhookConfig {
|
|
1016
1109
|
url: string;
|
|
1017
1110
|
events?: MigrationEventType[];
|
|
1018
1111
|
headers?: Record<string, string>;
|
|
1019
1112
|
secret?: string;
|
|
1113
|
+
type?: WebhookType;
|
|
1114
|
+
timeoutMs?: number;
|
|
1020
1115
|
}
|
|
1021
1116
|
/**
|
|
1022
1117
|
* Send migration event notifications via webhooks.
|
|
@@ -1032,6 +1127,16 @@ declare class WebhookNotifier {
|
|
|
1032
1127
|
* Send an event to all matching webhooks.
|
|
1033
1128
|
*/
|
|
1034
1129
|
send(event: MigrationEvent): Promise<NotificationResult[]>;
|
|
1130
|
+
/**
|
|
1131
|
+
* Format event as Slack Block Kit message.
|
|
1132
|
+
*/
|
|
1133
|
+
formatSlackPayload(event: MigrationEvent): Record<string, unknown>;
|
|
1134
|
+
/**
|
|
1135
|
+
* Format event as Microsoft Teams Adaptive Card.
|
|
1136
|
+
*/
|
|
1137
|
+
formatTeamsPayload(event: MigrationEvent): Record<string, unknown>;
|
|
1138
|
+
private getEventEmoji;
|
|
1139
|
+
private getEventTitle;
|
|
1035
1140
|
/**
|
|
1036
1141
|
* Send event to a single webhook endpoint.
|
|
1037
1142
|
*/
|
|
@@ -1124,6 +1229,56 @@ declare class PluginLoader {
|
|
|
1124
1229
|
private validatePlugin;
|
|
1125
1230
|
}
|
|
1126
1231
|
|
|
1232
|
+
interface VerificationSample {
|
|
1233
|
+
name: string;
|
|
1234
|
+
input: unknown;
|
|
1235
|
+
expectedValid: boolean;
|
|
1236
|
+
}
|
|
1237
|
+
interface SchemaVerificationResult {
|
|
1238
|
+
schemaName: string;
|
|
1239
|
+
filePath: string;
|
|
1240
|
+
totalSamples: number;
|
|
1241
|
+
matchingSamples: number;
|
|
1242
|
+
mismatches: VerificationMismatch[];
|
|
1243
|
+
parityScore: number;
|
|
1244
|
+
}
|
|
1245
|
+
interface VerificationMismatch {
|
|
1246
|
+
sampleName: string;
|
|
1247
|
+
input: unknown;
|
|
1248
|
+
sourceResult: {
|
|
1249
|
+
valid: boolean;
|
|
1250
|
+
error?: string;
|
|
1251
|
+
};
|
|
1252
|
+
targetResult: {
|
|
1253
|
+
valid: boolean;
|
|
1254
|
+
error?: string;
|
|
1255
|
+
};
|
|
1256
|
+
}
|
|
1257
|
+
interface VerificationReport {
|
|
1258
|
+
from: string;
|
|
1259
|
+
to: string;
|
|
1260
|
+
totalSchemas: number;
|
|
1261
|
+
results: SchemaVerificationResult[];
|
|
1262
|
+
overallParityScore: number;
|
|
1263
|
+
timestamp: string;
|
|
1264
|
+
}
|
|
1265
|
+
/**
|
|
1266
|
+
* Extracts schema definition names from source file text.
|
|
1267
|
+
*/
|
|
1268
|
+
declare function extractSchemaNames(sourceText: string): string[];
|
|
1269
|
+
/**
|
|
1270
|
+
* Generates test samples based on detected schema patterns.
|
|
1271
|
+
*/
|
|
1272
|
+
declare function generateSamples(sourceText: string, schemaName: string, maxSamples: number): VerificationSample[];
|
|
1273
|
+
/**
|
|
1274
|
+
* Creates a verification report comparing source and target schemas.
|
|
1275
|
+
*/
|
|
1276
|
+
declare function createVerificationReport(from: string, to: string, results: SchemaVerificationResult[]): VerificationReport;
|
|
1277
|
+
/**
|
|
1278
|
+
* Format verification report for terminal output.
|
|
1279
|
+
*/
|
|
1280
|
+
declare function formatVerificationReport(report: VerificationReport): string;
|
|
1281
|
+
|
|
1127
1282
|
interface StandardSchemaInfo {
|
|
1128
1283
|
detected: boolean;
|
|
1129
1284
|
compatibleLibraries: Array<{
|
|
@@ -1228,4 +1383,4 @@ declare class TypeDedupDetector {
|
|
|
1228
1383
|
private namesRelated;
|
|
1229
1384
|
}
|
|
1230
1385
|
|
|
1231
|
-
export { type AnalysisResult, type ApprovalDecision, ApprovalManager, type ApprovalStatus, type ApprovalSummary, type AuditEntry, type AuditEntryMetadata, type AuditLog, type BehavioralAnalysisResult, type BehavioralCategory, type BehavioralWarning, BehavioralWarningAnalyzer, BundleEstimator, type BundleSizeEstimate, type CallChainInfo, type ChainResult, type ChainStep, type ChainStepResult, type ChainValidation, CompatibilityAnalyzer, type CompatibilityResult, type ComplexityEstimate, ComplexityEstimator, type ComplexityWarning, type CrossFieldPattern, type CustomRule, type DependencyGraphResult, type DetailedAnalysisResult, DetailedAnalyzer, DriftDetector, type DriftModification, type DriftResult, type DuplicateTypeCandidate, EcosystemAnalyzer, type EcosystemIssue, type EcosystemReport, type EffortLevel, type FileComplexity, type FixResult, type FixSummary, type FormLibraryDetection, FormResolverMigrator, type FormResolverResult, GOVERNANCE_TEMPLATES, GovernanceEngine, GovernanceFixer, type GovernanceResult, type GovernanceRuleConfig, type GovernanceRuleFunction, type GovernanceTemplate, type GovernanceViolation, type GraphExportOptions, GraphExporter, type GraphNode, type IncrementalState, IncrementalTracker, type LibraryBundleInfo, type LibraryVersionInfo, type MethodCallInfo, MigrationAuditLog, MigrationChain, type MigrationEvent, type MigrationEventType, type MigrationReadiness, type MigrationRequest, type MigrationTemplate, type MigrationTemplateStep, type MonorepoInfo, type MonorepoPackage, MonorepoResolver, type NotificationResult, type PackageChange, type PackageUpdatePlan, PackageUpdater, type ParallelBatch, type PerformanceAnalysisResult, PerformanceAnalyzer, type PerformanceCategory, type PerformanceWarning, type PluginLoadResult, PluginLoader, type ScaffoldedTest, SchemaAnalyzer, type SchemaComplexity, SchemaDependencyResolver, type SchemaFileSnapshot, type SchemaInfo, type SchemaLibrary, type SchemaShiftConfig, type SchemaShiftPlugin, type SchemaSnapshot, StandardSchemaAdvisor, type StandardSchemaAdvisory, type StandardSchemaInfo, type TestScaffoldResult, TestScaffolder, TransformEngine, type TransformError, type TransformHandler, type TransformOptions, type TransformResult, TypeDedupDetector, type TypeDedupResult, type VersionIssue, type WarningSuppressionRule, type WebhookConfig, WebhookNotifier, type WorkspaceManager, buildCallChain, computeParallelBatches, conditionalValidation, dependentFields, detectFormLibraries, detectSchemaLibrary, detectStandardSchema, getAllMigrationTemplates, getGovernanceTemplate, getGovernanceTemplateNames, getGovernanceTemplatesByCategory, getMigrationTemplate, getMigrationTemplateNames, getMigrationTemplatesByCategory, isInsideComment, isInsideStringLiteral, loadConfig, mutuallyExclusive, parseCallChain, requireIf, requireOneOf, shouldSuppressWarning, startsWithBase, suggestCrossFieldPattern, transformMethodChain, validateConfig, validateMigrationTemplate };
|
|
1386
|
+
export { AUDIT_LOG_FILE, type AnalysisResult, type ApprovalDecision, ApprovalManager, type ApprovalStatus, type ApprovalSummary, type AuditEntry, type AuditEntryMetadata, type AuditLog, BACKUP_DIR, type BehavioralAnalysisResult, type BehavioralCategory, type BehavioralWarning, BehavioralWarningAnalyzer, BundleEstimator, type BundleSizeEstimate, CONFIG_FILE_NAMES, type CallChainInfo, type ChainResult, type ChainStep, type ChainStepResult, type ChainValidation, CompatibilityAnalyzer, type CompatibilityResult, type ComplexityEstimate, ComplexityEstimator, type ComplexityWarning, type CrossFieldPattern, type CustomRule, DEFAULT_CONFIG_FILE, DeadSchemaDetector, type DeadSchemaResult, type DependencyGraphResult, type DetailedAnalysisResult, DetailedAnalyzer, DriftDetector, type DriftModification, type DriftResult, type DuplicateImport, type DuplicateImportGroup, type DuplicateTypeCandidate, type DurationEstimate, EcosystemAnalyzer, type EcosystemIssue, type EcosystemReport, type EffortLevel, type FileComplexity, type FixResult, type FixSummary, type FormLibraryDetection, FormResolverMigrator, type FormResolverResult, GOVERNANCE_TEMPLATES, GovernanceEngine, GovernanceFixer, type GovernanceResult, type GovernanceRuleConfig, type GovernanceRuleFunction, type GovernanceTemplate, type GovernanceViolation, type GraphExportOptions, GraphExporter, type GraphNode, INCREMENTAL_STATE_FILE, type ImportDeduplicationResult, ImportDeduplicator, type IncrementalState, IncrementalTracker, type LibraryBundleInfo, type LibraryVersionInfo, type MethodCallInfo, MigrationAuditLog, MigrationChain, type MigrationEvent, type MigrationEventType, type MigrationReadiness, type MigrationRequest, type MigrationTemplate, type MigrationTemplateStep, type MonorepoInfo, type MonorepoPackage, MonorepoResolver, type NotificationResult, PENDING_DIR, type PackageChange, type PackageUpdatePlan, PackageUpdater, type ParallelBatch, type PerformanceAnalysisResult, PerformanceAnalyzer, type PerformanceCategory, type PerformanceWarning, type PluginLoadResult, PluginLoader, SCHEMASHIFT_DIR, SCHEMA_SNAPSHOT_FILE, type ScaffoldedTest, SchemaAnalyzer, type SchemaComplexity, SchemaDependencyResolver, type SchemaFileSnapshot, type SchemaInfo, type SchemaLibrary, type SchemaShiftConfig, type SchemaShiftPlugin, type SchemaSnapshot, type SchemaVerificationResult, StandardSchemaAdvisor, type StandardSchemaAdvisory, type StandardSchemaInfo, TESTS_DIR, type TestScaffoldResult, TestScaffolder, TransformEngine, type TransformError, type TransformHandler, type TransformOptions, type TransformResult, TypeDedupDetector, type TypeDedupResult, type UnusedSchema, type VerificationMismatch, type VerificationReport, type VerificationSample, type VersionIssue, type WarningSuppressionRule, type WebhookConfig, WebhookNotifier, type WebhookType, type WorkspaceManager, buildCallChain, computeParallelBatches, conditionalValidation, createVerificationReport, dependentFields, detectFormLibraries, detectSchemaLibrary, detectStandardSchema, extractSchemaNames, formatVerificationReport, generateSamples, getAllMigrationTemplates, getGovernanceTemplate, getGovernanceTemplateNames, getGovernanceTemplatesByCategory, getMigrationTemplate, getMigrationTemplateNames, getMigrationTemplatesByCategory, isInsideComment, isInsideStringLiteral, loadConfig, mutuallyExclusive, parseCallChain, requireIf, requireOneOf, shouldSuppressWarning, startsWithBase, suggestCrossFieldPattern, transformMethodChain, validateConfig, validateMigrationTemplate };
|
package/dist/index.d.ts
CHANGED
|
@@ -108,6 +108,7 @@ declare class ApprovalManager {
|
|
|
108
108
|
* Check if a migration has been approved.
|
|
109
109
|
*/
|
|
110
110
|
isApproved(requestId: string): boolean;
|
|
111
|
+
private isValidRequest;
|
|
111
112
|
private ensureDir;
|
|
112
113
|
}
|
|
113
114
|
|
|
@@ -297,7 +298,14 @@ declare class MigrationAuditLog {
|
|
|
297
298
|
* Clear the audit log.
|
|
298
299
|
*/
|
|
299
300
|
clear(): void;
|
|
301
|
+
/**
|
|
302
|
+
* Export a compliance report in SOC2 or HIPAA format.
|
|
303
|
+
*/
|
|
304
|
+
exportComplianceReport(format: 'soc2' | 'hipaa'): string;
|
|
305
|
+
private generateSoc2Report;
|
|
306
|
+
private generateHipaaReport;
|
|
300
307
|
private collectMetadata;
|
|
308
|
+
private isValidAuditLog;
|
|
301
309
|
private write;
|
|
302
310
|
private hashContent;
|
|
303
311
|
private getCurrentUser;
|
|
@@ -457,8 +465,13 @@ interface ComplexityEstimate {
|
|
|
457
465
|
warnings: ComplexityWarning[];
|
|
458
466
|
riskAreas: string[];
|
|
459
467
|
}
|
|
468
|
+
interface DurationEstimate {
|
|
469
|
+
label: string;
|
|
470
|
+
rangeMinutes: [number, number];
|
|
471
|
+
}
|
|
460
472
|
declare class ComplexityEstimator {
|
|
461
473
|
estimate(files: SourceFile[]): ComplexityEstimate;
|
|
474
|
+
estimateDuration(estimate: ComplexityEstimate): DurationEstimate;
|
|
462
475
|
private calculateEffort;
|
|
463
476
|
}
|
|
464
477
|
|
|
@@ -519,6 +532,28 @@ declare function validateConfig(config: SchemaShiftConfig): {
|
|
|
519
532
|
declare function shouldSuppressWarning(warning: string, filePath: string, rules: WarningSuppressionRule[]): boolean;
|
|
520
533
|
declare function loadConfig(configPath?: string): Promise<SchemaShiftConfig>;
|
|
521
534
|
|
|
535
|
+
/**
|
|
536
|
+
* Centralized constants for SchemaShift paths and defaults.
|
|
537
|
+
*/
|
|
538
|
+
/** Directory for SchemaShift state files (.schemashift/) */
|
|
539
|
+
declare const SCHEMASHIFT_DIR = ".schemashift";
|
|
540
|
+
/** Default backup directory name */
|
|
541
|
+
declare const BACKUP_DIR = ".schemashift-backup";
|
|
542
|
+
/** Config file search names (cosmiconfig) */
|
|
543
|
+
declare const CONFIG_FILE_NAMES: readonly [".schemashiftrc", ".schemashiftrc.json", ".schemashiftrc.yaml", ".schemashiftrc.yml", ".schemashiftrc.js", ".schemashiftrc.cjs"];
|
|
544
|
+
/** Default config file name for init command */
|
|
545
|
+
declare const DEFAULT_CONFIG_FILE = ".schemashiftrc.json";
|
|
546
|
+
/** Incremental state file name (inside SCHEMASHIFT_DIR) */
|
|
547
|
+
declare const INCREMENTAL_STATE_FILE = "incremental.json";
|
|
548
|
+
/** Audit log file name (inside SCHEMASHIFT_DIR) */
|
|
549
|
+
declare const AUDIT_LOG_FILE = "audit-log.json";
|
|
550
|
+
/** Schema snapshot file name (inside SCHEMASHIFT_DIR) */
|
|
551
|
+
declare const SCHEMA_SNAPSHOT_FILE = "schema-snapshot.json";
|
|
552
|
+
/** Pending approvals subdirectory (inside SCHEMASHIFT_DIR) */
|
|
553
|
+
declare const PENDING_DIR = "pending";
|
|
554
|
+
/** Test scaffolding output subdirectory (inside SCHEMASHIFT_DIR) */
|
|
555
|
+
declare const TESTS_DIR = "tests";
|
|
556
|
+
|
|
522
557
|
/**
|
|
523
558
|
* Cross-Field Validation Pattern Helpers
|
|
524
559
|
*
|
|
@@ -559,6 +594,28 @@ declare function conditionalValidation(conditionField: string, conditionValue: s
|
|
|
559
594
|
*/
|
|
560
595
|
declare function suggestCrossFieldPattern(whenCode: string): CrossFieldPattern | null;
|
|
561
596
|
|
|
597
|
+
interface UnusedSchema {
|
|
598
|
+
schemaName: string;
|
|
599
|
+
filePath: string;
|
|
600
|
+
lineNumber: number;
|
|
601
|
+
}
|
|
602
|
+
interface DeadSchemaResult {
|
|
603
|
+
unusedSchemas: UnusedSchema[];
|
|
604
|
+
totalSchemas: number;
|
|
605
|
+
summary: string;
|
|
606
|
+
}
|
|
607
|
+
/**
|
|
608
|
+
* Detects schema definitions that are never referenced elsewhere in the codebase.
|
|
609
|
+
*
|
|
610
|
+
* Scans for variable declarations that use schema library patterns (z., yup., Joi., etc.)
|
|
611
|
+
* and checks if those variables are referenced in other files.
|
|
612
|
+
*/
|
|
613
|
+
declare class DeadSchemaDetector {
|
|
614
|
+
detect(sourceFiles: SourceFile[]): DeadSchemaResult;
|
|
615
|
+
private collectSchemaDefinitions;
|
|
616
|
+
private findUnusedSchemas;
|
|
617
|
+
}
|
|
618
|
+
|
|
562
619
|
interface DependencyGraphResult {
|
|
563
620
|
/** Files sorted in dependency order (dependencies first) */
|
|
564
621
|
sortedFiles: string[];
|
|
@@ -789,6 +846,7 @@ declare class GovernanceEngine {
|
|
|
789
846
|
*/
|
|
790
847
|
registerRule(name: string, fn: GovernanceRuleFunction): void;
|
|
791
848
|
analyze(project: Project): GovernanceResult;
|
|
849
|
+
private safeRegExp;
|
|
792
850
|
private detectFileLibrary;
|
|
793
851
|
private measureNestingDepth;
|
|
794
852
|
private detectDynamicSchemas;
|
|
@@ -911,6 +969,34 @@ declare class GraphExporter {
|
|
|
911
969
|
private toMermaidId;
|
|
912
970
|
}
|
|
913
971
|
|
|
972
|
+
interface DuplicateImport {
|
|
973
|
+
source: string;
|
|
974
|
+
filePath: string;
|
|
975
|
+
lineNumber: number;
|
|
976
|
+
importedNames: string[];
|
|
977
|
+
}
|
|
978
|
+
interface DuplicateImportGroup {
|
|
979
|
+
source: string;
|
|
980
|
+
occurrences: DuplicateImport[];
|
|
981
|
+
suggestion: string;
|
|
982
|
+
}
|
|
983
|
+
interface ImportDeduplicationResult {
|
|
984
|
+
duplicateGroups: DuplicateImportGroup[];
|
|
985
|
+
totalDuplicates: number;
|
|
986
|
+
summary: string;
|
|
987
|
+
}
|
|
988
|
+
/**
|
|
989
|
+
* Detects duplicate import declarations within individual files.
|
|
990
|
+
*
|
|
991
|
+
* After migration, files may end up with multiple import statements from the
|
|
992
|
+
* same module (e.g., two `import { ... } from 'zod'` lines). This detector
|
|
993
|
+
* identifies those cases and suggests merging them.
|
|
994
|
+
*/
|
|
995
|
+
declare class ImportDeduplicator {
|
|
996
|
+
detect(sourceFiles: SourceFile[]): ImportDeduplicationResult;
|
|
997
|
+
private findDuplicatesInFile;
|
|
998
|
+
}
|
|
999
|
+
|
|
914
1000
|
interface IncrementalState {
|
|
915
1001
|
migrationId: string;
|
|
916
1002
|
from: SchemaLibrary;
|
|
@@ -937,7 +1023,13 @@ declare class IncrementalTracker {
|
|
|
937
1023
|
total: number;
|
|
938
1024
|
percent: number;
|
|
939
1025
|
} | null;
|
|
1026
|
+
/**
|
|
1027
|
+
* Get a canary batch — a percentage of remaining files, sorted simplest first.
|
|
1028
|
+
* Used for phased rollouts where you migrate a small batch, verify, then continue.
|
|
1029
|
+
*/
|
|
1030
|
+
getCanaryBatch(percent: number, fileSizes?: Map<string, number>): string[];
|
|
940
1031
|
clear(): void;
|
|
1032
|
+
private isValidState;
|
|
941
1033
|
private saveState;
|
|
942
1034
|
}
|
|
943
1035
|
|
|
@@ -1012,11 +1104,14 @@ interface NotificationResult {
|
|
|
1012
1104
|
statusCode?: number;
|
|
1013
1105
|
error?: string;
|
|
1014
1106
|
}
|
|
1107
|
+
type WebhookType = 'generic' | 'slack' | 'teams';
|
|
1015
1108
|
interface WebhookConfig {
|
|
1016
1109
|
url: string;
|
|
1017
1110
|
events?: MigrationEventType[];
|
|
1018
1111
|
headers?: Record<string, string>;
|
|
1019
1112
|
secret?: string;
|
|
1113
|
+
type?: WebhookType;
|
|
1114
|
+
timeoutMs?: number;
|
|
1020
1115
|
}
|
|
1021
1116
|
/**
|
|
1022
1117
|
* Send migration event notifications via webhooks.
|
|
@@ -1032,6 +1127,16 @@ declare class WebhookNotifier {
|
|
|
1032
1127
|
* Send an event to all matching webhooks.
|
|
1033
1128
|
*/
|
|
1034
1129
|
send(event: MigrationEvent): Promise<NotificationResult[]>;
|
|
1130
|
+
/**
|
|
1131
|
+
* Format event as Slack Block Kit message.
|
|
1132
|
+
*/
|
|
1133
|
+
formatSlackPayload(event: MigrationEvent): Record<string, unknown>;
|
|
1134
|
+
/**
|
|
1135
|
+
* Format event as Microsoft Teams Adaptive Card.
|
|
1136
|
+
*/
|
|
1137
|
+
formatTeamsPayload(event: MigrationEvent): Record<string, unknown>;
|
|
1138
|
+
private getEventEmoji;
|
|
1139
|
+
private getEventTitle;
|
|
1035
1140
|
/**
|
|
1036
1141
|
* Send event to a single webhook endpoint.
|
|
1037
1142
|
*/
|
|
@@ -1124,6 +1229,56 @@ declare class PluginLoader {
|
|
|
1124
1229
|
private validatePlugin;
|
|
1125
1230
|
}
|
|
1126
1231
|
|
|
1232
|
+
interface VerificationSample {
|
|
1233
|
+
name: string;
|
|
1234
|
+
input: unknown;
|
|
1235
|
+
expectedValid: boolean;
|
|
1236
|
+
}
|
|
1237
|
+
interface SchemaVerificationResult {
|
|
1238
|
+
schemaName: string;
|
|
1239
|
+
filePath: string;
|
|
1240
|
+
totalSamples: number;
|
|
1241
|
+
matchingSamples: number;
|
|
1242
|
+
mismatches: VerificationMismatch[];
|
|
1243
|
+
parityScore: number;
|
|
1244
|
+
}
|
|
1245
|
+
interface VerificationMismatch {
|
|
1246
|
+
sampleName: string;
|
|
1247
|
+
input: unknown;
|
|
1248
|
+
sourceResult: {
|
|
1249
|
+
valid: boolean;
|
|
1250
|
+
error?: string;
|
|
1251
|
+
};
|
|
1252
|
+
targetResult: {
|
|
1253
|
+
valid: boolean;
|
|
1254
|
+
error?: string;
|
|
1255
|
+
};
|
|
1256
|
+
}
|
|
1257
|
+
interface VerificationReport {
|
|
1258
|
+
from: string;
|
|
1259
|
+
to: string;
|
|
1260
|
+
totalSchemas: number;
|
|
1261
|
+
results: SchemaVerificationResult[];
|
|
1262
|
+
overallParityScore: number;
|
|
1263
|
+
timestamp: string;
|
|
1264
|
+
}
|
|
1265
|
+
/**
|
|
1266
|
+
* Extracts schema definition names from source file text.
|
|
1267
|
+
*/
|
|
1268
|
+
declare function extractSchemaNames(sourceText: string): string[];
|
|
1269
|
+
/**
|
|
1270
|
+
* Generates test samples based on detected schema patterns.
|
|
1271
|
+
*/
|
|
1272
|
+
declare function generateSamples(sourceText: string, schemaName: string, maxSamples: number): VerificationSample[];
|
|
1273
|
+
/**
|
|
1274
|
+
* Creates a verification report comparing source and target schemas.
|
|
1275
|
+
*/
|
|
1276
|
+
declare function createVerificationReport(from: string, to: string, results: SchemaVerificationResult[]): VerificationReport;
|
|
1277
|
+
/**
|
|
1278
|
+
* Format verification report for terminal output.
|
|
1279
|
+
*/
|
|
1280
|
+
declare function formatVerificationReport(report: VerificationReport): string;
|
|
1281
|
+
|
|
1127
1282
|
interface StandardSchemaInfo {
|
|
1128
1283
|
detected: boolean;
|
|
1129
1284
|
compatibleLibraries: Array<{
|
|
@@ -1228,4 +1383,4 @@ declare class TypeDedupDetector {
|
|
|
1228
1383
|
private namesRelated;
|
|
1229
1384
|
}
|
|
1230
1385
|
|
|
1231
|
-
export { type AnalysisResult, type ApprovalDecision, ApprovalManager, type ApprovalStatus, type ApprovalSummary, type AuditEntry, type AuditEntryMetadata, type AuditLog, type BehavioralAnalysisResult, type BehavioralCategory, type BehavioralWarning, BehavioralWarningAnalyzer, BundleEstimator, type BundleSizeEstimate, type CallChainInfo, type ChainResult, type ChainStep, type ChainStepResult, type ChainValidation, CompatibilityAnalyzer, type CompatibilityResult, type ComplexityEstimate, ComplexityEstimator, type ComplexityWarning, type CrossFieldPattern, type CustomRule, type DependencyGraphResult, type DetailedAnalysisResult, DetailedAnalyzer, DriftDetector, type DriftModification, type DriftResult, type DuplicateTypeCandidate, EcosystemAnalyzer, type EcosystemIssue, type EcosystemReport, type EffortLevel, type FileComplexity, type FixResult, type FixSummary, type FormLibraryDetection, FormResolverMigrator, type FormResolverResult, GOVERNANCE_TEMPLATES, GovernanceEngine, GovernanceFixer, type GovernanceResult, type GovernanceRuleConfig, type GovernanceRuleFunction, type GovernanceTemplate, type GovernanceViolation, type GraphExportOptions, GraphExporter, type GraphNode, type IncrementalState, IncrementalTracker, type LibraryBundleInfo, type LibraryVersionInfo, type MethodCallInfo, MigrationAuditLog, MigrationChain, type MigrationEvent, type MigrationEventType, type MigrationReadiness, type MigrationRequest, type MigrationTemplate, type MigrationTemplateStep, type MonorepoInfo, type MonorepoPackage, MonorepoResolver, type NotificationResult, type PackageChange, type PackageUpdatePlan, PackageUpdater, type ParallelBatch, type PerformanceAnalysisResult, PerformanceAnalyzer, type PerformanceCategory, type PerformanceWarning, type PluginLoadResult, PluginLoader, type ScaffoldedTest, SchemaAnalyzer, type SchemaComplexity, SchemaDependencyResolver, type SchemaFileSnapshot, type SchemaInfo, type SchemaLibrary, type SchemaShiftConfig, type SchemaShiftPlugin, type SchemaSnapshot, StandardSchemaAdvisor, type StandardSchemaAdvisory, type StandardSchemaInfo, type TestScaffoldResult, TestScaffolder, TransformEngine, type TransformError, type TransformHandler, type TransformOptions, type TransformResult, TypeDedupDetector, type TypeDedupResult, type VersionIssue, type WarningSuppressionRule, type WebhookConfig, WebhookNotifier, type WorkspaceManager, buildCallChain, computeParallelBatches, conditionalValidation, dependentFields, detectFormLibraries, detectSchemaLibrary, detectStandardSchema, getAllMigrationTemplates, getGovernanceTemplate, getGovernanceTemplateNames, getGovernanceTemplatesByCategory, getMigrationTemplate, getMigrationTemplateNames, getMigrationTemplatesByCategory, isInsideComment, isInsideStringLiteral, loadConfig, mutuallyExclusive, parseCallChain, requireIf, requireOneOf, shouldSuppressWarning, startsWithBase, suggestCrossFieldPattern, transformMethodChain, validateConfig, validateMigrationTemplate };
|
|
1386
|
+
export { AUDIT_LOG_FILE, type AnalysisResult, type ApprovalDecision, ApprovalManager, type ApprovalStatus, type ApprovalSummary, type AuditEntry, type AuditEntryMetadata, type AuditLog, BACKUP_DIR, type BehavioralAnalysisResult, type BehavioralCategory, type BehavioralWarning, BehavioralWarningAnalyzer, BundleEstimator, type BundleSizeEstimate, CONFIG_FILE_NAMES, type CallChainInfo, type ChainResult, type ChainStep, type ChainStepResult, type ChainValidation, CompatibilityAnalyzer, type CompatibilityResult, type ComplexityEstimate, ComplexityEstimator, type ComplexityWarning, type CrossFieldPattern, type CustomRule, DEFAULT_CONFIG_FILE, DeadSchemaDetector, type DeadSchemaResult, type DependencyGraphResult, type DetailedAnalysisResult, DetailedAnalyzer, DriftDetector, type DriftModification, type DriftResult, type DuplicateImport, type DuplicateImportGroup, type DuplicateTypeCandidate, type DurationEstimate, EcosystemAnalyzer, type EcosystemIssue, type EcosystemReport, type EffortLevel, type FileComplexity, type FixResult, type FixSummary, type FormLibraryDetection, FormResolverMigrator, type FormResolverResult, GOVERNANCE_TEMPLATES, GovernanceEngine, GovernanceFixer, type GovernanceResult, type GovernanceRuleConfig, type GovernanceRuleFunction, type GovernanceTemplate, type GovernanceViolation, type GraphExportOptions, GraphExporter, type GraphNode, INCREMENTAL_STATE_FILE, type ImportDeduplicationResult, ImportDeduplicator, type IncrementalState, IncrementalTracker, type LibraryBundleInfo, type LibraryVersionInfo, type MethodCallInfo, MigrationAuditLog, MigrationChain, type MigrationEvent, type MigrationEventType, type MigrationReadiness, type MigrationRequest, type MigrationTemplate, type MigrationTemplateStep, type MonorepoInfo, type MonorepoPackage, MonorepoResolver, type NotificationResult, PENDING_DIR, type PackageChange, type PackageUpdatePlan, PackageUpdater, type ParallelBatch, type PerformanceAnalysisResult, PerformanceAnalyzer, type PerformanceCategory, type PerformanceWarning, type PluginLoadResult, PluginLoader, SCHEMASHIFT_DIR, SCHEMA_SNAPSHOT_FILE, type ScaffoldedTest, SchemaAnalyzer, type SchemaComplexity, SchemaDependencyResolver, type SchemaFileSnapshot, type SchemaInfo, type SchemaLibrary, type SchemaShiftConfig, type SchemaShiftPlugin, type SchemaSnapshot, type SchemaVerificationResult, StandardSchemaAdvisor, type StandardSchemaAdvisory, type StandardSchemaInfo, TESTS_DIR, type TestScaffoldResult, TestScaffolder, TransformEngine, type TransformError, type TransformHandler, type TransformOptions, type TransformResult, TypeDedupDetector, type TypeDedupResult, type UnusedSchema, type VerificationMismatch, type VerificationReport, type VerificationSample, type VersionIssue, type WarningSuppressionRule, type WebhookConfig, WebhookNotifier, type WebhookType, type WorkspaceManager, buildCallChain, computeParallelBatches, conditionalValidation, createVerificationReport, dependentFields, detectFormLibraries, detectSchemaLibrary, detectStandardSchema, extractSchemaNames, formatVerificationReport, generateSamples, getAllMigrationTemplates, getGovernanceTemplate, getGovernanceTemplateNames, getGovernanceTemplatesByCategory, getMigrationTemplate, getMigrationTemplateNames, getMigrationTemplatesByCategory, isInsideComment, isInsideStringLiteral, loadConfig, mutuallyExclusive, parseCallChain, requireIf, requireOneOf, shouldSuppressWarning, startsWithBase, suggestCrossFieldPattern, transformMethodChain, validateConfig, validateMigrationTemplate };
|