UNPKG

@thisisagile/easy

Version:

Straightforward library for building domain-driven microservice architectures

71 lines (70 loc) 2.13 kB
import { Text } from './Text'; import { List } from './List'; import { Optional } from './Types'; import { OneOrMore } from './Array'; export type Segment = Text & { key?: string; segment?: string; query?: (value: unknown) => string; }; export declare const toSegment: (key?: Text, { segment, query, }?: { segment?: string; query?: (value: unknown) => string; }) => Segment; export declare const uri: { host: (key?: string) => Segment; resource: (resource: Uri) => Segment; segment: (key?: Text) => Segment; path: (key: Text) => Segment; query: (key: Text) => Segment; boolean: (key: Text) => Segment; }; type Prop = { segment: Segment; value: any; }; export type Uri = { id: (id?: unknown) => Uri; ids: (ids: OneOrMore<unknown>) => Uri; query: (q?: unknown) => Uri; sort: (q?: any) => Uri; skip: (n?: number) => Uri; take: (n?: number) => Uri; path: string; route: (resource: string) => string; isInternal: boolean; toString: () => string; }; export type UriExpandProps = { q: string; s: string; }; export declare class EasyUri<Props = UriExpandProps> implements Uri { readonly segments: Segment[]; static readonly id: Segment; static readonly ids: Segment; static readonly query: Segment; static readonly sort: Segment; static readonly skip: Segment; static readonly take: Segment; readonly host: Segment; protected resource: Segment; protected state: any; constructor(segments?: Segment[]); get path(): string; get complete(): string; get isInternal(): boolean; protected get props(): List<Prop>; route: (resource?: Optional<string>) => string; set: (segment: Segment, value?: unknown) => this; toString(): string; id: (id?: unknown) => this; ids: (ids: OneOrMore<unknown>) => this; query: (q?: unknown) => this; sort: (s?: any) => this; skip: (index?: number) => this; take: (items?: number) => this; expand(props: Partial<Props>): this; } export declare const clipUri: (uri?: EasyUri | string | null) => string; export {};