segment-matcher
Version:
Segment Matcher - TypeScript version with dual ESM/CJS format support
31 lines (30 loc) • 713 B
TypeScript
export interface MessageSegment {
type: string | {
name: string;
};
data: Record<string, any>;
}
export type TokenType = 'literal' | 'typed_literal' | 'parameter' | 'rest_parameter';
export interface PatternToken {
type: TokenType;
value?: string;
segmentType?: string;
name?: string;
dataType?: string | null;
optional?: boolean;
defaultValue?: any;
}
export interface MatchResult {
matched: MessageSegment[];
params: Record<string, any>;
remaining: MessageSegment[];
}
export interface MatchResponse {
success: boolean;
matched?: MessageSegment[];
param?: {
name: string;
value: any;
};
newSegmentIndex?: number;
}