@m5kdev/frontend 0.20.51 → 0.21.0
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/src/index.d.mts +25 -0
- package/dist/src/index.d.ts +25 -0
- package/dist/src/index.js +83 -0
- package/dist/src/index.mjs +25 -0
- package/dist/src/modules/auth/auth.client.d.mts +708 -0
- package/dist/src/modules/auth/auth.client.d.mts.map +1 -0
- package/dist/src/modules/auth/auth.client.d.ts +708 -0
- package/dist/src/modules/auth/auth.client.d.ts.map +1 -0
- package/dist/src/modules/auth/auth.client.js +72 -0
- package/dist/src/modules/auth/auth.client.js.map +1 -0
- package/dist/src/modules/auth/auth.client.mjs +71 -0
- package/dist/src/modules/auth/auth.client.mjs.map +1 -0
- package/dist/src/modules/auth/auth.context.d.mts +15 -0
- package/dist/src/modules/auth/auth.context.d.mts.map +1 -0
- package/dist/src/modules/auth/auth.context.d.ts +15 -0
- package/dist/src/modules/auth/auth.context.d.ts.map +1 -0
- package/dist/src/modules/auth/auth.context.js +13 -0
- package/dist/src/modules/auth/auth.context.js.map +1 -0
- package/dist/src/modules/auth/auth.context.mjs +13 -0
- package/dist/src/modules/auth/auth.context.mjs.map +1 -0
- package/dist/src/modules/auth/auth.lib.d.mts +1251 -1380
- package/dist/src/modules/auth/auth.lib.d.mts.map +1 -1
- package/dist/src/modules/auth/auth.lib.d.ts +1251 -1380
- package/dist/src/modules/auth/auth.lib.d.ts.map +1 -1
- package/dist/src/modules/auth/auth.lib.js +18 -63
- package/dist/src/modules/auth/auth.lib.js.map +1 -1
- package/dist/src/modules/auth/auth.lib.mjs +10 -64
- package/dist/src/modules/auth/auth.lib.mjs.map +1 -1
- package/dist/src/modules/auth/components/AuthProvider.d.mts +9 -10
- package/dist/src/modules/auth/components/AuthProvider.d.mts.map +1 -1
- package/dist/src/modules/auth/components/AuthProvider.d.ts +9 -10
- package/dist/src/modules/auth/components/AuthProvider.d.ts.map +1 -1
- package/dist/src/modules/auth/components/AuthProvider.js +20 -42
- package/dist/src/modules/auth/components/AuthProvider.js.map +1 -1
- package/dist/src/modules/auth/components/AuthProvider.mjs +22 -43
- package/dist/src/modules/auth/components/AuthProvider.mjs.map +1 -1
- package/dist/src/modules/auth/hooks/useAuth.d.mts.map +1 -1
- package/dist/src/modules/auth/hooks/useAuth.d.ts.map +1 -1
- package/dist/src/modules/auth/hooks/useAuth.js +5 -3
- package/dist/src/modules/auth/hooks/useAuth.js.map +1 -1
- package/dist/src/modules/auth/hooks/useAuth.mjs +3 -1
- package/dist/src/modules/auth/hooks/useAuth.mjs.map +1 -1
- package/dist/src/modules/auth/hooks/useAuthAdmin.d.mts +10 -19
- package/dist/src/modules/auth/hooks/useAuthAdmin.d.mts.map +1 -1
- package/dist/src/modules/auth/hooks/useAuthAdmin.d.ts +10 -19
- package/dist/src/modules/auth/hooks/useAuthAdmin.d.ts.map +1 -1
- package/dist/src/modules/auth/hooks/useAuthAdmin.js +20 -12
- package/dist/src/modules/auth/hooks/useAuthAdmin.js.map +1 -1
- package/dist/src/modules/auth/hooks/useAuthAdmin.mjs +14 -6
- package/dist/src/modules/auth/hooks/useAuthAdmin.mjs.map +1 -1
- package/dist/src/modules/auth/hooks/useAuthClient.d.mts +707 -0
- package/dist/src/modules/auth/hooks/useAuthClient.d.mts.map +1 -0
- package/dist/src/modules/auth/hooks/useAuthClient.d.ts +707 -0
- package/dist/src/modules/auth/hooks/useAuthClient.d.ts.map +1 -0
- package/dist/src/modules/auth/hooks/useAuthClient.js +12 -0
- package/dist/src/modules/auth/hooks/useAuthClient.js.map +1 -0
- package/dist/src/modules/auth/hooks/useAuthClient.mjs +11 -0
- package/dist/src/modules/auth/hooks/useAuthClient.mjs.map +1 -0
- package/dist/src/modules/auth/hooks/useMemberInvite.js +3 -2
- package/dist/src/modules/auth/hooks/useMemberInvite.js.map +1 -1
- package/dist/src/modules/auth/hooks/useMemberInvite.mjs +2 -1
- package/dist/src/modules/auth/hooks/useMemberInvite.mjs.map +1 -1
- package/dist/src/modules/auth/hooks/useOrganizationAccess.d.mts +1 -1
- package/dist/src/modules/auth/hooks/useOrganizationAccess.d.ts +1 -1
- package/dist/src/modules/auth/hooks/useSession.d.mts +4 -37
- package/dist/src/modules/auth/hooks/useSession.d.mts.map +1 -1
- package/dist/src/modules/auth/hooks/useSession.d.ts +4 -37
- package/dist/src/modules/auth/hooks/useSession.d.ts.map +1 -1
- package/dist/src/modules/auth/hooks/useSession.js +3 -2
- package/dist/src/modules/auth/hooks/useSession.js.map +1 -1
- package/dist/src/modules/auth/hooks/useSession.mjs +3 -2
- package/dist/src/modules/auth/hooks/useSession.mjs.map +1 -1
- package/dist/src/modules/billing/components/BillingProvider.d.mts +1 -1
- package/dist/src/modules/billing/components/BillingProvider.d.mts.map +1 -1
- package/dist/src/modules/billing/components/BillingProvider.d.ts +1 -1
- package/dist/src/modules/billing/components/BillingProvider.d.ts.map +1 -1
- package/dist/src/modules/file/hooks/useS3Upload.d.mts +15 -2
- package/dist/src/modules/file/hooks/useS3Upload.d.mts.map +1 -1
- package/dist/src/modules/file/hooks/useS3Upload.d.ts +15 -2
- package/dist/src/modules/file/hooks/useS3Upload.d.ts.map +1 -1
- package/dist/src/modules/file/hooks/useS3Upload.js +29 -4
- package/dist/src/modules/file/hooks/useS3Upload.js.map +1 -1
- package/dist/src/modules/file/hooks/useS3Upload.mjs +29 -5
- package/dist/src/modules/file/hooks/useS3Upload.mjs.map +1 -1
- package/dist/src/modules/file/hooks/useUpload.d.mts +6 -4
- package/dist/src/modules/file/hooks/useUpload.d.mts.map +1 -1
- package/dist/src/modules/file/hooks/useUpload.d.ts +6 -4
- package/dist/src/modules/file/hooks/useUpload.d.ts.map +1 -1
- package/dist/src/modules/file/hooks/useUpload.js +10 -7
- package/dist/src/modules/file/hooks/useUpload.js.map +1 -1
- package/dist/src/modules/file/hooks/useUpload.mjs +10 -7
- package/dist/src/modules/file/hooks/useUpload.mjs.map +1 -1
- package/dist/src/modules/table/hooks/useQueryWithParams.d.mts +2 -2
- package/dist/src/modules/table/hooks/useQueryWithParams.d.mts.map +1 -1
- package/dist/src/modules/table/hooks/useQueryWithParams.d.ts +2 -2
- package/dist/src/modules/table/hooks/useQueryWithParams.d.ts.map +1 -1
- package/dist/src/modules/table/hooks/useQueryWithParams.js.map +1 -1
- package/dist/src/modules/table/hooks/useQueryWithParams.mjs.map +1 -1
- package/dist/src/modules/table/hooks/useTableQueryParams.d.mts +7 -0
- package/dist/src/modules/table/hooks/useTableQueryParams.d.mts.map +1 -0
- package/dist/src/modules/table/hooks/useTableQueryParams.d.ts +7 -0
- package/dist/src/modules/table/hooks/useTableQueryParams.d.ts.map +1 -0
- package/dist/src/modules/table/hooks/useTableQueryParams.js +95 -0
- package/dist/src/modules/table/hooks/useTableQueryParams.js.map +1 -0
- package/dist/src/modules/table/hooks/useTableQueryParams.mjs +94 -0
- package/dist/src/modules/table/hooks/useTableQueryParams.mjs.map +1 -0
- package/dist/src/modules/table/queryParams.d.mts +34 -0
- package/dist/src/modules/table/queryParams.d.mts.map +1 -0
- package/dist/src/modules/table/queryParams.d.ts +34 -0
- package/dist/src/modules/table/queryParams.d.ts.map +1 -0
- package/dist/src/modules/table/{hooks/useNuqsQueryParams.js → queryParams.js} +14 -130
- package/dist/src/modules/table/queryParams.js.map +1 -0
- package/dist/src/modules/table/{hooks/useNuqsQueryParams.mjs → queryParams.mjs} +10 -130
- package/dist/src/modules/table/queryParams.mjs.map +1 -0
- package/dist/src/utils/date.d.mts +1 -1
- package/package.json +24 -6
- package/dist/src/modules/table/hooks/useDateRangeFilter.d.mts +0 -34
- package/dist/src/modules/table/hooks/useDateRangeFilter.d.mts.map +0 -1
- package/dist/src/modules/table/hooks/useDateRangeFilter.d.ts +0 -34
- package/dist/src/modules/table/hooks/useDateRangeFilter.d.ts.map +0 -1
- package/dist/src/modules/table/hooks/useDateRangeFilter.js +0 -30
- package/dist/src/modules/table/hooks/useDateRangeFilter.js.map +0 -1
- package/dist/src/modules/table/hooks/useDateRangeFilter.mjs +0 -29
- package/dist/src/modules/table/hooks/useDateRangeFilter.mjs.map +0 -1
- package/dist/src/modules/table/hooks/useNuqsQueryParams.d.mts +0 -34
- package/dist/src/modules/table/hooks/useNuqsQueryParams.d.mts.map +0 -1
- package/dist/src/modules/table/hooks/useNuqsQueryParams.d.ts +0 -34
- package/dist/src/modules/table/hooks/useNuqsQueryParams.d.ts.map +0 -1
- package/dist/src/modules/table/hooks/useNuqsQueryParams.js.map +0 -1
- package/dist/src/modules/table/hooks/useNuqsQueryParams.mjs.map +0 -1
- package/dist/src/modules/table/hooks/useNuqsTable.d.mts +0 -46
- package/dist/src/modules/table/hooks/useNuqsTable.d.mts.map +0 -1
- package/dist/src/modules/table/hooks/useNuqsTable.d.ts +0 -46
- package/dist/src/modules/table/hooks/useNuqsTable.d.ts.map +0 -1
- package/dist/src/modules/table/hooks/useNuqsTable.js +0 -58
- package/dist/src/modules/table/hooks/useNuqsTable.js.map +0 -1
- package/dist/src/modules/table/hooks/useNuqsTable.mjs +0 -58
- package/dist/src/modules/table/hooks/useNuqsTable.mjs.map +0 -1
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { M5KAuthClient } from "../auth.client.mjs";
|
|
2
2
|
import * as _$_tanstack_react_query0 from "@tanstack/react-query";
|
|
3
3
|
import { AnyUseMutationOptions, QueryClient, UseQueryOptions } from "@tanstack/react-query";
|
|
4
4
|
import { QueryFilters } from "@m5kdev/commons/modules/schemas/query.schema";
|
|
5
|
-
import * as _$better_auth_plugins0 from "better-auth/plugins";
|
|
6
5
|
|
|
7
6
|
//#region src/modules/auth/hooks/useAuthAdmin.d.ts
|
|
8
|
-
type ListUsersArgs = Parameters<
|
|
9
|
-
type ListUsersResult = Awaited<ReturnType<
|
|
7
|
+
type ListUsersArgs = Parameters<M5KAuthClient["admin"]["listUsers"]>;
|
|
8
|
+
type ListUsersResult = Awaited<ReturnType<M5KAuthClient["admin"]["listUsers"]>>;
|
|
10
9
|
/**
|
|
11
10
|
* Data shape returned from Better Auth `admin.listUsers` (tRPC-style query data).
|
|
12
11
|
*/
|
|
13
12
|
type ListUsersQueryData = NonNullable<ListUsersResult["data"]>;
|
|
14
13
|
declare const AUTH_ADMIN_LIST_USERS_KEY: "auth-admin-list-users";
|
|
15
14
|
/**
|
|
16
|
-
* Input aligned with `useQueryWithParams`
|
|
15
|
+
* Input aligned with `useQueryWithParams` table state (page, limit, sort, order, q, filters).
|
|
17
16
|
* Maps to Better Auth `listUsers` query payload.
|
|
18
17
|
*/
|
|
19
|
-
interface
|
|
18
|
+
interface ListUsersQueryInput {
|
|
20
19
|
page: number;
|
|
21
20
|
limit: number;
|
|
22
21
|
sort?: string;
|
|
@@ -27,23 +26,15 @@ interface ListUsersNuqsInput {
|
|
|
27
26
|
/**
|
|
28
27
|
* Query key factory (tRPC-style). Omit input to match all list-users queries for invalidation.
|
|
29
28
|
*/
|
|
30
|
-
declare function listUsersQueryKey(input?:
|
|
29
|
+
declare function listUsersQueryKey(input?: ListUsersQueryInput): readonly unknown[];
|
|
31
30
|
/**
|
|
32
|
-
* Query options factory for use with `useQuery`,
|
|
31
|
+
* Query options factory for use with `useQuery`, table hooks, `useQueryWithParams`, or `queryClient.fetchQuery`.
|
|
33
32
|
* Signature mirrors tRPC `procedure.queryOptions(input, opts?)`.
|
|
34
33
|
*/
|
|
35
|
-
declare function listUsersQueryOptions(input:
|
|
34
|
+
declare function listUsersQueryOptions(input: ListUsersQueryInput, opts?: Omit<UseQueryOptions<ListUsersQueryData, Error, ListUsersQueryData, readonly unknown[]>, "queryKey" | "queryFn">): UseQueryOptions<ListUsersQueryData, Error, ListUsersQueryData, readonly unknown[]>;
|
|
36
35
|
declare function invalidateListUsersQuery(queryClient: QueryClient): Promise<void>;
|
|
37
36
|
declare function useInvalidateListUsers(...args: ListUsersArgs): () => Promise<void>;
|
|
38
|
-
declare function useListUsers(...args: ListUsersArgs): _$_tanstack_react_query0.UseQueryResult<
|
|
39
|
-
users: _$better_auth_plugins0.UserWithRole[];
|
|
40
|
-
total: number;
|
|
41
|
-
limit: number | undefined;
|
|
42
|
-
offset: number | undefined;
|
|
43
|
-
} | {
|
|
44
|
-
users: never[];
|
|
45
|
-
total: number;
|
|
46
|
-
}>, Error>;
|
|
37
|
+
declare function useListUsers(...args: ListUsersArgs): _$_tanstack_react_query0.UseQueryResult<any, Error>;
|
|
47
38
|
declare function useRemoveUser(options: AnyUseMutationOptions): _$_tanstack_react_query0.UseMutationResult<any, any, any, any>;
|
|
48
39
|
declare function useUpdateUser(options: AnyUseMutationOptions): _$_tanstack_react_query0.UseMutationResult<any, any, any, any>;
|
|
49
40
|
declare function useBanUser(options: AnyUseMutationOptions): _$_tanstack_react_query0.UseMutationResult<any, any, any, any>;
|
|
@@ -51,5 +42,5 @@ declare function useUnbanUser(options: AnyUseMutationOptions): _$_tanstack_react
|
|
|
51
42
|
declare function useImpersonateUser(options: AnyUseMutationOptions): _$_tanstack_react_query0.UseMutationResult<any, any, any, any>;
|
|
52
43
|
declare function useStopImpersonating(options: AnyUseMutationOptions): _$_tanstack_react_query0.UseMutationResult<any, any, any, any>;
|
|
53
44
|
//#endregion
|
|
54
|
-
export { AUTH_ADMIN_LIST_USERS_KEY,
|
|
45
|
+
export { AUTH_ADMIN_LIST_USERS_KEY, ListUsersQueryData, ListUsersQueryInput, invalidateListUsersQuery, listUsersQueryKey, listUsersQueryOptions, useBanUser, useImpersonateUser, useInvalidateListUsers, useListUsers, useRemoveUser, useStopImpersonating, useUnbanUser, useUpdateUser };
|
|
55
46
|
//# sourceMappingURL=useAuthAdmin.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuthAdmin.d.mts","names":[],"sources":["../../../../../src/modules/auth/hooks/useAuthAdmin.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useAuthAdmin.d.mts","names":[],"sources":["../../../../../src/modules/auth/hooks/useAuthAdmin.ts"],"mappings":";;;;;;KAaK,aAAA,G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as _$_tanstack_react_query0 from "@tanstack/react-query";
|
|
3
3
|
import { AnyUseMutationOptions, QueryClient, UseQueryOptions } from "@tanstack/react-query";
|
|
4
|
-
import * as _$better_auth_plugins0 from "better-auth/plugins";
|
|
5
4
|
import { QueryFilters } from "@m5kdev/commons/modules/schemas/query.schema";
|
|
6
5
|
|
|
7
6
|
//#region src/modules/auth/hooks/useAuthAdmin.d.ts
|
|
8
|
-
type ListUsersArgs = Parameters<
|
|
9
|
-
type ListUsersResult = Awaited<ReturnType<
|
|
7
|
+
type ListUsersArgs = Parameters<M5KAuthClient["admin"]["listUsers"]>;
|
|
8
|
+
type ListUsersResult = Awaited<ReturnType<M5KAuthClient["admin"]["listUsers"]>>;
|
|
10
9
|
/**
|
|
11
10
|
* Data shape returned from Better Auth `admin.listUsers` (tRPC-style query data).
|
|
12
11
|
*/
|
|
13
12
|
type ListUsersQueryData = NonNullable<ListUsersResult["data"]>;
|
|
14
13
|
declare const AUTH_ADMIN_LIST_USERS_KEY: "auth-admin-list-users";
|
|
15
14
|
/**
|
|
16
|
-
* Input aligned with `useQueryWithParams`
|
|
15
|
+
* Input aligned with `useQueryWithParams` table state (page, limit, sort, order, q, filters).
|
|
17
16
|
* Maps to Better Auth `listUsers` query payload.
|
|
18
17
|
*/
|
|
19
|
-
interface
|
|
18
|
+
interface ListUsersQueryInput {
|
|
20
19
|
page: number;
|
|
21
20
|
limit: number;
|
|
22
21
|
sort?: string;
|
|
@@ -27,23 +26,15 @@ interface ListUsersNuqsInput {
|
|
|
27
26
|
/**
|
|
28
27
|
* Query key factory (tRPC-style). Omit input to match all list-users queries for invalidation.
|
|
29
28
|
*/
|
|
30
|
-
declare function listUsersQueryKey(input?:
|
|
29
|
+
declare function listUsersQueryKey(input?: ListUsersQueryInput): readonly unknown[];
|
|
31
30
|
/**
|
|
32
|
-
* Query options factory for use with `useQuery`,
|
|
31
|
+
* Query options factory for use with `useQuery`, table hooks, `useQueryWithParams`, or `queryClient.fetchQuery`.
|
|
33
32
|
* Signature mirrors tRPC `procedure.queryOptions(input, opts?)`.
|
|
34
33
|
*/
|
|
35
|
-
declare function listUsersQueryOptions(input:
|
|
34
|
+
declare function listUsersQueryOptions(input: ListUsersQueryInput, opts?: Omit<UseQueryOptions<ListUsersQueryData, Error, ListUsersQueryData, readonly unknown[]>, "queryKey" | "queryFn">): UseQueryOptions<ListUsersQueryData, Error, ListUsersQueryData, readonly unknown[]>;
|
|
36
35
|
declare function invalidateListUsersQuery(queryClient: QueryClient): Promise<void>;
|
|
37
36
|
declare function useInvalidateListUsers(...args: ListUsersArgs): () => Promise<void>;
|
|
38
|
-
declare function useListUsers(...args: ListUsersArgs): _$_tanstack_react_query0.UseQueryResult<
|
|
39
|
-
users: _$better_auth_plugins0.UserWithRole[];
|
|
40
|
-
total: number;
|
|
41
|
-
limit: number | undefined;
|
|
42
|
-
offset: number | undefined;
|
|
43
|
-
} | {
|
|
44
|
-
users: never[];
|
|
45
|
-
total: number;
|
|
46
|
-
}>, Error>;
|
|
37
|
+
declare function useListUsers(...args: ListUsersArgs): _$_tanstack_react_query0.UseQueryResult<any, Error>;
|
|
47
38
|
declare function useRemoveUser(options: AnyUseMutationOptions): _$_tanstack_react_query0.UseMutationResult<any, any, any, any>;
|
|
48
39
|
declare function useUpdateUser(options: AnyUseMutationOptions): _$_tanstack_react_query0.UseMutationResult<any, any, any, any>;
|
|
49
40
|
declare function useBanUser(options: AnyUseMutationOptions): _$_tanstack_react_query0.UseMutationResult<any, any, any, any>;
|
|
@@ -51,5 +42,5 @@ declare function useUnbanUser(options: AnyUseMutationOptions): _$_tanstack_react
|
|
|
51
42
|
declare function useImpersonateUser(options: AnyUseMutationOptions): _$_tanstack_react_query0.UseMutationResult<any, any, any, any>;
|
|
52
43
|
declare function useStopImpersonating(options: AnyUseMutationOptions): _$_tanstack_react_query0.UseMutationResult<any, any, any, any>;
|
|
53
44
|
//#endregion
|
|
54
|
-
export { AUTH_ADMIN_LIST_USERS_KEY,
|
|
45
|
+
export { AUTH_ADMIN_LIST_USERS_KEY, ListUsersQueryData, ListUsersQueryInput, invalidateListUsersQuery, listUsersQueryKey, listUsersQueryOptions, useBanUser, useImpersonateUser, useInvalidateListUsers, useListUsers, useRemoveUser, useStopImpersonating, useUnbanUser, useUpdateUser };
|
|
55
46
|
//# sourceMappingURL=useAuthAdmin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuthAdmin.d.ts","names":[],"sources":["../../../../../src/modules/auth/hooks/useAuthAdmin.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useAuthAdmin.d.ts","names":[],"sources":["../../../../../src/modules/auth/hooks/useAuthAdmin.ts"],"mappings":";;;;;;KAaK,aAAA,GAAgB,UAAA,CAAW,aAAA;AAAA,KAE3B,eAAA,GAAkB,OAAA,CAAQ,UAAA,CAAW,aAAA;;;AANI;KAWlC,kBAAA,GAAqB,WAAA,CAAY,eAAA;AAAA,cAEhC,yBAAA;;;AAT6B;;UAezB,mBAAA;EACf,IAAA;EACA,KAAA;EACA,IAAA;EACA,KAAA;EACA,CAAA;EACA,OAAA,GAAU,YAAA;AAAA;;;;iBAuBI,iBAAA,CAAkB,KAAA,GAAQ,mBAAA;;;;;iBAW1B,qBAAA,CACd,KAAA,EAAO,mBAAA,EACP,IAAA,GAAO,IAAA,CACL,eAAA,CAAgB,kBAAA,EAAoB,KAAA,EAAO,kBAAA,iDAG5C,eAAA,CAAgB,kBAAA,EAAoB,KAAA,EAAO,kBAAA;AAAA,iBAgB9B,wBAAA,CAAyB,WAAA,EAAa,WAAA,GAAc,OAAA;AAAA,iBAIpD,sBAAA,CAAA,GAA0B,IAAA,EAAM,aAAA,SAAa,OAAA;AAAA,iBAK7C,YAAA,CAAA,GAAgB,IAAA,EAAM,aAAA,GAAa,wBAAA,CAAA,cAAA,MAAA,KAAA;AAAA,iBAYnC,aAAA,CAAc,OAAA,EAAS,qBAAA,GAAqB,wBAAA,CAAA,iBAAA;AAAA,iBAS5C,aAAA,CAAc,OAAA,EAAS,qBAAA,GAAqB,wBAAA,CAAA,iBAAA;AAAA,iBAS5C,UAAA,CAAW,OAAA,EAAS,qBAAA,GAAqB,wBAAA,CAAA,iBAAA;AAAA,iBASzC,YAAA,CAAa,OAAA,EAAS,qBAAA,GAAqB,wBAAA,CAAA,iBAAA;AAAA,iBAS3C,kBAAA,CAAmB,OAAA,EAAS,qBAAA,GAAqB,wBAAA,CAAA,iBAAA;AAAA,iBASjD,oBAAA,CAAqB,OAAA,EAAS,qBAAA,GAAqB,wBAAA,CAAA,iBAAA"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_src_modules_auth_auth_lib = require("../auth.lib.js");
|
|
3
|
+
const require_src_modules_auth_hooks_useAuthClient = require("./useAuthClient.js");
|
|
3
4
|
let _tanstack_react_query = require("@tanstack/react-query");
|
|
4
5
|
//#region src/modules/auth/hooks/useAuthAdmin.ts
|
|
5
6
|
const AUTH_ADMIN_LIST_USERS_KEY = "auth-admin-list-users";
|
|
6
|
-
function
|
|
7
|
+
function mapQueryInputToListUsersArg(input) {
|
|
7
8
|
const page = Math.max(1, input.page);
|
|
8
9
|
return { query: {
|
|
9
10
|
searchField: "name",
|
|
@@ -20,18 +21,18 @@ function mapNuqsInputToListUsersArg(input) {
|
|
|
20
21
|
*/
|
|
21
22
|
function listUsersQueryKey(input) {
|
|
22
23
|
if (input === void 0) return [AUTH_ADMIN_LIST_USERS_KEY];
|
|
23
|
-
return [AUTH_ADMIN_LIST_USERS_KEY,
|
|
24
|
+
return [AUTH_ADMIN_LIST_USERS_KEY, mapQueryInputToListUsersArg(input)];
|
|
24
25
|
}
|
|
25
26
|
/**
|
|
26
|
-
* Query options factory for use with `useQuery`,
|
|
27
|
+
* Query options factory for use with `useQuery`, table hooks, `useQueryWithParams`, or `queryClient.fetchQuery`.
|
|
27
28
|
* Signature mirrors tRPC `procedure.queryOptions(input, opts?)`.
|
|
28
29
|
*/
|
|
29
30
|
function listUsersQueryOptions(input, opts) {
|
|
30
|
-
const arg =
|
|
31
|
+
const arg = mapQueryInputToListUsersArg(input);
|
|
31
32
|
return {
|
|
32
33
|
queryKey: listUsersQueryKey(input),
|
|
33
34
|
queryFn: async () => {
|
|
34
|
-
const { data, error } = await require_src_modules_auth_auth_lib.
|
|
35
|
+
const { data, error } = await require_src_modules_auth_auth_lib.getAuthClient().admin.listUsers(arg);
|
|
35
36
|
if (error) return Promise.reject(error);
|
|
36
37
|
if (data == null) return Promise.reject(/* @__PURE__ */ new Error("listUsers returned no data"));
|
|
37
38
|
return data;
|
|
@@ -47,48 +48,55 @@ function useInvalidateListUsers(...args) {
|
|
|
47
48
|
return () => queryClient.invalidateQueries({ queryKey: [AUTH_ADMIN_LIST_USERS_KEY, ...args] });
|
|
48
49
|
}
|
|
49
50
|
function useListUsers(...args) {
|
|
51
|
+
const authClient = require_src_modules_auth_hooks_useAuthClient.useAuthClient();
|
|
50
52
|
return (0, _tanstack_react_query.useQuery)({
|
|
51
53
|
queryKey: [AUTH_ADMIN_LIST_USERS_KEY, ...args],
|
|
52
54
|
queryFn: async () => {
|
|
53
|
-
const { data, error } = await
|
|
55
|
+
const { data, error } = await authClient.admin.listUsers(...args);
|
|
54
56
|
if (error) return Promise.reject(error);
|
|
55
57
|
return data;
|
|
56
58
|
}
|
|
57
59
|
});
|
|
58
60
|
}
|
|
59
61
|
function useRemoveUser(options) {
|
|
62
|
+
const authClient = require_src_modules_auth_hooks_useAuthClient.useAuthClient();
|
|
60
63
|
return (0, _tanstack_react_query.useMutation)({
|
|
61
|
-
mutationFn: (...args) =>
|
|
64
|
+
mutationFn: (...args) => authClient.admin.removeUser(...args),
|
|
62
65
|
...options
|
|
63
66
|
});
|
|
64
67
|
}
|
|
65
68
|
function useUpdateUser(options) {
|
|
69
|
+
const authClient = require_src_modules_auth_hooks_useAuthClient.useAuthClient();
|
|
66
70
|
return (0, _tanstack_react_query.useMutation)({
|
|
67
|
-
mutationFn: (...args) =>
|
|
71
|
+
mutationFn: (...args) => authClient.admin.updateUser(...args),
|
|
68
72
|
...options
|
|
69
73
|
});
|
|
70
74
|
}
|
|
71
75
|
function useBanUser(options) {
|
|
76
|
+
const authClient = require_src_modules_auth_hooks_useAuthClient.useAuthClient();
|
|
72
77
|
return (0, _tanstack_react_query.useMutation)({
|
|
73
|
-
mutationFn: (...args) =>
|
|
78
|
+
mutationFn: (...args) => authClient.admin.banUser(...args),
|
|
74
79
|
...options
|
|
75
80
|
});
|
|
76
81
|
}
|
|
77
82
|
function useUnbanUser(options) {
|
|
83
|
+
const authClient = require_src_modules_auth_hooks_useAuthClient.useAuthClient();
|
|
78
84
|
return (0, _tanstack_react_query.useMutation)({
|
|
79
|
-
mutationFn: (...args) =>
|
|
85
|
+
mutationFn: (...args) => authClient.admin.unbanUser(...args),
|
|
80
86
|
...options
|
|
81
87
|
});
|
|
82
88
|
}
|
|
83
89
|
function useImpersonateUser(options) {
|
|
90
|
+
const authClient = require_src_modules_auth_hooks_useAuthClient.useAuthClient();
|
|
84
91
|
return (0, _tanstack_react_query.useMutation)({
|
|
85
|
-
mutationFn: (...args) =>
|
|
92
|
+
mutationFn: (...args) => authClient.admin.impersonateUser(...args),
|
|
86
93
|
...options
|
|
87
94
|
});
|
|
88
95
|
}
|
|
89
96
|
function useStopImpersonating(options) {
|
|
97
|
+
const authClient = require_src_modules_auth_hooks_useAuthClient.useAuthClient();
|
|
90
98
|
return (0, _tanstack_react_query.useMutation)({
|
|
91
|
-
mutationFn: () =>
|
|
99
|
+
mutationFn: () => authClient.admin.stopImpersonating(),
|
|
92
100
|
...options
|
|
93
101
|
});
|
|
94
102
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuthAdmin.js","names":["
|
|
1
|
+
{"version":3,"file":"useAuthAdmin.js","names":["getAuthClient","useAuthClient"],"sources":["../../../../../src/modules/auth/hooks/useAuthAdmin.ts"],"sourcesContent":["import type { QueryFilters } from \"@m5kdev/commons/modules/schemas/query.schema\";\r\nimport {\r\n type AnyUseMutationOptions,\r\n type QueryClient,\r\n type UseQueryOptions,\r\n useMutation,\r\n useQuery,\r\n useQueryClient,\r\n} from \"@tanstack/react-query\";\r\nimport type { AuthClient } from \"../auth.lib\";\r\nimport { getAuthClient } from \"../auth.lib\";\r\nimport { useAuthClient } from \"./useAuthClient\";\r\n\r\ntype ListUsersArgs = Parameters<AuthClient[\"admin\"][\"listUsers\"]>;\r\n\r\ntype ListUsersResult = Awaited<ReturnType<AuthClient[\"admin\"][\"listUsers\"]>>;\r\n\r\n/**\r\n * Data shape returned from Better Auth `admin.listUsers` (tRPC-style query data).\r\n */\r\nexport type ListUsersQueryData = NonNullable<ListUsersResult[\"data\"]>;\r\n\r\nexport const AUTH_ADMIN_LIST_USERS_KEY = \"auth-admin-list-users\" as const;\r\n\r\n/**\r\n * Input aligned with `useQueryWithParams` table state (page, limit, sort, order, q, filters).\r\n * Maps to Better Auth `listUsers` query payload.\r\n */\r\nexport interface ListUsersQueryInput {\r\n page: number;\r\n limit: number;\r\n sort?: string;\r\n order?: \"asc\" | \"desc\" | null;\r\n q?: string;\r\n filters?: QueryFilters;\r\n}\r\n\r\ntype ListUsersFirstArg = ListUsersArgs[0];\r\n\r\nfunction mapQueryInputToListUsersArg(input: ListUsersQueryInput): ListUsersFirstArg {\r\n const page = Math.max(1, input.page);\r\n return {\r\n query: {\r\n searchField: \"name\",\r\n searchOperator: \"contains\",\r\n searchValue: input.q?.trim() ?? \"\",\r\n limit: input.limit,\r\n offset: (page - 1) * input.limit,\r\n sortBy: (input.sort ?? \"createdAt\") as \"name\" | \"email\" | \"role\" | \"createdAt\",\r\n sortDirection: (input.order ?? \"desc\") as \"asc\" | \"desc\",\r\n },\r\n };\r\n}\r\n\r\n/**\r\n * Query key factory (tRPC-style). Omit input to match all list-users queries for invalidation.\r\n */\r\nexport function listUsersQueryKey(input?: ListUsersQueryInput): readonly unknown[] {\r\n if (input === undefined) {\r\n return [AUTH_ADMIN_LIST_USERS_KEY] as const;\r\n }\r\n return [AUTH_ADMIN_LIST_USERS_KEY, mapQueryInputToListUsersArg(input)] as const;\r\n}\r\n\r\n/**\r\n * Query options factory for use with `useQuery`, table hooks, `useQueryWithParams`, or `queryClient.fetchQuery`.\r\n * Signature mirrors tRPC `procedure.queryOptions(input, opts?)`.\r\n */\r\nexport function listUsersQueryOptions(\r\n input: ListUsersQueryInput,\r\n opts?: Omit<\r\n UseQueryOptions<ListUsersQueryData, Error, ListUsersQueryData, readonly unknown[]>,\r\n \"queryKey\" | \"queryFn\"\r\n >\r\n): UseQueryOptions<ListUsersQueryData, Error, ListUsersQueryData, readonly unknown[]> {\r\n const arg = mapQueryInputToListUsersArg(input);\r\n return {\r\n queryKey: listUsersQueryKey(input),\r\n queryFn: async (): Promise<ListUsersQueryData> => {\r\n const { data, error } = await getAuthClient().admin.listUsers(arg);\r\n if (error) return Promise.reject(error);\r\n if (data == null) {\r\n return Promise.reject(new Error(\"listUsers returned no data\"));\r\n }\r\n return data;\r\n },\r\n ...opts,\r\n };\r\n}\r\n\r\nexport function invalidateListUsersQuery(queryClient: QueryClient): Promise<void> {\r\n return queryClient.invalidateQueries({ queryKey: [AUTH_ADMIN_LIST_USERS_KEY] });\r\n}\r\n\r\nexport function useInvalidateListUsers(...args: ListUsersArgs) {\r\n const queryClient = useQueryClient();\r\n return () => queryClient.invalidateQueries({ queryKey: [AUTH_ADMIN_LIST_USERS_KEY, ...args] });\r\n}\r\n\r\nexport function useListUsers(...args: ListUsersArgs) {\r\n const authClient = useAuthClient();\r\n return useQuery({\r\n queryKey: [AUTH_ADMIN_LIST_USERS_KEY, ...args],\r\n queryFn: async () => {\r\n const { data, error } = await authClient.admin.listUsers(...args);\r\n if (error) return Promise.reject(error);\r\n return data;\r\n },\r\n });\r\n}\r\n\r\nexport function useRemoveUser(options: AnyUseMutationOptions) {\r\n const authClient = useAuthClient();\r\n return useMutation({\r\n mutationFn: (...args: Parameters<typeof authClient.admin.removeUser>) =>\r\n authClient.admin.removeUser(...args),\r\n ...options,\r\n });\r\n}\r\n\r\nexport function useUpdateUser(options: AnyUseMutationOptions) {\r\n const authClient = useAuthClient();\r\n return useMutation({\r\n mutationFn: (...args: Parameters<typeof authClient.admin.updateUser>) =>\r\n authClient.admin.updateUser(...args),\r\n ...options,\r\n });\r\n}\r\n\r\nexport function useBanUser(options: AnyUseMutationOptions) {\r\n const authClient = useAuthClient();\r\n return useMutation({\r\n mutationFn: (...args: Parameters<typeof authClient.admin.banUser>) =>\r\n authClient.admin.banUser(...args),\r\n ...options,\r\n });\r\n}\r\n\r\nexport function useUnbanUser(options: AnyUseMutationOptions) {\r\n const authClient = useAuthClient();\r\n return useMutation({\r\n mutationFn: (...args: Parameters<typeof authClient.admin.unbanUser>) =>\r\n authClient.admin.unbanUser(...args),\r\n ...options,\r\n });\r\n}\r\n\r\nexport function useImpersonateUser(options: AnyUseMutationOptions) {\r\n const authClient = useAuthClient();\r\n return useMutation({\r\n mutationFn: (...args: Parameters<typeof authClient.admin.impersonateUser>) =>\r\n authClient.admin.impersonateUser(...args),\r\n ...options,\r\n });\r\n}\r\n\r\nexport function useStopImpersonating(options: AnyUseMutationOptions) {\r\n const authClient = useAuthClient();\r\n return useMutation({\r\n mutationFn: () => authClient.admin.stopImpersonating(),\r\n ...options,\r\n });\r\n}\r\n"],"mappings":";;;;;AAsBA,MAAa,4BAA4B;AAiBzC,SAAS,4BAA4B,OAA+C;CAClF,MAAM,OAAO,KAAK,IAAI,GAAG,MAAM,KAAK;AACpC,QAAO,EACL,OAAO;EACL,aAAa;EACb,gBAAgB;EAChB,aAAa,MAAM,GAAG,MAAM,IAAI;EAChC,OAAO,MAAM;EACb,SAAS,OAAO,KAAK,MAAM;EAC3B,QAAS,MAAM,QAAQ;EACvB,eAAgB,MAAM,SAAS;EAChC,EACF;;;;;AAMH,SAAgB,kBAAkB,OAAiD;AACjF,KAAI,UAAU,KAAA,EACZ,QAAO,CA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a,GAAG,SACd,WAAW,MAAM,WAAW,GAAG,KAAK;EACtC,GAAG;EACJ,CAAC;;AAGJ,SAAgB,WAAW,SAAgC;CACzD,MAAM,aAAaA,6CAAAA,eAAe;AAClC,SAAA,GAAA,sBAAA,aAAmB;EACjB,aAAa,GAAG,SACd,WAAW,MAAM,QAAQ,GAAG,KAAK;EACnC,GAAG;EACJ,CAAC;;AAGJ,SAAgB,aAAa,SAAgC;CAC3D,MAAM,aAAaA,6CAAAA,eAAe;AAClC,SAAA,GAAA,sBAAA,aAAmB;EACjB,aAAa,GAAG,SACd,WAAW,MAAM,UAAU,GAAG,KAAK;EACrC,GAAG;EACJ,CAAC;;AAGJ,SAAgB,mBAAmB,SAAgC;CACjE,MAAM,aAAaA,6CAAAA,eAAe;AAClC,SAAA,GAAA,sBAAA,aAAmB;EACjB,aAAa,GAAG,SACd,WAAW,MAAM,gBAAgB,GAAG,KAAK;EAC3C,GAAG;EACJ,CAAC;;AAGJ,SAAgB,qBAAqB,SAAgC;CACnE,MAAM,aAAaA,6CAAAA,eAAe;AAClC,SAAA,GAAA,sBAAA,aAAmB;EACjB,kBAAkB,WAAW,MAAM,mBAAmB;EACtD,GAAG;EACJ,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getAuthClient } from "../auth.lib.mjs";
|
|
2
|
+
import { useAuthClient } from "./useAuthClient.mjs";
|
|
2
3
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
3
4
|
//#region src/modules/auth/hooks/useAuthAdmin.ts
|
|
4
5
|
const AUTH_ADMIN_LIST_USERS_KEY = "auth-admin-list-users";
|
|
5
|
-
function
|
|
6
|
+
function mapQueryInputToListUsersArg(input) {
|
|
6
7
|
const page = Math.max(1, input.page);
|
|
7
8
|
return { query: {
|
|
8
9
|
searchField: "name",
|
|
@@ -19,18 +20,18 @@ function mapNuqsInputToListUsersArg(input) {
|
|
|
19
20
|
*/
|
|
20
21
|
function listUsersQueryKey(input) {
|
|
21
22
|
if (input === void 0) return [AUTH_ADMIN_LIST_USERS_KEY];
|
|
22
|
-
return [AUTH_ADMIN_LIST_USERS_KEY,
|
|
23
|
+
return [AUTH_ADMIN_LIST_USERS_KEY, mapQueryInputToListUsersArg(input)];
|
|
23
24
|
}
|
|
24
25
|
/**
|
|
25
|
-
* Query options factory for use with `useQuery`,
|
|
26
|
+
* Query options factory for use with `useQuery`, table hooks, `useQueryWithParams`, or `queryClient.fetchQuery`.
|
|
26
27
|
* Signature mirrors tRPC `procedure.queryOptions(input, opts?)`.
|
|
27
28
|
*/
|
|
28
29
|
function listUsersQueryOptions(input, opts) {
|
|
29
|
-
const arg =
|
|
30
|
+
const arg = mapQueryInputToListUsersArg(input);
|
|
30
31
|
return {
|
|
31
32
|
queryKey: listUsersQueryKey(input),
|
|
32
33
|
queryFn: async () => {
|
|
33
|
-
const { data, error } = await
|
|
34
|
+
const { data, error } = await getAuthClient().admin.listUsers(arg);
|
|
34
35
|
if (error) return Promise.reject(error);
|
|
35
36
|
if (data == null) return Promise.reject(/* @__PURE__ */ new Error("listUsers returned no data"));
|
|
36
37
|
return data;
|
|
@@ -46,6 +47,7 @@ function useInvalidateListUsers(...args) {
|
|
|
46
47
|
return () => queryClient.invalidateQueries({ queryKey: [AUTH_ADMIN_LIST_USERS_KEY, ...args] });
|
|
47
48
|
}
|
|
48
49
|
function useListUsers(...args) {
|
|
50
|
+
const authClient = useAuthClient();
|
|
49
51
|
return useQuery({
|
|
50
52
|
queryKey: [AUTH_ADMIN_LIST_USERS_KEY, ...args],
|
|
51
53
|
queryFn: async () => {
|
|
@@ -56,36 +58,42 @@ function useListUsers(...args) {
|
|
|
56
58
|
});
|
|
57
59
|
}
|
|
58
60
|
function useRemoveUser(options) {
|
|
61
|
+
const authClient = useAuthClient();
|
|
59
62
|
return useMutation({
|
|
60
63
|
mutationFn: (...args) => authClient.admin.removeUser(...args),
|
|
61
64
|
...options
|
|
62
65
|
});
|
|
63
66
|
}
|
|
64
67
|
function useUpdateUser(options) {
|
|
68
|
+
const authClient = useAuthClient();
|
|
65
69
|
return useMutation({
|
|
66
70
|
mutationFn: (...args) => authClient.admin.updateUser(...args),
|
|
67
71
|
...options
|
|
68
72
|
});
|
|
69
73
|
}
|
|
70
74
|
function useBanUser(options) {
|
|
75
|
+
const authClient = useAuthClient();
|
|
71
76
|
return useMutation({
|
|
72
77
|
mutationFn: (...args) => authClient.admin.banUser(...args),
|
|
73
78
|
...options
|
|
74
79
|
});
|
|
75
80
|
}
|
|
76
81
|
function useUnbanUser(options) {
|
|
82
|
+
const authClient = useAuthClient();
|
|
77
83
|
return useMutation({
|
|
78
84
|
mutationFn: (...args) => authClient.admin.unbanUser(...args),
|
|
79
85
|
...options
|
|
80
86
|
});
|
|
81
87
|
}
|
|
82
88
|
function useImpersonateUser(options) {
|
|
89
|
+
const authClient = useAuthClient();
|
|
83
90
|
return useMutation({
|
|
84
91
|
mutationFn: (...args) => authClient.admin.impersonateUser(...args),
|
|
85
92
|
...options
|
|
86
93
|
});
|
|
87
94
|
}
|
|
88
95
|
function useStopImpersonating(options) {
|
|
96
|
+
const authClient = useAuthClient();
|
|
89
97
|
return useMutation({
|
|
90
98
|
mutationFn: () => authClient.admin.stopImpersonating(),
|
|
91
99
|
...options
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuthAdmin.mjs","names":[],"sources":["../../../../../src/modules/auth/hooks/useAuthAdmin.ts"],"sourcesContent":["import type { QueryFilters } from \"@m5kdev/commons/modules/schemas/query.schema\";\r\nimport {\r\n type AnyUseMutationOptions,\r\n type QueryClient,\r\n type UseQueryOptions,\r\n useMutation,\r\n useQuery,\r\n useQueryClient,\r\n} from \"@tanstack/react-query\";\r\nimport {
|
|
1
|
+
{"version":3,"file":"useAuthAdmin.mjs","names":[],"sources":["../../../../../src/modules/auth/hooks/useAuthAdmin.ts"],"sourcesContent":["import type { QueryFilters } from \"@m5kdev/commons/modules/schemas/query.schema\";\r\nimport {\r\n type AnyUseMutationOptions,\r\n type QueryClient,\r\n type UseQueryOptions,\r\n useMutation,\r\n useQuery,\r\n useQueryClient,\r\n} from \"@tanstack/react-query\";\r\nimport type { AuthClient } from \"../auth.lib\";\r\nimport { getAuthClient } from \"../auth.lib\";\r\nimport { useAuthClient } from \"./useAuthClient\";\r\n\r\ntype ListUsersArgs = Parameters<AuthClient[\"admin\"][\"listUsers\"]>;\r\n\r\ntype ListUsersResult = Awaited<ReturnType<AuthClient[\"admin\"][\"listUsers\"]>>;\r\n\r\n/**\r\n * Data shape returned from Better Auth `admin.listUsers` (tRPC-style query data).\r\n */\r\nexport type ListUsersQueryData = NonNullable<ListUsersResult[\"data\"]>;\r\n\r\nexport const AUTH_ADMIN_LIST_USERS_KEY = \"auth-admin-list-users\" as const;\r\n\r\n/**\r\n * Input aligned with `useQueryWithParams` table state (page, limit, sort, order, q, filters).\r\n * Maps to Better Auth `listUsers` query payload.\r\n */\r\nexport interface ListUsersQueryInput {\r\n page: number;\r\n limit: number;\r\n sort?: string;\r\n order?: \"asc\" | \"desc\" | null;\r\n q?: string;\r\n filters?: QueryFilters;\r\n}\r\n\r\ntype ListUsersFirstArg = ListUsersArgs[0];\r\n\r\nfunction mapQueryInputToListUsersArg(input: ListUsersQueryInput): ListUsersFirstArg {\r\n const page = Math.max(1, input.page);\r\n return {\r\n query: {\r\n searchField: \"name\",\r\n searchOperator: \"contains\",\r\n searchValue: input.q?.trim() ?? \"\",\r\n limit: input.limit,\r\n offset: (page - 1) * input.limit,\r\n sortBy: (input.sort ?? \"createdAt\") as \"name\" | \"email\" | \"role\" | \"createdAt\",\r\n sortDirection: (input.order ?? \"desc\") as \"asc\" | \"desc\",\r\n },\r\n };\r\n}\r\n\r\n/**\r\n * Query key factory (tRPC-style). Omit input to match all list-users queries for invalidation.\r\n */\r\nexport function listUsersQueryKey(input?: ListUsersQueryInput): readonly unknown[] {\r\n if (input === undefined) {\r\n return [AUTH_ADMIN_LIST_USERS_KEY] as const;\r\n }\r\n return [AUTH_ADMIN_LIST_USERS_KEY, mapQueryInputToListUsersArg(input)] as const;\r\n}\r\n\r\n/**\r\n * Query options factory for use with `useQuery`, table hooks, `useQueryWithParams`, or `queryClient.fetchQuery`.\r\n * Signature mirrors tRPC `procedure.queryOptions(input, opts?)`.\r\n */\r\nexport function listUsersQueryOptions(\r\n input: ListUsersQueryInput,\r\n opts?: Omit<\r\n UseQueryOptions<ListUsersQueryData, Error, ListUsersQueryData, readonly unknown[]>,\r\n \"queryKey\" | \"queryFn\"\r\n >\r\n): UseQueryOptions<ListUsersQueryData, Error, ListUsersQueryData, readonly unknown[]> {\r\n const arg = mapQueryInputToListUsersArg(input);\r\n return {\r\n queryKey: listUsersQueryKey(input),\r\n queryFn: async (): Promise<ListUsersQueryData> => {\r\n const { data, error } = await getAuthClient().admin.listUsers(arg);\r\n if (error) return Promise.reject(error);\r\n if (data == null) {\r\n return Promise.reject(new Error(\"listUsers returned no data\"));\r\n }\r\n return data;\r\n },\r\n ...opts,\r\n };\r\n}\r\n\r\nexport function invalidateListUsersQuery(queryClient: QueryClient): Promise<void> {\r\n return queryClient.invalidateQueries({ queryKey: [AUTH_ADMIN_LIST_USERS_KEY] });\r\n}\r\n\r\nexport function useInvalidateListUsers(...args: ListUsersArgs) {\r\n const queryClient = useQueryClient();\r\n return () => queryClient.invalidateQueries({ queryKey: [AUTH_ADMIN_LIST_USERS_KEY, ...args] });\r\n}\r\n\r\nexport function useListUsers(...args: ListUsersArgs) {\r\n const authClient = useAuthClient();\r\n return useQuery({\r\n queryKey: [AUTH_ADMIN_LIST_USERS_KEY, ...args],\r\n queryFn: async () => {\r\n const { data, error } = await authClient.admin.listUsers(...args);\r\n if (error) return Promise.reject(error);\r\n return data;\r\n },\r\n });\r\n}\r\n\r\nexport function useRemoveUser(options: AnyUseMutationOptions) {\r\n const authClient = useAuthClient();\r\n return useMutation({\r\n mutationFn: (...args: Parameters<typeof authClient.admin.removeUser>) =>\r\n authClient.admin.removeUser(...args),\r\n ...options,\r\n });\r\n}\r\n\r\nexport function useUpdateUser(options: AnyUseMutationOptions) {\r\n const authClient = useAuthClient();\r\n return useMutation({\r\n mutationFn: (...args: Parameters<typeof authClient.admin.updateUser>) =>\r\n authClient.admin.updateUser(...args),\r\n ...options,\r\n });\r\n}\r\n\r\nexport function useBanUser(options: AnyUseMutationOptions) {\r\n const authClient = useAuthClient();\r\n return useMutation({\r\n mutationFn: (...args: Parameters<typeof authClient.admin.banUser>) =>\r\n authClient.admin.banUser(...args),\r\n ...options,\r\n });\r\n}\r\n\r\nexport function useUnbanUser(options: AnyUseMutationOptions) {\r\n const authClient = useAuthClient();\r\n return useMutation({\r\n mutationFn: (...args: Parameters<typeof authClient.admin.unbanUser>) =>\r\n authClient.admin.unbanUser(...args),\r\n ...options,\r\n });\r\n}\r\n\r\nexport function useImpersonateUser(options: AnyUseMutationOptions) {\r\n const authClient = useAuthClient();\r\n return useMutation({\r\n mutationFn: (...args: Parameters<typeof authClient.admin.impersonateUser>) =>\r\n authClient.admin.impersonateUser(...args),\r\n ...options,\r\n });\r\n}\r\n\r\nexport function useStopImpersonating(options: AnyUseMutationOptions) {\r\n const authClient = useAuthClient();\r\n return useMutation({\r\n mutationFn: () => authClient.admin.stopImpersonating(),\r\n ...options,\r\n });\r\n}\r\n"],"mappings":";;;;AAsBA,MAAa,4BAA4B;AAiBzC,SAAS,4BAA4B,OAA+C;CAClF,MAAM,OAAO,KAAK,IAAI,GAAG,MAAM,KAAK;AACpC,QAAO,EACL,OAAO;EACL,aAAa;EACb,gBAAgB;EAChB,aAAa,MAAM,GAAG,MAAM,IAAI;EAChC,OAAO,MAAM;EACb,SAAS,OAAO,KAAK,MAAM;EAC3B,QAAS,MAAM,QAAQ;EACvB,eAAgB,MAAM,SAAS;EAChC,EACF;;;;;AAMH,SAAgB,kBAAkB,OAAiD;AACjF,KAAI,UAAU,KAAA,EACZ,QAAO,CAAC,0BAA0B;AAEpC,QAAO,CAAC,2BAA2B,4BAA4B,M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