10 changed files with 159 additions and 18 deletions
@ -0,0 +1,39 @@
@@ -0,0 +1,39 @@
|
||||
/** |
||||
* Type definitions for highlight.js |
||||
* These are minimal types for the parts we use |
||||
*/ |
||||
|
||||
declare module 'highlight.js' { |
||||
export interface HighlightResult { |
||||
value: string; |
||||
language?: string; |
||||
relevance?: number; |
||||
} |
||||
|
||||
export interface HighlightOptions { |
||||
language?: string; |
||||
ignoreIllegals?: boolean; |
||||
} |
||||
|
||||
export interface AutoHighlightResult extends HighlightResult { |
||||
secondBest?: HighlightResult; |
||||
} |
||||
|
||||
export interface Language { |
||||
name?: string; |
||||
aliases?: string[]; |
||||
keywords?: Record<string, any>; |
||||
contains?: any[]; |
||||
} |
||||
|
||||
export interface HLJSApi { |
||||
highlight(code: string, options: HighlightOptions): HighlightResult; |
||||
highlightAuto(code: string, options?: { languageSubset?: string[] }): AutoHighlightResult; |
||||
getLanguage(name: string): Language | undefined; |
||||
registerLanguage(name: string, language: (hljs: HLJSApi) => Language): void; |
||||
listLanguages(): string[]; |
||||
} |
||||
|
||||
const hljs: HLJSApi; |
||||
export default hljs; |
||||
} |
||||
@ -0,0 +1,13 @@
@@ -0,0 +1,13 @@
|
||||
/** |
||||
* Logger interface for consistent logging across the application |
||||
* Compatible with both pino (server-side) and console (browser-side) |
||||
*/ |
||||
|
||||
export interface Logger { |
||||
info(...args: unknown[]): void; |
||||
error(...args: unknown[]): void; |
||||
warn(...args: unknown[]): void; |
||||
debug(...args: unknown[]): void; |
||||
trace(...args: unknown[]): void; |
||||
fatal(...args: unknown[]): void; |
||||
} |
||||
@ -0,0 +1,80 @@
@@ -0,0 +1,80 @@
|
||||
/** |
||||
* Type definitions for NIP-19 bech32 encoded entities |
||||
* These types help with proper typing of nip19.decode() return values |
||||
*/ |
||||
|
||||
/** |
||||
* Decoded npub (public key) |
||||
*/ |
||||
export interface DecodedNpub { |
||||
type: 'npub'; |
||||
data: string; // hex pubkey
|
||||
} |
||||
|
||||
/** |
||||
* Decoded nsec (private key) |
||||
*/ |
||||
export interface DecodedNsec { |
||||
type: 'nsec'; |
||||
data: Uint8Array; // private key bytes
|
||||
} |
||||
|
||||
/** |
||||
* Decoded note (event ID) |
||||
*/ |
||||
export interface DecodedNote { |
||||
type: 'note'; |
||||
data: string; // hex event ID
|
||||
} |
||||
|
||||
/** |
||||
* Decoded nevent (event reference) |
||||
*/ |
||||
export interface DecodedNevent { |
||||
type: 'nevent'; |
||||
data: { |
||||
id: string; // hex event ID
|
||||
pubkey?: string; // hex pubkey
|
||||
relays?: string[]; // relay hints
|
||||
kind?: number; // event kind
|
||||
}; |
||||
} |
||||
|
||||
/** |
||||
* Decoded naddr (parameterized replaceable event) |
||||
*/ |
||||
export interface DecodedNaddr { |
||||
type: 'naddr'; |
||||
data: { |
||||
pubkey: string; // hex pubkey
|
||||
kind: number; // event kind
|
||||
identifier: string; // d-tag value
|
||||
relays?: string[]; // relay hints
|
||||
}; |
||||
} |
||||
|
||||
/** |
||||
* Union type for all decoded NIP-19 entities |
||||
*/ |
||||
export type DecodedNip19 = DecodedNpub | DecodedNsec | DecodedNote | DecodedNevent | DecodedNaddr; |
||||
|
||||
/** |
||||
* Type guard to check if decoded value is an npub |
||||
*/ |
||||
export function isDecodedNpub(decoded: DecodedNip19): decoded is DecodedNpub { |
||||
return decoded.type === 'npub'; |
||||
} |
||||
|
||||
/** |
||||
* Type guard to check if decoded value is a nevent |
||||
*/ |
||||
export function isDecodedNevent(decoded: DecodedNip19): decoded is DecodedNevent { |
||||
return decoded.type === 'nevent'; |
||||
} |
||||
|
||||
/** |
||||
* Type guard to check if decoded value is an naddr |
||||
*/ |
||||
export function isDecodedNaddr(decoded: DecodedNip19): decoded is DecodedNaddr { |
||||
return decoded.type === 'naddr'; |
||||
} |
||||
Loading…
Reference in new issue