Skip to main content Link Search Menu Expand Document (external link)

AST overview

Added in v5.0.0


Table of contents


utils

AST (type alias)

Signature

export type AST =
  | Literal<string>
  | UnnamedParam
  | Param<string>
  | ZeroOrMore<AST>
  | OneOrMore<AST>
  | Optional<AST>
  | Prefix<string, AST>
  | QueryParams<AST, ReadonlyArray<QueryParam<string, AST>>>
  | Concat<AST, AST>
  | WithSchema<AST, Schema.Schema.All>

Added in v5.0.0

Concat (class)

Signature

export declare class Concat<L, R> { constructor(readonly left: L, readonly right: R) }

Added in v5.0.0

_tag (property)

Signature

readonly _tag: "Concat"

Added in v5.0.0

InterpolateLiteral (class)

Signature

export declare class InterpolateLiteral { constructor(readonly value: string) }

Added in v5.0.0

_tag (property)

Signature

readonly _tag: "Literal"

Added in v5.0.0

InterpolateParam (class)

Signature

export declare class InterpolateParam { constructor(
    readonly interpolate: Interpolater
  ) }

Added in v5.0.0

_tag (property)

Signature

readonly _tag: "Param"

Added in v5.0.0

Interpolater (type alias)

Signature

export type Interpolater = (params: Readonly<Record<string, string | ReadonlyArray<string>>>) => string

Added in v5.0.0

InterpolationPart (type alias)

Signature

export type InterpolationPart = InterpolateLiteral | InterpolateParam

Added in v5.0.0

Literal (class)

Signature

export declare class Literal<L> { constructor(readonly literal: L) }

Added in v5.0.0

_tag (property)

Signature

readonly _tag: "Literal"

Added in v5.0.0

Matcher (type alias)

Signature

export type Matcher = (
  pathSegments: Array<string>,
  query: URLSearchParams
) => Option.Option<Record<string, string | ReadonlyArray<string>>>

Added in v5.0.0

OneOrMore (class)

Signature

export declare class OneOrMore<P> { constructor(readonly param: P) }

Added in v5.0.0

_tag (property)

Signature

readonly _tag: "OneOrMore"

Added in v5.0.0

Optional (class)

Signature

export declare class Optional<P> { constructor(readonly param: P) }

Added in v5.0.0

_tag (property)

Signature

readonly _tag: "Optional"

Added in v5.0.0

Param (class)

Signature

export declare class Param<P> { constructor(readonly param: P) }

Added in v5.0.0

_tag (property)

Signature

readonly _tag: "Param"

Added in v5.0.0

Prefix (class)

Signature

export declare class Prefix<P, A> { constructor(readonly prefix: P, readonly param: A) }

Added in v5.0.0

_tag (property)

Signature

readonly _tag: "Prefix"

Added in v5.0.0

QueryParam (class)

Signature

export declare class QueryParam<K, V> { constructor(readonly key: K, readonly value: V) }

Added in v5.0.0

_tag (property)

Signature

readonly _tag: "QueryParam"

Added in v5.0.0

QueryParams (class)

Signature

export declare class QueryParams<Previous, P> { constructor(readonly previous: Previous, readonly params: P) }

Added in v5.0.0

_tag (property)

Signature

readonly _tag: "QueryParams"

Added in v5.0.0

UnnamedParam (class)

Signature

export declare class UnnamedParam

Added in v5.0.0

_tag (property)

Signature

readonly _tag: "UnnamedParam"

Added in v5.0.0

WithSchema (class)

Signature

export declare class WithSchema<A, S> { constructor(readonly ast: A, readonly schema: S) }

Added in v5.0.0

_tag (property)

Signature

readonly _tag: "WithSchema"

Added in v5.0.0

ZeroOrMore (class)

Signature

export declare class ZeroOrMore<P> { constructor(readonly param: P) }

Added in v5.0.0

_tag (property)

Signature

readonly _tag: "ZeroOrMore"

Added in v5.0.0

astToInterpolation

Signature

export declare function astToInterpolation(ast: AST): InterpolationPart

Added in v5.0.0

astToMatcher

Signature

export declare function astToMatcher(ast: AST, end: boolean = false): Matcher

Added in v5.0.0

concat

Signature

export declare const concat: (left: AST, right: AST) => AST

Added in v5.0.0

getAstSegments

Signature

export declare function getAstSegments(part: AST): Array<Array<AST>>

Added in v5.0.0

getOptionalQueryParams

Signature

export declare function getOptionalQueryParams(ast: AST): ReadonlyArray<QueryParam<string, AST>>

Added in v5.0.0

getPathAndQuery

Signature

export declare function getPathAndQuery(path: string)

Added in v5.0.0

getQueryParams

Signature

export declare function getQueryParams(ast: AST): QueryParams<AST, ReadonlyArray<QueryParam<string, AST>>> | null

Added in v5.0.0

parse

Signature

export declare function parse(path: string)

Added in v5.0.0

splitByQueryParams

Signature

export declare function splitByQueryParams(path: string): readonly [Array<string>, string]

Added in v5.0.0

toPath

Signature

export declare function toPath<A extends AST>(ast: A): string

Added in v5.0.0

toPathSchema

Signature

export declare function toPathSchema<A extends AST>(ast: A): Schema.Schema.All

Added in v5.0.0

toQuerySchema

Signature

export declare function toQuerySchema<A extends AST>(ast: A): Schema.Schema.All

Added in v5.0.0

toSchema

Signature

export declare function toSchema<A extends AST>(ast: A): Schema.Schema.All

Added in v5.0.0