import { QueryBuilder, buildFindManyDocument, buildFindFirstDocument, buildCreateDocument, buildUpdateByPkDocument, buildDeleteByPkDocument, } from '../query-builder';
import { connectionFieldsMap } from '../input-types';
export class PrimaryKeyConstraintModel {
    client;
    constructor(client) {
        this.client = client;
    }
    findMany(args) {
        const { document, variables } = buildFindManyDocument('PrimaryKeyConstraint', 'primaryKeyConstraints', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
            first: args?.first,
            last: args?.last,
            after: args?.after,
            before: args?.before,
            offset: args?.offset,
        }, 'PrimaryKeyConstraintFilter', 'PrimaryKeyConstraintOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'PrimaryKeyConstraint',
            fieldName: 'primaryKeyConstraints',
            document,
            variables,
        });
    }
    findFirst(args) {
        const { document, variables } = buildFindFirstDocument('PrimaryKeyConstraint', 'primaryKeyConstraints', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
        }, 'PrimaryKeyConstraintFilter', 'PrimaryKeyConstraintOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'PrimaryKeyConstraint',
            fieldName: 'primaryKeyConstraint',
            document,
            variables,
            transform: (data) => ({
                primaryKeyConstraint: data.primaryKeyConstraints?.nodes?.[0] ?? null,
            }),
        });
    }
    findOne(args) {
        const { document, variables } = buildFindManyDocument('PrimaryKeyConstraint', 'primaryKeyConstraints', args.select, {
            where: {
                id: {
                    equalTo: args.id,
                },
            },
            first: 1,
        }, 'PrimaryKeyConstraintFilter', 'PrimaryKeyConstraintOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'PrimaryKeyConstraint',
            fieldName: 'primaryKeyConstraint',
            document,
            variables,
            transform: (data) => ({
                primaryKeyConstraint: data.primaryKeyConstraints?.nodes?.[0] ?? null,
            }),
        });
    }
    create(args) {
        const { document, variables } = buildCreateDocument('PrimaryKeyConstraint', 'createPrimaryKeyConstraint', 'primaryKeyConstraint', args.select, args.data, 'CreatePrimaryKeyConstraintInput', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'PrimaryKeyConstraint',
            fieldName: 'createPrimaryKeyConstraint',
            document,
            variables,
        });
    }
    update(args) {
        const { document, variables } = buildUpdateByPkDocument('PrimaryKeyConstraint', 'updatePrimaryKeyConstraint', 'primaryKeyConstraint', args.select, args.where.id, args.data, 'UpdatePrimaryKeyConstraintInput', 'id', 'primaryKeyConstraintPatch', connectionFieldsMap, undefined);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'PrimaryKeyConstraint',
            fieldName: 'updatePrimaryKeyConstraint',
            document,
            variables,
        });
    }
    delete(args) {
        const { document, variables } = buildDeleteByPkDocument('PrimaryKeyConstraint', 'deletePrimaryKeyConstraint', 'primaryKeyConstraint', {
            id: args.where.id,
        }, 'DeletePrimaryKeyConstraintInput', args.select, connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'PrimaryKeyConstraint',
            fieldName: 'deletePrimaryKeyConstraint',
            document,
            variables,
        });
    }
}
