dynamodb-toolbox
Version:
Lightweight and type-safe query builder for DynamoDB and TypeScript.
21 lines (20 loc) • 1.13 kB
TypeScript
import { z } from 'zod';
import type { MapSchema } from '../../../../schema/index.js';
import type { Overwrite } from '../../../../types/overwrite.js';
import type { SelectKeys } from '../../../../types/selectKeys.js';
import type { WithValidate } from '../utils.js';
import type { SchemaZodParser } from './schema.js';
import type { ZodParserOptions } from './types.js';
import type { WithAttributeNameEncoding, WithDefault, WithOptional } from './utils.js';
export type MapZodParser<SCHEMA extends MapSchema, OPTIONS extends ZodParserOptions = {}> = MapSchema extends SCHEMA ? z.ZodTypeAny : WithAttributeNameEncoding<SCHEMA, OPTIONS, WithDefault<SCHEMA, OPTIONS, WithOptional<SCHEMA, OPTIONS, WithValidate<SCHEMA, z.ZodObject<{
[KEY in OPTIONS extends {
mode: 'key';
} ? SelectKeys<SCHEMA['attributes'], {
props: {
key: true;
};
}> : keyof SCHEMA['attributes']]: SchemaZodParser<SCHEMA['attributes'][KEY], Overwrite<OPTIONS, {
defined: false;
}>>;
}, 'strip'>>>>>;
export declare const mapZodParser: (schema: MapSchema, options?: ZodParserOptions) => z.ZodTypeAny;