UNPKG

dynamodb-toolbox

Version:

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

27 lines (26 loc) 1.64 kB
import type { SchemaAction } from '../../schema/index.js'; import type { ResetLinks } from '../../schema/utils/resetLinks.js'; import type { NarrowObject } from '../../types/index.js'; import type { Light, LightObj } from '../utils/light.js'; import { ItemSchema } from './schema.js'; import type { ItemAttributes } from './types.js'; type ItemSchemer = <ATTRIBUTES extends ItemAttributes>(attributes: NarrowObject<ATTRIBUTES>) => ItemSchema_<LightObj<ATTRIBUTES>>; /** * Define a new item schema * * @param attributes Dictionary of attributes */ export declare const item: ItemSchemer; export declare class ItemSchema_<ATTRIBUTES extends ItemAttributes = ItemAttributes> extends ItemSchema<ATTRIBUTES> { pick<ATTRIBUTE_NAMES extends (keyof ATTRIBUTES)[]>(...attributeNames: ATTRIBUTE_NAMES): ItemSchema_<{ [KEY in ATTRIBUTE_NAMES[number]]: ResetLinks<ATTRIBUTES[KEY]>; }>; omit<ATTRIBUTE_NAMES extends (keyof ATTRIBUTES)[]>(...attributeNames: ATTRIBUTE_NAMES): ItemSchema_<{ [KEY in Exclude<keyof ATTRIBUTES, ATTRIBUTE_NAMES[number]>]: ResetLinks<ATTRIBUTES[KEY]>; }>; and<ADDITIONAL_ATTRIBUTES extends ItemAttributes = ItemAttributes>(additionalAttr: NarrowObject<ADDITIONAL_ATTRIBUTES> | ((schema: this) => NarrowObject<ADDITIONAL_ATTRIBUTES>)): ItemSchema_<{ [KEY in keyof ATTRIBUTES | keyof ADDITIONAL_ATTRIBUTES]: KEY extends keyof ADDITIONAL_ATTRIBUTES ? Light<ADDITIONAL_ATTRIBUTES[KEY]> : KEY extends keyof ATTRIBUTES ? ATTRIBUTES[KEY] : never; }>; build<ACTION extends SchemaAction<this> = SchemaAction<this>>(Action: new (schema: this) => ACTION): ACTION; } export {};