Best JavaScript code snippet using fast-check-monorepo
tsql.d.ts
Source:tsql.d.ts
1// TypeScript Version: 3.42import {3 Iter,4 EP,5 ExtractMap,6 CurriedFunction2,7 FlatForInternalFn,8 OuterJoinMap,9 InnerJoinObject,10 OuterJoinObject,11 InnerJoinMap,12 PairRepeat,13} from './utils';14/**15 * https://github.com/rudty/nodekell#groupby16 *17 * @param f18 * @param iter19 */20export function groupBy<K, V>(f: (elem: V) => (K | Promise<K>), iter: Iter<V | Promise<V>>): Promise<Map<K, V[]>>;21// export function groupBy<K, V>(f: (elem: EP<V>) => K, iter: Iter<V>): Promise<Map<EP<K>, EP<V>[]>>;22export function groupBy<K, V extends Iter<any>>(f: (elem: FlatForInternalFn<V>) => K, iter: V): Promise<Map<EP<K>, FlatForInternalFn<V>[]>>;23export function groupBy<K, V extends Iter<any>>(f: (elem: FlatForInternalFn<V>) => K): (iter: V) => Promise<Map<EP<K>, FlatForInternalFn<V>[]>>;24export function groupBy<K, V>(f: (elem: V) => (K | Promise<K>)): (iter: Iter<V | Promise<V>>) => Promise<Map<K, V[]>>;25// export function groupBy<K, V>(f: (elem: EP<V>) => K): (iter: Iter<V>) => Promise<Map<EP<K>, EP<V>[]>>;26/**27 * https://github.com/rudty/nodekell#concat28 *29 * @param iter130 * @param iter231 */32export function concat<T, Y>(iter1: Iter<T | Promise<T>>, iter2: Iter<Y | Promise<Y>>): AsyncIterableIterator<T | Y>;33// export function concat<T, Y>(iter1: Iter<T>, iter2: Iter<Y>): AsyncIterableIterator<EP<T> | EP<Y>>;34export function concat<T extends Iter<any>, Y extends Iter<any>>(iter1: T, iter2: Y): AsyncIterableIterator<FlatForInternalFn<T> | FlatForInternalFn<Y>>;35export function concat<T extends Iter<any>, Y extends Iter<any>>(iter1: T): (iter2: Y) => AsyncIterableIterator<FlatForInternalFn<T> | FlatForInternalFn<Y>>;36export function concat<T, Y>(iter1: Iter<T | Promise<T>>): (iter2: Iter<Y | Promise<Y>>) => AsyncIterableIterator<T | Y>;37// export function concat<T, Y>(iter1: Iter<T>): (iter2: Iter<Y>) => AsyncIterableIterator<EP<T> | EP<Y>>;38/**39 * https://github.com/rudty/nodekell#union40 *41 * @param iter142 * @param iter243 */44export function union<T, Y>(iter1: Iter<T | Promise<T>>, iter2: Iter<Y | Promise<Y>>): AsyncIterableIterator<T | Y>;45// export function union<T, Y>(iter1: Iter<T>, iter2: Iter<Y>): AsyncIterableIterator<EP<T> | EP<Y>>;46export function union<T extends Iter<any>, Y extends Iter<any>>(iter1: T, iter2: Y): AsyncIterableIterator<FlatForInternalFn<T> | FlatForInternalFn<Y>>;47export function union<T extends Iter<any>, Y extends Iter<any>>(iter1: T): (iter2: Y) => AsyncIterableIterator<FlatForInternalFn<T> | FlatForInternalFn<Y>>;48export function union<T, Y>(iter1: Iter<T | Promise<T>>): (iter2: Iter<Y | Promise<Y>>) => AsyncIterableIterator<T | Y>;49// export function union<T, Y>(iter1: Iter<T>): (iter2: Iter<Y>) => AsyncIterableIterator<EP<T> | EP<Y>>;50export type CompareFn<T> = (a: T, b: T) => 1 | 0 | -1 | number;51export type OrderType = 'ASC' | 'DESC' | 'asc' | 'desc';52/**53 * ascending compare function54 *55 * @param a56 * @param b57 */58export function asc<T>(a: T, b: T): 1 | 0 | -1;59/**60 * descending compare function61 *62 * @param a63 * @param b64 */65export function desc<T>(a: T, b: T): 1 | 0 | -1;66/**67 * https://github.com/rudty/nodekell#orderby68 *69 * @param f70 * @param order71 * @param iter72 */73export function orderBy<T, S = T>(f: (e: T) => (S | Promise<S>), order: OrderType | CompareFn<S>, iter: Iter<T | Promise<T>>): AsyncIterableIterator<T>;74export function orderBy<T, S = T>(f: (e: T) => (S | Promise<S>), order: OrderType | CompareFn<S>): (iter: Iter<T | Promise<T>>) => AsyncIterableIterator<T>;75export function orderBy<T, S = T>(f: (e: T) => (S | Promise<S>)): CurriedFunction2<OrderType | CompareFn<S>, Iter<T | Promise<T>>, AsyncIterableIterator<T>>;76/**77 * https://github.com/rudty/nodekell#order78 *79 * ```ts80 * F.order(F.asc, iter);81 * // same as82 * F.orderBy(e => e, F.asc, iter);83 * ```84 *85 * @param order86 * @param iter87 */88export function order<T>(order: OrderType | CompareFn<EP<T>>, iter: Iter<T>): AsyncIterableIterator<EP<T>>;89export function order<T>(order: OrderType | CompareFn<EP<T>>): (iter: Iter<T>) => AsyncIterableIterator<EP<T>>;90/**91 * https://github.com/rudty/nodekell#innerjoin92 *93 * @param f94 * @param iter195 * @param iter296 */97export function innerJoin<T1 extends Map<ExtractMap<T1>[0], ExtractMap<T1>[1]>, T2 extends Map<ExtractMap<T2>[0], ExtractMap<T2>[1]>>(f: (elem1: T1 | Promise<T1>, elem2: T2 | Promise<T2>) => (boolean | Promise<boolean>), iter1: Iter<T1 | Promise<T1>>, iter2: Iter<T2 | Promise<T2>>): AsyncIterableIterator<InnerJoinMap<T1, T2>>;98export function innerJoin<T1 extends Map<ExtractMap<T1>[0], ExtractMap<T1>[1]>, T2 extends Map<ExtractMap<T2>[0], ExtractMap<T2>[1]>>(f: (elem1: T1 | Promise<T1>, elem2: T2 | Promise<T2>) => (boolean | Promise<boolean>), iter1: Iter<T1 | Promise<T1>>): (iter2: Iter<T2 | Promise<T2>>) => AsyncIterableIterator<InnerJoinMap<T1, T2>>;99export function innerJoin<T1 extends Map<ExtractMap<T1>[0], ExtractMap<T1>[1]>, T2 extends Map<ExtractMap<T2>[0], ExtractMap<T2>[1]>>(f: (elem1: T1 | Promise<T1>, elem2: T2 | Promise<T2>) => (boolean | Promise<boolean>)): CurriedFunction2<Iter<T1 | Promise<T1>>, Iter<T2 | Promise<T2>>, AsyncIterableIterator<InnerJoinMap<T1, T2>>>;100export function innerJoin<T1 extends object, T2 extends object>(f: (elem1: T1, elem2: T2) => (boolean | Promise<boolean>), iter1: Iter<T1 | Promise<T1>>, iter2: Iter<T2 | Promise<T2>>): AsyncIterableIterator<InnerJoinObject<T1, T2>>;101export function innerJoin<T1 extends object, T2 extends object>(f: (elem1: T1, elem2: T2) => (boolean | Promise<boolean>), iter1: Iter<T1 | Promise<T1>>): (iter2: Iter<T2 | Promise<T2>>) => AsyncIterableIterator<InnerJoinObject<T1, T2>>;102export function innerJoin<T1 extends object, T2 extends object>(f: (elem1: T2, elem2: T2) => (boolean | Promise<boolean>)): CurriedFunction2<Iter<T1 | Promise<T1>>, Iter<T2 | Promise<T2>>, AsyncIterableIterator<InnerJoinObject<T1, T2>>>;103/**104 * https://github.com/rudty/nodekell#leftinnerjoin105 *106 * as innerJoin107 *108 * @param f109 * @param iter1110 * @param iter2111 */112export function leftInnerJoin<T1 extends Map<ExtractMap<T1>[0], ExtractMap<T1>[1]>, T2 extends Map<ExtractMap<T2>[0], ExtractMap<T2>[1]>>(f: (elem1: T1 | Promise<T1>, elem2: T2 | Promise<T2>) => (boolean | Promise<boolean>), iter1: Iter<T1 | Promise<T1>>, iter2: Iter<T2 | Promise<T2>>): AsyncIterableIterator<InnerJoinMap<T1, T2>>;113export function leftInnerJoin<T1 extends Map<ExtractMap<T1>[0], ExtractMap<T1>[1]>, T2 extends Map<ExtractMap<T2>[0], ExtractMap<T2>[1]>>(f: (elem1: T1 | Promise<T1>, elem2: T2 | Promise<T2>) => (boolean | Promise<boolean>), iter1: Iter<T1 | Promise<T1>>): (iter2: Iter<T2 | Promise<T2>>) => AsyncIterableIterator<InnerJoinMap<T1, T2>>;114export function leftInnerJoin<T1 extends Map<ExtractMap<T1>[0], ExtractMap<T1>[1]>, T2 extends Map<ExtractMap<T2>[0], ExtractMap<T2>[1]>>(f: (elem1: T1 | Promise<T1>, elem2: T2 | Promise<T2>) => (boolean | Promise<boolean>)): CurriedFunction2<Iter<T1 | Promise<T1>>, Iter<T2 | Promise<T2>>, AsyncIterableIterator<InnerJoinMap<T1, T2>>>;115export function leftInnerJoin<T1 extends object, T2 extends object>(f: (elem1: T1, elem2: T2) => (boolean | Promise<boolean>), iter1: Iter<T1 | Promise<T1>>, iter2: Iter<T2 | Promise<T2>>): AsyncIterableIterator<InnerJoinObject<T1, T2>>;116export function leftInnerJoin<T1 extends object, T2 extends object>(f: (elem1: T1, elem2: T2) => (boolean | Promise<boolean>), iter1: Iter<T1 | Promise<T1>>): (iter2: Iter<T2 | Promise<T2>>) => AsyncIterableIterator<InnerJoinObject<T1, T2>>;117export function leftInnerJoin<T1 extends object, T2 extends object>(f: (elem1: T2, elem2: T2) => (boolean | Promise<boolean>)): CurriedFunction2<Iter<T1 | Promise<T1>>, Iter<T2 | Promise<T2>>, AsyncIterableIterator<InnerJoinObject<T1, T2>>>;118/**119 * https://github.com/rudty/nodekell#rightinnerjoin120 *121 * @param f122 * @param iter1123 * @param iter2124 */125export function rightInnerJoin<T1 extends Map<ExtractMap<T1>[0], ExtractMap<T1>[1]>, T2 extends Map<ExtractMap<T2>[0], ExtractMap<T2>[1]>>(f: (elem2: T2 | Promise<T2>, elem1: T1 | Promise<T1>) => (boolean | Promise<boolean>), iter1: Iter<T1 | Promise<T1>>, iter2: Iter<T2 | Promise<T2>>): AsyncIterableIterator<InnerJoinMap<T2, T1>>;126export function rightInnerJoin<T1 extends Map<ExtractMap<T1>[0], ExtractMap<T1>[1]>, T2 extends Map<ExtractMap<T2>[0], ExtractMap<T2>[1]>>(f: (elem2: T2 | Promise<T2>, elem1: T1 | Promise<T1>) => (boolean | Promise<boolean>), iter1: Iter<T1 | Promise<T1>>): (iter2: Iter<T2 | Promise<T2>>) => AsyncIterableIterator<InnerJoinMap<T2, T1>>;127export function rightInnerJoin<T1 extends Map<ExtractMap<T1>[0], ExtractMap<T1>[1]>, T2 extends Map<ExtractMap<T2>[0], ExtractMap<T2>[1]>>(f: (elem2: T2 | Promise<T2>, elem1: T1 | Promise<T1>) => (boolean | Promise<boolean>)): CurriedFunction2<Iter<T1 | Promise<T1>>, Iter<T2 | Promise<T2>>, AsyncIterableIterator<InnerJoinMap<T2, T1>>>;128export function rightInnerJoin<T1 extends object, T2 extends object>(f: (elem2: T2, elem1: T1) => (boolean | Promise<boolean>), iter1: Iter<T1 | Promise<T1>>, iter2: Iter<T2 | Promise<T2>>): AsyncIterableIterator<InnerJoinObject<T2, T1>>;129export function rightInnerJoin<T1 extends object, T2 extends object>(f: (elem2: T2, elem1: T1) => (boolean | Promise<boolean>), iter1: Iter<T1 | Promise<T1>>): (iter2: Iter<T2 | Promise<T2>>) => AsyncIterableIterator<InnerJoinObject<T2, T1>>;130export function rightInnerJoin<T1 extends object, T2 extends object>(f: (elem2: T2, elem1: T1) => (boolean | Promise<boolean>)): CurriedFunction2<Iter<T1 | Promise<T1>>, Iter<T2 | Promise<T2>>, AsyncIterableIterator<InnerJoinObject<T2, T1>>>;131/**132 * https://github.com/rudty/nodekell#outerjoin133 *134 * @param f135 * @param iter1136 * @param iter2137 */138export function outerJoin<T1 extends Map<ExtractMap<T1>[0], ExtractMap<T1>[1]>, T2 extends Map<ExtractMap<T2>[0], ExtractMap<T2>[1]>>(f: (elem1: T1, elem2: T2) => (boolean | Promise<boolean>), iter1: Iter<T1 | Promise<T1>>, iter2: Iter<T2 | Promise<T2>>): AsyncIterableIterator<OuterJoinMap<T1, T2>>;139export function outerJoin<T1 extends Map<ExtractMap<T1>[0], ExtractMap<T1>[1]>, T2 extends Map<ExtractMap<T2>[0], ExtractMap<T2>[1]>>(f: (elem1: T1, elem2: T2) => (boolean | Promise<boolean>), iter1: Iter<T1 | Promise<T1>>): (iter2: Iter<T2 | Promise<T2>>) => AsyncIterableIterator<OuterJoinMap<T1, T2>>;140export function outerJoin<T1 extends Map<ExtractMap<T1>[0], ExtractMap<T1>[1]>, T2 extends Map<ExtractMap<T2>[0], ExtractMap<T2>[1]>>(f: (elem1: T1, elem2: T2) => (boolean | Promise<boolean>)): CurriedFunction2<Iter<T1 | Promise<T1>>, Iter<T2 | Promise<T2>>, AsyncIterableIterator<OuterJoinMap<T1, T2>>>;141export function outerJoin<T1 extends object, T2 extends object>(f: (elem1: T1, elem2: T2) => (boolean | Promise<boolean>), iter1: Iter<T1 | Promise<T1>>, iter2: Iter<T2 | Promise<T2>>): AsyncIterableIterator<OuterJoinObject<T1, T2>>;142export function outerJoin<T1 extends object, T2 extends object>(f: (elem1: T1, elem2: T2) => (boolean | Promise<boolean>), iter1: Iter<T1 | Promise<T1>>): (iter2: Iter<T2 | Promise<T2>>) => AsyncIterableIterator<OuterJoinObject<T1, T2>>;143export function outerJoin<T1 extends object, T2 extends object>(f: (elem1: T1, elem2: T2) => (boolean | Promise<boolean>)): CurriedFunction2<Iter<T1 | Promise<T1>>, Iter<T2 | Promise<T2>>, AsyncIterableIterator<OuterJoinObject<T1, T2>>>;144/**145 * https://github.com/rudty/nodekell#leftouterjoin146 *147 * as outerJoin148 *149 * @param f150 * @param iter1151 * @param iter2152 */153export function leftOuterJoin<T1 extends Map<ExtractMap<T1>[0], ExtractMap<T1>[1]>, T2 extends Map<ExtractMap<T2>[0], ExtractMap<T2>[1]>>(f: (elem1: T1, elem2: T2) => (boolean | Promise<boolean>), iter1: Iter<T1 | Promise<T1>>, iter2: Iter<T2 | Promise<T2>>): AsyncIterableIterator<OuterJoinMap<T1, T2>>;154export function leftOuterJoin<T1 extends Map<ExtractMap<T1>[0], ExtractMap<T1>[1]>, T2 extends Map<ExtractMap<T2>[0], ExtractMap<T2>[1]>>(f: (elem1: T1, elem2: T2) => (boolean | Promise<boolean>), iter1: Iter<T1 | Promise<T1>>): (iter2: Iter<T2 | Promise<T2>>) => AsyncIterableIterator<OuterJoinMap<T1, T2>>;155export function leftOuterJoin<T1 extends Map<ExtractMap<T1>[0], ExtractMap<T1>[1]>, T2 extends Map<ExtractMap<T2>[0], ExtractMap<T2>[1]>>(f: (elem1: T1, elem2: T2) => (boolean | Promise<boolean>)): CurriedFunction2<Iter<T1 | Promise<T1>>, Iter<T2 | Promise<T2>>, AsyncIterableIterator<OuterJoinMap<T1, T2>>>;156export function leftOuterJoin<T1 extends object, T2 extends object>(f: (elem1: T1, elem2: T2) => (boolean | Promise<boolean>), iter1: Iter<T1 | Promise<T1>>, iter2: Iter<T2 | Promise<T2>>): AsyncIterableIterator<OuterJoinObject<T1, T2>>;157export function leftOuterJoin<T1 extends object, T2 extends object>(f: (elem1: T1, elem2: T2) => (boolean | Promise<boolean>), iter1: Iter<T1 | Promise<T1>>): (iter2: Iter<T2 | Promise<T2>>) => AsyncIterableIterator<OuterJoinObject<T1, T2>>;158export function leftOuterJoin<T1 extends object, T2 extends object>(f: (elem1: T1, elem2: T2) => (boolean | Promise<boolean>)): CurriedFunction2<Iter<T1 | Promise<T1>>, Iter<T2 | Promise<T2>>, AsyncIterableIterator<OuterJoinObject<T1, T2>>>;159/**160 * https://github.com/rudty/nodekell#rightouterjoin161 *162 * @param f163 * @param iter1164 * @param iter2165 */166export function rightOuterJoin<T1 extends Map<ExtractMap<T1>[0], ExtractMap<T1>[1]>, T2 extends Map<ExtractMap<T2>[0], ExtractMap<T2>[1]>>(f: (elem2: T2, elem1: T1) => (boolean | Promise<boolean>), iter1: Iter<T1 | Promise<T1>>, iter2: Iter<T2 | Promise<T2>>): AsyncIterableIterator<OuterJoinMap<T2, T1>>;167export function rightOuterJoin<T1 extends Map<ExtractMap<T1>[0], ExtractMap<T1>[1]>, T2 extends Map<ExtractMap<T2>[0], ExtractMap<T2>[1]>>(f: (elem2: T2, elem1: T1) => (boolean | Promise<boolean>), iter1: Iter<T1 | Promise<T1>>): (iter2: Iter<T2 | Promise<T2>>) => AsyncIterableIterator<OuterJoinMap<T2, T1>>;168export function rightOuterJoin<T1 extends Map<ExtractMap<T1>[0], ExtractMap<T1>[1]>, T2 extends Map<ExtractMap<T2>[0], ExtractMap<T2>[1]>>(f: (elem2: T2, elem1: T1) => (boolean | Promise<boolean>)): CurriedFunction2<Iter<T1 | Promise<T1>>, Iter<T2 | Promise<T2>>, AsyncIterableIterator<OuterJoinMap<T2, T1>>>;169export function rightOuterJoin<T1 extends object, T2 extends object>(f: (elem2: T2, elem1: T1) => (boolean | Promise<boolean>), iter1: Iter<T1 | Promise<T1>>, iter2: Iter<T2 | Promise<T2>>): AsyncIterableIterator<OuterJoinObject<T2, T1>>;170export function rightOuterJoin<T1 extends object, T2 extends object>(f: (elem2: T2, elem1: T1) => (boolean | Promise<boolean>), iter1: Iter<T1 | Promise<T1>>): (iter2: Iter<T2 | Promise<T2>>) => AsyncIterableIterator<OuterJoinObject<T2, T1>>;171export function rightOuterJoin<T1 extends object, T2 extends object>(f: (elem2: T2, elem1: T1) => (boolean | Promise<boolean>)): CurriedFunction2<Iter<T1 | Promise<T1>>, Iter<T2 | Promise<T2>>, AsyncIterableIterator<OuterJoinObject<T2, T1>>>;172/**173 * combine elements from two iterables based on the related elements between them.174 * works like TSQL175 * ---------------------176 * create table Orders(177 * orderID int,178 * customerID int,179 * info varchar(30)180 * );181 *182 * create table Customers(183 * customerID int,184 * customerName varchar(30)185 * );186 *187 * insert into Orders values(1,1,'t1');188 * insert into Orders values(2,1,'t2');189 * insert into Orders values(3,1,'t3');190 * insert into Orders values(4,2,'t4');191 * insert into Orders values(5,3,'t5');192 * insert into Orders values(6,4,'t6');193 *194 * insert into Customers values(1, 'ana');195 * insert into Customers values(2, 'cdn');196 * insert into Customers values(3, 'krw');197 * ---------------------198 * select (*)199 * from Customers C200 * join Orders O201 * on C.customerID = O.customerID202 * ---------------------203 * customerID, customerName, orderID, customerID, info204 * '1','ana','1','1','t1'205 * '1','ana','2','1','t2'206 * '1','ana','3','1','t3'207 * '2','cdn','4','2','t4'208 * '3','krw','5','3','t5'209 * ---------------------210 *211 * @param fn (elem1, elem2): bool | Promise<bool>212 * @param xs iterable213 * @param ys iterable214 */215export function innerJoin2<T1, T2>(joinFunc: (l: T1, r: T2) => boolean | Promise<boolean>, left: Iter<T1 | Promise<T1>>, right: Iter<T2 | Promise<T2>>): Promise<AsyncIterableIterator<PairRepeat<2, T1, T2>>>;216export function innerJoin2<T1, T2>(joinFunc: (l: T1, r: T2) => boolean | Promise<boolean>, left: Iter<T1 | Promise<T1>>): (right: Iter<T2 | Promise<T2>>) => Promise<AsyncIterableIterator<PairRepeat<2, T1, T2>>>;...
_joi_extract.ts
Source:_joi_extract.ts
1/** @format */2import 'joi';3/**4 * Helpers5 */6type Map<T> = { [P in keyof T]: T[P] };7type Diff<T, U> = T extends U ? never : T;8declare module 'joi' {9 /**10 * Field requirements interface11 */12 interface Box<T, R extends boolean> {13 /** Type the schema holds */14 T: T;15 /** If this attribute is required when inside an object */16 R: R;17 }18 type BoxType<B, nT> = B extends Box<infer oT, infer oR> ? Box<nT, oR> : B;19 type BoxUnion<B, nT> = B extends Box<infer oT, infer oR> ? Box<oT | nT, oR> : B;20 type BoxReq<B, nR extends boolean> = B extends Box<infer oT, infer oR> ? Box<oT, nR> : B;21 /**22 * Every Schema that implements the Box to allow the extraction23 */24 type BoxedPrimitive<T extends Box<any, any> = any> =25 | StringSchema<T>26 | NumberSchema<T>27 | BooleanSchema<T>28 | DateSchema<T>29 | FunctionSchema<T>30 | ArraySchema<T>31 | ObjectSchema<T>32 | AlternativesSchema<T>;33 // Base types34 type primitiveType = string | number | boolean | Function | Date | undefined | null | void;35 type thruthyPrimitiveType = NonNullable<primitiveType>;36 export type mappedSchema = SchemaLike | BoxedPrimitive;37 export type mappedSchemaMap<T = any> = { [K: string]: mappedSchema };38 // export type mappedSchemaMap<T extends mappedSchema = any> = { [K in keyof T]: T[K] };39 export type extendsGuard<T, S> = S extends T ? S : T;40 /**41 * Validation: extraction decorated methods42 */43 export function validate<T, S extends mappedSchemaMap>(44 value: T,45 schema: S,46 ): ValidationResult<extendsGuard<T, extractType<S>>>;47 export function validate<T, S extends mappedSchemaMap>(48 value: T,49 schema: S,50 options: ValidationOptions,51 ): ValidationResult<extendsGuard<T, extractType<S>>>;52 export function validate<T, R, S extends mappedSchemaMap>(53 value: T,54 schema: S,55 options: ValidationOptions,56 callback: (err: ValidationError, value: extendsGuard<T, extractType<S>>) => R,57 ): R;58 export function validate<T, R, S extends mappedSchemaMap>(59 value: T,60 schema: S,61 callback: (err: ValidationError, value: extendsGuard<T, extractType<S>>) => R,62 ): R;63 /**64 * String: extraction decorated schema65 */66 export interface StringSchema<N extends Box<string, boolean> = any> {67 default(): this;68 default(value: any, description?: string): this;69 default<T extends string>(value: T, description?: string): StringSchema<BoxType<N, N['T'] | T>>;70 valid<T extends string>(...values: T[]): StringSchema<BoxType<N, typeof values[number]>>;71 valid<T extends string>(values: T[]): StringSchema<BoxType<N, typeof values[number]>>;72 valid(...values: any[]): this;73 valid(values: any[]): this;74 required(): StringSchema<BoxReq<N, true>>;75 required(): this;76 exist(): StringSchema<BoxReq<N, true>>;77 exist(): this;78 optional(): StringSchema<BoxReq<N, false>>;79 optional(): this;80 }81 export function string<T extends string>(): StringSchema<{ T: extractType<T>; R: false }>;82 /**83 * Number: extraction decorated schema84 */85 export interface NumberSchema<N extends Box<number, boolean> = any> {86 default(): this;87 default(value: any, description?: string): this;88 default<T extends number>(value: T, description?: string): NumberSchema<BoxType<N, N['T'] | T>>;89 valid<T extends number>(...values: T[]): NumberSchema<BoxType<N, typeof values[number]>>;90 valid<T extends number>(values: T[]): NumberSchema<BoxType<N, typeof values[number]>>;91 valid(...values: any[]): this;92 valid(values: any[]): this;93 required(): NumberSchema<BoxReq<N, true>>;94 required(): this;95 exist(): NumberSchema<BoxReq<N, true>>;96 exist(): this;97 optional(): NumberSchema<BoxReq<N, false>>;98 optional(): this;99 }100 export function number<T extends number>(): NumberSchema<Box<extractType<T>, false>>;101 /**102 * Boolean: extraction decorated schema103 */104 export interface BooleanSchema<N extends Box<boolean, boolean> = any> {105 default(): this;106 default(value: any, description?: string): this;107 default<T extends boolean>(108 value: T,109 description?: string,110 ): BooleanSchema<BoxType<N, N['T'] | T>>;111 valid<T extends boolean>(...values: T[]): BooleanSchema<BoxType<N, typeof values[number]>>;112 valid<T extends boolean>(values: T[]): BooleanSchema<BoxType<N, typeof values[number]>>;113 valid(...values: any[]): this;114 valid(values: any[]): this;115 required(): BooleanSchema<BoxReq<N, true>>;116 required(): this;117 exist(): BooleanSchema<BoxReq<N, true>>;118 exist(): this;119 optional(): BooleanSchema<BoxReq<N, false>>;120 optional(): this;121 }122 export function boolean<T extends boolean>(): BooleanSchema<Box<T, false>>;123 export function bool<T extends boolean>(): BooleanSchema<Box<T, false>>;124 /**125 * Date: extraction decorated schema126 */127 export interface DateSchema<N extends Box<Date, boolean> = any> {128 default(): this;129 default(value: any, description?: string): this;130 default<T extends Date>(value: T, description?: string): DateSchema<BoxType<N, N['T'] | T>>;131 valid<T extends Date>(...values: T[]): DateSchema<BoxType<N, typeof values[number]>>;132 valid<T extends Date>(values: T[]): DateSchema<BoxType<N, typeof values[number]>>;133 valid(...values: any[]): this;134 valid(values: any[]): this;135 required(): DateSchema<BoxReq<N, true>>;136 required(): this;137 exist(): DateSchema<BoxReq<N, true>>;138 exist(): this;139 optional(): DateSchema<BoxReq<N, false>>;140 optional(): this;141 }142 export function date<T extends Date>(): DateSchema<Box<T, false>>;143 // TOOD: implement DecoratedExtractedValue at:144 // T extends DateSchema145 // T extends FunctionSchema146 /**147 * Function: extraction decorated schema148 */149 export interface FunctionSchema<N extends Box<Function, boolean> = any> {150 required(): FunctionSchema<BoxReq<N, true>>;151 required(): this;152 exist(): FunctionSchema<BoxReq<N, true>>;153 exist(): this;154 optional(): FunctionSchema<BoxReq<N, false>>;155 optional(): this;156 }157 export function func<T extends Function>(): FunctionSchema<Box<T, false>>;158 /**159 * Array: extraction decorated schema160 */161 export interface ArraySchema<N = null> {162 items<T extends mappedSchema>(163 type: T,164 ): this extends ArraySchema<infer O>165 ? O extends Box<infer oT, infer oR>166 ? ArraySchema<BoxType<O, oT | extractType<T>>>167 : ArraySchema<Box<extractType<T>, false>>168 : ArraySchema<Box<extractType<T>, false>>;169 required(): ArraySchema<BoxReq<N, true>>;170 required(): this;171 exist(): ArraySchema<BoxReq<N, true>>;172 exist(): this;173 optional(): ArraySchema<BoxReq<N, false>>;174 optional(): this;175 }176 export function array(): ArraySchema<Box<never, false>>;177 /**178 * Object: extraction decorated schema179 */180 export interface ObjectSchema<N = null> extends AnySchema {181 keys<T extends mappedSchemaMap>(182 schema: T,183 ): this extends ObjectSchema<infer O>184 ? O extends Box<infer oT, infer oR>185 ? ObjectSchema<BoxType<O, oT & extractMap<T>>>186 : ObjectSchema<Box<extractMap<T>, false>>187 : ObjectSchema<Box<extractMap<T>, false>>;188 pattern<S extends StringSchema, T extends mappedSchema>(189 pattern: S,190 schema: T,191 ): this extends ObjectSchema<infer O>192 ? O extends Box<infer oT, infer oR>193 ? ObjectSchema<BoxType<O, oT | extractMap<{ [key in extractType<S>]: T }>>>194 : ObjectSchema<Box<extractMap<{ [key in extractType<S>]: T }>, false>>195 : ObjectSchema<Box<extractMap<{ [key in extractType<S>]: T }>, false>>;196 pattern<T extends mappedSchema>(197 pattern: RegExp,198 schema: T,199 ): this extends ObjectSchema<infer O>200 ? O extends Box<infer oT, infer oR>201 ? ObjectSchema<BoxType<O, oT | extractMap<{ [key: string]: T }>>>202 : ObjectSchema<Box<extractMap<{ [key: string]: T }>, false>>203 : ObjectSchema<Box<extractMap<{ [key: string]: T }>, false>>;204 // this extends ObjectSchema<infer O>205 // ? (O extends null206 // ? ObjectSchema<extractMap<{ [key: string]: T }>>207 // : ObjectSchema<extractMap<{ [key: string]: T }> | O>)208 // : ObjectSchema<extractMap<{ [key: string]: T }>>;209 pattern(pattern: RegExp | SchemaLike, schema: SchemaLike): this;210 required(): ObjectSchema<BoxReq<N, true>>;211 required(): this;212 exist(): ObjectSchema<BoxReq<N, true>>;213 exist(): this;214 optional(): ObjectSchema<BoxReq<N, false>>;215 optional(): this;216 }217 export function object<T extends mappedSchemaMap>(218 schema: T,219 ): ObjectSchema<Box<extractMap<T>, false>>;220 /**221 * Alternatives: extraction decorated schema222 */223 export interface AlternativesSchema<N = any> extends AnySchema {224 try<T extends mappedSchema[]>(225 ...values: T226 ): this extends AlternativesSchema<infer O>227 ? O extends Box<infer oT, infer oR>228 ? AlternativesSchema<BoxType<O, oT | extractType<T>>>229 : AlternativesSchema<Box<extractType<T>, false>>230 : AlternativesSchema<Box<extractType<T>, false>>;231 try<T extends mappedSchema[]>(232 values: T,233 ): this extends AlternativesSchema<infer O>234 ? O extends Box<infer oT, infer oR>235 ? AlternativesSchema<BoxType<O, oT | extractType<T>>>236 : AlternativesSchema<Box<extractType<T>, false>>237 : AlternativesSchema<Box<extractType<T>, false>>;238 try(...types: SchemaLike[]): this;239 try(types: SchemaLike[]): this;240 required(): AlternativesSchema<BoxReq<N, true>>;241 required(): this;242 exist(): AlternativesSchema<BoxReq<N, true>>;243 exist(): this;244 optional(): AlternativesSchema<BoxReq<N, false>>;245 optional(): this;246 when<247 R,248 T1 extends mappedSchema,249 T2 extends mappedSchema,250 T extends { then: T1; otherwise: T2 }251 >(252 ref: R,253 defs: T,254 ): this extends AlternativesSchema<infer O>255 ? O extends Box<infer oT, infer oR>256 ? AlternativesSchema<BoxType<O, oT | extractType<T['then']> | extractType<T['otherwise']>>>257 : AlternativesSchema<Box<extractType<T['then']> | extractType<T['otherwise']>, false>>258 : AlternativesSchema<Box<extractType<T['then']> | extractType<T['otherwise']>, false>>;259 }260 export function alternatives<T extends mappedSchema[]>(261 ...alts: T262 ): AlternativesSchema<Box<extractType<typeof alts[number]>, false>>;263 export function alternatives<T extends mappedSchema[]>(264 alts: T,265 ): AlternativesSchema<Box<extractType<typeof alts[number]>, false>>;266 export function alt<T extends mappedSchema[]>(267 ...alts: T268 ): AlternativesSchema<Box<extractType<typeof alts[number]>, false>>;269 export function alt<T extends mappedSchema[]>(270 alts: T,271 ): AlternativesSchema<Box<extractType<typeof alts[number]>, false>>;272 // Required | Optional properties engine273 type FilterVoid<T extends string | number | symbol, O extends any> = {274 [K in T extends string | number | symbol275 ? O[T] extends null | undefined | void276 ? never277 : T278 : never]: O[K];279 };280 type MarkRequired<T, B> = {281 [K in keyof T]: T[K] extends BoxedPrimitive<infer D>282 ? D['R'] extends B283 ? T[K]284 : void285 : B extends false286 ? T[K]287 : void;288 };289 type Required<T> = FilterVoid<keyof T, MarkRequired<T, true>>;290 type Optional<T> = FilterVoid<keyof T, MarkRequired<T, false>>;291 type extractMap<T extends mappedSchemaMap> = Map<292 { [K in keyof Optional<T>]?: extractType<T[K]> } &293 { [K in keyof Required<T>]: extractType<T[K]> }294 >;295 type maybeExtractBox<T> = T extends Box<infer O, infer R> ? O : T;296 // prettier-ignore297 type extractOne<T extends mappedSchema> =298 /** Primitive types */299 T extends primitiveType ? T :300 /** Holds the extracted type */301 T extends BooleanSchema<infer O> ? maybeExtractBox<O> :302 T extends StringSchema<infer O> ? maybeExtractBox<O> :303 T extends NumberSchema<infer O> ? maybeExtractBox<O> :304 T extends DateSchema<infer O> ? maybeExtractBox<O> :305 T extends FunctionSchema<infer O> ? maybeExtractBox<O> :306 T extends ArraySchema<infer O> ? maybeExtractBox<O>[] :307 T extends ObjectSchema<infer O> ? maybeExtractBox<O> :308 /** Supports Joi.alternatives(Schema1, schema2, ...) */309 T extends AlternativesSchema<infer O> ? maybeExtractBox<O> :310 T extends mappedSchemaMap<infer O> ? maybeExtractBox<O> :311 T extends AnySchema ? any :312 any;313 // prettier-ignore314 export type extractType<T extends mappedSchema> =315 /**316 * Hack to support [Schema1, Schema2, ...N] alternatives notation317 * Can't use extractType directly here because of cycles:318 * ```319 * T extends Array<infer O> ? extractType<O> :320 * ^ cycle321 * ```322 */323 T extends Array<infer O> ? (324 O extends mappedSchema ? extractOne<O> : O325 ) :326 /**327 * Handle Objects as schemas, without Joi.object at the root.328 * It needs to come first than mappedSchema.329 * It is difficult to avoid it to be inferred from extends clause.330 */331 T extends mappedSchemaMap ? extractMap<T> :332 /**333 * This is the base case for every schema implemented334 */335 T extends mappedSchema ? extractOne<T> :336 /**337 * Default case to handle primitives and schemas338 */339 extractOne<T>;...
schemas.d.ts
Source:schemas.d.ts
1import Joi from '@hapi/joi';2import "joi-extract-type";3export declare const ChangedPairingSchema: Joi.BoxObjectSchema<Joi.Box<Joi.extractMap<{4 text: Joi.BoxStringSchema<Joi.Box<string, true>>;5 changed: Joi.BoxBooleanSchema<Joi.Box<boolean, false>>;6 commited: Joi.BoxBooleanSchema<Joi.Box<boolean, false>>;7}>, false>>;8export declare const YourVoiceTranscriptTheirVoiceSchema: Joi.BoxObjectSchema<Joi.Box<Joi.extractMap<{9 yourVoice: Joi.BoxObjectSchema<Joi.Box<Joi.extractMap<{10 text: Joi.BoxStringSchema<Joi.Box<string, true>>;11 changed: Joi.BoxBooleanSchema<Joi.Box<boolean, false>>;12 commited: Joi.BoxBooleanSchema<Joi.Box<boolean, false>>;13 }>, true>>;14 transcript: Joi.BoxObjectSchema<Joi.Box<Joi.extractMap<{15 text: Joi.BoxStringSchema<Joi.Box<string, true>>;16 changed: Joi.BoxBooleanSchema<Joi.Box<boolean, false>>;17 commited: Joi.BoxBooleanSchema<Joi.Box<boolean, false>>;18 }>, true>>;19 theirVoice: Joi.BoxObjectSchema<Joi.Box<Joi.extractMap<{20 text: Joi.BoxStringSchema<Joi.Box<string, true>>;21 changed: Joi.BoxBooleanSchema<Joi.Box<boolean, false>>;22 commited: Joi.BoxBooleanSchema<Joi.Box<boolean, false>>;23 }>, true>>;24 characterId: Joi.BoxStringSchema<Joi.Box<string, true>>;25 soundId: Joi.BoxStringSchema<Joi.Box<string, false>>;26}>, false>>;27export declare const ListYourVoiceTranscriptTheirVoiceSchema: Joi.BoxObjectSchema<Joi.Box<Joi.extractMap<{28 items: Joi.BoxArraySchema<Joi.Box<Joi.extractMap<{29 yourVoice: Joi.BoxObjectSchema<Joi.Box<Joi.extractMap<{30 text: Joi.BoxStringSchema<Joi.Box<string, true>>;31 changed: Joi.BoxBooleanSchema<Joi.Box<boolean, false>>;32 commited: Joi.BoxBooleanSchema<Joi.Box<boolean, false>>;33 }>, true>>;34 transcript: Joi.BoxObjectSchema<Joi.Box<Joi.extractMap<{35 text: Joi.BoxStringSchema<Joi.Box<string, true>>;36 changed: Joi.BoxBooleanSchema<Joi.Box<boolean, false>>;37 commited: Joi.BoxBooleanSchema<Joi.Box<boolean, false>>;38 }>, true>>;39 theirVoice: Joi.BoxObjectSchema<Joi.Box<Joi.extractMap<{40 text: Joi.BoxStringSchema<Joi.Box<string, true>>;41 changed: Joi.BoxBooleanSchema<Joi.Box<boolean, false>>;42 commited: Joi.BoxBooleanSchema<Joi.Box<boolean, false>>;43 }>, true>>;44 characterId: Joi.BoxStringSchema<Joi.Box<string, true>>;45 soundId: Joi.BoxStringSchema<Joi.Box<string, false>>;46 }>, true>>;47}>, false>>;...
Using AI Code Generation
1const { extractMap } = require('fast-check-monorepo');2const map = new Map();3map.set('key1', 'value1');4map.set('key2', 'value2');5console.log(extractMap(map));6const { extractSet } = require('fast-check-monorepo');7const set = new Set();8set.add('value1');9set.add('value2');10console.log(extractSet(set));11const { extractMap } = require('fast-check-monorepo');12const map = new Map();13map.set('key1', 'value1');14map.set('key2', 'value2');15console.log(extractMap(map));16const { extractSet } = require('fast-check-monorepo');17const set = new Set();18set.add('value1');19set.add('value2');20console.log(extractSet(set));21const { extractMap } = require('fast-check-monorepo');22const map = new Map();23map.set('key1', 'value1');24map.set('key2', 'value2');25console.log(extractMap(map));26const { extractSet } = require('fast-check-monorepo');27const set = new Set();28set.add('value1');29set.add('value2');30console.log(extractSet(set));31const { extractMap } = require('fast-check-monorepo');32const map = new Map();33map.set('key1', '
Using AI Code Generation
1const { extractMap } = require("fast-check");2const { fc } = require("fast-check");3const { property } = require("fast-check");4const { pre } = require("fast-check");5const { post } = require("fast-check");6const { tuple } = require("fast-check");7const { record } = require("fast-chec
Using AI Code Generation
1const { extractMap } = require("fast-check-monorepo");2const { extractMap } = require("fast-check-monorepo");3const myMap = extractMap({4});5const { extractMap } = require("fast-check");6const { extractMap } = require("fast-check");7const myMap = extractMap({8});9const { extractMap } = require("fast-check-monorepo");10const { extractMap } = require("fast-check-monorepo");11const myMap = extractMap({12});13const { extractMap } = require("fast-check");14const { extractMap } = require("fast-check");15const myMap = extractMap({16});17const { extractMap } = require("fast-check-monorepo");18const { extractMap } = require("fast-check-monorepo");19const myMap = extractMap({20});21const { extractMap } = require("fast-check");22const { extractMap } = require("fast-check");23const myMap = extractMap({24});25const { extractMap } = require("fast-check-monorepo");26const { extractMap } = require("fast-check-monorepo");27const myMap = extractMap({28});29const { extractMap } = require("fast-check");30const { extractMap } = require("fast-check");31const myMap = extractMap({
Using AI Code Generation
1const { extractMap } = require('fast-check');2const arb = extractMap(3 fc.integer(),4 fc.string(),5 (k, v) => `${k} -> ${v}`6);7fc.assert(8 fc.property(arb, m => {9 })10);11const arb = extractMap(fc.string(), fc.integer());12const arb = extractMap(13 fc.date(),14 fc.string(),15 (k, v) => [k.toISOString(), v]16);17const arb = extractMap(18 fc.date(),19 fc.string(),20 (k, v) => [k.toISOString(), v]21);22const arb = extractMap(fc.string(), fc.integer());
Using AI Code Generation
1const { extractMap } = require('fast-check-monorepo');2const map = extractMap('test1.js', 'test2.js');3console.log(map);4const { extractMap } = require('fast-check-monorepo');5const map = extractMap('test1.js', 'test3.js');6console.log(map);7const { extractMap } = require('fast-check-monorepo');8const map = extractMap('test1.js', 'test4.js');9console.log(map);10const { extractMap } = require('fast-check-monorepo');11const map = extractMap('test1.js', 'test5.js');12console.log(map);13const { extractMap } = require('fast-check-monorepo');14const map = extractMap('test1.js', 'test6.js');15console.log(map);16const { extractMap } = require('fast-check-monorepo');17const map = extractMap('test1.js', 'test7.js');18console.log(map);
Using AI Code Generation
1const { extractMap } = require('@fast-check/runner');2const { property } = require('ava-fast-check');3const { map } = require('lodash');4const { isString } = require('lodash');5const { isNumber } = require('lodash');6property('extractMap', [map(isString, isNumber)], (t, aMap) => {7 const extractedMap = extractMap(aMap);8 t.deepEqual(extractedMap, aMap);9});10const { extractMap } = require('@fast-check/runner');11const { property } = require('ava-fast-check');12const { map } = require('lodash');13const { isString } = require('lodash');14const { isNumber } = require('lodash');15property('extractMap', [map(isString, isNumber)], (t, aMap) => {16 const extractedMap = extractMap(aMap);17 t.deepEqual(extractedMap, aMap);18});19const { extractMap } = require('@fast-check/runner');20const { property } = require('ava-fast-check');21const { map } = require('lodash');22const { isString } = require('lodash');23const { isNumber } = require('lodash');24property('extractMap', [map(isString, isNumber)], (t, aMap) => {25 const extractedMap = extractMap(aMap);26 t.deepEqual(extractedMap, aMap);27});28const { extractMap } = require('@fast-check/runner');29const { property } = require('ava-fast-check');30const { map } = require('lodash');31const { isString } = require('lodash');32const { isNumber } = require('lodash');33property('extractMap', [map(isString, isNumber)], (t, aMap) => {34 const extractedMap = extractMap(aMap);35 t.deepEqual(extractedMap, aMap);36});
Using AI Code Generation
1var fastCheck = require('fast-check');2var extractMap = fastCheck.extractMap;3var map = extractMap();4var randomString = fastCheck.map(map);5console.log(randomString);6var fastCheck = require('fast-check');7var extractMap = fastCheck.extractMap;8var map = extractMap();9var randomString = fastCheck.map(map);10console.log(randomString);11var fastCheck = require('fast-check');12var extractMap = fastCheck.extractMap;13var map = extractMap();14var randomString = fastCheck.map(map);15console.log(randomString);16var fastCheck = require('fast-check');17var extractMap = fastCheck.extractMap;18var map = extractMap();19var randomString = fastCheck.map(map);20console.log(randomString);21var fastCheck = require('fast-check');22var extractMap = fastCheck.extractMap;23var map = extractMap();24var randomString = fastCheck.map(map);25console.log(randomString);26var fastCheck = require('fast-check');27var extractMap = fastCheck.extractMap;
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!