@thisisagile/easy
Version:
Straightforward library for building domain-driven microservice architectures
54 lines (53 loc) • 2.33 kB
TypeScript
import { Property, PropertyOptions } from './Property';
import { State } from './State';
import { Json, JsonValue } from '../types/Json';
import { Optional } from '../types/Types';
import { TypeGuard } from '../types/TypeGuard';
import { List } from '../types/List';
import { Get } from '../types/Get';
import { Construct } from '../types/Constructor';
export type Mapping = {
property: string;
in: (source?: Json, key?: string) => Optional<JsonValue>;
out: (source?: Json, key?: string) => Optional<JsonValue>;
};
export declare const isMapping: TypeGuard<Mapping>;
export type MapStartFrom = 'scratch' | 'source';
export type MapOptions = {
startFrom: MapStartFrom;
};
export declare class Mapper extends State implements Mapping {
readonly options: MapOptions;
readonly property: string;
protected readonly map: {
item: (property: string, options?: PropertyOptions) => Property;
ignore: (property?: string) => Mapping;
skipIn: (property: string) => Mapping;
skipOut: (property: string) => Mapping;
func: (property: string, funcIn: Get<Optional<JsonValue>, Json>, funcOut: Get<Optional<JsonValue>, Json>) => Mapping;
add: (funcIn: Get<JsonValue, Json>) => Mapping;
map: (mapper: Construct<Mapper>, property?: string) => Mapping;
propsToList: (...maps: Mapping[]) => Mapping;
list: (mapper: Mapping, property: string) => Mapping;
};
constructor(options?: MapOptions, property?: string);
get properties(): List<[string, Mapping]>;
get keys(): List<string>;
get columns(): List<string>;
private get droppedIn();
private get droppedOut();
in(from?: Json): Json;
out(to?: Json): Json;
toString(): string;
}
export declare const mappings: {
item: (property: string, options?: PropertyOptions) => Property;
ignore: (property?: string) => Mapping;
skipIn: (property: string) => Mapping;
skipOut: (property: string) => Mapping;
func: (property: string, funcIn: Get<Optional<JsonValue>, Json>, funcOut: Get<Optional<JsonValue>, Json>) => Mapping;
add: (funcIn: Get<JsonValue, Json>) => Mapping;
map: (mapper: Construct<Mapper>, property?: string) => Mapping;
propsToList: (...maps: Mapping[]) => Mapping;
list: (mapper: Mapping, property: string) => Mapping;
};