import { QueryBuilder, buildFindManyDocument, buildFindFirstDocument, buildCreateDocument, buildUpdateByPkDocument, buildDeleteByPkDocument, } from '../query-builder';
import { connectionFieldsMap } from '../input-types';
export class SchemaModel {
    client;
    constructor(client) {
        this.client = client;
    }
    findMany(args) {
        const { document, variables } = buildFindManyDocument('Schema', 'schemas', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
            first: args?.first,
            last: args?.last,
            after: args?.after,
            before: args?.before,
            offset: args?.offset,
        }, 'SchemaFilter', 'SchemaOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'Schema',
            fieldName: 'schemas',
            document,
            variables,
        });
    }
    findFirst(args) {
        const { document, variables } = buildFindFirstDocument('Schema', 'schemas', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
        }, 'SchemaFilter', 'SchemaOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'Schema',
            fieldName: 'schema',
            document,
            variables,
            transform: (data) => ({
                schema: data.schemas?.nodes?.[0] ?? null,
            }),
        });
    }
    findOne(args) {
        const { document, variables } = buildFindManyDocument('Schema', 'schemas', args.select, {
            where: {
                id: {
                    equalTo: args.id,
                },
            },
            first: 1,
        }, 'SchemaFilter', 'SchemaOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'Schema',
            fieldName: 'schema',
            document,
            variables,
            transform: (data) => ({
                schema: data.schemas?.nodes?.[0] ?? null,
            }),
        });
    }
    create(args) {
        const { document, variables } = buildCreateDocument('Schema', 'createSchema', 'schema', args.select, args.data, 'CreateSchemaInput', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'Schema',
            fieldName: 'createSchema',
            document,
            variables,
        });
    }
    update(args) {
        const { document, variables } = buildUpdateByPkDocument('Schema', 'updateSchema', 'schema', args.select, args.where.id, args.data, 'UpdateSchemaInput', 'id', 'schemaPatch', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'Schema',
            fieldName: 'updateSchema',
            document,
            variables,
        });
    }
    delete(args) {
        const { document, variables } = buildDeleteByPkDocument('Schema', 'deleteSchema', 'schema', {
            id: args.where.id,
        }, 'DeleteSchemaInput', args.select, connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'Schema',
            fieldName: 'deleteSchema',
            document,
            variables,
        });
    }
}
