import { QueryBuilder, buildFindManyDocument, buildFindFirstDocument, buildCreateDocument, buildUpdateByPkDocument, buildDeleteByPkDocument, } from '../query-builder';
import { connectionFieldsMap } from '../input-types';
export class SiteModuleModel {
    client;
    constructor(client) {
        this.client = client;
    }
    findMany(args) {
        const { document, variables } = buildFindManyDocument('SiteModule', 'siteModules', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
            first: args?.first,
            last: args?.last,
            after: args?.after,
            before: args?.before,
            offset: args?.offset,
        }, 'SiteModuleFilter', 'SiteModuleOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'SiteModule',
            fieldName: 'siteModules',
            document,
            variables,
        });
    }
    findFirst(args) {
        const { document, variables } = buildFindFirstDocument('SiteModule', 'siteModules', args.select, {
            where: args?.where,
        }, 'SiteModuleFilter', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'SiteModule',
            fieldName: 'siteModules',
            document,
            variables,
        });
    }
    findOne(args) {
        const { document, variables } = buildFindManyDocument('SiteModule', 'siteModules', args.select, {
            where: {
                id: {
                    equalTo: args.id,
                },
            },
            first: 1,
        }, 'SiteModuleFilter', 'SiteModuleOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'SiteModule',
            fieldName: 'siteModule',
            document,
            variables,
            transform: (data) => ({
                siteModule: data.siteModules?.nodes?.[0] ?? null,
            }),
        });
    }
    create(args) {
        const { document, variables } = buildCreateDocument('SiteModule', 'createSiteModule', 'siteModule', args.select, args.data, 'CreateSiteModuleInput', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'SiteModule',
            fieldName: 'createSiteModule',
            document,
            variables,
        });
    }
    update(args) {
        const { document, variables } = buildUpdateByPkDocument('SiteModule', 'updateSiteModule', 'siteModule', args.select, args.where.id, args.data, 'UpdateSiteModuleInput', 'id', 'siteModulePatch', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'SiteModule',
            fieldName: 'updateSiteModule',
            document,
            variables,
        });
    }
    delete(args) {
        const { document, variables } = buildDeleteByPkDocument('SiteModule', 'deleteSiteModule', 'siteModule', {
            id: args.where.id,
        }, 'DeleteSiteModuleInput', args.select, connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'SiteModule',
            fieldName: 'deleteSiteModule',
            document,
            variables,
        });
    }
}
