UNPKG

@gftdcojp/gftd-cli

Version:

GFTD Schema Management CLI - Drizzle-like schema management for Kafka and ksqlDB

315 lines 8.01 kB
/** * GFTD CLI Types - Category-theoretic Schema Management */ export type Morphism<A, B> = (a: A) => B; export type Functor<F> = <A, B>(f: Morphism<A, B>) => Morphism<F, B>; export interface ConnectionCredentials { endpoint: string; credentials: [string, string]; } export interface Connections { kafka: ConnectionCredentials; ksqldb: ConnectionCredentials; } export interface TopicObject { partitions: number; replication: number; config: Record<string, string | number>; } export interface StreamMorphism { source?: TopicObject; format: [string] | [string, string]; schema: Record<string, string>; } export interface TableMorphism { source: string; aggregation: string; } export interface GftdUnifiedConfig { org: string; project?: string; connections: Connections; schema: { version: string; topics: Record<string, TopicObject>; streams: Record<string, StreamMorphism>; tables: Record<string, TableMorphism>; }; naming: { topic: string; stream: string; table: string; }; migration: { strategy: 'colimit' | 'limit' | 'sequential'; output: string; dependency_order: string[]; }; } export interface GftdConfig { schema: string; tables: Record<string, TableConfig>; migrations?: MigrationConfig; database?: DatabaseConfig; categorical?: CategoricalConfig; orgId?: string; project?: string; schemaPath?: string; migrationPath?: string; kafka?: { endpoint: string; apiKey: string; apiSecret: string; }; ksqlDB?: { endpoint: string; apiKey: string; apiSecret: string; }; } export interface KafkaTopicConfig { name: string; partitions: number; replicationFactor: number; configEntries: Array<{ name: string; value: string; }>; } export interface KsqlStreamConfig { name: string; kafkaTopic: string; valueFormat: 'JSON' | 'AVRO' | 'PROTOBUF'; keyFormat?: 'JSON' | 'AVRO' | 'PROTOBUF' | 'KAFKA'; columns: Array<{ name: string; type: string; key?: boolean; }>; } export interface KsqlTableConfig { name: string; sourceStream?: string; kafkaTopic?: string; valueFormat?: 'JSON' | 'AVRO' | 'PROTOBUF'; keyFormat?: 'JSON' | 'AVRO' | 'PROTOBUF' | 'KAFKA'; columns?: Array<{ name: string; type: string; primaryKey?: boolean; }>; aggregation?: string; } export interface SchemaDefinition { orgId: string; project?: string; version: string; topics: Record<string, Omit<KafkaTopicConfig, 'name'>>; streams: Record<string, Omit<KsqlStreamConfig, 'name' | 'kafkaTopic'>>; tables: Record<string, Omit<KsqlTableConfig, 'name' | 'sourceStream' | 'kafkaTopic'>>; } export interface MigrationRecord { id: string; name: string; timestamp: number; applied: boolean; sql: string; type: 'TOPIC' | 'STREAM' | 'TABLE' | 'DROP'; orgId: string; } export interface TopicNaming { generateTopicName(orgId: string, topicName: string): string; generateStreamName(orgId: string, streamName: string): string; generateTableName(orgId: string, tableName: string): string; } export declare class CategoricalNaming implements TopicNaming { private templates; constructor(templates: GftdUnifiedConfig['naming']); generateTopicName(orgId: string, topicName: string): string; generateStreamName(orgId: string, streamName: string): string; generateTableName(orgId: string, tableName: string): string; } export declare class NamingConvention implements TopicNaming { generateTopicName(orgId: string, topicName: string): string; generateStreamName(orgId: string, streamName: string): string; generateTableName(orgId: string, tableName: string): string; } export declare class SchemaParser { static parseColumnType(definition: string): { name: string; type: string; key?: boolean; primaryKey?: boolean; }; static parseFormat(format: string | string[]): { valueFormat: string; keyFormat?: string; }; } export interface SchemaValidationResult { isValid: boolean; errors: string[]; warnings: string[]; } export interface InitOptions { orgId: string; project?: string; interactive?: boolean; unified?: boolean; } export interface MigrateOptions { dryRun?: boolean; force?: boolean; } export interface DevProjectConfig { id: string; name: string; path: string; port: number; subdomain: string; command: string; status: 'running' | 'stopped' | 'starting' | 'error'; pid?: number; lastAccessed?: Date; createdAt: Date; } export interface DevProxyConfig { port: number; domain: string; projects: Record<string, DevProjectConfig>; autoStart: boolean; timeout: number; dnsEnabled?: boolean; dnsAutoManage?: boolean; } export interface DevOptions { port?: number; name?: string; subdomain?: string; command?: string; path?: string; proxy?: boolean; watch?: boolean; manageDns?: boolean; skipDns?: boolean; } export interface DnsEntry { ip: string; hostname: string; comment?: string; } export interface DnsOptions { domain?: string; autoManage?: boolean; backupEnabled?: boolean; requireSudo?: boolean; } export interface DnsManagerConfig { enabled: boolean; domain: string; autoManage: boolean; backupEnabled: boolean; hostsPath: string; backupPath: string; } export interface DatabaseConfig { type: 'postgresql' | 'mysql' | 'sqlite' | 'mongodb'; host?: string; port?: number; database?: string; username?: string; password?: string; url?: string; ssl?: boolean; schema?: string; migrationsPath?: string; seedsPath?: string; } export interface MigrationConfig { path: string; tableName: string; schemaName?: string; createSchema?: boolean; } export interface TableConfig { name: string; schema?: string; columns: ColumnConfig[]; indexes?: IndexConfig[]; constraints?: ConstraintConfig[]; } export interface ColumnConfig { name: string; type: string; nullable?: boolean; primaryKey?: boolean; unique?: boolean; autoIncrement?: boolean; default?: any; references?: ReferenceConfig; } export interface IndexConfig { name: string; columns: string[]; unique?: boolean; type?: string; } export interface ConstraintConfig { name: string; type: 'primary' | 'foreign' | 'unique' | 'check'; columns: string[]; references?: ReferenceConfig; expression?: string; } export interface ReferenceConfig { table: string; column: string; onDelete?: 'CASCADE' | 'RESTRICT' | 'SET NULL' | 'NO ACTION'; onUpdate?: 'CASCADE' | 'RESTRICT' | 'SET NULL' | 'NO ACTION'; } export interface MigrationFile { version: string; name: string; up: string; down: string; timestamp: Date; checksum: string; } export interface MigrationStatus { version: string; name: string; applied: boolean; appliedAt?: Date; checksum: string; } export interface DBInitOptions { database?: string; type?: 'postgresql' | 'mysql' | 'sqlite' | 'mongodb'; force?: boolean; template?: string; } export interface MigrationOptions { name?: string; dry?: boolean; force?: boolean; target?: string; steps?: number; } export interface GenerateOptions { output?: string; watch?: boolean; declarations?: boolean; schema?: string; } export interface SchemaOptions { force?: boolean; drop?: boolean; seed?: boolean; } export interface CategoricalConfig { enabled?: boolean; categories?: string[]; defaultCategory?: string; validateCategories?: boolean; } //# sourceMappingURL=index.d.ts.map