/** * AgentThread model for ORM client * @generated by @constructive-io/graphql-codegen * DO NOT EDIT - changes will be overwritten */ import { OrmClient } from '../client'; import { QueryBuilder, buildFindManyDocument, buildFindFirstDocument, buildFindOneDocument, buildCreateDocument, buildUpdateByPkDocument, buildDeleteByPkDocument, } from '../query-builder'; import type { ConnectionResult, FindManyArgs, FindFirstArgs, CreateArgs, UpdateArgs, DeleteArgs, InferSelectResult, StrictSelect, } from '../select-types'; import type { AgentThread, AgentThreadWithRelations, AgentThreadSelect, AgentThreadFilter, AgentThreadOrderBy, CreateAgentThreadInput, UpdateAgentThreadInput, AgentThreadPatch, } from '../input-types'; import { connectionFieldsMap } from '../input-types'; export class AgentThreadModel { constructor(private client: OrmClient) {} findMany( args: FindManyArgs & { select: S; } & StrictSelect ): QueryBuilder<{ agentThreads: ConnectionResult>; }> { const { document, variables } = buildFindManyDocument( 'AgentThread', 'agentThreads', args.select, { where: args?.where, orderBy: args?.orderBy as string[] | undefined, first: args?.first, last: args?.last, after: args?.after, before: args?.before, offset: args?.offset, }, 'AgentThreadFilter', 'AgentThreadOrderBy', connectionFieldsMap ); return new QueryBuilder({ client: this.client, operation: 'query', operationName: 'AgentThread', fieldName: 'agentThreads', document, variables, }); } findFirst( args: FindFirstArgs & { select: S; } & StrictSelect ): QueryBuilder<{ agentThread: InferSelectResult | null; }> { const { document, variables } = buildFindFirstDocument( 'AgentThread', 'agentThreads', args.select, { where: args?.where, orderBy: args?.orderBy as string[] | undefined, }, 'AgentThreadFilter', 'AgentThreadOrderBy', connectionFieldsMap ); return new QueryBuilder({ client: this.client, operation: 'query', operationName: 'AgentThread', fieldName: 'agentThread', document, variables, transform: (data: { agentThreads?: { nodes?: InferSelectResult[]; }; }) => ({ agentThread: data.agentThreads?.nodes?.[0] ?? null, }), }); } findOne( args: { id: string; select: S; } & StrictSelect ): QueryBuilder<{ agentThread: InferSelectResult | null; }> { const { document, variables } = buildFindManyDocument( 'AgentThread', 'agentThreads', args.select, { where: { id: { equalTo: args.id, }, }, first: 1, }, 'AgentThreadFilter', 'AgentThreadOrderBy', connectionFieldsMap ); return new QueryBuilder({ client: this.client, operation: 'query', operationName: 'AgentThread', fieldName: 'agentThread', document, variables, transform: (data: { agentThreads?: { nodes?: InferSelectResult[]; }; }) => ({ agentThread: data.agentThreads?.nodes?.[0] ?? null, }), }); } create( args: CreateArgs & { select: S; } & StrictSelect ): QueryBuilder<{ createAgentThread: { agentThread: InferSelectResult; }; }> { const { document, variables } = buildCreateDocument( 'AgentThread', 'createAgentThread', 'agentThread', args.select, args.data, 'CreateAgentThreadInput', connectionFieldsMap ); return new QueryBuilder({ client: this.client, operation: 'mutation', operationName: 'AgentThread', fieldName: 'createAgentThread', document, variables, }); } update( args: UpdateArgs< S, { id: string; }, AgentThreadPatch > & { select: S; } & StrictSelect ): QueryBuilder<{ updateAgentThread: { agentThread: InferSelectResult; }; }> { const { document, variables } = buildUpdateByPkDocument( 'AgentThread', 'updateAgentThread', 'agentThread', args.select, args.where.id, args.data, 'UpdateAgentThreadInput', 'id', 'agentThreadPatch', connectionFieldsMap, undefined ); return new QueryBuilder({ client: this.client, operation: 'mutation', operationName: 'AgentThread', fieldName: 'updateAgentThread', document, variables, }); } delete( args: DeleteArgs< { id: string; }, S > & { select: S; } & StrictSelect ): QueryBuilder<{ deleteAgentThread: { agentThread: InferSelectResult; }; }> { const { document, variables } = buildDeleteByPkDocument( 'AgentThread', 'deleteAgentThread', 'agentThread', { id: args.where.id, }, 'DeleteAgentThreadInput', args.select, connectionFieldsMap ); return new QueryBuilder({ client: this.client, operation: 'mutation', operationName: 'AgentThread', fieldName: 'deleteAgentThread', document, variables, }); } }