|
| 1 | +/* eslint-disable */ |
| 2 | +import type { Prisma, Account } from "@prisma/client"; |
| 3 | +import { useContext } from 'react'; |
| 4 | +import { RequestHandlerContext, type RequestOptions } from '@zenstackhq/react/runtime'; |
| 5 | +import * as request from '@zenstackhq/react/runtime'; |
| 6 | + |
| 7 | +export function useAccount() { |
| 8 | + const { endpoint } = useContext(RequestHandlerContext); |
| 9 | + const prefixesToMutate = [`${endpoint}/account/find`, `${endpoint}/account/aggregate`, `${endpoint}/account/count`, `${endpoint}/account/groupBy`]; |
| 10 | + const mutate = request.getMutate(prefixesToMutate); |
| 11 | + |
| 12 | + async function create<T extends Prisma.AccountCreateArgs>(args: Prisma.SelectSubset<T, Prisma.AccountCreateArgs>) { |
| 13 | + try { |
| 14 | + return await request.post<Prisma.SelectSubset<T, Prisma.AccountCreateArgs>, Prisma.CheckSelect<T, Account, Prisma.AccountGetPayload<T>>>(`${endpoint}/account/create`, args, mutate); |
| 15 | + } catch (err: any) { |
| 16 | + if (err.info?.prisma && err.info?.code === 'P2004') { |
| 17 | + // unable to readback data |
| 18 | + return undefined; |
| 19 | + } else { |
| 20 | + throw err; |
| 21 | + } |
| 22 | + } |
| 23 | + } |
| 24 | + |
| 25 | + async function createMany<T extends Prisma.AccountCreateManyArgs>(args: Prisma.SelectSubset<T, Prisma.AccountCreateManyArgs>) { |
| 26 | + return await request.post<Prisma.SelectSubset<T, Prisma.AccountCreateManyArgs>, Prisma.BatchPayload>(`${endpoint}/account/createMany`, args, mutate); |
| 27 | + } |
| 28 | + |
| 29 | + function findMany<T extends Prisma.AccountFindManyArgs>(args?: Prisma.SelectSubset<T, Prisma.AccountFindManyArgs>, options?: RequestOptions<Array<Prisma.AccountGetPayload<T>>>) { |
| 30 | + return request.get<Array<Prisma.AccountGetPayload<T>>>(`${endpoint}/account/findMany`, args, options); |
| 31 | + } |
| 32 | + |
| 33 | + function findUnique<T extends Prisma.AccountFindUniqueArgs>(args: Prisma.SelectSubset<T, Prisma.AccountFindUniqueArgs>, options?: RequestOptions<Prisma.AccountGetPayload<T>>) { |
| 34 | + return request.get<Prisma.AccountGetPayload<T>>(`${endpoint}/account/findUnique`, args, options); |
| 35 | + } |
| 36 | + |
| 37 | + function findFirst<T extends Prisma.AccountFindFirstArgs>(args: Prisma.SelectSubset<T, Prisma.AccountFindFirstArgs>, options?: RequestOptions<Prisma.AccountGetPayload<T>>) { |
| 38 | + return request.get<Prisma.AccountGetPayload<T>>(`${endpoint}/account/findFirst`, args, options); |
| 39 | + } |
| 40 | + |
| 41 | + async function update<T extends Prisma.AccountUpdateArgs>(args: Prisma.SelectSubset<T, Prisma.AccountUpdateArgs>) { |
| 42 | + try { |
| 43 | + return await request.put<Prisma.SelectSubset<T, Prisma.AccountUpdateArgs>, Prisma.AccountGetPayload<T>>(`${endpoint}/account/update`, args, mutate); |
| 44 | + } catch (err: any) { |
| 45 | + if (err.info?.prisma && err.info?.code === 'P2004') { |
| 46 | + // unable to readback data |
| 47 | + return undefined; |
| 48 | + } else { |
| 49 | + throw err; |
| 50 | + } |
| 51 | + } |
| 52 | + } |
| 53 | + |
| 54 | + async function updateMany<T extends Prisma.AccountUpdateManyArgs>(args: Prisma.SelectSubset<T, Prisma.AccountUpdateManyArgs>) { |
| 55 | + return await request.put<Prisma.SelectSubset<T, Prisma.AccountUpdateManyArgs>, Prisma.BatchPayload>(`${endpoint}/account/updateMany`, args, mutate); |
| 56 | + } |
| 57 | + |
| 58 | + async function upsert<T extends Prisma.AccountUpsertArgs>(args: Prisma.SelectSubset<T, Prisma.AccountUpsertArgs>) { |
| 59 | + try { |
| 60 | + return await request.put<Prisma.SelectSubset<T, Prisma.AccountUpsertArgs>, Prisma.AccountGetPayload<T>>(`${endpoint}/account/upsert`, args, mutate); |
| 61 | + } catch (err: any) { |
| 62 | + if (err.info?.prisma && err.info?.code === 'P2004') { |
| 63 | + // unable to readback data |
| 64 | + return undefined; |
| 65 | + } else { |
| 66 | + throw err; |
| 67 | + } |
| 68 | + } |
| 69 | + } |
| 70 | + |
| 71 | + async function del<T extends Prisma.AccountDeleteArgs>(args?: Prisma.SelectSubset<T, Prisma.AccountDeleteArgs>) { |
| 72 | + try { |
| 73 | + return await request.del<Prisma.AccountGetPayload<T>>(`${endpoint}/account/delete`, args, mutate); |
| 74 | + } catch (err: any) { |
| 75 | + if (err.info?.prisma && err.info?.code === 'P2004') { |
| 76 | + // unable to readback data |
| 77 | + return undefined; |
| 78 | + } else { |
| 79 | + throw err; |
| 80 | + } |
| 81 | + } |
| 82 | + } |
| 83 | + |
| 84 | + async function deleteMany<T extends Prisma.AccountDeleteManyArgs>(args?: Prisma.SelectSubset<T, Prisma.AccountDeleteManyArgs>) { |
| 85 | + return await request.del<Prisma.BatchPayload>(`${endpoint}/account/deleteMany`, args, mutate); |
| 86 | + } |
| 87 | + |
| 88 | + function aggregate<T extends Prisma.AccountAggregateArgs>(args: Prisma.Subset<T, Prisma.AccountAggregateArgs>, options?: RequestOptions<Prisma.GetAccountAggregateType<T>>) { |
| 89 | + return request.get<Prisma.GetAccountAggregateType<T>>(`${endpoint}/account/aggregate`, args, options); |
| 90 | + } |
| 91 | + |
| 92 | + function groupBy<T extends Prisma.AccountGroupByArgs, HasSelectOrTake extends Prisma.Or<Prisma.Extends<'skip', Prisma.Keys<T>>, Prisma.Extends<'take', Prisma.Keys<T>>>, OrderByArg extends Prisma.True extends HasSelectOrTake ? { orderBy: Prisma.UserGroupByArgs['orderBy'] } : { orderBy?: Prisma.UserGroupByArgs['orderBy'] }, OrderFields extends Prisma.ExcludeUnderscoreKeys<Prisma.Keys<Prisma.MaybeTupleToUnion<T['orderBy']>>>, ByFields extends Prisma.TupleToUnion<T['by']>, ByValid extends Prisma.Has<ByFields, OrderFields>, HavingFields extends Prisma.GetHavingFields<T['having']>, HavingValid extends Prisma.Has<ByFields, HavingFields>, ByEmpty extends T['by'] extends never[] ? Prisma.True : Prisma.False, InputErrors extends ByEmpty extends Prisma.True |
| 93 | + ? `Error: "by" must not be empty.` |
| 94 | + : HavingValid extends Prisma.False |
| 95 | + ? { |
| 96 | + [P in HavingFields]: P extends ByFields |
| 97 | + ? never |
| 98 | + : P extends string |
| 99 | + ? `Error: Field "${P}" used in "having" needs to be provided in "by".` |
| 100 | + : [ |
| 101 | + Error, |
| 102 | + 'Field ', |
| 103 | + P, |
| 104 | + ` in "having" needs to be provided in "by"`, |
| 105 | + ] |
| 106 | + }[HavingFields] |
| 107 | + : 'take' extends Prisma.Keys<T> |
| 108 | + ? 'orderBy' extends Prisma.Keys<T> |
| 109 | + ? ByValid extends Prisma.True |
| 110 | + ? {} |
| 111 | + : { |
| 112 | + [P in OrderFields]: P extends ByFields |
| 113 | + ? never |
| 114 | + : `Error: Field "${P}" in "orderBy" needs to be provided in "by"` |
| 115 | + }[OrderFields] |
| 116 | + : 'Error: If you provide "take", you also need to provide "orderBy"' |
| 117 | + : 'skip' extends Prisma.Keys<T> |
| 118 | + ? 'orderBy' extends Prisma.Keys<T> |
| 119 | + ? ByValid extends Prisma.True |
| 120 | + ? {} |
| 121 | + : { |
| 122 | + [P in OrderFields]: P extends ByFields |
| 123 | + ? never |
| 124 | + : `Error: Field "${P}" in "orderBy" needs to be provided in "by"` |
| 125 | + }[OrderFields] |
| 126 | + : 'Error: If you provide "skip", you also need to provide "orderBy"' |
| 127 | + : ByValid extends Prisma.True |
| 128 | + ? {} |
| 129 | + : { |
| 130 | + [P in OrderFields]: P extends ByFields |
| 131 | + ? never |
| 132 | + : `Error: Field "${P}" in "orderBy" needs to be provided in "by"` |
| 133 | + }[OrderFields]>(args: Prisma.SubsetIntersection<T, Prisma.AccountGroupByArgs, OrderByArg> & InputErrors, options?: RequestOptions<{} extends InputErrors ? Prisma.GetAccountGroupByPayload<T> : InputErrors>) { |
| 134 | + return request.get<{} extends InputErrors ? Prisma.GetAccountGroupByPayload<T> : InputErrors>(`${endpoint}/account/groupBy`, args, options); |
| 135 | + } |
| 136 | + return { create, createMany, findMany, findUnique, findFirst, update, updateMany, upsert, del, deleteMany, aggregate, groupBy }; |
| 137 | +} |
0 commit comments