UNPKG

@akala/core

Version:
73 lines (72 loc) 2.17 kB
/** * Level 2 operators used in URI templates (RFC 6570). */ export type OperatorL2 = '+' | '#'; /** * Level 3 operators used in URI templates (RFC 6570). */ export type OperatorL3 = '.' | '/' | ';' | '?' | '&'; /** * Reserved operators used in URI templates (RFC 6570). */ export type OperatorReserved = '=' | ',' | '!' | '@' | '|'; /** * Union type combining all URI template operators. */ export type Operators = OperatorL2 | OperatorL3 | OperatorReserved; export declare const allow: { readonly '': readonly ["U"]; readonly '+': readonly ["U", "R"]; readonly '.': readonly ["U"]; readonly '/': readonly ["U"]; readonly ';': readonly ["U"]; readonly '?': readonly ["U"]; readonly '&': readonly ["U"]; readonly '#': readonly ["U", "R"]; }; export declare const restricted: { ' ': number; '<': number; '>': number; '{': number; '}': number; '%': number; ':': number; '/': number; '?': number; '#': number; '[': number; ']': number; '@': number; '!': number; $: number; '&': number; '\'': number; '(': number; ')': number; '*': number; '+': number; ',': number; ';': number; '=': number; }; export type UriTemplate = (string | UriTemplateExpansion)[]; export type UriTemplateExpansion = { ref: string | UriTemplateExpansion[]; sub?: number; operator?: Operators; explode?: boolean; }; export declare function subOperatorx(operator: Operators | undefined, isMulti: boolean): Operators | undefined; export declare function joinOperator(operator: Operators | undefined, isMulti: boolean): Operators | undefined; export declare function prefixOperator(operator: Operators | undefined, isMulti: boolean): Operators | undefined; export declare function match(s: string, template: UriTemplate): null | { remainder: string; variables: Record<string, unknown>; }; export declare function expand(template: UriTemplate, variables: Record<string, unknown>): string; export declare function parse(s: string): UriTemplate; export declare function tryParse(s: string): { template: UriTemplate; warnings: Error[]; };