UNPKG

wn-ts-node

Version:
1,259 lines (1,185 loc) 41.6 kB
import { Kysely } from 'kysely'; import { z } from 'zod'; /** * Shared database configuration interfaces for wn-ts ecosystem * * This provides common configuration types that both Node.js and Web implementations * can use, eliminating duplication across packages. */ /** * Base database configuration interface */ declare interface BaseDatabaseConfig { /** * Whether the database is read-only */ readonly?: boolean; /** * Whether to force recreation of the database */ forceRecreate?: boolean; /** * Whether to enable verbose logging */ verbose?: boolean; } declare abstract class BaseKyselyQueryService { protected db: Kysely<Database>; protected defaultStrategy: QueryStrategy; protected defaultOptions: QueryOptions; constructor(db: Kysely<Database>, options?: { strategy?: QueryStrategy; }); private updateDefaultOptions; private getOptionsForStrategy; getLexicons(options?: { ids?: string[]; id?: string; language?: string; version?: string; }): Promise<Lexicon[]>; getLexiconById(id: string): Promise<Lexicon | undefined>; getWords(options?: WordQuery & QueryOptions): Promise<Word[]>; getWordById(id: string): Promise<Word | undefined>; getWordsByFormFast(form: string, options?: { pos?: PartOfSpeech; lexicon?: string; maxResults?: number; }): Promise<Word[]>; getWordsByFormFuzzyFast(form: string, options?: { pos?: PartOfSpeech; lexicon?: string; maxResults?: number; }): Promise<Word[]>; getSynsets(options?: SynsetQuery & QueryOptions): Promise<Synset[]>; getSynsetsV1(options?: SynsetQuery): Promise<Synset[]>; getSynsetsV2(options?: SynsetQuery): Promise<Synset[]>; getSynsetsV3(options?: SynsetQuery): Promise<Synset[]>; getSynsetsV4(options?: SynsetQuery): Promise<Synset[]>; private queryCache; private cacheHits; private cacheMisses; getSynsetsV5(options?: SynsetQuery): Promise<Synset[]>; getSynsetsV6(options?: SynsetQuery): Promise<Synset[]>; getSynsetsFast(options?: SynsetQuery): Promise<Synset[]>; getSynsetById(id: string, options?: QueryOptions): Promise<Synset | undefined>; getSynsetsByFormFast(form: string, options?: { pos?: PartOfSpeech; lexicon?: string; maxResults?: number; } & QueryOptions): Promise<Synset[]>; getSenses(options?: SenseQuery & QueryOptions): Promise<Sense[]>; getSensesV1(options?: SenseQuery & QueryOptions): Promise<Sense[]>; getSensesV5(options?: SenseQuery & QueryOptions): Promise<Sense[]>; getSensesV6(options?: SenseQuery & QueryOptions): Promise<Sense[]>; getSenseById(id: string): Promise<Sense | undefined>; getDefinitionsBySynsetId(synsetId: string): Promise<any[]>; getIliById(id: string): Promise<ILI | undefined>; getIlis(options?: { status?: string; }): Promise<ILI[]>; getStatistics(): Promise<{ totalWords: number; totalSynsets: number; totalSenses: number; totalILIs: number; totalLexicons: number; }>; batchInsert<T extends keyof Database>(tableName: T, data: Database[T][]): Promise<void>; abstract createTables(): Promise<void>; protected transformLexiconRecord(record: any): Lexicon; protected transformWordRecord(record: Database['words']): Promise<Word>; protected transformSynsetRecordV1(record: any): Promise<Synset>; protected transformSynsetRecordV2(record: any): Promise<Synset>; protected transformSynsetRecordFast(record: any): Promise<Synset>; protected transformSynsetRecord(record: any, options?: QueryOptions): Promise<Synset>; protected transformSenseRecord(record: any): Sense; protected transformIliRecord(record: any): ILI; getWordsByLexicon(lexiconId: string): Promise<any[]>; getSensesByWordId(wordId: string): Promise<any[]>; getSynsetsByLexicon(lexiconId: string): Promise<any[]>; getExamplesBySynsetId(synsetId: string): Promise<any[]>; getSensesBySynsetId(synsetId: string): Promise<any[]>; getWordsByIds(wordIds: string[]): Promise<Word[]>; getWordsBySynsetAndLanguage(synsetId: string, language?: string): Promise<Word[]>; getWordsByIliAndLanguage(ili: string, language?: string): Promise<Word[]>; getWordsByIliAndLexiconPrefix(ili: string, lexiconPrefix: string): Promise<Word[]>; getRelationsBySynsetId(synsetId: string): Promise<any[]>; /** * Get forms for a specific word */ getFormsByWordId(wordId: string): Promise<any[]>; } declare interface CheckConstraint { name: string; condition: string; } declare interface ColumnRequirement { name: string; type: string; nullable: boolean; defaultValue?: string | number | boolean | null; autoIncrement?: boolean; unique?: boolean; } declare type ConflictResolutionStrategy = 'merge' | 'override' | 'skip' | 'manual' | 'rollback'; declare interface ConstraintRequirement { name: string; table: string; type: 'primary_key' | 'foreign_key' | 'unique' | 'check' | 'not_null'; definition: string; } /** * Shared database types for wn-ts ecosystem * * This file defines the common database schema types that both Node.js and Web * implementations can use, eliminating duplication across packages. */ declare interface Database { lexicons: LexiconTable; words: WordTable; synsets: SynsetTable; senses: SenseTable; definitions: DefinitionTable; relations: RelationTable; examples: ExampleTable; ilis: IliTable; forms: FormTable; } declare interface DataRequirement { table: string; records: Record<string, unknown>[]; condition?: string; upsert?: boolean; } declare type Definition = z.infer<typeof DefinitionSchema>; declare const DefinitionSchema: z.ZodObject<{ id: z.ZodString; language: z.ZodString; text: z.ZodString; source: z.ZodOptional<z.ZodString>; }, z.core.$strip>; declare interface DefinitionTable { id: string; synset_id: string; language: string; text: string; source?: string; } declare interface ExampleTable { id: string; synset_id?: string; sense_id?: string; language: string; text: string; source?: string; } declare interface ForeignKeyRequirement { column: string; referencedTable: string; referencedColumn: string; onDelete?: 'CASCADE' | 'SET NULL' | 'RESTRICT'; onUpdate?: 'CASCADE' | 'SET NULL' | 'RESTRICT'; } declare interface FormTable { id: string; word_id: string; written_form: string; script?: string; tag?: string; } declare interface HealthCheckResult { isHealthy: boolean; score: number; issues: HealthIssue[]; recommendations: HealthRecommendation[]; timestamp: number; } declare interface HealthIssue { id: string; type: 'missing_schema' | 'missing_data' | 'conflict' | 'performance' | 'integrity'; severity: 'low' | 'medium' | 'high' | 'critical'; title: string; description: string; affectedTables: string[]; suggestedFix: string; estimatedTime: number; } declare interface HealthRecommendation { id: string; type: 'schema' | 'data' | 'performance' | 'maintenance'; priority: 'low' | 'medium' | 'high' | 'critical'; title: string; description: string; benefits: string[]; estimatedEffort: number; implementation: string; } declare type ILI = z.infer<typeof ILISchema>; declare const ILISchema: z.ZodObject<{ id: z.ZodString; definition: z.ZodOptional<z.ZodString>; status: z.ZodEnum<{ standard: "standard"; proposed: "proposed"; deprecated: "deprecated"; }>; supersededBy: z.ZodOptional<z.ZodString>; note: z.ZodOptional<z.ZodString>; }, z.core.$strip>; declare interface IliTable { id: string; definition?: string; status: string; superseded_by?: string; note?: string; meta?: string; } declare interface IndexRequirement { name: string; table: string; columns: string[]; type: 'primary' | 'unique' | 'index' | 'fulltext'; condition?: string; } declare interface KyselyDatabase { db: Kysely<Database>; executeSchemaModification: (sql: string) => Promise<void>; getTableInfo: (tableName: string) => Promise<unknown[]>; getIndexInfo: (tableName: string) => Promise<unknown[]>; getConstraintInfo: (tableName: string) => Promise<unknown[]>; } declare class KyselyQueryService extends BaseKyselyQueryService { constructor(db: Kysely<Database>, options?: { strategy?: QueryStrategy; }); createTables(): Promise<void>; deleteLexicon(lexiconId: string): Promise<void>; deleteWordsByLexicon(lexiconId: string): Promise<void>; deleteSynsetsByLexicon(lexiconId: string): Promise<void>; } declare class KyselyWordnet extends LocalBaseWordnet { private nodeDatabase; private queryService; private strategy; constructor(lexicon?: string | string[], options?: Partial<NodeWordnetConfig>); initialize(): Promise<void>; private configureSQLite; getWord(id: string): Promise<Word | undefined>; getSynset(id: string): Promise<Synset | undefined>; synset(id: string): Promise<Synset | undefined>; getSense(id: string): Promise<Sense | undefined>; getIli(id: string): Promise<ILI | undefined>; words(query?: WordQuery): Promise<Word[]>; synsets(query?: SynsetQuery): Promise<Synset[]>; senses(query?: SenseQuery): Promise<Sense[]>; lexicons(): Promise<Lexicon[]>; getStatistics(): Promise<{ totalWords: number; totalSynsets: number; totalSenses: number; totalILIs: number; totalLexicons: number; }>; ilis(status?: string): Promise<ILI[]>; synsetsByILI(iliId: string): Promise<Synset[]>; getProjects(): Promise<Project[]>; searchWords(query: any): Promise<Word[]>; searchSynsets(query: any): Promise<Synset[]>; wordsByForm(form: string, options?: any): Promise<Word[]>; synsetsByForm(form: string, options?: any): Promise<Synset[]>; getWordForms(wordId: string): Promise<string[]>; getWordLemma(wordId: string): Promise<string>; morphy(form: string, pos?: PartOfSpeech): Promise<Record<PartOfSpeech, Set<string>>>; getDerivedWords(_wordId: string): Promise<Word[]>; getHypernyms(synsetId: string): Promise<Synset[]>; getHyponyms(synsetId: string): Promise<Synset[]>; getRelatedSynsets(synsetId: string, relationType: string): Promise<Synset[]>; getRelatedSenses(_senseId: string, _relationType: string): Promise<Sense[]>; getShortestPath(_synsetId1: string, _synsetId2: string): Promise<Synset[]>; getSynsetDepth(_synsetId: string): Promise<number>; translateWord(_wordId: string, _targetLang: string): Promise<Record<string, Word[]>>; translateSynset(synsetId: string, _targetLang: string): Promise<Synset[]>; translateSense(_senseId: string, _targetLang: string): Promise<Sense[]>; getCrossLingualSynsets(_iliId: string, _targetLangs?: string[]): Promise<Record<string, Synset[]>>; getDefinitions(synsetId: string): Promise<Definition[]>; getExamples(synsetId: string): Promise<string[]>; getSenseExamples(_senseId: string): Promise<string[]>; getSynsetWords(synsetId: string): Promise<Word[]>; getSynsetLemmas(synsetId: string): Promise<string[]>; getSynsetSenses(synsetId: string): Promise<Sense[]>; hasLexicon(lexiconId: string): Promise<boolean>; getSupportedLanguages(): Promise<string[]>; getLexiconDependencies(_lexiconId: string): Promise<string[]>; getRawDatabase(): Promise<Kysely<Database>>; executeRawQuery<T = any>(_sqlString: string, _params?: any[]): Promise<T[]>; executeRawTransaction<T>(callback: (db: Kysely<Database>) => Promise<T>): Promise<T>; batchInsertWords(words: any[]): Promise<void>; batchInsertSynsets(synsets: any[]): Promise<void>; batchInsertSenses(senses: any[]): Promise<void>; batchInsertForms(forms: any[]): Promise<void>; batchInsertDefinitions(definitions: any[]): Promise<void>; batchInsertExamples(examples: any[]): Promise<void>; batchInsertRelations(relations: any[]): Promise<void>; batchInsertILIs(ilis: any[]): Promise<void>; batchInsertLexicons(lexicons: any[]): Promise<void>; close(): Promise<void>; /** * Get the query service for direct database operations */ getQueryService(): KyselyQueryService; /** * Get words by ILI and language using the query service */ getWordsByIliAndLanguage(ili: string, language?: string): Promise<Word[]>; } declare type Lexicon = z.infer<typeof LexiconSchema>; declare const LexiconSchema: z.ZodObject<{ id: z.ZodString; label: z.ZodString; language: z.ZodString; email: z.ZodOptional<z.ZodString>; license: z.ZodOptional<z.ZodString>; version: z.ZodOptional<z.ZodString>; url: z.ZodOptional<z.ZodString>; citation: z.ZodOptional<z.ZodString>; logo: z.ZodOptional<z.ZodString>; requires: z.ZodOptional<z.ZodArray<z.ZodString>>; metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>; }, z.core.$strip>; declare interface LexiconTable { id: string; label: string; language: string; email?: string; license?: string; version?: string; url?: string; citation?: string; logo?: string; metadata?: string; } declare type LifecycleEvent = 'kernel:init' | 'lexicon:loaded' | 'lexicon:updated' | 'data:loaded' | 'data:updated' | 'plugin:added' | 'plugin:removed' | 'schema:changed'; declare interface LifecycleEventData { 'kernel:init': { kernel: WordNetCore; }; 'lexicon:loaded': { lexicon: Lexicon; source: string; }; 'lexicon:updated': { lexicon: Lexicon; changes: string[]; }; 'data:loaded': { source: string; recordCount: number; }; 'data:updated': { table: string; operation: 'insert' | 'update' | 'delete'; count: number; }; 'plugin:added': { pluginName: string; methods: string[]; }; 'plugin:removed': { pluginName: string; }; 'schema:changed': { modifications: string[]; }; } declare type LifecycleHook<T extends LifecycleEvent = LifecycleEvent> = (event: T, data: LifecycleEventData[T], kernel: WordNetCore) => Promise<void> | void; declare class LifecycleManager { private hooks; private pluginDependencies; private pluginPriorities; constructor(); /** * Register a plugin's lifecycle hooks */ registerPlugin(plugin: PluginLifecycle): void; /** * Unregister a plugin's lifecycle hooks */ unregisterPlugin(pluginName: string): void; /** * Emit a lifecycle event and run all registered hooks in priority order */ emit<T extends LifecycleEvent>(event: T, data: LifecycleEventData[T], kernel: WordNetCore): Promise<void>; /** * Validate that plugin dependencies are satisfied */ private validateDependencies; /** * Get all registered plugins */ getRegisteredPlugins(): string[]; /** * Get hooks for a specific event */ getHooksForEvent(event: LifecycleEvent): Array<{ plugin: string; priority: number; }>; } declare abstract class LocalBaseWordnet { protected database: NodeKyselyDatabase; protected initialized: boolean; protected lexicon: string[]; protected expand: string[]; protected normalizer?: (form: string) => string; constructor(lexicon?: string | string[], options?: any); abstract initialize(): Promise<void>; protected getDb(): Kysely<Database>; abstract getWord(id: string): Promise<Word | undefined>; abstract getSynset(id: string): Promise<Synset | undefined>; abstract getSense(id: string): Promise<Sense | undefined>; abstract getIli(id: string): Promise<ILI | undefined>; protected getSynsetOrUndefined(id: string): Promise<Synset | undefined>; abstract words(query?: any): Promise<Word[]>; abstract synsets(query?: any): Promise<Synset[]>; abstract senses(query?: any): Promise<Sense[]>; abstract lexicons(): Promise<Lexicon[]>; normalizeForm(form: string): Promise<string>; } /** * Node.js specific database configuration */ declare interface NodeDatabaseConfig extends BaseDatabaseConfig { /** * Database file path */ filename: string; /** * Whether the file must exist */ fileMustExist?: boolean; /** * Database timeout in milliseconds */ timeout?: number; } declare class NodeKyselyDatabase implements NodeKyselyDatabaseInterface { private db; private sqliteDb; private config; constructor(config: NodeDatabaseConfig); initialize(): Promise<void>; getDatabase(): Kysely<Database>; close(): Promise<void>; /** * Get the underlying better-sqlite3 database instance * This is useful for operations that need direct SQLite access */ getSqliteDatabase(): any; /** * Execute a raw SQL query (useful for complex operations) */ executeRaw(sql: string, params?: any[]): Promise<any[]>; /** * Execute a raw SQL query that returns a single row */ executeRawSingle(sql: string, params?: any[]): Promise<any>; /** * Begin a transaction */ beginTransaction(): Promise<void>; /** * Commit a transaction */ commitTransaction(): Promise<void>; /** * Rollback a transaction */ rollbackTransaction(): Promise<void>; /** * Check if the database is in a transaction */ isInTransaction(): boolean; /** * Get database statistics */ getDatabaseStats(): Promise<{ pageCount: number; pageSize: number; pageCountBytes: number; freelistCount: number; freelistCountBytes: number; cacheSize: number; cacheSizeBytes: number; cacheUsed: number; cacheUsedBytes: number; }>; /** * Optimize the database */ optimize(): Promise<void>; } declare interface NodeKyselyDatabaseInterface { getDatabase(): Kysely<Database>; initialize(): Promise<void>; close(): Promise<void>; } declare interface NodeWordnetConfig extends NodeDatabaseConfig { journalMode?: 'DELETE' | 'WAL' | 'MEMORY' | 'OFF'; synchronous?: 'OFF' | 'NORMAL' | 'FULL' | 'EXTRA'; cacheSize?: number; tempStore?: 'DEFAULT' | 'FILE' | 'MEMORY'; mmapSize?: number; foreignKeys?: boolean; recursiveTriggers?: boolean; forceRecreate?: boolean; strategy?: QueryStrategy; } /** * Node.js implementation of WordNetCore interface * Bridges the new kernel architecture with existing KyselyWordnet */ declare class NodeWordNetCore implements WordNetCore { private kyselyWordnet; constructor(lexicon?: string | string[], options?: Partial<NodeWordnetConfig>); query(_sql: string, _params?: unknown[]): Promise<unknown[]>; words(query?: WordQuery): Promise<Word[]>; word(wordId: string): Promise<Word>; synsets(query?: SynsetQuery): Promise<Synset[]>; synset(synsetId: string): Promise<Synset>; senses(query?: SenseQuery): Promise<Sense[]>; sense(senseId: string): Promise<Sense>; ili(iliId: string): Promise<ILI>; ilis(status?: string): Promise<ILI[]>; lexicons(): Promise<any[]>; synsetsByILI(iliId: string): Promise<Synset[]>; getWord(form: string): Promise<Word[]>; getSynset(id: string): Promise<any | null>; getSenses(wordId: string): Promise<Sense[]>; getDefinitions(synsetId: string): Promise<any[]>; getRelations(synsetId: string, type?: string): Promise<any[]>; initialize(): Promise<void>; close(): Promise<void>; getKyselyWordnet(): KyselyWordnet; } /** * Kernel-based WordNet for Node.js * Provides the new plugin system with full type safety */ export declare class NodeWordNetKernel { private wordnet; private core; constructor(lexicon?: string | string[], options?: Partial<NodeWordnetConfig>); initialize(): Promise<void>; close(): Promise<void>; words(query?: any): Promise<any[]>; word(wordId: string): Promise<any>; synsets(query?: any): Promise<any[]>; synset(synsetId: string): Promise<any>; senses(query?: any): Promise<any[]>; sense(senseId: string): Promise<any>; ili(iliId: string): Promise<any>; ilis(status?: string): Promise<any[]>; synsetsByILI(iliId: string): Promise<any[]>; getHypernyms(synsetId: string): Promise<Array<{ id: string; lemma: string; pos: string; language: string; }>>; getHyponyms(synsetId: string): Promise<Array<{ id: string; lemma: string; pos: string; language: string; }>>; getMeronyms(synsetId: string): Promise<Array<{ id: string; lemma: string; pos: string; language: string; }>>; getHolonyms(synsetId: string): Promise<Array<{ id: string; lemma: string; pos: string; language: string; }>>; getEntailments(synsetId: string): Promise<Array<{ id: string; lemma: string; pos: string; language: string; }>>; getSimilarTos(synsetId: string): Promise<Array<{ id: string; lemma: string; pos: string; language: string; }>>; getRelationsByType(synsetId: string, relationType: string): Promise<Array<{ id: string; lemma: string; pos: string; language: string; type: string; }>>; getAllRelations(synsetId: string): Promise<Array<{ id: string; source_id: string; target_id: string; type: string; source_lemma: string; target_lemma: string; direction: 'incoming' | 'outgoing'; }>>; getPathSimilarity(synset1: string | any, synset2: string | any): Promise<number>; getWuPalmerSimilarity(synset1: string | any, synset2: string | any): Promise<number>; getLeacockChodorowSimilarity(synset1: string | any, synset2: string | any): Promise<number>; getJaccardSimilarity(synset1: string | any, synset2: string | any): Promise<number>; getBestSimilarity(synset1: string | any, synset2: string | any): Promise<number>; findMostSimilar(synsetId: string, limit?: number): Promise<Array<{ id: string; similarity: number; }>>; getCrossLingualSimilarity(synset1: string | any, synset2: string | any): Promise<number>; getTranslations(synsetId: string, targetLanguage?: string): Promise<Array<{ id: string; language: string; lexicon: string; lemma: string; pos: string; }>>; getTranslationsByWord(wordForm: string, sourceLanguage: string, targetLanguage: string): Promise<Array<{ sourceSynset: string; ili: string; translations: Array<{ lemma: string; pos: string; lexicon: string; }>; }>>; getAvailableLanguages(synsetId: string): Promise<Array<{ language: string; word_count: number; }>>; getSynsetsByIli(ili: string): Promise<Array<{ id: string; language: string; lexicon: string; pos: string; words: string; }>>; getTranslationConfidence(synset1: string, synset2: string): Promise<number>; getTranslationSuggestions(wordForm: string, sourceLanguage: string, targetLanguage: string): Promise<Array<{ sourceSynset: string; ili: string; confidence: number; targetWords: string[]; }>>; get schemaManager(): any; getPlugins(): string[]; has(pluginName: string): boolean; getCore(): NodeWordNetCore; getWordnet(): WordNetWithPlugins<readonly [typeof similarity, typeof translation]>; } declare type PartOfSpeech = 'n' | 'v' | 'a' | 'r' | 's' | 'c' | 'p' | 'i' | 'x' | 'u'; declare interface Plugin<TMethods extends Record<string, PluginMethod> = Record<string, PluginMethod>> { name: string; methods: TMethods; lifecycle?: PluginLifecycle; } declare interface PluginLifecycle { name: string; hooks: { [K in LifecycleEvent]?: LifecycleHook<K>; }; dependencies?: string[]; priority?: number; } declare type PluginMethod<TCore = WordNetKernel, TArgs extends any[] = any[], TReturn = any> = (core: TCore, ...args: TArgs) => TReturn; declare interface PluginSchemaRequirements { pluginName: string; tables: TableRequirement[]; indexes: IndexRequirement[]; constraints: ConstraintRequirement[]; data: DataRequirement[]; dependencies: string[]; conflicts: string[]; } declare type Project = z.infer<typeof ProjectSchema>; declare const ProjectSchema: z.ZodObject<{ id: z.ZodString; label: z.ZodString; description: z.ZodOptional<z.ZodString>; url: z.ZodOptional<z.ZodString>; license: z.ZodOptional<z.ZodString>; citation: z.ZodOptional<z.ZodString>; metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>; }, z.core.$strip>; declare interface QueryOptions { strategy?: QueryStrategy; includeDefinitions?: boolean; includeExamples?: boolean; includeRelations?: boolean; includeSenses?: boolean; } /** * Query optimization strategies for different performance requirements * Strategy names are flexible and can be query-specific (e.g., 'v1', 'v2', 'optimized', 'fast', etc.) */ declare type QueryStrategy = string; declare type Relation = z.infer<typeof RelationSchema>; declare const RelationSchema: z.ZodObject<{ id: z.ZodString; type: z.ZodString; target: z.ZodString; source: z.ZodOptional<z.ZodString>; dcType: z.ZodOptional<z.ZodString>; }, z.core.$strip>; declare interface RelationTable { id: string; source_id: string; target_id: string; type: string; source?: string; } declare interface SchemaModification { id: string; type: 'table' | 'column' | 'index' | 'constraint' | 'data'; operation: 'create' | 'alter' | 'drop' | 'insert' | 'update' | 'delete'; table?: string; column?: string; sql: string; rollbackSql: string; dependencies: string[]; conflicts: string[]; priority: number; estimatedTime: number; } declare type Sense = z.infer<typeof SenseSchema>; declare type SenseQuery = z.infer<typeof SenseQuerySchema>; declare const SenseQuerySchema: z.ZodObject<{ wordIdOrForm: z.ZodOptional<z.ZodString>; pos: z.ZodOptional<z.ZodEnum<{ n: "n"; v: "v"; a: "a"; r: "r"; s: "s"; c: "c"; p: "p"; i: "i"; x: "x"; u: "u"; }>>; lexicon: z.ZodOptional<z.ZodString>; strategy: z.ZodOptional<z.ZodString>; }, z.core.$strip>; declare const SenseSchema: z.ZodObject<{ id: z.ZodString; wordId: z.ZodString; synsetId: z.ZodString; examples: z.ZodArray<z.ZodObject<{ id: z.ZodString; language: z.ZodString; text: z.ZodString; source: z.ZodOptional<z.ZodString>; }, z.core.$strip>>; counts: z.ZodArray<z.ZodObject<{ id: z.ZodString; value: z.ZodNumber; writtenForm: z.ZodString; pos: z.ZodEnum<{ n: "n"; v: "v"; a: "a"; r: "r"; s: "s"; c: "c"; p: "p"; i: "i"; x: "x"; u: "u"; }>; }, z.core.$strip>>; tags: z.ZodArray<z.ZodObject<{ id: z.ZodString; category: z.ZodString; value: z.ZodString; }, z.core.$strip>>; relations: z.ZodOptional<z.ZodArray<z.ZodObject<{ id: z.ZodString; type: z.ZodString; target: z.ZodString; source: z.ZodOptional<z.ZodString>; dcType: z.ZodOptional<z.ZodString>; }, z.core.$strip>>>; source: z.ZodOptional<z.ZodString>; sensekey: z.ZodOptional<z.ZodString>; adjposition: z.ZodOptional<z.ZodString>; subcategory: z.ZodOptional<z.ZodString>; domain: z.ZodOptional<z.ZodString>; register: z.ZodOptional<z.ZodString>; }, z.core.$strip>; declare interface SenseTable { id: string; word_id: string; synset_id: string; source?: string; sensekey?: string; adjposition?: string; subcategory?: string; domain?: string; register?: string; } /** * Similarity module for WordNet (Core Module) */ declare const similarity: Plugin; declare type Synset = z.infer<typeof SynsetSchema>; declare type SynsetQuery = z.infer<typeof SynsetQuerySchema>; declare const SynsetQuerySchema: z.ZodObject<{ form: z.ZodOptional<z.ZodString>; pos: z.ZodOptional<z.ZodEnum<{ n: "n"; v: "v"; a: "a"; r: "r"; s: "s"; c: "c"; p: "p"; i: "i"; x: "x"; u: "u"; }>>; ili: z.ZodOptional<z.ZodString>; lexicon: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>; language: z.ZodOptional<z.ZodString>; searchAllForms: z.ZodOptional<z.ZodBoolean>; fuzzy: z.ZodOptional<z.ZodBoolean>; maxResults: z.ZodOptional<z.ZodNumber>; includeDefinitions: z.ZodOptional<z.ZodBoolean>; includeExamples: z.ZodOptional<z.ZodBoolean>; includeRelations: z.ZodOptional<z.ZodBoolean>; strategy: z.ZodOptional<z.ZodString>; }, z.core.$strip>; declare const SynsetSchema: z.ZodObject<{ id: z.ZodString; ili: z.ZodOptional<z.ZodString>; pos: z.ZodEnum<{ n: "n"; v: "v"; a: "a"; r: "r"; s: "s"; c: "c"; p: "p"; i: "i"; x: "x"; u: "u"; }>; definitions: z.ZodArray<z.ZodObject<{ id: z.ZodString; language: z.ZodString; text: z.ZodString; source: z.ZodOptional<z.ZodString>; }, z.core.$strip>>; examples: z.ZodArray<z.ZodObject<{ id: z.ZodString; language: z.ZodString; text: z.ZodString; source: z.ZodOptional<z.ZodString>; }, z.core.$strip>>; relations: z.ZodArray<z.ZodObject<{ id: z.ZodString; type: z.ZodString; target: z.ZodString; source: z.ZodOptional<z.ZodString>; dcType: z.ZodOptional<z.ZodString>; }, z.core.$strip>>; iliDefinitions: z.ZodOptional<z.ZodArray<z.ZodObject<{ id: z.ZodString; language: z.ZodString; text: z.ZodString; source: z.ZodOptional<z.ZodString>; }, z.core.$strip>>>; language: z.ZodString; lexicon: z.ZodString; memberIds: z.ZodArray<z.ZodString>; senseIds: z.ZodArray<z.ZodString>; }, z.core.$strip>; declare interface SynsetTable { id: string; ili?: string; pos: string; language: string; lexicon: string; } declare interface TableRequirement { name: string; columns: ColumnRequirement[]; primaryKey?: string[]; uniqueKeys?: string[][]; foreignKeys?: ForeignKeyRequirement[]; checks?: CheckConstraint[]; } declare const translation: Plugin; declare type Word = z.infer<typeof WordSchema>; declare interface WordNetCore { query(sql: string, params?: unknown[]): Promise<unknown[]>; words(query?: WordQuery): Promise<Word[]>; word(wordId: string): Promise<Word>; synsets(query?: SynsetQuery): Promise<Synset[]>; synset(synsetId: string): Promise<Synset>; senses(query?: SenseQuery): Promise<Sense[]>; sense(senseId: string): Promise<Sense>; ili(iliId: string): Promise<ILI>; ilis(status?: string): Promise<ILI[]>; synsetsByILI(iliId: string): Promise<Synset[]>; lexicons(): Promise<Lexicon[]>; getWord(form: string): Promise<Word[]>; getSynset(id: string): Promise<Synset | null>; getSenses(wordId: string): Promise<Sense[]>; getDefinitions(synsetId: string): Promise<Definition[]>; getRelations(synsetId: string, type?: string): Promise<Relation[]>; } /** * New Kernel-based WordNet class * This replaces the old BaseWordnet architecture */ declare class WordNetKernel<TPlugins extends readonly Plugin[] = readonly []> { private plugins; core: WordNetCore; private kyselyDb; private modifications; private pluginRequirements; private conflictResolutions; private healthHistory; private lifecycleManager; constructor(core: WordNetCore, kyselyDb?: KyselyDatabase); words(query?: WordQuery): Promise<Word[]>; word(wordId: string): Promise<Word>; synsets(query?: SynsetQuery): Promise<Synset[]>; synset(synsetId: string): Promise<Synset>; senses(query?: SenseQuery): Promise<Sense[]>; sense(senseId: string): Promise<Sense>; ili(iliId: string): Promise<ILI>; ilis(status?: string): Promise<ILI[]>; synsetsByILI(iliId: string): Promise<Synset[]>; lexicons(): Promise<Lexicon[]>; query(sql: string, params?: unknown[]): Promise<unknown[]>; getWord(form: string): Promise<Word[]>; getSynset(id: string): Promise<Synset | null>; getSenses(wordId: string): Promise<Sense[]>; getDefinitions(synsetId: string): Promise<Definition[]>; getRelations(synsetId: string, type?: string): Promise<Relation[]>; /** * Add a plugin - just like Jotai atoms or Jest matchers * Returns a new type-safe instance with the plugin methods */ use<TNewPlugin extends Plugin>(plugin: TNewPlugin): WordNetWithPlugins<[...TPlugins, TNewPlugin]>; /** * Remove a plugin */ remove(name: string): WordNetWithPlugins<TPlugins>; /** * Check if plugin is loaded */ has(name: string): boolean; /** * Get all loaded plugins */ getPlugins(): string[]; /** * Get the core instance */ getCore(): WordNetCore; /** * Load a new lexicon and notify plugins */ loadLexicon(lexicon: Lexicon, source: string): Promise<void>; /** * Update lexicon data and notify plugins */ updateLexicon(lexicon: Lexicon, changes: string[]): Promise<void>; /** * Load data and notify plugins */ loadData(source: string, recordCount: number): Promise<void>; /** * Update data and notify plugins */ updateData(table: string, operation: 'insert' | 'update' | 'delete', count: number): Promise<void>; /** * Emit a lifecycle event to all registered plugins */ private emitLifecycleEvent; /** * Get lifecycle manager for advanced usage */ getLifecycleManager(): LifecycleManager; /** * Built-in schema management (not a plugin - core functionality) */ get schemaManager(): { registerPluginRequirements: (requirements: PluginSchemaRequirements) => Promise<void>; unregisterPluginRequirements: (pluginName: string) => Promise<void>; performHealthCheck: () => Promise<HealthCheckResult>; applyModifications: (modificationIds: string[]) => Promise<{ success: boolean; applied: string[]; failed: string[]; conflicts: string[]; errors: string[]; }>; resolveConflicts: (conflictId: string, strategy: ConflictResolutionStrategy) => Promise<boolean>; getSchemaStatus: () => Promise<{ tables: string[]; columns: Record<string, string[]>; indexes: Record<string, string[]>; constraints: Record<string, string[]>; modifications: SchemaModification[]; conflicts: string[]; healthScore: number; }>; }; private checkForConflicts; private generateSchemaModifications; private checkSchemaHealth; private checkDataHealth; private checkConflicts; private generateRecommendations; private calculateHealthScore; private sortModificationsByDependencies; private checkModificationConflicts; private mergeConflictingChanges; private overrideConflictingChanges; private skipConflictingChanges; private rollbackConflictingChanges; private getCurrentTables; private getTableColumns; private getTableIndexes; private getTableConstraints; } declare type WordNetWithPlugins<TPlugins extends readonly Plugin[] = readonly Plugin[]> = WordNetCore & { use: <TNewPlugin extends Plugin>(plugin: TNewPlugin) => WordNetWithPlugins<[...TPlugins, TNewPlugin]>; remove: (name: string) => WordNetWithPlugins<TPlugins>; has: (name: string) => boolean; getPlugins: () => string[]; getCore: () => WordNetCore; schemaManager: { registerPluginRequirements: (requirements: PluginSchemaRequirements) => Promise<void>; unregisterPluginRequirements: (pluginName: string) => Promise<void>; performHealthCheck: () => Promise<HealthCheckResult>; applyModifications: (modificationIds: string[]) => Promise<{ success: boolean; applied: string[]; failed: string[]; conflicts: string[]; errors: string[]; }>; resolveConflicts: (conflictId: string, strategy: ConflictResolutionStrategy) => Promise<boolean>; getSchemaStatus: () => Promise<{ tables: string[]; columns: Record<string, string[]>; indexes: Record<string, string[]>; constraints: Record<string, string[]>; modifications: SchemaModification[]; conflicts: string[]; healthScore: number; }>; }; } & { [K in TPlugins[number] extends infer P ? P extends Plugin ? keyof P['methods'] : never : never]: TPlugins[number] extends infer P ? P extends Plugin ? P['methods'][K] extends PluginMethod<infer _TCore, infer TArgs, infer TReturn> ? (...args: TArgs) => TReturn : never : never : never; }; declare type WordQuery = z.infer<typeof WordQuerySchema>; declare const WordQuerySchema: z.ZodObject<{ form: z.ZodOptional<z.ZodString>; pos: z.ZodOptional<z.ZodEnum<{ n: "n"; v: "v"; a: "a"; r: "r"; s: "s"; c: "c"; p: "p"; i: "i"; x: "x"; u: "u"; }>>; lexicon: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>; language: z.ZodOptional<z.ZodString>; searchAllForms: z.ZodOptional<z.ZodBoolean>; fuzzy: z.ZodOptional<z.ZodBoolean>; maxResults: z.ZodOptional<z.ZodNumber>; includeInflected: z.ZodOptional<z.ZodBoolean>; strategy: z.ZodOptional<z.ZodString>; }, z.core.$strip>; declare const WordSchema: z.ZodObject<{ id: z.ZodString; lemma: z.ZodString; pos: z.ZodEnum<{ n: "n"; v: "v"; a: "a"; r: "r"; s: "s"; c: "c"; p: "p"; i: "i"; x: "x"; u: "u"; }>; forms: z.ZodArray<z.ZodObject<{ id: z.ZodString; writtenForm: z.ZodString; script: z.ZodOptional<z.ZodString>; tag: z.ZodOptional<z.ZodString>; }, z.core.$strip>>; pronunciations: z.ZodArray<z.ZodObject<{ id: z.ZodString; value: z.ZodString; variety: z.ZodOptional<z.ZodString>; notation: z.ZodOptional<z.ZodString>; geographic: z.ZodOptional<z.ZodString>; }, z.core.$strip>>; tags: z.ZodArray<z.ZodObject<{ id: z.ZodString; category: z.ZodString; value: z.ZodString; }, z.core.$strip>>; counts: z.ZodArray<z.ZodObject<{ id: z.ZodString; value: z.ZodNumber; writtenForm: z.ZodString; pos: z.ZodEnum<{ n: "n"; v: "v"; a: "a"; r: "r"; s: "s"; c: "c"; p: "p"; i: "i"; x: "x"; u: "u"; }>; }, z.core.$strip>>; syntacticBehaviours: z.ZodOptional<z.ZodArray<z.ZodObject<{ id: z.ZodString; subcategorizationFrame: z.ZodString; source: z.ZodOptional<z.ZodString>; senseIds: z.ZodArray<z.ZodString>; }, z.core.$strip>>>; language: z.ZodString; lexicon: z.ZodString; }, z.core.$strip>; declare interface WordTable { id: string; lemma: string; pos: string; language: string; lexicon: string; } export { }