import type { Payload } from "payload"; import type { FindOptions, PayloadClient, PayloadClientResult, } from "./types"; export class LocalPayloadClient implements PayloadClient { constructor(private payload: Payload) {} async find>( collection: string, options?: FindOptions ): Promise> { const result = await this.payload.find({ collection: collection as any, where: options?.where as any, sort: options?.sort, limit: options?.limit, page: options?.page, depth: options?.depth, locale: options?.locale as any, }); return result as unknown as PayloadClientResult; } async findByID>( collection: string, id: string, options?: { depth?: number } ): Promise { const result = await this.payload.findByID({ collection: collection as any, id, depth: options?.depth, }); return result as unknown as T; } async create>( collection: string, data: Record, options?: { depth?: number } ): Promise { const result = await this.payload.create({ collection: collection as any, data: data as any, depth: options?.depth, }); return result as unknown as T; } async update>( collection: string, id: string, data: Record, options?: { depth?: number } ): Promise { const result = await this.payload.update({ collection: collection as any, id, data: data as any, depth: options?.depth, }); return result as unknown as T; } async delete>( collection: string, id: string ): Promise { const result = await this.payload.delete({ collection: collection as any, id, }); return result as unknown as T; } }