dyna-record
    Preparing search index...

    Type Alias InferObjectSchema<S>

    InferObjectSchema: {
        [K in keyof S as S[K] extends { nullable: true } ? never : K]: InferFieldDef<
            S[K],
        >
    } & {
        [K in keyof S as S[K] extends { nullable: true } ? K : never]?: InferFieldDef<
            S[K],
        >
    }

    Infers the TypeScript type from an ObjectSchema definition.

    • Primitive fields map to their TS equivalents via PrimitiveTypeMap
    • Enum fields become a union of their values (values[number])
    • Nested object fields recurse through InferObjectSchema — always required (never nullable)
    • Array fields become T[] where T is inferred from items
    • Fields with nullable: true become optional (T | undefined)
    • Object fields are always required because DynamoDB cannot update nested document paths if an intermediate object does not exist

    Type Parameters

    const schema = {
    name: { type: "string" },
    age: { type: "number", nullable: true },
    status: { type: "enum", values: ["active", "inactive"] },
    tags: { type: "array", items: { type: "string" } },
    geo: { type: "object", fields: { lat: { type: "number" }, lng: { type: "number" } } }
    } as const satisfies ObjectSchema;

    type MyType = InferObjectSchema<typeof schema>;
    // {
    // name: string;
    // status: "active" | "inactive";
    // tags: string[];
    // geo: { lat: number; lng: number };
    // age?: number;
    // }