UNPKG

dynamodb-toolbox

Version:

Lightweight and type-safe query builder for DynamoDB and TypeScript.

18 lines (17 loc) 2.19 kB
import type { EntityAttrDefaultOptions, EntityAttrOptions, TimestampsDefaultOptions, TimestampsOptions } from './options.js'; export type IsTimestampEnabled<TIMESTAMP_OPTIONS extends TimestampsOptions, TIMESTAMP extends 'created' | 'modified'> = TIMESTAMP_OPTIONS extends true | { [KEY in TIMESTAMP]: true | Record<string, unknown>; } ? true : false; export declare const isTimestampEnabled: <TIMESTAMP_OPTIONS extends TimestampsOptions, TIMESTAMP_KEY extends "created" | "modified">(timestampOptions: TIMESTAMP_OPTIONS, timestampKey: TIMESTAMP_KEY) => IsTimestampEnabled<TIMESTAMP_OPTIONS, TIMESTAMP_KEY>; export type TimestampOptionValue<TIMESTAMP_OPTIONS extends TimestampsOptions, TIMESTAMP_KEY extends 'created' | 'modified', OPTION_KEY extends 'name' | 'savedAs' | 'hidden'> = TIMESTAMP_OPTIONS extends { [KEY in TIMESTAMP_KEY]: { [KEY in OPTION_KEY]: unknown; }; } ? TIMESTAMP_OPTIONS[TIMESTAMP_KEY][OPTION_KEY] : TimestampsDefaultOptions[TIMESTAMP_KEY][OPTION_KEY]; export declare const getTimestampOptionValue: <TIMESTAMP_OPTIONS extends TimestampsOptions, TIMESTAMP_KEY extends "created" | "modified", OPTION_KEY extends "name" | "savedAs" | "hidden">(timestampsOptions: TIMESTAMP_OPTIONS, timestampKey: TIMESTAMP_KEY, optionKey: OPTION_KEY) => TimestampOptionValue<TIMESTAMP_OPTIONS, TIMESTAMP_KEY, OPTION_KEY>; export type IsEntityAttrEnabled<ENTITY_ATTR_OPTIONS extends EntityAttrOptions> = ENTITY_ATTR_OPTIONS extends true | Record<string, unknown> ? true : false; export declare const isEntityAttrEnabled: <ENTITY_ATTR_OPTIONS extends EntityAttrOptions>(entityAttrOptions: ENTITY_ATTR_OPTIONS) => IsEntityAttrEnabled<ENTITY_ATTR_OPTIONS>; export type EntityAttrOptionValue<ENTITY_ATTR_OPTIONS extends EntityAttrOptions, OPTION_KEY extends 'name' | 'hidden'> = ENTITY_ATTR_OPTIONS extends { [KEY in OPTION_KEY]: unknown; } ? ENTITY_ATTR_OPTIONS[OPTION_KEY] : EntityAttrDefaultOptions[OPTION_KEY]; export declare const getEntityAttrOptionValue: <ENTITY_ATTR_OPTIONS extends EntityAttrOptions, OPTION_KEY extends "name" | "hidden">(entityAttrOptions: ENTITY_ATTR_OPTIONS, optionKey: OPTION_KEY) => EntityAttrOptionValue<ENTITY_ATTR_OPTIONS, OPTION_KEY>;