@schemashift/core 0.9.0 → 0.10.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.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Project, CallExpression, Node, SourceFile } from 'ts-morph';
2
2
 
3
- type SchemaLibrary = 'zod' | 'zod-v3' | 'yup' | 'joi' | 'io-ts' | 'valibot' | 'v4' | 'unknown';
3
+ type SchemaLibrary = 'zod' | 'zod-v3' | 'yup' | 'joi' | 'io-ts' | 'valibot' | 'arktype' | 'superstruct' | 'effect' | 'v4' | 'unknown';
4
4
  interface SchemaInfo {
5
5
  name: string;
6
6
  filePath: string;
@@ -143,6 +143,15 @@ declare function transformMethodChain(chain: CallChainInfo, newBase: string, fac
143
143
  args: string[];
144
144
  }[] | null | undefined): string;
145
145
 
146
+ interface AuditEntryMetadata {
147
+ gitCommit?: string;
148
+ gitBranch?: string;
149
+ ciJobId?: string;
150
+ ciProvider?: string;
151
+ hostname?: string;
152
+ nodeVersion?: string;
153
+ schemashiftVersion?: string;
154
+ }
146
155
  interface AuditEntry {
147
156
  timestamp: string;
148
157
  migrationId: string;
@@ -158,6 +167,7 @@ interface AuditEntry {
158
167
  riskScore?: number;
159
168
  user?: string;
160
169
  duration?: number;
170
+ metadata?: AuditEntryMetadata;
161
171
  }
162
172
  interface AuditLog {
163
173
  version: number;
@@ -186,6 +196,7 @@ declare class MigrationAuditLog {
186
196
  errorCount: number;
187
197
  riskScore?: number;
188
198
  duration?: number;
199
+ metadata?: AuditEntryMetadata;
189
200
  }): AuditEntry;
190
201
  /**
191
202
  * Read the current audit log.
@@ -205,10 +216,23 @@ declare class MigrationAuditLog {
205
216
  failureCount: number;
206
217
  migrationPaths: string[];
207
218
  };
219
+ /**
220
+ * Export audit log as JSON string.
221
+ */
222
+ exportJson(): string;
223
+ /**
224
+ * Export audit log as CSV string.
225
+ */
226
+ exportCsv(): string;
227
+ /**
228
+ * Get entries filtered by date range.
229
+ */
230
+ getByDateRange(start: Date, end: Date): AuditEntry[];
208
231
  /**
209
232
  * Clear the audit log.
210
233
  */
211
234
  clear(): void;
235
+ private collectMetadata;
212
236
  private write;
213
237
  private hashContent;
214
238
  private getCurrentUser;
@@ -558,6 +582,67 @@ interface FormLibraryDetection {
558
582
  }
559
583
  declare function detectFormLibraries(sourceFile: SourceFile): FormLibraryDetection[];
560
584
 
585
+ interface SchemaSnapshot {
586
+ version: number;
587
+ timestamp: string;
588
+ projectPath: string;
589
+ schemas: SchemaFileSnapshot[];
590
+ }
591
+ interface SchemaFileSnapshot {
592
+ filePath: string;
593
+ library: string;
594
+ contentHash: string;
595
+ schemaCount: number;
596
+ schemaNames: string[];
597
+ }
598
+ interface DriftResult {
599
+ hasDrift: boolean;
600
+ added: SchemaFileSnapshot[];
601
+ removed: SchemaFileSnapshot[];
602
+ modified: DriftModification[];
603
+ unchanged: number;
604
+ totalFiles: number;
605
+ snapshotTimestamp: string;
606
+ }
607
+ interface DriftModification {
608
+ filePath: string;
609
+ library: string;
610
+ previousHash: string;
611
+ currentHash: string;
612
+ previousSchemaCount: number;
613
+ currentSchemaCount: number;
614
+ addedSchemas: string[];
615
+ removedSchemas: string[];
616
+ }
617
+ declare class DriftDetector {
618
+ private snapshotDir;
619
+ private snapshotPath;
620
+ constructor(projectPath: string);
621
+ /**
622
+ * Take a snapshot of the current schema state
623
+ */
624
+ snapshot(files: string[], projectPath: string): SchemaSnapshot;
625
+ /**
626
+ * Save a snapshot to disk
627
+ */
628
+ saveSnapshot(snapshot: SchemaSnapshot): void;
629
+ /**
630
+ * Load saved snapshot from disk
631
+ */
632
+ loadSnapshot(): SchemaSnapshot | null;
633
+ /**
634
+ * Compare current state against saved snapshot
635
+ */
636
+ detect(currentFiles: string[], projectPath: string): DriftResult;
637
+ /**
638
+ * Compare two snapshots and return drift results
639
+ */
640
+ compareSnapshots(baseline: SchemaSnapshot, current: SchemaSnapshot): DriftResult;
641
+ private extractSchemaNames;
642
+ private detectLibraryFromContent;
643
+ private hashContent;
644
+ }
645
+
561
646
  interface FormResolverResult {
562
647
  success: boolean;
563
648
  transformedCode: string;
@@ -606,6 +691,41 @@ declare class GovernanceEngine {
606
691
  private isSchemaExpression;
607
692
  }
608
693
 
694
+ /**
695
+ * Governance Rule Templates
696
+ *
697
+ * Pre-built governance rules for common enterprise policies.
698
+ * These can be registered into the GovernanceEngine for quick setup.
699
+ *
700
+ * Template categories:
701
+ * - Security: Prevent unsafe patterns (XSS, injection, DoS)
702
+ * - Quality: Enforce code quality standards
703
+ * - Compliance: Support SOX, HIPAA, GDPR requirements
704
+ * - Performance: Prevent known performance pitfalls
705
+ */
706
+ interface GovernanceTemplate {
707
+ name: string;
708
+ description: string;
709
+ category: 'security' | 'quality' | 'compliance' | 'performance';
710
+ rule: GovernanceRuleFunction;
711
+ }
712
+ /**
713
+ * All available governance rule templates
714
+ */
715
+ declare const GOVERNANCE_TEMPLATES: GovernanceTemplate[];
716
+ /**
717
+ * Get a governance template by name
718
+ */
719
+ declare function getGovernanceTemplate(name: string): GovernanceTemplate | undefined;
720
+ /**
721
+ * Get all templates for a category
722
+ */
723
+ declare function getGovernanceTemplatesByCategory(category: GovernanceTemplate['category']): GovernanceTemplate[];
724
+ /**
725
+ * Get all available template names
726
+ */
727
+ declare function getGovernanceTemplateNames(): string[];
728
+
609
729
  interface IncrementalState {
610
730
  migrationId: string;
611
731
  from: SchemaLibrary;
@@ -774,4 +894,4 @@ declare class TypeDedupDetector {
774
894
  private namesRelated;
775
895
  }
776
896
 
777
- export { type AnalysisResult, type AuditEntry, 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 CustomRule, type DependencyGraphResult, type DetailedAnalysisResult, DetailedAnalyzer, type DuplicateTypeCandidate, EcosystemAnalyzer, type EcosystemIssue, type EcosystemReport, type EffortLevel, type FileComplexity, type FormLibraryDetection, FormResolverMigrator, type FormResolverResult, GovernanceEngine, type GovernanceResult, type GovernanceRuleConfig, type GovernanceRuleFunction, type GovernanceViolation, type IncrementalState, IncrementalTracker, type LibraryBundleInfo, type LibraryVersionInfo, type MethodCallInfo, MigrationAuditLog, MigrationChain, type MigrationReadiness, type MonorepoInfo, type MonorepoPackage, MonorepoResolver, type PackageUpdatePlan, PackageUpdater, type ParallelBatch, type PerformanceAnalysisResult, PerformanceAnalyzer, type PerformanceCategory, type PerformanceWarning, type PluginLoadResult, PluginLoader, type ScaffoldedTest, SchemaAnalyzer, type SchemaComplexity, SchemaDependencyResolver, type SchemaInfo, type SchemaLibrary, type SchemaShiftConfig, type SchemaShiftPlugin, type StandardSchemaInfo, type TestScaffoldResult, TestScaffolder, TransformEngine, type TransformError, type TransformHandler, type TransformOptions, type TransformResult, TypeDedupDetector, type TypeDedupResult, type VersionIssue, type WarningSuppressionRule, type WorkspaceManager, buildCallChain, computeParallelBatches, detectFormLibraries, detectSchemaLibrary, detectStandardSchema, isInsideComment, isInsideStringLiteral, loadConfig, parseCallChain, shouldSuppressWarning, startsWithBase, transformMethodChain, validateConfig };
897
+ export { type AnalysisResult, 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 CustomRule, type DependencyGraphResult, type DetailedAnalysisResult, DetailedAnalyzer, DriftDetector, type DriftModification, type DriftResult, type DuplicateTypeCandidate, EcosystemAnalyzer, type EcosystemIssue, type EcosystemReport, type EffortLevel, type FileComplexity, type FormLibraryDetection, FormResolverMigrator, type FormResolverResult, GOVERNANCE_TEMPLATES, GovernanceEngine, type GovernanceResult, type GovernanceRuleConfig, type GovernanceRuleFunction, type GovernanceTemplate, type GovernanceViolation, type IncrementalState, IncrementalTracker, type LibraryBundleInfo, type LibraryVersionInfo, type MethodCallInfo, MigrationAuditLog, MigrationChain, type MigrationReadiness, type MonorepoInfo, type MonorepoPackage, MonorepoResolver, 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, type StandardSchemaInfo, type TestScaffoldResult, TestScaffolder, TransformEngine, type TransformError, type TransformHandler, type TransformOptions, type TransformResult, TypeDedupDetector, type TypeDedupResult, type VersionIssue, type WarningSuppressionRule, type WorkspaceManager, buildCallChain, computeParallelBatches, detectFormLibraries, detectSchemaLibrary, detectStandardSchema, getGovernanceTemplate, getGovernanceTemplateNames, getGovernanceTemplatesByCategory, isInsideComment, isInsideStringLiteral, loadConfig, parseCallChain, shouldSuppressWarning, startsWithBase, transformMethodChain, validateConfig };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Project, CallExpression, Node, SourceFile } from 'ts-morph';
2
2
 
3
- type SchemaLibrary = 'zod' | 'zod-v3' | 'yup' | 'joi' | 'io-ts' | 'valibot' | 'v4' | 'unknown';
3
+ type SchemaLibrary = 'zod' | 'zod-v3' | 'yup' | 'joi' | 'io-ts' | 'valibot' | 'arktype' | 'superstruct' | 'effect' | 'v4' | 'unknown';
4
4
  interface SchemaInfo {
5
5
  name: string;
6
6
  filePath: string;
@@ -143,6 +143,15 @@ declare function transformMethodChain(chain: CallChainInfo, newBase: string, fac
143
143
  args: string[];
144
144
  }[] | null | undefined): string;
145
145
 
146
+ interface AuditEntryMetadata {
147
+ gitCommit?: string;
148
+ gitBranch?: string;
149
+ ciJobId?: string;
150
+ ciProvider?: string;
151
+ hostname?: string;
152
+ nodeVersion?: string;
153
+ schemashiftVersion?: string;
154
+ }
146
155
  interface AuditEntry {
147
156
  timestamp: string;
148
157
  migrationId: string;
@@ -158,6 +167,7 @@ interface AuditEntry {
158
167
  riskScore?: number;
159
168
  user?: string;
160
169
  duration?: number;
170
+ metadata?: AuditEntryMetadata;
161
171
  }
162
172
  interface AuditLog {
163
173
  version: number;
@@ -186,6 +196,7 @@ declare class MigrationAuditLog {
186
196
  errorCount: number;
187
197
  riskScore?: number;
188
198
  duration?: number;
199
+ metadata?: AuditEntryMetadata;
189
200
  }): AuditEntry;
190
201
  /**
191
202
  * Read the current audit log.
@@ -205,10 +216,23 @@ declare class MigrationAuditLog {
205
216
  failureCount: number;
206
217
  migrationPaths: string[];
207
218
  };
219
+ /**
220
+ * Export audit log as JSON string.
221
+ */
222
+ exportJson(): string;
223
+ /**
224
+ * Export audit log as CSV string.
225
+ */
226
+ exportCsv(): string;
227
+ /**
228
+ * Get entries filtered by date range.
229
+ */
230
+ getByDateRange(start: Date, end: Date): AuditEntry[];
208
231
  /**
209
232
  * Clear the audit log.
210
233
  */
211
234
  clear(): void;
235
+ private collectMetadata;
212
236
  private write;
213
237
  private hashContent;
214
238
  private getCurrentUser;
@@ -558,6 +582,67 @@ interface FormLibraryDetection {
558
582
  }
559
583
  declare function detectFormLibraries(sourceFile: SourceFile): FormLibraryDetection[];
560
584
 
585
+ interface SchemaSnapshot {
586
+ version: number;
587
+ timestamp: string;
588
+ projectPath: string;
589
+ schemas: SchemaFileSnapshot[];
590
+ }
591
+ interface SchemaFileSnapshot {
592
+ filePath: string;
593
+ library: string;
594
+ contentHash: string;
595
+ schemaCount: number;
596
+ schemaNames: string[];
597
+ }
598
+ interface DriftResult {
599
+ hasDrift: boolean;
600
+ added: SchemaFileSnapshot[];
601
+ removed: SchemaFileSnapshot[];
602
+ modified: DriftModification[];
603
+ unchanged: number;
604
+ totalFiles: number;
605
+ snapshotTimestamp: string;
606
+ }
607
+ interface DriftModification {
608
+ filePath: string;
609
+ library: string;
610
+ previousHash: string;
611
+ currentHash: string;
612
+ previousSchemaCount: number;
613
+ currentSchemaCount: number;
614
+ addedSchemas: string[];
615
+ removedSchemas: string[];
616
+ }
617
+ declare class DriftDetector {
618
+ private snapshotDir;
619
+ private snapshotPath;
620
+ constructor(projectPath: string);
621
+ /**
622
+ * Take a snapshot of the current schema state
623
+ */
624
+ snapshot(files: string[], projectPath: string): SchemaSnapshot;
625
+ /**
626
+ * Save a snapshot to disk
627
+ */
628
+ saveSnapshot(snapshot: SchemaSnapshot): void;
629
+ /**
630
+ * Load saved snapshot from disk
631
+ */
632
+ loadSnapshot(): SchemaSnapshot | null;
633
+ /**
634
+ * Compare current state against saved snapshot
635
+ */
636
+ detect(currentFiles: string[], projectPath: string): DriftResult;
637
+ /**
638
+ * Compare two snapshots and return drift results
639
+ */
640
+ compareSnapshots(baseline: SchemaSnapshot, current: SchemaSnapshot): DriftResult;
641
+ private extractSchemaNames;
642
+ private detectLibraryFromContent;
643
+ private hashContent;
644
+ }
645
+
561
646
  interface FormResolverResult {
562
647
  success: boolean;
563
648
  transformedCode: string;
@@ -606,6 +691,41 @@ declare class GovernanceEngine {
606
691
  private isSchemaExpression;
607
692
  }
608
693
 
694
+ /**
695
+ * Governance Rule Templates
696
+ *
697
+ * Pre-built governance rules for common enterprise policies.
698
+ * These can be registered into the GovernanceEngine for quick setup.
699
+ *
700
+ * Template categories:
701
+ * - Security: Prevent unsafe patterns (XSS, injection, DoS)
702
+ * - Quality: Enforce code quality standards
703
+ * - Compliance: Support SOX, HIPAA, GDPR requirements
704
+ * - Performance: Prevent known performance pitfalls
705
+ */
706
+ interface GovernanceTemplate {
707
+ name: string;
708
+ description: string;
709
+ category: 'security' | 'quality' | 'compliance' | 'performance';
710
+ rule: GovernanceRuleFunction;
711
+ }
712
+ /**
713
+ * All available governance rule templates
714
+ */
715
+ declare const GOVERNANCE_TEMPLATES: GovernanceTemplate[];
716
+ /**
717
+ * Get a governance template by name
718
+ */
719
+ declare function getGovernanceTemplate(name: string): GovernanceTemplate | undefined;
720
+ /**
721
+ * Get all templates for a category
722
+ */
723
+ declare function getGovernanceTemplatesByCategory(category: GovernanceTemplate['category']): GovernanceTemplate[];
724
+ /**
725
+ * Get all available template names
726
+ */
727
+ declare function getGovernanceTemplateNames(): string[];
728
+
609
729
  interface IncrementalState {
610
730
  migrationId: string;
611
731
  from: SchemaLibrary;
@@ -774,4 +894,4 @@ declare class TypeDedupDetector {
774
894
  private namesRelated;
775
895
  }
776
896
 
777
- export { type AnalysisResult, type AuditEntry, 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 CustomRule, type DependencyGraphResult, type DetailedAnalysisResult, DetailedAnalyzer, type DuplicateTypeCandidate, EcosystemAnalyzer, type EcosystemIssue, type EcosystemReport, type EffortLevel, type FileComplexity, type FormLibraryDetection, FormResolverMigrator, type FormResolverResult, GovernanceEngine, type GovernanceResult, type GovernanceRuleConfig, type GovernanceRuleFunction, type GovernanceViolation, type IncrementalState, IncrementalTracker, type LibraryBundleInfo, type LibraryVersionInfo, type MethodCallInfo, MigrationAuditLog, MigrationChain, type MigrationReadiness, type MonorepoInfo, type MonorepoPackage, MonorepoResolver, type PackageUpdatePlan, PackageUpdater, type ParallelBatch, type PerformanceAnalysisResult, PerformanceAnalyzer, type PerformanceCategory, type PerformanceWarning, type PluginLoadResult, PluginLoader, type ScaffoldedTest, SchemaAnalyzer, type SchemaComplexity, SchemaDependencyResolver, type SchemaInfo, type SchemaLibrary, type SchemaShiftConfig, type SchemaShiftPlugin, type StandardSchemaInfo, type TestScaffoldResult, TestScaffolder, TransformEngine, type TransformError, type TransformHandler, type TransformOptions, type TransformResult, TypeDedupDetector, type TypeDedupResult, type VersionIssue, type WarningSuppressionRule, type WorkspaceManager, buildCallChain, computeParallelBatches, detectFormLibraries, detectSchemaLibrary, detectStandardSchema, isInsideComment, isInsideStringLiteral, loadConfig, parseCallChain, shouldSuppressWarning, startsWithBase, transformMethodChain, validateConfig };
897
+ export { type AnalysisResult, 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 CustomRule, type DependencyGraphResult, type DetailedAnalysisResult, DetailedAnalyzer, DriftDetector, type DriftModification, type DriftResult, type DuplicateTypeCandidate, EcosystemAnalyzer, type EcosystemIssue, type EcosystemReport, type EffortLevel, type FileComplexity, type FormLibraryDetection, FormResolverMigrator, type FormResolverResult, GOVERNANCE_TEMPLATES, GovernanceEngine, type GovernanceResult, type GovernanceRuleConfig, type GovernanceRuleFunction, type GovernanceTemplate, type GovernanceViolation, type IncrementalState, IncrementalTracker, type LibraryBundleInfo, type LibraryVersionInfo, type MethodCallInfo, MigrationAuditLog, MigrationChain, type MigrationReadiness, type MonorepoInfo, type MonorepoPackage, MonorepoResolver, 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, type StandardSchemaInfo, type TestScaffoldResult, TestScaffolder, TransformEngine, type TransformError, type TransformHandler, type TransformOptions, type TransformResult, TypeDedupDetector, type TypeDedupResult, type VersionIssue, type WarningSuppressionRule, type WorkspaceManager, buildCallChain, computeParallelBatches, detectFormLibraries, detectSchemaLibrary, detectStandardSchema, getGovernanceTemplate, getGovernanceTemplateNames, getGovernanceTemplatesByCategory, isInsideComment, isInsideStringLiteral, loadConfig, parseCallChain, shouldSuppressWarning, startsWithBase, transformMethodChain, validateConfig };