as-procedure
Version:
easily create procedures within a pit-of-success
10 lines (9 loc) • 701 B
TypeScript
import type { Procedure } from 'domain-glossary-procedure';
import type { Serializable } from 'serde-fns';
import type { NotNull } from 'type-fns';
type AsExpectOutkey<R extends Record<string, Serializable | null>> = <K extends keyof R, O extends R[K]>(key: K, operation: 'isPresent') => Promise<Record<K, NotNull<O>>>;
export type WithExpectOutkey<TLogic extends (...args: any[]) => Promise<Record<string, any>>> = (...args: Parameters<TLogic>) => ReturnType<TLogic> & {
expect: AsExpectOutkey<Awaited<ReturnType<TLogic>>>;
};
export declare const withExpectOutkey: <I, C, O extends Promise<Record<string, any>>>(procedure: Procedure<I, C, O>) => WithExpectOutkey<Procedure<I, C, O>>;
export {};