import { DynamoEntity } from './entity.js'; export { DynamoEntityConfig, EntityKeyInput } from './entity.js'; export { DynamoIndexKey, DynamoIndexKeyBuilder, DynamoIndexKeyableValue, DynamoKey, DynamoKeyBuilder, DynamoKeyableValue, GlobalSecondaryIndexKeyBuilders, LocalSecondaryIndexKeyBuilders, indexKey, key } from './key.js'; export { DynamoTable, DynamoTableConfig } from './table.js'; import { ZodType, output, input } from 'zod/v4'; import { TransactWriteItem, ConditionCheck, Put, Delete, Update } from '@aws-sdk/client-dynamodb'; import { NativeAttributeValue } from '@aws-sdk/lib-dynamodb'; /** * Constrains a Zod schema to types whose output is an object (record of key-value pairs). * * This is broader than `ZodObject` — it also accepts discriminated unions, * unions of objects, intersections, and other Zod types that produce object outputs. */ type ObjectLikeZodType = ZodType>; /** * Parses a partial object from a schema, calling `.partial()` when available (ZodObject) * and falling back to `.parseAsync()` for other object-like schemas. */ declare function parsePartial(schema: Schema, data: unknown): Promise>>; /** * Utility type used to derive the type from the Zod schema definition. Mainly for internal use. * * To get the schema type from an entity use [`Entity`](/api-reference/type-aliases/entity) instead. */ type EntitySchema = output; /** * Utility type used to derive the input type from the Zod schema definition. Mainly for internal use. * * To get the input schema type from an entity use [`EncodedEntity`](/api-reference/type-aliases/encodedentity) instead. */ type EncodedEntitySchema = input; /** * Utility type to derive the type of a DynamoEntity's schema. * * This is the Zod *output* type of a Zod schema (the type after a codec has been applied). * It is the equivalent of `z.infer` or `z.output`. * * @example * ```ts * import { DynamoTable, DynamoEntity, type Entity } from 'dynamo-document-builder'; * import { z } from 'zod'; * * const table = new DynamoTable({ * tableName: 'ExampleTable', * documentClient, * }); * * const userEntity = new DynamoEntity({ * table, * schema: z.object({ * id: z.string(), * name: z.string(), * age: z.number().optional(), * }), * partitionKey: user => key('USER', user.id), * sortKey: user => 'USER', * }); * * type User = Entity; */ type Entity> = output; /** * Utility type to derive the input type of a DynamoEntity's schema. * * This is the Zod *input* type of a Zod schema (the type before a codec has been applied). * It is the equivalent of `z.input`. * * @example * ```ts * import { DynamoTable, DynamoEntity, type EncodedEntity } from 'dynamo-document-builder'; * import { z } from 'zod'; * * const table = new DynamoTable({ * tableName: 'ExampleTable', * documentClient, * }); * * const isoDatetimeToDate = z.codec(z.iso.datetime(), z.date(), { * decode: isoString => new Date(isoString), * encode: date => date.toISOString(), * }); * * const checkinEntity = new DynamoEntity({ * table, * schema: z.object({ * id: z.string(), * timestamp: isoDatetimeToDate, * }), * }); * * type EncodedUser = EncodedEntity; * * // EncodedUser is: * // { * // id: string; * // timestamp: string; // ISO datetime string * // } * ``` */ type EncodedEntity> = input; /** * Type used to indicate the name of a DynamoDB secondary index. */ type IndexName = string; /** * Type representing the key names for a **global** secondary index. */ type GlobalSecondaryIndexKeyName = { partitionKey: string; sortKey?: string; }; /** * Type representing the key names for a **local** secondary index. */ type LocalSecondaryIndexKeyName = { sortKey: string; }; /** * Type mapping index names to their corresponding global secondary index key names. */ type NamedGlobalSecondaryIndexKeyNames = Record; /** * Type mapping index names to their corresponding local secondary index key names. */ type NamedLocalSecondaryIndexKeyNames = Record; /** * A modified version of TransactWriteItem that uses NativeAttributeValue for keys and items * (dynamodb-lib doesnt export this type for some reason). * * See: https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-lib-dynamodb/TypeAlias/TransactWriteCommandInput/ */ type TransactWriteOperation = Omit & { ConditionCheck?: (Omit & { Key: Record | undefined; ExpressionAttributeValues?: Record | undefined; }) | undefined; Put?: (Omit & { Item: Record | undefined; ExpressionAttributeValues?: Record | undefined; }) | undefined; Delete?: (Omit & { Key: Record | undefined; ExpressionAttributeValues?: Record | undefined; }) | undefined; Update?: (Omit & { Key: Record | undefined; ExpressionAttributeValues?: Record | undefined; }) | undefined; }; export { DynamoEntity, parsePartial }; export type { EncodedEntity, EncodedEntitySchema, Entity, EntitySchema, GlobalSecondaryIndexKeyName, IndexName, LocalSecondaryIndexKeyName, NamedGlobalSecondaryIndexKeyNames, NamedLocalSecondaryIndexKeyNames, ObjectLikeZodType, TransactWriteOperation };