@zeroin.earth/appwrite-graphql 23.0.3 → 23.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +5 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +26 -26
- package/dist/index.d.ts +26 -26
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/react-native/index.cjs +94 -94
- package/react-native/index.d.cts +25 -27
- package/react-native/index.d.ts +25 -27
- package/react-native/index.js +94 -94
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/AppwriteProvider.tsx","../src/useAppwrite.ts","../src/useQueryClient.ts","../src/useMutation.ts","../src/useQuery.ts","../src/useLazyQuery.ts","../src/useSuspenseQuery.ts","../src/client.ts","../src/query/Keys.ts","../src/account/queryOptions.ts","../src/account/useAccount.ts","../src/account/useCreateAnonymousSession.ts","../src/account/useCreateEmailToken.ts","../src/account/useCreateJWT.ts","../src/account/useCreateMagicURLToken.ts","../src/account/useCreateMfaAuthenticator.ts","../src/account/useCreateMfaChallenge.ts","../src/account/useCreateMfaRecoveryCodes.ts","../src/account/useCreateOAuth2Token.ts","../src/account/useCreatePhoneToken.ts","../src/account/useCreatePhoneVerification.ts","../src/account/useCreatePushTarget.ts","../src/account/useCreateSession.ts","../src/account/useCreateEmailVerification.ts","../src/account/useDeleteIdentity.ts","../src/account/useDeleteMfaAuthenticator.ts","../src/account/useDeletePushTarget.ts","../src/account/useDeleteSession.ts","../src/account/useDeleteSessions.ts","../src/account/useGetMfaRecoveryCodes.ts","../src/account/useGetPrefs.ts","../src/account/useGetSession.ts","../src/account/useListIdentities.ts","../src/account/useListMfaFactors.ts","../src/account/useListSessions.ts","../src/account/useLogin.ts","../src/account/useLogout.ts","../src/account/useLogs.ts","../src/account/usePasswordRecovery.ts","../src/account/useResetPassword.ts","../src/account/useSignUp.ts","../src/account/useUpdateEmail.ts","../src/account/useUpdateEmailVerification.ts","../src/account/useUpdateMagicURLSession.ts","../src/account/useUpdateMfa.ts","../src/account/useUpdateMfaAuthenticator.ts","../src/account/useUpdateMfaChallenge.ts","../src/account/useUpdateMfaRecoveryCodes.ts","../src/account/useUpdateName.ts","../src/account/useUpdatePassword.ts","../src/account/useUpdatePhone.ts","../src/account/useUpdatePhoneSession.ts","../src/account/useUpdatePhoneVerification.ts","../src/account/useUpdatePrefs.ts","../src/account/useUpdatePushTarget.ts","../src/account/useUpdateSession.ts","../src/account/useUpdateStatus.ts","../src/account/useVerification.ts","../src/avatars/useAvatarBrowser.ts","../src/avatars/useAvatarCreditCard.ts","../src/avatars/useAvatarFavicon.ts","../src/avatars/useAvatarFlag.ts","../src/avatars/useAvatarImage.ts","../src/avatars/useAvatarInitials.ts","../src/avatars/useAvatarQR.ts","../src/avatars/useAvatarScreenshot.ts","../src/databases/utils.ts","../src/databases/queryOptions.ts","../src/databases/useCollection.ts","../src/databases/useCollectionWithPagination.ts","../src/databases/useCreateDocument.ts","../src/databases/useCreateOperations.ts","../src/databases/useCreateTransaction.ts","../src/databases/useDecrementAttribute.ts","../src/databases/useDeleteDocument.ts","../src/databases/useDeleteTransaction.ts","../src/databases/useDocument.ts","../src/databases/useGetTransaction.ts","../src/databases/useIncrementAttribute.ts","../src/databases/useInfiniteCollection.ts","../src/databases/useListTransactions.ts","../src/offline/conflictResolution/resolve.ts","../src/offline/mutations/conflictAwareUpdate.ts","../src/databases/useUpdateDocument.ts","../src/databases/useUpdateTransaction.ts","../src/databases/useUpsertDocument.ts","../src/locale/useLocale.ts","../src/locale/useLocaleCodes.ts","../src/locale/useLocaleContinents.ts","../src/locale/useLocaleCountries.ts","../src/locale/useLocaleCountriesEU.ts","../src/locale/useLocaleCountriesPhones.ts","../src/locale/useLocaleCurrencies.ts","../src/locale/useLocaleLanguages.ts","../src/messaging/useCreateSubscriber.ts","../src/messaging/useDeleteSubscriber.ts","../src/storage/useFile.ts","../src/storage/useFileDownload.ts","../src/storage/useFilePreview.ts","../src/storage/useFileView.ts","../src/storage/useFiles.ts","../src/storage/useCreateFile.ts","../src/storage/useUpdateFile.ts","../src/storage/useDeleteFile.ts","../src/teams/queryOptions.ts","../src/teams/useTeam.ts","../src/teams/useTeams.ts","../src/teams/useTeamPrefs.ts","../src/teams/useTeamMembership.ts","../src/teams/useTeamMemberships.ts","../src/teams/useCreateTeam.ts","../src/teams/useUpdateTeamName.ts","../src/teams/useUpdateTeamPrefs.ts","../src/teams/useDeleteTeam.ts","../src/teams/useCreateMembership.ts","../src/teams/useUpdateMembership.ts","../src/teams/useUpdateMembershipStatus.ts","../src/teams/useDeleteMembership.ts","../src/query/QueryBuilder.ts","../node_modules/@tanstack/query-core/src/utils.ts","../node_modules/@tanstack/query-core/src/thenable.ts","../node_modules/@tanstack/query-core/src/hydration.ts","../node_modules/@tanstack/query-persist-client-core/src/persist.ts","../src/offline/mutations/registry.ts","../src/offline/createOfflineClient.ts","../src/offline/network/web.ts","../src/functions/useFunction.ts","../src/functions/useGetExecution.ts","../src/functions/useListExecutions.ts"],"names":["AppwriteContext","defaultQueryClient","QueryClient","AppwriteProvider","client","queryClient","persister","onCacheRestored","children","qc","PersistQueryClientProvider","mutation","query","ReactQueryDevtools","QueryClientProvider","useAppwrite","ctx","useContext","useQueryClient","QueryClientContext","useMutation","options","useReactMutation","useQuery","useReactQuery","useLazyQuery","useSuspenseQuery","useSuspenseReactQuery","graphqlObject","graphqlAppwrite","variables","data","errors","print","createAppwriteClient","endpoint","projectId","Client","Account","Avatars","Realtime","Storage","Graphql","Databases","Functions","Locale","Messaging","TablesDB","Teams","Keys","_Keys","segments","k","id","getAccount","gql","getAccountQuery","useLazyAccount","isActive","setIsActive","useState","queryResult","getAccountQueryOptions","useEffect","subscriptionPromise","subscribe","sub","useAccount","opts","realtime","Channel","response","event","account","produce","draft","castDraft","createAnonymousSession","useCreateAnonymousSession","graphql","createEmailToken","useCreateEmailToken","userId","email","phrase","accountCreateJWT","useCreateJWT","gcTime","useSuspenseCreateJWT","createMagicURLToken","useCreateMagicURLToken","url","accountCreateMfaAuthenticator","useCreateMfaAuthenticator","type","AuthenticatorType","accountCreateMfaChallenge","useCreateMfaChallenge","factor","accountCreateMfaRecoveryCodes","useCreateMfaRecoveryCodes","useCreateOAuth2Token","provider","success","failure","scopes","createPhoneToken","useCreatePhoneToken","phone","createPhoneVerification","useCreatePhoneVerification","accountCreatePushTarget","useCreatePushTarget","targetId","identifier","providerId","createSession","useCreateSession","secret","createEmailVerification","useCreateEmailVerification","accountDeleteIdentity","useDeleteIdentity","identityId","deleteMFAAuthenticator","useDeleteMfaAuthenticator","accountDeletePushTarget","useDeletePushTarget","deleteSession","useDeleteSession","sessionId","deleteSessions","useDeleteSessions","getMFARecoveryCodes","useGetMfaRecoveryCodes","accountGetPrefs","useGetPrefs","getSession","useGetSession","accountListIdentities","useListIdentities","listMFAFactors","useListMfaFactors","accountListSessions","useListSessions","accountCreateEmailPasswordSession","useLogin","login","password","oAuthLogin","useLogout","accountListLogs","useLogs","queries","createRecovery","usePasswordRecovery","resetUrl","_","e","updateRecovery","useResetPassword","createAccount","verify","useSignUp","signUp","name","ID","verifyEmail","verifyUrl","accountUpdateEmail","useUpdateEmail","updateEmailVerification","useUpdateEmailVerification","updateMagicURLSession","useUpdateMagicURLSession","accountUpdateMFA","useUpdateMfa","mfa","updateMFAAuthenticator","useUpdateMfaAuthenticator","otp","accountUpdateMfaChallenge","useUpdateMfaChallenge","challengeId","accountUpdateMfaRecoveryCodes","useUpdateMfaRecoveryCodes","accountUpdateName","useUpdateName","mutationData","updatePassword","useUpdatePassword","oldPassword","accountUpdatePhone","useUpdatePhone","updatePhoneSession","useUpdatePhoneSession","updatePhoneVerification","useUpdatePhoneVerification","accountUpdatePrefs","useUpdatePrefs","prefs","accountUpdatePushTarget","useUpdatePushTarget","updateSession","useUpdateSession","accountUpdateStatus","useUpdateStatus","updateVerification","useVerification","useAvatarBrowser","code","width","height","quality","avatars","useMemo","useAvatarCreditCard","useAvatarFavicon","useAvatarFlag","useAvatarImage","useAvatarInitials","background","useAvatarQR","text","size","margin","download","useAvatarScreenshot","mergeFieldsQuery","fields","Query","getDocument","getDocumentQuery","databaseId","collectionId","documentId","transactionId","rawQueries","mergedQueries","listDocuments","getCollectionQuery","documents","document","useCollectionQueryConfig","useCollectionRealtime","queriesKey","operation","useCollection","config","collection","useSuspenseCollection","usePaginationState","limit","page","setPage","totalRef","useRef","offset","prevPage","currentOffset","newPage","maxPage","useCollectionWithPagination","nextPage","previousPage","handlePageChange","total","useSuspenseCollectionWithPagination","createDocument","useCreateDocument","permissions","result","documentKeyPrefix","createOperations","useCreateOperations","operations","createTransaction","useCreateTransaction","ttl","decrementDocumentAttribute","useDecrementAttribute","attribute","value","min","previousEntries","old","current","decrement","newValue","__","context","key","deleteDocument","useDeleteDocument","deleteTransaction","useDeleteTransaction","useDocumentQueryConfig","useDocumentRealtime","useDocument","useSuspenseDocument","getTransaction","useGetTransaction","incrementDocumentAttribute","useIncrementAttribute","max","increment","useInfiniteCollection","accumulated","setAccumulated","paginatedQueries","prev","expectedLength","hasNextPage","fetchNextPage","useCallback","reset","listTransactions","useListTransactions","resolveConflict","strategy","extractChangedFields","localChanges","remoteChanges","original","updated","changes","conflictAwareUpdate","conflictStrategy","baseSnapshot","m","resolvedData","remoteResult","fetchErrors","rawRemote","remote","local","updateDocument","newData","thing","useUpdateDocument","appwrite","wasOffline","error","baseSnapshotCopy","willPerformOfflineMutation","onlineManager","updateTransaction","useUpdateTransaction","commit","rollback","upsertDocument","useUpsertDocument","getLocale","useLocale","listLocaleCodes","useLocaleCodes","listContinents","useLocaleContinents","listCountries","useLocaleCountries","listCountriesEU","useLocaleCountriesEU","listCountriesPhones","useLocaleCountriesPhones","listCurrencies","useLocaleCurrencies","listLanguages","useLocaleLanguages","createSubscriber","useCreateSubscriber","subscriberId","topicId","deleteSubscriber","useDeleteSubscriber","getFile","useFile","bucketId","fileId","useFileDownload","token","storage","useFilePreview","gravity","borderWidth","borderColor","borderRadius","opacity","rotation","output","useFileView","listFiles","useFiles","search","useCreateFile","file","onProgress","updateFile","useUpdateFile","deleteFile","useDeleteFile","getTeam","teamQueryOptions","teamId","useTeam","listTeams","useTeams","getTeamPrefs","useTeamPrefs","getMembership","useTeamMembership","membershipId","listMemberships","useTeamMemberships","createTeam","useCreateTeam","roles","updateTeamName","useUpdateTeamName","updateTeamPrefs","useUpdateTeamPrefs","deleteTeam","useDeleteTeam","createMembership","useCreateMembership","updateMembership","useUpdateMembership","updateMembershipStatus","useUpdateMembershipStatus","deleteMembership","useDeleteMembership","QueryBuilder","_QueryBuilder","field","pattern","start","end","prefix","suffix","term","count","values","date","orQueries","fn","andQueries","latitude","longitude","distance","meters","points","q","noop","tryResolveSync","promise","defaultTransformerFn","dehydrateMutation","dehydrateQuery","serializeData","shouldRedactErrors","dehydratePromise","defaultShouldDehydrateMutation","defaultShouldDehydrateQuery","defaultShouldRedactErrors","dehydrate","filterMutation","mutations","filterQuery","hydrate","dehydratedState","mutationCache","queryCache","deserializeData","state","mutationOptions","queryKey","queryHash","meta","dehydratedAt","syncData","rawData","existingQueryIsPending","existingQueryIsFetching","hasNewerSyncData","_ignored","serializedState","cacheEventTypes","isCacheEventType","eventType","persistQueryClientRestore","maxAge","buster","hydrateOptions","persistedClient","expired","busted","err","persistQueryClientSave","dehydrateOptions","persistClient","persistQueryClientSubscribe","props","unsubscribeQueryCache","unsubscribeMutationCache","persistQueryClient","hasUnsubscribed","persistQueryClientUnsubscribe","unsubscribe","restorePromise","gqlMutation","resultKey","vars","mutationRegistry","hydrateMutationDefaults","entry","createOfflineClient","externalPersister","networkAdapter","throttleTime","createAsyncStoragePersister","isOnline","restored","restoredWithResume","webNetworkAdapter","callback","updateOnlineStatus","createExecution","getFunctionExecution","useCurrentExecution","currentExecution","currentFunction","enabled","useFunction","setCurrentExecution","setCurrentFunction","getExecution","functionId","body","async","path","method","headers","scheduledAt","_id","status","responseBody","useSuspenseF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GAsBpB,OApBoBQ,CAAAA,CAA0E,CAC5F,QAAA,CAAU,CAAC,GAAG0B,CAAAA,CAAK,QAAA,CAASse,CAAU,EAAE,UAAA,EAAW,CAAE,GAAA,EAAI,CAAG,GAAI9X,CAAAA,EAAW,EAAG,CAAA,CAC9E,QAAS,SAAY,CACnB,GAAM,CAAE,KAAA1H,CAAAA,CAAM,MAAA,CAAAC,CAAO,CAAA,CAAI,MAAM+C,CAAAA,CAAQ,KAAA,CAAM,CAC3C,KAAA,CAAOqd,GACP,SAAA,CAAW,CACT,UAAA,CAAAb,CAAAA,CACA,QAAA9X,CACF,CACF,CAAC,CAAA,CAED,GAAIzH,CAAAA,CACF,MAAMA,CAAAA,CAGR,OAAOD,EAAK,uBACd,CAAA,CACA,GAAGqC,CACL,CAAC,CAGH","file":"index.js","sourcesContent":["import * as React from 'react'\nimport { type ReactNode } from 'react'\nimport type { Persister } from '@tanstack/query-persist-client-core'\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query'\nimport { ReactQueryDevtools } from '@tanstack/react-query-devtools'\nimport { PersistQueryClientProvider } from '@tanstack/react-query-persist-client'\n\nimport type { AppwriteClient } from './client'\n\nexport const AppwriteContext = React.createContext<AppwriteClient | null>(null)\n\nconst defaultQueryClient = new QueryClient()\n\n/**\n * React context provider that supplies the Appwrite client and QueryClient to all child hooks.\n * Supports optional `persister` for offline cache persistence and `onCacheRestored` callback.\n * Must wrap any component using Appwrite hooks.\n *\n * @example\n * ```tsx\n * <AppwriteProvider client={client}>\n * <App />\n * </AppwriteProvider>\n * ```\n */\nexport function AppwriteProvider({\n client,\n queryClient,\n persister,\n onCacheRestored,\n children,\n}: {\n client: AppwriteClient\n queryClient?: QueryClient\n persister?: Persister\n onCacheRestored?: () => void\n children: ReactNode\n}) {\n const qc = queryClient ?? defaultQueryClient\n\n if (persister) {\n return (\n <PersistQueryClientProvider\n client={qc}\n persistOptions={{\n persister,\n dehydrateOptions: {\n shouldDehydrateMutation: (mutation) => mutation.state.isPaused,\n shouldDehydrateQuery: (query) => query.state.status === 'success',\n },\n }}\n onSuccess={() => {\n void qc.resumePausedMutations()\n onCacheRestored?.()\n }}\n >\n <AppwriteContext.Provider value={client}>{children}</AppwriteContext.Provider>\n <ReactQueryDevtools initialIsOpen={false} />\n </PersistQueryClientProvider>\n )\n }\n\n return (\n <QueryClientProvider client={qc}>\n <AppwriteContext.Provider value={client}>{children}</AppwriteContext.Provider>\n <ReactQueryDevtools initialIsOpen={false} />\n </QueryClientProvider>\n )\n}\n","import { useContext } from 'react'\n\nimport { AppwriteContext } from './AppwriteProvider'\n\n/**\n * Returns the Appwrite client instance from context.\n * Must be used within an {@link AppwriteProvider}. Throws if called outside the provider.\n */\nexport function useAppwrite() {\n const ctx = useContext(AppwriteContext)\n if (!ctx) throw new Error('Wrap your app in <AppwriteProvider>')\n return ctx\n}\n","import { useContext } from 'react'\nimport { QueryClientContext } from '@tanstack/react-query'\n\n/**\n * Returns the TanStack Query `QueryClient` from the nearest `QueryClientProvider`.\n * Throws if called outside a provider.\n */\nexport function useQueryClient() {\n const ctx = useContext(QueryClientContext)\n if (!ctx) throw new Error('Wrap your app in <QueryClientProvider>')\n return ctx\n}\n","import type { UseMutationOptions } from '@tanstack/react-query'\nimport { useMutation as useReactMutation } from '@tanstack/react-query'\n\nimport type { AppwriteException } from './types'\nimport { useQueryClient } from './useQueryClient'\n\n/**\n * Wrapper around TanStack Query's `useMutation` that automatically injects the Appwrite-managed `QueryClient`.\n * Use this instead of importing `useMutation` from `@tanstack/react-query` directly.\n */\nexport function useMutation<\n TData = unknown,\n TError extends AppwriteException[] = [],\n TVariables = void,\n TContext = unknown,\n>(options: UseMutationOptions<TData, TError, TVariables, TContext>) {\n const queryClient = useQueryClient()\n return useReactMutation<TData, TError, TVariables, TContext>(options, queryClient)\n}\n","import type {\n DefinedInitialDataOptions,\n QueryKey,\n UndefinedInitialDataOptions,\n UseQueryOptions,\n} from '@tanstack/react-query'\nimport { useQuery as useReactQuery } from '@tanstack/react-query'\n\nimport type { AppwriteException } from './types'\nimport { useQueryClient } from './useQueryClient'\n\n/**\n * Wrapper around TanStack Query's `useQuery` that automatically injects the Appwrite-managed `QueryClient`.\n * Use this instead of importing `useQuery` from `@tanstack/react-query` directly.\n */\nexport function useQuery<\n TQueryFnData,\n TError extends AppwriteException[],\n TData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options:\n | UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>\n | DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>\n | UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n) {\n const queryClient = useQueryClient()\n return useReactQuery<TQueryFnData, TError, TData, TQueryKey>(options, queryClient)\n}\n","import type {\n DefinedInitialDataOptions,\n QueryKey,\n UndefinedInitialDataOptions,\n UseQueryOptions,\n} from '@tanstack/react-query'\nimport { useQuery as useReactQuery } from '@tanstack/react-query'\n\nimport type { AppwriteException } from './types'\nimport { useQueryClient } from './useQueryClient'\n\n/**\n * Like {@link useQuery}, but the query is disabled by default and only runs when `run()` is called.\n * @returns `{ run, query }` — `run` triggers the fetch, `query` contains the standard query result.\n */\nexport function useLazyQuery<\n TQueryFnData,\n TError extends AppwriteException[],\n TData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options:\n | UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>\n | DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>\n | UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n) {\n const queryClient = useQueryClient()\n const query = useReactQuery<TQueryFnData, TError, TData, TQueryKey>(\n { ...options, enabled: false },\n queryClient,\n )\n\n return { run: query.refetch, query }\n}\n","import type { QueryKey, UseSuspenseQueryOptions } from '@tanstack/react-query'\nimport { useSuspenseQuery as useSuspenseReactQuery } from '@tanstack/react-query'\n\nimport type { AppwriteException } from './types'\nimport { useQueryClient } from './useQueryClient'\n\n/**\n * Wrapper around TanStack Query's `useSuspenseQuery` that automatically injects the Appwrite-managed `QueryClient`.\n * Suspends the component while loading. Use with React Suspense boundaries.\n */\nexport function useSuspenseQuery<\n TQueryFnData,\n TError extends AppwriteException[],\n TData,\n TQueryKey extends QueryKey = QueryKey,\n>(options: UseSuspenseQueryOptions<TQueryFnData, TError, TData, TQueryKey>) {\n const queryClient = useQueryClient()\n return useSuspenseReactQuery<TQueryFnData, TError, TData, TQueryKey>(options, queryClient)\n}\n","import type { ResultOf, TypedDocumentNode } from '@graphql-typed-document-node/core'\nimport { print } from 'graphql'\n\nimport {\n Account,\n Avatars,\n Client,\n Databases,\n Functions,\n Graphql,\n Locale,\n Messaging,\n Realtime,\n type RealtimeLike,\n Storage,\n TablesDB,\n Teams,\n} from './types'\n\ntype Variables = Record<string, unknown>\n\nconst graphqlObject = (graphqlAppwrite: Graphql) => ({\n client: graphqlAppwrite.client,\n query: async <T, V extends Variables = Variables>({\n query,\n variables,\n }: {\n query: TypedDocumentNode<T, V>\n variables?: V\n }) => {\n const { data, errors } = (await graphqlAppwrite.query({\n query: { query: print(query), variables },\n })) as { data: ResultOf<typeof query>; errors: unknown[] }\n return { data, errors }\n },\n mutation: async <T, V extends Variables = Variables>({\n query,\n variables,\n }: {\n query: TypedDocumentNode<T, V>\n variables?: V\n }) => {\n const { data, errors } = (await graphqlAppwrite.mutation({\n query: { query: print(query), variables },\n })) as { data: ResultOf<typeof query>; errors: unknown[] }\n return { data, errors }\n },\n})\n\n/**\n * Creates and configures an Appwrite client with all service instances.\n *\n * @param config - The Appwrite connection config with `endpoint` and `projectId`.\n * @returns An object containing `client`, `account`, `avatars`, `realtime`, `storage`, `graphql`, `databases`, `functions`, `locale`, `messaging`, `tablesDB`, and `teams`.\n *\n * @example\n * ```ts\n * const client = createAppwriteClient({\n * endpoint: 'https://cloud.appwrite.io/v1',\n * projectId: 'my-project',\n * })\n * ```\n */\nexport function createAppwriteClient({\n endpoint,\n projectId,\n}: {\n endpoint: string\n projectId: string\n}) {\n const client = new Client()\n client.setEndpoint(endpoint).setProject(projectId)\n\n return {\n client,\n account: new Account(client),\n avatars: new Avatars(client),\n realtime: (typeof Realtime === 'function' ? new Realtime(client) : client) as RealtimeLike,\n storage: new Storage(client),\n graphql: graphqlObject(new Graphql(client)),\n databases: new Databases(client),\n functions: new Functions(client),\n locale: new Locale(client),\n messaging: new Messaging(client),\n tablesDB: new TablesDB(client),\n teams: new Teams(client),\n }\n}\n\nexport type AppwriteClient = ReturnType<typeof createAppwriteClient>\n","interface Account {\n acc?: string\n}\n\ninterface Database {\n db?: string\n}\n\ninterface Collection {\n col?: string\n}\n\ninterface Document {\n doc?: string\n}\n\ninterface TablesDB {\n tdb?: string\n}\n\ninterface Table {\n tbl?: string\n}\n\ninterface Row {\n row?: string\n}\n\ninterface Bucket {\n bucket?: string\n}\n\ninterface FileResource {\n file?: string\n}\n\ninterface Actionable {\n actionable?: string\n}\n\ninterface Execution {\n exec?: string\n}\n\ninterface Func {\n func?: string\n}\n\ninterface Team {\n team?: string\n}\n\ninterface Membership {\n membership?: string\n}\n\ninterface Locale {\n locale?: string\n}\n\ninterface Messaging {\n messaging?: string\n}\n\ninterface Transaction {\n transaction?: string\n}\n\nexport class Keys<T> {\n private keys: string[] = ['appwrite']\n private _type!: T\n\n private constructor() {}\n\n private static create<T>(...segments: string[]) {\n const k = new Keys<T>()\n k.keys.push(...segments)\n return k\n }\n\n static account() {\n return Keys.create<Account>('account')\n }\n\n static databases() {\n return Keys.create<Database>('databases')\n }\n\n static database(id: string) {\n return Keys.create<Database>('databases', id)\n }\n\n static tablesDB(id: string) {\n return Keys.create<TablesDB>('tablesDB', id)\n }\n\n static buckets() {\n return Keys.create<Bucket>('buckets')\n }\n\n static bucket(id: string) {\n return Keys.create<Bucket>('buckets', id)\n }\n\n static functions() {\n return Keys.create<Func>('functions')\n }\n\n static function(id: string) {\n return Keys.create<Func>('functions', id)\n }\n\n static teams() {\n return Keys.create<Team>('teams')\n }\n\n static team(id: string) {\n return Keys.create<Team>('teams', id)\n }\n\n static locale() {\n return Keys.create<Locale>('locale')\n }\n\n static messaging() {\n return Keys.create<Messaging>('messaging')\n }\n\n jwt(this: Keys<Account>) {\n this.keys.push('jwt')\n return this as unknown as Keys<Actionable>\n }\n\n anonymous(this: Keys<Account>) {\n this.keys.push('anonymous')\n return this as unknown as Keys<Actionable>\n }\n\n emailToken(this: Keys<Account>) {\n this.keys.push('emailToken')\n return this as unknown as Keys<Actionable>\n }\n\n emailVerification(this: Keys<Account>) {\n this.keys.push('emailVerification')\n return this as unknown as Keys<Actionable>\n }\n\n magicUrl(this: Keys<Account>) {\n this.keys.push('magicUrl')\n return this as unknown as Keys<Actionable>\n }\n\n mfaAuthenticator(this: Keys<Account>) {\n this.keys.push('mfaAuthenticator')\n return this as unknown as Keys<Actionable>\n }\n\n mfaChallenge(this: Keys<Account>) {\n this.keys.push('mfaChallenge')\n return this as unknown as Keys<Actionable>\n }\n\n mfaCodes(this: Keys<Account>) {\n this.keys.push('mfaCodes')\n return this as unknown as Keys<Actionable>\n }\n\n oauth2Token(this: Keys<Account>) {\n this.keys.push('oauth2Token')\n return this as unknown as Keys<Actionable>\n }\n\n phoneToken(this: Keys<Account>) {\n this.keys.push('phoneToken')\n return this as unknown as Keys<Actionable>\n }\n\n phoneVerification(this: Keys<Account>) {\n this.keys.push('phoneVerification')\n return this as unknown as Keys<Actionable>\n }\n\n pushTarget(this: Keys<Account>) {\n this.keys.push('pushTarget')\n return this as unknown as Keys<Actionable>\n }\n\n identity(this: Keys<Account>) {\n this.keys.push('identity')\n return this as unknown as Keys<Actionable>\n }\n\n prefs(this: Keys<Account>) {\n this.keys.push('prefs')\n return this as unknown as Keys<Actionable>\n }\n\n login(this: Keys<Account>) {\n this.keys.push('login')\n return this as unknown as Keys<Actionable>\n }\n\n signUp(this: Keys<Account>) {\n this.keys.push('signUp')\n return this as unknown as Keys<Actionable>\n }\n\n name(this: Keys<Account>) {\n this.keys.push('name')\n return this as unknown as Keys<Actionable>\n }\n\n email(this: Keys<Account>) {\n this.keys.push('email')\n return this as unknown as Keys<Actionable>\n }\n\n phone(this: Keys<Account>) {\n this.keys.push('phone')\n return this as unknown as Keys<Actionable>\n }\n\n password(this: Keys<Account>) {\n this.keys.push('password')\n return this as unknown as Keys<Actionable>\n }\n\n recovery(this: Keys<Account>) {\n this.keys.push('recovery')\n return this as unknown as Keys<Actionable>\n }\n\n mfa(this: Keys<Account>) {\n this.keys.push('mfa')\n return this as unknown as Keys<Actionable>\n }\n\n status(this: Keys<Account>) {\n this.keys.push('status')\n return this as unknown as Keys<Actionable>\n }\n\n logs(this: Keys<Account>) {\n this.keys.push('logs')\n return this as unknown as Keys<Actionable>\n }\n\n verification(this: Keys<Account>) {\n this.keys.push('verification')\n return this as unknown as Keys<Actionable>\n }\n\n session(this: Keys<Account>, id?: string) {\n this.keys.push('sessions')\n if (id) this.keys.push(id)\n return this as unknown as Keys<Actionable>\n }\n\n sessions(this: Keys<Account>) {\n return [...this.keys, 'sessions'] as const\n }\n\n identities(this: Keys<Account>) {\n return [...this.keys, 'identities'] as const\n }\n\n mfaFactors(this: Keys<Account>) {\n return [...this.keys, 'mfaFactors'] as const\n }\n\n collections(this: Keys<Database>) {\n this.keys.push('collections')\n return this as unknown as Keys<Collection>\n }\n\n collection(this: Keys<Database>, id: string) {\n this.keys.push('collections', id)\n return this as unknown as Keys<Collection>\n }\n\n transactions(this: Keys<Database>) {\n this.keys.push('transactions')\n return this as unknown as Keys<Transaction>\n }\n\n transaction(this: Keys<Database>, id: string) {\n this.keys.push('transactions', id)\n return this as unknown as Keys<Transaction>\n }\n\n documents(this: Keys<Collection>) {\n this.keys.push('documents')\n return this as unknown as Keys<Actionable>\n }\n\n document(this: Keys<Collection>, id: string) {\n this.keys.push('documents', id)\n return this as unknown as Keys<Document>\n }\n\n operations(this: Keys<Transaction>) {\n this.keys.push('operations')\n return this as unknown as Keys<Actionable>\n }\n\n table(this: Keys<TablesDB>, id: string) {\n this.keys.push('table', id)\n return this as unknown as Keys<Table>\n }\n\n rows(this: Keys<Table>) {\n this.keys.push('rows')\n return this as unknown as Keys<Actionable>\n }\n\n row(this: Keys<Table>, id: string) {\n this.keys.push('row', id)\n return this as unknown as Keys<Row>\n }\n\n files(this: Keys<Bucket>) {\n this.keys.push('files')\n return this as unknown as Keys<Actionable>\n }\n\n file(this: Keys<Bucket>, id: string) {\n this.keys.push('files', id)\n return this as unknown as Keys<FileResource>\n }\n\n executions(this: Keys<Func>) {\n this.keys.push('executions')\n return this as unknown as Keys<Actionable>\n }\n\n execution(this: Keys<Func>, id: string) {\n this.keys.push('executions', id)\n return this as unknown as Keys<Execution>\n }\n\n teamName(this: Keys<Team>) {\n this.keys.push('name')\n return this as unknown as Keys<Actionable>\n }\n\n teamPrefs(this: Keys<Team>) {\n this.keys.push('prefs')\n return this as unknown as Keys<Actionable>\n }\n\n memberships(this: Keys<Team>) {\n this.keys.push('memberships')\n return this as unknown as Keys<Actionable>\n }\n\n membership(this: Keys<Team>, id: string) {\n this.keys.push('memberships', id)\n return this as unknown as Keys<Membership>\n }\n\n membershipStatus(this: Keys<Team>) {\n this.keys.push('membershipStatus')\n return this as unknown as Keys<Actionable>\n }\n\n continents(this: Keys<Locale>) {\n return [...this.keys, 'continents'] as const\n }\n\n countries(this: Keys<Locale>) {\n return [...this.keys, 'countries'] as const\n }\n\n countriesEU(this: Keys<Locale>) {\n return [...this.keys, 'countriesEU'] as const\n }\n\n countriesPhones(this: Keys<Locale>) {\n return [...this.keys, 'countriesPhones'] as const\n }\n\n currencies(this: Keys<Locale>) {\n return [...this.keys, 'currencies'] as const\n }\n\n languages(this: Keys<Locale>) {\n return [...this.keys, 'languages'] as const\n }\n\n codes(this: Keys<Locale>) {\n return [...this.keys, 'codes'] as const\n }\n\n subscriber(this: Keys<Messaging>) {\n this.keys.push('subscriber')\n return this as unknown as Keys<Actionable>\n }\n\n create() {\n return [...this.keys, 'create'] as const\n }\n\n upsert() {\n return [...this.keys, 'upsert'] as const\n }\n\n update() {\n return [...this.keys, 'update'] as const\n }\n\n delete() {\n return [...this.keys, 'delete'] as const\n }\n\n key() {\n return [...this.keys] as const\n }\n}\n","import { graphql as gql } from 'gql.tada'\n\nimport type { AppwriteClient } from '../client'\nimport { Keys } from '../query/Keys'\n\nexport const getAccount = gql(/* GraphQL */ `\n query AccountGet {\n accountGet {\n _id\n name\n email\n prefs {\n data\n }\n }\n }\n`)\n\nexport function getAccountQuery(client: AppwriteClient) {\n return {\n queryKey: Keys.account().key(),\n queryFn: async () => {\n const { data, errors } = await client.graphql.query({\n query: getAccount,\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountGet\n },\n retry: false,\n }\n}\n","import { useEffect, useState } from 'react'\nimport type { ResultOf } from '@graphql-typed-document-node/core'\nimport { Channel } from 'appwrite'\nimport { castDraft, produce } from 'immer'\n\nimport type { getAccount } from './queryOptions'\nimport { getAccountQuery } from './queryOptions'\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Models, Prettify, QueryOptions, RealtimeLike } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useLazyQuery } from '../useLazyQuery'\nimport { useQuery } from '../useQuery'\nimport { useQueryClient } from '../useQueryClient'\n\n/** The result returned by the {@link useAccount} query. */\nexport type AccountResult = Prettify<ResultOf<typeof getAccount>['accountGet']>\n\n/**\n * Lazily fetches the current authenticated user's account. The query is\n * disabled until `run()` is called. Subscribes to real-time account updates\n * once activated.\n *\n * @example\n * ```tsx\n * const { data, run, isLoading } = useLazyAccount()\n *\n * // Call run() to trigger the query\n * run()\n * ```\n *\n * @returns A lazy query result with a `run()` function to trigger fetching ({@link AccountResult}).\n */\nexport function useLazyAccount() {\n const client = useAppwrite()\n const queryClient = useQueryClient()\n const [isActive, setIsActive] = useState(false)\n\n const queryResult = useLazyQuery<AccountResult, AppwriteException[], AccountResult>(\n getAccountQueryOptions(client),\n )\n\n useEffect(() => {\n if (!isActive) return\n\n const subscriptionPromise = subscribe(client.realtime, queryClient)\n return () => {\n void subscriptionPromise.then((sub) => sub.close())\n }\n }, [isActive, client.realtime, queryClient])\n\n return {\n ...queryResult,\n run: () => {\n setIsActive(true)\n return queryResult.run()\n },\n }\n}\n\n/**\n * Fetches the current authenticated user's account and subscribes to\n * real-time updates.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useAccount()\n * ```\n *\n * @param opts - Optional query options to customize caching, refetching, etc.\n * @returns A `UseQueryResult` with the authenticated user's account ({@link AccountResult}).\n */\nexport function useAccount(opts: QueryOptions = {}) {\n const client = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useQuery<AccountResult, AppwriteException[], AccountResult>({\n ...getAccountQueryOptions(client),\n ...opts,\n })\n\n useEffect(() => {\n const subscriptionPromise = subscribe(client.realtime, queryClient)\n return () => {\n void subscriptionPromise.then((sub) => sub.close())\n }\n }, [client.realtime, queryClient])\n\n return queryResult\n}\n\nfunction getAccountQueryOptions(client: ReturnType<typeof useAppwrite>) {\n return getAccountQuery(client)\n}\n\nfunction subscribe<Preferences extends Models.Preferences>(\n realtime: RealtimeLike,\n queryClient: ReturnType<typeof useQueryClient>,\n) {\n return realtime.subscribe<Models.User<Preferences>>(Channel.account(), (response) => {\n const isUpdatingPreferences = response.events.some((event) => event.endsWith('prefs'))\n\n if (isUpdatingPreferences) {\n queryClient.setQueryData<Models.User<Preferences>>(Keys.account().key(), (account) =>\n produce(account, (draft) => {\n if (draft) {\n draft.prefs = castDraft(response.payload.prefs) as typeof draft.prefs\n }\n }),\n )\n\n return\n }\n\n queryClient.setQueryData<Models.User<Preferences>>(Keys.account().key(), response.payload)\n })\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst createAnonymousSession = gql(/* GraphQL */ `\n mutation CreateAnonymousSession {\n accountCreateAnonymousSession {\n _id\n expire\n current\n }\n }\n`)\n\n/** The result returned by the {@link useCreateAnonymousSession} mutation. */\nexport type CreateAnonymousSessionResult = Prettify<\n ResultOf<typeof createAnonymousSession>['accountCreateAnonymousSession']\n>\n\n/**\n * Mutation to create an anonymous session.\n *\n * Invalidates account queries and the anonymous session cache key on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useCreateAnonymousSession()\n *\n * mutate()\n * ```\n *\n * This mutation takes no variables.\n *\n * @returns A `UseMutationResult` with the created session's `_id`, `expire`, and `current` fields.\n */\nexport function useCreateAnonymousSession() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<CreateAnonymousSessionResult, AppwriteException[], void>({\n mutationKey: Keys.account().anonymous().create(),\n mutationFn: async () => {\n const { data, errors } = await graphql.mutation({\n query: createAnonymousSession,\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountCreateAnonymousSession\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: Keys.account().key() })\n void queryClient.invalidateQueries({\n queryKey: Keys.account().anonymous().create(),\n })\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\n\nconst createEmailToken = gql(/* GraphQL */ `\n mutation CreateEmailToken($userId: String!, $email: String!, $phrase: Boolean) {\n accountCreateEmailToken(userId: $userId, email: $email, phrase: $phrase) {\n expire\n }\n }\n`)\n\n/** The variables accepted by the {@link useCreateEmailToken} mutation. */\nexport type CreateEmailTokenVariables = Prettify<VariablesOf<typeof createEmailToken>>\n/** The result returned by the {@link useCreateEmailToken} mutation. */\nexport type CreateEmailTokenResult = Prettify<\n ResultOf<typeof createEmailToken>['accountCreateEmailToken']\n>\n\n/**\n * Mutation to create an email token for passwordless authentication.\n *\n * Sends a token to the user's email that can be exchanged for a session\n * via {@link useCreateSession}.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useCreateEmailToken()\n *\n * mutate({\n * userId: 'user-123',\n * email: 'user@example.com',\n * phrase: true,\n * })\n * ```\n *\n * **Variables** ({@link CreateEmailTokenVariables}):\n * - `userId` — Unique user identifier\n * - `email` — User's email address to send the token to\n * - `phrase` — Optional. When `true`, returns a phrase-based token instead of a numeric code\n *\n * @returns A `UseMutationResult` with the token's `expire` timestamp.\n */\nexport function useCreateEmailToken() {\n const { graphql } = useAppwrite()\n\n const queryResult = useMutation<\n CreateEmailTokenResult,\n AppwriteException[],\n CreateEmailTokenVariables\n >({\n mutationKey: Keys.account().emailToken().create(),\n mutationFn: async ({ userId, email, phrase }) => {\n const { data, errors } = await graphql.mutation({\n query: createEmailToken,\n variables: {\n userId,\n email,\n phrase,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountCreateEmailToken\n },\n })\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\nimport { useSuspenseQuery } from '../useSuspenseQuery'\n\n//The documentation says there should be a duration parameter, but including one causes a server error.\nconst accountCreateJWT = gql(/* GraphQL */ `\n mutation CreateJWT {\n accountCreateJWT {\n jwt\n }\n }\n`)\n\n/** The result returned by the {@link useCreateJWT} mutation. */\nexport type CreateJWTResult = Prettify<ResultOf<typeof accountCreateJWT>['accountCreateJWT']>\n\n/**\n * Mutation to create a JSON Web Token for the current session.\n *\n * On success, the JWT is automatically set on the GraphQL client via\n * `graphql.client.setJWT()` and cached in the query store. The token\n * is garbage-collected after `gcTime` milliseconds (default: 10 minutes).\n *\n * @example\n * ```tsx\n * const { mutate, data, isPending } = useCreateJWT()\n *\n * // Create a JWT with default 10-minute gc time\n * mutate()\n *\n * // Access the token\n * console.log(data?.jwt)\n * ```\n *\n * @example\n * ```tsx\n * // Custom gc time (30 minutes)\n * const { mutate } = useCreateJWT({ gcTime: 1800000 })\n * ```\n *\n * This mutation takes no variables.\n *\n * @param opts - Optional config. `gcTime` controls garbage collection time (default: 10 minutes).\n * @returns A `UseMutationResult` with the created `jwt` string.\n */\nexport function useCreateJWT({ gcTime = 600000 }: { gcTime?: number } = {}) {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<CreateJWTResult, AppwriteException[], void>({\n gcTime,\n mutationKey: Keys.account().jwt().create(),\n mutationFn: async () => {\n const { data, errors } = await graphql.mutation({\n query: accountCreateJWT,\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountCreateJWT\n },\n onSuccess: (data) => {\n graphql.client.setJWT(data.jwt)\n queryClient.setQueryData(Keys.account().jwt().create(), data.jwt, {\n updatedAt: Date.now(),\n })\n },\n })\n\n return queryResult\n}\n\n/**\n * Suspense variant of {@link useCreateJWT}.\n *\n * Suspends the component while creating the JWT. Sets the JWT on the\n * GraphQL client automatically on success. Ideal for use with React\n * `<Suspense>` boundaries.\n *\n * @example\n * ```tsx\n * // Wrap in a <Suspense> boundary\n * const { data } = useSuspenseCreateJWT()\n *\n * // JWT is guaranteed to be available after suspension resolves\n * console.log(data.jwt)\n * ```\n *\n * This query takes no variables.\n *\n * @param opts - Optional config. `gcTime` controls garbage collection time (default: 10 minutes).\n * @returns A `UseSuspenseQueryResult` with the created `jwt` string.\n */\nexport function useSuspenseCreateJWT({ gcTime = 600000 }: { gcTime?: number } = {}) {\n const { graphql } = useAppwrite()\n\n const queryResult = useSuspenseQuery<CreateJWTResult, AppwriteException[], CreateJWTResult>({\n gcTime,\n queryKey: Keys.account().jwt().create(),\n queryFn: async () => {\n const { data, errors } = await graphql.mutation({\n query: accountCreateJWT,\n })\n\n if (errors) {\n throw errors\n }\n\n graphql.client.setJWT(data.accountCreateJWT.jwt)\n return data.accountCreateJWT\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\n\nconst createMagicURLToken = gql(/* GraphQL */ `\n mutation CreateMagicURLToken($userId: String!, $email: String!, $url: String, $phrase: Boolean) {\n accountCreateMagicURLToken(userId: $userId, email: $email, url: $url, phrase: $phrase) {\n expire\n }\n }\n`)\n\n/** The variables accepted by the {@link useCreateMagicURLToken} mutation. */\nexport type CreateMagicURLTokenVariables = Prettify<VariablesOf<typeof createMagicURLToken>>\n/** The result returned by the {@link useCreateMagicURLToken} mutation. */\nexport type CreateMagicURLTokenResult = Prettify<\n ResultOf<typeof createMagicURLToken>['accountCreateMagicURLToken']\n>\n\n/**\n * Mutation to send a magic URL login token to a user's email.\n *\n * The magic URL link contains a `userId` and `secret` that can be used\n * with {@link useUpdateMagicURLSession} to create a session.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useCreateMagicURLToken()\n *\n * mutate({\n * userId: 'user-123',\n * email: 'user@example.com',\n * url: 'https://example.com/magic-login',\n * phrase: true,\n * })\n * ```\n *\n * **Variables** ({@link CreateMagicURLTokenVariables}):\n * - `userId` — Unique user identifier\n * - `email` — User's email address to send the magic URL to\n * - `url` — Optional. Custom URL for the magic link redirect\n * - `phrase` — Optional. When `true`, returns a phrase-based token instead of a numeric code\n *\n * @returns A `UseMutationResult` with the token's `expire` timestamp.\n */\nexport function useCreateMagicURLToken() {\n const { graphql } = useAppwrite()\n\n const queryResult = useMutation<\n CreateMagicURLTokenResult,\n AppwriteException[],\n CreateMagicURLTokenVariables\n >({\n mutationKey: Keys.account().magicUrl().create(),\n mutationFn: async ({ userId, email, url, phrase }) => {\n const { data, errors } = await graphql.mutation({\n query: createMagicURLToken,\n variables: {\n userId,\n email,\n url,\n phrase,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountCreateMagicURLToken\n },\n })\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { AuthenticatorType } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst accountCreateMfaAuthenticator = gql(/* GraphQL */ `\n mutation CreateMfaAuthenticator($type: String!) {\n accountCreateMfaAuthenticator(type: $type) {\n secret\n uri\n }\n }\n`)\n\ntype Vars = {\n /** The authenticator type. Defaults to `AuthenticatorType.Totp`. */\n type?: AuthenticatorType\n}\n/** The variables accepted by the {@link useCreateMfaAuthenticator} mutation. */\nexport type CreateMfaAuthenticatorVariables = Prettify<Vars>\n/** The result returned by the {@link useCreateMfaAuthenticator} mutation. */\nexport type CreateMfaAuthenticatorResult = Prettify<\n ResultOf<typeof accountCreateMfaAuthenticator>['accountCreateMfaAuthenticator']\n>\n\n/**\n * Mutation to create an MFA authenticator (e.g., TOTP).\n *\n * Returns a `secret` and `uri` that can be used to generate a QR code\n * for the user to scan with an authenticator app. The authenticator must\n * be verified with {@link useUpdateMfaAuthenticator} before it becomes active.\n * Invalidates MFA authenticator queries on success.\n *\n * @example\n * ```tsx\n * import { AuthenticatorType } from '@zeroin.earth/appwrite-graphql'\n *\n * const { mutate, data, isPending } = useCreateMfaAuthenticator()\n *\n * mutate({ type: AuthenticatorType.Totp })\n *\n * // Use data.uri to generate a QR code\n * // Use data.secret as a manual entry fallback\n * ```\n *\n * **Variables** ({@link CreateMfaAuthenticatorVariables}):\n * - `type` — The authenticator type ({@link AuthenticatorType}). Defaults to `AuthenticatorType.Totp`.\n *\n * @returns A `UseMutationResult` with the authenticator's `secret` and `uri` for QR code generation.\n */\nexport function useCreateMfaAuthenticator() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<\n CreateMfaAuthenticatorResult,\n AppwriteException[],\n CreateMfaAuthenticatorVariables\n >({\n mutationKey: Keys.account().mfaAuthenticator().create(),\n mutationFn: async ({ type = AuthenticatorType.Totp }) => {\n const { data, errors } = await graphql.mutation({\n query: accountCreateMfaAuthenticator,\n variables: {\n type,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountCreateMfaAuthenticator\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({\n queryKey: Keys.account().mfaAuthenticator().key(),\n })\n },\n })\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, AuthenticationFactor, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\n\nconst accountCreateMfaChallenge = gql(/* GraphQL */ `\n mutation CreateMfaChallenge($factor: String!) {\n accountCreateMfaChallenge(factor: $factor) {\n _id\n userId\n expire\n }\n }\n`)\n\ntype Vars = {\n /** The authentication factor. Defaults to `AuthenticatorType.Totp`. */\n factor: AuthenticationFactor\n}\n/** The variables accepted by the {@link useCreateMfaChallenge} mutation. */\nexport type CreateMfaChallengeVariables = Prettify<Vars>\n/** The result returned by the {@link useCreateMfaChallenge} mutation. */\nexport type CreateMfaChallengeResult = Prettify<\n ResultOf<typeof accountCreateMfaChallenge>['accountCreateMfaChallenge']\n>\n\n/**\n * Mutation to create an MFA challenge for a given factor (e.g., `\"totp\"`, `\"phone\"`, `\"email\"`).\n *\n * Creates a challenge that must be completed with {@link useUpdateMfaChallenge}\n * by providing the challenge ID and the one-time password.\n *\n * @example\n * ```tsx\n * const { mutate, data, isPending } = useCreateMfaChallenge()\n *\n * mutate({ factor: 'totp' })\n *\n * // Use data._id as the challengeId for useUpdateMfaChallenge\n * ```\n *\n * **Variables** ({@link CreateMfaChallengeVariables}):\n * - `factor` — The MFA factor to challenge (e.g., `\"totp\"`, `\"phone\"`, `\"email\"`)\n *\n * @returns A `UseMutationResult` with the challenge's `_id`, `userId`, and `expire` fields.\n */\nexport function useCreateMfaChallenge() {\n const { graphql } = useAppwrite()\n\n const queryResult = useMutation<\n CreateMfaChallengeResult,\n AppwriteException[],\n CreateMfaChallengeVariables\n >({\n mutationKey: Keys.account().mfaChallenge().create(),\n mutationFn: async ({ factor }) => {\n const { data, errors } = await graphql.mutation({\n query: accountCreateMfaChallenge,\n variables: {\n factor,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountCreateMfaChallenge\n },\n })\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst accountCreateMfaRecoveryCodes = gql(/* GraphQL */ `\n mutation CreateMfaRecoveryCodes {\n accountCreateMfaRecoveryCodes {\n recoveryCodes\n }\n }\n`)\n\n/** The result returned by the {@link useCreateMfaRecoveryCodes} mutation. */\nexport type CreateMfaRecoveryCodesResult = Prettify<\n ResultOf<typeof accountCreateMfaRecoveryCodes>['accountCreateMfaRecoveryCodes']\n>\n\n/**\n * Mutation to generate MFA recovery codes.\n *\n * Generates a new set of recovery codes that can be used as a backup\n * when the primary MFA method is unavailable. Invalidates recovery code\n * queries on success. Use {@link useUpdateMfaRecoveryCodes} to regenerate codes.\n *\n * @example\n * ```tsx\n * const { mutate, data, isPending } = useCreateMfaRecoveryCodes()\n *\n * mutate()\n *\n * // Display data.recoveryCodes to the user for safekeeping\n * ```\n *\n * This mutation takes no variables.\n *\n * @returns A `UseMutationResult` with a `recoveryCodes` array of backup codes.\n */\nexport function useCreateMfaRecoveryCodes() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<CreateMfaRecoveryCodesResult, AppwriteException[], void>({\n mutationKey: Keys.account().mfaCodes().create(),\n mutationFn: async () => {\n const { data, errors } = await graphql.mutation({\n query: accountCreateMfaRecoveryCodes,\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountCreateMfaRecoveryCodes\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({\n queryKey: Keys.account().mfaCodes().key(),\n })\n },\n })\n\n return queryResult\n}\n","import { Keys } from '../query/Keys'\nimport type { AppwriteException, OAuthProvider, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\n\ntype Vars = {\n provider: OAuthProvider\n success?: string\n failure?: string\n scopes?: string[]\n}\n\n/** The variables accepted by the {@link useCreateOAuth2Token} mutation. */\nexport type CreateOAuth2TokenVariables = Prettify<Vars>\n\n/**\n * Mutation to create an OAuth2 authentication token.\n *\n * Triggers the OAuth2 flow using the Appwrite REST SDK (not GraphQL).\n * On web, this typically redirects the user to the provider's authorization page.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useCreateOAuth2Token()\n *\n * mutate({\n * provider: OAuthProvider.Google,\n * success: 'https://example.com/auth/callback',\n * failure: 'https://example.com/auth/error',\n * scopes: ['email', 'profile'],\n * })\n * ```\n *\n * **Variables** ({@link CreateOAuth2TokenVariables}):\n * - `provider` — The OAuth2 provider (e.g., `OAuthProvider.Google`, `OAuthProvider.GitHub`)\n * - `success` — Optional. URL to redirect to on successful authentication\n * - `failure` — Optional. URL to redirect to on failed authentication\n * - `scopes` — Optional. Array of OAuth2 scopes to request from the provider\n *\n * @returns A `UseMutationResult` that resolves to `void` or a redirect URL string.\n */\nexport function useCreateOAuth2Token() {\n const { account } = useAppwrite()\n\n const queryResult = useMutation<void | string, AppwriteException[], CreateOAuth2TokenVariables>({\n mutationKey: Keys.account().oauth2Token().create(),\n mutationFn: async ({ provider, success, failure, scopes }) => {\n return account.createOAuth2Token({ provider, success, failure, scopes })\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\n\nconst createPhoneToken = gql(/* GraphQL */ `\n mutation CreatePhoneToken($userId: String!, $phone: String!) {\n accountCreatePhoneToken(userId: $userId, phone: $phone) {\n expire\n }\n }\n`)\n\n/** The variables accepted by the {@link useCreatePhoneToken} mutation. */\nexport type CreatePhoneTokenVariables = Prettify<VariablesOf<typeof createPhoneToken>>\n/** The result returned by the {@link useCreatePhoneToken} mutation. */\nexport type CreatePhoneTokenResult = Prettify<\n ResultOf<typeof createPhoneToken>['accountCreatePhoneToken']\n>\n\n/**\n * Mutation to send a phone token for SMS-based authentication.\n *\n * Sends a verification code via SMS that can be exchanged for a session\n * using {@link useCreateSession} or {@link useUpdatePhoneSession}.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useCreatePhoneToken()\n *\n * mutate({\n * userId: 'user-123',\n * phone: '+14155551234',\n * })\n * ```\n *\n * **Variables** ({@link CreatePhoneTokenVariables}):\n * - `userId` — Unique user identifier\n * - `phone` — User's phone number in E.164 format (e.g., `\"+14155551234\"`)\n *\n * @returns A `UseMutationResult` with the token's `expire` timestamp.\n */\nexport function useCreatePhoneToken() {\n const { graphql } = useAppwrite()\n\n const queryResult = useMutation<\n CreatePhoneTokenResult,\n AppwriteException[],\n CreatePhoneTokenVariables\n >({\n mutationKey: Keys.account().phoneToken().create(),\n mutationFn: async ({ userId, phone }) => {\n const { data, errors } = await graphql.mutation({\n query: createPhoneToken,\n variables: {\n userId,\n phone,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountCreatePhoneToken\n },\n })\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\n\nconst createPhoneVerification = gql(/* GraphQL */ `\n mutation CreatePhoneVerification {\n accountCreatePhoneVerification {\n expire\n }\n }\n`)\n\n/** The result returned by the {@link useCreatePhoneVerification} mutation. */\nexport type CreatePhoneVerificationResult = Prettify<\n ResultOf<typeof createPhoneVerification>['accountCreatePhoneVerification']\n>\n\n/**\n * Mutation to send a phone verification SMS to the current user.\n *\n * Sends a verification code to the phone number associated with the\n * currently authenticated user. Complete the verification with\n * {@link useUpdatePhoneVerification}.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useCreatePhoneVerification()\n *\n * mutate()\n * ```\n *\n * This mutation takes no variables.\n *\n * @returns A `UseMutationResult` with the verification's `expire` timestamp.\n */\nexport function useCreatePhoneVerification() {\n const { graphql } = useAppwrite()\n\n const queryResult = useMutation<CreatePhoneVerificationResult, AppwriteException[], void>({\n mutationKey: Keys.account().phoneVerification().create(),\n mutationFn: async () => {\n const { data, errors } = await graphql.mutation({\n query: createPhoneVerification,\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountCreatePhoneVerification\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst accountCreatePushTarget = gql(/* GraphQL */ `\n mutation CreatePushTarget($targetId: String!, $identifier: String!, $providerId: String) {\n accountCreatePushTarget(targetId: $targetId, identifier: $identifier, providerId: $providerId) {\n _id\n userId\n providerType\n identifier\n }\n }\n`)\n\n/** The variables accepted by the {@link useCreatePushTarget} mutation. */\nexport type CreatePushTargetVariables = Prettify<VariablesOf<typeof accountCreatePushTarget>>\n/** The result returned by the {@link useCreatePushTarget} mutation. */\nexport type CreatePushTargetResult = Prettify<\n ResultOf<typeof accountCreatePushTarget>['accountCreatePushTarget']\n>\n\n/**\n * Mutation to register a push notification target for the current user.\n *\n * Registers a device token so the user can receive push notifications.\n * Invalidates account queries on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useCreatePushTarget()\n *\n * mutate({\n * targetId: 'target-123',\n * identifier: 'fcm-device-token-abc',\n * providerId: 'firebase-provider',\n * })\n * ```\n *\n * **Variables** ({@link CreatePushTargetVariables}):\n * - `targetId` — Unique target identifier for the push target\n * - `identifier` — The device token or registration ID from the push notification service\n * - `providerId` — Optional. The messaging provider ID configured in Appwrite\n *\n * @returns A `UseMutationResult` with the push target's `_id`, `userId`, `providerType`, and `identifier`.\n */\nexport function useCreatePushTarget() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<\n CreatePushTargetResult,\n AppwriteException[],\n CreatePushTargetVariables\n >({\n mutationKey: Keys.account().pushTarget().create(),\n mutationFn: async ({ targetId, identifier, providerId }) => {\n const { data, errors } = await graphql.mutation({\n query: accountCreatePushTarget,\n variables: {\n targetId,\n identifier,\n providerId,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountCreatePushTarget\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: Keys.account().key() })\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst createSession = gql(/* GraphQL */ `\n mutation CreateSession($userId: String!, $secret: String!) {\n accountCreateSession(userId: $userId, secret: $secret) {\n userId\n expire\n current\n }\n }\n`)\n\n/** The variables accepted by the {@link useCreateSession} mutation. */\nexport type CreateSessionVariables = Prettify<VariablesOf<typeof createSession>>\n/** The result returned by the {@link useCreateSession} mutation. */\nexport type CreateSessionResult = Prettify<ResultOf<typeof createSession>['accountCreateSession']>\n\n/**\n * Mutation to create a session using a `userId` and `secret` (e.g., from an email/phone token).\n *\n * Exchanges a token pair for a full session. Typically used after\n * {@link useCreateEmailToken} or {@link useCreatePhoneToken}. Invalidates\n * account and session queries on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useCreateSession()\n *\n * mutate({\n * userId: 'user-123',\n * secret: 'token-secret-from-email',\n * })\n * ```\n *\n * **Variables** ({@link CreateSessionVariables}):\n * - `userId` — The user's ID received from the token creation step\n * - `secret` — The secret received from the token creation step\n *\n * @returns A `UseMutationResult` with the session's `userId`, `expire`, and `current` fields.\n */\nexport function useCreateSession() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<CreateSessionResult, AppwriteException[], CreateSessionVariables>(\n {\n mutationKey: Keys.account().session().create(),\n mutationFn: async ({ userId, secret }) => {\n const { data, errors } = await graphql.mutation({\n query: createSession,\n variables: {\n userId,\n secret,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountCreateSession\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: Keys.account().key() })\n void queryClient.invalidateQueries({\n queryKey: Keys.account().sessions(),\n })\n },\n },\n )\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\n\nconst createEmailVerification = gql(/* GraphQL */ `\n mutation CreateEmailVerification($url: String!) {\n accountCreateEmailVerification(url: $url) {\n _id\n userId\n secret\n expire\n }\n }\n`)\n\n/** The variables accepted by the {@link useCreateEmailVerification} mutation. */\nexport type CreateEmailVerificationVariables = Prettify<VariablesOf<typeof createEmailVerification>>\n/** The result returned by the {@link useCreateEmailVerification} mutation. */\nexport type CreateEmailVerificationResult = Prettify<\n ResultOf<typeof createEmailVerification>['accountCreateEmailVerification']\n>\n\n/**\n * Mutation to send an email verification link to the current user.\n *\n * The verification link redirects the user to the provided URL with `userId`\n * and `secret` query parameters that can be used with {@link useUpdateEmailVerification}\n * to complete the verification.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useCreateEmailVerification()\n *\n * mutate({\n * url: 'https://example.com/verify-email',\n * })\n * ```\n *\n * **Variables** ({@link CreateEmailVerificationVariables}):\n * - `url` — The URL to redirect the user to after clicking the verification link\n *\n * @returns A `UseMutationResult` with the verification token's `_id`, `userId`, `secret`, and `expire` fields.\n */\nexport function useCreateEmailVerification() {\n const { graphql } = useAppwrite()\n\n const queryResult = useMutation<\n CreateEmailVerificationResult,\n AppwriteException[],\n CreateEmailVerificationVariables\n >({\n mutationKey: Keys.account().emailVerification().create(),\n mutationFn: async ({ url }) => {\n const { data, errors } = await graphql.mutation({\n query: createEmailVerification,\n variables: { url },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountCreateEmailVerification\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst accountDeleteIdentity = gql(/* GraphQL */ `\n mutation DeleteIdentity($identityId: String!) {\n accountDeleteIdentity(identityId: $identityId) {\n status\n }\n }\n`)\n\n/** The variables accepted by the {@link useDeleteIdentity} mutation. */\nexport type DeleteIdentityVariables = Prettify<VariablesOf<typeof accountDeleteIdentity>>\n/** The result returned by the {@link useDeleteIdentity} mutation. */\nexport type DeleteIdentityResult = Prettify<\n ResultOf<typeof accountDeleteIdentity>['accountDeleteIdentity']\n>\n\n/**\n * Mutation hook to delete an identity by its ID.\n *\n * Removes an OAuth2 or other external identity linked to the current user's\n * account. Invalidates account queries on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useDeleteIdentity()\n *\n * mutate({ identityId: 'identity-123' })\n * ```\n *\n * **Variables** ({@link DeleteIdentityVariables}):\n * - `identityId` — The ID of the identity to delete\n *\n * @returns A `UseMutationResult` with a `status` string indicating the operation result.\n */\nexport function useDeleteIdentity() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<\n DeleteIdentityResult,\n AppwriteException[],\n DeleteIdentityVariables\n >({\n mutationKey: Keys.account().identity().delete(),\n mutationFn: async ({ identityId }) => {\n const { data, errors } = await graphql.mutation({\n query: accountDeleteIdentity,\n variables: {\n identityId,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data?.accountDeleteIdentity ?? { status: '' }\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: Keys.account().key() })\n },\n })\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { AuthenticatorType } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst deleteMFAAuthenticator = gql(/* GraphQL */ `\n mutation DeleteMfaAuthenticator($type: String!) {\n accountDeleteMfaAuthenticator(type: $type) {\n status\n }\n }\n`)\n\ntype Vars = {\n /** The authenticator type to delete. Defaults to `AuthenticatorType.Totp`. */\n type?: AuthenticatorType\n}\n/** The variables accepted by the {@link useDeleteMfaAuthenticator} mutation. */\nexport type DeleteMfaAuthenticatorVariables = Prettify<Vars>\n/** The result returned by the {@link useDeleteMfaAuthenticator} mutation. */\nexport type DeleteMfaAuthenticatorResult = Prettify<\n ResultOf<typeof deleteMFAAuthenticator>['accountDeleteMfaAuthenticator']\n>\n\n/**\n * Mutation hook to delete an MFA authenticator by type (defaults to `\"totp\"`).\n *\n * Removes the specified authenticator from the user's account. Invalidates\n * account and MFA authenticator queries on success.\n *\n * @example\n * ```tsx\n * import { AuthenticatorType } from '@zeroin.earth/appwrite-graphql'\n *\n * const { mutate, isPending } = useDeleteMfaAuthenticator()\n *\n * mutate({ type: AuthenticatorType.Totp })\n * ```\n *\n * **Variables** ({@link DeleteMfaAuthenticatorVariables}):\n * - `type` — The authenticator type to delete ({@link AuthenticatorType}). Defaults to `AuthenticatorType.Totp`.\n *\n * @returns A `UseMutationResult` with a `status` string indicating the operation result.\n */\nexport function useDeleteMfaAuthenticator() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<\n DeleteMfaAuthenticatorResult,\n AppwriteException[],\n DeleteMfaAuthenticatorVariables\n >({\n mutationKey: Keys.account().mfaAuthenticator().delete(),\n mutationFn: async ({ type = AuthenticatorType.Totp }) => {\n const { data, errors } = await graphql.mutation({\n query: deleteMFAAuthenticator,\n variables: {\n type,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data?.accountDeleteMfaAuthenticator ?? { status: '' }\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: Keys.account().key() })\n void queryClient.invalidateQueries({\n queryKey: Keys.account().mfaAuthenticator().key(),\n })\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst accountDeletePushTarget = gql(/* GraphQL */ `\n mutation DeletePushTarget($targetId: String!) {\n accountDeletePushTarget(targetId: $targetId) {\n status\n }\n }\n`)\n\n/** The variables accepted by the {@link useDeletePushTarget} mutation. */\nexport type DeletePushTargetVariables = Prettify<VariablesOf<typeof accountDeletePushTarget>>\n/** The result returned by the {@link useDeletePushTarget} mutation. */\nexport type DeletePushTargetResult = Prettify<\n ResultOf<typeof accountDeletePushTarget>['accountDeletePushTarget']\n>\n\n/**\n * Mutation hook to delete a push notification target by its ID.\n *\n * Unregisters the device from receiving push notifications. Invalidates\n * account queries on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useDeletePushTarget()\n *\n * mutate({ targetId: 'target-123' })\n * ```\n *\n * **Variables** ({@link DeletePushTargetVariables}):\n * - `targetId` — The ID of the push target to delete\n *\n * @returns A `UseMutationResult` with a `status` string indicating the operation result.\n */\nexport function useDeletePushTarget() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<\n DeletePushTargetResult,\n AppwriteException[],\n DeletePushTargetVariables\n >({\n mutationKey: Keys.account().pushTarget().delete(),\n mutationFn: async ({ targetId }) => {\n const { data, errors } = await graphql.mutation({\n query: accountDeletePushTarget,\n variables: {\n targetId,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data?.accountDeletePushTarget ?? { status: '' }\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: Keys.account().key() })\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst deleteSession = gql(/* GraphQL */ `\n mutation DeleteSession($sessionId: String!) {\n accountDeleteSession(sessionId: $sessionId) {\n status\n }\n }\n`)\n\n/** The variables accepted by the {@link useDeleteSession} mutation. */\nexport type DeleteSessionVariables = Prettify<VariablesOf<typeof deleteSession>>\n/** The result returned by the {@link useDeleteSession} mutation. */\nexport type DeleteSessionResult = Prettify<ResultOf<typeof deleteSession>['accountDeleteSession']>\n\n/**\n * Mutation hook to delete a specific session by its ID.\n *\n * Removes the session without clearing the entire query cache (unlike\n * {@link useLogout} or {@link useDeleteSessions}). Invalidates session\n * list queries on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useDeleteSession()\n *\n * mutate({ sessionId: 'session-abc' })\n * ```\n *\n * **Variables** ({@link DeleteSessionVariables}):\n * - `sessionId` — The ID of the session to delete\n *\n * @returns A `UseMutationResult` with a `status` string indicating the operation result.\n */\nexport function useDeleteSession() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<DeleteSessionResult, AppwriteException[], DeleteSessionVariables>(\n {\n mutationKey: Keys.account().session().delete(),\n mutationFn: async ({ sessionId }) => {\n const { data, errors } = await graphql.mutation({\n query: deleteSession,\n variables: {\n sessionId,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data?.accountDeleteSession ?? { status: '' }\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({\n queryKey: Keys.account().sessions(),\n })\n },\n },\n )\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst deleteSessions = gql(/* GraphQL */ `\n mutation DeleteSessions {\n accountDeleteSessions {\n status\n }\n }\n`)\n\n/** The result returned by the {@link useDeleteSessions} mutation. */\nexport type DeleteSessionsResult = Prettify<\n ResultOf<typeof deleteSessions>['accountDeleteSessions']\n>\n\n/**\n * Mutation hook to delete all sessions for the current user.\n *\n * Logs the user out of every device. Invalidates account and session queries\n * and **clears the entire query cache** on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useDeleteSessions()\n *\n * mutate()\n * ```\n *\n * This mutation takes no variables.\n *\n * @returns A `UseMutationResult` with a `status` string indicating the operation result.\n */\nexport function useDeleteSessions() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<DeleteSessionsResult, AppwriteException[], void>({\n mutationKey: Keys.account().session().delete(),\n mutationFn: async () => {\n const { data, errors } = await graphql.mutation({\n query: deleteSessions,\n })\n\n if (errors) {\n throw errors\n }\n\n return data?.accountDeleteSessions ?? { status: '' }\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: Keys.account().key() })\n void queryClient.invalidateQueries({\n queryKey: Keys.account().sessions(),\n })\n queryClient.clear()\n },\n })\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify, QueryOptions } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst getMFARecoveryCodes = gql(/* GraphQL */ `\n query GetMfaRecoveryCodes {\n accountGetMfaRecoveryCodes {\n recoveryCodes\n }\n }\n`)\n\n/** The result returned by the {@link useGetMfaRecoveryCodes} query. */\nexport type GetMfaRecoveryCodesResult = Prettify<\n ResultOf<typeof getMFARecoveryCodes>['accountGetMfaRecoveryCodes']\n>\n\n/**\n * Fetches the current user's MFA recovery codes.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useGetMfaRecoveryCodes()\n * ```\n *\n * @returns A `UseQueryResult` with the user's MFA recovery codes ({@link GetMfaRecoveryCodesResult}).\n */\nexport function useGetMfaRecoveryCodes(opts: QueryOptions = {}) {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<\n GetMfaRecoveryCodesResult,\n AppwriteException[],\n GetMfaRecoveryCodesResult\n >({\n queryKey: Keys.account().mfaCodes().key(),\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: getMFARecoveryCodes,\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountGetMfaRecoveryCodes\n },\n ...opts,\n })\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify, QueryOptions } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst accountGetPrefs = gql(/* GraphQL */ `\n query GetPrefs {\n accountGetPrefs {\n data\n }\n }\n`)\n\n/** The result returned by the {@link useGetPrefs} query. */\nexport type GetPrefsResult = Prettify<ResultOf<typeof accountGetPrefs>['accountGetPrefs']>\n\n/**\n * Fetches the current user's account preferences.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useGetPrefs()\n * ```\n *\n * @returns A `UseQueryResult` with the user's account preferences ({@link GetPrefsResult}).\n */\nexport function useGetPrefs(opts: QueryOptions = {}) {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<GetPrefsResult, AppwriteException[], GetPrefsResult>({\n queryKey: Keys.account().prefs().key(),\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: accountGetPrefs,\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountGetPrefs\n },\n ...opts,\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify, QueryOptions } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst getSession = gql(/* GraphQL */ `\n query GetSession($sessionId: String!) {\n accountGetSession(sessionId: $sessionId) {\n userId\n expire\n current\n }\n }\n`)\n\n/** The variables accepted by the {@link useGetSession} query. */\nexport type GetSessionVariables = Prettify<VariablesOf<typeof getSession>>\n/** The result returned by the {@link useGetSession} query. */\nexport type GetSessionResult = Prettify<ResultOf<typeof getSession>['accountGetSession']>\n\n/**\n * Fetches a specific session by its ID.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useGetSession({ sessionId: 'current' })\n * ```\n *\n * **Parameters** ({@link GetSessionVariables}):\n * - `sessionId` — The ID of the session to retrieve (use `'current'` for the active session).\n *\n * @returns A `UseQueryResult` with the requested session ({@link GetSessionResult}).\n */\nexport function useGetSession({ sessionId }: GetSessionVariables, opts: QueryOptions = {}) {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<GetSessionResult, AppwriteException[], GetSessionResult>({\n queryKey: Keys.account().session(sessionId).key(),\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: getSession,\n variables: { sessionId },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountGetSession\n },\n ...opts,\n })\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify, QueryOptions } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst accountListIdentities = gql(/* GraphQL */ `\n query ListIdentities {\n accountListIdentities {\n total\n identities {\n _id\n userId\n provider\n }\n }\n }\n`)\n\n/** The result returned by the {@link useListIdentities} query. */\nexport type ListIdentitiesResult = Prettify<\n ResultOf<typeof accountListIdentities>['accountListIdentities']\n>\n\n/**\n * Fetches the list of identities associated with the current user's account.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useListIdentities()\n * ```\n *\n * @returns A `UseQueryResult` with the user's identities ({@link ListIdentitiesResult}).\n */\nexport function useListIdentities(opts: QueryOptions = {}) {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<ListIdentitiesResult, AppwriteException[], ListIdentitiesResult>({\n queryKey: Keys.account().identities(),\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: accountListIdentities,\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountListIdentities\n },\n ...opts,\n })\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify, QueryOptions } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst listMFAFactors = gql(/* GraphQL */ `\n query ListMfaFactors {\n accountListMfaFactors {\n totp\n phone\n email\n }\n }\n`)\n\n/** The result returned by the {@link useListMfaFactors} query. */\nexport type ListMfaFactorsResult = Prettify<\n ResultOf<typeof listMFAFactors>['accountListMfaFactors']\n>\n\n/**\n * Fetches the available MFA factors (TOTP, phone, email) for the current user.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useListMfaFactors()\n * ```\n *\n * @returns A `UseQueryResult` with the user's MFA factors ({@link ListMfaFactorsResult}).\n */\nexport function useListMfaFactors(opts: QueryOptions = {}) {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<ListMfaFactorsResult, AppwriteException[], ListMfaFactorsResult>({\n queryKey: Keys.account().mfaFactors(),\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: listMFAFactors,\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountListMfaFactors\n },\n ...opts,\n })\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify, QueryOptions } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst accountListSessions = gql(/* GraphQL */ `\n query ListSessions {\n accountListSessions {\n sessions {\n _id\n _createdAt\n osName\n clientName\n }\n }\n }\n`)\n\n/** The result returned by the {@link useListSessions} query. */\nexport type ListSessionsResult = Prettify<\n ResultOf<typeof accountListSessions>['accountListSessions']\n>\n\n/**\n * Fetches all active sessions for the current user.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useListSessions()\n * ```\n *\n * @returns A `UseQueryResult` with the user's active sessions ({@link ListSessionsResult}).\n */\nexport function useListSessions(opts: QueryOptions = {}) {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<ListSessionsResult, AppwriteException[], ListSessionsResult>({\n queryKey: Keys.account().sessions(),\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: accountListSessions,\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountListSessions\n },\n ...opts,\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, OAuthProvider, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\n/** The variables accepted by the OAuth login mutation in {@link useLogin}. */\nexport type OAuthLoginVariables = {\n provider: OAuthProvider\n success?: string\n failure?: string\n}\n\nconst accountCreateEmailPasswordSession = gql(/* GraphQL */ `\n mutation CreateEmailPasswordSession($email: String!, $password: String!) {\n accountCreateEmailPasswordSession(email: $email, password: $password) {\n userId\n expire\n current\n }\n }\n`)\n\n/** The variables accepted by the {@link useLogin} mutation. */\nexport type LoginVariables = Prettify<VariablesOf<typeof accountCreateEmailPasswordSession>>\n/** The result returned by the {@link useLogin} mutation. */\nexport type LoginResult = Prettify<\n ResultOf<typeof accountCreateEmailPasswordSession>['accountCreateEmailPasswordSession']\n>\n\n/**\n * Returns `login` and `oAuthLogin` mutations for authenticating users.\n *\n * `login` handles email/password sessions; `oAuthLogin` handles OAuth2\n * provider sessions. Invalidates account and session queries on successful\n * email/password login.\n *\n * @example\n * ```tsx\n * const { login, oAuthLogin } = useLogin()\n *\n * // Email/password login\n * login.mutate({\n * email: 'user@example.com',\n * password: 'my-secure-password',\n * })\n * ```\n *\n * @example\n * ```tsx\n * const { login, oAuthLogin } = useLogin()\n *\n * // OAuth2 login\n * oAuthLogin.mutate({\n * provider: OAuthProvider.Google,\n * success: 'https://example.com/auth/callback',\n * failure: 'https://example.com/auth/error',\n * })\n * ```\n *\n * **`login` variables** ({@link LoginVariables}):\n * - `email` — User's email address\n * - `password` — User's password\n *\n * **`oAuthLogin` variables** ({@link OAuthLoginVariables}):\n * - `provider` — The OAuth2 provider (e.g., `OAuthProvider.Google`)\n * - `success` — Optional. URL to redirect to on successful authentication\n * - `failure` — Optional. URL to redirect to on failed authentication\n *\n * @returns An object with `login` (`UseMutationResult` with session `userId`, `expire`, `current`) and `oAuthLogin` (`UseMutationResult` that resolves to `void` or a redirect URL string).\n */\nexport function useLogin() {\n const { account, graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const login = useMutation<LoginResult, AppwriteException[], LoginVariables>({\n mutationKey: Keys.account().login().create(),\n mutationFn: async ({ email, password }) => {\n const { data, errors } = await graphql.mutation({\n query: accountCreateEmailPasswordSession,\n variables: {\n email,\n password,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountCreateEmailPasswordSession\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: Keys.account().key() })\n void queryClient.invalidateQueries({\n queryKey: Keys.account().sessions(),\n })\n },\n })\n\n const oAuthLogin = useMutation<void | string, AppwriteException[], OAuthLoginVariables>({\n mutationFn: async ({ provider, success, failure }) => {\n return account.createOAuth2Session({ provider, success, failure })\n },\n })\n\n return {\n login,\n oAuthLogin,\n }\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst deleteSession = gql(/* GraphQL */ `\n mutation DeleteSession($sessionId: String!) {\n accountDeleteSession(sessionId: $sessionId) {\n status\n }\n }\n`)\n\n/** The variables accepted by the {@link useLogout} mutation. */\nexport type LogoutVariables = Prettify<VariablesOf<typeof deleteSession>>\n/** The result returned by the {@link useLogout} mutation. */\nexport type LogoutResult = Prettify<ResultOf<typeof deleteSession>['accountDeleteSession']>\n\n/**\n * Mutation to delete a session by its ID.\n *\n * Unlike {@link useDeleteSession}, this hook **clears the entire query cache**\n * on success, making it suitable for \"log out\" flows where the user should\n * be fully de-authenticated.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useLogout()\n *\n * mutate({ sessionId: 'current' })\n * ```\n *\n * **Variables** ({@link LogoutVariables}):\n * - `sessionId` — The ID of the session to delete (use `\"current\"` for the active session)\n *\n * @returns A `UseMutationResult` with a `status` string indicating the operation result.\n */\nexport function useLogout() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<LogoutResult, AppwriteException[], LogoutVariables>({\n mutationKey: Keys.account().session().delete(),\n mutationFn: async ({ sessionId }) => {\n const { data, errors } = await graphql.mutation({\n query: deleteSession,\n variables: {\n sessionId,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data?.accountDeleteSession ?? { status: '' }\n },\n onSuccess: async () => {\n queryClient.clear()\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify, QueryOptions } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst accountListLogs = gql(/* GraphQL */ `\n query ListLogs($queries: [String!]) {\n accountListLogs(queries: $queries) {\n total\n logs {\n event\n userId\n userEmail\n userName\n mode\n ip\n time\n osCode\n osName\n osVersion\n clientType\n clientCode\n clientName\n clientVersion\n clientEngine\n clientEngineVersion\n deviceName\n deviceBrand\n deviceModel\n countryCode\n countryName\n }\n }\n }\n`)\n\n/** The variables accepted by the {@link useLogs} query. */\nexport type LogsVariables = Prettify<VariablesOf<typeof accountListLogs>>\n/** The result returned by the {@link useLogs} query. */\nexport type LogsResult = Prettify<ResultOf<typeof accountListLogs>['accountListLogs']>\n\n/**\n * Fetches the account activity logs for the current user. Accepts optional\n * query filters to narrow down results.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useLogs({ queries: ['limit(10)'] })\n * ```\n *\n * **Parameters** ({@link LogsVariables}):\n * - `queries` — Optional array of query strings to filter or paginate log entries.\n *\n * @returns A `UseQueryResult` with the user's activity logs ({@link LogsResult}).\n */\nexport function useLogs({ queries }: LogsVariables, opts: QueryOptions = {}) {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<LogsResult, AppwriteException[], LogsResult>({\n queryKey: [...Keys.account().logs().key(), ...(queries ?? [])],\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: accountListLogs,\n variables: {\n queries,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountListLogs\n },\n ...opts,\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\n\nconst createRecovery = gql(/* GraphQL */ `\n mutation CreateRecovery($email: String!, $url: String!) {\n accountCreateRecovery(email: $email, url: $url) {\n expire\n }\n }\n`)\n\n/** The variables accepted by the {@link usePasswordRecovery} mutation. */\nexport type PasswordRecoveryVariables = Prettify<VariablesOf<typeof createRecovery>>\n/** The result returned by the {@link usePasswordRecovery} mutation. */\nexport type PasswordRecoveryResult = Prettify<\n ResultOf<typeof createRecovery>['accountCreateRecovery']\n>\n\n/**\n * Sends a password recovery email to the supplied address.\n *\n * Mutation hook to send a password recovery email. On success, stores\n * the email in `localStorage` for convenience during the reset flow\n * (silently skipped in React Native environments). The recovery URL\n * receives `userId` and `secret` query parameters for use with\n * {@link useResetPassword}.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = usePasswordRecovery()\n *\n * mutate({\n * email: 'user@example.com',\n * url: 'https://example.com/reset-password',\n * })\n * ```\n *\n * **Variables** ({@link PasswordRecoveryVariables}):\n * - `email` — The email address to send the recovery link to\n * - `url` — The URL of the password reset page in your application\n *\n * @returns A `UseMutationResult` with the recovery token's `expire` timestamp.\n */\nexport function usePasswordRecovery() {\n const { graphql } = useAppwrite()\n\n const queryResult = useMutation<\n PasswordRecoveryResult,\n AppwriteException[],\n PasswordRecoveryVariables\n >({\n mutationKey: Keys.account().recovery().create(),\n mutationFn: async ({ email, url: resetUrl }) => {\n const { data, errors } = await graphql.mutation({\n query: createRecovery,\n variables: {\n email,\n url: resetUrl,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountCreateRecovery\n },\n onSuccess: async (_, variables) => {\n try {\n localStorage?.setItem('email', variables.email)\n } catch (e: any) {\n console.error(\n 'Could not save email to local storage. If you are using react-native, this is expected.',\n e,\n )\n }\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\n\nconst updateRecovery = gql(/* GraphQL */ `\n mutation UpdateRecovery($userId: String!, $secret: String!, $password: String!) {\n accountUpdateRecovery(userId: $userId, secret: $secret, password: $password) {\n expire\n }\n }\n`)\n\n/** The variables accepted by the {@link useResetPassword} mutation. */\nexport type ResetPasswordVariables = Prettify<VariablesOf<typeof updateRecovery>>\n/** The result returned by the {@link useResetPassword} mutation. */\nexport type ResetPasswordResult = Prettify<ResultOf<typeof updateRecovery>['accountUpdateRecovery']>\n\n/**\n * Mutation hook to reset a password using the recovery `userId`, `secret`, and new `password`.\n *\n * Completes the password recovery flow started by {@link usePasswordRecovery}.\n * The `userId` and `secret` are provided in the recovery URL query parameters.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useResetPassword()\n *\n * mutate({\n * userId: 'user-123',\n * secret: 'recovery-secret',\n * password: 'new-secure-password',\n * })\n * ```\n *\n * **Variables** ({@link ResetPasswordVariables}):\n * - `userId` — The user's ID from the recovery URL\n * - `secret` — The secret token from the recovery URL\n * - `password` — The new password to set\n *\n * @returns A `UseMutationResult` with the recovery token's `expire` timestamp.\n */\nexport function useResetPassword() {\n const { graphql } = useAppwrite()\n\n const queryResult = useMutation<ResetPasswordResult, AppwriteException[], ResetPasswordVariables>(\n {\n mutationKey: Keys.account().recovery().update(),\n mutationFn: async ({ userId, secret, password }) => {\n const { data, errors } = await graphql.mutation({\n query: updateRecovery,\n variables: {\n userId,\n secret,\n password,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountUpdateRecovery\n },\n },\n )\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { ID } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\n\nconst createAccount = gql(/* GraphQL */ `\n mutation CreateAccount($userId: String!, $name: String, $email: String!, $password: String!) {\n accountCreate(userId: $userId, name: $name, email: $email, password: $password) {\n name\n email\n }\n }\n`)\n\nconst verify = gql(/* GraphQL */ `\n mutation VerifyEmail($url: String!) {\n accountCreateVerification(url: $url) {\n expire\n }\n }\n`)\n\n/** The variables accepted by the {@link useSignUp} mutation. */\nexport type SignUpVariables = Prettify<\n Omit<VariablesOf<typeof createAccount>, 'userId'> & {\n userId?: string\n }\n>\n/** The result returned by the {@link useSignUp} mutation. */\nexport type SignUpResult = Prettify<ResultOf<typeof createAccount>['accountCreate']>\n\n/** The variables accepted by the verify email mutation in {@link useSignUp}. */\nexport type VerifyEmailVariables = Prettify<{\n verifyUrl: string\n}>\n/** The result returned by the verify email mutation in {@link useSignUp}. */\nexport type VerifyEmailResult = Prettify<ResultOf<typeof verify>['accountCreateVerification']>\n\n/**\n * Returns `signUp` and `verifyEmail` mutations.\n *\n * `signUp` creates a new account with email/password. `verifyEmail` sends\n * a verification email to the newly created account. A `userId` is\n * auto-generated via `ID.unique()` if not provided.\n *\n * @example\n * ```tsx\n * const { signUp, verifyEmail } = useSignUp()\n *\n * // Create a new account\n * signUp.mutate({\n * email: 'user@example.com',\n * password: 'secure-password',\n * name: 'Jane Doe',\n * })\n * ```\n *\n * @example\n * ```tsx\n * const { signUp, verifyEmail } = useSignUp()\n *\n * // Send a verification email after sign-up\n * verifyEmail.mutate({\n * verifyUrl: 'https://example.com/verify-email',\n * })\n * ```\n *\n * **`signUp` variables** ({@link SignUpVariables}):\n * - `email` — The user's email address\n * - `password` — The user's password\n * - `name` — Optional. The user's display name\n * - `userId` — Optional. Custom user ID (auto-generated if omitted)\n *\n * **`verifyEmail` variables** ({@link VerifyEmailVariables}):\n * - `verifyUrl` — The URL to redirect the user to after clicking the verification link\n *\n * @returns An object with `signUp` (`UseMutationResult` with the account's `name` and `email`) and `verifyEmail` (`UseMutationResult` with the verification token's `expire` timestamp).\n */\nexport function useSignUp() {\n const { graphql } = useAppwrite()\n\n const signUp = useMutation<SignUpResult, AppwriteException[], SignUpVariables>({\n mutationKey: Keys.account().signUp().create(),\n mutationFn: async ({ userId, email, password, name }) => {\n const { data, errors } = await graphql.mutation({\n query: createAccount,\n variables: {\n userId: userId ?? ID.unique(),\n name,\n email,\n password,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountCreate\n },\n })\n\n const verifyEmail = useMutation<VerifyEmailResult, AppwriteException[], VerifyEmailVariables>({\n mutationKey: Keys.account().emailVerification().create(),\n mutationFn: async ({ verifyUrl }) => {\n const { data, errors } = await graphql.mutation({\n query: verify,\n variables: {\n url: verifyUrl,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountCreateVerification\n },\n })\n\n return { signUp, verifyEmail }\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nexport const accountUpdateEmail = gql(/* GraphQL */ `\n mutation UpdateEmail($email: String!, $password: String!) {\n accountUpdateEmail(email: $email, password: $password) {\n name\n email\n }\n }\n`)\n\n/** The variables accepted by the {@link useUpdateEmail} mutation. */\nexport type UpdateEmailVariables = Prettify<VariablesOf<typeof accountUpdateEmail>>\n/** The result returned by the {@link useUpdateEmail} mutation. */\nexport type UpdateEmailResult = Prettify<ResultOf<typeof accountUpdateEmail>['accountUpdateEmail']>\n\n/**\n * Mutation hook to update the current user's email address.\n *\n * Requires the new email and the current password for verification.\n * Invalidates account queries on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useUpdateEmail()\n *\n * mutate({\n * email: 'new-email@example.com',\n * password: 'current-password',\n * })\n * ```\n *\n * **Variables** ({@link UpdateEmailVariables}):\n * - `email` — The new email address\n * - `password` — The user's current password for verification\n *\n * @returns A `UseMutationResult` with the updated `name` and `email` fields.\n */\nexport function useUpdateEmail() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<UpdateEmailResult, AppwriteException[], UpdateEmailVariables>({\n mutationKey: Keys.account().email().update(),\n mutationFn: async ({ email, password }) => {\n const { data, errors } = await graphql.mutation({\n query: accountUpdateEmail,\n variables: {\n email,\n password,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountUpdateEmail\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: Keys.account().key() })\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst updateEmailVerification = gql(/* GraphQL */ `\n mutation UpdateEmailVerification($userId: String!, $secret: String!) {\n accountUpdateEmailVerification(userId: $userId, secret: $secret) {\n _id\n userId\n secret\n expire\n }\n }\n`)\n\n/** The variables accepted by the {@link useUpdateEmailVerification} mutation. */\nexport type UpdateEmailVerificationVariables = Prettify<VariablesOf<typeof updateEmailVerification>>\n/** The result returned by the {@link useUpdateEmailVerification} mutation. */\nexport type UpdateEmailVerificationResult = Prettify<\n ResultOf<typeof updateEmailVerification>['accountUpdateEmailVerification']\n>\n\n/**\n * Mutation hook to confirm email verification using `userId` and `secret`.\n *\n * Completes the email verification flow started by\n * {@link useCreateEmailVerification}. The `userId` and `secret` are\n * provided in the verification URL query parameters. Invalidates account\n * queries on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useUpdateEmailVerification()\n *\n * // Extract userId and secret from the verification URL\n * mutate({\n * userId: 'user-123',\n * secret: 'verification-secret',\n * })\n * ```\n *\n * **Variables** ({@link UpdateEmailVerificationVariables}):\n * - `userId` — The user's ID from the verification URL\n * - `secret` — The secret token from the verification URL\n *\n * @returns A `UseMutationResult` with the verification's `_id`, `userId`, `secret`, and `expire` fields.\n */\nexport function useUpdateEmailVerification() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<\n UpdateEmailVerificationResult,\n AppwriteException[],\n UpdateEmailVerificationVariables\n >({\n mutationKey: Keys.account().emailVerification().update(),\n mutationFn: async ({ userId, secret }) => {\n const { data, errors } = await graphql.mutation({\n query: updateEmailVerification,\n variables: { userId, secret },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountUpdateEmailVerification\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: Keys.account().key() })\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst updateMagicURLSession = gql(/* GraphQL */ `\n mutation UpdateMagicURLSession($userId: String!, $secret: String!) {\n accountUpdateMagicURLSession(userId: $userId, secret: $secret) {\n userId\n expire\n current\n }\n }\n`)\n\n/** The variables accepted by the {@link useUpdateMagicURLSession} mutation. */\nexport type UpdateMagicURLSessionVariables = Prettify<VariablesOf<typeof updateMagicURLSession>>\n/** The result returned by the {@link useUpdateMagicURLSession} mutation. */\nexport type UpdateMagicURLSessionResult = Prettify<\n ResultOf<typeof updateMagicURLSession>['accountUpdateMagicURLSession']\n>\n\n/**\n * Mutation hook to validate a magic URL session using `userId` and `secret`.\n *\n * Completes the magic URL authentication flow started by\n * {@link useCreateMagicURLToken}. The `userId` and `secret` are provided\n * in the magic URL query parameters. Invalidates account and session\n * queries on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useUpdateMagicURLSession()\n *\n * // Extract userId and secret from the magic URL\n * mutate({\n * userId: 'user-123',\n * secret: 'magic-url-secret',\n * })\n * ```\n *\n * **Variables** ({@link UpdateMagicURLSessionVariables}):\n * - `userId` — The user's ID from the magic URL\n * - `secret` — The secret token from the magic URL\n *\n * @returns A `UseMutationResult` with the session's `userId`, `expire`, and `current` fields.\n */\nexport function useUpdateMagicURLSession() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<\n UpdateMagicURLSessionResult,\n AppwriteException[],\n UpdateMagicURLSessionVariables\n >({\n mutationKey: Keys.account().magicUrl().update(),\n mutationFn: async ({ userId, secret }) => {\n const { data, errors } = await graphql.mutation({\n query: updateMagicURLSession,\n variables: {\n userId,\n secret,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountUpdateMagicURLSession\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: Keys.account().key() })\n void queryClient.invalidateQueries({\n queryKey: Keys.account().sessions(),\n })\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst accountUpdateMFA = gql(/* GraphQL */ `\n mutation UpdateMFA($mfa: Boolean!) {\n accountUpdateMFA(mfa: $mfa) {\n mfa\n }\n }\n`)\n\n/** The variables accepted by the {@link useUpdateMfa} mutation. */\nexport type UpdateMfaVariables = Prettify<VariablesOf<typeof accountUpdateMFA>>\n/** The result returned by the {@link useUpdateMfa} mutation. */\nexport type UpdateMfaResult = Prettify<ResultOf<typeof accountUpdateMFA>['accountUpdateMFA']>\n\n/**\n * Mutation hook to enable or disable MFA on the current account.\n *\n * Toggles multi-factor authentication for the user. Invalidates account\n * and MFA factor queries on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useUpdateMfa()\n *\n * // Enable MFA\n * mutate({ mfa: true })\n *\n * // Disable MFA\n * mutate({ mfa: false })\n * ```\n *\n * **Variables** ({@link UpdateMfaVariables}):\n * - `mfa` — `true` to enable MFA, `false` to disable it\n *\n * @returns A `UseMutationResult` with the updated `mfa` boolean status.\n */\nexport function useUpdateMfa() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<UpdateMfaResult, AppwriteException[], UpdateMfaVariables>({\n mutationKey: Keys.account().mfa().update(),\n mutationFn: async ({ mfa }) => {\n const { data, errors } = await graphql.mutation({\n query: accountUpdateMFA,\n variables: {\n mfa,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountUpdateMFA\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: Keys.account().key() })\n void queryClient.invalidateQueries({\n queryKey: Keys.account().mfaFactors(),\n })\n },\n })\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { AuthenticatorType } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst updateMFAAuthenticator = gql(/* GraphQL */ `\n mutation UpdateMfaAuthenticator($type: String!, $otp: String!) {\n accountUpdateMfaAuthenticator(type: $type, otp: $otp) {\n mfa\n }\n }\n`)\n\n/** The variables accepted by the {@link useUpdateMfaAuthenticator} mutation. */\nexport type UpdateMfaAuthenticatorVariables = {\n /** The authenticator type. Defaults to `AuthenticatorType.Totp`. */\n type?: AuthenticatorType\n /** The one-time password from the authenticator app. */\n otp: string\n}\n/** The result returned by the {@link useUpdateMfaAuthenticator} mutation. */\nexport type UpdateMfaAuthenticatorResult = Prettify<\n ResultOf<typeof updateMFAAuthenticator>['accountUpdateMfaAuthenticator']\n>\n\n/**\n * Mutation hook to verify an MFA authenticator by providing a `type` and `otp` code.\n *\n * Completes the MFA authenticator setup started by\n * {@link useCreateMfaAuthenticator}. The user must enter the OTP from\n * their authenticator app to confirm enrollment. Invalidates account\n * and MFA factor queries on success.\n *\n * @example\n * ```tsx\n * import { AuthenticatorType } from '@zeroin.earth/appwrite-graphql'\n *\n * const { mutate, isPending } = useUpdateMfaAuthenticator()\n *\n * mutate({\n * type: AuthenticatorType.Totp,\n * otp: '123456',\n * })\n * ```\n *\n * **Variables** ({@link UpdateMfaAuthenticatorVariables}):\n * - `type` — The authenticator type ({@link AuthenticatorType}). Defaults to `AuthenticatorType.Totp`.\n * - `otp` — The one-time password from the authenticator app\n *\n * @returns A `UseMutationResult` with the updated `mfa` boolean status.\n */\nexport function useUpdateMfaAuthenticator() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<\n UpdateMfaAuthenticatorResult,\n AppwriteException[],\n UpdateMfaAuthenticatorVariables\n >({\n mutationKey: Keys.account().mfaAuthenticator().update(),\n mutationFn: async ({ type = AuthenticatorType.Totp, otp }) => {\n const { data, errors } = await graphql.mutation({\n query: updateMFAAuthenticator,\n variables: {\n type,\n otp,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountUpdateMfaAuthenticator\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: Keys.account().key() })\n void queryClient.invalidateQueries({\n queryKey: Keys.account().mfaFactors(),\n })\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\n\nconst accountUpdateMfaChallenge = gql(/* GraphQL */ `\n mutation UpdateMfaChallenge($challengeId: String!, $otp: String!) {\n accountUpdateMfaChallenge(challengeId: $challengeId, otp: $otp) {\n _id\n userId\n expire\n current\n }\n }\n`)\n\n/** The variables accepted by the {@link useUpdateMfaChallenge} mutation. */\nexport type UpdateMfaChallengeVariables = Prettify<VariablesOf<typeof accountUpdateMfaChallenge>>\n/** The result returned by the {@link useUpdateMfaChallenge} mutation. */\nexport type UpdateMfaChallengeResult = Prettify<\n ResultOf<typeof accountUpdateMfaChallenge>['accountUpdateMfaChallenge']\n>\n\n/**\n * Mutation hook to complete an MFA challenge by providing the `challengeId` and `otp` code.\n *\n * Verifies the one-time password against the challenge created by\n * {@link useCreateMfaChallenge}. On success, a new session is established.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useUpdateMfaChallenge()\n *\n * mutate({\n * challengeId: 'challenge-abc',\n * otp: '123456',\n * })\n * ```\n *\n * **Variables** ({@link UpdateMfaChallengeVariables}):\n * - `challengeId` — The challenge ID returned by {@link useCreateMfaChallenge}\n * - `otp` — The one-time password from the user's authenticator, SMS, or email\n *\n * @returns A `UseMutationResult` with the session's `_id`, `userId`, `expire`, and `current` fields.\n */\nexport function useUpdateMfaChallenge() {\n const { graphql } = useAppwrite()\n\n const queryResult = useMutation<\n UpdateMfaChallengeResult,\n AppwriteException[],\n UpdateMfaChallengeVariables\n >({\n mutationKey: Keys.account().mfaChallenge().update(),\n mutationFn: async ({ challengeId, otp }) => {\n const { data, errors } = await graphql.mutation({\n query: accountUpdateMfaChallenge,\n variables: {\n challengeId,\n otp,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data?.accountUpdateMfaChallenge ?? null\n },\n })\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst accountUpdateMfaRecoveryCodes = gql(/* GraphQL */ `\n mutation UpdateMfaRecoveryCodes {\n accountUpdateMfaRecoveryCodes {\n recoveryCodes\n }\n }\n`)\n\n/** The result returned by the {@link useUpdateMfaRecoveryCodes} mutation. */\nexport type UpdateMfaRecoveryCodesResult = Prettify<\n ResultOf<typeof accountUpdateMfaRecoveryCodes>['accountUpdateMfaRecoveryCodes']\n>\n\n/**\n * Mutation hook to regenerate MFA recovery codes.\n *\n * Replaces the existing set of recovery codes with new ones. Previous\n * recovery codes will no longer be valid. Invalidates recovery code\n * queries on success.\n *\n * @example\n * ```tsx\n * const { mutate, data, isPending } = useUpdateMfaRecoveryCodes()\n *\n * mutate()\n *\n * // Display data.recoveryCodes to the user for safekeeping\n * ```\n *\n * This mutation takes no variables.\n *\n * @returns A `UseMutationResult` with a `recoveryCodes` array of new backup codes.\n */\nexport function useUpdateMfaRecoveryCodes() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<UpdateMfaRecoveryCodesResult, AppwriteException[], void>({\n mutationKey: Keys.account().mfaCodes().update(),\n mutationFn: async () => {\n const { data, errors } = await graphql.mutation({\n query: accountUpdateMfaRecoveryCodes,\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountUpdateMfaRecoveryCodes\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({\n queryKey: Keys.account().mfaCodes().key(),\n })\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nexport const accountUpdateName = gql(/* GraphQL */ `\n mutation UpdateName($name: String!) {\n accountUpdateName(name: $name) {\n name\n }\n }\n`)\n\n/** The variables accepted by the {@link useUpdateName} mutation. */\nexport type UpdateNameVariables = Prettify<VariablesOf<typeof accountUpdateName>>\n/** The result returned by the {@link useUpdateName} mutation. */\nexport type UpdateNameResult = Prettify<ResultOf<typeof accountUpdateName>['accountUpdateName']>\n\n/**\n * Mutation hook to update the current user's display name.\n *\n * Invalidates account queries on success so that components reading\n * the account will reflect the new name.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useUpdateName()\n *\n * mutate({ name: 'Jane Doe' })\n * ```\n *\n * **Variables** ({@link UpdateNameVariables}):\n * - `name` — The new display name for the user\n *\n * @returns A `UseMutationResult` with the updated `name` field.\n */\nexport function useUpdateName() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<UpdateNameResult, AppwriteException[], UpdateNameVariables>({\n mutationKey: Keys.account().name().update(),\n mutationFn: async ({ name }) => {\n const { data: mutationData, errors } = await graphql.mutation({\n query: accountUpdateName,\n variables: {\n name,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return mutationData.accountUpdateName\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: Keys.account().key() })\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nexport const updatePassword = gql(/* GraphQL */ `\n mutation UpdatePassword($password: String!, $oldPassword: String!) {\n accountUpdatePassword(password: $password, oldPassword: $oldPassword) {\n status\n }\n }\n`)\n\n/** The variables accepted by the {@link useUpdatePassword} mutation. */\nexport type UpdatePasswordVariables = Prettify<VariablesOf<typeof updatePassword>>\n/** The result returned by the {@link useUpdatePassword} mutation. */\nexport type UpdatePasswordResult = Prettify<\n ResultOf<typeof updatePassword>['accountUpdatePassword']\n>\n\n/**\n * Mutation hook to update the current user's password.\n *\n * Requires the new password and the current (old) password for verification.\n * Invalidates account queries on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useUpdatePassword()\n *\n * mutate({\n * password: 'new-secure-password',\n * oldPassword: 'current-password',\n * })\n * ```\n *\n * **Variables** ({@link UpdatePasswordVariables}):\n * - `password` — The new password\n * - `oldPassword` — The current password for verification\n *\n * @returns A `UseMutationResult` with a `status` string indicating the operation result.\n */\nexport function useUpdatePassword() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<\n UpdatePasswordResult,\n AppwriteException[],\n UpdatePasswordVariables\n >({\n mutationKey: Keys.account().password().update(),\n mutationFn: async ({ password, oldPassword }) => {\n const { data, errors } = await graphql.mutation({\n query: updatePassword,\n variables: {\n password,\n oldPassword,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data?.accountUpdatePassword\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: Keys.account().key() })\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nexport const accountUpdatePhone = gql(/* GraphQL */ `\n mutation UpdatePhone($phone: String!, $password: String!) {\n accountUpdatePhone(phone: $phone, password: $password) {\n phone\n }\n }\n`)\n\n/** The variables accepted by the {@link useUpdatePhone} mutation. */\nexport type UpdatePhoneVariables = Prettify<VariablesOf<typeof accountUpdatePhone>>\n/** The result returned by the {@link useUpdatePhone} mutation. */\nexport type UpdatePhoneResult = Prettify<ResultOf<typeof accountUpdatePhone>['accountUpdatePhone']>\n\n/**\n * Mutation hook to update the current user's phone number.\n *\n * Requires the new phone number and the current password for verification.\n * Invalidates account queries on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useUpdatePhone()\n *\n * mutate({\n * phone: '+14155551234',\n * password: 'current-password',\n * })\n * ```\n *\n * **Variables** ({@link UpdatePhoneVariables}):\n * - `phone` — The new phone number in E.164 format (e.g., `\"+14155551234\"`)\n * - `password` — The user's current password for verification\n *\n * @returns A `UseMutationResult` with the updated `phone` field.\n */\nexport function useUpdatePhone() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<UpdatePhoneResult, AppwriteException[], UpdatePhoneVariables>({\n mutationKey: Keys.account().phone().update(),\n mutationFn: async ({ phone, password }) => {\n const { data, errors } = await graphql.mutation({\n query: accountUpdatePhone,\n variables: {\n phone,\n password,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountUpdatePhone\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: Keys.account().key() })\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst updatePhoneSession = gql(/* GraphQL */ `\n mutation UpdatePhoneSession($userId: String!, $secret: String!) {\n accountUpdatePhoneSession(userId: $userId, secret: $secret) {\n userId\n expire\n current\n }\n }\n`)\n\n/** The variables accepted by the {@link useUpdatePhoneSession} mutation. */\nexport type UpdatePhoneSessionVariables = Prettify<VariablesOf<typeof updatePhoneSession>>\n/** The result returned by the {@link useUpdatePhoneSession} mutation. */\nexport type UpdatePhoneSessionResult = Prettify<\n ResultOf<typeof updatePhoneSession>['accountUpdatePhoneSession']\n>\n\n/**\n * Mutation hook to validate a phone session using `userId` and `secret`.\n *\n * Completes the phone-based authentication flow started by\n * {@link useCreatePhoneToken}. Invalidates account and session queries\n * on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useUpdatePhoneSession()\n *\n * mutate({\n * userId: 'user-123',\n * secret: '123456',\n * })\n * ```\n *\n * **Variables** ({@link UpdatePhoneSessionVariables}):\n * - `userId` — The user's ID received from the phone token step\n * - `secret` — The OTP code sent via SMS\n *\n * @returns A `UseMutationResult` with the session's `userId`, `expire`, and `current` fields.\n */\nexport function useUpdatePhoneSession() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<\n UpdatePhoneSessionResult,\n AppwriteException[],\n UpdatePhoneSessionVariables\n >({\n mutationKey: Keys.account().phoneToken().update(),\n mutationFn: async ({ userId, secret }) => {\n const { data, errors } = await graphql.mutation({\n query: updatePhoneSession,\n variables: {\n userId,\n secret,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountUpdatePhoneSession\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: Keys.account().key() })\n void queryClient.invalidateQueries({\n queryKey: Keys.account().sessions(),\n })\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\n\nconst updatePhoneVerification = gql(/* GraphQL */ `\n mutation UpdatePhoneVerification($userId: String!, $secret: String!) {\n accountUpdatePhoneVerification(userId: $userId, secret: $secret) {\n expire\n }\n }\n`)\n\n/** The variables accepted by the {@link useUpdatePhoneVerification} mutation. */\nexport type UpdatePhoneVerificationVariables = Prettify<VariablesOf<typeof updatePhoneVerification>>\n/** The result returned by the {@link useUpdatePhoneVerification} mutation. */\nexport type UpdatePhoneVerificationResult = Prettify<\n ResultOf<typeof updatePhoneVerification>['accountUpdatePhoneVerification']\n>\n\n/**\n * Mutation hook to confirm phone verification using `userId` and `secret`.\n *\n * Completes the phone verification flow started by\n * {@link useCreatePhoneVerification}.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useUpdatePhoneVerification()\n *\n * mutate({\n * userId: 'user-123',\n * secret: '123456',\n * })\n * ```\n *\n * **Variables** ({@link UpdatePhoneVerificationVariables}):\n * - `userId` — The user's ID\n * - `secret` — The verification code sent via SMS\n *\n * @returns A `UseMutationResult` with the verification's `expire` timestamp.\n */\nexport function useUpdatePhoneVerification() {\n const { graphql } = useAppwrite()\n\n const queryResult = useMutation<\n UpdatePhoneVerificationResult,\n AppwriteException[],\n UpdatePhoneVerificationVariables\n >({\n mutationKey: Keys.account().phoneVerification().update(),\n mutationFn: async ({ userId, secret }) => {\n const { data, errors } = await graphql.mutation({\n query: updatePhoneVerification,\n variables: {\n userId,\n secret,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountUpdatePhoneVerification\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nexport const accountUpdatePrefs = gql(/* GraphQL */ `\n mutation UpdatePrefs($prefs: Assoc!) {\n accountUpdatePrefs(prefs: $prefs) {\n prefs {\n data\n }\n }\n }\n`)\n\n/** The variables accepted by the {@link useUpdatePrefs} mutation. */\nexport type UpdatePrefsVariables = Prettify<VariablesOf<typeof accountUpdatePrefs>>\n/** The result returned by the {@link useUpdatePrefs} mutation. */\nexport type UpdatePrefsResult = Prettify<ResultOf<typeof accountUpdatePrefs>['accountUpdatePrefs']>\n\n/**\n * Mutation hook to update the current user's account preferences.\n *\n * Accepts an `Assoc` (key-value map) of preferences. Invalidates account\n * queries on success so that components reading preferences reflect the\n * updated values.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useUpdatePrefs()\n *\n * mutate({\n * prefs: { theme: 'dark', locale: 'en-US' },\n * })\n * ```\n *\n * **Variables** ({@link UpdatePrefsVariables}):\n * - `prefs` — A key-value object of account preferences to set\n *\n * @returns A `UseMutationResult` with the updated `prefs` containing a `data` field.\n */\nexport function useUpdatePrefs() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<UpdatePrefsResult, AppwriteException[], UpdatePrefsVariables>({\n mutationKey: Keys.account().prefs().update(),\n mutationFn: async ({ prefs }) => {\n const { data, errors } = await graphql.mutation({\n query: accountUpdatePrefs,\n variables: { prefs },\n })\n\n if (errors) {\n throw errors\n }\n\n return data?.accountUpdatePrefs\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: Keys.account().key() })\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst accountUpdatePushTarget = gql(/* GraphQL */ `\n mutation UpdatePushTarget($targetId: String!, $identifier: String!) {\n accountUpdatePushTarget(targetId: $targetId, identifier: $identifier) {\n _id\n userId\n providerType\n identifier\n }\n }\n`)\n\n/** The variables accepted by the {@link useUpdatePushTarget} mutation. */\nexport type UpdatePushTargetVariables = Prettify<VariablesOf<typeof accountUpdatePushTarget>>\n/** The result returned by the {@link useUpdatePushTarget} mutation. */\nexport type UpdatePushTargetResult = Prettify<\n ResultOf<typeof accountUpdatePushTarget>['accountUpdatePushTarget']\n>\n\n/**\n * Mutation hook to update a push notification target's identifier.\n *\n * Replaces the device token on an existing push target. Invalidates\n * account queries on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useUpdatePushTarget()\n *\n * mutate({\n * targetId: 'target-123',\n * identifier: 'new-fcm-device-token',\n * })\n * ```\n *\n * **Variables** ({@link UpdatePushTargetVariables}):\n * - `targetId` — The ID of the push target to update\n * - `identifier` — The new device token or registration ID\n *\n * @returns A `UseMutationResult` with the push target's `_id`, `userId`, `providerType`, and `identifier`.\n */\nexport function useUpdatePushTarget() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<\n UpdatePushTargetResult,\n AppwriteException[],\n UpdatePushTargetVariables\n >({\n mutationKey: Keys.account().pushTarget().update(),\n mutationFn: async ({ targetId, identifier }) => {\n const { data, errors } = await graphql.mutation({\n query: accountUpdatePushTarget,\n variables: {\n targetId,\n identifier,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountUpdatePushTarget\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: Keys.account().key() })\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst updateSession = gql(/* GraphQL */ `\n mutation UpdateSession($sessionId: String!) {\n accountUpdateSession(sessionId: $sessionId) {\n userId\n expire\n current\n }\n }\n`)\n\n/** The variables accepted by the {@link useUpdateSession} mutation. */\nexport type UpdateSessionVariables = Prettify<VariablesOf<typeof updateSession>>\n/** The result returned by the {@link useUpdateSession} mutation. */\nexport type UpdateSessionResult = Prettify<ResultOf<typeof updateSession>['accountUpdateSession']>\n\n/**\n * Mutation hook to extend a session's expiry by its ID.\n *\n * Refreshes the session so it does not expire. Invalidates session list\n * queries on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useUpdateSession()\n *\n * mutate({ sessionId: 'current' })\n * ```\n *\n * **Variables** ({@link UpdateSessionVariables}):\n * - `sessionId` — The ID of the session to extend (use `\"current\"` for the active session)\n *\n * @returns A `UseMutationResult` with the session's `userId`, `expire`, and `current` fields.\n */\nexport function useUpdateSession() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<UpdateSessionResult, AppwriteException[], UpdateSessionVariables>(\n {\n mutationKey: Keys.account().session().update(),\n mutationFn: async ({ sessionId }) => {\n const { data, errors } = await graphql.mutation({\n query: updateSession,\n variables: {\n sessionId,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountUpdateSession\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({\n queryKey: Keys.account().sessions(),\n })\n },\n },\n )\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst accountUpdateStatus = gql(/* GraphQL */ `\n mutation UpdateStatus {\n accountUpdateStatus {\n _id\n status\n }\n }\n`)\n\n/** The result returned by the {@link useUpdateStatus} mutation. */\nexport type UpdateStatusResult = Prettify<\n ResultOf<typeof accountUpdateStatus>['accountUpdateStatus']\n>\n\n/**\n * Mutation hook to update the current user's account status (e.g., disable account).\n *\n * Blocks the user account by setting the status to disabled. Invalidates\n * account queries on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useUpdateStatus()\n *\n * mutate()\n * ```\n *\n * This mutation takes no variables.\n *\n * @returns A `UseMutationResult` with the user's `_id` and updated `status`.\n */\nexport function useUpdateStatus() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<UpdateStatusResult, AppwriteException[], void>({\n mutationKey: Keys.account().status().update(),\n mutationFn: async () => {\n const { data, errors } = await graphql.mutation({\n query: accountUpdateStatus,\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountUpdateStatus\n },\n onSuccess: async () => {\n void queryClient.invalidateQueries({ queryKey: Keys.account().key() })\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst updateVerification = gql(/* GraphQL */ `\n mutation UpdateVerification($userId: String!, $secret: String!) {\n accountUpdateVerification(userId: $userId, secret: $secret) {\n secret\n expire\n userId\n }\n }\n`)\n\n/** The variables accepted by the {@link useVerification} mutation. */\nexport type VerificationVariables = Prettify<VariablesOf<typeof updateVerification>>\n/** The result returned by the {@link useVerification} mutation. */\nexport type VerificationResult = Prettify<\n ResultOf<typeof updateVerification>['accountUpdateVerification']\n>\n\n/**\n * Mutation hook to complete email verification using `userId` and `secret` from the verification link.\n *\n * Validates the verification token and marks the user's email as verified.\n * Throws an error if `userId` or `secret` is missing. On success, sets the\n * account query data to `null` to force a re-fetch.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useVerification()\n *\n * // Extract userId and secret from the verification URL\n * mutate({\n * userId: 'user-123',\n * secret: 'verification-secret',\n * })\n * ```\n *\n * **Variables** ({@link VerificationVariables}):\n * - `userId` — The user's ID from the verification URL\n * - `secret` — The secret token from the verification URL\n *\n * @returns A `UseMutationResult` with the verification's `secret`, `expire`, and `userId` fields.\n */\nexport function useVerification() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<VerificationResult, AppwriteException[], VerificationVariables>({\n mutationKey: Keys.account().verification().update(),\n mutationFn: async ({ userId, secret }) => {\n if (!userId || !secret) {\n throw new Error('Missing userId or secret')\n }\n\n const { data, errors } = await graphql.mutation({\n query: updateVerification,\n variables: {\n userId,\n secret,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountUpdateVerification\n },\n onSuccess: async () => {\n queryClient.setQueryData(Keys.account().key(), null)\n },\n })\n\n return queryResult\n}\n","import { useMemo } from 'react'\nimport type { Browser } from 'appwrite'\n\nimport { useAppwrite } from '../useAppwrite'\n\n/**\n * Returns a URL for a browser logo avatar image. Memoized.\n * @param params - The browser code and optional width, height, and quality.\n */\nexport function useAvatarBrowser({\n code,\n width,\n height,\n quality,\n}: {\n code: Browser\n width?: number\n height?: number\n quality?: number\n}) {\n const { avatars } = useAppwrite()\n\n const url = useMemo(\n () => avatars?.getBrowser({ code, width, height, quality }),\n [avatars, code, width, height, quality],\n )\n\n return url\n}\n","import { useMemo } from 'react'\nimport type { CreditCard } from 'appwrite'\n\nimport { useAppwrite } from '../useAppwrite'\n\n/**\n * Returns a URL for a credit card brand logo avatar image. Memoized.\n * @param params - The credit card code and optional width, height, and quality.\n */\nexport function useAvatarCreditCard({\n code,\n width,\n height,\n quality,\n}: {\n code: CreditCard\n width?: number\n height?: number\n quality?: number\n}) {\n const { avatars } = useAppwrite()\n\n const url = useMemo(\n () => avatars?.getCreditCard({ code, width, height, quality }),\n [avatars, code, width, height, quality],\n )\n\n return url\n}\n","import { useMemo } from 'react'\n\nimport { useAppwrite } from '../useAppwrite'\n\n/**\n * Returns a URL for a website's favicon. Memoized.\n * @param params - The website URL to fetch the favicon for.\n */\nexport function useAvatarFavicon({ url }: { url: string }) {\n const { avatars } = useAppwrite()\n\n const faviconUrl = useMemo(() => avatars?.getFavicon({ url }), [avatars, url])\n\n return faviconUrl\n}\n","import { useMemo } from 'react'\nimport type { Flag } from 'appwrite'\n\nimport { useAppwrite } from '../useAppwrite'\n\n/**\n * Returns a URL for a country flag avatar image. Memoized.\n * @param params - The country code and optional width, height, and quality.\n */\nexport function useAvatarFlag({\n code,\n width,\n height,\n quality,\n}: {\n code: Flag\n width?: number\n height?: number\n quality?: number\n}) {\n const { avatars } = useAppwrite()\n\n const url = useMemo(\n () => avatars?.getFlag({ code, width, height, quality }),\n [avatars, code, width, height, quality],\n )\n\n return url\n}\n","import { useMemo } from 'react'\n\nimport { useAppwrite } from '../useAppwrite'\n\n/**\n * Returns a URL for a remote image cropped to a specified size. Memoized.\n * @param params - The image URL and optional width and height.\n */\nexport function useAvatarImage({\n url,\n width,\n height,\n}: {\n url: string\n width?: number\n height?: number\n}) {\n const { avatars } = useAppwrite()\n\n const imageUrl = useMemo(\n () => avatars?.getImage({ url, width, height }),\n [avatars, url, width, height],\n )\n\n return imageUrl\n}\n","import { useMemo } from 'react'\n\nimport { useAppwrite } from '../useAppwrite'\n\n/**\n * Returns a URL for an avatar with user initials.\n * Uses the current user's name if none provided. Memoized.\n * @param params - Optional name, width, height, and background color.\n */\nexport function useAvatarInitials({\n name,\n width,\n height,\n background,\n}: {\n name?: string\n width?: number\n height?: number\n background?: string\n} = {}) {\n const { avatars } = useAppwrite()\n\n const url = useMemo(\n () => avatars?.getInitials({ name, width, height, background }),\n [avatars, name, width, height, background],\n )\n\n return url\n}\n","import { useMemo } from 'react'\n\nimport { useAppwrite } from '../useAppwrite'\n\n/**\n * Returns a URL for a QR code image. Memoized.\n * @param params - The text to encode, and optional size, margin, and download flag.\n */\nexport function useAvatarQR({\n text,\n size,\n margin,\n download,\n}: {\n text: string\n size?: number\n margin?: number\n download?: boolean\n}) {\n const { avatars } = useAppwrite()\n\n const url = useMemo(\n () => avatars?.getQR({ text, size, margin, download }),\n [avatars, text, size, margin, download],\n )\n\n return url\n}\n","import { useMemo } from 'react'\n\nimport { useAppwrite } from '../useAppwrite'\n\n/**\n * Returns a URL for a screenshot of a website. Memoized.\n * @param params - The website URL and optional width and height.\n */\nexport function useAvatarScreenshot({\n url,\n width,\n height,\n}: {\n url: string\n width?: number\n height?: number\n}) {\n const { avatars } = useAppwrite()\n\n const screenshotUrl = useMemo(\n () => avatars?.getScreenshot({ url, width, height }),\n [avatars, url, width, height],\n )\n\n return screenshotUrl\n}\n","import { Query } from 'appwrite'\n\nexport function mergeFieldsQuery(queries: string[], fields?: string[]): string[] {\n if (!fields || fields.length === 0) return queries\n return [Query.select(fields), ...queries]\n}\n","import { graphql as gql } from 'gql.tada'\n\nimport type { Collection, Document } from './types'\nimport { mergeFieldsQuery } from './utils'\nimport type { AppwriteClient } from '../client'\nimport { Keys } from '../query/Keys'\n\ntype DocumentParams<TDocument = Record<string, unknown>> = {\n databaseId: string\n collectionId: string\n documentId: string\n queries?: string[]\n transactionId?: string\n fields?: (keyof TDocument & string)[]\n}\n\nexport const getDocument = gql(/* GraphQL */ `\n query GetDocument(\n $databaseId: String!\n $collectionId: String!\n $documentId: String!\n $queries: [String!]\n $transactionId: String\n ) {\n databasesGetDocument(\n databaseId: $databaseId\n collectionId: $collectionId\n documentId: $documentId\n queries: $queries\n transactionId: $transactionId\n ) {\n _id\n data\n }\n }\n`)\n\nexport function getDocumentQuery<TDocument>(\n client: AppwriteClient,\n {\n databaseId,\n collectionId,\n documentId,\n queries,\n transactionId,\n fields,\n }: DocumentParams<TDocument>,\n) {\n const rawQueries = Array.isArray(queries) ? queries : queries ? [queries] : []\n const mergedQueries = mergeFieldsQuery(rawQueries, fields)\n\n return {\n queryKey: [\n ...Keys.database(databaseId).collection(collectionId).document(documentId).key(),\n ...mergedQueries,\n ] as const,\n queryFn: async () => {\n const { data, errors } = await client.graphql.query({\n query: getDocument,\n variables: {\n databaseId,\n collectionId,\n documentId,\n queries: mergedQueries.length > 0 ? mergedQueries : undefined,\n transactionId,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n const document = {\n ...data.databasesGetDocument,\n ...(data.databasesGetDocument\n ? (JSON.parse(data.databasesGetDocument.data as string) as TDocument)\n : {}),\n } as unknown as Document<TDocument>\n\n return document\n },\n }\n}\n\nexport const listDocuments = gql(/* GraphQL */ `\n query ListDocuments(\n $databaseId: String!\n $collectionId: String!\n $queries: [String!]\n $transactionId: String\n ) {\n databasesListDocuments(\n databaseId: $databaseId\n collectionId: $collectionId\n queries: $queries\n transactionId: $transactionId\n ) {\n total\n documents {\n _id\n data\n }\n }\n }\n`)\n\nexport function getCollectionQuery<TDocument>(\n client: AppwriteClient,\n {\n databaseId,\n collectionId,\n queries,\n transactionId,\n fields,\n }: Omit<DocumentParams<TDocument>, 'documentId'>,\n) {\n const mergedQueries = mergeFieldsQuery(queries ?? [], fields)\n\n return {\n queryKey: [\n ...Keys.database(databaseId).collection(collectionId).key(),\n ...mergedQueries,\n ] as const,\n queryFn: async () => {\n const { data, errors } = await client.graphql.query({\n query: listDocuments,\n variables: {\n databaseId,\n collectionId,\n queries: mergedQueries,\n transactionId,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n const documents =\n data.databasesListDocuments?.documents?.map((document) => ({\n ...document,\n ...(document ? (JSON.parse(document.data as string) as TDocument) : {}),\n })) ?? []\n\n return {\n total: data.databasesListDocuments?.total ?? 0,\n documents,\n } as unknown as Collection<TDocument>\n },\n }\n}\n","import { useEffect } from 'react'\nimport { Channel } from 'appwrite'\n\nimport { getCollectionQuery } from './queryOptions'\nimport type { Collection, Document } from './types'\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify, QueryOptions } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\nimport { useQueryClient } from '../useQueryClient'\nimport { useSuspenseQuery } from '../useSuspenseQuery'\n\ntype DocumentOperation = 'create' | 'update' | 'delete'\n\ntype CollectionParams<TDocument = Record<string, string | number | boolean | null>> = Prettify<{\n databaseId: string\n collectionId: string\n queries?: string[]\n transactionId?: string\n subscribe?: boolean\n fields?: (keyof TDocument & string)[]\n}>\n\nfunction useCollectionQueryConfig<TDocument>({\n databaseId,\n collectionId,\n queries,\n transactionId,\n fields,\n}: Omit<CollectionParams<TDocument>, 'subscribe'>) {\n const client = useAppwrite()\n\n return getCollectionQuery<TDocument>(client, {\n databaseId,\n collectionId,\n queries,\n transactionId,\n fields,\n })\n}\n\nfunction useCollectionRealtime<TDocument>(\n databaseId: string,\n collectionId: string,\n queries: string[],\n subscribe: boolean,\n) {\n const { realtime } = useAppwrite()\n const queryClient = useQueryClient()\n const queriesKey = JSON.stringify(queries)\n\n useEffect(() => {\n if (!subscribe) {\n return\n }\n\n const subscriptionPromise = realtime.subscribe(\n Channel.tablesdb(databaseId).table(collectionId).row(),\n (response) => {\n const [, operation] = response.events[0].match(/\\.(\\w+)$/) as RegExpMatchArray\n const document = response.payload as Document<TDocument>\n\n switch (operation as DocumentOperation) {\n case 'create':\n case 'update':\n case 'delete':\n queryClient.setQueryData(\n Keys.database(databaseId).collection(collectionId).document(document.$id).key(),\n document,\n )\n\n void queryClient.invalidateQueries({\n queryKey: Keys.database(databaseId).collection(collectionId).key(),\n })\n\n break\n }\n },\n )\n\n return () => {\n void subscriptionPromise.then((sub) => sub.close())\n }\n }, [databaseId, collectionId, realtime, queryClient, queriesKey, subscribe])\n}\n\n/**\n * Fetches a collection of documents with optional real-time subscription (enabled by default).\n * Returns `documents` and `total` alongside the standard query result.\n *\n * @typeParam TDocument - The shape of each document's custom attributes.\n *\n * @example\n * ```tsx\n * const { documents, total, isLoading } = useCollection({\n * databaseId: 'my-db',\n * collectionId: 'my-collection',\n * queries: [Query.equal('status', 'active')],\n * })\n * ```\n *\n * **Parameters** (`CollectionParams`):\n * - `databaseId` — The database ID\n * - `collectionId` — The collection ID\n * - `queries` — Optional query filters (defaults to `[]`)\n * - `transactionId` — Optional transaction ID for atomic reads\n * - `subscribe` — Whether to subscribe to real-time updates (defaults to `true`)\n * - `fields` — Optional array of document fields to select\n *\n * @returns A `UseQueryResult` with the collection data as `Collection<TDocument>`, plus\n * convenience accessors `documents` and `total`.\n */\nexport function useCollection<TDocument>(\n {\n databaseId,\n collectionId,\n queries = [],\n transactionId,\n subscribe = true,\n fields,\n }: CollectionParams<TDocument>,\n opts: QueryOptions = {},\n) {\n const config = useCollectionQueryConfig<TDocument>({\n databaseId,\n collectionId,\n queries,\n transactionId,\n fields,\n })\n\n const collection = useQuery<Collection<TDocument>, AppwriteException[], Collection<TDocument>>({\n ...config,\n ...opts,\n })\n\n useCollectionRealtime<TDocument>(databaseId, collectionId, queries, subscribe)\n\n return {\n ...collection,\n documents: collection.data?.documents,\n total: collection.data?.total,\n }\n}\n\n/**\n * Suspense variant of {@link useCollection}. Suspends the component while loading.\n *\n * @typeParam TDocument - The shape of each document's custom attributes.\n *\n * @example\n * ```tsx\n * const { documents, total } = useSuspenseCollection({\n * databaseId: 'my-db',\n * collectionId: 'my-collection',\n * })\n * ```\n *\n * **Parameters** (`CollectionParams`):\n * - `databaseId` — The database ID\n * - `collectionId` — The collection ID\n * - `queries` — Optional query filters\n * - `transactionId` — Optional transaction ID for atomic reads\n * - `subscribe` — Whether to subscribe to real-time updates (defaults to `true`)\n * - `fields` — Optional array of document fields to select\n *\n * @returns A `UseSuspenseQueryResult` with the collection data as `Collection<TDocument>`, plus\n * convenience accessors `documents` and `total`.\n */\nexport function useSuspenseCollection<TDocument>(\n {\n databaseId,\n collectionId,\n queries,\n transactionId,\n subscribe = true,\n fields,\n }: CollectionParams<TDocument>,\n opts: QueryOptions = {},\n) {\n const config = useCollectionQueryConfig<TDocument>({\n databaseId,\n collectionId,\n queries,\n transactionId,\n fields,\n })\n\n const collection = useSuspenseQuery<\n Collection<TDocument>,\n AppwriteException[],\n Collection<TDocument>\n >({\n ...config,\n ...opts,\n })\n\n useCollectionRealtime<TDocument>(databaseId, collectionId, queries, subscribe)\n\n return {\n ...collection,\n documents: collection.data?.documents,\n total: collection.data?.total,\n }\n}\n","import { useRef, useState } from 'react'\nimport { Query } from 'appwrite'\n\nimport { useCollection, useSuspenseCollection } from './useCollection'\nimport type { QueryOptions } from '../types'\n\ntype PaginationParams<TDocument = Record<string, unknown>> = {\n databaseId: string\n collectionId: string\n queries: string[]\n transactionId?: string\n limit?: number\n fields?: (keyof TDocument & string)[]\n}\n\nfunction usePaginationState(limit: number) {\n const [page, setPage] = useState(1)\n const totalRef = useRef(0)\n const offset = (page - 1) * limit\n\n const nextPage = () => {\n setPage((prevPage) => {\n const currentOffset = (prevPage - 1) * limit\n if (totalRef.current > 0 && currentOffset + limit < totalRef.current) {\n return prevPage + 1\n }\n return prevPage\n })\n }\n\n const previousPage = () => {\n setPage((prevPage) => (prevPage > 1 ? prevPage - 1 : prevPage))\n }\n\n const handlePageChange = (newPage: number) => {\n if (newPage < 1) return\n if (totalRef.current > 0) {\n const maxPage = Math.ceil(totalRef.current / limit)\n if (newPage > maxPage) return\n }\n setPage(newPage)\n }\n\n return { page, offset, totalRef, nextPage, previousPage, handlePageChange }\n}\n\n/**\n * Fetches a paginated collection of documents. Returns pagination helpers\n * (`page`, `hasNextPage`, `hasPreviousPage`, `nextPage`, `previousPage`, `handlePageChange`).\n * Default page limit is 25.\n *\n * @typeParam TDocument - The shape of each document's custom attributes.\n *\n * @example\n * ```tsx\n * const { documents, page, nextPage, previousPage, hasNextPage } =\n * useCollectionWithPagination({\n * databaseId: 'my-db',\n * collectionId: 'my-collection',\n * queries: [Query.equal('status', 'active')],\n * limit: 10,\n * })\n * ```\n *\n * **Parameters** (`PaginationParams`):\n * - `databaseId` — The database ID\n * - `collectionId` — The collection ID\n * - `queries` — Query filters applied to the collection\n * - `transactionId` — Optional transaction ID for atomic reads\n * - `limit` — Number of documents per page (defaults to `25`)\n * - `fields` — Optional array of document fields to select\n *\n * @returns An object with `documents`, `total`, `page`, `hasNextPage`, `hasPreviousPage`,\n * `nextPage()`, `previousPage()`, `handlePageChange(page)`, and standard query status flags.\n */\nexport function useCollectionWithPagination<TDocument>(\n {\n databaseId,\n collectionId,\n queries,\n transactionId,\n limit = 25,\n fields,\n }: PaginationParams<TDocument>,\n opts: QueryOptions = {},\n) {\n const { page, offset, totalRef, nextPage, previousPage, handlePageChange } =\n usePaginationState(limit)\n\n const collection = useCollection<TDocument>(\n {\n databaseId,\n collectionId,\n queries: [...queries, Query.limit(limit), Query.offset(offset)],\n transactionId,\n fields,\n },\n opts,\n )\n\n const total = collection.data?.total ?? 0\n totalRef.current = total\n\n return {\n documents: collection.data?.documents ?? [],\n total,\n page,\n hasNextPage: total > 0 && offset + limit < total,\n hasPreviousPage: page > 1,\n handlePageChange,\n nextPage,\n previousPage,\n isLoading: collection.isLoading,\n isError: collection.isError,\n error: collection.error,\n isFetching: collection.isFetching,\n }\n}\n\n/**\n * Suspense variant of {@link useCollectionWithPagination}. Suspends the component while loading.\n *\n * @typeParam TDocument - The shape of each document's custom attributes.\n *\n * @example\n * ```tsx\n * const { documents, page, nextPage, hasNextPage } =\n * useSuspenseCollectionWithPagination({\n * databaseId: 'my-db',\n * collectionId: 'my-collection',\n * queries: [Query.equal('status', 'active')],\n * })\n * ```\n *\n * **Parameters** (`PaginationParams`):\n * - `databaseId` — The database ID\n * - `collectionId` — The collection ID\n * - `queries` — Query filters applied to the collection\n * - `transactionId` — Optional transaction ID for atomic reads\n * - `limit` — Number of documents per page (defaults to `25`)\n * - `fields` — Optional array of document fields to select\n *\n * @returns An object with `documents`, `total`, `page`, `hasNextPage`, `hasPreviousPage`,\n * `nextPage()`, `previousPage()`, `handlePageChange(page)`, and standard query status flags.\n */\nexport function useSuspenseCollectionWithPagination<TDocument>(\n {\n databaseId,\n collectionId,\n queries,\n transactionId,\n limit = 25,\n fields,\n }: PaginationParams<TDocument>,\n opts: QueryOptions = {},\n) {\n const { page, offset, totalRef, nextPage, previousPage, handlePageChange } =\n usePaginationState(limit)\n\n const collection = useSuspenseCollection<TDocument>(\n {\n databaseId,\n collectionId,\n queries: [...queries, Query.limit(limit), Query.offset(offset)],\n transactionId,\n fields,\n },\n opts,\n )\n\n const total = collection.total ?? 0\n totalRef.current = total\n\n return {\n documents: collection.documents ?? [],\n total,\n page,\n hasNextPage: total > 0 && offset + limit < total,\n hasPreviousPage: page > 1,\n handlePageChange,\n nextPage,\n previousPage,\n isLoading: collection.isLoading,\n isError: collection.isError,\n error: collection.error,\n isFetching: collection.isFetching,\n }\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nexport const createDocument = gql(/* GraphQL */ `\n mutation CreateDocument(\n $databaseId: String!\n $collectionId: String!\n $documentId: String!\n $data: Json!\n $permissions: [String!]\n $transactionId: String\n ) {\n databasesCreateDocument(\n databaseId: $databaseId\n collectionId: $collectionId\n documentId: $documentId\n data: $data\n permissions: $permissions\n transactionId: $transactionId\n ) {\n _id\n }\n }\n`)\n\ntype Variables = VariablesOf<typeof createDocument>\n\n/** The result returned after creating a document. */\nexport type CreateDocumentResult = Prettify<\n ResultOf<typeof createDocument>['databasesCreateDocument']\n>\n\n/** The variables accepted by the {@link useCreateDocument} mutation. */\nexport type CreateDocumentVariables = Prettify<\n Omit<Variables, 'permissions'> & {\n permissions?: string[] | null\n }\n>\n\n/**\n * Mutation hook to create a new document.\n *\n * Invalidates collection queries and sets the new document in the cache on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useCreateDocument()\n *\n * mutate({\n * databaseId: 'my-db',\n * collectionId: 'my-collection',\n * documentId: ID.unique(),\n * data: { name: 'John', age: 30 },\n * permissions: ['read(\"any\")'],\n * })\n * ```\n *\n * **Variables** ({@link CreateDocumentVariables}):\n * - `databaseId` — The target database ID\n * - `collectionId` — The target collection ID\n * - `documentId` — Unique document ID (use `ID.unique()` for auto-generation)\n * - `data` — The document data as a JSON-serializable object\n * - `permissions` — Optional array of permission strings, or `null`\n * - `transactionId` — Optional transaction ID for atomic operations\n *\n * @returns A `UseMutationResult` with the created document's `_id`.\n */\nexport function useCreateDocument() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const mutationResult = useMutation<\n CreateDocumentResult,\n AppwriteException[],\n CreateDocumentVariables\n >({\n mutationKey: Keys.databases().collections().documents().create(),\n mutationFn: async ({\n databaseId,\n collectionId,\n documentId,\n data,\n permissions,\n transactionId,\n }) => {\n const { data: mutationData, errors } = await graphql.mutation({\n query: createDocument,\n variables: {\n databaseId,\n collectionId,\n documentId,\n data: JSON.stringify(data),\n permissions,\n transactionId,\n },\n })\n\n if (errors) {\n throw errors\n }\n return mutationData.databasesCreateDocument\n },\n onSuccess: (result, variables) => {\n const documentKeyPrefix = Keys.database(variables.databaseId)\n .collection(variables.collectionId)\n .document(result._id)\n .key()\n\n void queryClient.invalidateQueries({\n queryKey: Keys.database(variables.databaseId).collection(variables.collectionId).key(),\n })\n\n queryClient.setQueryData<Variables>(documentKeyPrefix, {\n ...variables,\n ...(variables.data as Record<string, unknown>),\n })\n },\n })\n\n return mutationResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst createOperations = gql(/* GraphQL */ `\n mutation CreateOperations($transactionId: String!, $operations: [String!]) {\n databasesCreateOperations(transactionId: $transactionId, operations: $operations) {\n _id\n status\n operations\n expiresAt\n }\n }\n`)\n\n/** The variables accepted by the {@link useCreateOperations} mutation. */\nexport type CreateOperationsVariables = Prettify<VariablesOf<typeof createOperations>>\n\n/** The result returned by the {@link useCreateOperations} mutation. */\nexport type CreateOperationsResult = Prettify<\n ResultOf<typeof createOperations>['databasesCreateOperations']\n>\n\n/**\n * Mutation hook to add operations to an existing transaction.\n *\n * Invalidates the parent transaction query on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useCreateOperations()\n *\n * mutate({\n * transactionId: 'txn-abc',\n * operations: [\n * JSON.stringify({ action: 'create', databaseId: 'my-db', collectionId: 'my-col', documentId: 'doc-1', data: '{}' }),\n * ],\n * })\n * ```\n *\n * **Variables** ({@link CreateOperationsVariables}):\n * - `transactionId` — The ID of the transaction to append operations to\n * - `operations` — Optional array of JSON-encoded operation strings\n *\n * @returns A `UseMutationResult` with the transaction's `_id`, `status`, `operations` list, and `expiresAt` timestamp.\n */\nexport function useCreateOperations() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const mutationResult = useMutation<\n CreateOperationsResult,\n AppwriteException[],\n CreateOperationsVariables\n >({\n mutationKey: Keys.databases().transactions().operations().create(),\n mutationFn: async ({ transactionId, operations }) => {\n const { data, errors } = await graphql.mutation({\n query: createOperations,\n variables: { transactionId, operations },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.databasesCreateOperations\n },\n onSuccess: (_, variables) => {\n void queryClient.invalidateQueries({\n queryKey: Keys.databases().transaction(variables.transactionId).key(),\n })\n },\n })\n\n return mutationResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst createTransaction = gql(/* GraphQL */ `\n mutation CreateTransaction($ttl: Int) {\n databasesCreateTransaction(ttl: $ttl) {\n _id\n status\n operations\n expiresAt\n }\n }\n`)\n\n/** The variables accepted by the {@link useCreateTransaction} mutation. */\nexport type CreateTransactionVariables = Prettify<VariablesOf<typeof createTransaction>>\n\n/** The result returned by the {@link useCreateTransaction} mutation. */\nexport type CreateTransactionResult = Prettify<\n ResultOf<typeof createTransaction>['databasesCreateTransaction']\n>\n\n/**\n * Mutation hook to create a new database transaction with optional TTL.\n *\n * Invalidates transaction list queries on success.\n *\n * @example\n * ```tsx\n * const { mutate, data } = useCreateTransaction()\n *\n * // Create a transaction with a 60-second TTL\n * mutate({ ttl: 60 })\n *\n * // Or create one with the default TTL\n * mutate({})\n * ```\n *\n * **Variables** ({@link CreateTransactionVariables}):\n * - `ttl` — Optional time-to-live in seconds for the transaction before it auto-expires\n *\n * @returns A `UseMutationResult` with the transaction's `_id`, `status`, `operations` list, and `expiresAt` timestamp.\n */\nexport function useCreateTransaction() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const mutationResult = useMutation<\n CreateTransactionResult,\n AppwriteException[],\n CreateTransactionVariables\n >({\n mutationKey: Keys.databases().transactions().create(),\n mutationFn: async ({ ttl } = {}) => {\n const { data, errors } = await graphql.mutation({\n query: createTransaction,\n variables: { ttl },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.databasesCreateTransaction\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({\n queryKey: Keys.databases().transactions().key(),\n })\n },\n })\n\n return mutationResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nexport const decrementDocumentAttribute = gql(/* GraphQL */ `\n mutation DecrementDocumentAttribute(\n $databaseId: String!\n $collectionId: String!\n $documentId: String!\n $attribute: String!\n $value: Int\n $min: Int\n $transactionId: String\n ) {\n databasesDecrementDocumentAttribute(\n databaseId: $databaseId\n collectionId: $collectionId\n documentId: $documentId\n attribute: $attribute\n value: $value\n min: $min\n transactionId: $transactionId\n ) {\n _id\n data\n }\n }\n`)\n\n/** The variables accepted by the {@link useDecrementAttribute} mutation. */\nexport type DecrementAttributeVariables = Prettify<VariablesOf<typeof decrementDocumentAttribute>>\n\n/** The result returned by the {@link useDecrementAttribute} mutation. */\nexport type DecrementAttributeResult = Prettify<\n ResultOf<typeof decrementDocumentAttribute>['databasesDecrementDocumentAttribute']\n>\n\n/**\n * Mutation hook to atomically decrement a numeric document attribute with optimistic updates.\n *\n * Accepts an optional `value` (default: 1) and `min` floor. The optimistic update\n * immediately reflects the new value in the cache and rolls back on error.\n *\n * @example\n * ```tsx\n * const { mutate } = useDecrementAttribute()\n *\n * // Decrement \"lives\" by 1\n * mutate({\n * databaseId: 'my-db',\n * collectionId: 'players',\n * documentId: 'player-1',\n * attribute: 'lives',\n * })\n *\n * // Decrement \"balance\" by 50, floored at 0\n * mutate({\n * databaseId: 'my-db',\n * collectionId: 'accounts',\n * documentId: 'acct-1',\n * attribute: 'balance',\n * value: 50,\n * min: 0,\n * })\n * ```\n *\n * **Variables** ({@link DecrementAttributeVariables}):\n * - `databaseId` — The target database ID\n * - `collectionId` — The target collection ID\n * - `documentId` — The ID of the document containing the attribute\n * - `attribute` — The name of the numeric attribute to decrement\n * - `value` — Optional decrement amount (defaults to `1`)\n * - `min` — Optional minimum floor; the attribute will not go below this value\n * - `transactionId` — Optional transaction ID for atomic operations\n *\n * @returns A `UseMutationResult` with the document's `_id` and updated `data`.\n */\nexport function useDecrementAttribute() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const mutationResult = useMutation<\n DecrementAttributeResult,\n AppwriteException[],\n DecrementAttributeVariables,\n {\n previousEntries: [queryKey: readonly unknown[], data: unknown][]\n documentKeyPrefix: readonly unknown[]\n }\n >({\n mutationKey: [...Keys.databases().transactions().operations().key(), 'decrementAttribute'],\n mutationFn: async ({\n databaseId,\n collectionId,\n documentId,\n attribute,\n value,\n min,\n transactionId,\n }) => {\n const { data: mutationData, errors } = await graphql.mutation({\n query: decrementDocumentAttribute,\n variables: {\n databaseId,\n collectionId,\n documentId,\n attribute,\n value,\n min,\n transactionId,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return mutationData.databasesDecrementDocumentAttribute\n },\n onMutate: async (variables) => {\n const documentKeyPrefix = Keys.database(variables.databaseId)\n .collection(variables.collectionId)\n .document(variables.documentId)\n .key()\n\n await queryClient.cancelQueries({ queryKey: documentKeyPrefix })\n\n const previousEntries = queryClient.getQueriesData({\n queryKey: documentKeyPrefix,\n })\n\n queryClient.setQueryData<DecrementAttributeVariables>(documentKeyPrefix, (old) => {\n if (!old) return old\n const current = (old[variables.attribute] as number) ?? 0\n const decrement = variables.value ?? 1\n const newValue =\n variables.min != null ? Math.max(current - decrement, variables.min) : current - decrement\n\n return { ...old, [variables.attribute]: newValue }\n })\n\n return { previousEntries, documentKeyPrefix }\n },\n onError: (_, __, context) => {\n if (context?.previousEntries) {\n for (const [key, data] of context.previousEntries) {\n queryClient.setQueryData(key, data)\n }\n }\n },\n onSettled: (_, __, variables) => {\n void queryClient.invalidateQueries({\n queryKey: Keys.database(variables.databaseId).collection(variables.collectionId).key(),\n })\n },\n })\n\n return mutationResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nexport const deleteDocument = gql(/* GraphQL */ `\n mutation DeleteDocument(\n $databaseId: String!\n $collectionId: String!\n $documentId: String!\n $transactionId: String\n ) {\n databasesDeleteDocument(\n databaseId: $databaseId\n collectionId: $collectionId\n documentId: $documentId\n transactionId: $transactionId\n ) {\n status\n }\n }\n`)\n\n/** The variables accepted by the {@link useDeleteDocument} mutation. */\nexport type DeleteDocumentVariables = Prettify<VariablesOf<typeof deleteDocument>>\n\n/** The result returned by the {@link useDeleteDocument} mutation. */\nexport type DeleteDocumentResult = Prettify<\n ResultOf<typeof deleteDocument>['databasesDeleteDocument']\n>\n\n/**\n * Mutation hook to delete a document with optimistic removal.\n *\n * Removes the document from cache immediately and rolls back on error.\n * On settlement, the document queries are removed and the parent collection\n * queries are invalidated.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useDeleteDocument()\n *\n * mutate({\n * databaseId: 'my-db',\n * collectionId: 'my-collection',\n * documentId: 'doc-123',\n * })\n * ```\n *\n * **Variables** ({@link DeleteDocumentVariables}):\n * - `databaseId` — The target database ID\n * - `collectionId` — The target collection ID\n * - `documentId` — The ID of the document to delete\n * - `transactionId` — Optional transaction ID for atomic operations\n *\n * @returns A `UseMutationResult` with a `status` string indicating the deletion result.\n */\nexport function useDeleteDocument() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const mutationResult = useMutation<\n DeleteDocumentResult,\n AppwriteException[],\n DeleteDocumentVariables,\n {\n previousEntries: [queryKey: readonly unknown[], data: unknown][]\n documentKeyPrefix: readonly unknown[]\n }\n >({\n mutationKey: Keys.databases().collections().documents().delete(),\n mutationFn: async ({ databaseId, collectionId, documentId, transactionId }) => {\n const { data: mutationData, errors } = await graphql.mutation({\n query: deleteDocument,\n variables: {\n databaseId,\n collectionId,\n documentId,\n transactionId,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return mutationData?.databasesDeleteDocument ?? { status: '' }\n },\n onMutate: async (variables) => {\n const documentKeyPrefix = Keys.database(variables.databaseId)\n .collection(variables.collectionId)\n .document(variables.documentId)\n .key()\n\n await queryClient.cancelQueries({ queryKey: documentKeyPrefix })\n\n const previousEntries = queryClient.getQueriesData({\n queryKey: documentKeyPrefix,\n })\n\n queryClient.removeQueries({ queryKey: documentKeyPrefix })\n\n return { previousEntries, documentKeyPrefix }\n },\n onError: (_, __, context) => {\n if (context?.previousEntries) {\n for (const [key, data] of context.previousEntries) {\n queryClient.setQueryData(key, data)\n }\n }\n },\n onSettled: (_, __, variables) => {\n queryClient.removeQueries({\n queryKey: Keys.database(variables.databaseId)\n .collection(variables.collectionId)\n .document(variables.documentId)\n .key(),\n })\n void queryClient.invalidateQueries({\n queryKey: Keys.database(variables.databaseId).collection(variables.collectionId).key(),\n })\n },\n })\n\n return mutationResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst deleteTransaction = gql(/* GraphQL */ `\n mutation DeleteTransaction($transactionId: String!) {\n databasesDeleteTransaction(transactionId: $transactionId) {\n status\n }\n }\n`)\n\n/** The variables accepted by the {@link useDeleteTransaction} mutation. */\nexport type DeleteTransactionVariables = Prettify<VariablesOf<typeof deleteTransaction>>\n\n/** The result returned by the {@link useDeleteTransaction} mutation. */\nexport type DeleteTransactionResult = Prettify<\n ResultOf<typeof deleteTransaction>['databasesDeleteTransaction']\n>\n\n/**\n * Mutation hook to delete a transaction by its ID.\n *\n * Removes the transaction from cache and invalidates transaction list queries on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useDeleteTransaction()\n *\n * mutate({ transactionId: 'txn-abc' })\n * ```\n *\n * **Variables** ({@link DeleteTransactionVariables}):\n * - `transactionId` — The ID of the transaction to delete\n *\n * @returns A `UseMutationResult` with a `status` string indicating the deletion result.\n */\nexport function useDeleteTransaction() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const mutationResult = useMutation<\n DeleteTransactionResult,\n AppwriteException[],\n DeleteTransactionVariables\n >({\n mutationKey: Keys.databases().transactions().delete(),\n mutationFn: async ({ transactionId }) => {\n const { data, errors } = await graphql.mutation({\n query: deleteTransaction,\n variables: { transactionId },\n })\n\n if (errors) {\n throw errors\n }\n\n return data?.databasesDeleteTransaction ?? { status: '' }\n },\n onSuccess: (_, variables) => {\n queryClient.removeQueries({\n queryKey: Keys.databases().transaction(variables.transactionId).key(),\n })\n void queryClient.invalidateQueries({\n queryKey: Keys.databases().transactions().key(),\n })\n },\n })\n\n return mutationResult\n}\n","import { useEffect } from 'react'\nimport { Channel } from 'appwrite'\nimport type { VariablesOf } from 'gql.tada'\n\nimport type { getDocument } from './queryOptions'\nimport { getDocumentQuery } from './queryOptions'\nimport type { Document } from './types'\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, QueryOptions } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\nimport { useQueryClient } from '../useQueryClient'\nimport { useSuspenseQuery } from '../useSuspenseQuery'\n\ntype Variables = VariablesOf<typeof getDocument>\n\n/** The parameters accepted by the {@link useDocument} hook. */\nexport type DocumentParams<TDocument = Record<string, unknown>> = Variables & {\n fields?: (keyof TDocument & string)[]\n}\n\nfunction useDocumentQueryConfig<TDocument>({\n databaseId,\n collectionId,\n documentId,\n queries,\n transactionId,\n fields,\n}: DocumentParams<TDocument>) {\n const client = useAppwrite()\n\n return getDocumentQuery<TDocument>(client, {\n databaseId,\n collectionId,\n documentId,\n queries,\n transactionId,\n fields,\n })\n}\n\nfunction useDocumentRealtime(\n databaseId: string,\n collectionId: string,\n documentId: string,\n queriesKey: string,\n) {\n const { realtime } = useAppwrite()\n const queryClient = useQueryClient()\n\n useEffect(() => {\n const subscriptionPromise = realtime.subscribe(\n Channel.tablesdb(databaseId).table(collectionId).row(documentId).update(),\n (response) => {\n queryClient.setQueryData(\n Keys.database(databaseId).collection(collectionId).document(documentId).key(),\n response.payload,\n )\n },\n )\n\n return () => {\n void subscriptionPromise.then((sub) => sub.close())\n }\n }, [databaseId, collectionId, documentId, realtime, queryClient, queriesKey])\n}\n\n/**\n * Fetches a single document by ID and subscribes to real-time updates.\n *\n * @typeParam TDocument - The shape of the document's custom attributes.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useDocument({\n * databaseId: 'my-db',\n * collectionId: 'my-collection',\n * documentId: 'doc-123',\n * })\n * ```\n *\n * **Parameters** ({@link DocumentParams}):\n * - `databaseId` — The database ID\n * - `collectionId` — The collection ID\n * - `documentId` — The document ID to fetch\n * - `queries` — Optional query filters\n * - `transactionId` — Optional transaction ID for atomic reads\n * - `fields` — Optional array of fields to select\n *\n * @returns A `UseQueryResult` with the document data as `Document<TDocument>`.\n */\nexport function useDocument<TDocument>(\n {\n databaseId,\n collectionId,\n documentId,\n queries,\n transactionId,\n fields,\n }: DocumentParams<TDocument>,\n opts: QueryOptions = {},\n) {\n const config = useDocumentQueryConfig<TDocument>({\n databaseId,\n collectionId,\n documentId,\n queries,\n transactionId,\n fields,\n })\n const queriesKey = JSON.stringify(queries)\n\n const queryResult = useQuery<Document<TDocument>, AppwriteException[], Document<TDocument>>({\n ...config,\n ...opts,\n })\n\n useDocumentRealtime(databaseId, collectionId, documentId, queriesKey)\n\n return queryResult\n}\n\n/**\n * Suspense variant of {@link useDocument}. Suspends the component while loading.\n *\n * @typeParam TDocument - The shape of the document's custom attributes.\n *\n * @example\n * ```tsx\n * const { data } = useSuspenseDocument({\n * databaseId: 'my-db',\n * collectionId: 'my-collection',\n * documentId: 'doc-123',\n * })\n * ```\n *\n * **Parameters** ({@link DocumentParams}):\n * - `databaseId` — The database ID\n * - `collectionId` — The collection ID\n * - `documentId` — The document ID to fetch\n * - `queries` — Optional query filters\n * - `transactionId` — Optional transaction ID for atomic reads\n * - `fields` — Optional array of fields to select\n *\n * @returns A `UseSuspenseQueryResult` with the document data as `Document<TDocument>`.\n */\nexport function useSuspenseDocument<TDocument>(\n {\n databaseId,\n collectionId,\n documentId,\n queries,\n transactionId,\n fields,\n }: DocumentParams<TDocument>,\n opts: QueryOptions = {},\n) {\n const config = useDocumentQueryConfig<TDocument>({\n databaseId,\n collectionId,\n documentId,\n queries,\n transactionId,\n fields,\n })\n const queriesKey = JSON.stringify(queries)\n\n const queryResult = useSuspenseQuery<\n Document<TDocument>,\n AppwriteException[],\n Document<TDocument>\n >({ ...config, ...opts })\n\n useDocumentRealtime(databaseId, collectionId, documentId, queriesKey)\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify, QueryOptions } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst getTransaction = gql(/* GraphQL */ `\n query GetTransaction($transactionId: String!) {\n databasesGetTransaction(transactionId: $transactionId) {\n _id\n _createdAt\n _updatedAt\n status\n operations\n expiresAt\n }\n }\n`)\n\n/** The variables accepted by the {@link useGetTransaction} hook. */\nexport type GetTransactionVariables = Prettify<VariablesOf<typeof getTransaction>>\n\n/** The result returned by the {@link useGetTransaction} hook. */\nexport type GetTransactionResult = Prettify<\n ResultOf<typeof getTransaction>['databasesGetTransaction']\n>\n\n/**\n * Fetches a transaction by its ID, including status, operations, and expiry.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useGetTransaction({\n * transactionId: 'txn-abc-123',\n * })\n * ```\n *\n * **Parameters** ({@link GetTransactionVariables}):\n * - `transactionId` — The ID of the transaction to fetch\n *\n * @returns A `UseQueryResult` with the transaction data as {@link GetTransactionResult}.\n */\nexport function useGetTransaction(\n { transactionId }: GetTransactionVariables,\n opts: QueryOptions = {},\n) {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<GetTransactionResult, AppwriteException[], GetTransactionResult>({\n queryKey: Keys.databases().transaction(transactionId).key(),\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: getTransaction,\n variables: { transactionId },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.databasesGetTransaction\n },\n ...opts,\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nexport const incrementDocumentAttribute = gql(/* GraphQL */ `\n mutation IncrementDocumentAttribute(\n $databaseId: String!\n $collectionId: String!\n $documentId: String!\n $attribute: String!\n $value: Int\n $max: Int\n $transactionId: String\n ) {\n databasesIncrementDocumentAttribute(\n databaseId: $databaseId\n collectionId: $collectionId\n documentId: $documentId\n attribute: $attribute\n value: $value\n max: $max\n transactionId: $transactionId\n ) {\n _id\n data\n }\n }\n`)\n\n/** The variables accepted by the {@link useIncrementAttribute} mutation. */\nexport type IncrementAttributeVariables = Prettify<VariablesOf<typeof incrementDocumentAttribute>>\n\n/** The result returned by the {@link useIncrementAttribute} mutation. */\nexport type IncrementAttributeResult = Prettify<\n ResultOf<typeof incrementDocumentAttribute>['databasesIncrementDocumentAttribute']\n>\n\n/**\n * Mutation hook to atomically increment a numeric document attribute with optimistic updates.\n *\n * Accepts an optional `value` (default: 1) and `max` ceiling. The optimistic update\n * immediately reflects the new value in the cache and rolls back on error.\n *\n * @example\n * ```tsx\n * const { mutate } = useIncrementAttribute()\n *\n * // Increment \"score\" by 1\n * mutate({\n * databaseId: 'my-db',\n * collectionId: 'players',\n * documentId: 'player-1',\n * attribute: 'score',\n * })\n *\n * // Increment \"lives\" by 3, capped at 10\n * mutate({\n * databaseId: 'my-db',\n * collectionId: 'players',\n * documentId: 'player-1',\n * attribute: 'lives',\n * value: 3,\n * max: 10,\n * })\n * ```\n *\n * **Variables** ({@link IncrementAttributeVariables}):\n * - `databaseId` — The target database ID\n * - `collectionId` — The target collection ID\n * - `documentId` — The ID of the document containing the attribute\n * - `attribute` — The name of the numeric attribute to increment\n * - `value` — Optional increment amount (defaults to `1`)\n * - `max` — Optional maximum ceiling; the attribute will not exceed this value\n * - `transactionId` — Optional transaction ID for atomic operations\n *\n * @returns A `UseMutationResult` with the document's `_id` and updated `data`.\n */\nexport function useIncrementAttribute() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const mutationResult = useMutation<\n IncrementAttributeResult,\n AppwriteException[],\n IncrementAttributeVariables,\n {\n previousEntries: [queryKey: readonly unknown[], data: unknown][]\n documentKeyPrefix: readonly unknown[]\n }\n >({\n mutationKey: [...Keys.databases().transactions().operations().key(), 'incrementAttribute'],\n mutationFn: async ({\n databaseId,\n collectionId,\n documentId,\n attribute,\n value,\n max,\n transactionId,\n }) => {\n const { data: mutationData, errors } = await graphql.mutation({\n query: incrementDocumentAttribute,\n variables: {\n databaseId,\n collectionId,\n documentId,\n attribute,\n value,\n max,\n transactionId,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return mutationData.databasesIncrementDocumentAttribute\n },\n onMutate: async (variables) => {\n const documentKeyPrefix = Keys.database(variables.databaseId)\n .collection(variables.collectionId)\n .document(variables.documentId)\n .key()\n\n await queryClient.cancelQueries({ queryKey: documentKeyPrefix })\n\n const previousEntries = queryClient.getQueriesData({\n queryKey: documentKeyPrefix,\n })\n\n queryClient.setQueryData<IncrementAttributeVariables>(documentKeyPrefix, (old) => {\n if (!old) return old\n const current = (old[variables.attribute] as number) ?? 0\n const increment = variables.value ?? 1\n const newValue =\n variables.max != null ? Math.min(current + increment, variables.max) : current + increment\n\n return { ...old, [variables.attribute]: newValue }\n })\n\n return { previousEntries, documentKeyPrefix }\n },\n onError: (_, __, context) => {\n if (context?.previousEntries) {\n for (const [key, data] of context.previousEntries) {\n queryClient.setQueryData(key, data)\n }\n }\n },\n onSettled: (_, __, variables) => {\n void queryClient.invalidateQueries({\n queryKey: Keys.database(variables.databaseId).collection(variables.collectionId).key(),\n })\n },\n })\n\n return mutationResult\n}\n","import { useCallback, useEffect, useState } from 'react'\nimport { Query } from 'appwrite'\n\nimport type { Document } from './types'\nimport { useCollection } from './useCollection'\n\n/**\n * Fetches documents with infinite scroll pagination, accumulating results across pages.\n * Returns `documents`, `total`, `hasNextPage`, `fetchNextPage`, `isFetchingNextPage`, and `reset`.\n * Default page limit is 25.\n *\n * @typeParam TDocument - The shape of each document's custom attributes.\n *\n * @example\n * ```tsx\n * const { documents, fetchNextPage, hasNextPage, isFetchingNextPage } =\n * useInfiniteCollection({\n * databaseId: 'my-db',\n * collectionId: 'my-collection',\n * queries: [Query.orderDesc('$createdAt')],\n * limit: 20,\n * })\n * ```\n *\n * **Parameters:**\n * - `databaseId` — The database ID\n * - `collectionId` — The collection ID\n * - `queries` — Query filters applied to the collection\n * - `transactionId` — Optional transaction ID for atomic reads\n * - `limit` — Number of documents per page (defaults to `25`)\n * - `subscribe` — Whether to subscribe to real-time updates (defaults to `true`)\n * - `fields` — Optional array of document fields to select\n *\n * @returns An object with accumulated `documents`, `total`, `hasNextPage`, `fetchNextPage()`,\n * `isFetchingNextPage`, `reset()`, and standard query status flags.\n */\nexport function useInfiniteCollection<TDocument>({\n databaseId,\n collectionId,\n queries,\n transactionId,\n limit = 25,\n subscribe = true,\n fields,\n}: {\n databaseId: string\n collectionId: string\n queries: string[]\n transactionId?: string\n limit?: number\n subscribe?: boolean\n fields?: (keyof TDocument & string)[]\n}) {\n const [page, setPage] = useState(1)\n const [accumulated, setAccumulated] = useState<Document<TDocument>[]>([])\n\n const offset = (page - 1) * limit\n const paginatedQueries = [...queries, Query.limit(limit), Query.offset(offset)]\n\n const collection = useCollection<TDocument>({\n databaseId,\n collectionId,\n queries: paginatedQueries,\n transactionId,\n subscribe,\n fields,\n })\n\n // Accumulate documents across pages\n useEffect(() => {\n if (collection.documents) {\n if (page === 1) {\n setAccumulated([...collection.documents])\n } else {\n setAccumulated((prev) => {\n // Only append if we don't already have documents for this page\n const expectedLength = (page - 1) * limit + collection.documents!.length\n if (prev.length < expectedLength) {\n return [...prev, ...collection.documents!]\n }\n return prev\n })\n }\n }\n }, [collection.documents, page, limit])\n\n const total = collection.total ?? 0\n const hasNextPage = total > 0 && offset + limit < total\n\n const fetchNextPage = useCallback(() => {\n if (hasNextPage && !collection.isFetching) {\n setPage((prev) => prev + 1)\n }\n }, [hasNextPage, collection.isFetching])\n\n const reset = useCallback(() => {\n setAccumulated([])\n setPage(1)\n }, [])\n\n return {\n documents: accumulated,\n total,\n hasNextPage,\n fetchNextPage,\n isFetchingNextPage: page > 1 && collection.isFetching,\n isLoading: collection.isLoading,\n isError: collection.isError,\n error: collection.error,\n isFetching: collection.isFetching,\n reset,\n }\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify, QueryOptions } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst listTransactions = gql(/* GraphQL */ `\n query ListTransactions($queries: String) {\n databasesListTransactions(queries: $queries) {\n total\n transactions {\n _id\n _createdAt\n _updatedAt\n status\n operations\n expiresAt\n }\n }\n }\n`)\n\n/** The result returned by the {@link useListTransactions} hook. */\nexport type ListTransactionsResult = Prettify<\n ResultOf<typeof listTransactions>['databasesListTransactions']\n>\n\n/**\n * Fetches a list of database transactions with optional query filters.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useListTransactions()\n * ```\n *\n * **Parameters:**\n * - `queries` — Optional query string to filter transactions\n *\n * @returns A `UseQueryResult` with the transaction list as {@link ListTransactionsResult},\n * containing `total` and `transactions`.\n */\nexport function useListTransactions(\n { queries }: { queries?: string } = {},\n opts: QueryOptions = {},\n) {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<ListTransactionsResult, AppwriteException[], ListTransactionsResult>(\n {\n queryKey: [...Keys.databases().transactions().key(), ...(queries ? [queries] : [])],\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: listTransactions,\n variables: { queries },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.databasesListTransactions\n },\n ...opts,\n },\n )\n\n return queryResult\n}\n","import type { ConflictContext, ConflictStrategy } from './types'\n\n/**\n * Applies a conflict resolution strategy to produce the merged document data\n * that should be sent to the server, or `'abort'` to discard the mutation.\n *\n * @returns The resolved field-level data (not the full document — just the\n * fields to write), or `'abort'` if the mutation should be dropped.\n */\nexport function resolveConflict(\n context: ConflictContext,\n strategy: ConflictStrategy,\n): Record<string, unknown> | 'abort' {\n if (typeof strategy === 'function') {\n return strategy(context)\n }\n\n switch (strategy) {\n case 'last-write-wins':\n return extractChangedFields(context.base, context.local)\n\n case 'server-wins':\n return 'abort'\n\n case 'merge-shallow': {\n const localChanges = extractChangedFields(context.base, context.local)\n const remoteChanges = extractChangedFields(context.base, context.remote)\n\n // Remote changes win where both sides modified the same field\n return { ...localChanges, ...remoteChanges }\n }\n }\n}\n\n/**\n * Returns only the fields in `updated` that differ from `original`.\n */\nfunction extractChangedFields(\n original: Record<string, unknown>,\n updated: Record<string, unknown>,\n): Record<string, unknown> {\n const changes: Record<string, unknown> = {}\n\n for (const key of Object.keys(updated)) {\n if (JSON.stringify(original[key]) !== JSON.stringify(updated[key])) {\n changes[key] = updated[key]\n }\n }\n\n return changes\n}\n","import { Keys } from '../..'\nimport { getDocument } from '../../databases/queryOptions'\nimport { updateDocument } from '../../databases/useUpdateDocument'\nimport { resolveConflict } from '../conflictResolution/resolve'\nimport type { ConflictStrategy } from '../conflictResolution/types'\nimport type { MutationFn, Vars } from '../types'\n\n/**\n * Creates a conflict-aware mutationFn for document updates.\n *\n * When a base snapshot is available (persisted in MutationState.context by\n * useUpdateDocument's onMutate), the function fetches the current remote\n * document, runs the configured conflict resolution strategy, and sends the\n * resolved data. If no base snapshot exists (e.g. the mutation was created\n * while online and executed immediately), it falls through to a normal update.\n */\nexport function conflictAwareUpdate(conflictStrategy: ConflictStrategy): MutationFn {\n return async (client, variables, queryClient) => {\n const { databaseId, collectionId, documentId } = variables as {\n databaseId: string\n collectionId: string\n documentId: string\n }\n\n // Look up the mutation instance to read the persisted onMutate context\n const mutation = queryClient\n .getMutationCache()\n .getAll()\n .find((m) => JSON.stringify(m.state.variables) === JSON.stringify(variables))\n\n const baseSnapshot = (mutation?.state.context as { baseSnapshot?: Record<string, unknown> })\n ?.baseSnapshot\n\n let resolvedData = variables.data as Record<string, unknown>\n if (baseSnapshot) {\n const { data: remoteResult, errors: fetchErrors } = await client.graphql.query({\n query: getDocument,\n variables: { databaseId, collectionId, documentId },\n })\n\n if (fetchErrors) throw fetchErrors\n\n const rawRemote = remoteResult.databasesGetDocument\n const remote = {\n ...rawRemote,\n ...(rawRemote ? (JSON.parse(rawRemote.data as string) as Record<string, unknown>) : {}),\n } as Record<string, unknown>\n delete remote.data // Remove the raw JSON string from the remote document\n delete remote._id // Remove the _id field to avoid confusion during conflict resolution\n\n // Build the \"local\" document: the base with the user's changes applied\n const local = {\n ...baseSnapshot,\n ...(variables.data as Record<string, unknown>),\n }\n\n const result = resolveConflict(\n {\n base: baseSnapshot as never,\n remote: remote as never,\n local: local as never,\n mutationKey: [databaseId, collectionId, documentId],\n },\n conflictStrategy,\n )\n\n if (result === 'abort') {\n await queryClient.setQueryData(\n Keys.database(databaseId).collection(collectionId).document(documentId).key(),\n remote,\n )\n return { _id: documentId }\n }\n\n resolvedData = result\n }\n\n const { data, errors } = await client.graphql.mutation({\n query: updateDocument,\n variables: {\n ...variables,\n data: JSON.stringify(resolvedData.data ?? resolvedData),\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } as any,\n })\n\n const newData = (resolvedData.data ?? resolvedData) as Record<string, unknown>\n delete variables.data\n\n const thing = { ...baseSnapshot, ...newData, _id: documentId }\n\n await queryClient.setQueryData(\n Keys.database(databaseId).collection(collectionId).document(documentId).key(),\n (old: Record<string, unknown> | undefined) =>\n old\n ? {\n ...old,\n ...thing,\n }\n : old,\n )\n\n if (errors) throw errors\n return (data as Vars).databasesUpdateDocument as { _id: string }\n }\n}\n","import { onlineManager } from '@tanstack/react-query'\nimport type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport type { ConflictStrategy } from '../offline/conflictResolution/types'\nimport { conflictAwareUpdate } from '../offline/mutations/conflictAwareUpdate'\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nexport const updateDocument = gql(/* GraphQL */ `\n mutation UpdateDocument(\n $databaseId: String!\n $collectionId: String!\n $documentId: String!\n $data: Json\n $permissions: [String!]\n $transactionId: String\n ) {\n databasesUpdateDocument(\n databaseId: $databaseId\n collectionId: $collectionId\n documentId: $documentId\n data: $data\n permissions: $permissions\n transactionId: $transactionId\n ) {\n _id\n }\n }\n`)\n\ntype Variables = VariablesOf<typeof updateDocument>\n/** The result returned by the {@link useUpdateDocument} mutation. */\nexport type UpdateDocumentResult = Prettify<\n ResultOf<typeof updateDocument>['databasesUpdateDocument']\n>\n\n/** The variables accepted by the {@link useUpdateDocument} mutation. */\nexport type UpdateDocumentVariables = Prettify<\n Omit<Variables, 'permissions'> & {\n permissions?: string[] | null\n }\n>\n\n/** The optimistic-update context used by the {@link useUpdateDocument} mutation. */\nexport type UpdateDocumentMutationContext = {\n previousEntries: [queryKey: readonly unknown[], data: unknown][]\n documentKeyPrefix: readonly unknown[]\n baseSnapshot: Record<string, unknown> | undefined\n willPerformOfflineMutation: boolean\n}\n\n/**\n * Mutation hook to update an existing document with optimistic updates.\n *\n * Supports offline conflict resolution and rolls back optimistic updates on error.\n * When the device is offline, mutations are queued and replayed when connectivity\n * returns. A `conflictStrategy` (configured via the offline client) controls how\n * conflicts between the optimistic base snapshot and the server state are resolved.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useUpdateDocument()\n *\n * mutate({\n * databaseId: 'my-db',\n * collectionId: 'my-collection',\n * documentId: 'doc-123',\n * data: { name: 'Jane', age: 31 },\n * permissions: ['read(\"any\")', 'write(\"user:alice\")'],\n * })\n * ```\n *\n * **Variables** ({@link UpdateDocumentVariables}):\n * - `databaseId` — The target database ID\n * - `collectionId` — The target collection ID\n * - `documentId` — The ID of the document to update\n * - `data` — Optional partial document data to merge into the existing document\n * - `permissions` — Optional array of permission strings, or `null`\n * - `transactionId` — Optional transaction ID for atomic operations\n *\n * An optional `conflictStrategy` can be configured through the offline client to\n * control conflict resolution (e.g. `'last-write-wins'`, `'server-wins'`, or a\n * custom three-way merge function).\n *\n * @returns A `UseMutationResult` with the updated document's `_id`.\n */\nexport function useUpdateDocument() {\n const appwrite = useAppwrite()\n const queryClient = useQueryClient()\n\n const mutationResult = useMutation<\n UpdateDocumentResult,\n AppwriteException[],\n UpdateDocumentVariables,\n UpdateDocumentMutationContext\n >({\n mutationKey: Keys.databases().collections().documents().update(),\n mutationFn: async (\n { databaseId, collectionId, documentId, data, permissions, transactionId },\n ctx,\n ) => {\n const wasOffline = ctx.meta.willPerformOfflineMutation ?? false\n\n if (ctx.meta.willPerformOfflineMutation != null) {\n delete ctx.meta.willPerformOfflineMutation\n }\n\n if (wasOffline) {\n try {\n const updateData = (await conflictAwareUpdate(\n ctx.meta.conflictStrategy as ConflictStrategy,\n )(\n appwrite,\n {\n databaseId,\n collectionId,\n documentId,\n data,\n permissions,\n transactionId,\n },\n queryClient,\n )) as UpdateDocumentResult\n\n return updateData\n } catch (error) {\n console.error('Conflict-aware update failed:', error)\n throw error\n }\n }\n\n const { data: mutationData, errors } = await appwrite.graphql.mutation({\n query: updateDocument,\n variables: {\n databaseId,\n collectionId,\n documentId,\n data: JSON.stringify(data),\n permissions,\n transactionId,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return mutationData.databasesUpdateDocument\n },\n onMutate: async (variables, ctx) => {\n const documentKeyPrefix = Keys.database(variables.databaseId)\n .collection(variables.collectionId)\n .document(variables.documentId)\n .key()\n\n await queryClient.cancelQueries({ queryKey: documentKeyPrefix })\n\n const previousEntries = queryClient.getQueriesData({\n queryKey: documentKeyPrefix,\n })\n\n // Capture a deep copy of the document before optimistic update.\n // This snapshot is persisted in MutationState.context through\n // dehydration and serves as the \"base\" for three-way conflict\n // resolution when a paused mutation is replayed.\n const baseSnapshot = previousEntries.find(([, data]) => data != null)?.[1] as\n | Record<string, unknown>\n | undefined\n const baseSnapshotCopy = baseSnapshot\n ? (JSON.parse(JSON.stringify(baseSnapshot)) as Record<string, unknown>)\n : undefined\n\n queryClient.setQueryData<UpdateDocumentVariables>(documentKeyPrefix, (old) =>\n old ? { ...old, ...(variables.data as Record<string, unknown>) } : old,\n )\n\n const willPerformOfflineMutation = onlineManager.isOnline() === false\n ctx.meta = { ...ctx.meta, willPerformOfflineMutation }\n\n return {\n previousEntries,\n documentKeyPrefix,\n baseSnapshot: baseSnapshotCopy,\n willPerformOfflineMutation,\n }\n },\n onError: (_, __, context) => {\n if (context?.previousEntries) {\n for (const [key, data] of context.previousEntries) {\n queryClient.setQueryData(key, data)\n }\n }\n },\n onSettled: (_, __, variables) => {\n void queryClient.invalidateQueries({\n queryKey: Keys.database(variables.databaseId).collection(variables.collectionId).key(),\n })\n },\n })\n\n return mutationResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst updateTransaction = gql(/* GraphQL */ `\n mutation UpdateTransaction($transactionId: String!, $commit: Boolean, $rollback: Boolean) {\n databasesUpdateTransaction(\n transactionId: $transactionId\n commit: $commit\n rollback: $rollback\n ) {\n _id\n status\n operations\n }\n }\n`)\n\n/** The variables accepted by the {@link useUpdateTransaction} mutation. */\nexport type UpdateTransactionVariables = Prettify<VariablesOf<typeof updateTransaction>>\n\n/** The result returned by the {@link useUpdateTransaction} mutation. */\nexport type UpdateTransactionResult = Prettify<\n ResultOf<typeof updateTransaction>['databasesUpdateTransaction']\n>\n\n/**\n * Mutation hook to commit or rollback a transaction.\n *\n * Invalidates both the individual transaction query and the transaction list queries\n * on success.\n *\n * @example\n * ```tsx\n * const { mutate } = useUpdateTransaction()\n *\n * // Commit a transaction\n * mutate({ transactionId: 'txn-abc', commit: true })\n *\n * // Or roll it back\n * mutate({ transactionId: 'txn-abc', rollback: true })\n * ```\n *\n * **Variables** ({@link UpdateTransactionVariables}):\n * - `transactionId` — The ID of the transaction to update\n * - `commit` — Optional boolean; set to `true` to commit the transaction\n * - `rollback` — Optional boolean; set to `true` to rollback the transaction\n *\n * @returns A `UseMutationResult` with the transaction's `_id`, `status`, and `operations` list.\n */\nexport function useUpdateTransaction() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const mutationResult = useMutation<\n UpdateTransactionResult,\n AppwriteException[],\n UpdateTransactionVariables\n >({\n mutationKey: Keys.databases().transactions().update(),\n mutationFn: async ({ transactionId, commit, rollback }) => {\n const { data, errors } = await graphql.mutation({\n query: updateTransaction,\n variables: { transactionId, commit, rollback },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.databasesUpdateTransaction\n },\n onSuccess: (_, variables) => {\n void queryClient.invalidateQueries({\n queryKey: Keys.databases().transaction(variables.transactionId).key(),\n })\n void queryClient.invalidateQueries({\n queryKey: Keys.databases().transactions().key(),\n })\n },\n })\n\n return mutationResult\n}\n","import { onlineManager } from '@tanstack/react-query'\nimport type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport type { ConflictStrategy } from '../offline'\nimport { conflictAwareUpdate } from '../offline/mutations/conflictAwareUpdate'\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nexport const upsertDocument = gql(/* GraphQL */ `\n mutation UpsertDocument(\n $databaseId: String!\n $collectionId: String!\n $documentId: String!\n $data: Json!\n $permissions: [String!]\n $transactionId: String\n ) {\n databasesUpsertDocument(\n databaseId: $databaseId\n collectionId: $collectionId\n documentId: $documentId\n data: $data\n permissions: $permissions\n transactionId: $transactionId\n ) {\n _id\n }\n }\n`)\n\ntype Variables = VariablesOf<typeof upsertDocument>\n/** The result returned by the {@link useUpsertDocument} mutation. */\nexport type UpsertDocumentResult = Prettify<\n ResultOf<typeof upsertDocument>['databasesUpsertDocument']\n>\n\n/** The variables accepted by the {@link useUpsertDocument} mutation. */\nexport type UpsertDocumentVariables = Prettify<\n Omit<Variables, 'permissions'> & {\n permissions?: string[] | null\n }\n>\n\n/** The optimistic-update context used by the {@link useUpsertDocument} mutation. */\nexport type UpsertDocumentMutationContext = {\n previousEntries: [queryKey: readonly unknown[], data: unknown][]\n documentKeyPrefix: readonly unknown[]\n baseSnapshot: Record<string, unknown> | undefined\n willPerformOfflineMutation: boolean\n}\n\n/**\n * Mutation hook to create or update a document (upsert) with optimistic updates.\n *\n * Supports offline conflict resolution and rolls back on error. When the device is\n * offline, mutations are queued and replayed when connectivity returns. A\n * `conflictStrategy` (configured via the offline client) controls how conflicts\n * between the optimistic base snapshot and the server state are resolved.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useUpsertDocument()\n *\n * mutate({\n * databaseId: 'my-db',\n * collectionId: 'my-collection',\n * documentId: 'doc-456',\n * data: { name: 'Alice', score: 100 },\n * permissions: ['read(\"any\")'],\n * })\n * ```\n *\n * **Variables** ({@link UpsertDocumentVariables}):\n * - `databaseId` — The target database ID\n * - `collectionId` — The target collection ID\n * - `documentId` — Unique document ID — creates the document if it doesn't exist, updates it otherwise\n * - `data` — The document data as a JSON-serializable object\n * - `permissions` — Optional array of permission strings, or `null`\n * - `transactionId` — Optional transaction ID for atomic operations\n *\n * An optional `conflictStrategy` can be configured through the offline client to\n * control conflict resolution (e.g. `'last-write-wins'`, `'server-wins'`, or a\n * custom three-way merge function).\n *\n * @returns A `UseMutationResult` with the upserted document's `_id`.\n */\nexport function useUpsertDocument() {\n const appwrite = useAppwrite()\n const queryClient = useQueryClient()\n\n const mutationResult = useMutation<\n UpsertDocumentResult,\n AppwriteException[],\n UpsertDocumentVariables,\n UpsertDocumentMutationContext\n >({\n mutationKey: Keys.databases().collections().documents().upsert(),\n mutationFn: async (\n { databaseId, collectionId, documentId, data, permissions, transactionId },\n ctx,\n ) => {\n const wasOffline = ctx.meta.willPerformOfflineMutation ?? false\n\n if (ctx.meta.willPerformOfflineMutation != null) {\n delete ctx.meta.willPerformOfflineMutation\n }\n\n if (wasOffline) {\n try {\n const updateData = (await conflictAwareUpdate(\n ctx.meta.conflictStrategy as ConflictStrategy,\n )(\n appwrite,\n {\n databaseId,\n collectionId,\n documentId,\n data,\n permissions,\n transactionId,\n },\n queryClient,\n )) as UpsertDocumentResult\n\n return updateData\n } catch (error) {\n console.error('Conflict-aware update failed:', error)\n throw error\n }\n }\n\n const { data: mutationData, errors } = await appwrite.graphql.mutation({\n query: upsertDocument,\n variables: {\n databaseId,\n collectionId,\n documentId,\n data: JSON.stringify(data),\n permissions,\n transactionId,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return mutationData.databasesUpsertDocument\n },\n onMutate: async (variables, ctx) => {\n const documentKeyPrefix = Keys.database(variables.databaseId)\n .collection(variables.collectionId)\n .document(variables.documentId)\n .key()\n\n await queryClient.cancelQueries({ queryKey: documentKeyPrefix })\n\n const previousEntries = queryClient.getQueriesData({\n queryKey: documentKeyPrefix,\n })\n\n const baseSnapshot = previousEntries.find(([, data]) => data != null)?.[1] as\n | Record<string, unknown>\n | undefined\n const baseSnapshotCopy = baseSnapshot\n ? (JSON.parse(JSON.stringify(baseSnapshot)) as Record<string, unknown>)\n : undefined\n\n queryClient.setQueryData<UpsertDocumentVariables>(documentKeyPrefix, (old) =>\n old ? { ...old, ...(variables.data as Record<string, unknown>) } : old,\n )\n\n const willPerformOfflineMutation = onlineManager.isOnline() === false\n ctx.meta = { ...ctx.meta, willPerformOfflineMutation }\n\n return {\n previousEntries,\n documentKeyPrefix,\n baseSnapshot: baseSnapshotCopy,\n willPerformOfflineMutation,\n }\n },\n onError: (_, __, context) => {\n if (context?.previousEntries) {\n for (const [key, data] of context.previousEntries) {\n queryClient.setQueryData(key, data)\n }\n }\n },\n onSettled: (_, __, variables) => {\n void queryClient.invalidateQueries({\n queryKey: Keys.database(variables.databaseId).collection(variables.collectionId).key(),\n })\n },\n })\n\n return mutationResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst getLocale = gql(/* GraphQL */ `\n query GetLocale {\n localeGet {\n ip\n countryCode\n country\n continentCode\n continent\n eu\n currency\n }\n }\n`)\n\n/** The result returned by the {@link useLocale} hook. */\nexport type LocaleResult = Prettify<ResultOf<typeof getLocale>['localeGet']>\n\n/**\n * Fetches the current user's locale information including IP, country,\n * continent, EU status, and currency.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useLocale()\n *\n * // data.country, data.ip, data.currency, etc.\n * ```\n *\n * @returns A `UseQueryResult` with the user's locale details ({@link LocaleResult}).\n */\nexport function useLocale() {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<LocaleResult, AppwriteException[], LocaleResult>({\n queryKey: Keys.locale().key(),\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: getLocale,\n })\n\n if (errors) {\n throw errors\n }\n\n return data.localeGet\n },\n })\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst listLocaleCodes = gql(/* GraphQL */ `\n query ListLocaleCodes {\n localeListCodes {\n total\n localeCodes {\n code\n name\n }\n }\n }\n`)\n\n/** The result returned by the {@link useLocaleCodes} hook. */\nexport type LocaleCodesResult = Prettify<ResultOf<typeof listLocaleCodes>['localeListCodes']>\n\n/**\n * Fetches the list of available locale codes.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useLocaleCodes()\n *\n * // data.localeCodes — array of { code, name }\n * ```\n *\n * @returns A `UseQueryResult` with the available locale codes ({@link LocaleCodesResult}).\n */\nexport function useLocaleCodes() {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<LocaleCodesResult, AppwriteException[], LocaleCodesResult>({\n queryKey: Keys.locale().codes(),\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: listLocaleCodes,\n })\n\n if (errors) {\n throw errors\n }\n\n return data.localeListCodes\n },\n })\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst listContinents = gql(/* GraphQL */ `\n query ListContinents {\n localeListContinents {\n total\n continents {\n name\n code\n }\n }\n }\n`)\n\n/** The result returned by the {@link useLocaleContinents} hook. */\nexport type LocaleContinentsResult = Prettify<\n ResultOf<typeof listContinents>['localeListContinents']\n>\n\n/**\n * Fetches the list of continents with their names and codes.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useLocaleContinents()\n *\n * // data.continents — array of { name, code }\n * ```\n *\n * @returns A `UseQueryResult` with the list of continents ({@link LocaleContinentsResult}).\n */\nexport function useLocaleContinents() {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<LocaleContinentsResult, AppwriteException[], LocaleContinentsResult>(\n {\n queryKey: Keys.locale().continents(),\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: listContinents,\n })\n\n if (errors) {\n throw errors\n }\n\n return data.localeListContinents\n },\n },\n )\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst listCountries = gql(/* GraphQL */ `\n query ListCountries {\n localeListCountries {\n total\n countries {\n name\n code\n }\n }\n }\n`)\n\n/** The result returned by the {@link useLocaleCountries} hook. */\nexport type LocaleCountriesResult = Prettify<ResultOf<typeof listCountries>['localeListCountries']>\n\n/**\n * Fetches the list of countries with their names and codes.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useLocaleCountries()\n *\n * // data.countries — array of { name, code }\n * ```\n *\n * @returns A `UseQueryResult` with the list of countries ({@link LocaleCountriesResult}).\n */\nexport function useLocaleCountries() {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<LocaleCountriesResult, AppwriteException[], LocaleCountriesResult>({\n queryKey: Keys.locale().countries(),\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: listCountries,\n })\n\n if (errors) {\n throw errors\n }\n\n return data.localeListCountries\n },\n })\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst listCountriesEU = gql(/* GraphQL */ `\n query ListCountriesEU {\n localeListCountriesEU {\n total\n countries {\n name\n code\n }\n }\n }\n`)\n\n/** The result returned by the {@link useLocaleCountriesEU} hook. */\nexport type LocaleCountriesEUResult = Prettify<\n ResultOf<typeof listCountriesEU>['localeListCountriesEU']\n>\n\n/**\n * Fetches the list of EU member countries.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useLocaleCountriesEU()\n *\n * // data.countries — array of { name, code }\n * ```\n *\n * @returns A `UseQueryResult` with the list of EU countries ({@link LocaleCountriesEUResult}).\n */\nexport function useLocaleCountriesEU() {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<\n LocaleCountriesEUResult,\n AppwriteException[],\n LocaleCountriesEUResult\n >({\n queryKey: Keys.locale().countriesEU(),\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: listCountriesEU,\n })\n\n if (errors) {\n throw errors\n }\n\n return data.localeListCountriesEU\n },\n })\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst listCountriesPhones = gql(/* GraphQL */ `\n query ListCountriesPhones {\n localeListCountriesPhones {\n total\n phones {\n code\n countryCode\n countryName\n }\n }\n }\n`)\n\n/** The result returned by the {@link useLocaleCountriesPhones} hook. */\nexport type LocaleCountriesPhonesResult = Prettify<\n ResultOf<typeof listCountriesPhones>['localeListCountriesPhones']\n>\n\n/**\n * Fetches the list of countries with their international phone codes.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useLocaleCountriesPhones()\n *\n * // data.phones — array of { code, countryCode, countryName }\n * ```\n *\n * @returns A `UseQueryResult` with countries and phone codes ({@link LocaleCountriesPhonesResult}).\n */\nexport function useLocaleCountriesPhones() {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<\n LocaleCountriesPhonesResult,\n AppwriteException[],\n LocaleCountriesPhonesResult\n >({\n queryKey: Keys.locale().countriesPhones(),\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: listCountriesPhones,\n })\n\n if (errors) {\n throw errors\n }\n\n return data.localeListCountriesPhones\n },\n })\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst listCurrencies = gql(/* GraphQL */ `\n query ListCurrencies {\n localeListCurrencies {\n total\n currencies {\n symbol\n name\n symbolNative\n decimalDigits\n rounding\n code\n namePlural\n }\n }\n }\n`)\n\n/** The result returned by the {@link useLocaleCurrencies} hook. */\nexport type LocaleCurrenciesResult = Prettify<\n ResultOf<typeof listCurrencies>['localeListCurrencies']\n>\n\n/**\n * Fetches the list of currencies with their symbols, names, and decimal info.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useLocaleCurrencies()\n *\n * // data.currencies — array of { code, name, symbol, ... }\n * ```\n *\n * @returns A `UseQueryResult` with the list of currencies ({@link LocaleCurrenciesResult}).\n */\nexport function useLocaleCurrencies() {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<LocaleCurrenciesResult, AppwriteException[], LocaleCurrenciesResult>(\n {\n queryKey: Keys.locale().currencies(),\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: listCurrencies,\n })\n\n if (errors) {\n throw errors\n }\n\n return data.localeListCurrencies\n },\n },\n )\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst listLanguages = gql(/* GraphQL */ `\n query ListLanguages {\n localeListLanguages {\n total\n languages {\n name\n code\n nativeName\n }\n }\n }\n`)\n\n/** The result returned by the {@link useLocaleLanguages} hook. */\nexport type LocaleLanguagesResult = Prettify<ResultOf<typeof listLanguages>['localeListLanguages']>\n\n/**\n * Fetches the list of languages with their names, codes, and native names.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useLocaleLanguages()\n *\n * // data.languages — array of { name, code, nativeName }\n * ```\n *\n * @returns A `UseQueryResult` with the list of languages ({@link LocaleLanguagesResult}).\n */\nexport function useLocaleLanguages() {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<LocaleLanguagesResult, AppwriteException[], LocaleLanguagesResult>({\n queryKey: Keys.locale().languages(),\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: listLanguages,\n })\n\n if (errors) {\n throw errors\n }\n\n return data.localeListLanguages\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\n\nexport const createSubscriber = gql(/* GraphQL */ `\n mutation CreateSubscriber($subscriberId: String!, $topicId: String!, $targetId: String!) {\n messagingCreateSubscriber(subscriberId: $subscriberId, topicId: $topicId, targetId: $targetId) {\n _id\n _createdAt\n _updatedAt\n targetId\n userId\n userName\n topicId\n providerType\n }\n }\n`)\n\n/** The variables accepted by the {@link useCreateSubscriber} hook. */\nexport type CreateSubscriberVariables = Prettify<VariablesOf<typeof createSubscriber>>\n\n/** The result returned by the {@link useCreateSubscriber} hook. */\nexport type CreateSubscriberResult = Prettify<\n ResultOf<typeof createSubscriber>['messagingCreateSubscriber']\n>\n\n/**\n * Mutation to subscribe a target to a messaging topic.\n *\n * Sends the `CreateSubscriber` GraphQL mutation. Does not perform any cache\n * invalidation — call `queryClient.invalidateQueries` manually if needed.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useCreateSubscriber()\n *\n * mutate({\n * subscriberId: ID.unique(),\n * topicId: 'announcements',\n * targetId: 'target_abc123',\n * })\n * ```\n *\n * **Variables** ({@link CreateSubscriberVariables}):\n * - `subscriberId` — A unique ID for the new subscriber (use `ID.unique()` to auto-generate)\n * - `topicId` — The ID of the messaging topic to subscribe to\n * - `targetId` — The ID of the target (e.g. device or user) to receive messages\n *\n * @returns A `UseMutationResult` whose `data` is the created {@link CreateSubscriberResult} with subscriber metadata including `_id`, `targetId`, `userId`, `userName`, `topicId`, and `providerType`.\n */\nexport function useCreateSubscriber() {\n const { graphql } = useAppwrite()\n\n const mutationResult = useMutation<\n CreateSubscriberResult,\n AppwriteException[],\n CreateSubscriberVariables\n >({\n mutationKey: Keys.messaging().subscriber().create(),\n mutationFn: async ({ subscriberId, topicId, targetId }) => {\n const { data: mutationData, errors } = await graphql.mutation({\n query: createSubscriber,\n variables: {\n subscriberId,\n topicId,\n targetId,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return mutationData?.messagingCreateSubscriber\n },\n })\n\n return mutationResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\n\nexport const deleteSubscriber = gql(/* GraphQL */ `\n mutation DeleteSubscriber($topicId: String!, $subscriberId: String!) {\n messagingDeleteSubscriber(topicId: $topicId, subscriberId: $subscriberId) {\n status\n }\n }\n`)\n\n/** The variables accepted by the {@link useDeleteSubscriber} hook. */\nexport type DeleteSubscriberVariables = Prettify<VariablesOf<typeof deleteSubscriber>>\n\n/** The result returned by the {@link useDeleteSubscriber} hook. */\nexport type DeleteSubscriberResult = Prettify<\n ResultOf<typeof deleteSubscriber>['messagingDeleteSubscriber']\n>\n\n/**\n * Mutation to unsubscribe a target from a messaging topic.\n *\n * Sends the `DeleteSubscriber` GraphQL mutation. Does not perform any cache\n * invalidation — call `queryClient.invalidateQueries` manually if needed.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useDeleteSubscriber()\n *\n * mutate({\n * topicId: 'announcements',\n * subscriberId: 'sub_abc123',\n * })\n * ```\n *\n * **Variables** ({@link DeleteSubscriberVariables}):\n * - `topicId` — The ID of the messaging topic to unsubscribe from\n * - `subscriberId` — The ID of the subscriber to remove\n *\n * @returns A `UseMutationResult` whose `data` is a {@link DeleteSubscriberResult} with a `status` field.\n */\nexport function useDeleteSubscriber() {\n const { graphql } = useAppwrite()\n\n const mutationResult = useMutation<\n DeleteSubscriberResult,\n AppwriteException[],\n DeleteSubscriberVariables\n >({\n mutationKey: Keys.messaging().subscriber().delete(),\n mutationFn: async ({ topicId, subscriberId }) => {\n const { data: mutationData, errors } = await graphql.mutation({\n query: deleteSubscriber,\n variables: {\n topicId,\n subscriberId,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return mutationData?.messagingDeleteSubscriber ?? { status: '' }\n },\n })\n\n return mutationResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst getFile = gql(/* GraphQL */ `\n query GetFile($bucketId: String!, $fileId: String!) {\n storageGetFile(bucketId: $bucketId, fileId: $fileId) {\n _id\n bucketId\n _createdAt\n _updatedAt\n _permissions\n name\n signature\n mimeType\n sizeOriginal\n chunksTotal\n chunksUploaded\n }\n }\n`)\n\n/** The variables accepted by the {@link useFile} hook. */\nexport type FileVariables = Prettify<VariablesOf<typeof getFile>>\n\n/** The result returned by the {@link useFile} hook. */\nexport type FileResult = Prettify<ResultOf<typeof getFile>['storageGetFile']>\n\n/**\n * Fetches a single file's metadata from a storage bucket.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useFile({\n * bucketId: 'images',\n * fileId: '6482…',\n * })\n *\n * // data.name, data.mimeType, data.sizeOriginal, etc.\n * ```\n *\n * **Parameters** ({@link FileVariables}):\n * - `bucketId` — The storage bucket identifier.\n * - `fileId` — The unique file identifier.\n *\n * @returns A `UseQueryResult` with the file's metadata ({@link FileResult}).\n */\nexport function useFile({ bucketId, fileId }: FileVariables) {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<FileResult, AppwriteException[], FileResult>({\n queryKey: Keys.bucket(bucketId).file(fileId).key(),\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: getFile,\n variables: { bucketId, fileId },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.storageGetFile\n },\n })\n\n return queryResult\n}\n","import { useMemo } from 'react'\n\nimport { useAppwrite } from '../useAppwrite'\n\n/**\n * Returns a URL for downloading a file from a storage bucket.\n * Memoized to avoid unnecessary recomputation.\n * @param params - The bucket ID, file ID, and optional access token.\n */\nexport function useFileDownload({\n bucketId,\n fileId,\n token,\n}: {\n bucketId: string\n fileId: string\n token?: string\n}) {\n const { storage } = useAppwrite()\n\n const url = useMemo(\n () => storage?.getFileDownload({ bucketId, fileId, token }),\n [storage, bucketId, fileId, token],\n )\n\n return url\n}\n","import { useMemo } from 'react'\nimport type { ImageFormat, ImageGravity } from 'appwrite'\n\nimport { useAppwrite } from '../useAppwrite'\n\n/**\n * Returns a URL for a file preview image with optional transformations\n * (resize, crop, border, opacity, rotation, format). Memoized to avoid unnecessary recomputation.\n * @param params - The bucket ID, file ID, and optional image transformation options.\n */\nexport function useFilePreview({\n bucketId,\n fileId,\n width,\n height,\n gravity,\n quality,\n borderWidth,\n borderColor,\n borderRadius,\n opacity,\n rotation,\n background,\n output,\n token,\n}: {\n bucketId: string\n fileId: string\n width?: number\n height?: number\n gravity?: ImageGravity\n quality?: number\n borderWidth?: number\n borderColor?: string\n borderRadius?: number\n opacity?: number\n rotation?: number\n background?: string\n output?: ImageFormat\n token?: string\n}) {\n const { storage } = useAppwrite()\n\n const url = useMemo(\n () =>\n storage?.getFilePreview({\n bucketId,\n fileId,\n width,\n height,\n gravity,\n quality,\n borderWidth,\n borderColor,\n borderRadius,\n opacity,\n rotation,\n background,\n output,\n token,\n }),\n [\n storage,\n bucketId,\n fileId,\n width,\n height,\n gravity,\n quality,\n borderWidth,\n borderColor,\n borderRadius,\n opacity,\n rotation,\n background,\n output,\n token,\n ],\n )\n\n return url\n}\n","import { useMemo } from 'react'\n\nimport { useAppwrite } from '../useAppwrite'\n\n/**\n * Returns a URL for viewing a file in the browser.\n * Memoized to avoid unnecessary recomputation.\n * @param params - The bucket ID, file ID, and optional access token.\n */\nexport function useFileView({\n bucketId,\n fileId,\n token,\n}: {\n bucketId: string\n fileId: string\n token?: string\n}) {\n const { storage } = useAppwrite()\n\n const url = useMemo(\n () => storage?.getFileView({ bucketId, fileId, token }),\n [storage, bucketId, fileId, token],\n )\n\n return url\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst listFiles = gql(/* GraphQL */ `\n query ListFiles($bucketId: String!, $queries: [String!], $search: String) {\n storageListFiles(bucketId: $bucketId, queries: $queries, search: $search) {\n total\n files {\n _id\n bucketId\n _createdAt\n _updatedAt\n _permissions\n name\n signature\n mimeType\n sizeOriginal\n chunksTotal\n chunksUploaded\n }\n }\n }\n`)\n\n/** The result returned by the {@link useFiles} hook. */\nexport type FilesResult = Prettify<ResultOf<typeof listFiles>['storageListFiles']>\n\n/**\n * Fetches a list of files from a storage bucket with optional query filters and search.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useFiles({\n * bucketId: 'images',\n * queries: ['limit(25)'],\n * })\n *\n * // data.total, data.files\n * ```\n *\n * **Parameters:**\n * - `bucketId` — The storage bucket identifier.\n * - `queries` *(optional)* — Appwrite query strings for filtering and pagination.\n * - `search` *(optional)* — A search term to filter files by name.\n *\n * @returns A `UseQueryResult` with the paginated file list ({@link FilesResult}).\n */\nexport function useFiles({\n bucketId,\n queries,\n search,\n}: {\n bucketId: string\n queries?: string[]\n search?: string\n}) {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<FilesResult, AppwriteException[], FilesResult>({\n queryKey: [\n ...Keys.bucket(bucketId).files().key(),\n ...(queries ?? []),\n ...(search ? [search] : []),\n ],\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: listFiles,\n variables: { bucketId, queries, search },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.storageListFiles\n },\n })\n\n return queryResult\n}\n","import { Keys } from '../query/Keys'\nimport type { AppwriteException, Models } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\n/** The variables accepted by the {@link useCreateFile} hook. */\nexport type CreateFileVariables = {\n bucketId: string\n fileId: string\n file: File\n permissions?: string[]\n onProgress?: (progress: {\n $id: string\n progress: number\n sizeUploaded: number\n chunksTotal: number\n chunksUploaded: number\n }) => void\n}\n\n/** The result returned by the {@link useCreateFile} hook's mutation. */\nexport type CreateFileResult = Models.File\n\n/**\n * Mutation to upload a file to a storage bucket.\n *\n * Uses the Appwrite Storage SDK directly (not GraphQL) to support chunked uploads\n * with progress tracking. Invalidates the file list cache for the target bucket on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useCreateFile()\n *\n * mutate({\n * bucketId: 'avatars',\n * fileId: ID.unique(),\n * file: selectedFile,\n * permissions: ['read(\"any\")'],\n * onProgress: ({ progress }) => console.log(`${progress}%`),\n * })\n * ```\n *\n * **Variables** ({@link CreateFileVariables}):\n * - `bucketId` — The ID of the storage bucket to upload into\n * - `fileId` — A unique ID for the new file (use `ID.unique()` to auto-generate)\n * - `file` — The `File` object to upload\n * - `permissions` — Optional. An array of permission strings for the file\n * - `onProgress` — Optional. Callback invoked with upload progress details\n *\n * @returns A `UseMutationResult` whose `data` is the created {@link CreateFileResult | File} metadata.\n */\nexport function useCreateFile() {\n const { storage } = useAppwrite()\n const queryClient = useQueryClient()\n\n const mutationResult = useMutation<CreateFileResult, AppwriteException[], CreateFileVariables>({\n mutationKey: Keys.buckets().files().create(),\n mutationFn: async ({ bucketId, fileId, file, permissions, onProgress }) => {\n return storage.createFile({\n bucketId,\n fileId,\n file,\n permissions,\n onProgress,\n })\n },\n onSuccess: (_, variables) => {\n void queryClient.invalidateQueries({\n queryKey: Keys.bucket(variables.bucketId).files().key(),\n })\n },\n })\n\n return mutationResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nexport const updateFile = gql(/* GraphQL */ `\n mutation UpdateFile(\n $bucketId: String!\n $fileId: String!\n $name: String\n $permissions: [String!]\n ) {\n storageUpdateFile(\n bucketId: $bucketId\n fileId: $fileId\n name: $name\n permissions: $permissions\n ) {\n _id\n bucketId\n name\n _permissions\n }\n }\n`)\n\n/** The variables accepted by the {@link useUpdateFile} hook. */\nexport type UpdateFileVariables = Prettify<VariablesOf<typeof updateFile>>\n\n/** The result returned by the {@link useUpdateFile} hook. */\nexport type UpdateFileResult = Prettify<ResultOf<typeof updateFile>['storageUpdateFile']>\n\n/**\n * Mutation to update a file's name or permissions in a storage bucket.\n *\n * Sends the `UpdateFile` GraphQL mutation and invalidates the file list cache\n * for the target bucket on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useUpdateFile()\n *\n * mutate({\n * bucketId: 'avatars',\n * fileId: '64a1b2c3d4e5f',\n * name: 'profile-photo.png',\n * permissions: ['read(\"any\")', 'write(\"user:123\")'],\n * })\n * ```\n *\n * **Variables** ({@link UpdateFileVariables}):\n * - `bucketId` — The ID of the storage bucket containing the file\n * - `fileId` — The ID of the file to update\n * - `name` — Optional. The new name for the file\n * - `permissions` — Optional. An updated array of permission strings\n *\n * @returns A `UseMutationResult` whose `data` is the updated {@link UpdateFileResult} with `_id`, `bucketId`, `name`, and `_permissions`.\n */\nexport function useUpdateFile() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const mutationResult = useMutation<UpdateFileResult, AppwriteException[], UpdateFileVariables>({\n mutationKey: Keys.buckets().files().update(),\n mutationFn: async ({ bucketId, fileId, name, permissions }) => {\n const { data, errors } = await graphql.mutation({\n query: updateFile,\n variables: { bucketId, fileId, name, permissions },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.storageUpdateFile\n },\n onSuccess: (_, variables) => {\n void queryClient.invalidateQueries({\n queryKey: Keys.bucket(variables.bucketId).files().key(),\n })\n },\n })\n\n return mutationResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nexport const deleteFile = gql(/* GraphQL */ `\n mutation DeleteFile($bucketId: String!, $fileId: String!) {\n storageDeleteFile(bucketId: $bucketId, fileId: $fileId) {\n status\n }\n }\n`)\n\n/** The variables accepted by the {@link useDeleteFile} hook. */\nexport type DeleteFileVariables = Prettify<VariablesOf<typeof deleteFile>>\n\n/** The result returned by the {@link useDeleteFile} hook. */\nexport type DeleteFileResult = Prettify<ResultOf<typeof deleteFile>['storageDeleteFile']>\n\n/**\n * Mutation to delete a file from a storage bucket.\n *\n * Sends the `DeleteFile` GraphQL mutation. On success, removes the individual file\n * query from the cache and invalidates the file list cache for the target bucket.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useDeleteFile()\n *\n * mutate({\n * bucketId: 'avatars',\n * fileId: '64a1b2c3d4e5f',\n * })\n * ```\n *\n * **Variables** ({@link DeleteFileVariables}):\n * - `bucketId` — The ID of the storage bucket containing the file\n * - `fileId` — The ID of the file to delete\n *\n * @returns A `UseMutationResult` whose `data` is a {@link DeleteFileResult} with a `status` field.\n */\nexport function useDeleteFile() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const mutationResult = useMutation<DeleteFileResult, AppwriteException[], DeleteFileVariables>({\n mutationKey: Keys.buckets().files().delete(),\n mutationFn: async ({ bucketId, fileId }) => {\n const { data, errors } = await graphql.mutation({\n query: deleteFile,\n variables: { bucketId, fileId },\n })\n\n if (errors) {\n throw errors\n }\n\n return data?.storageDeleteFile ?? { status: '' }\n },\n onSuccess: (_, variables) => {\n queryClient.removeQueries({\n queryKey: Keys.bucket(variables.bucketId).file(variables.fileId).key(),\n })\n void queryClient.invalidateQueries({\n queryKey: Keys.bucket(variables.bucketId).files().key(),\n })\n },\n })\n\n return mutationResult\n}\n","import { graphql as gql } from 'gql.tada'\n\nimport type { AppwriteClient } from '../client'\nimport { Keys } from '../query/Keys'\n\nexport const getTeam = gql(/* GraphQL */ `\n query GetTeam($teamId: String!) {\n teamsGet(teamId: $teamId) {\n _id\n _createdAt\n _updatedAt\n name\n total\n prefs {\n data\n }\n }\n }\n`)\n\nexport function teamQueryOptions(client: AppwriteClient, { teamId }: { teamId: string }) {\n return {\n queryKey: Keys.team(teamId).key(),\n queryFn: async () => {\n const { data, errors } = await client.graphql.query({\n query: getTeam,\n variables: { teamId },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.teamsGet\n },\n }\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\n\nimport type { getTeam } from './queryOptions'\nimport { teamQueryOptions } from './queryOptions'\nimport type { AppwriteException, Prettify, QueryOptions } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\n/** The variables accepted by the {@link useTeam} hook. */\nexport type TeamVariables = Prettify<VariablesOf<typeof getTeam>>\n\n/** The result returned by the {@link useTeam} hook. */\nexport type TeamResult = Prettify<ResultOf<typeof getTeam>['teamsGet']>\n\n/**\n * Fetches a team by its unique identifier.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useTeam({\n * teamId: 'engineering',\n * })\n *\n * // data.name, data.total, data._id\n * ```\n *\n * **Parameters** ({@link TeamVariables}):\n * - `teamId` — The unique team identifier.\n *\n * @returns A `UseQueryResult` with the team details ({@link TeamResult}).\n */\nexport function useTeam({ teamId }: TeamVariables, opts: QueryOptions = {}) {\n const client = useAppwrite()\n\n const queryResult = useQuery<TeamResult, AppwriteException[], TeamResult>({\n ...teamQueryOptions(client, { teamId }),\n ...opts,\n })\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify, QueryOptions } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst listTeams = gql(/* GraphQL */ `\n query ListTeams($queries: [String!], $search: String) {\n teamsList(queries: $queries, search: $search) {\n total\n teams {\n _id\n _createdAt\n _updatedAt\n name\n total\n prefs {\n data\n }\n }\n }\n }\n`)\n\n/** The result returned by the {@link useTeams} hook. */\nexport type TeamsResult = Prettify<ResultOf<typeof listTeams>['teamsList']>\n\n/**\n * Fetches a list of teams the current user belongs to.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useTeams()\n *\n * // data.total, data.teams\n * ```\n *\n * **Parameters** *(all optional)*:\n * - `queries` — Appwrite query strings for filtering and pagination.\n * - `search` — A search term to filter teams by name.\n *\n * @returns A `UseQueryResult` with the paginated team list ({@link TeamsResult}).\n */\nexport function useTeams(\n {\n queries,\n search,\n }: {\n queries?: string[]\n search?: string\n } = {},\n opts: QueryOptions = {},\n) {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<TeamsResult, AppwriteException[], TeamsResult>({\n queryKey: [...Keys.teams().key(), ...(queries ?? []), ...(search ? [search] : [])],\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: listTeams,\n variables: { queries, search },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.teamsList\n },\n ...opts,\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify, QueryOptions } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst getTeamPrefs = gql(/* GraphQL */ `\n query GetTeamPrefs($teamId: String!) {\n teamsGetPrefs(teamId: $teamId) {\n data\n }\n }\n`)\n\n/** The variables accepted by the {@link useTeamPrefs} hook. */\nexport type TeamPrefsVariables = Prettify<VariablesOf<typeof getTeamPrefs>>\n\n/** The result returned by the {@link useTeamPrefs} hook. */\nexport type TeamPrefsResult = Prettify<ResultOf<typeof getTeamPrefs>['teamsGetPrefs']>\n\n/**\n * Fetches the preferences for a specific team.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useTeamPrefs({\n * teamId: 'engineering',\n * })\n *\n * // data.data — the team's preference payload\n * ```\n *\n * **Parameters** ({@link TeamPrefsVariables}):\n * - `teamId` — The unique team identifier.\n *\n * @returns A `UseQueryResult` with the team preferences ({@link TeamPrefsResult}).\n */\nexport function useTeamPrefs({ teamId }: TeamPrefsVariables, opts: QueryOptions = {}) {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<TeamPrefsResult, AppwriteException[], TeamPrefsResult>({\n queryKey: Keys.team(teamId).teamPrefs().key(),\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: getTeamPrefs,\n variables: { teamId },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.teamsGetPrefs\n },\n ...opts,\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify, QueryOptions } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst getMembership = gql(/* GraphQL */ `\n query GetMembership($teamId: String!, $membershipId: String!) {\n teamsGetMembership(teamId: $teamId, membershipId: $membershipId) {\n _id\n _createdAt\n _updatedAt\n userId\n userName\n userEmail\n teamId\n teamName\n invited\n joined\n confirm\n mfa\n roles\n }\n }\n`)\n\n/** The variables accepted by the {@link useTeamMembership} hook. */\nexport type TeamMembershipVariables = Prettify<VariablesOf<typeof getMembership>>\n\n/** The result returned by the {@link useTeamMembership} hook. */\nexport type TeamMembershipResult = Prettify<ResultOf<typeof getMembership>['teamsGetMembership']>\n\n/**\n * Fetches a specific team membership by team and membership ID.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useTeamMembership({\n * teamId: 'engineering',\n * membershipId: '7a3f…',\n * })\n *\n * // data.userName, data.userEmail, data.roles\n * ```\n *\n * **Parameters** ({@link TeamMembershipVariables}):\n * - `teamId` — The unique team identifier.\n * - `membershipId` — The unique membership identifier.\n *\n * @returns A `UseQueryResult` with the membership details ({@link TeamMembershipResult}).\n */\nexport function useTeamMembership(\n { teamId, membershipId }: TeamMembershipVariables,\n opts: QueryOptions = {},\n) {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<TeamMembershipResult, AppwriteException[], TeamMembershipResult>({\n queryKey: Keys.team(teamId).membership(membershipId).key(),\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: getMembership,\n variables: { teamId, membershipId },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.teamsGetMembership\n },\n ...opts,\n })\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify, QueryOptions } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst listMemberships = gql(/* GraphQL */ `\n query ListMemberships($teamId: String!, $queries: [String!], $search: String) {\n teamsListMemberships(teamId: $teamId, queries: $queries, search: $search) {\n total\n memberships {\n _id\n _createdAt\n _updatedAt\n userId\n userName\n userEmail\n teamId\n teamName\n invited\n joined\n confirm\n mfa\n roles\n }\n }\n }\n`)\n\n/** The result returned by the {@link useTeamMemberships} hook. */\nexport type TeamMembershipsResult = Prettify<\n ResultOf<typeof listMemberships>['teamsListMemberships']\n>\n\n/**\n * Fetches the list of memberships for a team with optional query filters and search.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useTeamMemberships({\n * teamId: 'engineering',\n * queries: ['limit(25)'],\n * })\n *\n * // data.total, data.memberships\n * ```\n *\n * **Parameters:**\n * - `teamId` — The unique team identifier.\n * - `queries` *(optional)* — Appwrite query strings for filtering and pagination.\n * - `search` *(optional)* — A search term to filter memberships.\n *\n * @returns A `UseQueryResult` with the paginated membership list ({@link TeamMembershipsResult}).\n */\nexport function useTeamMemberships(\n {\n teamId,\n queries,\n search,\n }: {\n teamId: string\n queries?: string[]\n search?: string\n },\n opts: QueryOptions = {},\n) {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<TeamMembershipsResult, AppwriteException[], TeamMembershipsResult>({\n queryKey: [\n ...Keys.team(teamId).memberships().key(),\n ...(queries ?? []),\n ...(search ? [search] : []),\n ],\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: listMemberships,\n variables: { teamId, queries, search },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.teamsListMemberships\n },\n ...opts,\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nexport const createTeam = gql(/* GraphQL */ `\n mutation CreateTeam($teamId: String!, $name: String!, $roles: [String!]) {\n teamsCreate(teamId: $teamId, name: $name, roles: $roles) {\n _id\n name\n total\n }\n }\n`)\n\n/** The variables accepted by the {@link useCreateTeam} hook. */\nexport type CreateTeamVariables = Prettify<VariablesOf<typeof createTeam>>\n\n/** The result returned by the {@link useCreateTeam} hook. */\nexport type CreateTeamResult = Prettify<ResultOf<typeof createTeam>['teamsCreate']>\n\n/**\n * Mutation to create a new team.\n *\n * Sends the `CreateTeam` GraphQL mutation and invalidates the team list cache on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useCreateTeam()\n *\n * mutate({\n * teamId: ID.unique(),\n * name: 'Engineering',\n * roles: ['owner', 'developer'],\n * })\n * ```\n *\n * **Variables** ({@link CreateTeamVariables}):\n * - `teamId` — A unique ID for the new team (use `ID.unique()` to auto-generate)\n * - `name` — The display name of the team\n * - `roles` — Optional. An array of roles assigned to the team creator\n *\n * @returns A `UseMutationResult` whose `data` is the created {@link CreateTeamResult} with `_id`, `name`, and `total`.\n */\nexport function useCreateTeam() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const mutationResult = useMutation<CreateTeamResult, AppwriteException[], CreateTeamVariables>({\n mutationKey: Keys.teams().create(),\n mutationFn: async ({ teamId, name, roles }) => {\n const { data, errors } = await graphql.mutation({\n query: createTeam,\n variables: { teamId, name, roles },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.teamsCreate\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: Keys.teams().key() })\n },\n })\n\n return mutationResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nexport const updateTeamName = gql(/* GraphQL */ `\n mutation UpdateTeamName($teamId: String!, $name: String!) {\n teamsUpdateName(teamId: $teamId, name: $name) {\n _id\n name\n }\n }\n`)\n\n/** The variables accepted by the {@link useUpdateTeamName} hook. */\nexport type UpdateTeamNameVariables = Prettify<VariablesOf<typeof updateTeamName>>\n\n/** The result returned by the {@link useUpdateTeamName} hook. */\nexport type UpdateTeamNameResult = Prettify<ResultOf<typeof updateTeamName>['teamsUpdateName']>\n\n/**\n * Mutation to update a team's name.\n *\n * Sends the `UpdateTeamName` GraphQL mutation. On success, invalidates both the\n * individual team cache and the team list cache.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useUpdateTeamName()\n *\n * mutate({\n * teamId: '64a1b2c3d4e5f',\n * name: 'Platform Engineering',\n * })\n * ```\n *\n * **Variables** ({@link UpdateTeamNameVariables}):\n * - `teamId` — The ID of the team to rename\n * - `name` — The new display name for the team\n *\n * @returns A `UseMutationResult` whose `data` is the updated {@link UpdateTeamNameResult} with `_id` and `name`.\n */\nexport function useUpdateTeamName() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const mutationResult = useMutation<\n UpdateTeamNameResult,\n AppwriteException[],\n UpdateTeamNameVariables\n >({\n mutationKey: Keys.teams().teamName().update(),\n mutationFn: async ({ teamId, name }) => {\n const { data, errors } = await graphql.mutation({\n query: updateTeamName,\n variables: { teamId, name },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.teamsUpdateName\n },\n onSuccess: (_, variables) => {\n void queryClient.invalidateQueries({\n queryKey: Keys.team(variables.teamId).key(),\n })\n void queryClient.invalidateQueries({ queryKey: Keys.teams().key() })\n },\n })\n\n return mutationResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nexport const updateTeamPrefs = gql(/* GraphQL */ `\n mutation UpdateTeamPrefs($teamId: String!, $prefs: Assoc!) {\n teamsUpdatePrefs(teamId: $teamId, prefs: $prefs) {\n data\n }\n }\n`)\n\n/** The variables accepted by the {@link useUpdateTeamPrefs} hook. */\nexport type UpdateTeamPrefsVariables = Prettify<VariablesOf<typeof updateTeamPrefs>>\n\n/** The result returned by the {@link useUpdateTeamPrefs} hook. */\nexport type UpdateTeamPrefsResult = Prettify<ResultOf<typeof updateTeamPrefs>['teamsUpdatePrefs']>\n\n/**\n * Mutation to update a team's preferences.\n *\n * Sends the `UpdateTeamPrefs` GraphQL mutation with an arbitrary key-value object.\n * Invalidates the individual team cache on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useUpdateTeamPrefs()\n *\n * mutate({\n * teamId: '64a1b2c3d4e5f',\n * prefs: { theme: 'dark', notificationsEnabled: true },\n * })\n * ```\n *\n * **Variables** ({@link UpdateTeamPrefsVariables}):\n * - `teamId` — The ID of the team whose preferences to update\n * - `prefs` — An associative object of key-value preferences to set\n *\n * @returns A `UseMutationResult` whose `data` is the updated {@link UpdateTeamPrefsResult} containing a `data` field with the new preferences.\n */\nexport function useUpdateTeamPrefs() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const mutationResult = useMutation<\n UpdateTeamPrefsResult,\n AppwriteException[],\n UpdateTeamPrefsVariables\n >({\n mutationKey: Keys.teams().teamPrefs().update(),\n mutationFn: async ({ teamId, prefs }) => {\n const { data, errors } = await graphql.mutation({\n query: updateTeamPrefs,\n variables: { teamId, prefs },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.teamsUpdatePrefs\n },\n onSuccess: (_, variables) => {\n void queryClient.invalidateQueries({\n queryKey: Keys.team(variables.teamId).key(),\n })\n },\n })\n\n return mutationResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nexport const deleteTeam = gql(/* GraphQL */ `\n mutation DeleteTeam($teamId: String!) {\n teamsDelete(teamId: $teamId) {\n status\n }\n }\n`)\n\n/** The variables accepted by the {@link useDeleteTeam} hook. */\nexport type DeleteTeamVariables = Prettify<VariablesOf<typeof deleteTeam>>\n\n/** The result returned by the {@link useDeleteTeam} hook. */\nexport type DeleteTeamResult = Prettify<ResultOf<typeof deleteTeam>['teamsDelete']>\n\n/**\n * Mutation to delete a team by its ID.\n *\n * Sends the `DeleteTeam` GraphQL mutation. On success, removes the individual team\n * query from the cache and invalidates the team list cache.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useDeleteTeam()\n *\n * mutate({ teamId: '64a1b2c3d4e5f' })\n * ```\n *\n * **Variables** ({@link DeleteTeamVariables}):\n * - `teamId` — The ID of the team to delete\n *\n * @returns A `UseMutationResult` whose `data` is a {@link DeleteTeamResult} with a `status` field.\n */\nexport function useDeleteTeam() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const mutationResult = useMutation<DeleteTeamResult, AppwriteException[], DeleteTeamVariables>({\n mutationKey: Keys.teams().delete(),\n mutationFn: async ({ teamId }) => {\n const { data, errors } = await graphql.mutation({\n query: deleteTeam,\n variables: { teamId },\n })\n\n if (errors) {\n throw errors\n }\n\n return data?.teamsDelete ?? { status: '' }\n },\n onSuccess: (_, variables) => {\n queryClient.removeQueries({\n queryKey: Keys.team(variables.teamId).key(),\n })\n void queryClient.invalidateQueries({ queryKey: Keys.teams().key() })\n },\n })\n\n return mutationResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nexport const createMembership = gql(/* GraphQL */ `\n mutation CreateMembership(\n $teamId: String!\n $roles: [String!]!\n $email: String\n $userId: String\n $phone: String\n $url: String\n $name: String\n ) {\n teamsCreateMembership(\n teamId: $teamId\n roles: $roles\n email: $email\n userId: $userId\n phone: $phone\n url: $url\n name: $name\n ) {\n _id\n userId\n teamId\n roles\n confirm\n }\n }\n`)\n\n/** The variables accepted by the {@link useCreateMembership} hook. */\nexport type CreateMembershipVariables = Prettify<VariablesOf<typeof createMembership>>\n\n/** The result returned by the {@link useCreateMembership} hook. */\nexport type CreateMembershipResult = Prettify<\n ResultOf<typeof createMembership>['teamsCreateMembership']\n>\n\n/**\n * Mutation to invite a user to a team.\n *\n * Sends the `CreateMembership` GraphQL mutation. At least one of `email`, `userId`,\n * or `phone` must be provided to identify the invitee. On success, invalidates both\n * the membership list and the individual team cache.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useCreateMembership()\n *\n * mutate({\n * teamId: '64a1b2c3d4e5f',\n * roles: ['developer'],\n * email: 'alice@example.com',\n * url: 'https://myapp.com/accept-invite',\n * name: 'Alice',\n * })\n * ```\n *\n * **Variables** ({@link CreateMembershipVariables}):\n * - `teamId` — The ID of the team to invite the user to\n * - `roles` — An array of roles to assign to the new member\n * - `email` — Optional. The invitee's email address\n * - `userId` — Optional. The invitee's user ID\n * - `phone` — Optional. The invitee's phone number\n * - `url` — Optional. A URL the invitee is redirected to for accepting the invitation\n * - `name` — Optional. The invitee's display name\n *\n * @returns A `UseMutationResult` whose `data` is the created {@link CreateMembershipResult} with `_id`, `userId`, `teamId`, `roles`, and `confirm`.\n */\nexport function useCreateMembership() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const mutationResult = useMutation<\n CreateMembershipResult,\n AppwriteException[],\n CreateMembershipVariables\n >({\n mutationKey: Keys.teams().memberships().create(),\n mutationFn: async ({ teamId, roles, email, userId, phone, url, name }) => {\n const { data, errors } = await graphql.mutation({\n query: createMembership,\n variables: { teamId, roles, email, userId, phone, url, name },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.teamsCreateMembership\n },\n onSuccess: (_, variables) => {\n void queryClient.invalidateQueries({\n queryKey: Keys.team(variables.teamId).memberships().key(),\n })\n void queryClient.invalidateQueries({\n queryKey: Keys.team(variables.teamId).key(),\n })\n },\n })\n\n return mutationResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nexport const updateMembership = gql(/* GraphQL */ `\n mutation UpdateMembership($teamId: String!, $membershipId: String!, $roles: [String!]!) {\n teamsUpdateMembership(teamId: $teamId, membershipId: $membershipId, roles: $roles) {\n _id\n roles\n }\n }\n`)\n\n/** The variables accepted by the {@link useUpdateMembership} hook. */\nexport type UpdateMembershipVariables = Prettify<VariablesOf<typeof updateMembership>>\n\n/** The result returned by the {@link useUpdateMembership} hook. */\nexport type UpdateMembershipResult = Prettify<\n ResultOf<typeof updateMembership>['teamsUpdateMembership']\n>\n\n/**\n * Mutation to update a team membership's roles.\n *\n * Sends the `UpdateMembership` GraphQL mutation and invalidates the membership list\n * cache for the team on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useUpdateMembership()\n *\n * mutate({\n * teamId: '64a1b2c3d4e5f',\n * membershipId: '71b2c3d4e5f6a',\n * roles: ['admin', 'developer'],\n * })\n * ```\n *\n * **Variables** ({@link UpdateMembershipVariables}):\n * - `teamId` — The ID of the team containing the membership\n * - `membershipId` — The ID of the membership to update\n * - `roles` — The new array of roles to assign to the member\n *\n * @returns A `UseMutationResult` whose `data` is the updated {@link UpdateMembershipResult} with `_id` and `roles`.\n */\nexport function useUpdateMembership() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const mutationResult = useMutation<\n UpdateMembershipResult,\n AppwriteException[],\n UpdateMembershipVariables\n >({\n mutationKey: Keys.teams().memberships().update(),\n mutationFn: async ({ teamId, membershipId, roles }) => {\n const { data, errors } = await graphql.mutation({\n query: updateMembership,\n variables: { teamId, membershipId, roles },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.teamsUpdateMembership\n },\n onSuccess: (_, variables) => {\n void queryClient.invalidateQueries({\n queryKey: Keys.team(variables.teamId).memberships().key(),\n })\n },\n })\n\n return mutationResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst updateMembershipStatus = gql(/* GraphQL */ `\n mutation UpdateMembershipStatus(\n $teamId: String!\n $membershipId: String!\n $userId: String!\n $secret: String!\n ) {\n teamsUpdateMembershipStatus(\n teamId: $teamId\n membershipId: $membershipId\n userId: $userId\n secret: $secret\n ) {\n _id\n confirm\n }\n }\n`)\n\n/** The variables accepted by the {@link useUpdateMembershipStatus} hook. */\nexport type UpdateMembershipStatusVariables = Prettify<VariablesOf<typeof updateMembershipStatus>>\n\n/** The result returned by the {@link useUpdateMembershipStatus} hook. */\nexport type UpdateMembershipStatusResult = Prettify<\n ResultOf<typeof updateMembershipStatus>['teamsUpdateMembershipStatus']\n>\n\n/**\n * Mutation to accept a team invitation.\n *\n * Sends the `UpdateMembershipStatus` GraphQL mutation using the invitation secret.\n * Typically called after a user clicks an invitation link. Invalidates the membership\n * list cache for the team on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useUpdateMembershipStatus()\n *\n * // Values are typically extracted from the invitation URL\n * mutate({\n * teamId: '64a1b2c3d4e5f',\n * membershipId: '71b2c3d4e5f6a',\n * userId: 'user_123',\n * secret: 'invite-secret-token',\n * })\n * ```\n *\n * **Variables** ({@link UpdateMembershipStatusVariables}):\n * - `teamId` — The ID of the team the user is joining\n * - `membershipId` — The ID of the membership invitation\n * - `userId` — The ID of the user accepting the invitation\n * - `secret` — The invitation secret from the invite URL\n *\n * @returns A `UseMutationResult` whose `data` is the updated {@link UpdateMembershipStatusResult} with `_id` and `confirm`.\n */\nexport function useUpdateMembershipStatus() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const mutationResult = useMutation<\n UpdateMembershipStatusResult,\n AppwriteException[],\n UpdateMembershipStatusVariables\n >({\n mutationKey: Keys.teams().membershipStatus().update(),\n mutationFn: async ({ teamId, membershipId, userId, secret }) => {\n const { data, errors } = await graphql.mutation({\n query: updateMembershipStatus,\n variables: { teamId, membershipId, userId, secret },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.teamsUpdateMembershipStatus\n },\n onSuccess: (_, variables) => {\n void queryClient.invalidateQueries({\n queryKey: Keys.team(variables.teamId).memberships().key(),\n })\n },\n })\n\n return mutationResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nexport const deleteMembership = gql(/* GraphQL */ `\n mutation DeleteMembership($teamId: String!, $membershipId: String!) {\n teamsDeleteMembership(teamId: $teamId, membershipId: $membershipId) {\n status\n }\n }\n`)\n\n/** The variables accepted by the {@link useDeleteMembership} hook. */\nexport type DeleteMembershipVariables = Prettify<VariablesOf<typeof deleteMembership>>\n\n/** The result returned by the {@link useDeleteMembership} hook. */\nexport type DeleteMembershipResult = Prettify<\n ResultOf<typeof deleteMembership>['teamsDeleteMembership']\n>\n\n/**\n * Mutation to remove a member from a team.\n *\n * Sends the `DeleteMembership` GraphQL mutation. On success, removes the individual\n * membership query from the cache and invalidates both the membership list and the\n * individual team cache.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useDeleteMembership()\n *\n * mutate({\n * teamId: '64a1b2c3d4e5f',\n * membershipId: '71b2c3d4e5f6a',\n * })\n * ```\n *\n * **Variables** ({@link DeleteMembershipVariables}):\n * - `teamId` — The ID of the team containing the membership\n * - `membershipId` — The ID of the membership to remove\n *\n * @returns A `UseMutationResult` whose `data` is a {@link DeleteMembershipResult} with a `status` field.\n */\nexport function useDeleteMembership() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const mutationResult = useMutation<\n DeleteMembershipResult,\n AppwriteException[],\n DeleteMembershipVariables\n >({\n mutationKey: Keys.teams().memberships().delete(),\n mutationFn: async ({ teamId, membershipId }) => {\n const { data, errors } = await graphql.mutation({\n query: deleteMembership,\n variables: { teamId, membershipId },\n })\n\n if (errors) {\n throw errors\n }\n\n return data?.teamsDeleteMembership ?? { status: '' }\n },\n onSuccess: (_, variables) => {\n queryClient.removeQueries({\n queryKey: Keys.team(variables.teamId).membership(variables.membershipId).key(),\n })\n void queryClient.invalidateQueries({\n queryKey: Keys.team(variables.teamId).memberships().key(),\n })\n void queryClient.invalidateQueries({\n queryKey: Keys.team(variables.teamId).key(),\n })\n },\n })\n\n return mutationResult\n}\n","import type { QueryTypes } from 'appwrite'\nimport { Query } from 'appwrite'\n\ntype FieldValue<T, K extends keyof T> = T[K]\n\ntype ArrayElement<T> = T extends (infer E)[] ? E : never\n\ntype ContainsValue<T, K extends keyof T> = T[K] extends unknown[]\n ? ArrayElement<T[K]> | ArrayElement<T[K]>[]\n : T[K] extends string\n ? string\n : T[K] | T[K][]\n\n/**\n * Type-safe query builder for constructing Appwrite queries.\n * Provides a fluent API with autocompletion for your document fields.\n */\nexport class QueryBuilder<T extends Record<string, unknown>> {\n private queries: string[] = []\n\n equal<K extends keyof T & string>(field: K, value: FieldValue<T, K> | FieldValue<T, K>[]): this {\n this.queries.push(Query.equal(field, value as QueryTypes))\n return this\n }\n\n notEqual<K extends keyof T & string>(\n field: K,\n value: FieldValue<T, K> | FieldValue<T, K>[],\n ): this {\n this.queries.push(Query.notEqual(field, value as QueryTypes))\n return this\n }\n\n regex<K extends keyof T & string>(field: K, pattern: string): this {\n this.queries.push(Query.regex(field, pattern))\n return this\n }\n\n lessThan<K extends keyof T & string>(field: K, value: FieldValue<T, K>): this {\n this.queries.push(Query.lessThan(field, value as QueryTypes))\n return this\n }\n\n lessThanEqual<K extends keyof T & string>(field: K, value: FieldValue<T, K>): this {\n this.queries.push(Query.lessThanEqual(field, value as QueryTypes))\n return this\n }\n\n greaterThan<K extends keyof T & string>(field: K, value: FieldValue<T, K>): this {\n this.queries.push(Query.greaterThan(field, value as QueryTypes))\n return this\n }\n\n greaterThanEqual<K extends keyof T & string>(field: K, value: FieldValue<T, K>): this {\n this.queries.push(Query.greaterThanEqual(field, value as QueryTypes))\n return this\n }\n\n isNull<K extends keyof T & string>(field: K): this {\n this.queries.push(Query.isNull(field))\n return this\n }\n\n isNotNull<K extends keyof T & string>(field: K): this {\n this.queries.push(Query.isNotNull(field))\n return this\n }\n\n exists<K extends keyof T & string>(fields: K[]): this {\n this.queries.push(Query.exists(fields))\n return this\n }\n\n notExists<K extends keyof T & string>(fields: K[]): this {\n this.queries.push(Query.notExists(fields))\n return this\n }\n\n between<K extends keyof T & string>(\n field: K,\n start: string | number | bigint,\n end: string | number | bigint,\n ): this {\n this.queries.push(Query.between(field, start, end))\n return this\n }\n\n startsWith<K extends keyof T & string>(field: K, prefix: string): this {\n this.queries.push(Query.startsWith(field, prefix))\n return this\n }\n\n endsWith<K extends keyof T & string>(field: K, suffix: string): this {\n this.queries.push(Query.endsWith(field, suffix))\n return this\n }\n\n select<K extends keyof T & string>(fields: K[]): this {\n this.queries.push(Query.select(fields))\n return this\n }\n\n search<K extends keyof T & string>(field: K, term: string): this {\n this.queries.push(Query.search(field, term))\n return this\n }\n\n orderAsc<K extends keyof T & string>(field: K): this {\n this.queries.push(Query.orderAsc(field))\n return this\n }\n\n orderDesc<K extends keyof T & string>(field: K): this {\n this.queries.push(Query.orderDesc(field))\n return this\n }\n\n orderRandom(): this {\n this.queries.push(Query.orderRandom())\n return this\n }\n\n cursorAfter(id: string): this {\n this.queries.push(Query.cursorAfter(id))\n return this\n }\n\n cursorBefore(id: string): this {\n this.queries.push(Query.cursorBefore(id))\n return this\n }\n\n limit(count: number): this {\n this.queries.push(Query.limit(count))\n return this\n }\n\n offset(count: number): this {\n this.queries.push(Query.offset(count))\n return this\n }\n\n contains<K extends keyof T & string>(field: K, value: ContainsValue<T, K>): this {\n this.queries.push(Query.contains(field, value as string | any[]))\n return this\n }\n\n containsAny<K extends keyof T & string>(field: K, values: ContainsValue<T, K>[]): this {\n this.queries.push(Query.containsAny(field, values as any[]))\n return this\n }\n\n containsAll<K extends keyof T & string>(field: K, values: ContainsValue<T, K>[]): this {\n this.queries.push(Query.containsAll(field, values as any[]))\n return this\n }\n\n notContains<K extends keyof T & string>(field: K, value: ContainsValue<T, K>): this {\n this.queries.push(Query.notContains(field, value as string | any[]))\n return this\n }\n\n notSearch<K extends keyof T & string>(field: K, term: string): this {\n this.queries.push(Query.notSearch(field, term))\n return this\n }\n\n notBetween<K extends keyof T & string>(\n field: K,\n start: string | number | bigint,\n end: string | number | bigint,\n ): this {\n this.queries.push(Query.notBetween(field, start, end))\n return this\n }\n\n notStartsWith<K extends keyof T & string>(field: K, prefix: string): this {\n this.queries.push(Query.notStartsWith(field, prefix))\n return this\n }\n\n notEndsWith<K extends keyof T & string>(field: K, suffix: string): this {\n this.queries.push(Query.notEndsWith(field, suffix))\n return this\n }\n\n createdBefore(date: string): this {\n this.queries.push(Query.createdBefore(date))\n return this\n }\n\n createdAfter(date: string): this {\n this.queries.push(Query.createdAfter(date))\n return this\n }\n\n createdBetween(start: string, end: string): this {\n this.queries.push(Query.createdBetween(start, end))\n return this\n }\n\n updatedBefore(date: string): this {\n this.queries.push(Query.updatedBefore(date))\n return this\n }\n\n updatedAfter(date: string): this {\n this.queries.push(Query.updatedAfter(date))\n return this\n }\n\n updatedBetween(start: string, end: string): this {\n this.queries.push(Query.updatedBetween(start, end))\n return this\n }\n\n or(...queries: ((q: QueryBuilder<T>) => QueryBuilder<T>)[]): this {\n const orQueries = queries.map((fn) => fn(new QueryBuilder<T>()).queries).flat()\n this.queries.push(Query.or(orQueries))\n return this\n }\n\n and(...queries: ((q: QueryBuilder<T>) => QueryBuilder<T>)[]): this {\n const andQueries = queries.map((fn) => fn(new QueryBuilder<T>()).queries).flat()\n this.queries.push(Query.and(andQueries))\n return this\n }\n\n elemMatch<K extends keyof T & string>(field: K, query: QueryBuilder<T>): this {\n this.queries.push(Query.elemMatch(field, query.queries))\n return this\n }\n\n distanceEqual<K extends keyof T & string>(\n field: K,\n latitude: number,\n longitude: number,\n distance: number,\n meters: boolean = true,\n ): this {\n this.queries.push(Query.distanceEqual(field, [latitude, longitude], distance, meters))\n return this\n }\n\n distanceNotEqual<K extends keyof T & string>(\n field: K,\n latitude: number,\n longitude: number,\n distance: number,\n meters: boolean = true,\n ): this {\n this.queries.push(Query.distanceNotEqual(field, [latitude, longitude], distance, meters))\n return this\n }\n\n distanceGreaterThan<K extends keyof T & string>(\n field: K,\n latitude: number,\n longitude: number,\n distance: number,\n meters: boolean = true,\n ): this {\n this.queries.push(Query.distanceGreaterThan(field, [latitude, longitude], distance, meters))\n return this\n }\n\n distanceLessThan<K extends keyof T & string>(\n field: K,\n latitude: number,\n longitude: number,\n distance: number,\n meters: boolean = true,\n ): this {\n this.queries.push(Query.distanceLessThan(field, [latitude, longitude], distance, meters))\n return this\n }\n\n intersects<K extends keyof T & string>(field: K, points: [number, number][]): this {\n this.queries.push(Query.intersects(field, points))\n return this\n }\n\n notIntersects<K extends keyof T & string>(field: K, points: [number, number][]): this {\n this.queries.push(Query.notIntersects(field, points))\n return this\n }\n\n crosses<K extends keyof T & string>(field: K, points: [number, number][]): this {\n this.queries.push(Query.crosses(field, points))\n return this\n }\n\n notCrosses<K extends keyof T & string>(field: K, points: [number, number][]): this {\n this.queries.push(Query.notCrosses(field, points))\n return this\n }\n\n overlaps<K extends keyof T & string>(field: K, points: [number, number][]): this {\n this.queries.push(Query.overlaps(field, points))\n return this\n }\n\n notOverlaps<K extends keyof T & string>(field: K, points: [number, number][]): this {\n this.queries.push(Query.notOverlaps(field, points))\n return this\n }\n\n touches<K extends keyof T & string>(field: K, points: [number, number][]): this {\n this.queries.push(Query.touches(field, points))\n return this\n }\n\n notTouches<K extends keyof T & string>(field: K, points: [number, number][]): this {\n this.queries.push(Query.notTouches(field, points))\n return this\n }\n\n build() {\n return [...this.queries]\n }\n}\n\n/**\n * Creates a new type-safe {@link QueryBuilder} instance.\n *\n * @example\n * ```ts\n * const queries = q<MyDocument>()\n * .equal('status', 'active')\n * .greaterThan('age', 18)\n * .build()\n * ```\n */\nexport function q<T extends Record<string, unknown>>(): QueryBuilder<T> {\n return new QueryBuilder<T>()\n}\n","import { timeoutManager } from './timeoutManager'\nimport type {\n DefaultError,\n Enabled,\n FetchStatus,\n MutationKey,\n MutationStatus,\n QueryFunction,\n QueryKey,\n QueryOptions,\n StaleTime,\n StaleTimeFunction,\n} from './types'\nimport type { Mutation } from './mutation'\nimport type { FetchOptions, Query } from './query'\n\n// TYPES\n\ntype DropLast<T extends ReadonlyArray<unknown>> = T extends readonly [\n ...infer R,\n unknown,\n]\n ? readonly [...R]\n : never\n\ntype TuplePrefixes<T extends ReadonlyArray<unknown>> = T extends readonly []\n ? readonly []\n : TuplePrefixes<DropLast<T>> | T\n\nexport interface QueryFilters<TQueryKey extends QueryKey = QueryKey> {\n /**\n * Filter to active queries, inactive queries or all queries\n */\n type?: QueryTypeFilter\n /**\n * Match query key exactly\n */\n exact?: boolean\n /**\n * Include queries matching this predicate function\n */\n predicate?: (query: Query) => boolean\n /**\n * Include queries matching this query key\n */\n queryKey?: TQueryKey | TuplePrefixes<TQueryKey>\n /**\n * Include or exclude stale queries\n */\n stale?: boolean\n /**\n * Include queries matching their fetchStatus\n */\n fetchStatus?: FetchStatus\n}\n\nexport interface MutationFilters<\n TData = unknown,\n TError = DefaultError,\n TVariables = unknown,\n TOnMutateResult = unknown,\n> {\n /**\n * Match mutation key exactly\n */\n exact?: boolean\n /**\n * Include mutations matching this predicate function\n */\n predicate?: (\n mutation: Mutation<TData, TError, TVariables, TOnMutateResult>,\n ) => boolean\n /**\n * Include mutations matching this mutation key\n */\n mutationKey?: TuplePrefixes<MutationKey>\n /**\n * Filter by mutation status\n */\n status?: MutationStatus\n}\n\nexport type Updater<TInput, TOutput> = TOutput | ((input: TInput) => TOutput)\n\nexport type QueryTypeFilter = 'all' | 'active' | 'inactive'\n\n// UTILS\n\n/** @deprecated\n * use `environmentManager.isServer()` instead.\n */\nexport const isServer = typeof window === 'undefined' || 'Deno' in globalThis\n\nexport function noop(): void\nexport function noop(): undefined\nexport function noop() {}\n\nexport function functionalUpdate<TInput, TOutput>(\n updater: Updater<TInput, TOutput>,\n input: TInput,\n): TOutput {\n return typeof updater === 'function'\n ? (updater as (_: TInput) => TOutput)(input)\n : updater\n}\n\nexport function isValidTimeout(value: unknown): value is number {\n return typeof value === 'number' && value >= 0 && value !== Infinity\n}\n\nexport function timeUntilStale(updatedAt: number, staleTime?: number): number {\n return Math.max(updatedAt + (staleTime || 0) - Date.now(), 0)\n}\n\nexport function resolveStaleTime<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n staleTime:\n | undefined\n | StaleTimeFunction<TQueryFnData, TError, TData, TQueryKey>,\n query: Query<TQueryFnData, TError, TData, TQueryKey>,\n): StaleTime | undefined {\n return typeof staleTime === 'function' ? staleTime(query) : staleTime\n}\n\nexport function resolveEnabled<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n enabled: undefined | Enabled<TQueryFnData, TError, TData, TQueryKey>,\n query: Query<TQueryFnData, TError, TData, TQueryKey>,\n): boolean | undefined {\n return typeof enabled === 'function' ? enabled(query) : enabled\n}\n\nexport function matchQuery(\n filters: QueryFilters,\n query: Query<any, any, any, any>,\n): boolean {\n const {\n type = 'all',\n exact,\n fetchStatus,\n predicate,\n queryKey,\n stale,\n } = filters\n\n if (queryKey) {\n if (exact) {\n if (query.queryHash !== hashQueryKeyByOptions(queryKey, query.options)) {\n return false\n }\n } else if (!partialMatchKey(query.queryKey, queryKey)) {\n return false\n }\n }\n\n if (type !== 'all') {\n const isActive = query.isActive()\n if (type === 'active' && !isActive) {\n return false\n }\n if (type === 'inactive' && isActive) {\n return false\n }\n }\n\n if (typeof stale === 'boolean' && query.isStale() !== stale) {\n return false\n }\n\n if (fetchStatus && fetchStatus !== query.state.fetchStatus) {\n return false\n }\n\n if (predicate && !predicate(query)) {\n return false\n }\n\n return true\n}\n\nexport function matchMutation(\n filters: MutationFilters,\n mutation: Mutation<any, any>,\n): boolean {\n const { exact, status, predicate, mutationKey } = filters\n if (mutationKey) {\n if (!mutation.options.mutationKey) {\n return false\n }\n if (exact) {\n if (hashKey(mutation.options.mutationKey) !== hashKey(mutationKey)) {\n return false\n }\n } else if (!partialMatchKey(mutation.options.mutationKey, mutationKey)) {\n return false\n }\n }\n\n if (status && mutation.state.status !== status) {\n return false\n }\n\n if (predicate && !predicate(mutation)) {\n return false\n }\n\n return true\n}\n\nexport function hashQueryKeyByOptions<TQueryKey extends QueryKey = QueryKey>(\n queryKey: TQueryKey,\n options?: Pick<QueryOptions<any, any, any, any>, 'queryKeyHashFn'>,\n): string {\n const hashFn = options?.queryKeyHashFn || hashKey\n return hashFn(queryKey)\n}\n\n/**\n * Default query & mutation keys hash function.\n * Hashes the value into a stable hash.\n */\nexport function hashKey(queryKey: QueryKey | MutationKey): string {\n return JSON.stringify(queryKey, (_, val) =>\n isPlainObject(val)\n ? Object.keys(val)\n .sort()\n .reduce((result, key) => {\n result[key] = val[key]\n return result\n }, {} as any)\n : val,\n )\n}\n\n/**\n * Checks if key `b` partially matches with key `a`.\n */\nexport function partialMatchKey(a: QueryKey, b: QueryKey): boolean\nexport function partialMatchKey(a: any, b: any): boolean {\n if (a === b) {\n return true\n }\n\n if (typeof a !== typeof b) {\n return false\n }\n\n if (a && b && typeof a === 'object' && typeof b === 'object') {\n return Object.keys(b).every((key) => partialMatchKey(a[key], b[key]))\n }\n\n return false\n}\n\nconst hasOwn = Object.prototype.hasOwnProperty\n\n/**\n * This function returns `a` if `b` is deeply equal.\n * If not, it will replace any deeply equal children of `b` with those of `a`.\n * This can be used for structural sharing between JSON values for example.\n */\nexport function replaceEqualDeep<T>(a: unknown, b: T, depth?: number): T\nexport function replaceEqualDeep(a: any, b: any, depth = 0): any {\n if (a === b) {\n return a\n }\n\n if (depth > 500) return b\n\n const array = isPlainArray(a) && isPlainArray(b)\n\n if (!array && !(isPlainObject(a) && isPlainObject(b))) return b\n\n const aItems = array ? a : Object.keys(a)\n const aSize = aItems.length\n const bItems = array ? b : Object.keys(b)\n const bSize = bItems.length\n const copy: any = array ? new Array(bSize) : {}\n\n let equalItems = 0\n\n for (let i = 0; i < bSize; i++) {\n const key: any = array ? i : bItems[i]\n const aItem = a[key]\n const bItem = b[key]\n\n if (aItem === bItem) {\n copy[key] = aItem\n if (array ? i < aSize : hasOwn.call(a, key)) equalItems++\n continue\n }\n\n if (\n aItem === null ||\n bItem === null ||\n typeof aItem !== 'object' ||\n typeof bItem !== 'object'\n ) {\n copy[key] = bItem\n continue\n }\n\n const v = replaceEqualDeep(aItem, bItem, depth + 1)\n copy[key] = v\n if (v === aItem) equalItems++\n }\n\n return aSize === bSize && equalItems === aSize ? a : copy\n}\n\n/**\n * Shallow compare objects.\n */\nexport function shallowEqualObjects<T extends Record<string, any>>(\n a: T,\n b: T | undefined,\n): boolean {\n if (!b || Object.keys(a).length !== Object.keys(b).length) {\n return false\n }\n\n for (const key in a) {\n if (a[key] !== b[key]) {\n return false\n }\n }\n\n return true\n}\n\nexport function isPlainArray(value: unknown): value is Array<unknown> {\n return Array.isArray(value) && value.length === Object.keys(value).length\n}\n\n// Copied from: https://github.com/jonschlinkert/is-plain-object\nexport function isPlainObject(o: any): o is Record<PropertyKey, unknown> {\n if (!hasObjectPrototype(o)) {\n return false\n }\n\n // If has no constructor\n const ctor = o.constructor\n if (ctor === undefined) {\n return true\n }\n\n // If has modified prototype\n const prot = ctor.prototype\n if (!hasObjectPrototype(prot)) {\n return false\n }\n\n // If constructor does not have an Object-specific method\n if (!prot.hasOwnProperty('isPrototypeOf')) {\n return false\n }\n\n // Handles Objects created by Object.create(<arbitrary prototype>)\n if (Object.getPrototypeOf(o) !== Object.prototype) {\n return false\n }\n\n // Most likely a plain Object\n return true\n}\n\nfunction hasObjectPrototype(o: any): boolean {\n return Object.prototype.toString.call(o) === '[object Object]'\n}\n\nexport function sleep(timeout: number): Promise<void> {\n return new Promise((resolve) => {\n timeoutManager.setTimeout(resolve, timeout)\n })\n}\n\nexport function replaceData<\n TData,\n TOptions extends QueryOptions<any, any, any, any>,\n>(prevData: TData | undefined, data: TData, options: TOptions): TData {\n if (typeof options.structuralSharing === 'function') {\n return options.structuralSharing(prevData, data) as TData\n } else if (options.structuralSharing !== false) {\n if (process.env.NODE_ENV !== 'production') {\n try {\n return replaceEqualDeep(prevData, data)\n } catch (error) {\n console.error(\n `Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${options.queryHash}]: ${error}`,\n )\n\n // Prevent the replaceEqualDeep from being called again down below.\n throw error\n }\n }\n // Structurally share data between prev and new data if needed\n return replaceEqualDeep(prevData, data)\n }\n return data\n}\n\nexport function keepPreviousData<T>(\n previousData: T | undefined,\n): T | undefined {\n return previousData\n}\n\nexport function addToEnd<T>(items: Array<T>, item: T, max = 0): Array<T> {\n const newItems = [...items, item]\n return max && newItems.length > max ? newItems.slice(1) : newItems\n}\n\nexport function addToStart<T>(items: Array<T>, item: T, max = 0): Array<T> {\n const newItems = [item, ...items]\n return max && newItems.length > max ? newItems.slice(0, -1) : newItems\n}\n\nexport const skipToken = Symbol()\nexport type SkipToken = typeof skipToken\n\nexport function ensureQueryFn<\n TQueryFnData = unknown,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: {\n queryFn?: QueryFunction<TQueryFnData, TQueryKey> | SkipToken\n queryHash?: string\n },\n fetchOptions?: FetchOptions<TQueryFnData>,\n): QueryFunction<TQueryFnData, TQueryKey> {\n if (process.env.NODE_ENV !== 'production') {\n if (options.queryFn === skipToken) {\n console.error(\n `Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${options.queryHash}'`,\n )\n }\n }\n\n // if we attempt to retry a fetch that was triggered from an initialPromise\n // when we don't have a queryFn yet, we can't retry, so we just return the already rejected initialPromise\n // if an observer has already mounted, we will be able to retry with that queryFn\n if (!options.queryFn && fetchOptions?.initialPromise) {\n return () => fetchOptions.initialPromise!\n }\n\n if (!options.queryFn || options.queryFn === skipToken) {\n return () =>\n Promise.reject(new Error(`Missing queryFn: '${options.queryHash}'`))\n }\n\n return options.queryFn\n}\n\nexport function shouldThrowError<T extends (...args: Array<any>) => boolean>(\n throwOnError: boolean | T | undefined,\n params: Parameters<T>,\n): boolean {\n // Allow throwOnError function to override throwing behavior on a per-error basis\n if (typeof throwOnError === 'function') {\n return throwOnError(...params)\n }\n\n return !!throwOnError\n}\n\nexport function addConsumeAwareSignal<T>(\n object: T,\n getSignal: () => AbortSignal,\n onCancelled: VoidFunction,\n): T & { signal: AbortSignal } {\n let consumed = false\n let signal: AbortSignal | undefined\n\n Object.defineProperty(object, 'signal', {\n enumerable: true,\n get: () => {\n signal ??= getSignal()\n if (consumed) {\n return signal\n }\n\n consumed = true\n if (signal.aborted) {\n onCancelled()\n } else {\n signal.addEventListener('abort', onCancelled, { once: true })\n }\n\n return signal\n },\n })\n\n return object as T & { signal: AbortSignal }\n}\n","/**\n * Thenable types which matches React's types for promises\n *\n * React seemingly uses `.status`, `.value` and `.reason` properties on a promises to optimistically unwrap data from promises\n *\n * @see https://github.com/facebook/react/blob/main/packages/shared/ReactTypes.js#L112-L138\n * @see https://github.com/facebook/react/blob/4f604941569d2e8947ce1460a0b2997e835f37b9/packages/react-debug-tools/src/ReactDebugHooks.js#L224-L227\n */\n\nimport { noop } from './utils'\n\ninterface Fulfilled<T> {\n status: 'fulfilled'\n value: T\n}\ninterface Rejected {\n status: 'rejected'\n reason: unknown\n}\ninterface Pending<T> {\n status: 'pending'\n\n /**\n * Resolve the promise with a value.\n * Will remove the `resolve` and `reject` properties from the promise.\n */\n resolve: (value: T) => void\n /**\n * Reject the promise with a reason.\n * Will remove the `resolve` and `reject` properties from the promise.\n */\n reject: (reason: unknown) => void\n}\n\nexport type FulfilledThenable<T> = Promise<T> & Fulfilled<T>\nexport type RejectedThenable<T> = Promise<T> & Rejected\nexport type PendingThenable<T> = Promise<T> & Pending<T>\n\nexport type Thenable<T> =\n | FulfilledThenable<T>\n | RejectedThenable<T>\n | PendingThenable<T>\n\nexport function pendingThenable<T>(): PendingThenable<T> {\n let resolve: Pending<T>['resolve']\n let reject: Pending<T>['reject']\n // this could use `Promise.withResolvers()` in the future\n const thenable = new Promise((_resolve, _reject) => {\n resolve = _resolve\n reject = _reject\n }) as PendingThenable<T>\n\n thenable.status = 'pending'\n thenable.catch(() => {\n // prevent unhandled rejection errors\n })\n\n function finalize(data: Fulfilled<T> | Rejected) {\n Object.assign(thenable, data)\n\n // clear pending props to avoid calling them twice\n delete (thenable as Partial<PendingThenable<T>>).resolve\n delete (thenable as Partial<PendingThenable<T>>).reject\n }\n\n thenable.resolve = (value) => {\n finalize({\n status: 'fulfilled',\n value,\n })\n\n resolve(value)\n }\n thenable.reject = (reason) => {\n finalize({\n status: 'rejected',\n reason,\n })\n\n reject(reason)\n }\n\n return thenable\n}\n\n/**\n * This function takes a Promise-like input and detects whether the data\n * is synchronously available or not.\n *\n * It does not inspect .status, .value or .reason properties of the promise,\n * as those are not always available, and the .status of React's promises\n * should not be considered part of the public API.\n */\nexport function tryResolveSync(promise: Promise<unknown> | Thenable<unknown>) {\n let data: unknown\n\n promise\n .then((result) => {\n data = result\n return result\n }, noop)\n // .catch can be unavailable on certain kinds of thenable's\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n ?.catch(noop)\n\n if (data !== undefined) {\n return { data }\n }\n\n return undefined\n}\n","import { tryResolveSync } from './thenable'\nimport { noop } from './utils'\nimport type {\n DefaultError,\n MutationKey,\n MutationMeta,\n MutationOptions,\n MutationScope,\n QueryKey,\n QueryMeta,\n QueryOptions,\n} from './types'\nimport type { QueryClient } from './queryClient'\nimport type { Query, QueryState } from './query'\nimport type { Mutation, MutationState } from './mutation'\n\n// TYPES\ntype TransformerFn = (data: any) => any\nfunction defaultTransformerFn(data: any): any {\n return data\n}\n\nexport interface DehydrateOptions {\n serializeData?: TransformerFn\n shouldDehydrateMutation?: (mutation: Mutation) => boolean\n shouldDehydrateQuery?: (query: Query) => boolean\n shouldRedactErrors?: (error: unknown) => boolean\n}\n\nexport interface HydrateOptions {\n defaultOptions?: {\n deserializeData?: TransformerFn\n queries?: QueryOptions\n mutations?: MutationOptions<unknown, DefaultError, unknown, unknown>\n }\n}\n\ninterface DehydratedMutation {\n mutationKey?: MutationKey\n state: MutationState\n meta?: MutationMeta\n scope?: MutationScope\n}\n\ninterface DehydratedQuery {\n queryHash: string\n queryKey: QueryKey\n state: QueryState\n promise?: Promise<unknown>\n meta?: QueryMeta\n // This is only optional because older versions of Query might have dehydrated\n // without it which we need to handle for backwards compatibility.\n // This should be changed to required in the future.\n dehydratedAt?: number\n}\n\nexport interface DehydratedState {\n mutations: Array<DehydratedMutation>\n queries: Array<DehydratedQuery>\n}\n\n// FUNCTIONS\n\nfunction dehydrateMutation(mutation: Mutation): DehydratedMutation {\n return {\n mutationKey: mutation.options.mutationKey,\n state: mutation.state,\n ...(mutation.options.scope && { scope: mutation.options.scope }),\n ...(mutation.meta && { meta: mutation.meta }),\n }\n}\n\n// Most config is not dehydrated but instead meant to configure again when\n// consuming the de/rehydrated data, typically with useQuery on the client.\n// Sometimes it might make sense to prefetch data on the server and include\n// in the html-payload, but not consume it on the initial render.\nfunction dehydrateQuery(\n query: Query,\n serializeData: TransformerFn,\n shouldRedactErrors: (error: unknown) => boolean,\n): DehydratedQuery {\n const dehydratePromise = () => {\n const promise = query.promise?.then(serializeData).catch((error) => {\n if (!shouldRedactErrors(error)) {\n // Reject original error if it should not be redacted\n return Promise.reject(error)\n }\n // If not in production, log original error before rejecting redacted error\n if (process.env.NODE_ENV !== 'production') {\n console.error(\n `A query that was dehydrated as pending ended up rejecting. [${query.queryHash}]: ${error}; The error will be redacted in production builds`,\n )\n }\n return Promise.reject(new Error('redacted'))\n })\n\n // Avoid unhandled promise rejections\n // We need the promise we dehydrate to reject to get the correct result into\n // the query cache, but we also want to avoid unhandled promise rejections\n // in whatever environment the prefetches are happening in.\n promise?.catch(noop)\n\n return promise\n }\n\n return {\n dehydratedAt: Date.now(),\n state: {\n ...query.state,\n ...(query.state.data !== undefined && {\n data: serializeData(query.state.data),\n }),\n },\n queryKey: query.queryKey,\n queryHash: query.queryHash,\n ...(query.state.status === 'pending' && {\n promise: dehydratePromise(),\n }),\n ...(query.meta && { meta: query.meta }),\n }\n}\n\nexport function defaultShouldDehydrateMutation(mutation: Mutation) {\n return mutation.state.isPaused\n}\n\nexport function defaultShouldDehydrateQuery(query: Query) {\n return query.state.status === 'success'\n}\n\nfunction defaultShouldRedactErrors(_: unknown) {\n return true\n}\n\nexport function dehydrate(\n client: QueryClient,\n options: DehydrateOptions = {},\n): DehydratedState {\n const filterMutation =\n options.shouldDehydrateMutation ??\n client.getDefaultOptions().dehydrate?.shouldDehydrateMutation ??\n defaultShouldDehydrateMutation\n\n const mutations = client\n .getMutationCache()\n .getAll()\n .flatMap((mutation) =>\n filterMutation(mutation) ? [dehydrateMutation(mutation)] : [],\n )\n\n const filterQuery =\n options.shouldDehydrateQuery ??\n client.getDefaultOptions().dehydrate?.shouldDehydrateQuery ??\n defaultShouldDehydrateQuery\n\n const shouldRedactErrors =\n options.shouldRedactErrors ??\n client.getDefaultOptions().dehydrate?.shouldRedactErrors ??\n defaultShouldRedactErrors\n\n const serializeData =\n options.serializeData ??\n client.getDefaultOptions().dehydrate?.serializeData ??\n defaultTransformerFn\n\n const queries = client\n .getQueryCache()\n .getAll()\n .flatMap((query) =>\n filterQuery(query)\n ? [dehydrateQuery(query, serializeData, shouldRedactErrors)]\n : [],\n )\n\n return { mutations, queries }\n}\n\nexport function hydrate(\n client: QueryClient,\n dehydratedState: unknown,\n options?: HydrateOptions,\n): void {\n if (typeof dehydratedState !== 'object' || dehydratedState === null) {\n return\n }\n\n const mutationCache = client.getMutationCache()\n const queryCache = client.getQueryCache()\n const deserializeData =\n options?.defaultOptions?.deserializeData ??\n client.getDefaultOptions().hydrate?.deserializeData ??\n defaultTransformerFn\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n const mutations = (dehydratedState as DehydratedState).mutations || []\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n const queries = (dehydratedState as DehydratedState).queries || []\n\n mutations.forEach(({ state, ...mutationOptions }) => {\n mutationCache.build(\n client,\n {\n ...client.getDefaultOptions().hydrate?.mutations,\n ...options?.defaultOptions?.mutations,\n ...mutationOptions,\n },\n state,\n )\n })\n\n queries.forEach(\n ({ queryKey, state, queryHash, meta, promise, dehydratedAt }) => {\n const syncData = promise ? tryResolveSync(promise) : undefined\n const rawData = state.data === undefined ? syncData?.data : state.data\n const data = rawData === undefined ? rawData : deserializeData(rawData)\n\n let query = queryCache.get(queryHash)\n const existingQueryIsPending = query?.state.status === 'pending'\n const existingQueryIsFetching = query?.state.fetchStatus === 'fetching'\n\n // Do not hydrate if an existing query exists with newer data\n if (query) {\n const hasNewerSyncData =\n syncData &&\n // We only need this undefined check to handle older dehydration\n // payloads that might not have dehydratedAt\n dehydratedAt !== undefined &&\n dehydratedAt > query.state.dataUpdatedAt\n if (\n state.dataUpdatedAt > query.state.dataUpdatedAt ||\n hasNewerSyncData\n ) {\n // omit fetchStatus from dehydrated state\n // so that query stays in its current fetchStatus\n const { fetchStatus: _ignored, ...serializedState } = state\n query.setState({\n ...serializedState,\n data,\n })\n }\n } else {\n // Restore query\n query = queryCache.build(\n client,\n {\n ...client.getDefaultOptions().hydrate?.queries,\n ...options?.defaultOptions?.queries,\n queryKey,\n queryHash,\n meta,\n },\n // Reset fetch status to idle to avoid\n // query being stuck in fetching state upon hydration\n {\n ...state,\n data,\n fetchStatus: 'idle',\n status: data !== undefined ? 'success' : state.status,\n },\n )\n }\n\n if (\n promise &&\n !existingQueryIsPending &&\n !existingQueryIsFetching &&\n // Only hydrate if dehydration is newer than any existing data,\n // this is always true for new queries\n (dehydratedAt === undefined || dehydratedAt > query.state.dataUpdatedAt)\n ) {\n // This doesn't actually fetch - it just creates a retryer\n // which will re-use the passed `initialPromise`\n // Note that we need to call these even when data was synchronously\n // available, as we still need to set up the retryer\n query\n .fetch(undefined, {\n // RSC transformed promises are not thenable\n initialPromise: Promise.resolve(promise).then(deserializeData),\n })\n // Avoid unhandled promise rejections\n .catch(noop)\n }\n },\n )\n}\n","import { dehydrate, hydrate } from '@tanstack/query-core'\nimport type {\n DehydrateOptions,\n DehydratedState,\n HydrateOptions,\n NotifyEventType,\n QueryClient,\n} from '@tanstack/query-core'\n\nexport type Promisable<T> = T | PromiseLike<T>\n\nexport interface Persister {\n persistClient: (persistClient: PersistedClient) => Promisable<void>\n restoreClient: () => Promisable<PersistedClient | undefined>\n removeClient: () => Promisable<void>\n}\n\nexport interface PersistedClient {\n timestamp: number\n buster: string\n clientState: DehydratedState\n}\n\nexport interface PersistQueryClientRootOptions {\n /** The QueryClient to persist */\n queryClient: QueryClient\n /** The Persister interface for storing and restoring the cache\n * to/from a persisted location */\n persister: Persister\n /** A unique string that can be used to forcefully\n * invalidate existing caches if they do not share the same buster string */\n buster?: string\n}\n\nexport interface PersistedQueryClientRestoreOptions extends PersistQueryClientRootOptions {\n /** The max-allowed age of the cache in milliseconds.\n * If a persisted cache is found that is older than this\n * time, it will be discarded */\n maxAge?: number\n /** The options passed to the hydrate function */\n hydrateOptions?: HydrateOptions\n}\n\nexport interface PersistedQueryClientSaveOptions extends PersistQueryClientRootOptions {\n /** The options passed to the dehydrate function */\n dehydrateOptions?: DehydrateOptions\n}\n\nexport interface PersistQueryClientOptions\n extends\n PersistedQueryClientRestoreOptions,\n PersistedQueryClientSaveOptions,\n PersistQueryClientRootOptions {}\n\n/**\n * Checks if emitted event is about cache change and not about observers.\n * Useful for persist, where we only want to trigger save when cache is changed.\n */\nconst cacheEventTypes: Array<NotifyEventType> = ['added', 'removed', 'updated']\n\nfunction isCacheEventType(eventType: NotifyEventType) {\n return cacheEventTypes.includes(eventType)\n}\n\n/**\n * Restores persisted data to the QueryCache\n * - data obtained from persister.restoreClient\n * - data is hydrated using hydrateOptions\n * If data is expired, busted, empty, or throws, it runs persister.removeClient\n */\nexport async function persistQueryClientRestore({\n queryClient,\n persister,\n maxAge = 1000 * 60 * 60 * 24,\n buster = '',\n hydrateOptions,\n}: PersistedQueryClientRestoreOptions) {\n try {\n const persistedClient = await persister.restoreClient()\n\n if (persistedClient) {\n if (persistedClient.timestamp) {\n const expired = Date.now() - persistedClient.timestamp > maxAge\n const busted = persistedClient.buster !== buster\n if (expired || busted) {\n return persister.removeClient()\n } else {\n hydrate(queryClient, persistedClient.clientState, hydrateOptions)\n }\n } else {\n return persister.removeClient()\n }\n }\n } catch (err) {\n if (process.env.NODE_ENV !== 'production') {\n console.error(err)\n console.warn(\n 'Encountered an error attempting to restore client cache from persisted location. As a precaution, the persisted cache will be discarded.',\n )\n }\n\n await persister.removeClient()\n\n throw err\n }\n}\n\n/**\n * Persists data from the QueryCache\n * - data dehydrated using dehydrateOptions\n * - data is persisted using persister.persistClient\n */\nexport async function persistQueryClientSave({\n queryClient,\n persister,\n buster = '',\n dehydrateOptions,\n}: PersistedQueryClientSaveOptions) {\n const persistClient: PersistedClient = {\n buster,\n timestamp: Date.now(),\n clientState: dehydrate(queryClient, dehydrateOptions),\n }\n\n await persister.persistClient(persistClient)\n}\n\n/**\n * Subscribe to QueryCache and MutationCache updates (for persisting)\n * @returns an unsubscribe function (to discontinue monitoring)\n */\nexport function persistQueryClientSubscribe(\n props: PersistedQueryClientSaveOptions,\n) {\n const unsubscribeQueryCache = props.queryClient\n .getQueryCache()\n .subscribe((event) => {\n if (isCacheEventType(event.type)) {\n persistQueryClientSave(props)\n }\n })\n\n const unsubscribeMutationCache = props.queryClient\n .getMutationCache()\n .subscribe((event) => {\n if (isCacheEventType(event.type)) {\n persistQueryClientSave(props)\n }\n })\n\n return () => {\n unsubscribeQueryCache()\n unsubscribeMutationCache()\n }\n}\n\n/**\n * Restores persisted data to QueryCache and persists further changes.\n */\nexport function persistQueryClient(\n props: PersistQueryClientOptions,\n): [() => void, Promise<void>] {\n let hasUnsubscribed = false\n let persistQueryClientUnsubscribe: (() => void) | undefined\n const unsubscribe = () => {\n hasUnsubscribed = true\n persistQueryClientUnsubscribe?.()\n }\n\n // Attempt restore\n const restorePromise = persistQueryClientRestore(props).then(() => {\n if (!hasUnsubscribed) {\n // Subscribe to changes in the query cache to trigger the save\n persistQueryClientUnsubscribe = persistQueryClientSubscribe(props)\n }\n })\n\n return [unsubscribe, restorePromise]\n}\n","import type { QueryClient } from '@tanstack/react-query'\nimport type { TadaDocumentNode } from 'gql.tada'\n\nimport { conflictAwareUpdate } from './conflictAwareUpdate'\nimport { accountUpdateEmail } from '../../account/useUpdateEmail'\nimport { accountUpdateName } from '../../account/useUpdateName'\nimport { updatePassword } from '../../account/useUpdatePassword'\nimport { accountUpdatePhone } from '../../account/useUpdatePhone'\nimport { accountUpdatePrefs } from '../../account/useUpdatePrefs'\nimport type { AppwriteClient } from '../../client'\nimport { createDocument } from '../../databases/useCreateDocument'\nimport { decrementDocumentAttribute } from '../../databases/useDecrementAttribute'\nimport { deleteDocument } from '../../databases/useDeleteDocument'\nimport { incrementDocumentAttribute } from '../../databases/useIncrementAttribute'\nimport { upsertDocument } from '../../databases/useUpsertDocument'\nimport { createSubscriber } from '../../messaging/useCreateSubscriber'\nimport { deleteSubscriber } from '../../messaging/useDeleteSubscriber'\nimport { Keys } from '../../query/Keys'\nimport { createMembership } from '../../teams/useCreateMembership'\nimport { createTeam } from '../../teams/useCreateTeam'\nimport { deleteMembership } from '../../teams/useDeleteMembership'\nimport { deleteTeam } from '../../teams/useDeleteTeam'\nimport { updateMembership } from '../../teams/useUpdateMembership'\nimport { updateTeamName } from '../../teams/useUpdateTeamName'\nimport { updateTeamPrefs } from '../../teams/useUpdateTeamPrefs'\nimport type { ConflictStrategy } from '../conflictResolution/types'\nimport type { MutationFn, Vars } from '../types'\n\n/**\n * Creates a mutationFn that executes a GraphQL mutation and returns the\n * first field from the response data.\n */\nfunction gqlMutation(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n query: TadaDocumentNode<any, any>,\n resultKey: string,\n options?: { serializeData?: boolean },\n): MutationFn {\n return async (client, variables) => {\n const vars = options?.serializeData\n ? { ...variables, data: JSON.stringify(variables.data) }\n : variables\n\n const { data, errors } = await client.graphql.mutation({\n query,\n variables: vars as any,\n })\n if (errors) throw errors\n return (data as Vars)[resultKey]\n }\n}\n\ntype MutationEntry = {\n mutationKey: readonly string[]\n mutationFn: MutationFn\n}\n\nexport const mutationRegistry: MutationEntry[] = [\n {\n mutationKey: Keys.databases().collections().documents().create(),\n mutationFn: gqlMutation(createDocument, 'databasesCreateDocument', {\n serializeData: true,\n }),\n },\n // The update document entry is registered separately by hydrateMutationDefaults\n // so it can be configured with the user's conflict resolution strategy.\n {\n mutationKey: Keys.databases().collections().documents().delete(),\n mutationFn: gqlMutation(deleteDocument, 'databasesDeleteDocument'),\n },\n {\n mutationKey: Keys.databases().collections().documents().upsert(),\n mutationFn: gqlMutation(upsertDocument, 'databasesUpsertDocument', {\n serializeData: true,\n }),\n },\n {\n mutationKey: [...Keys.databases().transactions().operations().key(), 'incrementAttribute'],\n mutationFn: gqlMutation(incrementDocumentAttribute, 'databasesIncrementDocumentAttribute'),\n },\n\n {\n mutationKey: [...Keys.databases().transactions().operations().key(), 'decrementAttribute'],\n mutationFn: gqlMutation(decrementDocumentAttribute, 'databasesDecrementDocumentAttribute'),\n },\n\n {\n mutationKey: Keys.account().prefs().update(),\n mutationFn: gqlMutation(accountUpdatePrefs, 'accountUpdatePrefs'),\n },\n {\n mutationKey: Keys.account().name().update(),\n mutationFn: gqlMutation(accountUpdateName, 'accountUpdateName'),\n },\n {\n mutationKey: Keys.account().email().update(),\n mutationFn: gqlMutation(accountUpdateEmail, 'accountUpdateEmail'),\n },\n {\n mutationKey: Keys.account().password().update(),\n mutationFn: gqlMutation(updatePassword, 'accountUpdatePassword'),\n },\n {\n mutationKey: Keys.account().phone().update(),\n mutationFn: gqlMutation(accountUpdatePhone, 'accountUpdatePhone'),\n },\n\n {\n mutationKey: Keys.teams().create(),\n mutationFn: gqlMutation(createTeam, 'teamsCreate'),\n },\n {\n mutationKey: Keys.teams().delete(),\n mutationFn: gqlMutation(deleteTeam, 'teamsDelete'),\n },\n {\n mutationKey: Keys.teams().teamName().update(),\n mutationFn: gqlMutation(updateTeamName, 'teamsUpdateName'),\n },\n {\n mutationKey: Keys.teams().teamPrefs().update(),\n mutationFn: gqlMutation(updateTeamPrefs, 'teamsUpdatePrefs'),\n },\n {\n mutationKey: Keys.teams().memberships().create(),\n mutationFn: gqlMutation(createMembership, 'teamsCreateMembership'),\n },\n {\n mutationKey: Keys.teams().memberships().delete(),\n mutationFn: gqlMutation(deleteMembership, 'teamsDeleteMembership'),\n },\n {\n mutationKey: Keys.teams().memberships().update(),\n mutationFn: gqlMutation(updateMembership, 'teamsUpdateMembership'),\n },\n\n {\n mutationKey: Keys.messaging().subscriber().create(),\n mutationFn: gqlMutation(createSubscriber, 'messagingCreateSubscriber'),\n },\n {\n mutationKey: Keys.messaging().subscriber().delete(),\n mutationFn: gqlMutation(deleteSubscriber, 'messagingDeleteSubscriber'),\n },\n]\n\n/**\n * Registers all mutation defaults with the QueryClient so that\n * dehydrated/persisted mutations can be replayed on app restart.\n *\n * Call once during app initialization, before rehydrating the persisted\n * mutation cache.\n */\nexport function hydrateMutationDefaults(\n queryClient: QueryClient,\n client: AppwriteClient,\n options?: { conflictStrategy?: ConflictStrategy },\n) {\n for (const entry of mutationRegistry) {\n queryClient.setMutationDefaults(entry.mutationKey, {\n mutationFn: (variables: Vars) => entry.mutationFn(client, variables, queryClient),\n scope: { id: 'appwrite' },\n })\n }\n\n // Register the update document mutation with conflict resolution awareness\n const strategy = options?.conflictStrategy ?? 'last-write-wins'\n queryClient.setMutationDefaults(Keys.databases().collections().documents().update(), {\n mutationFn: (variables: Vars) => conflictAwareUpdate(strategy)(client, variables, queryClient),\n scope: { id: 'appwrite' },\n })\n}\n","import { createAsyncStoragePersister } from '@tanstack/query-async-storage-persister'\nimport type { AsyncStorage, Persister } from '@tanstack/query-persist-client-core'\nimport { persistQueryClient } from '@tanstack/query-persist-client-core'\nimport { onlineManager, QueryClient } from '@tanstack/react-query'\n\nimport type { ConflictStrategy } from './conflictResolution/types'\nimport { hydrateMutationDefaults } from './mutations/registry'\nimport type { NetworkAdapter } from './types'\nimport type { AppwriteClient } from '../client'\nimport { createAppwriteClient } from '../client'\n\nexport type OfflineClient = {\n appwrite: AppwriteClient\n queryClient: QueryClient\n persister: Persister | undefined\n\n /**\n * Start persistence for non-React (imperative) usage.\n * Restores the persisted cache, subscribes to future changes,\n * and replays any paused mutations once the cache is restored.\n *\n * @returns `unsubscribe` to stop persisting and `restored` which resolves\n * when the cache has been rehydrated from storage.\n * @throws If no persister was configured via `storage` or `persister`.\n */\n startPersistence: () => { unsubscribe: () => void; restored: Promise<void> }\n\n conflictStrategy?: ConflictStrategy\n}\n\nconst dehydrateOptions = {\n shouldDehydrateMutation: (mutation: { state: { isPaused: boolean } }) => mutation.state.isPaused,\n shouldDehydrateQuery: (query: { state: { status: string } }) => query.state.status === 'success',\n}\n\n/**\n * Creates an offline-capable Appwrite client with a pre-configured QueryClient.\n *\n * Persistence can be configured in three ways:\n * - **Batteries-included**: pass `storage` (an `AsyncStorage` interface) and\n * the factory builds a TanStack persister automatically.\n * - **Bring your own**: pass a pre-built `persister` (TanStack `Persister`\n * interface) — e.g. one backed by TinyBase, SQLite, etc.\n * - **No persistence**: omit both — you still get offline mutation queuing\n * and network state management.\n *\n * For React apps, pass `client.persister` to `<AppwriteProvider persister={…}>`.\n * For non-React (imperative) usage, call `client.startPersistence()`.\n */\nexport function createOfflineClient({\n endpoint,\n projectId,\n storage,\n persister: externalPersister,\n networkAdapter,\n throttleTime = 1000,\n conflictStrategy = 'last-write-wins',\n}: {\n endpoint: string\n projectId: string\n /** Batteries-included: provide a simple getItem/setItem/removeItem storage. */\n storage?: AsyncStorage\n /** BYOP: provide a pre-built TanStack Persister. */\n persister?: Persister\n networkAdapter: NetworkAdapter\n /** Throttle time for network status changes to prevent rapid toggling. Default: 1000ms. */\n throttleTime?: number\n conflictStrategy?: ConflictStrategy\n}): OfflineClient {\n if (storage && externalPersister) {\n throw new Error('Provide either `storage` or `persister`, not both.')\n }\n\n const appwrite = createAppwriteClient({ endpoint, projectId })\n\n const queryClient = new QueryClient({\n defaultOptions: {\n mutations: {\n networkMode: 'offlineFirst',\n meta: {\n conflictStrategy,\n },\n },\n queries: { networkMode: 'offlineFirst', gcTime: 1000 * 60 * 60 * 24 },\n },\n })\n\n hydrateMutationDefaults(queryClient, appwrite, { conflictStrategy })\n\n const persister =\n externalPersister ??\n (storage\n ? createAsyncStoragePersister({\n storage,\n key: 'appwrite-graphql-offline-cache',\n throttleTime,\n })\n : undefined)\n\n networkAdapter.listen((isOnline) => {\n onlineManager.setOnline(isOnline)\n })\n\n return {\n appwrite,\n queryClient,\n persister,\n startPersistence() {\n if (!persister) {\n throw new Error(\n 'No persister configured. Provide `storage` or `persister` to createOfflineClient.',\n )\n }\n\n const [unsubscribe, restored] = persistQueryClient({\n queryClient,\n persister,\n dehydrateOptions,\n })\n\n const restoredWithResume = restored.then(() => {\n void queryClient.resumePausedMutations()\n })\n\n return { unsubscribe, restored: restoredWithResume }\n },\n }\n}\n","import type { NetworkAdapter } from '../types'\n\nexport function webNetworkAdapter(): NetworkAdapter {\n return {\n listen: (callback) => {\n const updateOnlineStatus = () => {\n callback(navigator.onLine)\n }\n\n window.addEventListener('online', updateOnlineStatus)\n window.addEventListener('offline', updateOnlineStatus)\n\n // Initial status\n callback(navigator.onLine)\n\n return () => {\n window.removeEventListener('online', updateOnlineStatus)\n window.removeEventListener('offline', updateOnlineStatus)\n }\n },\n }\n}\n","import { useState } from 'react'\nimport type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQuery } from '../useQuery'\nimport { useSuspenseQuery } from '../useSuspenseQuery'\n\ntype Props = {\n functionId: string\n body?: Record<string, string | number | boolean | null>\n async?: boolean\n path?: string\n method?: string\n headers?: Record<string, string | number | boolean | null>\n scheduledAt?: string\n}\n\nconst createExecution = gql(/* GraphQL */ `\n mutation CreateExecution(\n $functionId: String!\n $body: String\n $async: Boolean\n $path: String\n $method: String\n $headers: String\n $scheduledAt: String\n ) {\n functionsCreateExecution(\n functionId: $functionId\n body: $body\n async: $async\n path: $path\n method: $method\n headers: $headers\n scheduledAt: $scheduledAt\n ) {\n _id\n status\n responseStatusCode\n responseBody\n errors\n duration\n }\n }\n`)\n\nconst getFunctionExecution = gql(/* GraphQL */ `\n query GetFunctionExecution($functionId: String!, $executionId: String!) {\n functionsGetExecution(functionId: $functionId, executionId: $executionId) {\n status\n errors\n duration\n responseBody\n requestPath\n }\n }\n`)\n\n/** The result of polling the current execution in the {@link useFunction} hook. */\nexport type FunctionResult = Prettify<\n ResultOf<typeof getFunctionExecution>['functionsGetExecution']\n>\n\ntype ResponseBody = string | null | undefined | Record<string, string | number | boolean | null>\n\nfunction useCurrentExecution({\n currentExecution,\n currentFunction,\n}: {\n currentExecution: string | null\n currentFunction: string | null\n}) {\n const { graphql } = useAppwrite()\n const enabled = !!currentFunction && !!currentExecution\n\n const query = useQuery<FunctionResult | null, AppwriteException[], FunctionResult | null>({\n queryKey: enabled\n ? Keys.function(currentFunction).execution(currentExecution).key()\n : Keys.functions().key(),\n queryFn: async () => {\n if (!currentExecution || !currentFunction) {\n return null\n }\n const { data } = await graphql.query({\n query: getFunctionExecution,\n variables: {\n functionId: currentFunction,\n executionId: currentExecution,\n },\n })\n\n if (!data?.functionsGetExecution) {\n throw new Error('Execution not found')\n }\n\n return data.functionsGetExecution ?? null\n },\n enabled,\n })\n\n return { ...query }\n}\n\n/**\n * Returns `{ executeFunction, currentExecution }` for triggering Appwrite function executions.\n *\n * **`executeFunction`** is a mutation that sends the `CreateExecution` GraphQL mutation.\n * It serialises `body` and `headers` to JSON strings before sending, and automatically\n * parses JSON response bodies back into objects. If the execution status is `\"failed\"`,\n * the mutation throws with the error details.\n *\n * **`currentExecution`** is a query that polls the latest execution's status via the\n * `GetFunctionExecution` GraphQL query. It is enabled automatically once an execution\n * has been triggered and exposes standard `useQuery` fields (`data`, `isLoading`, etc.).\n *\n * @example\n * ```tsx\n * const { executeFunction, currentExecution } = useFunction()\n *\n * // Trigger a function execution\n * executeFunction.mutate({\n * functionId: 'send-welcome-email',\n * body: { userId: 'user_123' },\n * method: 'POST',\n * path: '/send',\n * })\n *\n * // Poll the result\n * if (currentExecution.data) {\n * console.log(currentExecution.data.status)\n * console.log(currentExecution.data.responseBody)\n * }\n * ```\n *\n * **Variables** (`Props`):\n * - `functionId` — The ID of the Appwrite function to execute\n * - `body` — Optional. A key-value object sent as the request body (serialised to JSON)\n * - `async` — Optional. When `true`, the function runs asynchronously (defaults to `false`)\n * - `path` — Optional. The execution path (defaults to `'/'`)\n * - `method` — Optional. The HTTP method (defaults to `'POST'`)\n * - `headers` — Optional. A key-value object of custom headers (serialised to JSON)\n * - `scheduledAt` — Optional. An ISO 8601 date string to schedule the execution\n *\n * @returns An object with `executeFunction` (a `UseMutationResult` whose `data` is the\n * parsed response body or raw string) and `currentExecution` (a `UseQueryResult` whose\n * `data` is the {@link FunctionResult} with `status`, `errors`, `duration`, `responseBody`,\n * and `requestPath`).\n */\nexport function useFunction() {\n const { graphql } = useAppwrite()\n const [currentExecution, setCurrentExecution] = useState<string | null>(null)\n const [currentFunction, setCurrentFunction] = useState<string | null>(null)\n const getExecution = useCurrentExecution({\n currentExecution,\n currentFunction,\n })\n\n const executeFunction = useMutation<ResponseBody, AppwriteException[], Props>({\n mutationKey: Keys.functions().executions().create(),\n mutationFn: async ({\n functionId,\n body = {},\n async = false,\n path = '/',\n method = 'POST',\n headers = {},\n scheduledAt,\n }) => {\n setCurrentFunction(functionId)\n\n const { data } = await graphql.mutation({\n query: createExecution,\n variables: {\n functionId,\n body: JSON.stringify(body),\n async,\n path,\n method,\n headers: JSON.stringify(headers),\n scheduledAt,\n },\n })\n\n const { _id, status, errors, responseBody } = data.functionsCreateExecution ?? {}\n\n if (status === 'failed') {\n throw new Error(errors)\n }\n\n setCurrentExecution(_id ?? null)\n\n if (typeof responseBody === 'string') {\n if (responseBody.trim().startsWith('{') && responseBody.trim().endsWith('}')) {\n try {\n return JSON.parse(responseBody)\n } catch (error) {\n console.error('Failed to parse response body:', error)\n return responseBody\n }\n }\n return responseBody\n }\n },\n })\n\n return {\n executeFunction,\n currentExecution: getExecution,\n }\n}\n\n/**\n * Suspense variant that executes an Appwrite function and suspends until the result is available.\n *\n * Uses `useSuspenseQuery` under the hood so the component tree suspends while the function\n * executes. The query is cached with `staleTime: Infinity` so re-renders do not re-trigger\n * the execution. JSON response bodies are automatically parsed into objects.\n *\n * @example\n * ```tsx\n * function WelcomeMessage() {\n * const { executeFunction } = useSuspenseFunction({\n * functionId: 'get-greeting',\n * body: { locale: 'en' },\n * path: '/greet',\n * method: 'GET',\n * })\n *\n * return <p>{executeFunction.data}</p>\n * }\n * ```\n *\n * **Variables** (`Props`):\n * - `functionId` — The ID of the Appwrite function to execute\n * - `body` — Optional. A key-value object sent as the request body (serialised to JSON)\n * - `async` — Optional. When `true`, the function runs asynchronously (defaults to `false`)\n * - `path` — Optional. The execution path (defaults to `'/'`)\n * - `method` — Optional. The HTTP method (defaults to `'POST'`)\n * - `headers` — Optional. A key-value object of custom headers (serialised to JSON)\n * - `scheduledAt` — Optional. An ISO 8601 date string to schedule the execution\n *\n * @returns An object with `executeFunction` (a `UseSuspenseQueryResult` whose `data` is\n * the parsed response body or raw string).\n */\nexport function useSuspenseFunction({\n functionId,\n body = {},\n async = false,\n path = '/',\n method = 'POST',\n headers = {},\n scheduledAt,\n}: Props) {\n const { graphql } = useAppwrite()\n\n const executeFunction = useSuspenseQuery<ResponseBody, AppwriteException[], ResponseBody>({\n queryKey: [...Keys.function(functionId).key(), 'execute', { path, method, body }],\n queryFn: async () => {\n const { data } = await graphql.mutation({\n query: createExecution,\n variables: {\n functionId,\n body: JSON.stringify(body),\n async,\n path,\n method,\n headers: JSON.stringify(headers),\n scheduledAt,\n },\n })\n\n if (data?.functionsCreateExecution?.status === 'failed') {\n throw new Error(data.functionsCreateExecution.errors)\n }\n\n const { responseBody } = data.functionsCreateExecution ?? {}\n\n if (typeof responseBody === 'string') {\n if (responseBody.trim().startsWith('{') && responseBody.trim().endsWith('}')) {\n try {\n return JSON.parse(responseBody)\n } catch (error) {\n console.error('Failed to parse response body:', error)\n return responseBody\n }\n }\n }\n return responseBody\n },\n staleTime: Infinity,\n })\n\n return {\n executeFunction,\n }\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify, QueryOptions } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst getExecution = gql(/* GraphQL */ `\n query GetExecution($functionId: String!, $executionId: String!) {\n functionsGetExecution(functionId: $functionId, executionId: $executionId) {\n _id\n _createdAt\n _updatedAt\n functionId\n trigger\n status\n requestMethod\n requestPath\n responseStatusCode\n responseBody\n errors\n duration\n }\n }\n`)\n\n/** The variables accepted by the {@link useGetExecution} hook. */\nexport type GetExecutionVariables = Prettify<VariablesOf<typeof getExecution>>\n\n/** The result returned by the {@link useGetExecution} hook. */\nexport type GetExecutionResult = Prettify<ResultOf<typeof getExecution>['functionsGetExecution']>\n\n/**\n * Fetches the details of a specific function execution.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useGetExecution({\n * functionId: 'send-email',\n * executionId: '9b2c…',\n * })\n *\n * // data.status, data.responseBody, data.duration\n * ```\n *\n * **Parameters** ({@link GetExecutionVariables}):\n * - `functionId` — The unique function identifier.\n * - `executionId` — The unique execution identifier.\n *\n * @returns A `UseQueryResult` with the execution details ({@link GetExecutionResult}).\n */\nexport function useGetExecution(\n { functionId, executionId }: GetExecutionVariables,\n opts: QueryOptions = {},\n) {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<GetExecutionResult, AppwriteException[], GetExecutionResult>({\n queryKey: Keys.function(functionId).execution(executionId).key(),\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: getExecution,\n variables: { functionId, executionId },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.functionsGetExecution\n },\n ...opts,\n })\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify, QueryOptions } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst listExecutions = gql(/* GraphQL */ `\n query ListExecutions($functionId: String!, $queries: [String!]) {\n functionsListExecutions(functionId: $functionId, queries: $queries) {\n total\n executions {\n _id\n _createdAt\n _updatedAt\n functionId\n trigger\n status\n requestMethod\n requestPath\n responseStatusCode\n responseBody\n errors\n duration\n }\n }\n }\n`)\n\n/** The result returned by the {@link useListExecutions} hook. */\nexport type ListExecutionsResult = Prettify<\n ResultOf<typeof listExecutions>['functionsListExecutions']\n>\n\n/**\n * Fetches the list of executions for a function with optional query filters.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useListExecutions({\n * functionId: 'send-email',\n * queries: ['limit(10)'],\n * })\n *\n * // data.total, data.executions\n * ```\n *\n * **Parameters:**\n * - `functionId` — The unique function identifier.\n * - `queries` *(optional)* — Appwrite query strings for filtering and pagination.\n *\n * @returns A `UseQueryResult` with the paginated execution list ({@link ListExecutionsResult}).\n */\nexport function useListExecutions(\n {\n functionId,\n queries,\n }: {\n functionId: string\n queries?: string[]\n },\n opts: QueryOptions = {},\n) {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<ListExecutionsResult, AppwriteException[], ListExecutionsResult>({\n queryKey: [...Keys.function(functionId).executions().key(), ...(queries ?? [])],\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: listExecutions,\n variables: {\n functionId,\n queries,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.functionsListExecutions\n },\n ...opts,\n })\n\n return queryResult\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/AppwriteProvider.tsx","../src/useAppwrite.ts","../src/useQueryClient.ts","../src/useMutation.ts","../src/useQuery.ts","../src/useLazyQuery.ts","../src/useSuspenseQuery.ts","../src/client.ts","../src/query/Keys.ts","../src/account/queryOptions.ts","../src/account/useAccount.ts","../src/account/useCreateAnonymousSession.ts","../src/account/useCreateEmailToken.ts","../src/account/useCreateJWT.ts","../src/account/useCreateMagicURLToken.ts","../src/account/useCreateMfaAuthenticator.ts","../src/account/useCreateMfaChallenge.ts","../src/account/useCreateMfaRecoveryCodes.ts","../src/account/useCreateOAuth2Token.ts","../src/account/useCreatePhoneToken.ts","../src/account/useCreatePhoneVerification.ts","../src/account/useCreatePushTarget.ts","../src/account/useCreateSession.ts","../src/account/useCreateEmailVerification.ts","../src/account/useDeleteIdentity.ts","../src/account/useDeleteMfaAuthenticator.ts","../src/account/useDeletePushTarget.ts","../src/account/useDeleteSession.ts","../src/account/useDeleteSessions.ts","../src/account/useGetMfaRecoveryCodes.ts","../src/account/useGetPrefs.ts","../src/account/useGetSession.ts","../src/account/useListIdentities.ts","../src/account/useListMfaFactors.ts","../src/account/useListSessions.ts","../src/account/useLogin.ts","../src/account/useLogout.ts","../src/account/useLogs.ts","../src/account/usePasswordRecovery.ts","../src/account/useResetPassword.ts","../src/account/useSignUp.ts","../src/account/useUpdateEmail.ts","../src/account/useUpdateEmailVerification.ts","../src/account/useUpdateMagicURLSession.ts","../src/account/useUpdateMfa.ts","../src/account/useUpdateMfaAuthenticator.ts","../src/account/useUpdateMfaChallenge.ts","../src/account/useUpdateMfaRecoveryCodes.ts","../src/account/useUpdateName.ts","../src/account/useUpdatePassword.ts","../src/account/useUpdatePhone.ts","../src/account/useUpdatePhoneSession.ts","../src/account/useUpdatePhoneVerification.ts","../src/account/useUpdatePrefs.ts","../src/account/useUpdatePushTarget.ts","../src/account/useUpdateSession.ts","../src/account/useUpdateStatus.ts","../src/account/useVerification.ts","../src/avatars/useAvatarBrowser.ts","../src/avatars/useAvatarCreditCard.ts","../src/avatars/useAvatarFavicon.ts","../src/avatars/useAvatarFlag.ts","../src/avatars/useAvatarImage.ts","../src/avatars/useAvatarInitials.ts","../src/avatars/useAvatarQR.ts","../src/avatars/useAvatarScreenshot.ts","../src/databases/utils.ts","../src/databases/queryOptions.ts","../src/databases/useCollection.ts","../src/databases/useCollectionWithPagination.ts","../src/databases/useCreateDocument.ts","../src/databases/useCreateOperations.ts","../src/databases/useCreateTransaction.ts","../src/databases/useDecrementAttribute.ts","../src/databases/useDeleteDocument.ts","../src/databases/useDeleteTransaction.ts","../src/databases/useDocument.ts","../src/databases/useGetTransaction.ts","../src/databases/useIncrementAttribute.ts","../src/databases/useInfiniteCollection.ts","../src/databases/useListTransactions.ts","../src/offline/conflictResolution/resolve.ts","../src/offline/mutations/conflictAwareUpdate.ts","../src/databases/useUpdateDocument.ts","../src/databases/useUpdateTransaction.ts","../src/databases/useUpsertDocument.ts","../src/locale/useLocale.ts","../src/locale/useLocaleCodes.ts","../src/locale/useLocaleContinents.ts","../src/locale/useLocaleCountries.ts","../src/locale/useLocaleCountriesEU.ts","../src/locale/useLocaleCountriesPhones.ts","../src/locale/useLocaleCurrencies.ts","../src/locale/useLocaleLanguages.ts","../src/messaging/useCreateSubscriber.ts","../src/messaging/useDeleteSubscriber.ts","../src/storage/useFile.ts","../src/storage/useFileDownload.ts","../src/storage/useFilePreview.ts","../src/storage/useFileView.ts","../src/storage/useFiles.ts","../src/storage/useCreateFile.ts","../src/storage/useUpdateFile.ts","../src/storage/useDeleteFile.ts","../src/teams/queryOptions.ts","../src/teams/useTeam.ts","../src/teams/useTeams.ts","../src/teams/useTeamPrefs.ts","../src/teams/useTeamMembership.ts","../src/teams/useTeamMemberships.ts","../src/teams/useCreateTeam.ts","../src/teams/useUpdateTeamName.ts","../src/teams/useUpdateTeamPrefs.ts","../src/teams/useDeleteTeam.ts","../src/teams/useCreateMembership.ts","../src/teams/useUpdateMembership.ts","../src/teams/useUpdateMembershipStatus.ts","../src/teams/useDeleteMembership.ts","../src/query/QueryBuilder.ts","../node_modules/@tanstack/query-core/src/utils.ts","../node_modules/@tanstack/query-core/src/thenable.ts","../node_modules/@tanstack/query-core/src/hydration.ts","../node_modules/@tanstack/query-persist-client-core/src/persist.ts","../src/offline/mutations/registry.ts","../src/offline/createOfflineClient.ts","../src/functions/useFunction.ts","../src/functions/useGetExecution.ts","../src/functions/useListExecutions.ts","../src/offline/network/web.ts"],"names":["AppwriteContext","defaultQueryClient","QueryClient","AppwriteProvider","client","queryClient","persister","onCacheRestored","children","qc","PersistQueryClientProvider","mutation","query","ReactQueryDevtools","QueryClientProvider","useAppwrite","ctx","useContext","useQueryClient","QueryClientContext","useMutation","options","useReactMutation","useQuery","useReactQuery","useLazyQuery","useSuspenseQuery","useSuspenseReactQuery","graphqlObject","graphqlAppwrite","variables","data","errors","print","createAppwriteClient","endpoint","projectId","Client","Account","Avatars","Realtime","Storage","Graphql","Databases","Functions","Locale","Messaging","TablesDB","Teams","Keys","_Keys","segments","k","id","getAccount","gql","getAccountQuery","useLazyAccount","isActive","setIsActive","useState","queryResult","getAccountQueryOptions","useEffect","subscriptionPromise","subscribe","sub","useAccount","opts","realtime","Channel","response","event","account","produce","draft","castDraft","createAnonymousSession","useCreateAnonymousSession","graphql","createEmailToken","useCreateEmailToken","userId","email","phrase","accountCreateJWT","useCreateJWT","gcTime","useSuspenseCreateJWT","createMagicURLToken","useCreateMagicURLToken","url","accountCreateMfaAuthenticator","useCreateMfaAuthenticator","type","AuthenticatorType","accountCreateMfaChallenge","useCreateMfaChallenge","factor","accountCreateMfaRecoveryCodes","useCreateMfaRecoveryCodes","useCreateOAuth2Token","provider","success","failure","scopes","createPhoneToken","useCreatePhoneToken","phone","createPhoneVerification","useCreatePhoneVerification","accountCreatePushTarget","useCreatePushTarget","targetId","identifier","providerId","createSession","useCreateSession","secret","createEmailVerification","useCreateEmailVerification","accountDeleteIdentity","useDeleteIdentity","identityId","deleteMFAAuthenticator","useDeleteMfaAuthenticator","accountDeletePushTarget","useDeletePushTarget","deleteSession","useDeleteSession","sessionId","deleteSessions","useDeleteSessions","getMFARecoveryCodes","useGetMfaRecoveryCodes","accountGetPrefs","useGetPrefs","getSession","useGetSession","accountListIdentities","useListIdentities","listMFAFactors","useListMfaFactors","accountListSessions","useListSessions","accountCreateEmailPasswordSession","useLogin","login","password","oAuthLogin","useLogout","accountListLogs","useLogs","queries","createRecovery","usePasswordRecovery","resetUrl","_","e","updateRecovery","useResetPassword","createAccount","verify","useSignUp","signUp","name","ID","verifyEmail","verifyUrl","accountUpdateEmail","useUpdateEmail","updateEmailVerification","useUpdateEmailVerification","updateMagicURLSession","useUpdateMagicURLSession","accountUpdateMFA","useUpdateMfa","mfa","updateMFAAuthenticator","useUpdateMfaAuthenticator","otp","accountUpdateMfaChallenge","useUpdateMfaChallenge","challengeId","accountUpdateMfaRecoveryCodes","useUpdateMfaRecoveryCodes","accountUpdateName","useUpdateName","mutationData","updatePassword","useUpdatePassword","oldPassword","accountUpdatePhone","useUpdatePhone","updatePhoneSession","useUpdatePhoneSession","updatePhoneVerification","useUpdatePhoneVerification","accountUpdatePrefs","useUpdatePrefs","prefs","accountUpdatePushTarget","useUpdatePushTarget","updateSession","useUpdateSession","accountUpdateStatus","useUpdateStatus","updateVerification","useVerification","useAvatarBrowser","code","width","height","quality","avatars","useMemo","useAvatarCreditCard","useAvatarFavicon","useAvatarFlag","useAvatarImage","useAvatarInitials","background","useAvatarQR","text","size","margin","download","useAvatarScreenshot","mergeFieldsQuery","fields","Query","getDocument","getDocumentQuery","databaseId","collectionId","documentId","transactionId","rawQueries","mergedQueries","listDocuments","getCollectionQuery","documents","document","useCollectionQueryConfig","useCollectionRealtime","queriesKey","operation","useCollection","config","collection","useSuspenseCollection","usePaginationState","limit","page","setPage","totalRef","useRef","offset","prevPage","currentOffset","newPage","maxPage","useCollectionWithPagination","nextPage","previousPage","handlePageChange","total","useSuspenseCollectionWithPagination","createDocument","useCreateDocument","permissions","result","documentKeyPrefix","createOperations","useCreateOperations","operations","createTransaction","useCreateTransaction","ttl","decrementDocumentAttribute","useDecrementAttribute","attribute","value","min","previousEntries","old","current","decrement","newValue","__","context","key","deleteDocument","useDeleteDocument","deleteTransaction","useDeleteTransaction","useDocumentQueryConfig","useDocumentRealtime","useDocument","useSuspenseDocument","getTransaction","useGetTransaction","incrementDocumentAttribute","useIncrementAttribute","max","increment","useInfiniteCollection","accumulated","setAccumulated","paginatedQueries","prev","expectedLength","hasNextPage","fetchNextPage","useCallback","reset","listTransactions","useListTransactions","resolveConflict","strategy","extractChangedFields","localChanges","remoteChanges","original","updated","changes","conflictAwareUpdate","conflictStrategy","baseSnapshot","m","resolvedData","remoteResult","fetchErrors","rawRemote","remote","local","updateDocument","newData","thing","useUpdateDocument","appwrite","wasOffline","error","baseSnapshotCopy","willPerformOfflineMutation","onlineManager","updateTransaction","useUpdateTransaction","commit","rollback","upsertDocument","useUpsertDocument","getLocale","useLocale","listLocaleCodes","useLocaleCodes","listContinents","useLocaleContinents","listCountries","useLocaleCountries","listCountriesEU","useLocaleCountriesEU","listCountriesPhones","useLocaleCountriesPhones","listCurrencies","useLocaleCurrencies","listLanguages","useLocaleLanguages","createSubscriber","useCreateSubscriber","subscriberId","topicId","deleteSubscriber","useDeleteSubscriber","getFile","useFile","bucketId","fileId","useFileDownload","token","storage","useFilePreview","gravity","borderWidth","borderColor","borderRadius","opacity","rotation","output","useFileView","listFiles","useFiles","search","useCreateFile","file","onProgress","updateFile","useUpdateFile","deleteFile","useDeleteFile","getTeam","teamQueryOptions","teamId","useTeam","listTeams","useTeams","getTeamPrefs","useTeamPrefs","getMembership","useTeamMembership","membershipId","listMemberships","useTeamMemberships","createTeam","useCreateTeam","roles","updateTeamName","useUpdateTeamName","updateTeamPrefs","useUpdateTeamPrefs","deleteTeam","useDeleteTeam","createMembership","useCreateMembership","updateMembership","useUpdateMembership","updateMembershipStatus","useUpdateMembershipStatus","deleteMembership","useDeleteMembership","QueryBuilder","_QueryBuilder","field","pattern","start","end","prefix","suffix","term","count","values","date","orQueries","fn","andQueries","latitude","longitude","distance","meters","points","q","noop","tryResolveSync","promise","defaultTransformerFn","dehydrateMutation","dehydrateQuery","serializeData","shouldRedactErrors","dehydratePromise","defaultShouldDehydrateMutation","defaultShouldDehydrateQuery","defaultShouldRedactErrors","dehydrate","filterMutation","mutations","filterQuery","hydrate","dehydratedState","mutationCache","queryCache","deserializeData","state","mutationOptions","queryKey","queryHash","meta","dehydratedAt","syncData","rawData","existingQueryIsPending","existingQueryIsFetching","hasNewerSyncData","_ignored","serializedState","cacheEventTypes","isCacheEventType","eventType","persistQueryClientRestore","maxAge","buster","hydrateOptions","persistedClient","expired","busted","err","persistQueryClientSave","dehydrateOptions","persistClient","persistQueryClientSubscribe","props","unsubscribeQueryCache","unsubscribeMutationCache","persistQueryClient","hasUnsubscribed","persistQueryClientUnsubscribe","unsubscribe","restorePromise","gqlMutation","resultKey","vars","mutationRegistry","hydrateMutationDefaults","entry","createOfflineClient","externalPersister","networkAdapter","throttleTime","createAsyncStoragePersister","isOnline","restored","restoredWithResume","createExecution","getFunctionExecution","useCurrentExecution","currentExecution","currentFunction","enabled","useFunction","setCurrentExecution","setCurrentFunction","getExecution","functionId","body","async","path","method","headers","scheduledAt","_id","status","responseBody","useSuspenseFunction","useGetExecution","executionId","listExecutions","useListExecutions","webNetworkAdapter","callback","updateOnlineStatus"],"mappings":"+yBASO,IAAMA,CAAAA,CAAwB,gBAAqC,IAAI,CAAA,CAExEC,EAAAA,CAAqB,IAAIC,YAcxB,SAASC,EAAAA,CAAiB,CAC/B,MAAA,CAAAC,EACA,WAAA,CAAAC,CAAAA,CACA,SAAA,CAAAC,CAAAA,CACA,eAAA,CAAAC,CAAAA,CACA,QAAA,CAAAC,CACF,EAMG,CACD,IAAMC,CAAAA,CAAKJ,CAAAA,EAAeJ,GAE1B,OAAIK,CAAAA,CAEA,CAAA,CAAA,aAAA,CAACI,0BAAAA,CAAA,CACC,MAAA,CAAQD,CAAAA,CACR,cAAA,CAAgB,CACd,SAAA,CAAAH,C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AAM,CAC/BD,CAAAA,CAAS,SAAA,CAAU,MAAM,EAC3B,CAAA,CAEA,OAAA,MAAA,CAAO,gBAAA,CAAiB,QAAA,CAAUC,CAAkB,CAAA,CACpD,MAAA,CAAO,gBAAA,CAAiB,SAAA,CAAWA,CAAkB,CAAA,CAGrDD,CAAAA,CAAS,SAAA,CAAU,MAAM,CAAA,CAElB,IAAM,CACX,MAAA,CAAO,mBAAA,CAAoB,QAAA,CAAUC,CAAkB,CAAA,CACvD,MAAA,CAAO,mBAAA,CAAoB,SAAA,CAAWA,CAAkB,EAC1D,CACF,CACF,CACF","file":"index.js","sourcesContent":["import * as React from 'react'\nimport { type ReactNode } from 'react'\nimport type { Persister } from '@tanstack/query-persist-client-core'\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query'\nimport { ReactQueryDevtools } from '@tanstack/react-query-devtools'\nimport { PersistQueryClientProvider } from '@tanstack/react-query-persist-client'\n\nimport type { AppwriteClient } from './client'\n\nexport const AppwriteContext = React.createContext<AppwriteClient | null>(null)\n\nconst defaultQueryClient = new QueryClient()\n\n/**\n * React context provider that supplies the Appwrite client and QueryClient to all child hooks.\n * Supports optional `persister` for offline cache persistence and `onCacheRestored` callback.\n * Must wrap any component using Appwrite hooks.\n *\n * @example\n * ```tsx\n * <AppwriteProvider client={client}>\n * <App />\n * </AppwriteProvider>\n * ```\n */\nexport function AppwriteProvider({\n client,\n queryClient,\n persister,\n onCacheRestored,\n children,\n}: {\n client: AppwriteClient\n queryClient?: QueryClient\n persister?: Persister\n onCacheRestored?: () => void\n children: ReactNode\n}) {\n const qc = queryClient ?? defaultQueryClient\n\n if (persister) {\n return (\n <PersistQueryClientProvider\n client={qc}\n persistOptions={{\n persister,\n dehydrateOptions: {\n shouldDehydrateMutation: (mutation) => mutation.state.isPaused,\n shouldDehydrateQuery: (query) => query.state.status === 'success',\n },\n }}\n onSuccess={() => {\n void qc.resumePausedMutations()\n onCacheRestored?.()\n }}\n >\n <AppwriteContext.Provider value={client}>{children}</AppwriteContext.Provider>\n <ReactQueryDevtools initialIsOpen={false} />\n </PersistQueryClientProvider>\n )\n }\n\n return (\n <QueryClientProvider client={qc}>\n <AppwriteContext.Provider value={client}>{children}</AppwriteContext.Provider>\n <ReactQueryDevtools initialIsOpen={false} />\n </QueryClientProvider>\n )\n}\n","import { useContext } from 'react'\n\nimport { AppwriteContext } from './AppwriteProvider'\n\n/**\n * Returns the Appwrite client instance from context.\n * Must be used within an {@link AppwriteProvider}. Throws if called outside the provider.\n */\nexport function useAppwrite() {\n const ctx = useContext(AppwriteContext)\n if (!ctx) throw new Error('Wrap your app in <AppwriteProvider>')\n return ctx\n}\n","import { useContext } from 'react'\nimport { QueryClientContext } from '@tanstack/react-query'\n\n/**\n * Returns the TanStack Query `QueryClient` from the nearest `QueryClientProvider`.\n * Throws if called outside a provider.\n */\nexport function useQueryClient() {\n const ctx = useContext(QueryClientContext)\n if (!ctx) throw new Error('Wrap your app in <QueryClientProvider>')\n return ctx\n}\n","import type { UseMutationOptions } from '@tanstack/react-query'\nimport { useMutation as useReactMutation } from '@tanstack/react-query'\n\nimport type { AppwriteException } from './types'\nimport { useQueryClient } from './useQueryClient'\n\n/**\n * Wrapper around TanStack Query's `useMutation` that automatically injects the Appwrite-managed `QueryClient`.\n * Use this instead of importing `useMutation` from `@tanstack/react-query` directly.\n */\nexport function useMutation<\n TData = unknown,\n TError extends AppwriteException[] = [],\n TVariables = void,\n TContext = unknown,\n>(options: UseMutationOptions<TData, TError, TVariables, TContext>) {\n const queryClient = useQueryClient()\n return useReactMutation<TData, TError, TVariables, TContext>(options, queryClient)\n}\n","import type {\n DefinedInitialDataOptions,\n QueryKey,\n UndefinedInitialDataOptions,\n UseQueryOptions,\n} from '@tanstack/react-query'\nimport { useQuery as useReactQuery } from '@tanstack/react-query'\n\nimport type { AppwriteException } from './types'\nimport { useQueryClient } from './useQueryClient'\n\n/**\n * Wrapper around TanStack Query's `useQuery` that automatically injects the Appwrite-managed `QueryClient`.\n * Use this instead of importing `useQuery` from `@tanstack/react-query` directly.\n */\nexport function useQuery<\n TQueryFnData,\n TError extends AppwriteException[],\n TData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options:\n | UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>\n | DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>\n | UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n) {\n const queryClient = useQueryClient()\n return useReactQuery<TQueryFnData, TError, TData, TQueryKey>(options, queryClient)\n}\n","import type {\n DefinedInitialDataOptions,\n QueryKey,\n UndefinedInitialDataOptions,\n UseQueryOptions,\n} from '@tanstack/react-query'\nimport { useQuery as useReactQuery } from '@tanstack/react-query'\n\nimport type { AppwriteException } from './types'\nimport { useQueryClient } from './useQueryClient'\n\n/**\n * Like {@link useQuery}, but the query is disabled by default and only runs when `run()` is called.\n * @returns `{ run, query }` — `run` triggers the fetch, `query` contains the standard query result.\n */\nexport function useLazyQuery<\n TQueryFnData,\n TError extends AppwriteException[],\n TData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options:\n | UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>\n | DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>\n | UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n) {\n const queryClient = useQueryClient()\n const query = useReactQuery<TQueryFnData, TError, TData, TQueryKey>(\n { ...options, enabled: false },\n queryClient,\n )\n\n return { run: query.refetch, query }\n}\n","import type { QueryKey, UseSuspenseQueryOptions } from '@tanstack/react-query'\nimport { useSuspenseQuery as useSuspenseReactQuery } from '@tanstack/react-query'\n\nimport type { AppwriteException } from './types'\nimport { useQueryClient } from './useQueryClient'\n\n/**\n * Wrapper around TanStack Query's `useSuspenseQuery` that automatically injects the Appwrite-managed `QueryClient`.\n * Suspends the component while loading. Use with React Suspense boundaries.\n */\nexport function useSuspenseQuery<\n TQueryFnData,\n TError extends AppwriteException[],\n TData,\n TQueryKey extends QueryKey = QueryKey,\n>(options: UseSuspenseQueryOptions<TQueryFnData, TError, TData, TQueryKey>) {\n const queryClient = useQueryClient()\n return useSuspenseReactQuery<TQueryFnData, TError, TData, TQueryKey>(options, queryClient)\n}\n","import type { ResultOf, TypedDocumentNode } from '@graphql-typed-document-node/core'\nimport { print } from 'graphql'\n\nimport {\n Account,\n Avatars,\n Client,\n Databases,\n Functions,\n Graphql,\n Locale,\n Messaging,\n Realtime,\n type RealtimeLike,\n Storage,\n TablesDB,\n Teams,\n} from './types'\n\ntype Variables = Record<string, unknown>\n\nconst graphqlObject = (graphqlAppwrite: Graphql) => ({\n client: graphqlAppwrite.client,\n query: async <T, V extends Variables = Variables>({\n query,\n variables,\n }: {\n query: TypedDocumentNode<T, V>\n variables?: V\n }) => {\n const { data, errors } = (await graphqlAppwrite.query({\n query: { query: print(query), variables },\n })) as { data: ResultOf<typeof query>; errors: unknown[] }\n return { data, errors }\n },\n mutation: async <T, V extends Variables = Variables>({\n query,\n variables,\n }: {\n query: TypedDocumentNode<T, V>\n variables?: V\n }) => {\n const { data, errors } = (await graphqlAppwrite.mutation({\n query: { query: print(query), variables },\n })) as { data: ResultOf<typeof query>; errors: unknown[] }\n return { data, errors }\n },\n})\n\n/**\n * Creates and configures an Appwrite client with all service instances.\n *\n * @param config - The Appwrite connection config with `endpoint` and `projectId`.\n * @returns An object containing `client`, `account`, `avatars`, `realtime`, `storage`, `graphql`, `databases`, `functions`, `locale`, `messaging`, `tablesDB`, and `teams`.\n *\n * @example\n * ```ts\n * const client = createAppwriteClient({\n * endpoint: 'https://cloud.appwrite.io/v1',\n * projectId: 'my-project',\n * })\n * ```\n */\nexport function createAppwriteClient({\n endpoint,\n projectId,\n}: {\n endpoint: string\n projectId: string\n}) {\n const client = new Client()\n client.setEndpoint(endpoint).setProject(projectId)\n\n return {\n client,\n account: new Account(client),\n avatars: new Avatars(client),\n realtime: (typeof Realtime === 'function' ? new Realtime(client) : client) as RealtimeLike,\n storage: new Storage(client),\n graphql: graphqlObject(new Graphql(client)),\n databases: new Databases(client),\n functions: new Functions(client),\n locale: new Locale(client),\n messaging: new Messaging(client),\n tablesDB: new TablesDB(client),\n teams: new Teams(client),\n }\n}\n\nexport type AppwriteClient = ReturnType<typeof createAppwriteClient>\n","interface Account {\n acc?: string\n}\n\ninterface Database {\n db?: string\n}\n\ninterface Collection {\n col?: string\n}\n\ninterface Document {\n doc?: string\n}\n\ninterface TablesDB {\n tdb?: string\n}\n\ninterface Table {\n tbl?: string\n}\n\ninterface Row {\n row?: string\n}\n\ninterface Bucket {\n bucket?: string\n}\n\ninterface FileResource {\n file?: string\n}\n\ninterface Actionable {\n actionable?: string\n}\n\ninterface Execution {\n exec?: string\n}\n\ninterface Func {\n func?: string\n}\n\ninterface Team {\n team?: string\n}\n\ninterface Membership {\n membership?: string\n}\n\ninterface Locale {\n locale?: string\n}\n\ninterface Messaging {\n messaging?: string\n}\n\ninterface Transaction {\n transaction?: string\n}\n\nexport class Keys<T> {\n private keys: string[] = ['appwrite']\n private _type!: T\n\n private constructor() {}\n\n private static create<T>(...segments: string[]) {\n const k = new Keys<T>()\n k.keys.push(...segments)\n return k\n }\n\n static account() {\n return Keys.create<Account>('account')\n }\n\n static databases() {\n return Keys.create<Database>('databases')\n }\n\n static database(id: string) {\n return Keys.create<Database>('databases', id)\n }\n\n static tablesDB(id: string) {\n return Keys.create<TablesDB>('tablesDB', id)\n }\n\n static buckets() {\n return Keys.create<Bucket>('buckets')\n }\n\n static bucket(id: string) {\n return Keys.create<Bucket>('buckets', id)\n }\n\n static functions() {\n return Keys.create<Func>('functions')\n }\n\n static function(id: string) {\n return Keys.create<Func>('functions', id)\n }\n\n static teams() {\n return Keys.create<Team>('teams')\n }\n\n static team(id: string) {\n return Keys.create<Team>('teams', id)\n }\n\n static locale() {\n return Keys.create<Locale>('locale')\n }\n\n static messaging() {\n return Keys.create<Messaging>('messaging')\n }\n\n jwt(this: Keys<Account>) {\n this.keys.push('jwt')\n return this as unknown as Keys<Actionable>\n }\n\n anonymous(this: Keys<Account>) {\n this.keys.push('anonymous')\n return this as unknown as Keys<Actionable>\n }\n\n emailToken(this: Keys<Account>) {\n this.keys.push('emailToken')\n return this as unknown as Keys<Actionable>\n }\n\n emailVerification(this: Keys<Account>) {\n this.keys.push('emailVerification')\n return this as unknown as Keys<Actionable>\n }\n\n magicUrl(this: Keys<Account>) {\n this.keys.push('magicUrl')\n return this as unknown as Keys<Actionable>\n }\n\n mfaAuthenticator(this: Keys<Account>) {\n this.keys.push('mfaAuthenticator')\n return this as unknown as Keys<Actionable>\n }\n\n mfaChallenge(this: Keys<Account>) {\n this.keys.push('mfaChallenge')\n return this as unknown as Keys<Actionable>\n }\n\n mfaCodes(this: Keys<Account>) {\n this.keys.push('mfaCodes')\n return this as unknown as Keys<Actionable>\n }\n\n oauth2Token(this: Keys<Account>) {\n this.keys.push('oauth2Token')\n return this as unknown as Keys<Actionable>\n }\n\n phoneToken(this: Keys<Account>) {\n this.keys.push('phoneToken')\n return this as unknown as Keys<Actionable>\n }\n\n phoneVerification(this: Keys<Account>) {\n this.keys.push('phoneVerification')\n return this as unknown as Keys<Actionable>\n }\n\n pushTarget(this: Keys<Account>) {\n this.keys.push('pushTarget')\n return this as unknown as Keys<Actionable>\n }\n\n identity(this: Keys<Account>) {\n this.keys.push('identity')\n return this as unknown as Keys<Actionable>\n }\n\n prefs(this: Keys<Account>) {\n this.keys.push('prefs')\n return this as unknown as Keys<Actionable>\n }\n\n login(this: Keys<Account>) {\n this.keys.push('login')\n return this as unknown as Keys<Actionable>\n }\n\n signUp(this: Keys<Account>) {\n this.keys.push('signUp')\n return this as unknown as Keys<Actionable>\n }\n\n name(this: Keys<Account>) {\n this.keys.push('name')\n return this as unknown as Keys<Actionable>\n }\n\n email(this: Keys<Account>) {\n this.keys.push('email')\n return this as unknown as Keys<Actionable>\n }\n\n phone(this: Keys<Account>) {\n this.keys.push('phone')\n return this as unknown as Keys<Actionable>\n }\n\n password(this: Keys<Account>) {\n this.keys.push('password')\n return this as unknown as Keys<Actionable>\n }\n\n recovery(this: Keys<Account>) {\n this.keys.push('recovery')\n return this as unknown as Keys<Actionable>\n }\n\n mfa(this: Keys<Account>) {\n this.keys.push('mfa')\n return this as unknown as Keys<Actionable>\n }\n\n status(this: Keys<Account>) {\n this.keys.push('status')\n return this as unknown as Keys<Actionable>\n }\n\n logs(this: Keys<Account>) {\n this.keys.push('logs')\n return this as unknown as Keys<Actionable>\n }\n\n verification(this: Keys<Account>) {\n this.keys.push('verification')\n return this as unknown as Keys<Actionable>\n }\n\n session(this: Keys<Account>, id?: string) {\n this.keys.push('sessions')\n if (id) this.keys.push(id)\n return this as unknown as Keys<Actionable>\n }\n\n sessions(this: Keys<Account>) {\n return [...this.keys, 'sessions'] as const\n }\n\n identities(this: Keys<Account>) {\n return [...this.keys, 'identities'] as const\n }\n\n mfaFactors(this: Keys<Account>) {\n return [...this.keys, 'mfaFactors'] as const\n }\n\n collections(this: Keys<Database>) {\n this.keys.push('collections')\n return this as unknown as Keys<Collection>\n }\n\n collection(this: Keys<Database>, id: string) {\n this.keys.push('collections', id)\n return this as unknown as Keys<Collection>\n }\n\n transactions(this: Keys<Database>) {\n this.keys.push('transactions')\n return this as unknown as Keys<Transaction>\n }\n\n transaction(this: Keys<Database>, id: string) {\n this.keys.push('transactions', id)\n return this as unknown as Keys<Transaction>\n }\n\n documents(this: Keys<Collection>) {\n this.keys.push('documents')\n return this as unknown as Keys<Actionable>\n }\n\n document(this: Keys<Collection>, id: string) {\n this.keys.push('documents', id)\n return this as unknown as Keys<Document>\n }\n\n operations(this: Keys<Transaction>) {\n this.keys.push('operations')\n return this as unknown as Keys<Actionable>\n }\n\n table(this: Keys<TablesDB>, id: string) {\n this.keys.push('table', id)\n return this as unknown as Keys<Table>\n }\n\n rows(this: Keys<Table>) {\n this.keys.push('rows')\n return this as unknown as Keys<Actionable>\n }\n\n row(this: Keys<Table>, id: string) {\n this.keys.push('row', id)\n return this as unknown as Keys<Row>\n }\n\n files(this: Keys<Bucket>) {\n this.keys.push('files')\n return this as unknown as Keys<Actionable>\n }\n\n file(this: Keys<Bucket>, id: string) {\n this.keys.push('files', id)\n return this as unknown as Keys<FileResource>\n }\n\n executions(this: Keys<Func>) {\n this.keys.push('executions')\n return this as unknown as Keys<Actionable>\n }\n\n execution(this: Keys<Func>, id: string) {\n this.keys.push('executions', id)\n return this as unknown as Keys<Execution>\n }\n\n teamName(this: Keys<Team>) {\n this.keys.push('name')\n return this as unknown as Keys<Actionable>\n }\n\n teamPrefs(this: Keys<Team>) {\n this.keys.push('prefs')\n return this as unknown as Keys<Actionable>\n }\n\n memberships(this: Keys<Team>) {\n this.keys.push('memberships')\n return this as unknown as Keys<Actionable>\n }\n\n membership(this: Keys<Team>, id: string) {\n this.keys.push('memberships', id)\n return this as unknown as Keys<Membership>\n }\n\n membershipStatus(this: Keys<Team>) {\n this.keys.push('membershipStatus')\n return this as unknown as Keys<Actionable>\n }\n\n continents(this: Keys<Locale>) {\n return [...this.keys, 'continents'] as const\n }\n\n countries(this: Keys<Locale>) {\n return [...this.keys, 'countries'] as const\n }\n\n countriesEU(this: Keys<Locale>) {\n return [...this.keys, 'countriesEU'] as const\n }\n\n countriesPhones(this: Keys<Locale>) {\n return [...this.keys, 'countriesPhones'] as const\n }\n\n currencies(this: Keys<Locale>) {\n return [...this.keys, 'currencies'] as const\n }\n\n languages(this: Keys<Locale>) {\n return [...this.keys, 'languages'] as const\n }\n\n codes(this: Keys<Locale>) {\n return [...this.keys, 'codes'] as const\n }\n\n subscriber(this: Keys<Messaging>) {\n this.keys.push('subscriber')\n return this as unknown as Keys<Actionable>\n }\n\n create() {\n return [...this.keys, 'create'] as const\n }\n\n upsert() {\n return [...this.keys, 'upsert'] as const\n }\n\n update() {\n return [...this.keys, 'update'] as const\n }\n\n delete() {\n return [...this.keys, 'delete'] as const\n }\n\n key() {\n return [...this.keys] as const\n }\n}\n","import { graphql as gql } from 'gql.tada'\n\nimport type { AppwriteClient } from '../client'\nimport { Keys } from '../query/Keys'\n\nexport const getAccount = gql(/* GraphQL */ `\n query AccountGet {\n accountGet {\n _id\n name\n email\n prefs {\n data\n }\n }\n }\n`)\n\nexport function getAccountQuery(client: AppwriteClient) {\n return {\n queryKey: Keys.account().key(),\n queryFn: async () => {\n const { data, errors } = await client.graphql.query({\n query: getAccount,\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountGet\n },\n retry: false,\n }\n}\n","import { useEffect, useState } from 'react'\nimport type { ResultOf } from '@graphql-typed-document-node/core'\nimport { Channel } from 'appwrite'\nimport { castDraft, produce } from 'immer'\n\nimport type { getAccount } from './queryOptions'\nimport { getAccountQuery } from './queryOptions'\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Models, Prettify, QueryOptions, RealtimeLike } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useLazyQuery } from '../useLazyQuery'\nimport { useQuery } from '../useQuery'\nimport { useQueryClient } from '../useQueryClient'\n\n/** The result returned by the {@link useAccount} query. */\nexport type AccountResult = Prettify<ResultOf<typeof getAccount>['accountGet']>\n\n/**\n * Lazily fetches the current authenticated user's account. The query is\n * disabled until `run()` is called. Subscribes to real-time account updates\n * once activated.\n *\n * @example\n * ```tsx\n * const { data, run, isLoading } = useLazyAccount()\n *\n * // Call run() to trigger the query\n * run()\n * ```\n *\n * @returns A lazy query result with a `run()` function to trigger fetching ({@link AccountResult}).\n */\nexport function useLazyAccount() {\n const client = useAppwrite()\n const queryClient = useQueryClient()\n const [isActive, setIsActive] = useState(false)\n\n const queryResult = useLazyQuery<AccountResult, AppwriteException[], AccountResult>(\n getAccountQueryOptions(client),\n )\n\n useEffect(() => {\n if (!isActive) return\n\n const subscriptionPromise = subscribe(client.realtime, queryClient)\n return () => {\n void subscriptionPromise.then((sub) => sub.close())\n }\n }, [isActive, client.realtime, queryClient])\n\n return {\n ...queryResult,\n run: () => {\n setIsActive(true)\n return queryResult.run()\n },\n }\n}\n\n/**\n * Fetches the current authenticated user's account and subscribes to\n * real-time updates.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useAccount()\n * ```\n *\n * @param opts - Optional query options to customize caching, refetching, etc.\n * @returns A `UseQueryResult` with the authenticated user's account ({@link AccountResult}).\n */\nexport function useAccount(opts: QueryOptions = {}) {\n const client = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useQuery<AccountResult, AppwriteException[], AccountResult>({\n ...getAccountQueryOptions(client),\n ...opts,\n })\n\n useEffect(() => {\n const subscriptionPromise = subscribe(client.realtime, queryClient)\n return () => {\n void subscriptionPromise.then((sub) => sub.close())\n }\n }, [client.realtime, queryClient])\n\n return queryResult\n}\n\nfunction getAccountQueryOptions(client: ReturnType<typeof useAppwrite>) {\n return getAccountQuery(client)\n}\n\nfunction subscribe<Preferences extends Models.Preferences>(\n realtime: RealtimeLike,\n queryClient: ReturnType<typeof useQueryClient>,\n) {\n return realtime.subscribe<Models.User<Preferences>>(Channel.account(), (response) => {\n const isUpdatingPreferences = response.events.some((event) => event.endsWith('prefs'))\n\n if (isUpdatingPreferences) {\n queryClient.setQueryData<Models.User<Preferences>>(Keys.account().key(), (account) =>\n produce(account, (draft) => {\n if (draft) {\n draft.prefs = castDraft(response.payload.prefs) as typeof draft.prefs\n }\n }),\n )\n\n return\n }\n\n queryClient.setQueryData<Models.User<Preferences>>(Keys.account().key(), response.payload)\n })\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst createAnonymousSession = gql(/* GraphQL */ `\n mutation CreateAnonymousSession {\n accountCreateAnonymousSession {\n _id\n expire\n current\n }\n }\n`)\n\n/** The result returned by the {@link useCreateAnonymousSession} mutation. */\nexport type CreateAnonymousSessionResult = Prettify<\n ResultOf<typeof createAnonymousSession>['accountCreateAnonymousSession']\n>\n\n/**\n * Mutation to create an anonymous session.\n *\n * Invalidates account queries and the anonymous session cache key on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useCreateAnonymousSession()\n *\n * mutate()\n * ```\n *\n * This mutation takes no variables.\n *\n * @returns A `UseMutationResult` with the created session's `_id`, `expire`, and `current` fields.\n */\nexport function useCreateAnonymousSession() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<CreateAnonymousSessionResult, AppwriteException[], void>({\n mutationKey: Keys.account().anonymous().create(),\n mutationFn: async () => {\n const { data, errors } = await graphql.mutation({\n query: createAnonymousSession,\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountCreateAnonymousSession\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: Keys.account().key() })\n void queryClient.invalidateQueries({\n queryKey: Keys.account().anonymous().create(),\n })\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\n\nconst createEmailToken = gql(/* GraphQL */ `\n mutation CreateEmailToken($userId: String!, $email: String!, $phrase: Boolean) {\n accountCreateEmailToken(userId: $userId, email: $email, phrase: $phrase) {\n expire\n }\n }\n`)\n\n/** The variables accepted by the {@link useCreateEmailToken} mutation. */\nexport type CreateEmailTokenVariables = Prettify<VariablesOf<typeof createEmailToken>>\n/** The result returned by the {@link useCreateEmailToken} mutation. */\nexport type CreateEmailTokenResult = Prettify<\n ResultOf<typeof createEmailToken>['accountCreateEmailToken']\n>\n\n/**\n * Mutation to create an email token for passwordless authentication.\n *\n * Sends a token to the user's email that can be exchanged for a session\n * via {@link useCreateSession}.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useCreateEmailToken()\n *\n * mutate({\n * userId: 'user-123',\n * email: 'user@example.com',\n * phrase: true,\n * })\n * ```\n *\n * **Variables** ({@link CreateEmailTokenVariables}):\n * - `userId` — Unique user identifier\n * - `email` — User's email address to send the token to\n * - `phrase` — Optional. When `true`, returns a phrase-based token instead of a numeric code\n *\n * @returns A `UseMutationResult` with the token's `expire` timestamp.\n */\nexport function useCreateEmailToken() {\n const { graphql } = useAppwrite()\n\n const queryResult = useMutation<\n CreateEmailTokenResult,\n AppwriteException[],\n CreateEmailTokenVariables\n >({\n mutationKey: Keys.account().emailToken().create(),\n mutationFn: async ({ userId, email, phrase }) => {\n const { data, errors } = await graphql.mutation({\n query: createEmailToken,\n variables: {\n userId,\n email,\n phrase,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountCreateEmailToken\n },\n })\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\nimport { useSuspenseQuery } from '../useSuspenseQuery'\n\n//The documentation says there should be a duration parameter, but including one causes a server error.\nconst accountCreateJWT = gql(/* GraphQL */ `\n mutation CreateJWT {\n accountCreateJWT {\n jwt\n }\n }\n`)\n\n/** The result returned by the {@link useCreateJWT} mutation. */\nexport type CreateJWTResult = Prettify<ResultOf<typeof accountCreateJWT>['accountCreateJWT']>\n\n/**\n * Mutation to create a JSON Web Token for the current session.\n *\n * On success, the JWT is automatically set on the GraphQL client via\n * `graphql.client.setJWT()` and cached in the query store. The token\n * is garbage-collected after `gcTime` milliseconds (default: 10 minutes).\n *\n * @example\n * ```tsx\n * const { mutate, data, isPending } = useCreateJWT()\n *\n * // Create a JWT with default 10-minute gc time\n * mutate()\n *\n * // Access the token\n * console.log(data?.jwt)\n * ```\n *\n * @example\n * ```tsx\n * // Custom gc time (30 minutes)\n * const { mutate } = useCreateJWT({ gcTime: 1800000 })\n * ```\n *\n * This mutation takes no variables.\n *\n * @param opts - Optional config. `gcTime` controls garbage collection time (default: 10 minutes).\n * @returns A `UseMutationResult` with the created `jwt` string.\n */\nexport function useCreateJWT({ gcTime = 600000 }: { gcTime?: number } = {}) {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<CreateJWTResult, AppwriteException[], void>({\n gcTime,\n mutationKey: Keys.account().jwt().create(),\n mutationFn: async () => {\n const { data, errors } = await graphql.mutation({\n query: accountCreateJWT,\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountCreateJWT\n },\n onSuccess: (data) => {\n graphql.client.setJWT(data.jwt)\n queryClient.setQueryData(Keys.account().jwt().create(), data.jwt, {\n updatedAt: Date.now(),\n })\n },\n })\n\n return queryResult\n}\n\n/**\n * Suspense variant of {@link useCreateJWT}.\n *\n * Suspends the component while creating the JWT. Sets the JWT on the\n * GraphQL client automatically on success. Ideal for use with React\n * `<Suspense>` boundaries.\n *\n * @example\n * ```tsx\n * // Wrap in a <Suspense> boundary\n * const { data } = useSuspenseCreateJWT()\n *\n * // JWT is guaranteed to be available after suspension resolves\n * console.log(data.jwt)\n * ```\n *\n * This query takes no variables.\n *\n * @param opts - Optional config. `gcTime` controls garbage collection time (default: 10 minutes).\n * @returns A `UseSuspenseQueryResult` with the created `jwt` string.\n */\nexport function useSuspenseCreateJWT({ gcTime = 600000 }: { gcTime?: number } = {}) {\n const { graphql } = useAppwrite()\n\n const queryResult = useSuspenseQuery<CreateJWTResult, AppwriteException[], CreateJWTResult>({\n gcTime,\n queryKey: Keys.account().jwt().create(),\n queryFn: async () => {\n const { data, errors } = await graphql.mutation({\n query: accountCreateJWT,\n })\n\n if (errors) {\n throw errors\n }\n\n graphql.client.setJWT(data.accountCreateJWT.jwt)\n return data.accountCreateJWT\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\n\nconst createMagicURLToken = gql(/* GraphQL */ `\n mutation CreateMagicURLToken($userId: String!, $email: String!, $url: String, $phrase: Boolean) {\n accountCreateMagicURLToken(userId: $userId, email: $email, url: $url, phrase: $phrase) {\n expire\n }\n }\n`)\n\n/** The variables accepted by the {@link useCreateMagicURLToken} mutation. */\nexport type CreateMagicURLTokenVariables = Prettify<VariablesOf<typeof createMagicURLToken>>\n/** The result returned by the {@link useCreateMagicURLToken} mutation. */\nexport type CreateMagicURLTokenResult = Prettify<\n ResultOf<typeof createMagicURLToken>['accountCreateMagicURLToken']\n>\n\n/**\n * Mutation to send a magic URL login token to a user's email.\n *\n * The magic URL link contains a `userId` and `secret` that can be used\n * with {@link useUpdateMagicURLSession} to create a session.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useCreateMagicURLToken()\n *\n * mutate({\n * userId: 'user-123',\n * email: 'user@example.com',\n * url: 'https://example.com/magic-login',\n * phrase: true,\n * })\n * ```\n *\n * **Variables** ({@link CreateMagicURLTokenVariables}):\n * - `userId` — Unique user identifier\n * - `email` — User's email address to send the magic URL to\n * - `url` — Optional. Custom URL for the magic link redirect\n * - `phrase` — Optional. When `true`, returns a phrase-based token instead of a numeric code\n *\n * @returns A `UseMutationResult` with the token's `expire` timestamp.\n */\nexport function useCreateMagicURLToken() {\n const { graphql } = useAppwrite()\n\n const queryResult = useMutation<\n CreateMagicURLTokenResult,\n AppwriteException[],\n CreateMagicURLTokenVariables\n >({\n mutationKey: Keys.account().magicUrl().create(),\n mutationFn: async ({ userId, email, url, phrase }) => {\n const { data, errors } = await graphql.mutation({\n query: createMagicURLToken,\n variables: {\n userId,\n email,\n url,\n phrase,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountCreateMagicURLToken\n },\n })\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { AuthenticatorType } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst accountCreateMfaAuthenticator = gql(/* GraphQL */ `\n mutation CreateMfaAuthenticator($type: String!) {\n accountCreateMfaAuthenticator(type: $type) {\n secret\n uri\n }\n }\n`)\n\ntype Vars = {\n /** The authenticator type. Defaults to `AuthenticatorType.Totp`. */\n type?: AuthenticatorType\n}\n/** The variables accepted by the {@link useCreateMfaAuthenticator} mutation. */\nexport type CreateMfaAuthenticatorVariables = Prettify<Vars>\n/** The result returned by the {@link useCreateMfaAuthenticator} mutation. */\nexport type CreateMfaAuthenticatorResult = Prettify<\n ResultOf<typeof accountCreateMfaAuthenticator>['accountCreateMfaAuthenticator']\n>\n\n/**\n * Mutation to create an MFA authenticator (e.g., TOTP).\n *\n * Returns a `secret` and `uri` that can be used to generate a QR code\n * for the user to scan with an authenticator app. The authenticator must\n * be verified with {@link useUpdateMfaAuthenticator} before it becomes active.\n * Invalidates MFA authenticator queries on success.\n *\n * @example\n * ```tsx\n * import { AuthenticatorType } from '@zeroin.earth/appwrite-graphql'\n *\n * const { mutate, data, isPending } = useCreateMfaAuthenticator()\n *\n * mutate({ type: AuthenticatorType.Totp })\n *\n * // Use data.uri to generate a QR code\n * // Use data.secret as a manual entry fallback\n * ```\n *\n * **Variables** ({@link CreateMfaAuthenticatorVariables}):\n * - `type` — The authenticator type ({@link AuthenticatorType}). Defaults to `AuthenticatorType.Totp`.\n *\n * @returns A `UseMutationResult` with the authenticator's `secret` and `uri` for QR code generation.\n */\nexport function useCreateMfaAuthenticator() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<\n CreateMfaAuthenticatorResult,\n AppwriteException[],\n CreateMfaAuthenticatorVariables\n >({\n mutationKey: Keys.account().mfaAuthenticator().create(),\n mutationFn: async ({ type = AuthenticatorType.Totp }) => {\n const { data, errors } = await graphql.mutation({\n query: accountCreateMfaAuthenticator,\n variables: {\n type,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountCreateMfaAuthenticator\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({\n queryKey: Keys.account().mfaAuthenticator().key(),\n })\n },\n })\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, AuthenticationFactor, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\n\nconst accountCreateMfaChallenge = gql(/* GraphQL */ `\n mutation CreateMfaChallenge($factor: String!) {\n accountCreateMfaChallenge(factor: $factor) {\n _id\n userId\n expire\n }\n }\n`)\n\ntype Vars = {\n /** The authentication factor. Defaults to `AuthenticatorType.Totp`. */\n factor: AuthenticationFactor\n}\n/** The variables accepted by the {@link useCreateMfaChallenge} mutation. */\nexport type CreateMfaChallengeVariables = Prettify<Vars>\n/** The result returned by the {@link useCreateMfaChallenge} mutation. */\nexport type CreateMfaChallengeResult = Prettify<\n ResultOf<typeof accountCreateMfaChallenge>['accountCreateMfaChallenge']\n>\n\n/**\n * Mutation to create an MFA challenge for a given factor (e.g., `\"totp\"`, `\"phone\"`, `\"email\"`).\n *\n * Creates a challenge that must be completed with {@link useUpdateMfaChallenge}\n * by providing the challenge ID and the one-time password.\n *\n * @example\n * ```tsx\n * const { mutate, data, isPending } = useCreateMfaChallenge()\n *\n * mutate({ factor: 'totp' })\n *\n * // Use data._id as the challengeId for useUpdateMfaChallenge\n * ```\n *\n * **Variables** ({@link CreateMfaChallengeVariables}):\n * - `factor` — The MFA factor to challenge (e.g., `\"totp\"`, `\"phone\"`, `\"email\"`)\n *\n * @returns A `UseMutationResult` with the challenge's `_id`, `userId`, and `expire` fields.\n */\nexport function useCreateMfaChallenge() {\n const { graphql } = useAppwrite()\n\n const queryResult = useMutation<\n CreateMfaChallengeResult,\n AppwriteException[],\n CreateMfaChallengeVariables\n >({\n mutationKey: Keys.account().mfaChallenge().create(),\n mutationFn: async ({ factor }) => {\n const { data, errors } = await graphql.mutation({\n query: accountCreateMfaChallenge,\n variables: {\n factor,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountCreateMfaChallenge\n },\n })\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst accountCreateMfaRecoveryCodes = gql(/* GraphQL */ `\n mutation CreateMfaRecoveryCodes {\n accountCreateMfaRecoveryCodes {\n recoveryCodes\n }\n }\n`)\n\n/** The result returned by the {@link useCreateMfaRecoveryCodes} mutation. */\nexport type CreateMfaRecoveryCodesResult = Prettify<\n ResultOf<typeof accountCreateMfaRecoveryCodes>['accountCreateMfaRecoveryCodes']\n>\n\n/**\n * Mutation to generate MFA recovery codes.\n *\n * Generates a new set of recovery codes that can be used as a backup\n * when the primary MFA method is unavailable. Invalidates recovery code\n * queries on success. Use {@link useUpdateMfaRecoveryCodes} to regenerate codes.\n *\n * @example\n * ```tsx\n * const { mutate, data, isPending } = useCreateMfaRecoveryCodes()\n *\n * mutate()\n *\n * // Display data.recoveryCodes to the user for safekeeping\n * ```\n *\n * This mutation takes no variables.\n *\n * @returns A `UseMutationResult` with a `recoveryCodes` array of backup codes.\n */\nexport function useCreateMfaRecoveryCodes() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<CreateMfaRecoveryCodesResult, AppwriteException[], void>({\n mutationKey: Keys.account().mfaCodes().create(),\n mutationFn: async () => {\n const { data, errors } = await graphql.mutation({\n query: accountCreateMfaRecoveryCodes,\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountCreateMfaRecoveryCodes\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({\n queryKey: Keys.account().mfaCodes().key(),\n })\n },\n })\n\n return queryResult\n}\n","import { Keys } from '../query/Keys'\nimport type { AppwriteException, OAuthProvider, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\n\ntype Vars = {\n provider: OAuthProvider\n success?: string\n failure?: string\n scopes?: string[]\n}\n\n/** The variables accepted by the {@link useCreateOAuth2Token} mutation. */\nexport type CreateOAuth2TokenVariables = Prettify<Vars>\n\n/**\n * Mutation to create an OAuth2 authentication token.\n *\n * Triggers the OAuth2 flow using the Appwrite REST SDK (not GraphQL).\n * On web, this typically redirects the user to the provider's authorization page.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useCreateOAuth2Token()\n *\n * mutate({\n * provider: OAuthProvider.Google,\n * success: 'https://example.com/auth/callback',\n * failure: 'https://example.com/auth/error',\n * scopes: ['email', 'profile'],\n * })\n * ```\n *\n * **Variables** ({@link CreateOAuth2TokenVariables}):\n * - `provider` — The OAuth2 provider (e.g., `OAuthProvider.Google`, `OAuthProvider.GitHub`)\n * - `success` — Optional. URL to redirect to on successful authentication\n * - `failure` — Optional. URL to redirect to on failed authentication\n * - `scopes` — Optional. Array of OAuth2 scopes to request from the provider\n *\n * @returns A `UseMutationResult` that resolves to `void` or a redirect URL string.\n */\nexport function useCreateOAuth2Token() {\n const { account } = useAppwrite()\n\n const queryResult = useMutation<void | string, AppwriteException[], CreateOAuth2TokenVariables>({\n mutationKey: Keys.account().oauth2Token().create(),\n mutationFn: async ({ provider, success, failure, scopes }) => {\n return account.createOAuth2Token({ provider, success, failure, scopes })\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\n\nconst createPhoneToken = gql(/* GraphQL */ `\n mutation CreatePhoneToken($userId: String!, $phone: String!) {\n accountCreatePhoneToken(userId: $userId, phone: $phone) {\n expire\n }\n }\n`)\n\n/** The variables accepted by the {@link useCreatePhoneToken} mutation. */\nexport type CreatePhoneTokenVariables = Prettify<VariablesOf<typeof createPhoneToken>>\n/** The result returned by the {@link useCreatePhoneToken} mutation. */\nexport type CreatePhoneTokenResult = Prettify<\n ResultOf<typeof createPhoneToken>['accountCreatePhoneToken']\n>\n\n/**\n * Mutation to send a phone token for SMS-based authentication.\n *\n * Sends a verification code via SMS that can be exchanged for a session\n * using {@link useCreateSession} or {@link useUpdatePhoneSession}.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useCreatePhoneToken()\n *\n * mutate({\n * userId: 'user-123',\n * phone: '+14155551234',\n * })\n * ```\n *\n * **Variables** ({@link CreatePhoneTokenVariables}):\n * - `userId` — Unique user identifier\n * - `phone` — User's phone number in E.164 format (e.g., `\"+14155551234\"`)\n *\n * @returns A `UseMutationResult` with the token's `expire` timestamp.\n */\nexport function useCreatePhoneToken() {\n const { graphql } = useAppwrite()\n\n const queryResult = useMutation<\n CreatePhoneTokenResult,\n AppwriteException[],\n CreatePhoneTokenVariables\n >({\n mutationKey: Keys.account().phoneToken().create(),\n mutationFn: async ({ userId, phone }) => {\n const { data, errors } = await graphql.mutation({\n query: createPhoneToken,\n variables: {\n userId,\n phone,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountCreatePhoneToken\n },\n })\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\n\nconst createPhoneVerification = gql(/* GraphQL */ `\n mutation CreatePhoneVerification {\n accountCreatePhoneVerification {\n expire\n }\n }\n`)\n\n/** The result returned by the {@link useCreatePhoneVerification} mutation. */\nexport type CreatePhoneVerificationResult = Prettify<\n ResultOf<typeof createPhoneVerification>['accountCreatePhoneVerification']\n>\n\n/**\n * Mutation to send a phone verification SMS to the current user.\n *\n * Sends a verification code to the phone number associated with the\n * currently authenticated user. Complete the verification with\n * {@link useUpdatePhoneVerification}.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useCreatePhoneVerification()\n *\n * mutate()\n * ```\n *\n * This mutation takes no variables.\n *\n * @returns A `UseMutationResult` with the verification's `expire` timestamp.\n */\nexport function useCreatePhoneVerification() {\n const { graphql } = useAppwrite()\n\n const queryResult = useMutation<CreatePhoneVerificationResult, AppwriteException[], void>({\n mutationKey: Keys.account().phoneVerification().create(),\n mutationFn: async () => {\n const { data, errors } = await graphql.mutation({\n query: createPhoneVerification,\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountCreatePhoneVerification\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst accountCreatePushTarget = gql(/* GraphQL */ `\n mutation CreatePushTarget($targetId: String!, $identifier: String!, $providerId: String) {\n accountCreatePushTarget(targetId: $targetId, identifier: $identifier, providerId: $providerId) {\n _id\n userId\n providerType\n identifier\n }\n }\n`)\n\n/** The variables accepted by the {@link useCreatePushTarget} mutation. */\nexport type CreatePushTargetVariables = Prettify<VariablesOf<typeof accountCreatePushTarget>>\n/** The result returned by the {@link useCreatePushTarget} mutation. */\nexport type CreatePushTargetResult = Prettify<\n ResultOf<typeof accountCreatePushTarget>['accountCreatePushTarget']\n>\n\n/**\n * Mutation to register a push notification target for the current user.\n *\n * Registers a device token so the user can receive push notifications.\n * Invalidates account queries on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useCreatePushTarget()\n *\n * mutate({\n * targetId: 'target-123',\n * identifier: 'fcm-device-token-abc',\n * providerId: 'firebase-provider',\n * })\n * ```\n *\n * **Variables** ({@link CreatePushTargetVariables}):\n * - `targetId` — Unique target identifier for the push target\n * - `identifier` — The device token or registration ID from the push notification service\n * - `providerId` — Optional. The messaging provider ID configured in Appwrite\n *\n * @returns A `UseMutationResult` with the push target's `_id`, `userId`, `providerType`, and `identifier`.\n */\nexport function useCreatePushTarget() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<\n CreatePushTargetResult,\n AppwriteException[],\n CreatePushTargetVariables\n >({\n mutationKey: Keys.account().pushTarget().create(),\n mutationFn: async ({ targetId, identifier, providerId }) => {\n const { data, errors } = await graphql.mutation({\n query: accountCreatePushTarget,\n variables: {\n targetId,\n identifier,\n providerId,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountCreatePushTarget\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: Keys.account().key() })\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst createSession = gql(/* GraphQL */ `\n mutation CreateSession($userId: String!, $secret: String!) {\n accountCreateSession(userId: $userId, secret: $secret) {\n userId\n expire\n current\n }\n }\n`)\n\n/** The variables accepted by the {@link useCreateSession} mutation. */\nexport type CreateSessionVariables = Prettify<VariablesOf<typeof createSession>>\n/** The result returned by the {@link useCreateSession} mutation. */\nexport type CreateSessionResult = Prettify<ResultOf<typeof createSession>['accountCreateSession']>\n\n/**\n * Mutation to create a session using a `userId` and `secret` (e.g., from an email/phone token).\n *\n * Exchanges a token pair for a full session. Typically used after\n * {@link useCreateEmailToken} or {@link useCreatePhoneToken}. Invalidates\n * account and session queries on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useCreateSession()\n *\n * mutate({\n * userId: 'user-123',\n * secret: 'token-secret-from-email',\n * })\n * ```\n *\n * **Variables** ({@link CreateSessionVariables}):\n * - `userId` — The user's ID received from the token creation step\n * - `secret` — The secret received from the token creation step\n *\n * @returns A `UseMutationResult` with the session's `userId`, `expire`, and `current` fields.\n */\nexport function useCreateSession() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<CreateSessionResult, AppwriteException[], CreateSessionVariables>(\n {\n mutationKey: Keys.account().session().create(),\n mutationFn: async ({ userId, secret }) => {\n const { data, errors } = await graphql.mutation({\n query: createSession,\n variables: {\n userId,\n secret,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountCreateSession\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: Keys.account().key() })\n void queryClient.invalidateQueries({\n queryKey: Keys.account().sessions(),\n })\n },\n },\n )\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\n\nconst createEmailVerification = gql(/* GraphQL */ `\n mutation CreateEmailVerification($url: String!) {\n accountCreateEmailVerification(url: $url) {\n _id\n userId\n secret\n expire\n }\n }\n`)\n\n/** The variables accepted by the {@link useCreateEmailVerification} mutation. */\nexport type CreateEmailVerificationVariables = Prettify<VariablesOf<typeof createEmailVerification>>\n/** The result returned by the {@link useCreateEmailVerification} mutation. */\nexport type CreateEmailVerificationResult = Prettify<\n ResultOf<typeof createEmailVerification>['accountCreateEmailVerification']\n>\n\n/**\n * Mutation to send an email verification link to the current user.\n *\n * The verification link redirects the user to the provided URL with `userId`\n * and `secret` query parameters that can be used with {@link useUpdateEmailVerification}\n * to complete the verification.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useCreateEmailVerification()\n *\n * mutate({\n * url: 'https://example.com/verify-email',\n * })\n * ```\n *\n * **Variables** ({@link CreateEmailVerificationVariables}):\n * - `url` — The URL to redirect the user to after clicking the verification link\n *\n * @returns A `UseMutationResult` with the verification token's `_id`, `userId`, `secret`, and `expire` fields.\n */\nexport function useCreateEmailVerification() {\n const { graphql } = useAppwrite()\n\n const queryResult = useMutation<\n CreateEmailVerificationResult,\n AppwriteException[],\n CreateEmailVerificationVariables\n >({\n mutationKey: Keys.account().emailVerification().create(),\n mutationFn: async ({ url }) => {\n const { data, errors } = await graphql.mutation({\n query: createEmailVerification,\n variables: { url },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountCreateEmailVerification\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst accountDeleteIdentity = gql(/* GraphQL */ `\n mutation DeleteIdentity($identityId: String!) {\n accountDeleteIdentity(identityId: $identityId) {\n status\n }\n }\n`)\n\n/** The variables accepted by the {@link useDeleteIdentity} mutation. */\nexport type DeleteIdentityVariables = Prettify<VariablesOf<typeof accountDeleteIdentity>>\n/** The result returned by the {@link useDeleteIdentity} mutation. */\nexport type DeleteIdentityResult = Prettify<\n ResultOf<typeof accountDeleteIdentity>['accountDeleteIdentity']\n>\n\n/**\n * Mutation hook to delete an identity by its ID.\n *\n * Removes an OAuth2 or other external identity linked to the current user's\n * account. Invalidates account queries on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useDeleteIdentity()\n *\n * mutate({ identityId: 'identity-123' })\n * ```\n *\n * **Variables** ({@link DeleteIdentityVariables}):\n * - `identityId` — The ID of the identity to delete\n *\n * @returns A `UseMutationResult` with a `status` string indicating the operation result.\n */\nexport function useDeleteIdentity() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<\n DeleteIdentityResult,\n AppwriteException[],\n DeleteIdentityVariables\n >({\n mutationKey: Keys.account().identity().delete(),\n mutationFn: async ({ identityId }) => {\n const { data, errors } = await graphql.mutation({\n query: accountDeleteIdentity,\n variables: {\n identityId,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data?.accountDeleteIdentity ?? { status: '' }\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: Keys.account().key() })\n },\n })\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { AuthenticatorType } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst deleteMFAAuthenticator = gql(/* GraphQL */ `\n mutation DeleteMfaAuthenticator($type: String!) {\n accountDeleteMfaAuthenticator(type: $type) {\n status\n }\n }\n`)\n\ntype Vars = {\n /** The authenticator type to delete. Defaults to `AuthenticatorType.Totp`. */\n type?: AuthenticatorType\n}\n/** The variables accepted by the {@link useDeleteMfaAuthenticator} mutation. */\nexport type DeleteMfaAuthenticatorVariables = Prettify<Vars>\n/** The result returned by the {@link useDeleteMfaAuthenticator} mutation. */\nexport type DeleteMfaAuthenticatorResult = Prettify<\n ResultOf<typeof deleteMFAAuthenticator>['accountDeleteMfaAuthenticator']\n>\n\n/**\n * Mutation hook to delete an MFA authenticator by type (defaults to `\"totp\"`).\n *\n * Removes the specified authenticator from the user's account. Invalidates\n * account and MFA authenticator queries on success.\n *\n * @example\n * ```tsx\n * import { AuthenticatorType } from '@zeroin.earth/appwrite-graphql'\n *\n * const { mutate, isPending } = useDeleteMfaAuthenticator()\n *\n * mutate({ type: AuthenticatorType.Totp })\n * ```\n *\n * **Variables** ({@link DeleteMfaAuthenticatorVariables}):\n * - `type` — The authenticator type to delete ({@link AuthenticatorType}). Defaults to `AuthenticatorType.Totp`.\n *\n * @returns A `UseMutationResult` with a `status` string indicating the operation result.\n */\nexport function useDeleteMfaAuthenticator() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<\n DeleteMfaAuthenticatorResult,\n AppwriteException[],\n DeleteMfaAuthenticatorVariables\n >({\n mutationKey: Keys.account().mfaAuthenticator().delete(),\n mutationFn: async ({ type = AuthenticatorType.Totp }) => {\n const { data, errors } = await graphql.mutation({\n query: deleteMFAAuthenticator,\n variables: {\n type,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data?.accountDeleteMfaAuthenticator ?? { status: '' }\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: Keys.account().key() })\n void queryClient.invalidateQueries({\n queryKey: Keys.account().mfaAuthenticator().key(),\n })\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst accountDeletePushTarget = gql(/* GraphQL */ `\n mutation DeletePushTarget($targetId: String!) {\n accountDeletePushTarget(targetId: $targetId) {\n status\n }\n }\n`)\n\n/** The variables accepted by the {@link useDeletePushTarget} mutation. */\nexport type DeletePushTargetVariables = Prettify<VariablesOf<typeof accountDeletePushTarget>>\n/** The result returned by the {@link useDeletePushTarget} mutation. */\nexport type DeletePushTargetResult = Prettify<\n ResultOf<typeof accountDeletePushTarget>['accountDeletePushTarget']\n>\n\n/**\n * Mutation hook to delete a push notification target by its ID.\n *\n * Unregisters the device from receiving push notifications. Invalidates\n * account queries on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useDeletePushTarget()\n *\n * mutate({ targetId: 'target-123' })\n * ```\n *\n * **Variables** ({@link DeletePushTargetVariables}):\n * - `targetId` — The ID of the push target to delete\n *\n * @returns A `UseMutationResult` with a `status` string indicating the operation result.\n */\nexport function useDeletePushTarget() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<\n DeletePushTargetResult,\n AppwriteException[],\n DeletePushTargetVariables\n >({\n mutationKey: Keys.account().pushTarget().delete(),\n mutationFn: async ({ targetId }) => {\n const { data, errors } = await graphql.mutation({\n query: accountDeletePushTarget,\n variables: {\n targetId,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data?.accountDeletePushTarget ?? { status: '' }\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: Keys.account().key() })\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst deleteSession = gql(/* GraphQL */ `\n mutation DeleteSession($sessionId: String!) {\n accountDeleteSession(sessionId: $sessionId) {\n status\n }\n }\n`)\n\n/** The variables accepted by the {@link useDeleteSession} mutation. */\nexport type DeleteSessionVariables = Prettify<VariablesOf<typeof deleteSession>>\n/** The result returned by the {@link useDeleteSession} mutation. */\nexport type DeleteSessionResult = Prettify<ResultOf<typeof deleteSession>['accountDeleteSession']>\n\n/**\n * Mutation hook to delete a specific session by its ID.\n *\n * Removes the session without clearing the entire query cache (unlike\n * {@link useLogout} or {@link useDeleteSessions}). Invalidates session\n * list queries on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useDeleteSession()\n *\n * mutate({ sessionId: 'session-abc' })\n * ```\n *\n * **Variables** ({@link DeleteSessionVariables}):\n * - `sessionId` — The ID of the session to delete\n *\n * @returns A `UseMutationResult` with a `status` string indicating the operation result.\n */\nexport function useDeleteSession() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<DeleteSessionResult, AppwriteException[], DeleteSessionVariables>(\n {\n mutationKey: Keys.account().session().delete(),\n mutationFn: async ({ sessionId }) => {\n const { data, errors } = await graphql.mutation({\n query: deleteSession,\n variables: {\n sessionId,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data?.accountDeleteSession ?? { status: '' }\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({\n queryKey: Keys.account().sessions(),\n })\n },\n },\n )\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst deleteSessions = gql(/* GraphQL */ `\n mutation DeleteSessions {\n accountDeleteSessions {\n status\n }\n }\n`)\n\n/** The result returned by the {@link useDeleteSessions} mutation. */\nexport type DeleteSessionsResult = Prettify<\n ResultOf<typeof deleteSessions>['accountDeleteSessions']\n>\n\n/**\n * Mutation hook to delete all sessions for the current user.\n *\n * Logs the user out of every device. Invalidates account and session queries\n * and **clears the entire query cache** on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useDeleteSessions()\n *\n * mutate()\n * ```\n *\n * This mutation takes no variables.\n *\n * @returns A `UseMutationResult` with a `status` string indicating the operation result.\n */\nexport function useDeleteSessions() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<DeleteSessionsResult, AppwriteException[], void>({\n mutationKey: Keys.account().session().delete(),\n mutationFn: async () => {\n const { data, errors } = await graphql.mutation({\n query: deleteSessions,\n })\n\n if (errors) {\n throw errors\n }\n\n return data?.accountDeleteSessions ?? { status: '' }\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: Keys.account().key() })\n void queryClient.invalidateQueries({\n queryKey: Keys.account().sessions(),\n })\n queryClient.clear()\n },\n })\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify, QueryOptions } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst getMFARecoveryCodes = gql(/* GraphQL */ `\n query GetMfaRecoveryCodes {\n accountGetMfaRecoveryCodes {\n recoveryCodes\n }\n }\n`)\n\n/** The result returned by the {@link useGetMfaRecoveryCodes} query. */\nexport type GetMfaRecoveryCodesResult = Prettify<\n ResultOf<typeof getMFARecoveryCodes>['accountGetMfaRecoveryCodes']\n>\n\n/**\n * Fetches the current user's MFA recovery codes.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useGetMfaRecoveryCodes()\n * ```\n *\n * @returns A `UseQueryResult` with the user's MFA recovery codes ({@link GetMfaRecoveryCodesResult}).\n */\nexport function useGetMfaRecoveryCodes(opts: QueryOptions = {}) {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<\n GetMfaRecoveryCodesResult,\n AppwriteException[],\n GetMfaRecoveryCodesResult\n >({\n queryKey: Keys.account().mfaCodes().key(),\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: getMFARecoveryCodes,\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountGetMfaRecoveryCodes\n },\n ...opts,\n })\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify, QueryOptions } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst accountGetPrefs = gql(/* GraphQL */ `\n query GetPrefs {\n accountGetPrefs {\n data\n }\n }\n`)\n\n/** The result returned by the {@link useGetPrefs} query. */\nexport type GetPrefsResult = Prettify<ResultOf<typeof accountGetPrefs>['accountGetPrefs']>\n\n/**\n * Fetches the current user's account preferences.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useGetPrefs()\n * ```\n *\n * @returns A `UseQueryResult` with the user's account preferences ({@link GetPrefsResult}).\n */\nexport function useGetPrefs(opts: QueryOptions = {}) {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<GetPrefsResult, AppwriteException[], GetPrefsResult>({\n queryKey: Keys.account().prefs().key(),\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: accountGetPrefs,\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountGetPrefs\n },\n ...opts,\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify, QueryOptions } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst getSession = gql(/* GraphQL */ `\n query GetSession($sessionId: String!) {\n accountGetSession(sessionId: $sessionId) {\n userId\n expire\n current\n }\n }\n`)\n\n/** The variables accepted by the {@link useGetSession} query. */\nexport type GetSessionVariables = Prettify<VariablesOf<typeof getSession>>\n/** The result returned by the {@link useGetSession} query. */\nexport type GetSessionResult = Prettify<ResultOf<typeof getSession>['accountGetSession']>\n\n/**\n * Fetches a specific session by its ID.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useGetSession({ sessionId: 'current' })\n * ```\n *\n * **Parameters** ({@link GetSessionVariables}):\n * - `sessionId` — The ID of the session to retrieve (use `'current'` for the active session).\n *\n * @returns A `UseQueryResult` with the requested session ({@link GetSessionResult}).\n */\nexport function useGetSession({ sessionId }: GetSessionVariables, opts: QueryOptions = {}) {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<GetSessionResult, AppwriteException[], GetSessionResult>({\n queryKey: Keys.account().session(sessionId).key(),\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: getSession,\n variables: { sessionId },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountGetSession\n },\n ...opts,\n })\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify, QueryOptions } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst accountListIdentities = gql(/* GraphQL */ `\n query ListIdentities {\n accountListIdentities {\n total\n identities {\n _id\n userId\n provider\n }\n }\n }\n`)\n\n/** The result returned by the {@link useListIdentities} query. */\nexport type ListIdentitiesResult = Prettify<\n ResultOf<typeof accountListIdentities>['accountListIdentities']\n>\n\n/**\n * Fetches the list of identities associated with the current user's account.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useListIdentities()\n * ```\n *\n * @returns A `UseQueryResult` with the user's identities ({@link ListIdentitiesResult}).\n */\nexport function useListIdentities(opts: QueryOptions = {}) {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<ListIdentitiesResult, AppwriteException[], ListIdentitiesResult>({\n queryKey: Keys.account().identities(),\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: accountListIdentities,\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountListIdentities\n },\n ...opts,\n })\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify, QueryOptions } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst listMFAFactors = gql(/* GraphQL */ `\n query ListMfaFactors {\n accountListMfaFactors {\n totp\n phone\n email\n }\n }\n`)\n\n/** The result returned by the {@link useListMfaFactors} query. */\nexport type ListMfaFactorsResult = Prettify<\n ResultOf<typeof listMFAFactors>['accountListMfaFactors']\n>\n\n/**\n * Fetches the available MFA factors (TOTP, phone, email) for the current user.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useListMfaFactors()\n * ```\n *\n * @returns A `UseQueryResult` with the user's MFA factors ({@link ListMfaFactorsResult}).\n */\nexport function useListMfaFactors(opts: QueryOptions = {}) {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<ListMfaFactorsResult, AppwriteException[], ListMfaFactorsResult>({\n queryKey: Keys.account().mfaFactors(),\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: listMFAFactors,\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountListMfaFactors\n },\n ...opts,\n })\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify, QueryOptions } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst accountListSessions = gql(/* GraphQL */ `\n query ListSessions {\n accountListSessions {\n sessions {\n _id\n _createdAt\n osName\n clientName\n }\n }\n }\n`)\n\n/** The result returned by the {@link useListSessions} query. */\nexport type ListSessionsResult = Prettify<\n ResultOf<typeof accountListSessions>['accountListSessions']\n>\n\n/**\n * Fetches all active sessions for the current user.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useListSessions()\n * ```\n *\n * @returns A `UseQueryResult` with the user's active sessions ({@link ListSessionsResult}).\n */\nexport function useListSessions(opts: QueryOptions = {}) {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<ListSessionsResult, AppwriteException[], ListSessionsResult>({\n queryKey: Keys.account().sessions(),\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: accountListSessions,\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountListSessions\n },\n ...opts,\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, OAuthProvider, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\n/** The variables accepted by the OAuth login mutation in {@link useLogin}. */\nexport type OAuthLoginVariables = {\n provider: OAuthProvider\n success?: string\n failure?: string\n}\n\nconst accountCreateEmailPasswordSession = gql(/* GraphQL */ `\n mutation CreateEmailPasswordSession($email: String!, $password: String!) {\n accountCreateEmailPasswordSession(email: $email, password: $password) {\n userId\n expire\n current\n }\n }\n`)\n\n/** The variables accepted by the {@link useLogin} mutation. */\nexport type LoginVariables = Prettify<VariablesOf<typeof accountCreateEmailPasswordSession>>\n/** The result returned by the {@link useLogin} mutation. */\nexport type LoginResult = Prettify<\n ResultOf<typeof accountCreateEmailPasswordSession>['accountCreateEmailPasswordSession']\n>\n\n/**\n * Returns `login` and `oAuthLogin` mutations for authenticating users.\n *\n * `login` handles email/password sessions; `oAuthLogin` handles OAuth2\n * provider sessions. Invalidates account and session queries on successful\n * email/password login.\n *\n * @example\n * ```tsx\n * const { login, oAuthLogin } = useLogin()\n *\n * // Email/password login\n * login.mutate({\n * email: 'user@example.com',\n * password: 'my-secure-password',\n * })\n * ```\n *\n * @example\n * ```tsx\n * const { login, oAuthLogin } = useLogin()\n *\n * // OAuth2 login\n * oAuthLogin.mutate({\n * provider: OAuthProvider.Google,\n * success: 'https://example.com/auth/callback',\n * failure: 'https://example.com/auth/error',\n * })\n * ```\n *\n * **`login` variables** ({@link LoginVariables}):\n * - `email` — User's email address\n * - `password` — User's password\n *\n * **`oAuthLogin` variables** ({@link OAuthLoginVariables}):\n * - `provider` — The OAuth2 provider (e.g., `OAuthProvider.Google`)\n * - `success` — Optional. URL to redirect to on successful authentication\n * - `failure` — Optional. URL to redirect to on failed authentication\n *\n * @returns An object with `login` (`UseMutationResult` with session `userId`, `expire`, `current`) and `oAuthLogin` (`UseMutationResult` that resolves to `void` or a redirect URL string).\n */\nexport function useLogin() {\n const { account, graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const login = useMutation<LoginResult, AppwriteException[], LoginVariables>({\n mutationKey: Keys.account().login().create(),\n mutationFn: async ({ email, password }) => {\n const { data, errors } = await graphql.mutation({\n query: accountCreateEmailPasswordSession,\n variables: {\n email,\n password,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountCreateEmailPasswordSession\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: Keys.account().key() })\n void queryClient.invalidateQueries({\n queryKey: Keys.account().sessions(),\n })\n },\n })\n\n const oAuthLogin = useMutation<void | string, AppwriteException[], OAuthLoginVariables>({\n mutationFn: async ({ provider, success, failure }) => {\n return account.createOAuth2Session({ provider, success, failure })\n },\n })\n\n return {\n login,\n oAuthLogin,\n }\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst deleteSession = gql(/* GraphQL */ `\n mutation DeleteSession($sessionId: String!) {\n accountDeleteSession(sessionId: $sessionId) {\n status\n }\n }\n`)\n\n/** The variables accepted by the {@link useLogout} mutation. */\nexport type LogoutVariables = Prettify<VariablesOf<typeof deleteSession>>\n/** The result returned by the {@link useLogout} mutation. */\nexport type LogoutResult = Prettify<ResultOf<typeof deleteSession>['accountDeleteSession']>\n\n/**\n * Mutation to delete a session by its ID.\n *\n * Unlike {@link useDeleteSession}, this hook **clears the entire query cache**\n * on success, making it suitable for \"log out\" flows where the user should\n * be fully de-authenticated.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useLogout()\n *\n * mutate({ sessionId: 'current' })\n * ```\n *\n * **Variables** ({@link LogoutVariables}):\n * - `sessionId` — The ID of the session to delete (use `\"current\"` for the active session)\n *\n * @returns A `UseMutationResult` with a `status` string indicating the operation result.\n */\nexport function useLogout() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<LogoutResult, AppwriteException[], LogoutVariables>({\n mutationKey: Keys.account().session().delete(),\n mutationFn: async ({ sessionId }) => {\n const { data, errors } = await graphql.mutation({\n query: deleteSession,\n variables: {\n sessionId,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data?.accountDeleteSession ?? { status: '' }\n },\n onSuccess: async () => {\n queryClient.clear()\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify, QueryOptions } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst accountListLogs = gql(/* GraphQL */ `\n query ListLogs($queries: [String!]) {\n accountListLogs(queries: $queries) {\n total\n logs {\n event\n userId\n userEmail\n userName\n mode\n ip\n time\n osCode\n osName\n osVersion\n clientType\n clientCode\n clientName\n clientVersion\n clientEngine\n clientEngineVersion\n deviceName\n deviceBrand\n deviceModel\n countryCode\n countryName\n }\n }\n }\n`)\n\n/** The variables accepted by the {@link useLogs} query. */\nexport type LogsVariables = Prettify<VariablesOf<typeof accountListLogs>>\n/** The result returned by the {@link useLogs} query. */\nexport type LogsResult = Prettify<ResultOf<typeof accountListLogs>['accountListLogs']>\n\n/**\n * Fetches the account activity logs for the current user. Accepts optional\n * query filters to narrow down results.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useLogs({ queries: ['limit(10)'] })\n * ```\n *\n * **Parameters** ({@link LogsVariables}):\n * - `queries` — Optional array of query strings to filter or paginate log entries.\n *\n * @returns A `UseQueryResult` with the user's activity logs ({@link LogsResult}).\n */\nexport function useLogs({ queries }: LogsVariables, opts: QueryOptions = {}) {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<LogsResult, AppwriteException[], LogsResult>({\n queryKey: [...Keys.account().logs().key(), ...(queries ?? [])],\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: accountListLogs,\n variables: {\n queries,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountListLogs\n },\n ...opts,\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\n\nconst createRecovery = gql(/* GraphQL */ `\n mutation CreateRecovery($email: String!, $url: String!) {\n accountCreateRecovery(email: $email, url: $url) {\n expire\n }\n }\n`)\n\n/** The variables accepted by the {@link usePasswordRecovery} mutation. */\nexport type PasswordRecoveryVariables = Prettify<VariablesOf<typeof createRecovery>>\n/** The result returned by the {@link usePasswordRecovery} mutation. */\nexport type PasswordRecoveryResult = Prettify<\n ResultOf<typeof createRecovery>['accountCreateRecovery']\n>\n\n/**\n * Sends a password recovery email to the supplied address.\n *\n * Mutation hook to send a password recovery email. On success, stores\n * the email in `localStorage` for convenience during the reset flow\n * (silently skipped in React Native environments). The recovery URL\n * receives `userId` and `secret` query parameters for use with\n * {@link useResetPassword}.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = usePasswordRecovery()\n *\n * mutate({\n * email: 'user@example.com',\n * url: 'https://example.com/reset-password',\n * })\n * ```\n *\n * **Variables** ({@link PasswordRecoveryVariables}):\n * - `email` — The email address to send the recovery link to\n * - `url` — The URL of the password reset page in your application\n *\n * @returns A `UseMutationResult` with the recovery token's `expire` timestamp.\n */\nexport function usePasswordRecovery() {\n const { graphql } = useAppwrite()\n\n const queryResult = useMutation<\n PasswordRecoveryResult,\n AppwriteException[],\n PasswordRecoveryVariables\n >({\n mutationKey: Keys.account().recovery().create(),\n mutationFn: async ({ email, url: resetUrl }) => {\n const { data, errors } = await graphql.mutation({\n query: createRecovery,\n variables: {\n email,\n url: resetUrl,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountCreateRecovery\n },\n onSuccess: async (_, variables) => {\n try {\n localStorage?.setItem('email', variables.email)\n } catch (e: any) {\n console.error(\n 'Could not save email to local storage. If you are using react-native, this is expected.',\n e,\n )\n }\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\n\nconst updateRecovery = gql(/* GraphQL */ `\n mutation UpdateRecovery($userId: String!, $secret: String!, $password: String!) {\n accountUpdateRecovery(userId: $userId, secret: $secret, password: $password) {\n expire\n }\n }\n`)\n\n/** The variables accepted by the {@link useResetPassword} mutation. */\nexport type ResetPasswordVariables = Prettify<VariablesOf<typeof updateRecovery>>\n/** The result returned by the {@link useResetPassword} mutation. */\nexport type ResetPasswordResult = Prettify<ResultOf<typeof updateRecovery>['accountUpdateRecovery']>\n\n/**\n * Mutation hook to reset a password using the recovery `userId`, `secret`, and new `password`.\n *\n * Completes the password recovery flow started by {@link usePasswordRecovery}.\n * The `userId` and `secret` are provided in the recovery URL query parameters.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useResetPassword()\n *\n * mutate({\n * userId: 'user-123',\n * secret: 'recovery-secret',\n * password: 'new-secure-password',\n * })\n * ```\n *\n * **Variables** ({@link ResetPasswordVariables}):\n * - `userId` — The user's ID from the recovery URL\n * - `secret` — The secret token from the recovery URL\n * - `password` — The new password to set\n *\n * @returns A `UseMutationResult` with the recovery token's `expire` timestamp.\n */\nexport function useResetPassword() {\n const { graphql } = useAppwrite()\n\n const queryResult = useMutation<ResetPasswordResult, AppwriteException[], ResetPasswordVariables>(\n {\n mutationKey: Keys.account().recovery().update(),\n mutationFn: async ({ userId, secret, password }) => {\n const { data, errors } = await graphql.mutation({\n query: updateRecovery,\n variables: {\n userId,\n secret,\n password,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountUpdateRecovery\n },\n },\n )\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { ID } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\n\nconst createAccount = gql(/* GraphQL */ `\n mutation CreateAccount($userId: String!, $name: String, $email: String!, $password: String!) {\n accountCreate(userId: $userId, name: $name, email: $email, password: $password) {\n name\n email\n }\n }\n`)\n\nconst verify = gql(/* GraphQL */ `\n mutation VerifyEmail($url: String!) {\n accountCreateVerification(url: $url) {\n expire\n }\n }\n`)\n\n/** The variables accepted by the {@link useSignUp} mutation. */\nexport type SignUpVariables = Prettify<\n Omit<VariablesOf<typeof createAccount>, 'userId'> & {\n userId?: string\n }\n>\n/** The result returned by the {@link useSignUp} mutation. */\nexport type SignUpResult = Prettify<ResultOf<typeof createAccount>['accountCreate']>\n\n/** The variables accepted by the verify email mutation in {@link useSignUp}. */\nexport type VerifyEmailVariables = Prettify<{\n verifyUrl: string\n}>\n/** The result returned by the verify email mutation in {@link useSignUp}. */\nexport type VerifyEmailResult = Prettify<ResultOf<typeof verify>['accountCreateVerification']>\n\n/**\n * Returns `signUp` and `verifyEmail` mutations.\n *\n * `signUp` creates a new account with email/password. `verifyEmail` sends\n * a verification email to the newly created account. A `userId` is\n * auto-generated via `ID.unique()` if not provided.\n *\n * @example\n * ```tsx\n * const { signUp, verifyEmail } = useSignUp()\n *\n * // Create a new account\n * signUp.mutate({\n * email: 'user@example.com',\n * password: 'secure-password',\n * name: 'Jane Doe',\n * })\n * ```\n *\n * @example\n * ```tsx\n * const { signUp, verifyEmail } = useSignUp()\n *\n * // Send a verification email after sign-up\n * verifyEmail.mutate({\n * verifyUrl: 'https://example.com/verify-email',\n * })\n * ```\n *\n * **`signUp` variables** ({@link SignUpVariables}):\n * - `email` — The user's email address\n * - `password` — The user's password\n * - `name` — Optional. The user's display name\n * - `userId` — Optional. Custom user ID (auto-generated if omitted)\n *\n * **`verifyEmail` variables** ({@link VerifyEmailVariables}):\n * - `verifyUrl` — The URL to redirect the user to after clicking the verification link\n *\n * @returns An object with `signUp` (`UseMutationResult` with the account's `name` and `email`) and `verifyEmail` (`UseMutationResult` with the verification token's `expire` timestamp).\n */\nexport function useSignUp() {\n const { graphql } = useAppwrite()\n\n const signUp = useMutation<SignUpResult, AppwriteException[], SignUpVariables>({\n mutationKey: Keys.account().signUp().create(),\n mutationFn: async ({ userId, email, password, name }) => {\n const { data, errors } = await graphql.mutation({\n query: createAccount,\n variables: {\n userId: userId ?? ID.unique(),\n name,\n email,\n password,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountCreate\n },\n })\n\n const verifyEmail = useMutation<VerifyEmailResult, AppwriteException[], VerifyEmailVariables>({\n mutationKey: Keys.account().emailVerification().create(),\n mutationFn: async ({ verifyUrl }) => {\n const { data, errors } = await graphql.mutation({\n query: verify,\n variables: {\n url: verifyUrl,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountCreateVerification\n },\n })\n\n return { signUp, verifyEmail }\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nexport const accountUpdateEmail = gql(/* GraphQL */ `\n mutation UpdateEmail($email: String!, $password: String!) {\n accountUpdateEmail(email: $email, password: $password) {\n name\n email\n }\n }\n`)\n\n/** The variables accepted by the {@link useUpdateEmail} mutation. */\nexport type UpdateEmailVariables = Prettify<VariablesOf<typeof accountUpdateEmail>>\n/** The result returned by the {@link useUpdateEmail} mutation. */\nexport type UpdateEmailResult = Prettify<ResultOf<typeof accountUpdateEmail>['accountUpdateEmail']>\n\n/**\n * Mutation hook to update the current user's email address.\n *\n * Requires the new email and the current password for verification.\n * Invalidates account queries on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useUpdateEmail()\n *\n * mutate({\n * email: 'new-email@example.com',\n * password: 'current-password',\n * })\n * ```\n *\n * **Variables** ({@link UpdateEmailVariables}):\n * - `email` — The new email address\n * - `password` — The user's current password for verification\n *\n * @returns A `UseMutationResult` with the updated `name` and `email` fields.\n */\nexport function useUpdateEmail() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<UpdateEmailResult, AppwriteException[], UpdateEmailVariables>({\n mutationKey: Keys.account().email().update(),\n mutationFn: async ({ email, password }) => {\n const { data, errors } = await graphql.mutation({\n query: accountUpdateEmail,\n variables: {\n email,\n password,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountUpdateEmail\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: Keys.account().key() })\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst updateEmailVerification = gql(/* GraphQL */ `\n mutation UpdateEmailVerification($userId: String!, $secret: String!) {\n accountUpdateEmailVerification(userId: $userId, secret: $secret) {\n _id\n userId\n secret\n expire\n }\n }\n`)\n\n/** The variables accepted by the {@link useUpdateEmailVerification} mutation. */\nexport type UpdateEmailVerificationVariables = Prettify<VariablesOf<typeof updateEmailVerification>>\n/** The result returned by the {@link useUpdateEmailVerification} mutation. */\nexport type UpdateEmailVerificationResult = Prettify<\n ResultOf<typeof updateEmailVerification>['accountUpdateEmailVerification']\n>\n\n/**\n * Mutation hook to confirm email verification using `userId` and `secret`.\n *\n * Completes the email verification flow started by\n * {@link useCreateEmailVerification}. The `userId` and `secret` are\n * provided in the verification URL query parameters. Invalidates account\n * queries on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useUpdateEmailVerification()\n *\n * // Extract userId and secret from the verification URL\n * mutate({\n * userId: 'user-123',\n * secret: 'verification-secret',\n * })\n * ```\n *\n * **Variables** ({@link UpdateEmailVerificationVariables}):\n * - `userId` — The user's ID from the verification URL\n * - `secret` — The secret token from the verification URL\n *\n * @returns A `UseMutationResult` with the verification's `_id`, `userId`, `secret`, and `expire` fields.\n */\nexport function useUpdateEmailVerification() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<\n UpdateEmailVerificationResult,\n AppwriteException[],\n UpdateEmailVerificationVariables\n >({\n mutationKey: Keys.account().emailVerification().update(),\n mutationFn: async ({ userId, secret }) => {\n const { data, errors } = await graphql.mutation({\n query: updateEmailVerification,\n variables: { userId, secret },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountUpdateEmailVerification\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: Keys.account().key() })\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst updateMagicURLSession = gql(/* GraphQL */ `\n mutation UpdateMagicURLSession($userId: String!, $secret: String!) {\n accountUpdateMagicURLSession(userId: $userId, secret: $secret) {\n userId\n expire\n current\n }\n }\n`)\n\n/** The variables accepted by the {@link useUpdateMagicURLSession} mutation. */\nexport type UpdateMagicURLSessionVariables = Prettify<VariablesOf<typeof updateMagicURLSession>>\n/** The result returned by the {@link useUpdateMagicURLSession} mutation. */\nexport type UpdateMagicURLSessionResult = Prettify<\n ResultOf<typeof updateMagicURLSession>['accountUpdateMagicURLSession']\n>\n\n/**\n * Mutation hook to validate a magic URL session using `userId` and `secret`.\n *\n * Completes the magic URL authentication flow started by\n * {@link useCreateMagicURLToken}. The `userId` and `secret` are provided\n * in the magic URL query parameters. Invalidates account and session\n * queries on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useUpdateMagicURLSession()\n *\n * // Extract userId and secret from the magic URL\n * mutate({\n * userId: 'user-123',\n * secret: 'magic-url-secret',\n * })\n * ```\n *\n * **Variables** ({@link UpdateMagicURLSessionVariables}):\n * - `userId` — The user's ID from the magic URL\n * - `secret` — The secret token from the magic URL\n *\n * @returns A `UseMutationResult` with the session's `userId`, `expire`, and `current` fields.\n */\nexport function useUpdateMagicURLSession() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<\n UpdateMagicURLSessionResult,\n AppwriteException[],\n UpdateMagicURLSessionVariables\n >({\n mutationKey: Keys.account().magicUrl().update(),\n mutationFn: async ({ userId, secret }) => {\n const { data, errors } = await graphql.mutation({\n query: updateMagicURLSession,\n variables: {\n userId,\n secret,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountUpdateMagicURLSession\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: Keys.account().key() })\n void queryClient.invalidateQueries({\n queryKey: Keys.account().sessions(),\n })\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst accountUpdateMFA = gql(/* GraphQL */ `\n mutation UpdateMFA($mfa: Boolean!) {\n accountUpdateMFA(mfa: $mfa) {\n mfa\n }\n }\n`)\n\n/** The variables accepted by the {@link useUpdateMfa} mutation. */\nexport type UpdateMfaVariables = Prettify<VariablesOf<typeof accountUpdateMFA>>\n/** The result returned by the {@link useUpdateMfa} mutation. */\nexport type UpdateMfaResult = Prettify<ResultOf<typeof accountUpdateMFA>['accountUpdateMFA']>\n\n/**\n * Mutation hook to enable or disable MFA on the current account.\n *\n * Toggles multi-factor authentication for the user. Invalidates account\n * and MFA factor queries on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useUpdateMfa()\n *\n * // Enable MFA\n * mutate({ mfa: true })\n *\n * // Disable MFA\n * mutate({ mfa: false })\n * ```\n *\n * **Variables** ({@link UpdateMfaVariables}):\n * - `mfa` — `true` to enable MFA, `false` to disable it\n *\n * @returns A `UseMutationResult` with the updated `mfa` boolean status.\n */\nexport function useUpdateMfa() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<UpdateMfaResult, AppwriteException[], UpdateMfaVariables>({\n mutationKey: Keys.account().mfa().update(),\n mutationFn: async ({ mfa }) => {\n const { data, errors } = await graphql.mutation({\n query: accountUpdateMFA,\n variables: {\n mfa,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountUpdateMFA\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: Keys.account().key() })\n void queryClient.invalidateQueries({\n queryKey: Keys.account().mfaFactors(),\n })\n },\n })\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { AuthenticatorType } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst updateMFAAuthenticator = gql(/* GraphQL */ `\n mutation UpdateMfaAuthenticator($type: String!, $otp: String!) {\n accountUpdateMfaAuthenticator(type: $type, otp: $otp) {\n mfa\n }\n }\n`)\n\n/** The variables accepted by the {@link useUpdateMfaAuthenticator} mutation. */\nexport type UpdateMfaAuthenticatorVariables = {\n /** The authenticator type. Defaults to `AuthenticatorType.Totp`. */\n type?: AuthenticatorType\n /** The one-time password from the authenticator app. */\n otp: string\n}\n/** The result returned by the {@link useUpdateMfaAuthenticator} mutation. */\nexport type UpdateMfaAuthenticatorResult = Prettify<\n ResultOf<typeof updateMFAAuthenticator>['accountUpdateMfaAuthenticator']\n>\n\n/**\n * Mutation hook to verify an MFA authenticator by providing a `type` and `otp` code.\n *\n * Completes the MFA authenticator setup started by\n * {@link useCreateMfaAuthenticator}. The user must enter the OTP from\n * their authenticator app to confirm enrollment. Invalidates account\n * and MFA factor queries on success.\n *\n * @example\n * ```tsx\n * import { AuthenticatorType } from '@zeroin.earth/appwrite-graphql'\n *\n * const { mutate, isPending } = useUpdateMfaAuthenticator()\n *\n * mutate({\n * type: AuthenticatorType.Totp,\n * otp: '123456',\n * })\n * ```\n *\n * **Variables** ({@link UpdateMfaAuthenticatorVariables}):\n * - `type` — The authenticator type ({@link AuthenticatorType}). Defaults to `AuthenticatorType.Totp`.\n * - `otp` — The one-time password from the authenticator app\n *\n * @returns A `UseMutationResult` with the updated `mfa` boolean status.\n */\nexport function useUpdateMfaAuthenticator() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<\n UpdateMfaAuthenticatorResult,\n AppwriteException[],\n UpdateMfaAuthenticatorVariables\n >({\n mutationKey: Keys.account().mfaAuthenticator().update(),\n mutationFn: async ({ type = AuthenticatorType.Totp, otp }) => {\n const { data, errors } = await graphql.mutation({\n query: updateMFAAuthenticator,\n variables: {\n type,\n otp,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountUpdateMfaAuthenticator\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: Keys.account().key() })\n void queryClient.invalidateQueries({\n queryKey: Keys.account().mfaFactors(),\n })\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\n\nconst accountUpdateMfaChallenge = gql(/* GraphQL */ `\n mutation UpdateMfaChallenge($challengeId: String!, $otp: String!) {\n accountUpdateMfaChallenge(challengeId: $challengeId, otp: $otp) {\n _id\n userId\n expire\n current\n }\n }\n`)\n\n/** The variables accepted by the {@link useUpdateMfaChallenge} mutation. */\nexport type UpdateMfaChallengeVariables = Prettify<VariablesOf<typeof accountUpdateMfaChallenge>>\n/** The result returned by the {@link useUpdateMfaChallenge} mutation. */\nexport type UpdateMfaChallengeResult = Prettify<\n ResultOf<typeof accountUpdateMfaChallenge>['accountUpdateMfaChallenge']\n>\n\n/**\n * Mutation hook to complete an MFA challenge by providing the `challengeId` and `otp` code.\n *\n * Verifies the one-time password against the challenge created by\n * {@link useCreateMfaChallenge}. On success, a new session is established.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useUpdateMfaChallenge()\n *\n * mutate({\n * challengeId: 'challenge-abc',\n * otp: '123456',\n * })\n * ```\n *\n * **Variables** ({@link UpdateMfaChallengeVariables}):\n * - `challengeId` — The challenge ID returned by {@link useCreateMfaChallenge}\n * - `otp` — The one-time password from the user's authenticator, SMS, or email\n *\n * @returns A `UseMutationResult` with the session's `_id`, `userId`, `expire`, and `current` fields.\n */\nexport function useUpdateMfaChallenge() {\n const { graphql } = useAppwrite()\n\n const queryResult = useMutation<\n UpdateMfaChallengeResult,\n AppwriteException[],\n UpdateMfaChallengeVariables\n >({\n mutationKey: Keys.account().mfaChallenge().update(),\n mutationFn: async ({ challengeId, otp }) => {\n const { data, errors } = await graphql.mutation({\n query: accountUpdateMfaChallenge,\n variables: {\n challengeId,\n otp,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data?.accountUpdateMfaChallenge ?? null\n },\n })\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst accountUpdateMfaRecoveryCodes = gql(/* GraphQL */ `\n mutation UpdateMfaRecoveryCodes {\n accountUpdateMfaRecoveryCodes {\n recoveryCodes\n }\n }\n`)\n\n/** The result returned by the {@link useUpdateMfaRecoveryCodes} mutation. */\nexport type UpdateMfaRecoveryCodesResult = Prettify<\n ResultOf<typeof accountUpdateMfaRecoveryCodes>['accountUpdateMfaRecoveryCodes']\n>\n\n/**\n * Mutation hook to regenerate MFA recovery codes.\n *\n * Replaces the existing set of recovery codes with new ones. Previous\n * recovery codes will no longer be valid. Invalidates recovery code\n * queries on success.\n *\n * @example\n * ```tsx\n * const { mutate, data, isPending } = useUpdateMfaRecoveryCodes()\n *\n * mutate()\n *\n * // Display data.recoveryCodes to the user for safekeeping\n * ```\n *\n * This mutation takes no variables.\n *\n * @returns A `UseMutationResult` with a `recoveryCodes` array of new backup codes.\n */\nexport function useUpdateMfaRecoveryCodes() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<UpdateMfaRecoveryCodesResult, AppwriteException[], void>({\n mutationKey: Keys.account().mfaCodes().update(),\n mutationFn: async () => {\n const { data, errors } = await graphql.mutation({\n query: accountUpdateMfaRecoveryCodes,\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountUpdateMfaRecoveryCodes\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({\n queryKey: Keys.account().mfaCodes().key(),\n })\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nexport const accountUpdateName = gql(/* GraphQL */ `\n mutation UpdateName($name: String!) {\n accountUpdateName(name: $name) {\n name\n }\n }\n`)\n\n/** The variables accepted by the {@link useUpdateName} mutation. */\nexport type UpdateNameVariables = Prettify<VariablesOf<typeof accountUpdateName>>\n/** The result returned by the {@link useUpdateName} mutation. */\nexport type UpdateNameResult = Prettify<ResultOf<typeof accountUpdateName>['accountUpdateName']>\n\n/**\n * Mutation hook to update the current user's display name.\n *\n * Invalidates account queries on success so that components reading\n * the account will reflect the new name.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useUpdateName()\n *\n * mutate({ name: 'Jane Doe' })\n * ```\n *\n * **Variables** ({@link UpdateNameVariables}):\n * - `name` — The new display name for the user\n *\n * @returns A `UseMutationResult` with the updated `name` field.\n */\nexport function useUpdateName() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<UpdateNameResult, AppwriteException[], UpdateNameVariables>({\n mutationKey: Keys.account().name().update(),\n mutationFn: async ({ name }) => {\n const { data: mutationData, errors } = await graphql.mutation({\n query: accountUpdateName,\n variables: {\n name,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return mutationData.accountUpdateName\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: Keys.account().key() })\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nexport const updatePassword = gql(/* GraphQL */ `\n mutation UpdatePassword($password: String!, $oldPassword: String!) {\n accountUpdatePassword(password: $password, oldPassword: $oldPassword) {\n status\n }\n }\n`)\n\n/** The variables accepted by the {@link useUpdatePassword} mutation. */\nexport type UpdatePasswordVariables = Prettify<VariablesOf<typeof updatePassword>>\n/** The result returned by the {@link useUpdatePassword} mutation. */\nexport type UpdatePasswordResult = Prettify<\n ResultOf<typeof updatePassword>['accountUpdatePassword']\n>\n\n/**\n * Mutation hook to update the current user's password.\n *\n * Requires the new password and the current (old) password for verification.\n * Invalidates account queries on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useUpdatePassword()\n *\n * mutate({\n * password: 'new-secure-password',\n * oldPassword: 'current-password',\n * })\n * ```\n *\n * **Variables** ({@link UpdatePasswordVariables}):\n * - `password` — The new password\n * - `oldPassword` — The current password for verification\n *\n * @returns A `UseMutationResult` with a `status` string indicating the operation result.\n */\nexport function useUpdatePassword() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<\n UpdatePasswordResult,\n AppwriteException[],\n UpdatePasswordVariables\n >({\n mutationKey: Keys.account().password().update(),\n mutationFn: async ({ password, oldPassword }) => {\n const { data, errors } = await graphql.mutation({\n query: updatePassword,\n variables: {\n password,\n oldPassword,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data?.accountUpdatePassword\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: Keys.account().key() })\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nexport const accountUpdatePhone = gql(/* GraphQL */ `\n mutation UpdatePhone($phone: String!, $password: String!) {\n accountUpdatePhone(phone: $phone, password: $password) {\n phone\n }\n }\n`)\n\n/** The variables accepted by the {@link useUpdatePhone} mutation. */\nexport type UpdatePhoneVariables = Prettify<VariablesOf<typeof accountUpdatePhone>>\n/** The result returned by the {@link useUpdatePhone} mutation. */\nexport type UpdatePhoneResult = Prettify<ResultOf<typeof accountUpdatePhone>['accountUpdatePhone']>\n\n/**\n * Mutation hook to update the current user's phone number.\n *\n * Requires the new phone number and the current password for verification.\n * Invalidates account queries on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useUpdatePhone()\n *\n * mutate({\n * phone: '+14155551234',\n * password: 'current-password',\n * })\n * ```\n *\n * **Variables** ({@link UpdatePhoneVariables}):\n * - `phone` — The new phone number in E.164 format (e.g., `\"+14155551234\"`)\n * - `password` — The user's current password for verification\n *\n * @returns A `UseMutationResult` with the updated `phone` field.\n */\nexport function useUpdatePhone() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<UpdatePhoneResult, AppwriteException[], UpdatePhoneVariables>({\n mutationKey: Keys.account().phone().update(),\n mutationFn: async ({ phone, password }) => {\n const { data, errors } = await graphql.mutation({\n query: accountUpdatePhone,\n variables: {\n phone,\n password,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountUpdatePhone\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: Keys.account().key() })\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst updatePhoneSession = gql(/* GraphQL */ `\n mutation UpdatePhoneSession($userId: String!, $secret: String!) {\n accountUpdatePhoneSession(userId: $userId, secret: $secret) {\n userId\n expire\n current\n }\n }\n`)\n\n/** The variables accepted by the {@link useUpdatePhoneSession} mutation. */\nexport type UpdatePhoneSessionVariables = Prettify<VariablesOf<typeof updatePhoneSession>>\n/** The result returned by the {@link useUpdatePhoneSession} mutation. */\nexport type UpdatePhoneSessionResult = Prettify<\n ResultOf<typeof updatePhoneSession>['accountUpdatePhoneSession']\n>\n\n/**\n * Mutation hook to validate a phone session using `userId` and `secret`.\n *\n * Completes the phone-based authentication flow started by\n * {@link useCreatePhoneToken}. Invalidates account and session queries\n * on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useUpdatePhoneSession()\n *\n * mutate({\n * userId: 'user-123',\n * secret: '123456',\n * })\n * ```\n *\n * **Variables** ({@link UpdatePhoneSessionVariables}):\n * - `userId` — The user's ID received from the phone token step\n * - `secret` — The OTP code sent via SMS\n *\n * @returns A `UseMutationResult` with the session's `userId`, `expire`, and `current` fields.\n */\nexport function useUpdatePhoneSession() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<\n UpdatePhoneSessionResult,\n AppwriteException[],\n UpdatePhoneSessionVariables\n >({\n mutationKey: Keys.account().phoneToken().update(),\n mutationFn: async ({ userId, secret }) => {\n const { data, errors } = await graphql.mutation({\n query: updatePhoneSession,\n variables: {\n userId,\n secret,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountUpdatePhoneSession\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: Keys.account().key() })\n void queryClient.invalidateQueries({\n queryKey: Keys.account().sessions(),\n })\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\n\nconst updatePhoneVerification = gql(/* GraphQL */ `\n mutation UpdatePhoneVerification($userId: String!, $secret: String!) {\n accountUpdatePhoneVerification(userId: $userId, secret: $secret) {\n expire\n }\n }\n`)\n\n/** The variables accepted by the {@link useUpdatePhoneVerification} mutation. */\nexport type UpdatePhoneVerificationVariables = Prettify<VariablesOf<typeof updatePhoneVerification>>\n/** The result returned by the {@link useUpdatePhoneVerification} mutation. */\nexport type UpdatePhoneVerificationResult = Prettify<\n ResultOf<typeof updatePhoneVerification>['accountUpdatePhoneVerification']\n>\n\n/**\n * Mutation hook to confirm phone verification using `userId` and `secret`.\n *\n * Completes the phone verification flow started by\n * {@link useCreatePhoneVerification}.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useUpdatePhoneVerification()\n *\n * mutate({\n * userId: 'user-123',\n * secret: '123456',\n * })\n * ```\n *\n * **Variables** ({@link UpdatePhoneVerificationVariables}):\n * - `userId` — The user's ID\n * - `secret` — The verification code sent via SMS\n *\n * @returns A `UseMutationResult` with the verification's `expire` timestamp.\n */\nexport function useUpdatePhoneVerification() {\n const { graphql } = useAppwrite()\n\n const queryResult = useMutation<\n UpdatePhoneVerificationResult,\n AppwriteException[],\n UpdatePhoneVerificationVariables\n >({\n mutationKey: Keys.account().phoneVerification().update(),\n mutationFn: async ({ userId, secret }) => {\n const { data, errors } = await graphql.mutation({\n query: updatePhoneVerification,\n variables: {\n userId,\n secret,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountUpdatePhoneVerification\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nexport const accountUpdatePrefs = gql(/* GraphQL */ `\n mutation UpdatePrefs($prefs: Assoc!) {\n accountUpdatePrefs(prefs: $prefs) {\n prefs {\n data\n }\n }\n }\n`)\n\n/** The variables accepted by the {@link useUpdatePrefs} mutation. */\nexport type UpdatePrefsVariables = Prettify<VariablesOf<typeof accountUpdatePrefs>>\n/** The result returned by the {@link useUpdatePrefs} mutation. */\nexport type UpdatePrefsResult = Prettify<ResultOf<typeof accountUpdatePrefs>['accountUpdatePrefs']>\n\n/**\n * Mutation hook to update the current user's account preferences.\n *\n * Accepts an `Assoc` (key-value map) of preferences. Invalidates account\n * queries on success so that components reading preferences reflect the\n * updated values.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useUpdatePrefs()\n *\n * mutate({\n * prefs: { theme: 'dark', locale: 'en-US' },\n * })\n * ```\n *\n * **Variables** ({@link UpdatePrefsVariables}):\n * - `prefs` — A key-value object of account preferences to set\n *\n * @returns A `UseMutationResult` with the updated `prefs` containing a `data` field.\n */\nexport function useUpdatePrefs() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<UpdatePrefsResult, AppwriteException[], UpdatePrefsVariables>({\n mutationKey: Keys.account().prefs().update(),\n mutationFn: async ({ prefs }) => {\n const { data, errors } = await graphql.mutation({\n query: accountUpdatePrefs,\n variables: { prefs },\n })\n\n if (errors) {\n throw errors\n }\n\n return data?.accountUpdatePrefs\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: Keys.account().key() })\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst accountUpdatePushTarget = gql(/* GraphQL */ `\n mutation UpdatePushTarget($targetId: String!, $identifier: String!) {\n accountUpdatePushTarget(targetId: $targetId, identifier: $identifier) {\n _id\n userId\n providerType\n identifier\n }\n }\n`)\n\n/** The variables accepted by the {@link useUpdatePushTarget} mutation. */\nexport type UpdatePushTargetVariables = Prettify<VariablesOf<typeof accountUpdatePushTarget>>\n/** The result returned by the {@link useUpdatePushTarget} mutation. */\nexport type UpdatePushTargetResult = Prettify<\n ResultOf<typeof accountUpdatePushTarget>['accountUpdatePushTarget']\n>\n\n/**\n * Mutation hook to update a push notification target's identifier.\n *\n * Replaces the device token on an existing push target. Invalidates\n * account queries on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useUpdatePushTarget()\n *\n * mutate({\n * targetId: 'target-123',\n * identifier: 'new-fcm-device-token',\n * })\n * ```\n *\n * **Variables** ({@link UpdatePushTargetVariables}):\n * - `targetId` — The ID of the push target to update\n * - `identifier` — The new device token or registration ID\n *\n * @returns A `UseMutationResult` with the push target's `_id`, `userId`, `providerType`, and `identifier`.\n */\nexport function useUpdatePushTarget() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<\n UpdatePushTargetResult,\n AppwriteException[],\n UpdatePushTargetVariables\n >({\n mutationKey: Keys.account().pushTarget().update(),\n mutationFn: async ({ targetId, identifier }) => {\n const { data, errors } = await graphql.mutation({\n query: accountUpdatePushTarget,\n variables: {\n targetId,\n identifier,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountUpdatePushTarget\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: Keys.account().key() })\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst updateSession = gql(/* GraphQL */ `\n mutation UpdateSession($sessionId: String!) {\n accountUpdateSession(sessionId: $sessionId) {\n userId\n expire\n current\n }\n }\n`)\n\n/** The variables accepted by the {@link useUpdateSession} mutation. */\nexport type UpdateSessionVariables = Prettify<VariablesOf<typeof updateSession>>\n/** The result returned by the {@link useUpdateSession} mutation. */\nexport type UpdateSessionResult = Prettify<ResultOf<typeof updateSession>['accountUpdateSession']>\n\n/**\n * Mutation hook to extend a session's expiry by its ID.\n *\n * Refreshes the session so it does not expire. Invalidates session list\n * queries on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useUpdateSession()\n *\n * mutate({ sessionId: 'current' })\n * ```\n *\n * **Variables** ({@link UpdateSessionVariables}):\n * - `sessionId` — The ID of the session to extend (use `\"current\"` for the active session)\n *\n * @returns A `UseMutationResult` with the session's `userId`, `expire`, and `current` fields.\n */\nexport function useUpdateSession() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<UpdateSessionResult, AppwriteException[], UpdateSessionVariables>(\n {\n mutationKey: Keys.account().session().update(),\n mutationFn: async ({ sessionId }) => {\n const { data, errors } = await graphql.mutation({\n query: updateSession,\n variables: {\n sessionId,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountUpdateSession\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({\n queryKey: Keys.account().sessions(),\n })\n },\n },\n )\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst accountUpdateStatus = gql(/* GraphQL */ `\n mutation UpdateStatus {\n accountUpdateStatus {\n _id\n status\n }\n }\n`)\n\n/** The result returned by the {@link useUpdateStatus} mutation. */\nexport type UpdateStatusResult = Prettify<\n ResultOf<typeof accountUpdateStatus>['accountUpdateStatus']\n>\n\n/**\n * Mutation hook to update the current user's account status (e.g., disable account).\n *\n * Blocks the user account by setting the status to disabled. Invalidates\n * account queries on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useUpdateStatus()\n *\n * mutate()\n * ```\n *\n * This mutation takes no variables.\n *\n * @returns A `UseMutationResult` with the user's `_id` and updated `status`.\n */\nexport function useUpdateStatus() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<UpdateStatusResult, AppwriteException[], void>({\n mutationKey: Keys.account().status().update(),\n mutationFn: async () => {\n const { data, errors } = await graphql.mutation({\n query: accountUpdateStatus,\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountUpdateStatus\n },\n onSuccess: async () => {\n void queryClient.invalidateQueries({ queryKey: Keys.account().key() })\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst updateVerification = gql(/* GraphQL */ `\n mutation UpdateVerification($userId: String!, $secret: String!) {\n accountUpdateVerification(userId: $userId, secret: $secret) {\n secret\n expire\n userId\n }\n }\n`)\n\n/** The variables accepted by the {@link useVerification} mutation. */\nexport type VerificationVariables = Prettify<VariablesOf<typeof updateVerification>>\n/** The result returned by the {@link useVerification} mutation. */\nexport type VerificationResult = Prettify<\n ResultOf<typeof updateVerification>['accountUpdateVerification']\n>\n\n/**\n * Mutation hook to complete email verification using `userId` and `secret` from the verification link.\n *\n * Validates the verification token and marks the user's email as verified.\n * Throws an error if `userId` or `secret` is missing. On success, sets the\n * account query data to `null` to force a re-fetch.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useVerification()\n *\n * // Extract userId and secret from the verification URL\n * mutate({\n * userId: 'user-123',\n * secret: 'verification-secret',\n * })\n * ```\n *\n * **Variables** ({@link VerificationVariables}):\n * - `userId` — The user's ID from the verification URL\n * - `secret` — The secret token from the verification URL\n *\n * @returns A `UseMutationResult` with the verification's `secret`, `expire`, and `userId` fields.\n */\nexport function useVerification() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const queryResult = useMutation<VerificationResult, AppwriteException[], VerificationVariables>({\n mutationKey: Keys.account().verification().update(),\n mutationFn: async ({ userId, secret }) => {\n if (!userId || !secret) {\n throw new Error('Missing userId or secret')\n }\n\n const { data, errors } = await graphql.mutation({\n query: updateVerification,\n variables: {\n userId,\n secret,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.accountUpdateVerification\n },\n onSuccess: async () => {\n queryClient.setQueryData(Keys.account().key(), null)\n },\n })\n\n return queryResult\n}\n","import { useMemo } from 'react'\nimport type { Browser } from 'appwrite'\n\nimport { useAppwrite } from '../useAppwrite'\n\n/**\n * Returns a URL for a browser logo avatar image. Memoized.\n * @param params - The browser code and optional width, height, and quality.\n */\nexport function useAvatarBrowser({\n code,\n width,\n height,\n quality,\n}: {\n code: Browser\n width?: number\n height?: number\n quality?: number\n}) {\n const { avatars } = useAppwrite()\n\n const url = useMemo(\n () => avatars?.getBrowser({ code, width, height, quality }),\n [avatars, code, width, height, quality],\n )\n\n return url\n}\n","import { useMemo } from 'react'\nimport type { CreditCard } from 'appwrite'\n\nimport { useAppwrite } from '../useAppwrite'\n\n/**\n * Returns a URL for a credit card brand logo avatar image. Memoized.\n * @param params - The credit card code and optional width, height, and quality.\n */\nexport function useAvatarCreditCard({\n code,\n width,\n height,\n quality,\n}: {\n code: CreditCard\n width?: number\n height?: number\n quality?: number\n}) {\n const { avatars } = useAppwrite()\n\n const url = useMemo(\n () => avatars?.getCreditCard({ code, width, height, quality }),\n [avatars, code, width, height, quality],\n )\n\n return url\n}\n","import { useMemo } from 'react'\n\nimport { useAppwrite } from '../useAppwrite'\n\n/**\n * Returns a URL for a website's favicon. Memoized.\n * @param params - The website URL to fetch the favicon for.\n */\nexport function useAvatarFavicon({ url }: { url: string }) {\n const { avatars } = useAppwrite()\n\n const faviconUrl = useMemo(() => avatars?.getFavicon({ url }), [avatars, url])\n\n return faviconUrl\n}\n","import { useMemo } from 'react'\nimport type { Flag } from 'appwrite'\n\nimport { useAppwrite } from '../useAppwrite'\n\n/**\n * Returns a URL for a country flag avatar image. Memoized.\n * @param params - The country code and optional width, height, and quality.\n */\nexport function useAvatarFlag({\n code,\n width,\n height,\n quality,\n}: {\n code: Flag\n width?: number\n height?: number\n quality?: number\n}) {\n const { avatars } = useAppwrite()\n\n const url = useMemo(\n () => avatars?.getFlag({ code, width, height, quality }),\n [avatars, code, width, height, quality],\n )\n\n return url\n}\n","import { useMemo } from 'react'\n\nimport { useAppwrite } from '../useAppwrite'\n\n/**\n * Returns a URL for a remote image cropped to a specified size. Memoized.\n * @param params - The image URL and optional width and height.\n */\nexport function useAvatarImage({\n url,\n width,\n height,\n}: {\n url: string\n width?: number\n height?: number\n}) {\n const { avatars } = useAppwrite()\n\n const imageUrl = useMemo(\n () => avatars?.getImage({ url, width, height }),\n [avatars, url, width, height],\n )\n\n return imageUrl\n}\n","import { useMemo } from 'react'\n\nimport { useAppwrite } from '../useAppwrite'\n\n/**\n * Returns a URL for an avatar with user initials.\n * Uses the current user's name if none provided. Memoized.\n * @param params - Optional name, width, height, and background color.\n */\nexport function useAvatarInitials({\n name,\n width,\n height,\n background,\n}: {\n name?: string\n width?: number\n height?: number\n background?: string\n} = {}) {\n const { avatars } = useAppwrite()\n\n const url = useMemo(\n () => avatars?.getInitials({ name, width, height, background }),\n [avatars, name, width, height, background],\n )\n\n return url\n}\n","import { useMemo } from 'react'\n\nimport { useAppwrite } from '../useAppwrite'\n\n/**\n * Returns a URL for a QR code image. Memoized.\n * @param params - The text to encode, and optional size, margin, and download flag.\n */\nexport function useAvatarQR({\n text,\n size,\n margin,\n download,\n}: {\n text: string\n size?: number\n margin?: number\n download?: boolean\n}) {\n const { avatars } = useAppwrite()\n\n const url = useMemo(\n () => avatars?.getQR({ text, size, margin, download }),\n [avatars, text, size, margin, download],\n )\n\n return url\n}\n","import { useMemo } from 'react'\n\nimport { useAppwrite } from '../useAppwrite'\n\n/**\n * Returns a URL for a screenshot of a website. Memoized.\n * @param params - The website URL and optional width and height.\n */\nexport function useAvatarScreenshot({\n url,\n width,\n height,\n}: {\n url: string\n width?: number\n height?: number\n}) {\n const { avatars } = useAppwrite()\n\n const screenshotUrl = useMemo(\n () => avatars?.getScreenshot({ url, width, height }),\n [avatars, url, width, height],\n )\n\n return screenshotUrl\n}\n","import { Query } from 'appwrite'\n\nexport function mergeFieldsQuery(queries: string[], fields?: string[]): string[] {\n if (!fields || fields.length === 0) return queries\n return [Query.select(fields), ...queries]\n}\n","import { graphql as gql } from 'gql.tada'\n\nimport type { Collection, Document } from './types'\nimport { mergeFieldsQuery } from './utils'\nimport type { AppwriteClient } from '../client'\nimport { Keys } from '../query/Keys'\n\ntype DocumentParams<TDocument = Record<string, unknown>> = {\n databaseId: string\n collectionId: string\n documentId: string\n queries?: string[]\n transactionId?: string\n fields?: (keyof TDocument & string)[]\n}\n\nexport const getDocument = gql(/* GraphQL */ `\n query GetDocument(\n $databaseId: String!\n $collectionId: String!\n $documentId: String!\n $queries: [String!]\n $transactionId: String\n ) {\n databasesGetDocument(\n databaseId: $databaseId\n collectionId: $collectionId\n documentId: $documentId\n queries: $queries\n transactionId: $transactionId\n ) {\n _id\n data\n }\n }\n`)\n\nexport function getDocumentQuery<TDocument>(\n client: AppwriteClient,\n {\n databaseId,\n collectionId,\n documentId,\n queries,\n transactionId,\n fields,\n }: DocumentParams<TDocument>,\n) {\n const rawQueries = Array.isArray(queries) ? queries : queries ? [queries] : []\n const mergedQueries = mergeFieldsQuery(rawQueries, fields)\n\n return {\n queryKey: [\n ...Keys.database(databaseId).collection(collectionId).document(documentId).key(),\n ...mergedQueries,\n ] as const,\n queryFn: async () => {\n const { data, errors } = await client.graphql.query({\n query: getDocument,\n variables: {\n databaseId,\n collectionId,\n documentId,\n queries: mergedQueries.length > 0 ? mergedQueries : undefined,\n transactionId,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n const document = {\n ...data.databasesGetDocument,\n ...(data.databasesGetDocument\n ? (JSON.parse(data.databasesGetDocument.data as string) as TDocument)\n : {}),\n } as unknown as Document<TDocument>\n\n return document\n },\n }\n}\n\nexport const listDocuments = gql(/* GraphQL */ `\n query ListDocuments(\n $databaseId: String!\n $collectionId: String!\n $queries: [String!]\n $transactionId: String\n ) {\n databasesListDocuments(\n databaseId: $databaseId\n collectionId: $collectionId\n queries: $queries\n transactionId: $transactionId\n ) {\n total\n documents {\n _id\n data\n }\n }\n }\n`)\n\nexport function getCollectionQuery<TDocument>(\n client: AppwriteClient,\n {\n databaseId,\n collectionId,\n queries,\n transactionId,\n fields,\n }: Omit<DocumentParams<TDocument>, 'documentId'>,\n) {\n const mergedQueries = mergeFieldsQuery(queries ?? [], fields)\n\n return {\n queryKey: [\n ...Keys.database(databaseId).collection(collectionId).key(),\n ...mergedQueries,\n ] as const,\n queryFn: async () => {\n const { data, errors } = await client.graphql.query({\n query: listDocuments,\n variables: {\n databaseId,\n collectionId,\n queries: mergedQueries,\n transactionId,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n const documents =\n data.databasesListDocuments?.documents?.map((document) => ({\n ...document,\n ...(document ? (JSON.parse(document.data as string) as TDocument) : {}),\n })) ?? []\n\n return {\n total: data.databasesListDocuments?.total ?? 0,\n documents,\n } as unknown as Collection<TDocument>\n },\n }\n}\n","import { useEffect } from 'react'\nimport { Channel } from 'appwrite'\n\nimport { getCollectionQuery } from './queryOptions'\nimport type { Collection, Document } from './types'\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify, QueryOptions } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\nimport { useQueryClient } from '../useQueryClient'\nimport { useSuspenseQuery } from '../useSuspenseQuery'\n\ntype DocumentOperation = 'create' | 'update' | 'delete'\n\ntype CollectionParams<TDocument = Record<string, string | number | boolean | null>> = Prettify<{\n databaseId: string\n collectionId: string\n queries?: string[]\n transactionId?: string\n subscribe?: boolean\n fields?: (keyof TDocument & string)[]\n}>\n\nfunction useCollectionQueryConfig<TDocument>({\n databaseId,\n collectionId,\n queries,\n transactionId,\n fields,\n}: Omit<CollectionParams<TDocument>, 'subscribe'>) {\n const client = useAppwrite()\n\n return getCollectionQuery<TDocument>(client, {\n databaseId,\n collectionId,\n queries,\n transactionId,\n fields,\n })\n}\n\nfunction useCollectionRealtime<TDocument>(\n databaseId: string,\n collectionId: string,\n queries: string[],\n subscribe: boolean,\n) {\n const { realtime } = useAppwrite()\n const queryClient = useQueryClient()\n const queriesKey = JSON.stringify(queries)\n\n useEffect(() => {\n if (!subscribe) {\n return\n }\n\n const subscriptionPromise = realtime.subscribe(\n Channel.tablesdb(databaseId).table(collectionId).row(),\n (response) => {\n const [, operation] = response.events[0].match(/\\.(\\w+)$/) as RegExpMatchArray\n const document = response.payload as Document<TDocument>\n\n switch (operation as DocumentOperation) {\n case 'create':\n case 'update':\n case 'delete':\n queryClient.setQueryData(\n Keys.database(databaseId).collection(collectionId).document(document.$id).key(),\n document,\n )\n\n void queryClient.invalidateQueries({\n queryKey: Keys.database(databaseId).collection(collectionId).key(),\n })\n\n break\n }\n },\n )\n\n return () => {\n void subscriptionPromise.then((sub) => sub.close())\n }\n }, [databaseId, collectionId, realtime, queryClient, queriesKey, subscribe])\n}\n\n/**\n * Fetches a collection of documents with optional real-time subscription (enabled by default).\n * Returns `documents` and `total` alongside the standard query result.\n *\n * @typeParam TDocument - The shape of each document's custom attributes.\n *\n * @example\n * ```tsx\n * const { documents, total, isLoading } = useCollection({\n * databaseId: 'my-db',\n * collectionId: 'my-collection',\n * queries: [Query.equal('status', 'active')],\n * })\n * ```\n *\n * **Parameters** (`CollectionParams`):\n * - `databaseId` — The database ID\n * - `collectionId` — The collection ID\n * - `queries` — Optional query filters (defaults to `[]`)\n * - `transactionId` — Optional transaction ID for atomic reads\n * - `subscribe` — Whether to subscribe to real-time updates (defaults to `true`)\n * - `fields` — Optional array of document fields to select\n *\n * @returns A `UseQueryResult` with the collection data as `Collection<TDocument>`, plus\n * convenience accessors `documents` and `total`.\n */\nexport function useCollection<TDocument>(\n {\n databaseId,\n collectionId,\n queries = [],\n transactionId,\n subscribe = true,\n fields,\n }: CollectionParams<TDocument>,\n opts: QueryOptions = {},\n) {\n const config = useCollectionQueryConfig<TDocument>({\n databaseId,\n collectionId,\n queries,\n transactionId,\n fields,\n })\n\n const collection = useQuery<Collection<TDocument>, AppwriteException[], Collection<TDocument>>({\n ...config,\n ...opts,\n })\n\n useCollectionRealtime<TDocument>(databaseId, collectionId, queries, subscribe)\n\n return {\n ...collection,\n documents: collection.data?.documents,\n total: collection.data?.total,\n }\n}\n\n/**\n * Suspense variant of {@link useCollection}. Suspends the component while loading.\n *\n * @typeParam TDocument - The shape of each document's custom attributes.\n *\n * @example\n * ```tsx\n * const { documents, total } = useSuspenseCollection({\n * databaseId: 'my-db',\n * collectionId: 'my-collection',\n * })\n * ```\n *\n * **Parameters** (`CollectionParams`):\n * - `databaseId` — The database ID\n * - `collectionId` — The collection ID\n * - `queries` — Optional query filters\n * - `transactionId` — Optional transaction ID for atomic reads\n * - `subscribe` — Whether to subscribe to real-time updates (defaults to `true`)\n * - `fields` — Optional array of document fields to select\n *\n * @returns A `UseSuspenseQueryResult` with the collection data as `Collection<TDocument>`, plus\n * convenience accessors `documents` and `total`.\n */\nexport function useSuspenseCollection<TDocument>(\n {\n databaseId,\n collectionId,\n queries,\n transactionId,\n subscribe = true,\n fields,\n }: CollectionParams<TDocument>,\n opts: QueryOptions = {},\n) {\n const config = useCollectionQueryConfig<TDocument>({\n databaseId,\n collectionId,\n queries,\n transactionId,\n fields,\n })\n\n const collection = useSuspenseQuery<\n Collection<TDocument>,\n AppwriteException[],\n Collection<TDocument>\n >({\n ...config,\n ...opts,\n })\n\n useCollectionRealtime<TDocument>(databaseId, collectionId, queries, subscribe)\n\n return {\n ...collection,\n documents: collection.data?.documents,\n total: collection.data?.total,\n }\n}\n","import { useRef, useState } from 'react'\nimport { Query } from 'appwrite'\n\nimport { useCollection, useSuspenseCollection } from './useCollection'\nimport type { QueryOptions } from '../types'\n\ntype PaginationParams<TDocument = Record<string, unknown>> = {\n databaseId: string\n collectionId: string\n queries: string[]\n transactionId?: string\n limit?: number\n fields?: (keyof TDocument & string)[]\n}\n\nfunction usePaginationState(limit: number) {\n const [page, setPage] = useState(1)\n const totalRef = useRef(0)\n const offset = (page - 1) * limit\n\n const nextPage = () => {\n setPage((prevPage) => {\n const currentOffset = (prevPage - 1) * limit\n if (totalRef.current > 0 && currentOffset + limit < totalRef.current) {\n return prevPage + 1\n }\n return prevPage\n })\n }\n\n const previousPage = () => {\n setPage((prevPage) => (prevPage > 1 ? prevPage - 1 : prevPage))\n }\n\n const handlePageChange = (newPage: number) => {\n if (newPage < 1) return\n if (totalRef.current > 0) {\n const maxPage = Math.ceil(totalRef.current / limit)\n if (newPage > maxPage) return\n }\n setPage(newPage)\n }\n\n return { page, offset, totalRef, nextPage, previousPage, handlePageChange }\n}\n\n/**\n * Fetches a paginated collection of documents. Returns pagination helpers\n * (`page`, `hasNextPage`, `hasPreviousPage`, `nextPage`, `previousPage`, `handlePageChange`).\n * Default page limit is 25.\n *\n * @typeParam TDocument - The shape of each document's custom attributes.\n *\n * @example\n * ```tsx\n * const { documents, page, nextPage, previousPage, hasNextPage } =\n * useCollectionWithPagination({\n * databaseId: 'my-db',\n * collectionId: 'my-collection',\n * queries: [Query.equal('status', 'active')],\n * limit: 10,\n * })\n * ```\n *\n * **Parameters** (`PaginationParams`):\n * - `databaseId` — The database ID\n * - `collectionId` — The collection ID\n * - `queries` — Query filters applied to the collection\n * - `transactionId` — Optional transaction ID for atomic reads\n * - `limit` — Number of documents per page (defaults to `25`)\n * - `fields` — Optional array of document fields to select\n *\n * @returns An object with `documents`, `total`, `page`, `hasNextPage`, `hasPreviousPage`,\n * `nextPage()`, `previousPage()`, `handlePageChange(page)`, and standard query status flags.\n */\nexport function useCollectionWithPagination<TDocument>(\n {\n databaseId,\n collectionId,\n queries,\n transactionId,\n limit = 25,\n fields,\n }: PaginationParams<TDocument>,\n opts: QueryOptions = {},\n) {\n const { page, offset, totalRef, nextPage, previousPage, handlePageChange } =\n usePaginationState(limit)\n\n const collection = useCollection<TDocument>(\n {\n databaseId,\n collectionId,\n queries: [...queries, Query.limit(limit), Query.offset(offset)],\n transactionId,\n fields,\n },\n opts,\n )\n\n const total = collection.data?.total ?? 0\n totalRef.current = total\n\n return {\n documents: collection.data?.documents ?? [],\n total,\n page,\n hasNextPage: total > 0 && offset + limit < total,\n hasPreviousPage: page > 1,\n handlePageChange,\n nextPage,\n previousPage,\n isLoading: collection.isLoading,\n isError: collection.isError,\n error: collection.error,\n isFetching: collection.isFetching,\n }\n}\n\n/**\n * Suspense variant of {@link useCollectionWithPagination}. Suspends the component while loading.\n *\n * @typeParam TDocument - The shape of each document's custom attributes.\n *\n * @example\n * ```tsx\n * const { documents, page, nextPage, hasNextPage } =\n * useSuspenseCollectionWithPagination({\n * databaseId: 'my-db',\n * collectionId: 'my-collection',\n * queries: [Query.equal('status', 'active')],\n * })\n * ```\n *\n * **Parameters** (`PaginationParams`):\n * - `databaseId` — The database ID\n * - `collectionId` — The collection ID\n * - `queries` — Query filters applied to the collection\n * - `transactionId` — Optional transaction ID for atomic reads\n * - `limit` — Number of documents per page (defaults to `25`)\n * - `fields` — Optional array of document fields to select\n *\n * @returns An object with `documents`, `total`, `page`, `hasNextPage`, `hasPreviousPage`,\n * `nextPage()`, `previousPage()`, `handlePageChange(page)`, and standard query status flags.\n */\nexport function useSuspenseCollectionWithPagination<TDocument>(\n {\n databaseId,\n collectionId,\n queries,\n transactionId,\n limit = 25,\n fields,\n }: PaginationParams<TDocument>,\n opts: QueryOptions = {},\n) {\n const { page, offset, totalRef, nextPage, previousPage, handlePageChange } =\n usePaginationState(limit)\n\n const collection = useSuspenseCollection<TDocument>(\n {\n databaseId,\n collectionId,\n queries: [...queries, Query.limit(limit), Query.offset(offset)],\n transactionId,\n fields,\n },\n opts,\n )\n\n const total = collection.total ?? 0\n totalRef.current = total\n\n return {\n documents: collection.documents ?? [],\n total,\n page,\n hasNextPage: total > 0 && offset + limit < total,\n hasPreviousPage: page > 1,\n handlePageChange,\n nextPage,\n previousPage,\n isLoading: collection.isLoading,\n isError: collection.isError,\n error: collection.error,\n isFetching: collection.isFetching,\n }\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nexport const createDocument = gql(/* GraphQL */ `\n mutation CreateDocument(\n $databaseId: String!\n $collectionId: String!\n $documentId: String!\n $data: Json!\n $permissions: [String!]\n $transactionId: String\n ) {\n databasesCreateDocument(\n databaseId: $databaseId\n collectionId: $collectionId\n documentId: $documentId\n data: $data\n permissions: $permissions\n transactionId: $transactionId\n ) {\n _id\n }\n }\n`)\n\ntype Variables = VariablesOf<typeof createDocument>\n\n/** The result returned after creating a document. */\nexport type CreateDocumentResult = Prettify<\n ResultOf<typeof createDocument>['databasesCreateDocument']\n>\n\n/** The variables accepted by the {@link useCreateDocument} mutation. */\nexport type CreateDocumentVariables = Prettify<\n Omit<Variables, 'permissions'> & {\n permissions?: string[] | null\n }\n>\n\n/**\n * Mutation hook to create a new document.\n *\n * Invalidates collection queries and sets the new document in the cache on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useCreateDocument()\n *\n * mutate({\n * databaseId: 'my-db',\n * collectionId: 'my-collection',\n * documentId: ID.unique(),\n * data: { name: 'John', age: 30 },\n * permissions: ['read(\"any\")'],\n * })\n * ```\n *\n * **Variables** ({@link CreateDocumentVariables}):\n * - `databaseId` — The target database ID\n * - `collectionId` — The target collection ID\n * - `documentId` — Unique document ID (use `ID.unique()` for auto-generation)\n * - `data` — The document data as a JSON-serializable object\n * - `permissions` — Optional array of permission strings, or `null`\n * - `transactionId` — Optional transaction ID for atomic operations\n *\n * @returns A `UseMutationResult` with the created document's `_id`.\n */\nexport function useCreateDocument() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const mutationResult = useMutation<\n CreateDocumentResult,\n AppwriteException[],\n CreateDocumentVariables\n >({\n mutationKey: Keys.databases().collections().documents().create(),\n mutationFn: async ({\n databaseId,\n collectionId,\n documentId,\n data,\n permissions,\n transactionId,\n }) => {\n const { data: mutationData, errors } = await graphql.mutation({\n query: createDocument,\n variables: {\n databaseId,\n collectionId,\n documentId,\n data: JSON.stringify(data),\n permissions,\n transactionId,\n },\n })\n\n if (errors) {\n throw errors\n }\n return mutationData.databasesCreateDocument\n },\n onSuccess: (result, variables) => {\n const documentKeyPrefix = Keys.database(variables.databaseId)\n .collection(variables.collectionId)\n .document(result._id)\n .key()\n\n void queryClient.invalidateQueries({\n queryKey: Keys.database(variables.databaseId).collection(variables.collectionId).key(),\n })\n\n queryClient.setQueryData<Variables>(documentKeyPrefix, {\n ...variables,\n ...(variables.data as Record<string, unknown>),\n })\n },\n })\n\n return mutationResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst createOperations = gql(/* GraphQL */ `\n mutation CreateOperations($transactionId: String!, $operations: [String!]) {\n databasesCreateOperations(transactionId: $transactionId, operations: $operations) {\n _id\n status\n operations\n expiresAt\n }\n }\n`)\n\n/** The variables accepted by the {@link useCreateOperations} mutation. */\nexport type CreateOperationsVariables = Prettify<VariablesOf<typeof createOperations>>\n\n/** The result returned by the {@link useCreateOperations} mutation. */\nexport type CreateOperationsResult = Prettify<\n ResultOf<typeof createOperations>['databasesCreateOperations']\n>\n\n/**\n * Mutation hook to add operations to an existing transaction.\n *\n * Invalidates the parent transaction query on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useCreateOperations()\n *\n * mutate({\n * transactionId: 'txn-abc',\n * operations: [\n * JSON.stringify({ action: 'create', databaseId: 'my-db', collectionId: 'my-col', documentId: 'doc-1', data: '{}' }),\n * ],\n * })\n * ```\n *\n * **Variables** ({@link CreateOperationsVariables}):\n * - `transactionId` — The ID of the transaction to append operations to\n * - `operations` — Optional array of JSON-encoded operation strings\n *\n * @returns A `UseMutationResult` with the transaction's `_id`, `status`, `operations` list, and `expiresAt` timestamp.\n */\nexport function useCreateOperations() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const mutationResult = useMutation<\n CreateOperationsResult,\n AppwriteException[],\n CreateOperationsVariables\n >({\n mutationKey: Keys.databases().transactions().operations().create(),\n mutationFn: async ({ transactionId, operations }) => {\n const { data, errors } = await graphql.mutation({\n query: createOperations,\n variables: { transactionId, operations },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.databasesCreateOperations\n },\n onSuccess: (_, variables) => {\n void queryClient.invalidateQueries({\n queryKey: Keys.databases().transaction(variables.transactionId).key(),\n })\n },\n })\n\n return mutationResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst createTransaction = gql(/* GraphQL */ `\n mutation CreateTransaction($ttl: Int) {\n databasesCreateTransaction(ttl: $ttl) {\n _id\n status\n operations\n expiresAt\n }\n }\n`)\n\n/** The variables accepted by the {@link useCreateTransaction} mutation. */\nexport type CreateTransactionVariables = Prettify<VariablesOf<typeof createTransaction>>\n\n/** The result returned by the {@link useCreateTransaction} mutation. */\nexport type CreateTransactionResult = Prettify<\n ResultOf<typeof createTransaction>['databasesCreateTransaction']\n>\n\n/**\n * Mutation hook to create a new database transaction with optional TTL.\n *\n * Invalidates transaction list queries on success.\n *\n * @example\n * ```tsx\n * const { mutate, data } = useCreateTransaction()\n *\n * // Create a transaction with a 60-second TTL\n * mutate({ ttl: 60 })\n *\n * // Or create one with the default TTL\n * mutate({})\n * ```\n *\n * **Variables** ({@link CreateTransactionVariables}):\n * - `ttl` — Optional time-to-live in seconds for the transaction before it auto-expires\n *\n * @returns A `UseMutationResult` with the transaction's `_id`, `status`, `operations` list, and `expiresAt` timestamp.\n */\nexport function useCreateTransaction() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const mutationResult = useMutation<\n CreateTransactionResult,\n AppwriteException[],\n CreateTransactionVariables\n >({\n mutationKey: Keys.databases().transactions().create(),\n mutationFn: async ({ ttl } = {}) => {\n const { data, errors } = await graphql.mutation({\n query: createTransaction,\n variables: { ttl },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.databasesCreateTransaction\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({\n queryKey: Keys.databases().transactions().key(),\n })\n },\n })\n\n return mutationResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nexport const decrementDocumentAttribute = gql(/* GraphQL */ `\n mutation DecrementDocumentAttribute(\n $databaseId: String!\n $collectionId: String!\n $documentId: String!\n $attribute: String!\n $value: Int\n $min: Int\n $transactionId: String\n ) {\n databasesDecrementDocumentAttribute(\n databaseId: $databaseId\n collectionId: $collectionId\n documentId: $documentId\n attribute: $attribute\n value: $value\n min: $min\n transactionId: $transactionId\n ) {\n _id\n data\n }\n }\n`)\n\n/** The variables accepted by the {@link useDecrementAttribute} mutation. */\nexport type DecrementAttributeVariables = Prettify<VariablesOf<typeof decrementDocumentAttribute>>\n\n/** The result returned by the {@link useDecrementAttribute} mutation. */\nexport type DecrementAttributeResult = Prettify<\n ResultOf<typeof decrementDocumentAttribute>['databasesDecrementDocumentAttribute']\n>\n\n/**\n * Mutation hook to atomically decrement a numeric document attribute with optimistic updates.\n *\n * Accepts an optional `value` (default: 1) and `min` floor. The optimistic update\n * immediately reflects the new value in the cache and rolls back on error.\n *\n * @example\n * ```tsx\n * const { mutate } = useDecrementAttribute()\n *\n * // Decrement \"lives\" by 1\n * mutate({\n * databaseId: 'my-db',\n * collectionId: 'players',\n * documentId: 'player-1',\n * attribute: 'lives',\n * })\n *\n * // Decrement \"balance\" by 50, floored at 0\n * mutate({\n * databaseId: 'my-db',\n * collectionId: 'accounts',\n * documentId: 'acct-1',\n * attribute: 'balance',\n * value: 50,\n * min: 0,\n * })\n * ```\n *\n * **Variables** ({@link DecrementAttributeVariables}):\n * - `databaseId` — The target database ID\n * - `collectionId` — The target collection ID\n * - `documentId` — The ID of the document containing the attribute\n * - `attribute` — The name of the numeric attribute to decrement\n * - `value` — Optional decrement amount (defaults to `1`)\n * - `min` — Optional minimum floor; the attribute will not go below this value\n * - `transactionId` — Optional transaction ID for atomic operations\n *\n * @returns A `UseMutationResult` with the document's `_id` and updated `data`.\n */\nexport function useDecrementAttribute() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const mutationResult = useMutation<\n DecrementAttributeResult,\n AppwriteException[],\n DecrementAttributeVariables,\n {\n previousEntries: [queryKey: readonly unknown[], data: unknown][]\n documentKeyPrefix: readonly unknown[]\n }\n >({\n mutationKey: [...Keys.databases().transactions().operations().key(), 'decrementAttribute'],\n mutationFn: async ({\n databaseId,\n collectionId,\n documentId,\n attribute,\n value,\n min,\n transactionId,\n }) => {\n const { data: mutationData, errors } = await graphql.mutation({\n query: decrementDocumentAttribute,\n variables: {\n databaseId,\n collectionId,\n documentId,\n attribute,\n value,\n min,\n transactionId,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return mutationData.databasesDecrementDocumentAttribute\n },\n onMutate: async (variables) => {\n const documentKeyPrefix = Keys.database(variables.databaseId)\n .collection(variables.collectionId)\n .document(variables.documentId)\n .key()\n\n await queryClient.cancelQueries({ queryKey: documentKeyPrefix })\n\n const previousEntries = queryClient.getQueriesData({\n queryKey: documentKeyPrefix,\n })\n\n queryClient.setQueryData<DecrementAttributeVariables>(documentKeyPrefix, (old) => {\n if (!old) return old\n const current = (old[variables.attribute] as number) ?? 0\n const decrement = variables.value ?? 1\n const newValue =\n variables.min != null ? Math.max(current - decrement, variables.min) : current - decrement\n\n return { ...old, [variables.attribute]: newValue }\n })\n\n return { previousEntries, documentKeyPrefix }\n },\n onError: (_, __, context) => {\n if (context?.previousEntries) {\n for (const [key, data] of context.previousEntries) {\n queryClient.setQueryData(key, data)\n }\n }\n },\n onSettled: (_, __, variables) => {\n void queryClient.invalidateQueries({\n queryKey: Keys.database(variables.databaseId).collection(variables.collectionId).key(),\n })\n },\n })\n\n return mutationResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nexport const deleteDocument = gql(/* GraphQL */ `\n mutation DeleteDocument(\n $databaseId: String!\n $collectionId: String!\n $documentId: String!\n $transactionId: String\n ) {\n databasesDeleteDocument(\n databaseId: $databaseId\n collectionId: $collectionId\n documentId: $documentId\n transactionId: $transactionId\n ) {\n status\n }\n }\n`)\n\n/** The variables accepted by the {@link useDeleteDocument} mutation. */\nexport type DeleteDocumentVariables = Prettify<VariablesOf<typeof deleteDocument>>\n\n/** The result returned by the {@link useDeleteDocument} mutation. */\nexport type DeleteDocumentResult = Prettify<\n ResultOf<typeof deleteDocument>['databasesDeleteDocument']\n>\n\n/**\n * Mutation hook to delete a document with optimistic removal.\n *\n * Removes the document from cache immediately and rolls back on error.\n * On settlement, the document queries are removed and the parent collection\n * queries are invalidated.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useDeleteDocument()\n *\n * mutate({\n * databaseId: 'my-db',\n * collectionId: 'my-collection',\n * documentId: 'doc-123',\n * })\n * ```\n *\n * **Variables** ({@link DeleteDocumentVariables}):\n * - `databaseId` — The target database ID\n * - `collectionId` — The target collection ID\n * - `documentId` — The ID of the document to delete\n * - `transactionId` — Optional transaction ID for atomic operations\n *\n * @returns A `UseMutationResult` with a `status` string indicating the deletion result.\n */\nexport function useDeleteDocument() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const mutationResult = useMutation<\n DeleteDocumentResult,\n AppwriteException[],\n DeleteDocumentVariables,\n {\n previousEntries: [queryKey: readonly unknown[], data: unknown][]\n documentKeyPrefix: readonly unknown[]\n }\n >({\n mutationKey: Keys.databases().collections().documents().delete(),\n mutationFn: async ({ databaseId, collectionId, documentId, transactionId }) => {\n const { data: mutationData, errors } = await graphql.mutation({\n query: deleteDocument,\n variables: {\n databaseId,\n collectionId,\n documentId,\n transactionId,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return mutationData?.databasesDeleteDocument ?? { status: '' }\n },\n onMutate: async (variables) => {\n const documentKeyPrefix = Keys.database(variables.databaseId)\n .collection(variables.collectionId)\n .document(variables.documentId)\n .key()\n\n await queryClient.cancelQueries({ queryKey: documentKeyPrefix })\n\n const previousEntries = queryClient.getQueriesData({\n queryKey: documentKeyPrefix,\n })\n\n queryClient.removeQueries({ queryKey: documentKeyPrefix })\n\n return { previousEntries, documentKeyPrefix }\n },\n onError: (_, __, context) => {\n if (context?.previousEntries) {\n for (const [key, data] of context.previousEntries) {\n queryClient.setQueryData(key, data)\n }\n }\n },\n onSettled: (_, __, variables) => {\n queryClient.removeQueries({\n queryKey: Keys.database(variables.databaseId)\n .collection(variables.collectionId)\n .document(variables.documentId)\n .key(),\n })\n void queryClient.invalidateQueries({\n queryKey: Keys.database(variables.databaseId).collection(variables.collectionId).key(),\n })\n },\n })\n\n return mutationResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst deleteTransaction = gql(/* GraphQL */ `\n mutation DeleteTransaction($transactionId: String!) {\n databasesDeleteTransaction(transactionId: $transactionId) {\n status\n }\n }\n`)\n\n/** The variables accepted by the {@link useDeleteTransaction} mutation. */\nexport type DeleteTransactionVariables = Prettify<VariablesOf<typeof deleteTransaction>>\n\n/** The result returned by the {@link useDeleteTransaction} mutation. */\nexport type DeleteTransactionResult = Prettify<\n ResultOf<typeof deleteTransaction>['databasesDeleteTransaction']\n>\n\n/**\n * Mutation hook to delete a transaction by its ID.\n *\n * Removes the transaction from cache and invalidates transaction list queries on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useDeleteTransaction()\n *\n * mutate({ transactionId: 'txn-abc' })\n * ```\n *\n * **Variables** ({@link DeleteTransactionVariables}):\n * - `transactionId` — The ID of the transaction to delete\n *\n * @returns A `UseMutationResult` with a `status` string indicating the deletion result.\n */\nexport function useDeleteTransaction() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const mutationResult = useMutation<\n DeleteTransactionResult,\n AppwriteException[],\n DeleteTransactionVariables\n >({\n mutationKey: Keys.databases().transactions().delete(),\n mutationFn: async ({ transactionId }) => {\n const { data, errors } = await graphql.mutation({\n query: deleteTransaction,\n variables: { transactionId },\n })\n\n if (errors) {\n throw errors\n }\n\n return data?.databasesDeleteTransaction ?? { status: '' }\n },\n onSuccess: (_, variables) => {\n queryClient.removeQueries({\n queryKey: Keys.databases().transaction(variables.transactionId).key(),\n })\n void queryClient.invalidateQueries({\n queryKey: Keys.databases().transactions().key(),\n })\n },\n })\n\n return mutationResult\n}\n","import { useEffect } from 'react'\nimport { Channel } from 'appwrite'\nimport type { VariablesOf } from 'gql.tada'\n\nimport type { getDocument } from './queryOptions'\nimport { getDocumentQuery } from './queryOptions'\nimport type { Document } from './types'\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, QueryOptions } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\nimport { useQueryClient } from '../useQueryClient'\nimport { useSuspenseQuery } from '../useSuspenseQuery'\n\ntype Variables = VariablesOf<typeof getDocument>\n\n/** The parameters accepted by the {@link useDocument} hook. */\nexport type DocumentParams<TDocument = Record<string, unknown>> = Variables & {\n fields?: (keyof TDocument & string)[]\n}\n\nfunction useDocumentQueryConfig<TDocument>({\n databaseId,\n collectionId,\n documentId,\n queries,\n transactionId,\n fields,\n}: DocumentParams<TDocument>) {\n const client = useAppwrite()\n\n return getDocumentQuery<TDocument>(client, {\n databaseId,\n collectionId,\n documentId,\n queries,\n transactionId,\n fields,\n })\n}\n\nfunction useDocumentRealtime(\n databaseId: string,\n collectionId: string,\n documentId: string,\n queriesKey: string,\n) {\n const { realtime } = useAppwrite()\n const queryClient = useQueryClient()\n\n useEffect(() => {\n const subscriptionPromise = realtime.subscribe(\n Channel.tablesdb(databaseId).table(collectionId).row(documentId).update(),\n (response) => {\n queryClient.setQueryData(\n Keys.database(databaseId).collection(collectionId).document(documentId).key(),\n response.payload,\n )\n },\n )\n\n return () => {\n void subscriptionPromise.then((sub) => sub.close())\n }\n }, [databaseId, collectionId, documentId, realtime, queryClient, queriesKey])\n}\n\n/**\n * Fetches a single document by ID and subscribes to real-time updates.\n *\n * @typeParam TDocument - The shape of the document's custom attributes.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useDocument({\n * databaseId: 'my-db',\n * collectionId: 'my-collection',\n * documentId: 'doc-123',\n * })\n * ```\n *\n * **Parameters** ({@link DocumentParams}):\n * - `databaseId` — The database ID\n * - `collectionId` — The collection ID\n * - `documentId` — The document ID to fetch\n * - `queries` — Optional query filters\n * - `transactionId` — Optional transaction ID for atomic reads\n * - `fields` — Optional array of fields to select\n *\n * @returns A `UseQueryResult` with the document data as `Document<TDocument>`.\n */\nexport function useDocument<TDocument>(\n {\n databaseId,\n collectionId,\n documentId,\n queries,\n transactionId,\n fields,\n }: DocumentParams<TDocument>,\n opts: QueryOptions = {},\n) {\n const config = useDocumentQueryConfig<TDocument>({\n databaseId,\n collectionId,\n documentId,\n queries,\n transactionId,\n fields,\n })\n const queriesKey = JSON.stringify(queries)\n\n const queryResult = useQuery<Document<TDocument>, AppwriteException[], Document<TDocument>>({\n ...config,\n ...opts,\n })\n\n useDocumentRealtime(databaseId, collectionId, documentId, queriesKey)\n\n return queryResult\n}\n\n/**\n * Suspense variant of {@link useDocument}. Suspends the component while loading.\n *\n * @typeParam TDocument - The shape of the document's custom attributes.\n *\n * @example\n * ```tsx\n * const { data } = useSuspenseDocument({\n * databaseId: 'my-db',\n * collectionId: 'my-collection',\n * documentId: 'doc-123',\n * })\n * ```\n *\n * **Parameters** ({@link DocumentParams}):\n * - `databaseId` — The database ID\n * - `collectionId` — The collection ID\n * - `documentId` — The document ID to fetch\n * - `queries` — Optional query filters\n * - `transactionId` — Optional transaction ID for atomic reads\n * - `fields` — Optional array of fields to select\n *\n * @returns A `UseSuspenseQueryResult` with the document data as `Document<TDocument>`.\n */\nexport function useSuspenseDocument<TDocument>(\n {\n databaseId,\n collectionId,\n documentId,\n queries,\n transactionId,\n fields,\n }: DocumentParams<TDocument>,\n opts: QueryOptions = {},\n) {\n const config = useDocumentQueryConfig<TDocument>({\n databaseId,\n collectionId,\n documentId,\n queries,\n transactionId,\n fields,\n })\n const queriesKey = JSON.stringify(queries)\n\n const queryResult = useSuspenseQuery<\n Document<TDocument>,\n AppwriteException[],\n Document<TDocument>\n >({ ...config, ...opts })\n\n useDocumentRealtime(databaseId, collectionId, documentId, queriesKey)\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify, QueryOptions } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst getTransaction = gql(/* GraphQL */ `\n query GetTransaction($transactionId: String!) {\n databasesGetTransaction(transactionId: $transactionId) {\n _id\n _createdAt\n _updatedAt\n status\n operations\n expiresAt\n }\n }\n`)\n\n/** The variables accepted by the {@link useGetTransaction} hook. */\nexport type GetTransactionVariables = Prettify<VariablesOf<typeof getTransaction>>\n\n/** The result returned by the {@link useGetTransaction} hook. */\nexport type GetTransactionResult = Prettify<\n ResultOf<typeof getTransaction>['databasesGetTransaction']\n>\n\n/**\n * Fetches a transaction by its ID, including status, operations, and expiry.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useGetTransaction({\n * transactionId: 'txn-abc-123',\n * })\n * ```\n *\n * **Parameters** ({@link GetTransactionVariables}):\n * - `transactionId` — The ID of the transaction to fetch\n *\n * @returns A `UseQueryResult` with the transaction data as {@link GetTransactionResult}.\n */\nexport function useGetTransaction(\n { transactionId }: GetTransactionVariables,\n opts: QueryOptions = {},\n) {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<GetTransactionResult, AppwriteException[], GetTransactionResult>({\n queryKey: Keys.databases().transaction(transactionId).key(),\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: getTransaction,\n variables: { transactionId },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.databasesGetTransaction\n },\n ...opts,\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nexport const incrementDocumentAttribute = gql(/* GraphQL */ `\n mutation IncrementDocumentAttribute(\n $databaseId: String!\n $collectionId: String!\n $documentId: String!\n $attribute: String!\n $value: Int\n $max: Int\n $transactionId: String\n ) {\n databasesIncrementDocumentAttribute(\n databaseId: $databaseId\n collectionId: $collectionId\n documentId: $documentId\n attribute: $attribute\n value: $value\n max: $max\n transactionId: $transactionId\n ) {\n _id\n data\n }\n }\n`)\n\n/** The variables accepted by the {@link useIncrementAttribute} mutation. */\nexport type IncrementAttributeVariables = Prettify<VariablesOf<typeof incrementDocumentAttribute>>\n\n/** The result returned by the {@link useIncrementAttribute} mutation. */\nexport type IncrementAttributeResult = Prettify<\n ResultOf<typeof incrementDocumentAttribute>['databasesIncrementDocumentAttribute']\n>\n\n/**\n * Mutation hook to atomically increment a numeric document attribute with optimistic updates.\n *\n * Accepts an optional `value` (default: 1) and `max` ceiling. The optimistic update\n * immediately reflects the new value in the cache and rolls back on error.\n *\n * @example\n * ```tsx\n * const { mutate } = useIncrementAttribute()\n *\n * // Increment \"score\" by 1\n * mutate({\n * databaseId: 'my-db',\n * collectionId: 'players',\n * documentId: 'player-1',\n * attribute: 'score',\n * })\n *\n * // Increment \"lives\" by 3, capped at 10\n * mutate({\n * databaseId: 'my-db',\n * collectionId: 'players',\n * documentId: 'player-1',\n * attribute: 'lives',\n * value: 3,\n * max: 10,\n * })\n * ```\n *\n * **Variables** ({@link IncrementAttributeVariables}):\n * - `databaseId` — The target database ID\n * - `collectionId` — The target collection ID\n * - `documentId` — The ID of the document containing the attribute\n * - `attribute` — The name of the numeric attribute to increment\n * - `value` — Optional increment amount (defaults to `1`)\n * - `max` — Optional maximum ceiling; the attribute will not exceed this value\n * - `transactionId` — Optional transaction ID for atomic operations\n *\n * @returns A `UseMutationResult` with the document's `_id` and updated `data`.\n */\nexport function useIncrementAttribute() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const mutationResult = useMutation<\n IncrementAttributeResult,\n AppwriteException[],\n IncrementAttributeVariables,\n {\n previousEntries: [queryKey: readonly unknown[], data: unknown][]\n documentKeyPrefix: readonly unknown[]\n }\n >({\n mutationKey: [...Keys.databases().transactions().operations().key(), 'incrementAttribute'],\n mutationFn: async ({\n databaseId,\n collectionId,\n documentId,\n attribute,\n value,\n max,\n transactionId,\n }) => {\n const { data: mutationData, errors } = await graphql.mutation({\n query: incrementDocumentAttribute,\n variables: {\n databaseId,\n collectionId,\n documentId,\n attribute,\n value,\n max,\n transactionId,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return mutationData.databasesIncrementDocumentAttribute\n },\n onMutate: async (variables) => {\n const documentKeyPrefix = Keys.database(variables.databaseId)\n .collection(variables.collectionId)\n .document(variables.documentId)\n .key()\n\n await queryClient.cancelQueries({ queryKey: documentKeyPrefix })\n\n const previousEntries = queryClient.getQueriesData({\n queryKey: documentKeyPrefix,\n })\n\n queryClient.setQueryData<IncrementAttributeVariables>(documentKeyPrefix, (old) => {\n if (!old) return old\n const current = (old[variables.attribute] as number) ?? 0\n const increment = variables.value ?? 1\n const newValue =\n variables.max != null ? Math.min(current + increment, variables.max) : current + increment\n\n return { ...old, [variables.attribute]: newValue }\n })\n\n return { previousEntries, documentKeyPrefix }\n },\n onError: (_, __, context) => {\n if (context?.previousEntries) {\n for (const [key, data] of context.previousEntries) {\n queryClient.setQueryData(key, data)\n }\n }\n },\n onSettled: (_, __, variables) => {\n void queryClient.invalidateQueries({\n queryKey: Keys.database(variables.databaseId).collection(variables.collectionId).key(),\n })\n },\n })\n\n return mutationResult\n}\n","import { useCallback, useEffect, useState } from 'react'\nimport { Query } from 'appwrite'\n\nimport type { Document } from './types'\nimport { useCollection } from './useCollection'\n\n/**\n * Fetches documents with infinite scroll pagination, accumulating results across pages.\n * Returns `documents`, `total`, `hasNextPage`, `fetchNextPage`, `isFetchingNextPage`, and `reset`.\n * Default page limit is 25.\n *\n * @typeParam TDocument - The shape of each document's custom attributes.\n *\n * @example\n * ```tsx\n * const { documents, fetchNextPage, hasNextPage, isFetchingNextPage } =\n * useInfiniteCollection({\n * databaseId: 'my-db',\n * collectionId: 'my-collection',\n * queries: [Query.orderDesc('$createdAt')],\n * limit: 20,\n * })\n * ```\n *\n * **Parameters:**\n * - `databaseId` — The database ID\n * - `collectionId` — The collection ID\n * - `queries` — Query filters applied to the collection\n * - `transactionId` — Optional transaction ID for atomic reads\n * - `limit` — Number of documents per page (defaults to `25`)\n * - `subscribe` — Whether to subscribe to real-time updates (defaults to `true`)\n * - `fields` — Optional array of document fields to select\n *\n * @returns An object with accumulated `documents`, `total`, `hasNextPage`, `fetchNextPage()`,\n * `isFetchingNextPage`, `reset()`, and standard query status flags.\n */\nexport function useInfiniteCollection<TDocument>({\n databaseId,\n collectionId,\n queries,\n transactionId,\n limit = 25,\n subscribe = true,\n fields,\n}: {\n databaseId: string\n collectionId: string\n queries: string[]\n transactionId?: string\n limit?: number\n subscribe?: boolean\n fields?: (keyof TDocument & string)[]\n}) {\n const [page, setPage] = useState(1)\n const [accumulated, setAccumulated] = useState<Document<TDocument>[]>([])\n\n const offset = (page - 1) * limit\n const paginatedQueries = [...queries, Query.limit(limit), Query.offset(offset)]\n\n const collection = useCollection<TDocument>({\n databaseId,\n collectionId,\n queries: paginatedQueries,\n transactionId,\n subscribe,\n fields,\n })\n\n // Accumulate documents across pages\n useEffect(() => {\n if (collection.documents) {\n if (page === 1) {\n setAccumulated([...collection.documents])\n } else {\n setAccumulated((prev) => {\n // Only append if we don't already have documents for this page\n const expectedLength = (page - 1) * limit + collection.documents!.length\n if (prev.length < expectedLength) {\n return [...prev, ...collection.documents!]\n }\n return prev\n })\n }\n }\n }, [collection.documents, page, limit])\n\n const total = collection.total ?? 0\n const hasNextPage = total > 0 && offset + limit < total\n\n const fetchNextPage = useCallback(() => {\n if (hasNextPage && !collection.isFetching) {\n setPage((prev) => prev + 1)\n }\n }, [hasNextPage, collection.isFetching])\n\n const reset = useCallback(() => {\n setAccumulated([])\n setPage(1)\n }, [])\n\n return {\n documents: accumulated,\n total,\n hasNextPage,\n fetchNextPage,\n isFetchingNextPage: page > 1 && collection.isFetching,\n isLoading: collection.isLoading,\n isError: collection.isError,\n error: collection.error,\n isFetching: collection.isFetching,\n reset,\n }\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify, QueryOptions } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst listTransactions = gql(/* GraphQL */ `\n query ListTransactions($queries: String) {\n databasesListTransactions(queries: $queries) {\n total\n transactions {\n _id\n _createdAt\n _updatedAt\n status\n operations\n expiresAt\n }\n }\n }\n`)\n\n/** The result returned by the {@link useListTransactions} hook. */\nexport type ListTransactionsResult = Prettify<\n ResultOf<typeof listTransactions>['databasesListTransactions']\n>\n\n/**\n * Fetches a list of database transactions with optional query filters.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useListTransactions()\n * ```\n *\n * **Parameters:**\n * - `queries` — Optional query string to filter transactions\n *\n * @returns A `UseQueryResult` with the transaction list as {@link ListTransactionsResult},\n * containing `total` and `transactions`.\n */\nexport function useListTransactions(\n { queries }: { queries?: string } = {},\n opts: QueryOptions = {},\n) {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<ListTransactionsResult, AppwriteException[], ListTransactionsResult>(\n {\n queryKey: [...Keys.databases().transactions().key(), ...(queries ? [queries] : [])],\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: listTransactions,\n variables: { queries },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.databasesListTransactions\n },\n ...opts,\n },\n )\n\n return queryResult\n}\n","import type { ConflictContext, ConflictStrategy } from './types'\n\n/**\n * Applies a conflict resolution strategy to produce the merged document data\n * that should be sent to the server, or `'abort'` to discard the mutation.\n *\n * @returns The resolved field-level data (not the full document — just the\n * fields to write), or `'abort'` if the mutation should be dropped.\n */\nexport function resolveConflict(\n context: ConflictContext,\n strategy: ConflictStrategy,\n): Record<string, unknown> | 'abort' {\n if (typeof strategy === 'function') {\n return strategy(context)\n }\n\n switch (strategy) {\n case 'last-write-wins':\n return extractChangedFields(context.base, context.local)\n\n case 'server-wins':\n return 'abort'\n\n case 'merge-shallow': {\n const localChanges = extractChangedFields(context.base, context.local)\n const remoteChanges = extractChangedFields(context.base, context.remote)\n\n // Remote changes win where both sides modified the same field\n return { ...localChanges, ...remoteChanges }\n }\n }\n}\n\n/**\n * Returns only the fields in `updated` that differ from `original`.\n */\nfunction extractChangedFields(\n original: Record<string, unknown>,\n updated: Record<string, unknown>,\n): Record<string, unknown> {\n const changes: Record<string, unknown> = {}\n\n for (const key of Object.keys(updated)) {\n if (JSON.stringify(original[key]) !== JSON.stringify(updated[key])) {\n changes[key] = updated[key]\n }\n }\n\n return changes\n}\n","import { Keys } from '../..'\nimport { getDocument } from '../../databases/queryOptions'\nimport { updateDocument } from '../../databases/useUpdateDocument'\nimport { resolveConflict } from '../conflictResolution/resolve'\nimport type { ConflictStrategy } from '../conflictResolution/types'\nimport type { MutationFn, Vars } from '../types'\n\n/**\n * Creates a conflict-aware mutationFn for document updates.\n *\n * When a base snapshot is available (persisted in MutationState.context by\n * useUpdateDocument's onMutate), the function fetches the current remote\n * document, runs the configured conflict resolution strategy, and sends the\n * resolved data. If no base snapshot exists (e.g. the mutation was created\n * while online and executed immediately), it falls through to a normal update.\n */\nexport function conflictAwareUpdate(conflictStrategy: ConflictStrategy): MutationFn {\n return async (client, variables, queryClient) => {\n const { databaseId, collectionId, documentId } = variables as {\n databaseId: string\n collectionId: string\n documentId: string\n }\n\n // Look up the mutation instance to read the persisted onMutate context\n const mutation = queryClient\n .getMutationCache()\n .getAll()\n .find((m) => JSON.stringify(m.state.variables) === JSON.stringify(variables))\n\n const baseSnapshot = (mutation?.state.context as { baseSnapshot?: Record<string, unknown> })\n ?.baseSnapshot\n\n let resolvedData = variables.data as Record<string, unknown>\n if (baseSnapshot) {\n const { data: remoteResult, errors: fetchErrors } = await client.graphql.query({\n query: getDocument,\n variables: { databaseId, collectionId, documentId },\n })\n\n if (fetchErrors) throw fetchErrors\n\n const rawRemote = remoteResult.databasesGetDocument\n const remote = {\n ...rawRemote,\n ...(rawRemote ? (JSON.parse(rawRemote.data as string) as Record<string, unknown>) : {}),\n } as Record<string, unknown>\n delete remote.data // Remove the raw JSON string from the remote document\n delete remote._id // Remove the _id field to avoid confusion during conflict resolution\n\n // Build the \"local\" document: the base with the user's changes applied\n const local = {\n ...baseSnapshot,\n ...(variables.data as Record<string, unknown>),\n }\n\n const result = resolveConflict(\n {\n base: baseSnapshot as never,\n remote: remote as never,\n local: local as never,\n mutationKey: [databaseId, collectionId, documentId],\n },\n conflictStrategy,\n )\n\n if (result === 'abort') {\n await queryClient.setQueryData(\n Keys.database(databaseId).collection(collectionId).document(documentId).key(),\n remote,\n )\n return { _id: documentId }\n }\n\n resolvedData = result\n }\n\n const { data, errors } = await client.graphql.mutation({\n query: updateDocument,\n variables: {\n ...variables,\n data: JSON.stringify(resolvedData.data ?? resolvedData),\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } as any,\n })\n\n const newData = (resolvedData.data ?? resolvedData) as Record<string, unknown>\n delete variables.data\n\n const thing = { ...baseSnapshot, ...newData, _id: documentId }\n\n await queryClient.setQueryData(\n Keys.database(databaseId).collection(collectionId).document(documentId).key(),\n (old: Record<string, unknown> | undefined) =>\n old\n ? {\n ...old,\n ...thing,\n }\n : old,\n )\n\n if (errors) throw errors\n return (data as Vars).databasesUpdateDocument as { _id: string }\n }\n}\n","import { onlineManager } from '@tanstack/react-query'\nimport type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport type { ConflictStrategy } from '../offline/conflictResolution/types'\nimport { conflictAwareUpdate } from '../offline/mutations/conflictAwareUpdate'\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nexport const updateDocument = gql(/* GraphQL */ `\n mutation UpdateDocument(\n $databaseId: String!\n $collectionId: String!\n $documentId: String!\n $data: Json\n $permissions: [String!]\n $transactionId: String\n ) {\n databasesUpdateDocument(\n databaseId: $databaseId\n collectionId: $collectionId\n documentId: $documentId\n data: $data\n permissions: $permissions\n transactionId: $transactionId\n ) {\n _id\n }\n }\n`)\n\ntype Variables = VariablesOf<typeof updateDocument>\n/** The result returned by the {@link useUpdateDocument} mutation. */\nexport type UpdateDocumentResult = Prettify<\n ResultOf<typeof updateDocument>['databasesUpdateDocument']\n>\n\n/** The variables accepted by the {@link useUpdateDocument} mutation. */\nexport type UpdateDocumentVariables = Prettify<\n Omit<Variables, 'permissions'> & {\n permissions?: string[] | null\n }\n>\n\n/** The optimistic-update context used by the {@link useUpdateDocument} mutation. */\nexport type UpdateDocumentMutationContext = {\n previousEntries: [queryKey: readonly unknown[], data: unknown][]\n documentKeyPrefix: readonly unknown[]\n baseSnapshot: Record<string, unknown> | undefined\n willPerformOfflineMutation: boolean\n}\n\n/**\n * Mutation hook to update an existing document with optimistic updates.\n *\n * Supports offline conflict resolution and rolls back optimistic updates on error.\n * When the device is offline, mutations are queued and replayed when connectivity\n * returns. A `conflictStrategy` (configured via the offline client) controls how\n * conflicts between the optimistic base snapshot and the server state are resolved.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useUpdateDocument()\n *\n * mutate({\n * databaseId: 'my-db',\n * collectionId: 'my-collection',\n * documentId: 'doc-123',\n * data: { name: 'Jane', age: 31 },\n * permissions: ['read(\"any\")', 'write(\"user:alice\")'],\n * })\n * ```\n *\n * **Variables** ({@link UpdateDocumentVariables}):\n * - `databaseId` — The target database ID\n * - `collectionId` — The target collection ID\n * - `documentId` — The ID of the document to update\n * - `data` — Optional partial document data to merge into the existing document\n * - `permissions` — Optional array of permission strings, or `null`\n * - `transactionId` — Optional transaction ID for atomic operations\n *\n * An optional `conflictStrategy` can be configured through the offline client to\n * control conflict resolution (e.g. `'last-write-wins'`, `'server-wins'`, or a\n * custom three-way merge function).\n *\n * @returns A `UseMutationResult` with the updated document's `_id`.\n */\nexport function useUpdateDocument() {\n const appwrite = useAppwrite()\n const queryClient = useQueryClient()\n\n const mutationResult = useMutation<\n UpdateDocumentResult,\n AppwriteException[],\n UpdateDocumentVariables,\n UpdateDocumentMutationContext\n >({\n mutationKey: Keys.databases().collections().documents().update(),\n mutationFn: async (\n { databaseId, collectionId, documentId, data, permissions, transactionId },\n ctx,\n ) => {\n const wasOffline = ctx.meta.willPerformOfflineMutation ?? false\n\n if (ctx.meta.willPerformOfflineMutation != null) {\n delete ctx.meta.willPerformOfflineMutation\n }\n\n if (wasOffline) {\n try {\n const updateData = (await conflictAwareUpdate(\n ctx.meta.conflictStrategy as ConflictStrategy,\n )(\n appwrite,\n {\n databaseId,\n collectionId,\n documentId,\n data,\n permissions,\n transactionId,\n },\n queryClient,\n )) as UpdateDocumentResult\n\n return updateData\n } catch (error) {\n console.error('Conflict-aware update failed:', error)\n throw error\n }\n }\n\n const { data: mutationData, errors } = await appwrite.graphql.mutation({\n query: updateDocument,\n variables: {\n databaseId,\n collectionId,\n documentId,\n data: JSON.stringify(data),\n permissions,\n transactionId,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return mutationData.databasesUpdateDocument\n },\n onMutate: async (variables, ctx) => {\n const documentKeyPrefix = Keys.database(variables.databaseId)\n .collection(variables.collectionId)\n .document(variables.documentId)\n .key()\n\n await queryClient.cancelQueries({ queryKey: documentKeyPrefix })\n\n const previousEntries = queryClient.getQueriesData({\n queryKey: documentKeyPrefix,\n })\n\n // Capture a deep copy of the document before optimistic update.\n // This snapshot is persisted in MutationState.context through\n // dehydration and serves as the \"base\" for three-way conflict\n // resolution when a paused mutation is replayed.\n const baseSnapshot = previousEntries.find(([, data]) => data != null)?.[1] as\n | Record<string, unknown>\n | undefined\n const baseSnapshotCopy = baseSnapshot\n ? (JSON.parse(JSON.stringify(baseSnapshot)) as Record<string, unknown>)\n : undefined\n\n queryClient.setQueryData<UpdateDocumentVariables>(documentKeyPrefix, (old) =>\n old ? { ...old, ...(variables.data as Record<string, unknown>) } : old,\n )\n\n const willPerformOfflineMutation = onlineManager.isOnline() === false\n ctx.meta = { ...ctx.meta, willPerformOfflineMutation }\n\n return {\n previousEntries,\n documentKeyPrefix,\n baseSnapshot: baseSnapshotCopy,\n willPerformOfflineMutation,\n }\n },\n onError: (_, __, context) => {\n if (context?.previousEntries) {\n for (const [key, data] of context.previousEntries) {\n queryClient.setQueryData(key, data)\n }\n }\n },\n onSettled: (_, __, variables) => {\n void queryClient.invalidateQueries({\n queryKey: Keys.database(variables.databaseId).collection(variables.collectionId).key(),\n })\n },\n })\n\n return mutationResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst updateTransaction = gql(/* GraphQL */ `\n mutation UpdateTransaction($transactionId: String!, $commit: Boolean, $rollback: Boolean) {\n databasesUpdateTransaction(\n transactionId: $transactionId\n commit: $commit\n rollback: $rollback\n ) {\n _id\n status\n operations\n }\n }\n`)\n\n/** The variables accepted by the {@link useUpdateTransaction} mutation. */\nexport type UpdateTransactionVariables = Prettify<VariablesOf<typeof updateTransaction>>\n\n/** The result returned by the {@link useUpdateTransaction} mutation. */\nexport type UpdateTransactionResult = Prettify<\n ResultOf<typeof updateTransaction>['databasesUpdateTransaction']\n>\n\n/**\n * Mutation hook to commit or rollback a transaction.\n *\n * Invalidates both the individual transaction query and the transaction list queries\n * on success.\n *\n * @example\n * ```tsx\n * const { mutate } = useUpdateTransaction()\n *\n * // Commit a transaction\n * mutate({ transactionId: 'txn-abc', commit: true })\n *\n * // Or roll it back\n * mutate({ transactionId: 'txn-abc', rollback: true })\n * ```\n *\n * **Variables** ({@link UpdateTransactionVariables}):\n * - `transactionId` — The ID of the transaction to update\n * - `commit` — Optional boolean; set to `true` to commit the transaction\n * - `rollback` — Optional boolean; set to `true` to rollback the transaction\n *\n * @returns A `UseMutationResult` with the transaction's `_id`, `status`, and `operations` list.\n */\nexport function useUpdateTransaction() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const mutationResult = useMutation<\n UpdateTransactionResult,\n AppwriteException[],\n UpdateTransactionVariables\n >({\n mutationKey: Keys.databases().transactions().update(),\n mutationFn: async ({ transactionId, commit, rollback }) => {\n const { data, errors } = await graphql.mutation({\n query: updateTransaction,\n variables: { transactionId, commit, rollback },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.databasesUpdateTransaction\n },\n onSuccess: (_, variables) => {\n void queryClient.invalidateQueries({\n queryKey: Keys.databases().transaction(variables.transactionId).key(),\n })\n void queryClient.invalidateQueries({\n queryKey: Keys.databases().transactions().key(),\n })\n },\n })\n\n return mutationResult\n}\n","import { onlineManager } from '@tanstack/react-query'\nimport type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport type { ConflictStrategy } from '../offline'\nimport { conflictAwareUpdate } from '../offline/mutations/conflictAwareUpdate'\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nexport const upsertDocument = gql(/* GraphQL */ `\n mutation UpsertDocument(\n $databaseId: String!\n $collectionId: String!\n $documentId: String!\n $data: Json!\n $permissions: [String!]\n $transactionId: String\n ) {\n databasesUpsertDocument(\n databaseId: $databaseId\n collectionId: $collectionId\n documentId: $documentId\n data: $data\n permissions: $permissions\n transactionId: $transactionId\n ) {\n _id\n }\n }\n`)\n\ntype Variables = VariablesOf<typeof upsertDocument>\n/** The result returned by the {@link useUpsertDocument} mutation. */\nexport type UpsertDocumentResult = Prettify<\n ResultOf<typeof upsertDocument>['databasesUpsertDocument']\n>\n\n/** The variables accepted by the {@link useUpsertDocument} mutation. */\nexport type UpsertDocumentVariables = Prettify<\n Omit<Variables, 'permissions'> & {\n permissions?: string[] | null\n }\n>\n\n/** The optimistic-update context used by the {@link useUpsertDocument} mutation. */\nexport type UpsertDocumentMutationContext = {\n previousEntries: [queryKey: readonly unknown[], data: unknown][]\n documentKeyPrefix: readonly unknown[]\n baseSnapshot: Record<string, unknown> | undefined\n willPerformOfflineMutation: boolean\n}\n\n/**\n * Mutation hook to create or update a document (upsert) with optimistic updates.\n *\n * Supports offline conflict resolution and rolls back on error. When the device is\n * offline, mutations are queued and replayed when connectivity returns. A\n * `conflictStrategy` (configured via the offline client) controls how conflicts\n * between the optimistic base snapshot and the server state are resolved.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useUpsertDocument()\n *\n * mutate({\n * databaseId: 'my-db',\n * collectionId: 'my-collection',\n * documentId: 'doc-456',\n * data: { name: 'Alice', score: 100 },\n * permissions: ['read(\"any\")'],\n * })\n * ```\n *\n * **Variables** ({@link UpsertDocumentVariables}):\n * - `databaseId` — The target database ID\n * - `collectionId` — The target collection ID\n * - `documentId` — Unique document ID — creates the document if it doesn't exist, updates it otherwise\n * - `data` — The document data as a JSON-serializable object\n * - `permissions` — Optional array of permission strings, or `null`\n * - `transactionId` — Optional transaction ID for atomic operations\n *\n * An optional `conflictStrategy` can be configured through the offline client to\n * control conflict resolution (e.g. `'last-write-wins'`, `'server-wins'`, or a\n * custom three-way merge function).\n *\n * @returns A `UseMutationResult` with the upserted document's `_id`.\n */\nexport function useUpsertDocument() {\n const appwrite = useAppwrite()\n const queryClient = useQueryClient()\n\n const mutationResult = useMutation<\n UpsertDocumentResult,\n AppwriteException[],\n UpsertDocumentVariables,\n UpsertDocumentMutationContext\n >({\n mutationKey: Keys.databases().collections().documents().upsert(),\n mutationFn: async (\n { databaseId, collectionId, documentId, data, permissions, transactionId },\n ctx,\n ) => {\n const wasOffline = ctx.meta.willPerformOfflineMutation ?? false\n\n if (ctx.meta.willPerformOfflineMutation != null) {\n delete ctx.meta.willPerformOfflineMutation\n }\n\n if (wasOffline) {\n try {\n const updateData = (await conflictAwareUpdate(\n ctx.meta.conflictStrategy as ConflictStrategy,\n )(\n appwrite,\n {\n databaseId,\n collectionId,\n documentId,\n data,\n permissions,\n transactionId,\n },\n queryClient,\n )) as UpsertDocumentResult\n\n return updateData\n } catch (error) {\n console.error('Conflict-aware update failed:', error)\n throw error\n }\n }\n\n const { data: mutationData, errors } = await appwrite.graphql.mutation({\n query: upsertDocument,\n variables: {\n databaseId,\n collectionId,\n documentId,\n data: JSON.stringify(data),\n permissions,\n transactionId,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return mutationData.databasesUpsertDocument\n },\n onMutate: async (variables, ctx) => {\n const documentKeyPrefix = Keys.database(variables.databaseId)\n .collection(variables.collectionId)\n .document(variables.documentId)\n .key()\n\n await queryClient.cancelQueries({ queryKey: documentKeyPrefix })\n\n const previousEntries = queryClient.getQueriesData({\n queryKey: documentKeyPrefix,\n })\n\n const baseSnapshot = previousEntries.find(([, data]) => data != null)?.[1] as\n | Record<string, unknown>\n | undefined\n const baseSnapshotCopy = baseSnapshot\n ? (JSON.parse(JSON.stringify(baseSnapshot)) as Record<string, unknown>)\n : undefined\n\n queryClient.setQueryData<UpsertDocumentVariables>(documentKeyPrefix, (old) =>\n old ? { ...old, ...(variables.data as Record<string, unknown>) } : old,\n )\n\n const willPerformOfflineMutation = onlineManager.isOnline() === false\n ctx.meta = { ...ctx.meta, willPerformOfflineMutation }\n\n return {\n previousEntries,\n documentKeyPrefix,\n baseSnapshot: baseSnapshotCopy,\n willPerformOfflineMutation,\n }\n },\n onError: (_, __, context) => {\n if (context?.previousEntries) {\n for (const [key, data] of context.previousEntries) {\n queryClient.setQueryData(key, data)\n }\n }\n },\n onSettled: (_, __, variables) => {\n void queryClient.invalidateQueries({\n queryKey: Keys.database(variables.databaseId).collection(variables.collectionId).key(),\n })\n },\n })\n\n return mutationResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst getLocale = gql(/* GraphQL */ `\n query GetLocale {\n localeGet {\n ip\n countryCode\n country\n continentCode\n continent\n eu\n currency\n }\n }\n`)\n\n/** The result returned by the {@link useLocale} hook. */\nexport type LocaleResult = Prettify<ResultOf<typeof getLocale>['localeGet']>\n\n/**\n * Fetches the current user's locale information including IP, country,\n * continent, EU status, and currency.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useLocale()\n *\n * // data.country, data.ip, data.currency, etc.\n * ```\n *\n * @returns A `UseQueryResult` with the user's locale details ({@link LocaleResult}).\n */\nexport function useLocale() {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<LocaleResult, AppwriteException[], LocaleResult>({\n queryKey: Keys.locale().key(),\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: getLocale,\n })\n\n if (errors) {\n throw errors\n }\n\n return data.localeGet\n },\n })\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst listLocaleCodes = gql(/* GraphQL */ `\n query ListLocaleCodes {\n localeListCodes {\n total\n localeCodes {\n code\n name\n }\n }\n }\n`)\n\n/** The result returned by the {@link useLocaleCodes} hook. */\nexport type LocaleCodesResult = Prettify<ResultOf<typeof listLocaleCodes>['localeListCodes']>\n\n/**\n * Fetches the list of available locale codes.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useLocaleCodes()\n *\n * // data.localeCodes — array of { code, name }\n * ```\n *\n * @returns A `UseQueryResult` with the available locale codes ({@link LocaleCodesResult}).\n */\nexport function useLocaleCodes() {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<LocaleCodesResult, AppwriteException[], LocaleCodesResult>({\n queryKey: Keys.locale().codes(),\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: listLocaleCodes,\n })\n\n if (errors) {\n throw errors\n }\n\n return data.localeListCodes\n },\n })\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst listContinents = gql(/* GraphQL */ `\n query ListContinents {\n localeListContinents {\n total\n continents {\n name\n code\n }\n }\n }\n`)\n\n/** The result returned by the {@link useLocaleContinents} hook. */\nexport type LocaleContinentsResult = Prettify<\n ResultOf<typeof listContinents>['localeListContinents']\n>\n\n/**\n * Fetches the list of continents with their names and codes.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useLocaleContinents()\n *\n * // data.continents — array of { name, code }\n * ```\n *\n * @returns A `UseQueryResult` with the list of continents ({@link LocaleContinentsResult}).\n */\nexport function useLocaleContinents() {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<LocaleContinentsResult, AppwriteException[], LocaleContinentsResult>(\n {\n queryKey: Keys.locale().continents(),\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: listContinents,\n })\n\n if (errors) {\n throw errors\n }\n\n return data.localeListContinents\n },\n },\n )\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst listCountries = gql(/* GraphQL */ `\n query ListCountries {\n localeListCountries {\n total\n countries {\n name\n code\n }\n }\n }\n`)\n\n/** The result returned by the {@link useLocaleCountries} hook. */\nexport type LocaleCountriesResult = Prettify<ResultOf<typeof listCountries>['localeListCountries']>\n\n/**\n * Fetches the list of countries with their names and codes.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useLocaleCountries()\n *\n * // data.countries — array of { name, code }\n * ```\n *\n * @returns A `UseQueryResult` with the list of countries ({@link LocaleCountriesResult}).\n */\nexport function useLocaleCountries() {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<LocaleCountriesResult, AppwriteException[], LocaleCountriesResult>({\n queryKey: Keys.locale().countries(),\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: listCountries,\n })\n\n if (errors) {\n throw errors\n }\n\n return data.localeListCountries\n },\n })\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst listCountriesEU = gql(/* GraphQL */ `\n query ListCountriesEU {\n localeListCountriesEU {\n total\n countries {\n name\n code\n }\n }\n }\n`)\n\n/** The result returned by the {@link useLocaleCountriesEU} hook. */\nexport type LocaleCountriesEUResult = Prettify<\n ResultOf<typeof listCountriesEU>['localeListCountriesEU']\n>\n\n/**\n * Fetches the list of EU member countries.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useLocaleCountriesEU()\n *\n * // data.countries — array of { name, code }\n * ```\n *\n * @returns A `UseQueryResult` with the list of EU countries ({@link LocaleCountriesEUResult}).\n */\nexport function useLocaleCountriesEU() {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<\n LocaleCountriesEUResult,\n AppwriteException[],\n LocaleCountriesEUResult\n >({\n queryKey: Keys.locale().countriesEU(),\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: listCountriesEU,\n })\n\n if (errors) {\n throw errors\n }\n\n return data.localeListCountriesEU\n },\n })\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst listCountriesPhones = gql(/* GraphQL */ `\n query ListCountriesPhones {\n localeListCountriesPhones {\n total\n phones {\n code\n countryCode\n countryName\n }\n }\n }\n`)\n\n/** The result returned by the {@link useLocaleCountriesPhones} hook. */\nexport type LocaleCountriesPhonesResult = Prettify<\n ResultOf<typeof listCountriesPhones>['localeListCountriesPhones']\n>\n\n/**\n * Fetches the list of countries with their international phone codes.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useLocaleCountriesPhones()\n *\n * // data.phones — array of { code, countryCode, countryName }\n * ```\n *\n * @returns A `UseQueryResult` with countries and phone codes ({@link LocaleCountriesPhonesResult}).\n */\nexport function useLocaleCountriesPhones() {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<\n LocaleCountriesPhonesResult,\n AppwriteException[],\n LocaleCountriesPhonesResult\n >({\n queryKey: Keys.locale().countriesPhones(),\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: listCountriesPhones,\n })\n\n if (errors) {\n throw errors\n }\n\n return data.localeListCountriesPhones\n },\n })\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst listCurrencies = gql(/* GraphQL */ `\n query ListCurrencies {\n localeListCurrencies {\n total\n currencies {\n symbol\n name\n symbolNative\n decimalDigits\n rounding\n code\n namePlural\n }\n }\n }\n`)\n\n/** The result returned by the {@link useLocaleCurrencies} hook. */\nexport type LocaleCurrenciesResult = Prettify<\n ResultOf<typeof listCurrencies>['localeListCurrencies']\n>\n\n/**\n * Fetches the list of currencies with their symbols, names, and decimal info.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useLocaleCurrencies()\n *\n * // data.currencies — array of { code, name, symbol, ... }\n * ```\n *\n * @returns A `UseQueryResult` with the list of currencies ({@link LocaleCurrenciesResult}).\n */\nexport function useLocaleCurrencies() {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<LocaleCurrenciesResult, AppwriteException[], LocaleCurrenciesResult>(\n {\n queryKey: Keys.locale().currencies(),\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: listCurrencies,\n })\n\n if (errors) {\n throw errors\n }\n\n return data.localeListCurrencies\n },\n },\n )\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst listLanguages = gql(/* GraphQL */ `\n query ListLanguages {\n localeListLanguages {\n total\n languages {\n name\n code\n nativeName\n }\n }\n }\n`)\n\n/** The result returned by the {@link useLocaleLanguages} hook. */\nexport type LocaleLanguagesResult = Prettify<ResultOf<typeof listLanguages>['localeListLanguages']>\n\n/**\n * Fetches the list of languages with their names, codes, and native names.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useLocaleLanguages()\n *\n * // data.languages — array of { name, code, nativeName }\n * ```\n *\n * @returns A `UseQueryResult` with the list of languages ({@link LocaleLanguagesResult}).\n */\nexport function useLocaleLanguages() {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<LocaleLanguagesResult, AppwriteException[], LocaleLanguagesResult>({\n queryKey: Keys.locale().languages(),\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: listLanguages,\n })\n\n if (errors) {\n throw errors\n }\n\n return data.localeListLanguages\n },\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\n\nexport const createSubscriber = gql(/* GraphQL */ `\n mutation CreateSubscriber($subscriberId: String!, $topicId: String!, $targetId: String!) {\n messagingCreateSubscriber(subscriberId: $subscriberId, topicId: $topicId, targetId: $targetId) {\n _id\n _createdAt\n _updatedAt\n targetId\n userId\n userName\n topicId\n providerType\n }\n }\n`)\n\n/** The variables accepted by the {@link useCreateSubscriber} hook. */\nexport type CreateSubscriberVariables = Prettify<VariablesOf<typeof createSubscriber>>\n\n/** The result returned by the {@link useCreateSubscriber} hook. */\nexport type CreateSubscriberResult = Prettify<\n ResultOf<typeof createSubscriber>['messagingCreateSubscriber']\n>\n\n/**\n * Mutation to subscribe a target to a messaging topic.\n *\n * Sends the `CreateSubscriber` GraphQL mutation. Does not perform any cache\n * invalidation — call `queryClient.invalidateQueries` manually if needed.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useCreateSubscriber()\n *\n * mutate({\n * subscriberId: ID.unique(),\n * topicId: 'announcements',\n * targetId: 'target_abc123',\n * })\n * ```\n *\n * **Variables** ({@link CreateSubscriberVariables}):\n * - `subscriberId` — A unique ID for the new subscriber (use `ID.unique()` to auto-generate)\n * - `topicId` — The ID of the messaging topic to subscribe to\n * - `targetId` — The ID of the target (e.g. device or user) to receive messages\n *\n * @returns A `UseMutationResult` whose `data` is the created {@link CreateSubscriberResult} with subscriber metadata including `_id`, `targetId`, `userId`, `userName`, `topicId`, and `providerType`.\n */\nexport function useCreateSubscriber() {\n const { graphql } = useAppwrite()\n\n const mutationResult = useMutation<\n CreateSubscriberResult,\n AppwriteException[],\n CreateSubscriberVariables\n >({\n mutationKey: Keys.messaging().subscriber().create(),\n mutationFn: async ({ subscriberId, topicId, targetId }) => {\n const { data: mutationData, errors } = await graphql.mutation({\n query: createSubscriber,\n variables: {\n subscriberId,\n topicId,\n targetId,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return mutationData?.messagingCreateSubscriber\n },\n })\n\n return mutationResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\n\nexport const deleteSubscriber = gql(/* GraphQL */ `\n mutation DeleteSubscriber($topicId: String!, $subscriberId: String!) {\n messagingDeleteSubscriber(topicId: $topicId, subscriberId: $subscriberId) {\n status\n }\n }\n`)\n\n/** The variables accepted by the {@link useDeleteSubscriber} hook. */\nexport type DeleteSubscriberVariables = Prettify<VariablesOf<typeof deleteSubscriber>>\n\n/** The result returned by the {@link useDeleteSubscriber} hook. */\nexport type DeleteSubscriberResult = Prettify<\n ResultOf<typeof deleteSubscriber>['messagingDeleteSubscriber']\n>\n\n/**\n * Mutation to unsubscribe a target from a messaging topic.\n *\n * Sends the `DeleteSubscriber` GraphQL mutation. Does not perform any cache\n * invalidation — call `queryClient.invalidateQueries` manually if needed.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useDeleteSubscriber()\n *\n * mutate({\n * topicId: 'announcements',\n * subscriberId: 'sub_abc123',\n * })\n * ```\n *\n * **Variables** ({@link DeleteSubscriberVariables}):\n * - `topicId` — The ID of the messaging topic to unsubscribe from\n * - `subscriberId` — The ID of the subscriber to remove\n *\n * @returns A `UseMutationResult` whose `data` is a {@link DeleteSubscriberResult} with a `status` field.\n */\nexport function useDeleteSubscriber() {\n const { graphql } = useAppwrite()\n\n const mutationResult = useMutation<\n DeleteSubscriberResult,\n AppwriteException[],\n DeleteSubscriberVariables\n >({\n mutationKey: Keys.messaging().subscriber().delete(),\n mutationFn: async ({ topicId, subscriberId }) => {\n const { data: mutationData, errors } = await graphql.mutation({\n query: deleteSubscriber,\n variables: {\n topicId,\n subscriberId,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return mutationData?.messagingDeleteSubscriber ?? { status: '' }\n },\n })\n\n return mutationResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst getFile = gql(/* GraphQL */ `\n query GetFile($bucketId: String!, $fileId: String!) {\n storageGetFile(bucketId: $bucketId, fileId: $fileId) {\n _id\n bucketId\n _createdAt\n _updatedAt\n _permissions\n name\n signature\n mimeType\n sizeOriginal\n chunksTotal\n chunksUploaded\n }\n }\n`)\n\n/** The variables accepted by the {@link useFile} hook. */\nexport type FileVariables = Prettify<VariablesOf<typeof getFile>>\n\n/** The result returned by the {@link useFile} hook. */\nexport type FileResult = Prettify<ResultOf<typeof getFile>['storageGetFile']>\n\n/**\n * Fetches a single file's metadata from a storage bucket.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useFile({\n * bucketId: 'images',\n * fileId: '6482…',\n * })\n *\n * // data.name, data.mimeType, data.sizeOriginal, etc.\n * ```\n *\n * **Parameters** ({@link FileVariables}):\n * - `bucketId` — The storage bucket identifier.\n * - `fileId` — The unique file identifier.\n *\n * @returns A `UseQueryResult` with the file's metadata ({@link FileResult}).\n */\nexport function useFile({ bucketId, fileId }: FileVariables) {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<FileResult, AppwriteException[], FileResult>({\n queryKey: Keys.bucket(bucketId).file(fileId).key(),\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: getFile,\n variables: { bucketId, fileId },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.storageGetFile\n },\n })\n\n return queryResult\n}\n","import { useMemo } from 'react'\n\nimport { useAppwrite } from '../useAppwrite'\n\n/**\n * Returns a URL for downloading a file from a storage bucket.\n * Memoized to avoid unnecessary recomputation.\n * @param params - The bucket ID, file ID, and optional access token.\n */\nexport function useFileDownload({\n bucketId,\n fileId,\n token,\n}: {\n bucketId: string\n fileId: string\n token?: string\n}) {\n const { storage } = useAppwrite()\n\n const url = useMemo(\n () => storage?.getFileDownload({ bucketId, fileId, token }),\n [storage, bucketId, fileId, token],\n )\n\n return url\n}\n","import { useMemo } from 'react'\nimport type { ImageFormat, ImageGravity } from 'appwrite'\n\nimport { useAppwrite } from '../useAppwrite'\n\n/**\n * Returns a URL for a file preview image with optional transformations\n * (resize, crop, border, opacity, rotation, format). Memoized to avoid unnecessary recomputation.\n * @param params - The bucket ID, file ID, and optional image transformation options.\n */\nexport function useFilePreview({\n bucketId,\n fileId,\n width,\n height,\n gravity,\n quality,\n borderWidth,\n borderColor,\n borderRadius,\n opacity,\n rotation,\n background,\n output,\n token,\n}: {\n bucketId: string\n fileId: string\n width?: number\n height?: number\n gravity?: ImageGravity\n quality?: number\n borderWidth?: number\n borderColor?: string\n borderRadius?: number\n opacity?: number\n rotation?: number\n background?: string\n output?: ImageFormat\n token?: string\n}) {\n const { storage } = useAppwrite()\n\n const url = useMemo(\n () =>\n storage?.getFilePreview({\n bucketId,\n fileId,\n width,\n height,\n gravity,\n quality,\n borderWidth,\n borderColor,\n borderRadius,\n opacity,\n rotation,\n background,\n output,\n token,\n }),\n [\n storage,\n bucketId,\n fileId,\n width,\n height,\n gravity,\n quality,\n borderWidth,\n borderColor,\n borderRadius,\n opacity,\n rotation,\n background,\n output,\n token,\n ],\n )\n\n return url\n}\n","import { useMemo } from 'react'\n\nimport { useAppwrite } from '../useAppwrite'\n\n/**\n * Returns a URL for viewing a file in the browser.\n * Memoized to avoid unnecessary recomputation.\n * @param params - The bucket ID, file ID, and optional access token.\n */\nexport function useFileView({\n bucketId,\n fileId,\n token,\n}: {\n bucketId: string\n fileId: string\n token?: string\n}) {\n const { storage } = useAppwrite()\n\n const url = useMemo(\n () => storage?.getFileView({ bucketId, fileId, token }),\n [storage, bucketId, fileId, token],\n )\n\n return url\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst listFiles = gql(/* GraphQL */ `\n query ListFiles($bucketId: String!, $queries: [String!], $search: String) {\n storageListFiles(bucketId: $bucketId, queries: $queries, search: $search) {\n total\n files {\n _id\n bucketId\n _createdAt\n _updatedAt\n _permissions\n name\n signature\n mimeType\n sizeOriginal\n chunksTotal\n chunksUploaded\n }\n }\n }\n`)\n\n/** The result returned by the {@link useFiles} hook. */\nexport type FilesResult = Prettify<ResultOf<typeof listFiles>['storageListFiles']>\n\n/**\n * Fetches a list of files from a storage bucket with optional query filters and search.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useFiles({\n * bucketId: 'images',\n * queries: ['limit(25)'],\n * })\n *\n * // data.total, data.files\n * ```\n *\n * **Parameters:**\n * - `bucketId` — The storage bucket identifier.\n * - `queries` *(optional)* — Appwrite query strings for filtering and pagination.\n * - `search` *(optional)* — A search term to filter files by name.\n *\n * @returns A `UseQueryResult` with the paginated file list ({@link FilesResult}).\n */\nexport function useFiles({\n bucketId,\n queries,\n search,\n}: {\n bucketId: string\n queries?: string[]\n search?: string\n}) {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<FilesResult, AppwriteException[], FilesResult>({\n queryKey: [\n ...Keys.bucket(bucketId).files().key(),\n ...(queries ?? []),\n ...(search ? [search] : []),\n ],\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: listFiles,\n variables: { bucketId, queries, search },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.storageListFiles\n },\n })\n\n return queryResult\n}\n","import { Keys } from '../query/Keys'\nimport type { AppwriteException, Models } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\n/** The variables accepted by the {@link useCreateFile} hook. */\nexport type CreateFileVariables = {\n bucketId: string\n fileId: string\n file: File\n permissions?: string[]\n onProgress?: (progress: {\n $id: string\n progress: number\n sizeUploaded: number\n chunksTotal: number\n chunksUploaded: number\n }) => void\n}\n\n/** The result returned by the {@link useCreateFile} hook's mutation. */\nexport type CreateFileResult = Models.File\n\n/**\n * Mutation to upload a file to a storage bucket.\n *\n * Uses the Appwrite Storage SDK directly (not GraphQL) to support chunked uploads\n * with progress tracking. Invalidates the file list cache for the target bucket on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useCreateFile()\n *\n * mutate({\n * bucketId: 'avatars',\n * fileId: ID.unique(),\n * file: selectedFile,\n * permissions: ['read(\"any\")'],\n * onProgress: ({ progress }) => console.log(`${progress}%`),\n * })\n * ```\n *\n * **Variables** ({@link CreateFileVariables}):\n * - `bucketId` — The ID of the storage bucket to upload into\n * - `fileId` — A unique ID for the new file (use `ID.unique()` to auto-generate)\n * - `file` — The `File` object to upload\n * - `permissions` — Optional. An array of permission strings for the file\n * - `onProgress` — Optional. Callback invoked with upload progress details\n *\n * @returns A `UseMutationResult` whose `data` is the created {@link CreateFileResult | File} metadata.\n */\nexport function useCreateFile() {\n const { storage } = useAppwrite()\n const queryClient = useQueryClient()\n\n const mutationResult = useMutation<CreateFileResult, AppwriteException[], CreateFileVariables>({\n mutationKey: Keys.buckets().files().create(),\n mutationFn: async ({ bucketId, fileId, file, permissions, onProgress }) => {\n return storage.createFile({\n bucketId,\n fileId,\n file,\n permissions,\n onProgress,\n })\n },\n onSuccess: (_, variables) => {\n void queryClient.invalidateQueries({\n queryKey: Keys.bucket(variables.bucketId).files().key(),\n })\n },\n })\n\n return mutationResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nexport const updateFile = gql(/* GraphQL */ `\n mutation UpdateFile(\n $bucketId: String!\n $fileId: String!\n $name: String\n $permissions: [String!]\n ) {\n storageUpdateFile(\n bucketId: $bucketId\n fileId: $fileId\n name: $name\n permissions: $permissions\n ) {\n _id\n bucketId\n name\n _permissions\n }\n }\n`)\n\n/** The variables accepted by the {@link useUpdateFile} hook. */\nexport type UpdateFileVariables = Prettify<VariablesOf<typeof updateFile>>\n\n/** The result returned by the {@link useUpdateFile} hook. */\nexport type UpdateFileResult = Prettify<ResultOf<typeof updateFile>['storageUpdateFile']>\n\n/**\n * Mutation to update a file's name or permissions in a storage bucket.\n *\n * Sends the `UpdateFile` GraphQL mutation and invalidates the file list cache\n * for the target bucket on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useUpdateFile()\n *\n * mutate({\n * bucketId: 'avatars',\n * fileId: '64a1b2c3d4e5f',\n * name: 'profile-photo.png',\n * permissions: ['read(\"any\")', 'write(\"user:123\")'],\n * })\n * ```\n *\n * **Variables** ({@link UpdateFileVariables}):\n * - `bucketId` — The ID of the storage bucket containing the file\n * - `fileId` — The ID of the file to update\n * - `name` — Optional. The new name for the file\n * - `permissions` — Optional. An updated array of permission strings\n *\n * @returns A `UseMutationResult` whose `data` is the updated {@link UpdateFileResult} with `_id`, `bucketId`, `name`, and `_permissions`.\n */\nexport function useUpdateFile() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const mutationResult = useMutation<UpdateFileResult, AppwriteException[], UpdateFileVariables>({\n mutationKey: Keys.buckets().files().update(),\n mutationFn: async ({ bucketId, fileId, name, permissions }) => {\n const { data, errors } = await graphql.mutation({\n query: updateFile,\n variables: { bucketId, fileId, name, permissions },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.storageUpdateFile\n },\n onSuccess: (_, variables) => {\n void queryClient.invalidateQueries({\n queryKey: Keys.bucket(variables.bucketId).files().key(),\n })\n },\n })\n\n return mutationResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nexport const deleteFile = gql(/* GraphQL */ `\n mutation DeleteFile($bucketId: String!, $fileId: String!) {\n storageDeleteFile(bucketId: $bucketId, fileId: $fileId) {\n status\n }\n }\n`)\n\n/** The variables accepted by the {@link useDeleteFile} hook. */\nexport type DeleteFileVariables = Prettify<VariablesOf<typeof deleteFile>>\n\n/** The result returned by the {@link useDeleteFile} hook. */\nexport type DeleteFileResult = Prettify<ResultOf<typeof deleteFile>['storageDeleteFile']>\n\n/**\n * Mutation to delete a file from a storage bucket.\n *\n * Sends the `DeleteFile` GraphQL mutation. On success, removes the individual file\n * query from the cache and invalidates the file list cache for the target bucket.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useDeleteFile()\n *\n * mutate({\n * bucketId: 'avatars',\n * fileId: '64a1b2c3d4e5f',\n * })\n * ```\n *\n * **Variables** ({@link DeleteFileVariables}):\n * - `bucketId` — The ID of the storage bucket containing the file\n * - `fileId` — The ID of the file to delete\n *\n * @returns A `UseMutationResult` whose `data` is a {@link DeleteFileResult} with a `status` field.\n */\nexport function useDeleteFile() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const mutationResult = useMutation<DeleteFileResult, AppwriteException[], DeleteFileVariables>({\n mutationKey: Keys.buckets().files().delete(),\n mutationFn: async ({ bucketId, fileId }) => {\n const { data, errors } = await graphql.mutation({\n query: deleteFile,\n variables: { bucketId, fileId },\n })\n\n if (errors) {\n throw errors\n }\n\n return data?.storageDeleteFile ?? { status: '' }\n },\n onSuccess: (_, variables) => {\n queryClient.removeQueries({\n queryKey: Keys.bucket(variables.bucketId).file(variables.fileId).key(),\n })\n void queryClient.invalidateQueries({\n queryKey: Keys.bucket(variables.bucketId).files().key(),\n })\n },\n })\n\n return mutationResult\n}\n","import { graphql as gql } from 'gql.tada'\n\nimport type { AppwriteClient } from '../client'\nimport { Keys } from '../query/Keys'\n\nexport const getTeam = gql(/* GraphQL */ `\n query GetTeam($teamId: String!) {\n teamsGet(teamId: $teamId) {\n _id\n _createdAt\n _updatedAt\n name\n total\n prefs {\n data\n }\n }\n }\n`)\n\nexport function teamQueryOptions(client: AppwriteClient, { teamId }: { teamId: string }) {\n return {\n queryKey: Keys.team(teamId).key(),\n queryFn: async () => {\n const { data, errors } = await client.graphql.query({\n query: getTeam,\n variables: { teamId },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.teamsGet\n },\n }\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\n\nimport type { getTeam } from './queryOptions'\nimport { teamQueryOptions } from './queryOptions'\nimport type { AppwriteException, Prettify, QueryOptions } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\n/** The variables accepted by the {@link useTeam} hook. */\nexport type TeamVariables = Prettify<VariablesOf<typeof getTeam>>\n\n/** The result returned by the {@link useTeam} hook. */\nexport type TeamResult = Prettify<ResultOf<typeof getTeam>['teamsGet']>\n\n/**\n * Fetches a team by its unique identifier.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useTeam({\n * teamId: 'engineering',\n * })\n *\n * // data.name, data.total, data._id\n * ```\n *\n * **Parameters** ({@link TeamVariables}):\n * - `teamId` — The unique team identifier.\n *\n * @returns A `UseQueryResult` with the team details ({@link TeamResult}).\n */\nexport function useTeam({ teamId }: TeamVariables, opts: QueryOptions = {}) {\n const client = useAppwrite()\n\n const queryResult = useQuery<TeamResult, AppwriteException[], TeamResult>({\n ...teamQueryOptions(client, { teamId }),\n ...opts,\n })\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify, QueryOptions } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst listTeams = gql(/* GraphQL */ `\n query ListTeams($queries: [String!], $search: String) {\n teamsList(queries: $queries, search: $search) {\n total\n teams {\n _id\n _createdAt\n _updatedAt\n name\n total\n prefs {\n data\n }\n }\n }\n }\n`)\n\n/** The result returned by the {@link useTeams} hook. */\nexport type TeamsResult = Prettify<ResultOf<typeof listTeams>['teamsList']>\n\n/**\n * Fetches a list of teams the current user belongs to.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useTeams()\n *\n * // data.total, data.teams\n * ```\n *\n * **Parameters** *(all optional)*:\n * - `queries` — Appwrite query strings for filtering and pagination.\n * - `search` — A search term to filter teams by name.\n *\n * @returns A `UseQueryResult` with the paginated team list ({@link TeamsResult}).\n */\nexport function useTeams(\n {\n queries,\n search,\n }: {\n queries?: string[]\n search?: string\n } = {},\n opts: QueryOptions = {},\n) {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<TeamsResult, AppwriteException[], TeamsResult>({\n queryKey: [...Keys.teams().key(), ...(queries ?? []), ...(search ? [search] : [])],\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: listTeams,\n variables: { queries, search },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.teamsList\n },\n ...opts,\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify, QueryOptions } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst getTeamPrefs = gql(/* GraphQL */ `\n query GetTeamPrefs($teamId: String!) {\n teamsGetPrefs(teamId: $teamId) {\n data\n }\n }\n`)\n\n/** The variables accepted by the {@link useTeamPrefs} hook. */\nexport type TeamPrefsVariables = Prettify<VariablesOf<typeof getTeamPrefs>>\n\n/** The result returned by the {@link useTeamPrefs} hook. */\nexport type TeamPrefsResult = Prettify<ResultOf<typeof getTeamPrefs>['teamsGetPrefs']>\n\n/**\n * Fetches the preferences for a specific team.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useTeamPrefs({\n * teamId: 'engineering',\n * })\n *\n * // data.data — the team's preference payload\n * ```\n *\n * **Parameters** ({@link TeamPrefsVariables}):\n * - `teamId` — The unique team identifier.\n *\n * @returns A `UseQueryResult` with the team preferences ({@link TeamPrefsResult}).\n */\nexport function useTeamPrefs({ teamId }: TeamPrefsVariables, opts: QueryOptions = {}) {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<TeamPrefsResult, AppwriteException[], TeamPrefsResult>({\n queryKey: Keys.team(teamId).teamPrefs().key(),\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: getTeamPrefs,\n variables: { teamId },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.teamsGetPrefs\n },\n ...opts,\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify, QueryOptions } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst getMembership = gql(/* GraphQL */ `\n query GetMembership($teamId: String!, $membershipId: String!) {\n teamsGetMembership(teamId: $teamId, membershipId: $membershipId) {\n _id\n _createdAt\n _updatedAt\n userId\n userName\n userEmail\n teamId\n teamName\n invited\n joined\n confirm\n mfa\n roles\n }\n }\n`)\n\n/** The variables accepted by the {@link useTeamMembership} hook. */\nexport type TeamMembershipVariables = Prettify<VariablesOf<typeof getMembership>>\n\n/** The result returned by the {@link useTeamMembership} hook. */\nexport type TeamMembershipResult = Prettify<ResultOf<typeof getMembership>['teamsGetMembership']>\n\n/**\n * Fetches a specific team membership by team and membership ID.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useTeamMembership({\n * teamId: 'engineering',\n * membershipId: '7a3f…',\n * })\n *\n * // data.userName, data.userEmail, data.roles\n * ```\n *\n * **Parameters** ({@link TeamMembershipVariables}):\n * - `teamId` — The unique team identifier.\n * - `membershipId` — The unique membership identifier.\n *\n * @returns A `UseQueryResult` with the membership details ({@link TeamMembershipResult}).\n */\nexport function useTeamMembership(\n { teamId, membershipId }: TeamMembershipVariables,\n opts: QueryOptions = {},\n) {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<TeamMembershipResult, AppwriteException[], TeamMembershipResult>({\n queryKey: Keys.team(teamId).membership(membershipId).key(),\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: getMembership,\n variables: { teamId, membershipId },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.teamsGetMembership\n },\n ...opts,\n })\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify, QueryOptions } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst listMemberships = gql(/* GraphQL */ `\n query ListMemberships($teamId: String!, $queries: [String!], $search: String) {\n teamsListMemberships(teamId: $teamId, queries: $queries, search: $search) {\n total\n memberships {\n _id\n _createdAt\n _updatedAt\n userId\n userName\n userEmail\n teamId\n teamName\n invited\n joined\n confirm\n mfa\n roles\n }\n }\n }\n`)\n\n/** The result returned by the {@link useTeamMemberships} hook. */\nexport type TeamMembershipsResult = Prettify<\n ResultOf<typeof listMemberships>['teamsListMemberships']\n>\n\n/**\n * Fetches the list of memberships for a team with optional query filters and search.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useTeamMemberships({\n * teamId: 'engineering',\n * queries: ['limit(25)'],\n * })\n *\n * // data.total, data.memberships\n * ```\n *\n * **Parameters:**\n * - `teamId` — The unique team identifier.\n * - `queries` *(optional)* — Appwrite query strings for filtering and pagination.\n * - `search` *(optional)* — A search term to filter memberships.\n *\n * @returns A `UseQueryResult` with the paginated membership list ({@link TeamMembershipsResult}).\n */\nexport function useTeamMemberships(\n {\n teamId,\n queries,\n search,\n }: {\n teamId: string\n queries?: string[]\n search?: string\n },\n opts: QueryOptions = {},\n) {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<TeamMembershipsResult, AppwriteException[], TeamMembershipsResult>({\n queryKey: [\n ...Keys.team(teamId).memberships().key(),\n ...(queries ?? []),\n ...(search ? [search] : []),\n ],\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: listMemberships,\n variables: { teamId, queries, search },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.teamsListMemberships\n },\n ...opts,\n })\n\n return queryResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nexport const createTeam = gql(/* GraphQL */ `\n mutation CreateTeam($teamId: String!, $name: String!, $roles: [String!]) {\n teamsCreate(teamId: $teamId, name: $name, roles: $roles) {\n _id\n name\n total\n }\n }\n`)\n\n/** The variables accepted by the {@link useCreateTeam} hook. */\nexport type CreateTeamVariables = Prettify<VariablesOf<typeof createTeam>>\n\n/** The result returned by the {@link useCreateTeam} hook. */\nexport type CreateTeamResult = Prettify<ResultOf<typeof createTeam>['teamsCreate']>\n\n/**\n * Mutation to create a new team.\n *\n * Sends the `CreateTeam` GraphQL mutation and invalidates the team list cache on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useCreateTeam()\n *\n * mutate({\n * teamId: ID.unique(),\n * name: 'Engineering',\n * roles: ['owner', 'developer'],\n * })\n * ```\n *\n * **Variables** ({@link CreateTeamVariables}):\n * - `teamId` — A unique ID for the new team (use `ID.unique()` to auto-generate)\n * - `name` — The display name of the team\n * - `roles` — Optional. An array of roles assigned to the team creator\n *\n * @returns A `UseMutationResult` whose `data` is the created {@link CreateTeamResult} with `_id`, `name`, and `total`.\n */\nexport function useCreateTeam() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const mutationResult = useMutation<CreateTeamResult, AppwriteException[], CreateTeamVariables>({\n mutationKey: Keys.teams().create(),\n mutationFn: async ({ teamId, name, roles }) => {\n const { data, errors } = await graphql.mutation({\n query: createTeam,\n variables: { teamId, name, roles },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.teamsCreate\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: Keys.teams().key() })\n },\n })\n\n return mutationResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nexport const updateTeamName = gql(/* GraphQL */ `\n mutation UpdateTeamName($teamId: String!, $name: String!) {\n teamsUpdateName(teamId: $teamId, name: $name) {\n _id\n name\n }\n }\n`)\n\n/** The variables accepted by the {@link useUpdateTeamName} hook. */\nexport type UpdateTeamNameVariables = Prettify<VariablesOf<typeof updateTeamName>>\n\n/** The result returned by the {@link useUpdateTeamName} hook. */\nexport type UpdateTeamNameResult = Prettify<ResultOf<typeof updateTeamName>['teamsUpdateName']>\n\n/**\n * Mutation to update a team's name.\n *\n * Sends the `UpdateTeamName` GraphQL mutation. On success, invalidates both the\n * individual team cache and the team list cache.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useUpdateTeamName()\n *\n * mutate({\n * teamId: '64a1b2c3d4e5f',\n * name: 'Platform Engineering',\n * })\n * ```\n *\n * **Variables** ({@link UpdateTeamNameVariables}):\n * - `teamId` — The ID of the team to rename\n * - `name` — The new display name for the team\n *\n * @returns A `UseMutationResult` whose `data` is the updated {@link UpdateTeamNameResult} with `_id` and `name`.\n */\nexport function useUpdateTeamName() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const mutationResult = useMutation<\n UpdateTeamNameResult,\n AppwriteException[],\n UpdateTeamNameVariables\n >({\n mutationKey: Keys.teams().teamName().update(),\n mutationFn: async ({ teamId, name }) => {\n const { data, errors } = await graphql.mutation({\n query: updateTeamName,\n variables: { teamId, name },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.teamsUpdateName\n },\n onSuccess: (_, variables) => {\n void queryClient.invalidateQueries({\n queryKey: Keys.team(variables.teamId).key(),\n })\n void queryClient.invalidateQueries({ queryKey: Keys.teams().key() })\n },\n })\n\n return mutationResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nexport const updateTeamPrefs = gql(/* GraphQL */ `\n mutation UpdateTeamPrefs($teamId: String!, $prefs: Assoc!) {\n teamsUpdatePrefs(teamId: $teamId, prefs: $prefs) {\n data\n }\n }\n`)\n\n/** The variables accepted by the {@link useUpdateTeamPrefs} hook. */\nexport type UpdateTeamPrefsVariables = Prettify<VariablesOf<typeof updateTeamPrefs>>\n\n/** The result returned by the {@link useUpdateTeamPrefs} hook. */\nexport type UpdateTeamPrefsResult = Prettify<ResultOf<typeof updateTeamPrefs>['teamsUpdatePrefs']>\n\n/**\n * Mutation to update a team's preferences.\n *\n * Sends the `UpdateTeamPrefs` GraphQL mutation with an arbitrary key-value object.\n * Invalidates the individual team cache on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useUpdateTeamPrefs()\n *\n * mutate({\n * teamId: '64a1b2c3d4e5f',\n * prefs: { theme: 'dark', notificationsEnabled: true },\n * })\n * ```\n *\n * **Variables** ({@link UpdateTeamPrefsVariables}):\n * - `teamId` — The ID of the team whose preferences to update\n * - `prefs` — An associative object of key-value preferences to set\n *\n * @returns A `UseMutationResult` whose `data` is the updated {@link UpdateTeamPrefsResult} containing a `data` field with the new preferences.\n */\nexport function useUpdateTeamPrefs() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const mutationResult = useMutation<\n UpdateTeamPrefsResult,\n AppwriteException[],\n UpdateTeamPrefsVariables\n >({\n mutationKey: Keys.teams().teamPrefs().update(),\n mutationFn: async ({ teamId, prefs }) => {\n const { data, errors } = await graphql.mutation({\n query: updateTeamPrefs,\n variables: { teamId, prefs },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.teamsUpdatePrefs\n },\n onSuccess: (_, variables) => {\n void queryClient.invalidateQueries({\n queryKey: Keys.team(variables.teamId).key(),\n })\n },\n })\n\n return mutationResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nexport const deleteTeam = gql(/* GraphQL */ `\n mutation DeleteTeam($teamId: String!) {\n teamsDelete(teamId: $teamId) {\n status\n }\n }\n`)\n\n/** The variables accepted by the {@link useDeleteTeam} hook. */\nexport type DeleteTeamVariables = Prettify<VariablesOf<typeof deleteTeam>>\n\n/** The result returned by the {@link useDeleteTeam} hook. */\nexport type DeleteTeamResult = Prettify<ResultOf<typeof deleteTeam>['teamsDelete']>\n\n/**\n * Mutation to delete a team by its ID.\n *\n * Sends the `DeleteTeam` GraphQL mutation. On success, removes the individual team\n * query from the cache and invalidates the team list cache.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useDeleteTeam()\n *\n * mutate({ teamId: '64a1b2c3d4e5f' })\n * ```\n *\n * **Variables** ({@link DeleteTeamVariables}):\n * - `teamId` — The ID of the team to delete\n *\n * @returns A `UseMutationResult` whose `data` is a {@link DeleteTeamResult} with a `status` field.\n */\nexport function useDeleteTeam() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const mutationResult = useMutation<DeleteTeamResult, AppwriteException[], DeleteTeamVariables>({\n mutationKey: Keys.teams().delete(),\n mutationFn: async ({ teamId }) => {\n const { data, errors } = await graphql.mutation({\n query: deleteTeam,\n variables: { teamId },\n })\n\n if (errors) {\n throw errors\n }\n\n return data?.teamsDelete ?? { status: '' }\n },\n onSuccess: (_, variables) => {\n queryClient.removeQueries({\n queryKey: Keys.team(variables.teamId).key(),\n })\n void queryClient.invalidateQueries({ queryKey: Keys.teams().key() })\n },\n })\n\n return mutationResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nexport const createMembership = gql(/* GraphQL */ `\n mutation CreateMembership(\n $teamId: String!\n $roles: [String!]!\n $email: String\n $userId: String\n $phone: String\n $url: String\n $name: String\n ) {\n teamsCreateMembership(\n teamId: $teamId\n roles: $roles\n email: $email\n userId: $userId\n phone: $phone\n url: $url\n name: $name\n ) {\n _id\n userId\n teamId\n roles\n confirm\n }\n }\n`)\n\n/** The variables accepted by the {@link useCreateMembership} hook. */\nexport type CreateMembershipVariables = Prettify<VariablesOf<typeof createMembership>>\n\n/** The result returned by the {@link useCreateMembership} hook. */\nexport type CreateMembershipResult = Prettify<\n ResultOf<typeof createMembership>['teamsCreateMembership']\n>\n\n/**\n * Mutation to invite a user to a team.\n *\n * Sends the `CreateMembership` GraphQL mutation. At least one of `email`, `userId`,\n * or `phone` must be provided to identify the invitee. On success, invalidates both\n * the membership list and the individual team cache.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useCreateMembership()\n *\n * mutate({\n * teamId: '64a1b2c3d4e5f',\n * roles: ['developer'],\n * email: 'alice@example.com',\n * url: 'https://myapp.com/accept-invite',\n * name: 'Alice',\n * })\n * ```\n *\n * **Variables** ({@link CreateMembershipVariables}):\n * - `teamId` — The ID of the team to invite the user to\n * - `roles` — An array of roles to assign to the new member\n * - `email` — Optional. The invitee's email address\n * - `userId` — Optional. The invitee's user ID\n * - `phone` — Optional. The invitee's phone number\n * - `url` — Optional. A URL the invitee is redirected to for accepting the invitation\n * - `name` — Optional. The invitee's display name\n *\n * @returns A `UseMutationResult` whose `data` is the created {@link CreateMembershipResult} with `_id`, `userId`, `teamId`, `roles`, and `confirm`.\n */\nexport function useCreateMembership() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const mutationResult = useMutation<\n CreateMembershipResult,\n AppwriteException[],\n CreateMembershipVariables\n >({\n mutationKey: Keys.teams().memberships().create(),\n mutationFn: async ({ teamId, roles, email, userId, phone, url, name }) => {\n const { data, errors } = await graphql.mutation({\n query: createMembership,\n variables: { teamId, roles, email, userId, phone, url, name },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.teamsCreateMembership\n },\n onSuccess: (_, variables) => {\n void queryClient.invalidateQueries({\n queryKey: Keys.team(variables.teamId).memberships().key(),\n })\n void queryClient.invalidateQueries({\n queryKey: Keys.team(variables.teamId).key(),\n })\n },\n })\n\n return mutationResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nexport const updateMembership = gql(/* GraphQL */ `\n mutation UpdateMembership($teamId: String!, $membershipId: String!, $roles: [String!]!) {\n teamsUpdateMembership(teamId: $teamId, membershipId: $membershipId, roles: $roles) {\n _id\n roles\n }\n }\n`)\n\n/** The variables accepted by the {@link useUpdateMembership} hook. */\nexport type UpdateMembershipVariables = Prettify<VariablesOf<typeof updateMembership>>\n\n/** The result returned by the {@link useUpdateMembership} hook. */\nexport type UpdateMembershipResult = Prettify<\n ResultOf<typeof updateMembership>['teamsUpdateMembership']\n>\n\n/**\n * Mutation to update a team membership's roles.\n *\n * Sends the `UpdateMembership` GraphQL mutation and invalidates the membership list\n * cache for the team on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useUpdateMembership()\n *\n * mutate({\n * teamId: '64a1b2c3d4e5f',\n * membershipId: '71b2c3d4e5f6a',\n * roles: ['admin', 'developer'],\n * })\n * ```\n *\n * **Variables** ({@link UpdateMembershipVariables}):\n * - `teamId` — The ID of the team containing the membership\n * - `membershipId` — The ID of the membership to update\n * - `roles` — The new array of roles to assign to the member\n *\n * @returns A `UseMutationResult` whose `data` is the updated {@link UpdateMembershipResult} with `_id` and `roles`.\n */\nexport function useUpdateMembership() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const mutationResult = useMutation<\n UpdateMembershipResult,\n AppwriteException[],\n UpdateMembershipVariables\n >({\n mutationKey: Keys.teams().memberships().update(),\n mutationFn: async ({ teamId, membershipId, roles }) => {\n const { data, errors } = await graphql.mutation({\n query: updateMembership,\n variables: { teamId, membershipId, roles },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.teamsUpdateMembership\n },\n onSuccess: (_, variables) => {\n void queryClient.invalidateQueries({\n queryKey: Keys.team(variables.teamId).memberships().key(),\n })\n },\n })\n\n return mutationResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nconst updateMembershipStatus = gql(/* GraphQL */ `\n mutation UpdateMembershipStatus(\n $teamId: String!\n $membershipId: String!\n $userId: String!\n $secret: String!\n ) {\n teamsUpdateMembershipStatus(\n teamId: $teamId\n membershipId: $membershipId\n userId: $userId\n secret: $secret\n ) {\n _id\n confirm\n }\n }\n`)\n\n/** The variables accepted by the {@link useUpdateMembershipStatus} hook. */\nexport type UpdateMembershipStatusVariables = Prettify<VariablesOf<typeof updateMembershipStatus>>\n\n/** The result returned by the {@link useUpdateMembershipStatus} hook. */\nexport type UpdateMembershipStatusResult = Prettify<\n ResultOf<typeof updateMembershipStatus>['teamsUpdateMembershipStatus']\n>\n\n/**\n * Mutation to accept a team invitation.\n *\n * Sends the `UpdateMembershipStatus` GraphQL mutation using the invitation secret.\n * Typically called after a user clicks an invitation link. Invalidates the membership\n * list cache for the team on success.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useUpdateMembershipStatus()\n *\n * // Values are typically extracted from the invitation URL\n * mutate({\n * teamId: '64a1b2c3d4e5f',\n * membershipId: '71b2c3d4e5f6a',\n * userId: 'user_123',\n * secret: 'invite-secret-token',\n * })\n * ```\n *\n * **Variables** ({@link UpdateMembershipStatusVariables}):\n * - `teamId` — The ID of the team the user is joining\n * - `membershipId` — The ID of the membership invitation\n * - `userId` — The ID of the user accepting the invitation\n * - `secret` — The invitation secret from the invite URL\n *\n * @returns A `UseMutationResult` whose `data` is the updated {@link UpdateMembershipStatusResult} with `_id` and `confirm`.\n */\nexport function useUpdateMembershipStatus() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const mutationResult = useMutation<\n UpdateMembershipStatusResult,\n AppwriteException[],\n UpdateMembershipStatusVariables\n >({\n mutationKey: Keys.teams().membershipStatus().update(),\n mutationFn: async ({ teamId, membershipId, userId, secret }) => {\n const { data, errors } = await graphql.mutation({\n query: updateMembershipStatus,\n variables: { teamId, membershipId, userId, secret },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.teamsUpdateMembershipStatus\n },\n onSuccess: (_, variables) => {\n void queryClient.invalidateQueries({\n queryKey: Keys.team(variables.teamId).memberships().key(),\n })\n },\n })\n\n return mutationResult\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQueryClient } from '../useQueryClient'\n\nexport const deleteMembership = gql(/* GraphQL */ `\n mutation DeleteMembership($teamId: String!, $membershipId: String!) {\n teamsDeleteMembership(teamId: $teamId, membershipId: $membershipId) {\n status\n }\n }\n`)\n\n/** The variables accepted by the {@link useDeleteMembership} hook. */\nexport type DeleteMembershipVariables = Prettify<VariablesOf<typeof deleteMembership>>\n\n/** The result returned by the {@link useDeleteMembership} hook. */\nexport type DeleteMembershipResult = Prettify<\n ResultOf<typeof deleteMembership>['teamsDeleteMembership']\n>\n\n/**\n * Mutation to remove a member from a team.\n *\n * Sends the `DeleteMembership` GraphQL mutation. On success, removes the individual\n * membership query from the cache and invalidates both the membership list and the\n * individual team cache.\n *\n * @example\n * ```tsx\n * const { mutate, isPending } = useDeleteMembership()\n *\n * mutate({\n * teamId: '64a1b2c3d4e5f',\n * membershipId: '71b2c3d4e5f6a',\n * })\n * ```\n *\n * **Variables** ({@link DeleteMembershipVariables}):\n * - `teamId` — The ID of the team containing the membership\n * - `membershipId` — The ID of the membership to remove\n *\n * @returns A `UseMutationResult` whose `data` is a {@link DeleteMembershipResult} with a `status` field.\n */\nexport function useDeleteMembership() {\n const { graphql } = useAppwrite()\n const queryClient = useQueryClient()\n\n const mutationResult = useMutation<\n DeleteMembershipResult,\n AppwriteException[],\n DeleteMembershipVariables\n >({\n mutationKey: Keys.teams().memberships().delete(),\n mutationFn: async ({ teamId, membershipId }) => {\n const { data, errors } = await graphql.mutation({\n query: deleteMembership,\n variables: { teamId, membershipId },\n })\n\n if (errors) {\n throw errors\n }\n\n return data?.teamsDeleteMembership ?? { status: '' }\n },\n onSuccess: (_, variables) => {\n queryClient.removeQueries({\n queryKey: Keys.team(variables.teamId).membership(variables.membershipId).key(),\n })\n void queryClient.invalidateQueries({\n queryKey: Keys.team(variables.teamId).memberships().key(),\n })\n void queryClient.invalidateQueries({\n queryKey: Keys.team(variables.teamId).key(),\n })\n },\n })\n\n return mutationResult\n}\n","import type { QueryTypes } from 'appwrite'\nimport { Query } from 'appwrite'\n\ntype FieldValue<T, K extends keyof T> = T[K]\n\ntype ArrayElement<T> = T extends (infer E)[] ? E : never\n\ntype ContainsValue<T, K extends keyof T> = T[K] extends unknown[]\n ? ArrayElement<T[K]> | ArrayElement<T[K]>[]\n : T[K] extends string\n ? string\n : T[K] | T[K][]\n\n/**\n * Type-safe query builder for constructing Appwrite queries.\n * Provides a fluent API with autocompletion for your document fields.\n */\nexport class QueryBuilder<T extends Record<string, unknown>> {\n private queries: string[] = []\n\n equal<K extends keyof T & string>(field: K, value: FieldValue<T, K> | FieldValue<T, K>[]): this {\n this.queries.push(Query.equal(field, value as QueryTypes))\n return this\n }\n\n notEqual<K extends keyof T & string>(\n field: K,\n value: FieldValue<T, K> | FieldValue<T, K>[],\n ): this {\n this.queries.push(Query.notEqual(field, value as QueryTypes))\n return this\n }\n\n regex<K extends keyof T & string>(field: K, pattern: string): this {\n this.queries.push(Query.regex(field, pattern))\n return this\n }\n\n lessThan<K extends keyof T & string>(field: K, value: FieldValue<T, K>): this {\n this.queries.push(Query.lessThan(field, value as QueryTypes))\n return this\n }\n\n lessThanEqual<K extends keyof T & string>(field: K, value: FieldValue<T, K>): this {\n this.queries.push(Query.lessThanEqual(field, value as QueryTypes))\n return this\n }\n\n greaterThan<K extends keyof T & string>(field: K, value: FieldValue<T, K>): this {\n this.queries.push(Query.greaterThan(field, value as QueryTypes))\n return this\n }\n\n greaterThanEqual<K extends keyof T & string>(field: K, value: FieldValue<T, K>): this {\n this.queries.push(Query.greaterThanEqual(field, value as QueryTypes))\n return this\n }\n\n isNull<K extends keyof T & string>(field: K): this {\n this.queries.push(Query.isNull(field))\n return this\n }\n\n isNotNull<K extends keyof T & string>(field: K): this {\n this.queries.push(Query.isNotNull(field))\n return this\n }\n\n exists<K extends keyof T & string>(fields: K[]): this {\n this.queries.push(Query.exists(fields))\n return this\n }\n\n notExists<K extends keyof T & string>(fields: K[]): this {\n this.queries.push(Query.notExists(fields))\n return this\n }\n\n between<K extends keyof T & string>(\n field: K,\n start: string | number | bigint,\n end: string | number | bigint,\n ): this {\n this.queries.push(Query.between(field, start, end))\n return this\n }\n\n startsWith<K extends keyof T & string>(field: K, prefix: string): this {\n this.queries.push(Query.startsWith(field, prefix))\n return this\n }\n\n endsWith<K extends keyof T & string>(field: K, suffix: string): this {\n this.queries.push(Query.endsWith(field, suffix))\n return this\n }\n\n select<K extends keyof T & string>(fields: K[]): this {\n this.queries.push(Query.select(fields))\n return this\n }\n\n search<K extends keyof T & string>(field: K, term: string): this {\n this.queries.push(Query.search(field, term))\n return this\n }\n\n orderAsc<K extends keyof T & string>(field: K): this {\n this.queries.push(Query.orderAsc(field))\n return this\n }\n\n orderDesc<K extends keyof T & string>(field: K): this {\n this.queries.push(Query.orderDesc(field))\n return this\n }\n\n orderRandom(): this {\n this.queries.push(Query.orderRandom())\n return this\n }\n\n cursorAfter(id: string): this {\n this.queries.push(Query.cursorAfter(id))\n return this\n }\n\n cursorBefore(id: string): this {\n this.queries.push(Query.cursorBefore(id))\n return this\n }\n\n limit(count: number): this {\n this.queries.push(Query.limit(count))\n return this\n }\n\n offset(count: number): this {\n this.queries.push(Query.offset(count))\n return this\n }\n\n contains<K extends keyof T & string>(field: K, value: ContainsValue<T, K>): this {\n this.queries.push(Query.contains(field, value as string | any[]))\n return this\n }\n\n containsAny<K extends keyof T & string>(field: K, values: ContainsValue<T, K>[]): this {\n this.queries.push(Query.containsAny(field, values as any[]))\n return this\n }\n\n containsAll<K extends keyof T & string>(field: K, values: ContainsValue<T, K>[]): this {\n this.queries.push(Query.containsAll(field, values as any[]))\n return this\n }\n\n notContains<K extends keyof T & string>(field: K, value: ContainsValue<T, K>): this {\n this.queries.push(Query.notContains(field, value as string | any[]))\n return this\n }\n\n notSearch<K extends keyof T & string>(field: K, term: string): this {\n this.queries.push(Query.notSearch(field, term))\n return this\n }\n\n notBetween<K extends keyof T & string>(\n field: K,\n start: string | number | bigint,\n end: string | number | bigint,\n ): this {\n this.queries.push(Query.notBetween(field, start, end))\n return this\n }\n\n notStartsWith<K extends keyof T & string>(field: K, prefix: string): this {\n this.queries.push(Query.notStartsWith(field, prefix))\n return this\n }\n\n notEndsWith<K extends keyof T & string>(field: K, suffix: string): this {\n this.queries.push(Query.notEndsWith(field, suffix))\n return this\n }\n\n createdBefore(date: string): this {\n this.queries.push(Query.createdBefore(date))\n return this\n }\n\n createdAfter(date: string): this {\n this.queries.push(Query.createdAfter(date))\n return this\n }\n\n createdBetween(start: string, end: string): this {\n this.queries.push(Query.createdBetween(start, end))\n return this\n }\n\n updatedBefore(date: string): this {\n this.queries.push(Query.updatedBefore(date))\n return this\n }\n\n updatedAfter(date: string): this {\n this.queries.push(Query.updatedAfter(date))\n return this\n }\n\n updatedBetween(start: string, end: string): this {\n this.queries.push(Query.updatedBetween(start, end))\n return this\n }\n\n or(...queries: ((q: QueryBuilder<T>) => QueryBuilder<T>)[]): this {\n const orQueries = queries.map((fn) => fn(new QueryBuilder<T>()).queries).flat()\n this.queries.push(Query.or(orQueries))\n return this\n }\n\n and(...queries: ((q: QueryBuilder<T>) => QueryBuilder<T>)[]): this {\n const andQueries = queries.map((fn) => fn(new QueryBuilder<T>()).queries).flat()\n this.queries.push(Query.and(andQueries))\n return this\n }\n\n elemMatch<K extends keyof T & string>(field: K, query: QueryBuilder<T>): this {\n this.queries.push(Query.elemMatch(field, query.queries))\n return this\n }\n\n distanceEqual<K extends keyof T & string>(\n field: K,\n latitude: number,\n longitude: number,\n distance: number,\n meters: boolean = true,\n ): this {\n this.queries.push(Query.distanceEqual(field, [latitude, longitude], distance, meters))\n return this\n }\n\n distanceNotEqual<K extends keyof T & string>(\n field: K,\n latitude: number,\n longitude: number,\n distance: number,\n meters: boolean = true,\n ): this {\n this.queries.push(Query.distanceNotEqual(field, [latitude, longitude], distance, meters))\n return this\n }\n\n distanceGreaterThan<K extends keyof T & string>(\n field: K,\n latitude: number,\n longitude: number,\n distance: number,\n meters: boolean = true,\n ): this {\n this.queries.push(Query.distanceGreaterThan(field, [latitude, longitude], distance, meters))\n return this\n }\n\n distanceLessThan<K extends keyof T & string>(\n field: K,\n latitude: number,\n longitude: number,\n distance: number,\n meters: boolean = true,\n ): this {\n this.queries.push(Query.distanceLessThan(field, [latitude, longitude], distance, meters))\n return this\n }\n\n intersects<K extends keyof T & string>(field: K, points: [number, number][]): this {\n this.queries.push(Query.intersects(field, points))\n return this\n }\n\n notIntersects<K extends keyof T & string>(field: K, points: [number, number][]): this {\n this.queries.push(Query.notIntersects(field, points))\n return this\n }\n\n crosses<K extends keyof T & string>(field: K, points: [number, number][]): this {\n this.queries.push(Query.crosses(field, points))\n return this\n }\n\n notCrosses<K extends keyof T & string>(field: K, points: [number, number][]): this {\n this.queries.push(Query.notCrosses(field, points))\n return this\n }\n\n overlaps<K extends keyof T & string>(field: K, points: [number, number][]): this {\n this.queries.push(Query.overlaps(field, points))\n return this\n }\n\n notOverlaps<K extends keyof T & string>(field: K, points: [number, number][]): this {\n this.queries.push(Query.notOverlaps(field, points))\n return this\n }\n\n touches<K extends keyof T & string>(field: K, points: [number, number][]): this {\n this.queries.push(Query.touches(field, points))\n return this\n }\n\n notTouches<K extends keyof T & string>(field: K, points: [number, number][]): this {\n this.queries.push(Query.notTouches(field, points))\n return this\n }\n\n build() {\n return [...this.queries]\n }\n}\n\n/**\n * Creates a new type-safe {@link QueryBuilder} instance.\n *\n * @example\n * ```ts\n * const queries = q<MyDocument>()\n * .equal('status', 'active')\n * .greaterThan('age', 18)\n * .build()\n * ```\n */\nexport function q<T extends Record<string, unknown>>(): QueryBuilder<T> {\n return new QueryBuilder<T>()\n}\n","import { timeoutManager } from './timeoutManager'\nimport type {\n DefaultError,\n Enabled,\n FetchStatus,\n MutationKey,\n MutationStatus,\n QueryFunction,\n QueryKey,\n QueryOptions,\n StaleTime,\n StaleTimeFunction,\n} from './types'\nimport type { Mutation } from './mutation'\nimport type { FetchOptions, Query } from './query'\n\n// TYPES\n\ntype DropLast<T extends ReadonlyArray<unknown>> = T extends readonly [\n ...infer R,\n unknown,\n]\n ? readonly [...R]\n : never\n\ntype TuplePrefixes<T extends ReadonlyArray<unknown>> = T extends readonly []\n ? readonly []\n : TuplePrefixes<DropLast<T>> | T\n\nexport interface QueryFilters<TQueryKey extends QueryKey = QueryKey> {\n /**\n * Filter to active queries, inactive queries or all queries\n */\n type?: QueryTypeFilter\n /**\n * Match query key exactly\n */\n exact?: boolean\n /**\n * Include queries matching this predicate function\n */\n predicate?: (query: Query) => boolean\n /**\n * Include queries matching this query key\n */\n queryKey?: TQueryKey | TuplePrefixes<TQueryKey>\n /**\n * Include or exclude stale queries\n */\n stale?: boolean\n /**\n * Include queries matching their fetchStatus\n */\n fetchStatus?: FetchStatus\n}\n\nexport interface MutationFilters<\n TData = unknown,\n TError = DefaultError,\n TVariables = unknown,\n TOnMutateResult = unknown,\n> {\n /**\n * Match mutation key exactly\n */\n exact?: boolean\n /**\n * Include mutations matching this predicate function\n */\n predicate?: (\n mutation: Mutation<TData, TError, TVariables, TOnMutateResult>,\n ) => boolean\n /**\n * Include mutations matching this mutation key\n */\n mutationKey?: TuplePrefixes<MutationKey>\n /**\n * Filter by mutation status\n */\n status?: MutationStatus\n}\n\nexport type Updater<TInput, TOutput> = TOutput | ((input: TInput) => TOutput)\n\nexport type QueryTypeFilter = 'all' | 'active' | 'inactive'\n\n// UTILS\n\n/** @deprecated\n * use `environmentManager.isServer()` instead.\n */\nexport const isServer = typeof window === 'undefined' || 'Deno' in globalThis\n\nexport function noop(): void\nexport function noop(): undefined\nexport function noop() {}\n\nexport function functionalUpdate<TInput, TOutput>(\n updater: Updater<TInput, TOutput>,\n input: TInput,\n): TOutput {\n return typeof updater === 'function'\n ? (updater as (_: TInput) => TOutput)(input)\n : updater\n}\n\nexport function isValidTimeout(value: unknown): value is number {\n return typeof value === 'number' && value >= 0 && value !== Infinity\n}\n\nexport function timeUntilStale(updatedAt: number, staleTime?: number): number {\n return Math.max(updatedAt + (staleTime || 0) - Date.now(), 0)\n}\n\nexport function resolveStaleTime<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n staleTime:\n | undefined\n | StaleTimeFunction<TQueryFnData, TError, TData, TQueryKey>,\n query: Query<TQueryFnData, TError, TData, TQueryKey>,\n): StaleTime | undefined {\n return typeof staleTime === 'function' ? staleTime(query) : staleTime\n}\n\nexport function resolveEnabled<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n enabled: undefined | Enabled<TQueryFnData, TError, TData, TQueryKey>,\n query: Query<TQueryFnData, TError, TData, TQueryKey>,\n): boolean | undefined {\n return typeof enabled === 'function' ? enabled(query) : enabled\n}\n\nexport function matchQuery(\n filters: QueryFilters,\n query: Query<any, any, any, any>,\n): boolean {\n const {\n type = 'all',\n exact,\n fetchStatus,\n predicate,\n queryKey,\n stale,\n } = filters\n\n if (queryKey) {\n if (exact) {\n if (query.queryHash !== hashQueryKeyByOptions(queryKey, query.options)) {\n return false\n }\n } else if (!partialMatchKey(query.queryKey, queryKey)) {\n return false\n }\n }\n\n if (type !== 'all') {\n const isActive = query.isActive()\n if (type === 'active' && !isActive) {\n return false\n }\n if (type === 'inactive' && isActive) {\n return false\n }\n }\n\n if (typeof stale === 'boolean' && query.isStale() !== stale) {\n return false\n }\n\n if (fetchStatus && fetchStatus !== query.state.fetchStatus) {\n return false\n }\n\n if (predicate && !predicate(query)) {\n return false\n }\n\n return true\n}\n\nexport function matchMutation(\n filters: MutationFilters,\n mutation: Mutation<any, any>,\n): boolean {\n const { exact, status, predicate, mutationKey } = filters\n if (mutationKey) {\n if (!mutation.options.mutationKey) {\n return false\n }\n if (exact) {\n if (hashKey(mutation.options.mutationKey) !== hashKey(mutationKey)) {\n return false\n }\n } else if (!partialMatchKey(mutation.options.mutationKey, mutationKey)) {\n return false\n }\n }\n\n if (status && mutation.state.status !== status) {\n return false\n }\n\n if (predicate && !predicate(mutation)) {\n return false\n }\n\n return true\n}\n\nexport function hashQueryKeyByOptions<TQueryKey extends QueryKey = QueryKey>(\n queryKey: TQueryKey,\n options?: Pick<QueryOptions<any, any, any, any>, 'queryKeyHashFn'>,\n): string {\n const hashFn = options?.queryKeyHashFn || hashKey\n return hashFn(queryKey)\n}\n\n/**\n * Default query & mutation keys hash function.\n * Hashes the value into a stable hash.\n */\nexport function hashKey(queryKey: QueryKey | MutationKey): string {\n return JSON.stringify(queryKey, (_, val) =>\n isPlainObject(val)\n ? Object.keys(val)\n .sort()\n .reduce((result, key) => {\n result[key] = val[key]\n return result\n }, {} as any)\n : val,\n )\n}\n\n/**\n * Checks if key `b` partially matches with key `a`.\n */\nexport function partialMatchKey(a: QueryKey, b: QueryKey): boolean\nexport function partialMatchKey(a: any, b: any): boolean {\n if (a === b) {\n return true\n }\n\n if (typeof a !== typeof b) {\n return false\n }\n\n if (a && b && typeof a === 'object' && typeof b === 'object') {\n return Object.keys(b).every((key) => partialMatchKey(a[key], b[key]))\n }\n\n return false\n}\n\nconst hasOwn = Object.prototype.hasOwnProperty\n\n/**\n * This function returns `a` if `b` is deeply equal.\n * If not, it will replace any deeply equal children of `b` with those of `a`.\n * This can be used for structural sharing between JSON values for example.\n */\nexport function replaceEqualDeep<T>(a: unknown, b: T, depth?: number): T\nexport function replaceEqualDeep(a: any, b: any, depth = 0): any {\n if (a === b) {\n return a\n }\n\n if (depth > 500) return b\n\n const array = isPlainArray(a) && isPlainArray(b)\n\n if (!array && !(isPlainObject(a) && isPlainObject(b))) return b\n\n const aItems = array ? a : Object.keys(a)\n const aSize = aItems.length\n const bItems = array ? b : Object.keys(b)\n const bSize = bItems.length\n const copy: any = array ? new Array(bSize) : {}\n\n let equalItems = 0\n\n for (let i = 0; i < bSize; i++) {\n const key: any = array ? i : bItems[i]\n const aItem = a[key]\n const bItem = b[key]\n\n if (aItem === bItem) {\n copy[key] = aItem\n if (array ? i < aSize : hasOwn.call(a, key)) equalItems++\n continue\n }\n\n if (\n aItem === null ||\n bItem === null ||\n typeof aItem !== 'object' ||\n typeof bItem !== 'object'\n ) {\n copy[key] = bItem\n continue\n }\n\n const v = replaceEqualDeep(aItem, bItem, depth + 1)\n copy[key] = v\n if (v === aItem) equalItems++\n }\n\n return aSize === bSize && equalItems === aSize ? a : copy\n}\n\n/**\n * Shallow compare objects.\n */\nexport function shallowEqualObjects<T extends Record<string, any>>(\n a: T,\n b: T | undefined,\n): boolean {\n if (!b || Object.keys(a).length !== Object.keys(b).length) {\n return false\n }\n\n for (const key in a) {\n if (a[key] !== b[key]) {\n return false\n }\n }\n\n return true\n}\n\nexport function isPlainArray(value: unknown): value is Array<unknown> {\n return Array.isArray(value) && value.length === Object.keys(value).length\n}\n\n// Copied from: https://github.com/jonschlinkert/is-plain-object\nexport function isPlainObject(o: any): o is Record<PropertyKey, unknown> {\n if (!hasObjectPrototype(o)) {\n return false\n }\n\n // If has no constructor\n const ctor = o.constructor\n if (ctor === undefined) {\n return true\n }\n\n // If has modified prototype\n const prot = ctor.prototype\n if (!hasObjectPrototype(prot)) {\n return false\n }\n\n // If constructor does not have an Object-specific method\n if (!prot.hasOwnProperty('isPrototypeOf')) {\n return false\n }\n\n // Handles Objects created by Object.create(<arbitrary prototype>)\n if (Object.getPrototypeOf(o) !== Object.prototype) {\n return false\n }\n\n // Most likely a plain Object\n return true\n}\n\nfunction hasObjectPrototype(o: any): boolean {\n return Object.prototype.toString.call(o) === '[object Object]'\n}\n\nexport function sleep(timeout: number): Promise<void> {\n return new Promise((resolve) => {\n timeoutManager.setTimeout(resolve, timeout)\n })\n}\n\nexport function replaceData<\n TData,\n TOptions extends QueryOptions<any, any, any, any>,\n>(prevData: TData | undefined, data: TData, options: TOptions): TData {\n if (typeof options.structuralSharing === 'function') {\n return options.structuralSharing(prevData, data) as TData\n } else if (options.structuralSharing !== false) {\n if (process.env.NODE_ENV !== 'production') {\n try {\n return replaceEqualDeep(prevData, data)\n } catch (error) {\n console.error(\n `Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${options.queryHash}]: ${error}`,\n )\n\n // Prevent the replaceEqualDeep from being called again down below.\n throw error\n }\n }\n // Structurally share data between prev and new data if needed\n return replaceEqualDeep(prevData, data)\n }\n return data\n}\n\nexport function keepPreviousData<T>(\n previousData: T | undefined,\n): T | undefined {\n return previousData\n}\n\nexport function addToEnd<T>(items: Array<T>, item: T, max = 0): Array<T> {\n const newItems = [...items, item]\n return max && newItems.length > max ? newItems.slice(1) : newItems\n}\n\nexport function addToStart<T>(items: Array<T>, item: T, max = 0): Array<T> {\n const newItems = [item, ...items]\n return max && newItems.length > max ? newItems.slice(0, -1) : newItems\n}\n\nexport const skipToken = Symbol()\nexport type SkipToken = typeof skipToken\n\nexport function ensureQueryFn<\n TQueryFnData = unknown,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: {\n queryFn?: QueryFunction<TQueryFnData, TQueryKey> | SkipToken\n queryHash?: string\n },\n fetchOptions?: FetchOptions<TQueryFnData>,\n): QueryFunction<TQueryFnData, TQueryKey> {\n if (process.env.NODE_ENV !== 'production') {\n if (options.queryFn === skipToken) {\n console.error(\n `Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${options.queryHash}'`,\n )\n }\n }\n\n // if we attempt to retry a fetch that was triggered from an initialPromise\n // when we don't have a queryFn yet, we can't retry, so we just return the already rejected initialPromise\n // if an observer has already mounted, we will be able to retry with that queryFn\n if (!options.queryFn && fetchOptions?.initialPromise) {\n return () => fetchOptions.initialPromise!\n }\n\n if (!options.queryFn || options.queryFn === skipToken) {\n return () =>\n Promise.reject(new Error(`Missing queryFn: '${options.queryHash}'`))\n }\n\n return options.queryFn\n}\n\nexport function shouldThrowError<T extends (...args: Array<any>) => boolean>(\n throwOnError: boolean | T | undefined,\n params: Parameters<T>,\n): boolean {\n // Allow throwOnError function to override throwing behavior on a per-error basis\n if (typeof throwOnError === 'function') {\n return throwOnError(...params)\n }\n\n return !!throwOnError\n}\n\nexport function addConsumeAwareSignal<T>(\n object: T,\n getSignal: () => AbortSignal,\n onCancelled: VoidFunction,\n): T & { signal: AbortSignal } {\n let consumed = false\n let signal: AbortSignal | undefined\n\n Object.defineProperty(object, 'signal', {\n enumerable: true,\n get: () => {\n signal ??= getSignal()\n if (consumed) {\n return signal\n }\n\n consumed = true\n if (signal.aborted) {\n onCancelled()\n } else {\n signal.addEventListener('abort', onCancelled, { once: true })\n }\n\n return signal\n },\n })\n\n return object as T & { signal: AbortSignal }\n}\n","/**\n * Thenable types which matches React's types for promises\n *\n * React seemingly uses `.status`, `.value` and `.reason` properties on a promises to optimistically unwrap data from promises\n *\n * @see https://github.com/facebook/react/blob/main/packages/shared/ReactTypes.js#L112-L138\n * @see https://github.com/facebook/react/blob/4f604941569d2e8947ce1460a0b2997e835f37b9/packages/react-debug-tools/src/ReactDebugHooks.js#L224-L227\n */\n\nimport { noop } from './utils'\n\ninterface Fulfilled<T> {\n status: 'fulfilled'\n value: T\n}\ninterface Rejected {\n status: 'rejected'\n reason: unknown\n}\ninterface Pending<T> {\n status: 'pending'\n\n /**\n * Resolve the promise with a value.\n * Will remove the `resolve` and `reject` properties from the promise.\n */\n resolve: (value: T) => void\n /**\n * Reject the promise with a reason.\n * Will remove the `resolve` and `reject` properties from the promise.\n */\n reject: (reason: unknown) => void\n}\n\nexport type FulfilledThenable<T> = Promise<T> & Fulfilled<T>\nexport type RejectedThenable<T> = Promise<T> & Rejected\nexport type PendingThenable<T> = Promise<T> & Pending<T>\n\nexport type Thenable<T> =\n | FulfilledThenable<T>\n | RejectedThenable<T>\n | PendingThenable<T>\n\nexport function pendingThenable<T>(): PendingThenable<T> {\n let resolve: Pending<T>['resolve']\n let reject: Pending<T>['reject']\n // this could use `Promise.withResolvers()` in the future\n const thenable = new Promise((_resolve, _reject) => {\n resolve = _resolve\n reject = _reject\n }) as PendingThenable<T>\n\n thenable.status = 'pending'\n thenable.catch(() => {\n // prevent unhandled rejection errors\n })\n\n function finalize(data: Fulfilled<T> | Rejected) {\n Object.assign(thenable, data)\n\n // clear pending props to avoid calling them twice\n delete (thenable as Partial<PendingThenable<T>>).resolve\n delete (thenable as Partial<PendingThenable<T>>).reject\n }\n\n thenable.resolve = (value) => {\n finalize({\n status: 'fulfilled',\n value,\n })\n\n resolve(value)\n }\n thenable.reject = (reason) => {\n finalize({\n status: 'rejected',\n reason,\n })\n\n reject(reason)\n }\n\n return thenable\n}\n\n/**\n * This function takes a Promise-like input and detects whether the data\n * is synchronously available or not.\n *\n * It does not inspect .status, .value or .reason properties of the promise,\n * as those are not always available, and the .status of React's promises\n * should not be considered part of the public API.\n */\nexport function tryResolveSync(promise: Promise<unknown> | Thenable<unknown>) {\n let data: unknown\n\n promise\n .then((result) => {\n data = result\n return result\n }, noop)\n // .catch can be unavailable on certain kinds of thenable's\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n ?.catch(noop)\n\n if (data !== undefined) {\n return { data }\n }\n\n return undefined\n}\n","import { tryResolveSync } from './thenable'\nimport { noop } from './utils'\nimport type {\n DefaultError,\n MutationKey,\n MutationMeta,\n MutationOptions,\n MutationScope,\n QueryKey,\n QueryMeta,\n QueryOptions,\n} from './types'\nimport type { QueryClient } from './queryClient'\nimport type { Query, QueryState } from './query'\nimport type { Mutation, MutationState } from './mutation'\n\n// TYPES\ntype TransformerFn = (data: any) => any\nfunction defaultTransformerFn(data: any): any {\n return data\n}\n\nexport interface DehydrateOptions {\n serializeData?: TransformerFn\n shouldDehydrateMutation?: (mutation: Mutation) => boolean\n shouldDehydrateQuery?: (query: Query) => boolean\n shouldRedactErrors?: (error: unknown) => boolean\n}\n\nexport interface HydrateOptions {\n defaultOptions?: {\n deserializeData?: TransformerFn\n queries?: QueryOptions\n mutations?: MutationOptions<unknown, DefaultError, unknown, unknown>\n }\n}\n\ninterface DehydratedMutation {\n mutationKey?: MutationKey\n state: MutationState\n meta?: MutationMeta\n scope?: MutationScope\n}\n\ninterface DehydratedQuery {\n queryHash: string\n queryKey: QueryKey\n state: QueryState\n promise?: Promise<unknown>\n meta?: QueryMeta\n // This is only optional because older versions of Query might have dehydrated\n // without it which we need to handle for backwards compatibility.\n // This should be changed to required in the future.\n dehydratedAt?: number\n}\n\nexport interface DehydratedState {\n mutations: Array<DehydratedMutation>\n queries: Array<DehydratedQuery>\n}\n\n// FUNCTIONS\n\nfunction dehydrateMutation(mutation: Mutation): DehydratedMutation {\n return {\n mutationKey: mutation.options.mutationKey,\n state: mutation.state,\n ...(mutation.options.scope && { scope: mutation.options.scope }),\n ...(mutation.meta && { meta: mutation.meta }),\n }\n}\n\n// Most config is not dehydrated but instead meant to configure again when\n// consuming the de/rehydrated data, typically with useQuery on the client.\n// Sometimes it might make sense to prefetch data on the server and include\n// in the html-payload, but not consume it on the initial render.\nfunction dehydrateQuery(\n query: Query,\n serializeData: TransformerFn,\n shouldRedactErrors: (error: unknown) => boolean,\n): DehydratedQuery {\n const dehydratePromise = () => {\n const promise = query.promise?.then(serializeData).catch((error) => {\n if (!shouldRedactErrors(error)) {\n // Reject original error if it should not be redacted\n return Promise.reject(error)\n }\n // If not in production, log original error before rejecting redacted error\n if (process.env.NODE_ENV !== 'production') {\n console.error(\n `A query that was dehydrated as pending ended up rejecting. [${query.queryHash}]: ${error}; The error will be redacted in production builds`,\n )\n }\n return Promise.reject(new Error('redacted'))\n })\n\n // Avoid unhandled promise rejections\n // We need the promise we dehydrate to reject to get the correct result into\n // the query cache, but we also want to avoid unhandled promise rejections\n // in whatever environment the prefetches are happening in.\n promise?.catch(noop)\n\n return promise\n }\n\n return {\n dehydratedAt: Date.now(),\n state: {\n ...query.state,\n ...(query.state.data !== undefined && {\n data: serializeData(query.state.data),\n }),\n },\n queryKey: query.queryKey,\n queryHash: query.queryHash,\n ...(query.state.status === 'pending' && {\n promise: dehydratePromise(),\n }),\n ...(query.meta && { meta: query.meta }),\n }\n}\n\nexport function defaultShouldDehydrateMutation(mutation: Mutation) {\n return mutation.state.isPaused\n}\n\nexport function defaultShouldDehydrateQuery(query: Query) {\n return query.state.status === 'success'\n}\n\nfunction defaultShouldRedactErrors(_: unknown) {\n return true\n}\n\nexport function dehydrate(\n client: QueryClient,\n options: DehydrateOptions = {},\n): DehydratedState {\n const filterMutation =\n options.shouldDehydrateMutation ??\n client.getDefaultOptions().dehydrate?.shouldDehydrateMutation ??\n defaultShouldDehydrateMutation\n\n const mutations = client\n .getMutationCache()\n .getAll()\n .flatMap((mutation) =>\n filterMutation(mutation) ? [dehydrateMutation(mutation)] : [],\n )\n\n const filterQuery =\n options.shouldDehydrateQuery ??\n client.getDefaultOptions().dehydrate?.shouldDehydrateQuery ??\n defaultShouldDehydrateQuery\n\n const shouldRedactErrors =\n options.shouldRedactErrors ??\n client.getDefaultOptions().dehydrate?.shouldRedactErrors ??\n defaultShouldRedactErrors\n\n const serializeData =\n options.serializeData ??\n client.getDefaultOptions().dehydrate?.serializeData ??\n defaultTransformerFn\n\n const queries = client\n .getQueryCache()\n .getAll()\n .flatMap((query) =>\n filterQuery(query)\n ? [dehydrateQuery(query, serializeData, shouldRedactErrors)]\n : [],\n )\n\n return { mutations, queries }\n}\n\nexport function hydrate(\n client: QueryClient,\n dehydratedState: unknown,\n options?: HydrateOptions,\n): void {\n if (typeof dehydratedState !== 'object' || dehydratedState === null) {\n return\n }\n\n const mutationCache = client.getMutationCache()\n const queryCache = client.getQueryCache()\n const deserializeData =\n options?.defaultOptions?.deserializeData ??\n client.getDefaultOptions().hydrate?.deserializeData ??\n defaultTransformerFn\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n const mutations = (dehydratedState as DehydratedState).mutations || []\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n const queries = (dehydratedState as DehydratedState).queries || []\n\n mutations.forEach(({ state, ...mutationOptions }) => {\n mutationCache.build(\n client,\n {\n ...client.getDefaultOptions().hydrate?.mutations,\n ...options?.defaultOptions?.mutations,\n ...mutationOptions,\n },\n state,\n )\n })\n\n queries.forEach(\n ({ queryKey, state, queryHash, meta, promise, dehydratedAt }) => {\n const syncData = promise ? tryResolveSync(promise) : undefined\n const rawData = state.data === undefined ? syncData?.data : state.data\n const data = rawData === undefined ? rawData : deserializeData(rawData)\n\n let query = queryCache.get(queryHash)\n const existingQueryIsPending = query?.state.status === 'pending'\n const existingQueryIsFetching = query?.state.fetchStatus === 'fetching'\n\n // Do not hydrate if an existing query exists with newer data\n if (query) {\n const hasNewerSyncData =\n syncData &&\n // We only need this undefined check to handle older dehydration\n // payloads that might not have dehydratedAt\n dehydratedAt !== undefined &&\n dehydratedAt > query.state.dataUpdatedAt\n if (\n state.dataUpdatedAt > query.state.dataUpdatedAt ||\n hasNewerSyncData\n ) {\n // omit fetchStatus from dehydrated state\n // so that query stays in its current fetchStatus\n const { fetchStatus: _ignored, ...serializedState } = state\n query.setState({\n ...serializedState,\n data,\n })\n }\n } else {\n // Restore query\n query = queryCache.build(\n client,\n {\n ...client.getDefaultOptions().hydrate?.queries,\n ...options?.defaultOptions?.queries,\n queryKey,\n queryHash,\n meta,\n },\n // Reset fetch status to idle to avoid\n // query being stuck in fetching state upon hydration\n {\n ...state,\n data,\n fetchStatus: 'idle',\n status: data !== undefined ? 'success' : state.status,\n },\n )\n }\n\n if (\n promise &&\n !existingQueryIsPending &&\n !existingQueryIsFetching &&\n // Only hydrate if dehydration is newer than any existing data,\n // this is always true for new queries\n (dehydratedAt === undefined || dehydratedAt > query.state.dataUpdatedAt)\n ) {\n // This doesn't actually fetch - it just creates a retryer\n // which will re-use the passed `initialPromise`\n // Note that we need to call these even when data was synchronously\n // available, as we still need to set up the retryer\n query\n .fetch(undefined, {\n // RSC transformed promises are not thenable\n initialPromise: Promise.resolve(promise).then(deserializeData),\n })\n // Avoid unhandled promise rejections\n .catch(noop)\n }\n },\n )\n}\n","import { dehydrate, hydrate } from '@tanstack/query-core'\nimport type {\n DehydrateOptions,\n DehydratedState,\n HydrateOptions,\n NotifyEventType,\n QueryClient,\n} from '@tanstack/query-core'\n\nexport type Promisable<T> = T | PromiseLike<T>\n\nexport interface Persister {\n persistClient: (persistClient: PersistedClient) => Promisable<void>\n restoreClient: () => Promisable<PersistedClient | undefined>\n removeClient: () => Promisable<void>\n}\n\nexport interface PersistedClient {\n timestamp: number\n buster: string\n clientState: DehydratedState\n}\n\nexport interface PersistQueryClientRootOptions {\n /** The QueryClient to persist */\n queryClient: QueryClient\n /** The Persister interface for storing and restoring the cache\n * to/from a persisted location */\n persister: Persister\n /** A unique string that can be used to forcefully\n * invalidate existing caches if they do not share the same buster string */\n buster?: string\n}\n\nexport interface PersistedQueryClientRestoreOptions extends PersistQueryClientRootOptions {\n /** The max-allowed age of the cache in milliseconds.\n * If a persisted cache is found that is older than this\n * time, it will be discarded */\n maxAge?: number\n /** The options passed to the hydrate function */\n hydrateOptions?: HydrateOptions\n}\n\nexport interface PersistedQueryClientSaveOptions extends PersistQueryClientRootOptions {\n /** The options passed to the dehydrate function */\n dehydrateOptions?: DehydrateOptions\n}\n\nexport interface PersistQueryClientOptions\n extends\n PersistedQueryClientRestoreOptions,\n PersistedQueryClientSaveOptions,\n PersistQueryClientRootOptions {}\n\n/**\n * Checks if emitted event is about cache change and not about observers.\n * Useful for persist, where we only want to trigger save when cache is changed.\n */\nconst cacheEventTypes: Array<NotifyEventType> = ['added', 'removed', 'updated']\n\nfunction isCacheEventType(eventType: NotifyEventType) {\n return cacheEventTypes.includes(eventType)\n}\n\n/**\n * Restores persisted data to the QueryCache\n * - data obtained from persister.restoreClient\n * - data is hydrated using hydrateOptions\n * If data is expired, busted, empty, or throws, it runs persister.removeClient\n */\nexport async function persistQueryClientRestore({\n queryClient,\n persister,\n maxAge = 1000 * 60 * 60 * 24,\n buster = '',\n hydrateOptions,\n}: PersistedQueryClientRestoreOptions) {\n try {\n const persistedClient = await persister.restoreClient()\n\n if (persistedClient) {\n if (persistedClient.timestamp) {\n const expired = Date.now() - persistedClient.timestamp > maxAge\n const busted = persistedClient.buster !== buster\n if (expired || busted) {\n return persister.removeClient()\n } else {\n hydrate(queryClient, persistedClient.clientState, hydrateOptions)\n }\n } else {\n return persister.removeClient()\n }\n }\n } catch (err) {\n if (process.env.NODE_ENV !== 'production') {\n console.error(err)\n console.warn(\n 'Encountered an error attempting to restore client cache from persisted location. As a precaution, the persisted cache will be discarded.',\n )\n }\n\n await persister.removeClient()\n\n throw err\n }\n}\n\n/**\n * Persists data from the QueryCache\n * - data dehydrated using dehydrateOptions\n * - data is persisted using persister.persistClient\n */\nexport async function persistQueryClientSave({\n queryClient,\n persister,\n buster = '',\n dehydrateOptions,\n}: PersistedQueryClientSaveOptions) {\n const persistClient: PersistedClient = {\n buster,\n timestamp: Date.now(),\n clientState: dehydrate(queryClient, dehydrateOptions),\n }\n\n await persister.persistClient(persistClient)\n}\n\n/**\n * Subscribe to QueryCache and MutationCache updates (for persisting)\n * @returns an unsubscribe function (to discontinue monitoring)\n */\nexport function persistQueryClientSubscribe(\n props: PersistedQueryClientSaveOptions,\n) {\n const unsubscribeQueryCache = props.queryClient\n .getQueryCache()\n .subscribe((event) => {\n if (isCacheEventType(event.type)) {\n persistQueryClientSave(props)\n }\n })\n\n const unsubscribeMutationCache = props.queryClient\n .getMutationCache()\n .subscribe((event) => {\n if (isCacheEventType(event.type)) {\n persistQueryClientSave(props)\n }\n })\n\n return () => {\n unsubscribeQueryCache()\n unsubscribeMutationCache()\n }\n}\n\n/**\n * Restores persisted data to QueryCache and persists further changes.\n */\nexport function persistQueryClient(\n props: PersistQueryClientOptions,\n): [() => void, Promise<void>] {\n let hasUnsubscribed = false\n let persistQueryClientUnsubscribe: (() => void) | undefined\n const unsubscribe = () => {\n hasUnsubscribed = true\n persistQueryClientUnsubscribe?.()\n }\n\n // Attempt restore\n const restorePromise = persistQueryClientRestore(props).then(() => {\n if (!hasUnsubscribed) {\n // Subscribe to changes in the query cache to trigger the save\n persistQueryClientUnsubscribe = persistQueryClientSubscribe(props)\n }\n })\n\n return [unsubscribe, restorePromise]\n}\n","import type { QueryClient } from '@tanstack/react-query'\nimport type { TadaDocumentNode } from 'gql.tada'\n\nimport { conflictAwareUpdate } from './conflictAwareUpdate'\nimport { accountUpdateEmail } from '../../account/useUpdateEmail'\nimport { accountUpdateName } from '../../account/useUpdateName'\nimport { updatePassword } from '../../account/useUpdatePassword'\nimport { accountUpdatePhone } from '../../account/useUpdatePhone'\nimport { accountUpdatePrefs } from '../../account/useUpdatePrefs'\nimport type { AppwriteClient } from '../../client'\nimport { createDocument } from '../../databases/useCreateDocument'\nimport { decrementDocumentAttribute } from '../../databases/useDecrementAttribute'\nimport { deleteDocument } from '../../databases/useDeleteDocument'\nimport { incrementDocumentAttribute } from '../../databases/useIncrementAttribute'\nimport { upsertDocument } from '../../databases/useUpsertDocument'\nimport { createSubscriber } from '../../messaging/useCreateSubscriber'\nimport { deleteSubscriber } from '../../messaging/useDeleteSubscriber'\nimport { Keys } from '../../query/Keys'\nimport { createMembership } from '../../teams/useCreateMembership'\nimport { createTeam } from '../../teams/useCreateTeam'\nimport { deleteMembership } from '../../teams/useDeleteMembership'\nimport { deleteTeam } from '../../teams/useDeleteTeam'\nimport { updateMembership } from '../../teams/useUpdateMembership'\nimport { updateTeamName } from '../../teams/useUpdateTeamName'\nimport { updateTeamPrefs } from '../../teams/useUpdateTeamPrefs'\nimport type { ConflictStrategy } from '../conflictResolution/types'\nimport type { MutationFn, Vars } from '../types'\n\n/**\n * Creates a mutationFn that executes a GraphQL mutation and returns the\n * first field from the response data.\n */\nfunction gqlMutation(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n query: TadaDocumentNode<any, any>,\n resultKey: string,\n options?: { serializeData?: boolean },\n): MutationFn {\n return async (client, variables) => {\n const vars = options?.serializeData\n ? { ...variables, data: JSON.stringify(variables.data) }\n : variables\n\n const { data, errors } = await client.graphql.mutation({\n query,\n variables: vars as any,\n })\n if (errors) throw errors\n return (data as Vars)[resultKey]\n }\n}\n\ntype MutationEntry = {\n mutationKey: readonly string[]\n mutationFn: MutationFn\n}\n\nexport const mutationRegistry: MutationEntry[] = [\n {\n mutationKey: Keys.databases().collections().documents().create(),\n mutationFn: gqlMutation(createDocument, 'databasesCreateDocument', {\n serializeData: true,\n }),\n },\n // The update document entry is registered separately by hydrateMutationDefaults\n // so it can be configured with the user's conflict resolution strategy.\n {\n mutationKey: Keys.databases().collections().documents().delete(),\n mutationFn: gqlMutation(deleteDocument, 'databasesDeleteDocument'),\n },\n {\n mutationKey: Keys.databases().collections().documents().upsert(),\n mutationFn: gqlMutation(upsertDocument, 'databasesUpsertDocument', {\n serializeData: true,\n }),\n },\n {\n mutationKey: [...Keys.databases().transactions().operations().key(), 'incrementAttribute'],\n mutationFn: gqlMutation(incrementDocumentAttribute, 'databasesIncrementDocumentAttribute'),\n },\n\n {\n mutationKey: [...Keys.databases().transactions().operations().key(), 'decrementAttribute'],\n mutationFn: gqlMutation(decrementDocumentAttribute, 'databasesDecrementDocumentAttribute'),\n },\n\n {\n mutationKey: Keys.account().prefs().update(),\n mutationFn: gqlMutation(accountUpdatePrefs, 'accountUpdatePrefs'),\n },\n {\n mutationKey: Keys.account().name().update(),\n mutationFn: gqlMutation(accountUpdateName, 'accountUpdateName'),\n },\n {\n mutationKey: Keys.account().email().update(),\n mutationFn: gqlMutation(accountUpdateEmail, 'accountUpdateEmail'),\n },\n {\n mutationKey: Keys.account().password().update(),\n mutationFn: gqlMutation(updatePassword, 'accountUpdatePassword'),\n },\n {\n mutationKey: Keys.account().phone().update(),\n mutationFn: gqlMutation(accountUpdatePhone, 'accountUpdatePhone'),\n },\n\n {\n mutationKey: Keys.teams().create(),\n mutationFn: gqlMutation(createTeam, 'teamsCreate'),\n },\n {\n mutationKey: Keys.teams().delete(),\n mutationFn: gqlMutation(deleteTeam, 'teamsDelete'),\n },\n {\n mutationKey: Keys.teams().teamName().update(),\n mutationFn: gqlMutation(updateTeamName, 'teamsUpdateName'),\n },\n {\n mutationKey: Keys.teams().teamPrefs().update(),\n mutationFn: gqlMutation(updateTeamPrefs, 'teamsUpdatePrefs'),\n },\n {\n mutationKey: Keys.teams().memberships().create(),\n mutationFn: gqlMutation(createMembership, 'teamsCreateMembership'),\n },\n {\n mutationKey: Keys.teams().memberships().delete(),\n mutationFn: gqlMutation(deleteMembership, 'teamsDeleteMembership'),\n },\n {\n mutationKey: Keys.teams().memberships().update(),\n mutationFn: gqlMutation(updateMembership, 'teamsUpdateMembership'),\n },\n\n {\n mutationKey: Keys.messaging().subscriber().create(),\n mutationFn: gqlMutation(createSubscriber, 'messagingCreateSubscriber'),\n },\n {\n mutationKey: Keys.messaging().subscriber().delete(),\n mutationFn: gqlMutation(deleteSubscriber, 'messagingDeleteSubscriber'),\n },\n]\n\n/**\n * Registers all mutation defaults with the QueryClient so that\n * dehydrated/persisted mutations can be replayed on app restart.\n *\n * Call once during app initialization, before rehydrating the persisted\n * mutation cache.\n */\nexport function hydrateMutationDefaults(\n queryClient: QueryClient,\n client: AppwriteClient,\n options?: { conflictStrategy?: ConflictStrategy },\n) {\n for (const entry of mutationRegistry) {\n queryClient.setMutationDefaults(entry.mutationKey, {\n mutationFn: (variables: Vars) => entry.mutationFn(client, variables, queryClient),\n scope: { id: 'appwrite' },\n })\n }\n\n // Register the update document mutation with conflict resolution awareness\n const strategy = options?.conflictStrategy ?? 'last-write-wins'\n queryClient.setMutationDefaults(Keys.databases().collections().documents().update(), {\n mutationFn: (variables: Vars) => conflictAwareUpdate(strategy)(client, variables, queryClient),\n scope: { id: 'appwrite' },\n })\n}\n","import { createAsyncStoragePersister } from '@tanstack/query-async-storage-persister'\nimport type { AsyncStorage, Persister } from '@tanstack/query-persist-client-core'\nimport { persistQueryClient } from '@tanstack/query-persist-client-core'\nimport { onlineManager, QueryClient } from '@tanstack/react-query'\n\nimport type { ConflictStrategy } from './conflictResolution/types'\nimport { hydrateMutationDefaults } from './mutations/registry'\nimport type { NetworkAdapter } from './types'\nimport type { AppwriteClient } from '../client'\nimport { createAppwriteClient } from '../client'\n\nexport type OfflineClient = {\n appwrite: AppwriteClient\n queryClient: QueryClient\n persister: Persister | undefined\n\n /**\n * Start persistence for non-React (imperative) usage.\n * Restores the persisted cache, subscribes to future changes,\n * and replays any paused mutations once the cache is restored.\n *\n * @returns `unsubscribe` to stop persisting and `restored` which resolves\n * when the cache has been rehydrated from storage.\n * @throws If no persister was configured via `storage` or `persister`.\n */\n startPersistence: () => { unsubscribe: () => void; restored: Promise<void> }\n\n conflictStrategy?: ConflictStrategy\n}\n\nconst dehydrateOptions = {\n shouldDehydrateMutation: (mutation: { state: { isPaused: boolean } }) => mutation.state.isPaused,\n shouldDehydrateQuery: (query: { state: { status: string } }) => query.state.status === 'success',\n}\n\n/**\n * Creates an offline-capable Appwrite client with a pre-configured QueryClient.\n *\n * Persistence can be configured in three ways:\n * - **Batteries-included**: pass `storage` (an `AsyncStorage` interface) and\n * the factory builds a TanStack persister automatically.\n * - **Bring your own**: pass a pre-built `persister` (TanStack `Persister`\n * interface) — e.g. one backed by TinyBase, SQLite, etc.\n * - **No persistence**: omit both — you still get offline mutation queuing\n * and network state management.\n *\n * For React apps, pass `client.persister` to `<AppwriteProvider persister={…}>`.\n * For non-React (imperative) usage, call `client.startPersistence()`.\n */\nexport function createOfflineClient({\n endpoint,\n projectId,\n storage,\n persister: externalPersister,\n networkAdapter,\n throttleTime = 1000,\n conflictStrategy = 'last-write-wins',\n}: {\n endpoint: string\n projectId: string\n /** Batteries-included: provide a simple getItem/setItem/removeItem storage. */\n storage?: AsyncStorage\n /** BYOP: provide a pre-built TanStack Persister. */\n persister?: Persister\n networkAdapter: NetworkAdapter\n /** Throttle time for network status changes to prevent rapid toggling. Default: 1000ms. */\n throttleTime?: number\n conflictStrategy?: ConflictStrategy\n}): OfflineClient {\n if (storage && externalPersister) {\n throw new Error('Provide either `storage` or `persister`, not both.')\n }\n\n const appwrite = createAppwriteClient({ endpoint, projectId })\n\n const queryClient = new QueryClient({\n defaultOptions: {\n mutations: {\n networkMode: 'offlineFirst',\n meta: {\n conflictStrategy,\n },\n },\n queries: { networkMode: 'offlineFirst', gcTime: 1000 * 60 * 60 * 24 },\n },\n })\n\n hydrateMutationDefaults(queryClient, appwrite, { conflictStrategy })\n\n const persister =\n externalPersister ??\n (storage\n ? createAsyncStoragePersister({\n storage,\n key: 'appwrite-graphql-offline-cache',\n throttleTime,\n })\n : undefined)\n\n networkAdapter.listen((isOnline) => {\n onlineManager.setOnline(isOnline)\n })\n\n return {\n appwrite,\n queryClient,\n persister,\n startPersistence() {\n if (!persister) {\n throw new Error(\n 'No persister configured. Provide `storage` or `persister` to createOfflineClient.',\n )\n }\n\n const [unsubscribe, restored] = persistQueryClient({\n queryClient,\n persister,\n dehydrateOptions,\n })\n\n const restoredWithResume = restored.then(() => {\n void queryClient.resumePausedMutations()\n })\n\n return { unsubscribe, restored: restoredWithResume }\n },\n }\n}\n","import { useState } from 'react'\nimport type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useMutation } from '../useMutation'\nimport { useQuery } from '../useQuery'\nimport { useSuspenseQuery } from '../useSuspenseQuery'\n\ntype Props = {\n functionId: string\n body?: Record<string, string | number | boolean | null>\n async?: boolean\n path?: string\n method?: string\n headers?: Record<string, string | number | boolean | null>\n scheduledAt?: string\n}\n\nconst createExecution = gql(/* GraphQL */ `\n mutation CreateExecution(\n $functionId: String!\n $body: String\n $async: Boolean\n $path: String\n $method: String\n $headers: String\n $scheduledAt: String\n ) {\n functionsCreateExecution(\n functionId: $functionId\n body: $body\n async: $async\n path: $path\n method: $method\n headers: $headers\n scheduledAt: $scheduledAt\n ) {\n _id\n status\n responseStatusCode\n responseBody\n errors\n duration\n }\n }\n`)\n\nconst getFunctionExecution = gql(/* GraphQL */ `\n query GetFunctionExecution($functionId: String!, $executionId: String!) {\n functionsGetExecution(functionId: $functionId, executionId: $executionId) {\n status\n errors\n duration\n responseBody\n requestPath\n }\n }\n`)\n\n/** The result of polling the current execution in the {@link useFunction} hook. */\nexport type FunctionResult = Prettify<\n ResultOf<typeof getFunctionExecution>['functionsGetExecution']\n>\n\ntype ResponseBody = string | null | undefined | Record<string, string | number | boolean | null>\n\nfunction useCurrentExecution({\n currentExecution,\n currentFunction,\n}: {\n currentExecution: string | null\n currentFunction: string | null\n}) {\n const { graphql } = useAppwrite()\n const enabled = !!currentFunction && !!currentExecution\n\n const query = useQuery<FunctionResult | null, AppwriteException[], FunctionResult | null>({\n queryKey: enabled\n ? Keys.function(currentFunction).execution(currentExecution).key()\n : Keys.functions().key(),\n queryFn: async () => {\n if (!currentExecution || !currentFunction) {\n return null\n }\n const { data } = await graphql.query({\n query: getFunctionExecution,\n variables: {\n functionId: currentFunction,\n executionId: currentExecution,\n },\n })\n\n if (!data?.functionsGetExecution) {\n throw new Error('Execution not found')\n }\n\n return data.functionsGetExecution ?? null\n },\n enabled,\n })\n\n return { ...query }\n}\n\n/**\n * Returns `{ executeFunction, currentExecution }` for triggering Appwrite function executions.\n *\n * **`executeFunction`** is a mutation that sends the `CreateExecution` GraphQL mutation.\n * It serialises `body` and `headers` to JSON strings before sending, and automatically\n * parses JSON response bodies back into objects. If the execution status is `\"failed\"`,\n * the mutation throws with the error details.\n *\n * **`currentExecution`** is a query that polls the latest execution's status via the\n * `GetFunctionExecution` GraphQL query. It is enabled automatically once an execution\n * has been triggered and exposes standard `useQuery` fields (`data`, `isLoading`, etc.).\n *\n * @example\n * ```tsx\n * const { executeFunction, currentExecution } = useFunction()\n *\n * // Trigger a function execution\n * executeFunction.mutate({\n * functionId: 'send-welcome-email',\n * body: { userId: 'user_123' },\n * method: 'POST',\n * path: '/send',\n * })\n *\n * // Poll the result\n * if (currentExecution.data) {\n * console.log(currentExecution.data.status)\n * console.log(currentExecution.data.responseBody)\n * }\n * ```\n *\n * **Variables** (`Props`):\n * - `functionId` — The ID of the Appwrite function to execute\n * - `body` — Optional. A key-value object sent as the request body (serialised to JSON)\n * - `async` — Optional. When `true`, the function runs asynchronously (defaults to `false`)\n * - `path` — Optional. The execution path (defaults to `'/'`)\n * - `method` — Optional. The HTTP method (defaults to `'POST'`)\n * - `headers` — Optional. A key-value object of custom headers (serialised to JSON)\n * - `scheduledAt` — Optional. An ISO 8601 date string to schedule the execution\n *\n * @returns An object with `executeFunction` (a `UseMutationResult` whose `data` is the\n * parsed response body or raw string) and `currentExecution` (a `UseQueryResult` whose\n * `data` is the {@link FunctionResult} with `status`, `errors`, `duration`, `responseBody`,\n * and `requestPath`).\n */\nexport function useFunction() {\n const { graphql } = useAppwrite()\n const [currentExecution, setCurrentExecution] = useState<string | null>(null)\n const [currentFunction, setCurrentFunction] = useState<string | null>(null)\n const getExecution = useCurrentExecution({\n currentExecution,\n currentFunction,\n })\n\n const executeFunction = useMutation<ResponseBody, AppwriteException[], Props>({\n mutationKey: Keys.functions().executions().create(),\n mutationFn: async ({\n functionId,\n body = {},\n async = false,\n path = '/',\n method = 'POST',\n headers = {},\n scheduledAt,\n }) => {\n setCurrentFunction(functionId)\n\n const { data } = await graphql.mutation({\n query: createExecution,\n variables: {\n functionId,\n body: JSON.stringify(body),\n async,\n path,\n method,\n headers: JSON.stringify(headers),\n scheduledAt,\n },\n })\n\n const { _id, status, errors, responseBody } = data.functionsCreateExecution ?? {}\n\n if (status === 'failed') {\n throw new Error(errors)\n }\n\n setCurrentExecution(_id ?? null)\n\n if (typeof responseBody === 'string') {\n if (responseBody.trim().startsWith('{') && responseBody.trim().endsWith('}')) {\n try {\n return JSON.parse(responseBody)\n } catch (error) {\n console.error('Failed to parse response body:', error)\n return responseBody\n }\n }\n return responseBody\n }\n },\n })\n\n return {\n executeFunction,\n currentExecution: getExecution,\n }\n}\n\n/**\n * Suspense variant that executes an Appwrite function and suspends until the result is available.\n *\n * Uses `useSuspenseQuery` under the hood so the component tree suspends while the function\n * executes. The query is cached with `staleTime: Infinity` so re-renders do not re-trigger\n * the execution. JSON response bodies are automatically parsed into objects.\n *\n * @example\n * ```tsx\n * function WelcomeMessage() {\n * const { executeFunction } = useSuspenseFunction({\n * functionId: 'get-greeting',\n * body: { locale: 'en' },\n * path: '/greet',\n * method: 'GET',\n * })\n *\n * return <p>{executeFunction.data}</p>\n * }\n * ```\n *\n * **Variables** (`Props`):\n * - `functionId` — The ID of the Appwrite function to execute\n * - `body` — Optional. A key-value object sent as the request body (serialised to JSON)\n * - `async` — Optional. When `true`, the function runs asynchronously (defaults to `false`)\n * - `path` — Optional. The execution path (defaults to `'/'`)\n * - `method` — Optional. The HTTP method (defaults to `'POST'`)\n * - `headers` — Optional. A key-value object of custom headers (serialised to JSON)\n * - `scheduledAt` — Optional. An ISO 8601 date string to schedule the execution\n *\n * @returns An object with `executeFunction` (a `UseSuspenseQueryResult` whose `data` is\n * the parsed response body or raw string).\n */\nexport function useSuspenseFunction({\n functionId,\n body = {},\n async = false,\n path = '/',\n method = 'POST',\n headers = {},\n scheduledAt,\n}: Props) {\n const { graphql } = useAppwrite()\n\n const executeFunction = useSuspenseQuery<ResponseBody, AppwriteException[], ResponseBody>({\n queryKey: [...Keys.function(functionId).key(), 'execute', { path, method, body }],\n queryFn: async () => {\n const { data } = await graphql.mutation({\n query: createExecution,\n variables: {\n functionId,\n body: JSON.stringify(body),\n async,\n path,\n method,\n headers: JSON.stringify(headers),\n scheduledAt,\n },\n })\n\n if (data?.functionsCreateExecution?.status === 'failed') {\n throw new Error(data.functionsCreateExecution.errors)\n }\n\n const { responseBody } = data.functionsCreateExecution ?? {}\n\n if (typeof responseBody === 'string') {\n if (responseBody.trim().startsWith('{') && responseBody.trim().endsWith('}')) {\n try {\n return JSON.parse(responseBody)\n } catch (error) {\n console.error('Failed to parse response body:', error)\n return responseBody\n }\n }\n }\n return responseBody\n },\n staleTime: Infinity,\n })\n\n return {\n executeFunction,\n }\n}\n","import type { ResultOf, VariablesOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify, QueryOptions } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst getExecution = gql(/* GraphQL */ `\n query GetExecution($functionId: String!, $executionId: String!) {\n functionsGetExecution(functionId: $functionId, executionId: $executionId) {\n _id\n _createdAt\n _updatedAt\n functionId\n trigger\n status\n requestMethod\n requestPath\n responseStatusCode\n responseBody\n errors\n duration\n }\n }\n`)\n\n/** The variables accepted by the {@link useGetExecution} hook. */\nexport type GetExecutionVariables = Prettify<VariablesOf<typeof getExecution>>\n\n/** The result returned by the {@link useGetExecution} hook. */\nexport type GetExecutionResult = Prettify<ResultOf<typeof getExecution>['functionsGetExecution']>\n\n/**\n * Fetches the details of a specific function execution.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useGetExecution({\n * functionId: 'send-email',\n * executionId: '9b2c…',\n * })\n *\n * // data.status, data.responseBody, data.duration\n * ```\n *\n * **Parameters** ({@link GetExecutionVariables}):\n * - `functionId` — The unique function identifier.\n * - `executionId` — The unique execution identifier.\n *\n * @returns A `UseQueryResult` with the execution details ({@link GetExecutionResult}).\n */\nexport function useGetExecution(\n { functionId, executionId }: GetExecutionVariables,\n opts: QueryOptions = {},\n) {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<GetExecutionResult, AppwriteException[], GetExecutionResult>({\n queryKey: Keys.function(functionId).execution(executionId).key(),\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: getExecution,\n variables: { functionId, executionId },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.functionsGetExecution\n },\n ...opts,\n })\n\n return queryResult\n}\n","import type { ResultOf } from 'gql.tada'\nimport { graphql as gql } from 'gql.tada'\n\nimport { Keys } from '../query/Keys'\nimport type { AppwriteException, Prettify, QueryOptions } from '../types'\nimport { useAppwrite } from '../useAppwrite'\nimport { useQuery } from '../useQuery'\n\nconst listExecutions = gql(/* GraphQL */ `\n query ListExecutions($functionId: String!, $queries: [String!]) {\n functionsListExecutions(functionId: $functionId, queries: $queries) {\n total\n executions {\n _id\n _createdAt\n _updatedAt\n functionId\n trigger\n status\n requestMethod\n requestPath\n responseStatusCode\n responseBody\n errors\n duration\n }\n }\n }\n`)\n\n/** The result returned by the {@link useListExecutions} hook. */\nexport type ListExecutionsResult = Prettify<\n ResultOf<typeof listExecutions>['functionsListExecutions']\n>\n\n/**\n * Fetches the list of executions for a function with optional query filters.\n *\n * @example\n * ```tsx\n * const { data, isLoading } = useListExecutions({\n * functionId: 'send-email',\n * queries: ['limit(10)'],\n * })\n *\n * // data.total, data.executions\n * ```\n *\n * **Parameters:**\n * - `functionId` — The unique function identifier.\n * - `queries` *(optional)* — Appwrite query strings for filtering and pagination.\n *\n * @returns A `UseQueryResult` with the paginated execution list ({@link ListExecutionsResult}).\n */\nexport function useListExecutions(\n {\n functionId,\n queries,\n }: {\n functionId: string\n queries?: string[]\n },\n opts: QueryOptions = {},\n) {\n const { graphql } = useAppwrite()\n\n const queryResult = useQuery<ListExecutionsResult, AppwriteException[], ListExecutionsResult>({\n queryKey: [...Keys.function(functionId).executions().key(), ...(queries ?? [])],\n queryFn: async () => {\n const { data, errors } = await graphql.query({\n query: listExecutions,\n variables: {\n functionId,\n queries,\n },\n })\n\n if (errors) {\n throw errors\n }\n\n return data.functionsListExecutions\n },\n ...opts,\n })\n\n return queryResult\n}\n","import type { NetworkAdapter } from '../types'\n\nexport function webNetworkAdapter(): NetworkAdapter {\n return {\n listen: (callback) => {\n const updateOnlineStatus = () => {\n callback(navigator.onLine)\n }\n\n window.addEventListener('online', updateOnlineStatus)\n window.addEventListener('offline', updateOnlineStatus)\n\n // Initial status\n callback(navigator.onLine)\n\n return () => {\n window.removeEventListener('online', updateOnlineStatus)\n window.removeEventListener('offline', updateOnlineStatus)\n }\n },\n }\n}\n"]}
|