dynamodb-toolbox
Version:
Lightweight and type-safe query builder for DynamoDB and TypeScript.
18 lines (17 loc) • 1.41 kB
TypeScript
import type { DecodedValue, FormattedValue, ReadValueOptions, Schema, TransformedValue } from '../../../schema/index.js';
import { SchemaAction } from '../../../schema/index.js';
import type { FormatValueOptions, InferReadValueOptions } from './options.js';
export type FormatterYield<SCHEMA extends Schema, OPTIONS extends FormatValueOptions<SCHEMA> = {}, READ_VALUE_OPTIONS extends ReadValueOptions<SCHEMA> = InferReadValueOptions<SCHEMA, OPTIONS>> = OPTIONS extends {
transform: false;
} | {
format: false;
} ? never : DecodedValue<SCHEMA, READ_VALUE_OPTIONS>;
export type FormatterReturn<SCHEMA extends Schema, OPTIONS extends FormatValueOptions<SCHEMA> = {}, READ_VALUE_OPTIONS extends ReadValueOptions<SCHEMA> = InferReadValueOptions<SCHEMA, OPTIONS>> = OPTIONS extends {
format: false;
} ? DecodedValue<SCHEMA, READ_VALUE_OPTIONS> : FormattedValue<SCHEMA, READ_VALUE_OPTIONS>;
export declare class Formatter<SCHEMA extends Schema = Schema> extends SchemaAction<SCHEMA> {
static actionName: "format";
start<OPTIONS extends FormatValueOptions<SCHEMA> = {}>(inputValue: unknown, options?: OPTIONS): Generator<FormatterYield<SCHEMA, OPTIONS>, FormatterReturn<SCHEMA, OPTIONS>>;
format<OPTIONS extends FormatValueOptions<SCHEMA> = {}>(inputValue: unknown, options?: OPTIONS): FormatterReturn<SCHEMA, OPTIONS>;
validate(inputValue: unknown): inputValue is TransformedValue<SCHEMA>;
}