import { QueryBuilder, buildFindManyDocument, buildFindFirstDocument, buildCreateDocument, buildUpdateByPkDocument, buildDeleteByPkDocument, } from '../query-builder';
import { connectionFieldsMap } from '../input-types';
export class SpatialRelationModel {
    client;
    constructor(client) {
        this.client = client;
    }
    findMany(args) {
        const { document, variables } = buildFindManyDocument('SpatialRelation', 'spatialRelations', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
            first: args?.first,
            last: args?.last,
            after: args?.after,
            before: args?.before,
            offset: args?.offset,
        }, 'SpatialRelationFilter', 'SpatialRelationOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'SpatialRelation',
            fieldName: 'spatialRelations',
            document,
            variables,
        });
    }
    findFirst(args) {
        const { document, variables } = buildFindFirstDocument('SpatialRelation', 'spatialRelations', args.select, {
            where: args?.where,
        }, 'SpatialRelationFilter', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'SpatialRelation',
            fieldName: 'spatialRelations',
            document,
            variables,
        });
    }
    findOne(args) {
        const { document, variables } = buildFindManyDocument('SpatialRelation', 'spatialRelations', args.select, {
            where: {
                id: {
                    equalTo: args.id,
                },
            },
            first: 1,
        }, 'SpatialRelationFilter', 'SpatialRelationOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'SpatialRelation',
            fieldName: 'spatialRelation',
            document,
            variables,
            transform: (data) => ({
                spatialRelation: data.spatialRelations?.nodes?.[0] ?? null,
            }),
        });
    }
    create(args) {
        const { document, variables } = buildCreateDocument('SpatialRelation', 'createSpatialRelation', 'spatialRelation', args.select, args.data, 'CreateSpatialRelationInput', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'SpatialRelation',
            fieldName: 'createSpatialRelation',
            document,
            variables,
        });
    }
    update(args) {
        const { document, variables } = buildUpdateByPkDocument('SpatialRelation', 'updateSpatialRelation', 'spatialRelation', args.select, args.where.id, args.data, 'UpdateSpatialRelationInput', 'id', 'spatialRelationPatch', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'SpatialRelation',
            fieldName: 'updateSpatialRelation',
            document,
            variables,
        });
    }
    delete(args) {
        const { document, variables } = buildDeleteByPkDocument('SpatialRelation', 'deleteSpatialRelation', 'spatialRelation', {
            id: args.where.id,
        }, 'DeleteSpatialRelationInput', args.select, connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'SpatialRelation',
            fieldName: 'deleteSpatialRelation',
            document,
            variables,
        });
    }
}
