import { QueryBuilder, buildFindManyDocument, buildFindFirstDocument, buildCreateDocument, buildUpdateByPkDocument, buildDeleteByPkDocument, } from '../query-builder';
import { connectionFieldsMap } from '../input-types';
export class NamespaceModel {
    client;
    constructor(client) {
        this.client = client;
    }
    findMany(args) {
        const { document, variables } = buildFindManyDocument('Namespace', 'namespaces', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
            first: args?.first,
            last: args?.last,
            after: args?.after,
            before: args?.before,
            offset: args?.offset,
        }, 'NamespaceFilter', 'NamespaceOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'Namespace',
            fieldName: 'namespaces',
            document,
            variables,
        });
    }
    findFirst(args) {
        const { document, variables } = buildFindFirstDocument('Namespace', 'namespaces', args.select, {
            where: args?.where,
            orderBy: args?.orderBy,
        }, 'NamespaceFilter', 'NamespaceOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'Namespace',
            fieldName: 'namespace',
            document,
            variables,
            transform: (data) => ({
                namespace: data.namespaces?.nodes?.[0] ?? null,
            }),
        });
    }
    findOne(args) {
        const { document, variables } = buildFindManyDocument('Namespace', 'namespaces', args.select, {
            where: {
                id: {
                    equalTo: args.id,
                },
            },
            first: 1,
        }, 'NamespaceFilter', 'NamespaceOrderBy', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'query',
            operationName: 'Namespace',
            fieldName: 'namespace',
            document,
            variables,
            transform: (data) => ({
                namespace: data.namespaces?.nodes?.[0] ?? null,
            }),
        });
    }
    create(args) {
        const { document, variables } = buildCreateDocument('Namespace', 'createNamespace', 'namespace', args.select, args.data, 'CreateNamespaceInput', connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'Namespace',
            fieldName: 'createNamespace',
            document,
            variables,
        });
    }
    update(args) {
        const { document, variables } = buildUpdateByPkDocument('Namespace', 'updateNamespace', 'namespace', args.select, args.where.id, args.data, 'UpdateNamespaceInput', 'id', 'namespacePatch', connectionFieldsMap, undefined);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'Namespace',
            fieldName: 'updateNamespace',
            document,
            variables,
        });
    }
    delete(args) {
        const { document, variables } = buildDeleteByPkDocument('Namespace', 'deleteNamespace', 'namespace', {
            id: args.where.id,
        }, 'DeleteNamespaceInput', args.select, connectionFieldsMap);
        return new QueryBuilder({
            client: this.client,
            operation: 'mutation',
            operationName: 'Namespace',
            fieldName: 'deleteNamespace',
            document,
            variables,
        });
    }
}
