@m5kdev/frontend 0.19.3 → 0.20.5
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/modules/app/components/AppTrpcQueryProvider.js +1 -1
- package/dist/src/modules/app/components/AppTrpcQueryProvider.mjs +1 -1
- package/dist/src/modules/auth/auth.lib.d.mts +13 -4
- package/dist/src/modules/auth/auth.lib.d.mts.map +1 -1
- package/dist/src/modules/auth/auth.lib.d.ts +13 -4
- package/dist/src/modules/auth/auth.lib.d.ts.map +1 -1
- package/dist/src/modules/auth/auth.lib.js +24 -4
- package/dist/src/modules/auth/auth.lib.js.map +1 -1
- package/dist/src/modules/auth/auth.lib.mjs +23 -0
- package/dist/src/modules/auth/auth.lib.mjs.map +1 -1
- package/dist/src/modules/auth/components/AuthProvider.js +1 -1
- package/dist/src/modules/auth/components/AuthProvider.mjs +1 -1
- package/dist/src/modules/auth/hooks/useAuthAdmin.d.mts +31 -2
- package/dist/src/modules/auth/hooks/useAuthAdmin.d.mts.map +1 -1
- package/dist/src/modules/auth/hooks/useAuthAdmin.d.ts +31 -2
- package/dist/src/modules/auth/hooks/useAuthAdmin.d.ts.map +1 -1
- package/dist/src/modules/auth/hooks/useAuthAdmin.js +48 -5
- package/dist/src/modules/auth/hooks/useAuthAdmin.js.map +1 -1
- package/dist/src/modules/auth/hooks/useAuthAdmin.mjs +45 -6
- package/dist/src/modules/auth/hooks/useAuthAdmin.mjs.map +1 -1
- package/dist/src/modules/auth/hooks/useSession.d.mts +3 -0
- package/dist/src/modules/auth/hooks/useSession.d.ts +3 -0
- package/dist/src/modules/auth/hooks/useUserOrganizations.d.mts +20 -0
- package/dist/src/modules/auth/hooks/useUserOrganizations.d.mts.map +1 -0
- package/dist/src/modules/auth/hooks/useUserOrganizations.d.ts +20 -0
- package/dist/src/modules/auth/hooks/useUserOrganizations.d.ts.map +1 -0
- package/dist/src/modules/auth/hooks/useUserOrganizations.js +14 -0
- package/dist/src/modules/auth/hooks/useUserOrganizations.js.map +1 -0
- package/dist/src/modules/auth/hooks/useUserOrganizations.mjs +13 -0
- package/dist/src/modules/auth/hooks/useUserOrganizations.mjs.map +1 -0
- package/package.json +5 -5
|
@@ -2,8 +2,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_src_modules_app_hooks_useAppConfig = require("../hooks/useAppConfig.js");
|
|
3
3
|
let react = require("react");
|
|
4
4
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
|
-
let _tanstack_react_query = require("@tanstack/react-query");
|
|
6
5
|
let _m5kdev_commons_utils_trpc = require("@m5kdev/commons/utils/trpc");
|
|
6
|
+
let _tanstack_react_query = require("@tanstack/react-query");
|
|
7
7
|
let _trpc_client = require("@trpc/client");
|
|
8
8
|
let _trpc_tanstack_react_query = require("@trpc/tanstack-react-query");
|
|
9
9
|
//#region src/modules/app/components/AppTrpcQueryProvider.tsx
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useAppConfig } from "../hooks/useAppConfig.mjs";
|
|
2
2
|
import { useState } from "react";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
|
-
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
5
4
|
import { transformer } from "@m5kdev/commons/utils/trpc";
|
|
5
|
+
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
6
6
|
import { createTRPCClient, httpBatchLink } from "@trpc/client";
|
|
7
7
|
import { createTRPCContext } from "@trpc/tanstack-react-query";
|
|
8
8
|
//#region src/modules/app/components/AppTrpcQueryProvider.tsx
|
|
@@ -669,7 +669,7 @@ declare const authClient: {
|
|
|
669
669
|
sortDirection?: "asc" | "desc" | undefined;
|
|
670
670
|
filterField?: string | undefined;
|
|
671
671
|
filterValue?: string | number | boolean | undefined;
|
|
672
|
-
filterOperator?: "
|
|
672
|
+
filterOperator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "contains" | undefined;
|
|
673
673
|
organizationId?: string | undefined;
|
|
674
674
|
organizationSlug?: string | undefined;
|
|
675
675
|
}> & Record<string, any>, Record<string, any> | undefined>>(data_0?: _$better_auth0.Prettify<{
|
|
@@ -680,7 +680,7 @@ declare const authClient: {
|
|
|
680
680
|
sortDirection?: "asc" | "desc" | undefined;
|
|
681
681
|
filterField?: string | undefined;
|
|
682
682
|
filterValue?: string | number | boolean | undefined;
|
|
683
|
-
filterOperator?: "
|
|
683
|
+
filterOperator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "contains" | undefined;
|
|
684
684
|
organizationId?: string | undefined;
|
|
685
685
|
organizationSlug?: string | undefined;
|
|
686
686
|
} | undefined;
|
|
@@ -1042,7 +1042,7 @@ declare const authClient: {
|
|
|
1042
1042
|
sortDirection?: "asc" | "desc" | undefined;
|
|
1043
1043
|
filterField?: string | undefined;
|
|
1044
1044
|
filterValue?: string | number | boolean | undefined;
|
|
1045
|
-
filterOperator?: "
|
|
1045
|
+
filterOperator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "contains" | undefined;
|
|
1046
1046
|
}> & Record<string, any>, Record<string, any> | undefined>>(data_0: _$better_auth0.Prettify<{
|
|
1047
1047
|
query: {
|
|
1048
1048
|
searchValue?: string | undefined;
|
|
@@ -1054,7 +1054,7 @@ declare const authClient: {
|
|
|
1054
1054
|
sortDirection?: "asc" | "desc" | undefined;
|
|
1055
1055
|
filterField?: string | undefined;
|
|
1056
1056
|
filterValue?: string | number | boolean | undefined;
|
|
1057
|
-
filterOperator?: "
|
|
1057
|
+
filterOperator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "contains" | undefined;
|
|
1058
1058
|
};
|
|
1059
1059
|
fetchOptions?: FetchOptions | undefined;
|
|
1060
1060
|
}>, data_1?: FetchOptions | undefined) => Promise<_$better_auth_client0.BetterFetchResponse<NonNullable<{
|
|
@@ -1824,6 +1824,9 @@ declare const authClient: {
|
|
|
1824
1824
|
activeOrganizationId?: string | null | undefined;
|
|
1825
1825
|
activeTeamId?: string | null | undefined;
|
|
1826
1826
|
impersonatedBy?: string | null | undefined;
|
|
1827
|
+
activeTeamRole?: string | null | undefined;
|
|
1828
|
+
activeOrganizationRole?: string | null | undefined;
|
|
1829
|
+
activeOrganizationType?: string | null | undefined;
|
|
1827
1830
|
};
|
|
1828
1831
|
} | null, {
|
|
1829
1832
|
code?: string | undefined;
|
|
@@ -1990,6 +1993,9 @@ declare const authClient: {
|
|
|
1990
1993
|
activeOrganizationId?: string | null | undefined;
|
|
1991
1994
|
activeTeamId?: string | null | undefined;
|
|
1992
1995
|
impersonatedBy?: string | null | undefined;
|
|
1996
|
+
activeTeamRole?: string | null | undefined;
|
|
1997
|
+
activeOrganizationRole?: string | null | undefined;
|
|
1998
|
+
activeOrganizationType?: string | null | undefined;
|
|
1993
1999
|
};
|
|
1994
2000
|
} | null;
|
|
1995
2001
|
isPending: boolean;
|
|
@@ -2030,6 +2036,9 @@ declare const authClient: {
|
|
|
2030
2036
|
activeOrganizationId?: string | null | undefined;
|
|
2031
2037
|
activeTeamId?: string | null | undefined;
|
|
2032
2038
|
impersonatedBy?: string | null | undefined;
|
|
2039
|
+
activeTeamRole?: string | null | undefined;
|
|
2040
|
+
activeOrganizationRole?: string | null | undefined;
|
|
2041
|
+
activeOrganizationType?: string | null | undefined;
|
|
2033
2042
|
};
|
|
2034
2043
|
};
|
|
2035
2044
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.lib.d.mts","names":[],"sources":["../../../../src/modules/auth/auth.lib.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"auth.lib.d.mts","names":[],"sources":["../../../../src/modules/auth/auth.lib.ts"],"mappings":";;;;;cAQa,UAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BAWL,kBAAA;IAAA;;;;;;;;;;;;;;;6BAAA,kBAAA;IAAA;;;;;;;;;;;;;;6BAAA,kBAAA;IAAA;;;;;;;;;;6BA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A,IAAA,WAAA;;;;;eAA+U,eAAA;kBAA+C,kBAAA;;;WAAwG,WAAA;eAAwC,eAAA;;qBAAqF,cAAA;cAAyC,WAAA;gBAAgD,QAAA,EAAhD,qBAAA,CAAgD,eAAA,KAAA,OAAA;;;;;qBAAA,qBAAA,CAAA,UAAA;;;;;;;;;;;;;;;;;;;;kCAA27B,YAAA;;cAAA,qBAAA,CAAmG,gBAAA,UAAA,IAAA,UAAA,IAAA;kBAAA,qBAAA,CAAmG,gBAAA;;;;;uBAAuM,IAAA"}
|
|
@@ -669,7 +669,7 @@ declare const authClient: {
|
|
|
669
669
|
sortDirection?: "asc" | "desc" | undefined;
|
|
670
670
|
filterField?: string | undefined;
|
|
671
671
|
filterValue?: string | number | boolean | undefined;
|
|
672
|
-
filterOperator?: "
|
|
672
|
+
filterOperator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "contains" | undefined;
|
|
673
673
|
organizationId?: string | undefined;
|
|
674
674
|
organizationSlug?: string | undefined;
|
|
675
675
|
}> & Record<string, any>, Record<string, any> | undefined>>(data_0?: _$better_auth0.Prettify<{
|
|
@@ -680,7 +680,7 @@ declare const authClient: {
|
|
|
680
680
|
sortDirection?: "asc" | "desc" | undefined;
|
|
681
681
|
filterField?: string | undefined;
|
|
682
682
|
filterValue?: string | number | boolean | undefined;
|
|
683
|
-
filterOperator?: "
|
|
683
|
+
filterOperator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "contains" | undefined;
|
|
684
684
|
organizationId?: string | undefined;
|
|
685
685
|
organizationSlug?: string | undefined;
|
|
686
686
|
} | undefined;
|
|
@@ -1042,7 +1042,7 @@ declare const authClient: {
|
|
|
1042
1042
|
sortDirection?: "asc" | "desc" | undefined;
|
|
1043
1043
|
filterField?: string | undefined;
|
|
1044
1044
|
filterValue?: string | number | boolean | undefined;
|
|
1045
|
-
filterOperator?: "
|
|
1045
|
+
filterOperator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "contains" | undefined;
|
|
1046
1046
|
}> & Record<string, any>, Record<string, any> | undefined>>(data_0: _$better_auth0.Prettify<{
|
|
1047
1047
|
query: {
|
|
1048
1048
|
searchValue?: string | undefined;
|
|
@@ -1054,7 +1054,7 @@ declare const authClient: {
|
|
|
1054
1054
|
sortDirection?: "asc" | "desc" | undefined;
|
|
1055
1055
|
filterField?: string | undefined;
|
|
1056
1056
|
filterValue?: string | number | boolean | undefined;
|
|
1057
|
-
filterOperator?: "
|
|
1057
|
+
filterOperator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "contains" | undefined;
|
|
1058
1058
|
};
|
|
1059
1059
|
fetchOptions?: FetchOptions | undefined;
|
|
1060
1060
|
}>, data_1?: FetchOptions | undefined) => Promise<_$better_auth_client0.BetterFetchResponse<NonNullable<{
|
|
@@ -1824,6 +1824,9 @@ declare const authClient: {
|
|
|
1824
1824
|
activeOrganizationId?: string | null | undefined;
|
|
1825
1825
|
activeTeamId?: string | null | undefined;
|
|
1826
1826
|
impersonatedBy?: string | null | undefined;
|
|
1827
|
+
activeTeamRole?: string | null | undefined;
|
|
1828
|
+
activeOrganizationRole?: string | null | undefined;
|
|
1829
|
+
activeOrganizationType?: string | null | undefined;
|
|
1827
1830
|
};
|
|
1828
1831
|
} | null, {
|
|
1829
1832
|
code?: string | undefined;
|
|
@@ -1990,6 +1993,9 @@ declare const authClient: {
|
|
|
1990
1993
|
activeOrganizationId?: string | null | undefined;
|
|
1991
1994
|
activeTeamId?: string | null | undefined;
|
|
1992
1995
|
impersonatedBy?: string | null | undefined;
|
|
1996
|
+
activeTeamRole?: string | null | undefined;
|
|
1997
|
+
activeOrganizationRole?: string | null | undefined;
|
|
1998
|
+
activeOrganizationType?: string | null | undefined;
|
|
1993
1999
|
};
|
|
1994
2000
|
} | null;
|
|
1995
2001
|
isPending: boolean;
|
|
@@ -2030,6 +2036,9 @@ declare const authClient: {
|
|
|
2030
2036
|
activeOrganizationId?: string | null | undefined;
|
|
2031
2037
|
activeTeamId?: string | null | undefined;
|
|
2032
2038
|
impersonatedBy?: string | null | undefined;
|
|
2039
|
+
activeTeamRole?: string | null | undefined;
|
|
2040
|
+
activeOrganizationRole?: string | null | undefined;
|
|
2041
|
+
activeOrganizationType?: string | null | undefined;
|
|
2033
2042
|
};
|
|
2034
2043
|
};
|
|
2035
2044
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.lib.d.ts","names":[],"sources":["../../../../src/modules/auth/auth.lib.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"auth.lib.d.ts","names":[],"sources":["../../../../src/modules/auth/auth.lib.ts"],"mappings":";;;;;cAQa,UAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BAWL,kBAAA;IAAA;;;;;;;;;;;;;;;6BAAA,kBAAA;IAAA;;;;;;;;;;;;;;6BAAA,kBAAA;IAAA;;;;;;;;;;6BAAA,kBAAA;IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BAiDwc,kBAAA;IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAA+wG,qBAAA,CAAA,WAAA;;;;;;;;;;;;;;;;;YAAx5D,YAAA;;;eAA2F,WAAA,IAAA,WAAA;;;;;eAA+U,eAAA;kBAA+C,kBAAA;;;WAAwG,WAAA;eAAwC,eAAA;;qBAAqF,cAAA;cAAyC,WAAA;gBAAgD,QAAA,EAAhD,qBAAA,CAAgD,eAAA,KAAA,OAAA;;;;;qBAAA,qBAAA,CAAA,UAAA;;;;;;;;;;;;;;;;;;;;kCAA27B,YAAA;;cAAA,qBAAA,CAAmG,gBAAA,UAAA,IAAA,UAAA,IAAA;kBAAA,qBAAA,CAAmG,gBAAA;;;;;uBAAuM,IAAA"}
|
|
@@ -1,14 +1,35 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
let better_auth_client_plugins = require("better-auth/client/plugins");
|
|
3
|
-
let better_auth_react = require("better-auth/react");
|
|
4
3
|
//#region src/modules/auth/auth.lib.ts
|
|
5
|
-
const
|
|
4
|
+
const authClient = (0, require("better-auth/react").createAuthClient)({
|
|
6
5
|
baseURL: {}.env.VITE_SERVER_URL,
|
|
7
6
|
plugins: [
|
|
8
7
|
(0, better_auth_client_plugins.lastLoginMethodClient)(),
|
|
9
8
|
(0, better_auth_client_plugins.organizationClient)({ teams: { enabled: true } }),
|
|
10
9
|
(0, better_auth_client_plugins.adminClient)(),
|
|
11
10
|
(0, better_auth_client_plugins.inferAdditionalFields)({
|
|
11
|
+
session: {
|
|
12
|
+
activeOrganizationId: {
|
|
13
|
+
type: "string",
|
|
14
|
+
required: false
|
|
15
|
+
},
|
|
16
|
+
activeTeamId: {
|
|
17
|
+
type: "string",
|
|
18
|
+
required: false
|
|
19
|
+
},
|
|
20
|
+
activeTeamRole: {
|
|
21
|
+
type: "string",
|
|
22
|
+
required: false
|
|
23
|
+
},
|
|
24
|
+
activeOrganizationRole: {
|
|
25
|
+
type: "string",
|
|
26
|
+
required: false
|
|
27
|
+
},
|
|
28
|
+
activeOrganizationType: {
|
|
29
|
+
type: "string",
|
|
30
|
+
required: false
|
|
31
|
+
}
|
|
32
|
+
},
|
|
12
33
|
user: {
|
|
13
34
|
onboarding: {
|
|
14
35
|
type: "number",
|
|
@@ -33,8 +54,7 @@ const options = {
|
|
|
33
54
|
} }
|
|
34
55
|
})
|
|
35
56
|
]
|
|
36
|
-
};
|
|
37
|
-
const authClient = (0, better_auth_react.createAuthClient)(options);
|
|
57
|
+
});
|
|
38
58
|
//#endregion
|
|
39
59
|
exports.authClient = authClient;
|
|
40
60
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.lib.js","names":[],"sources":["../../../../src/modules/auth/auth.lib.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"auth.lib.js","names":[],"sources":["../../../../src/modules/auth/auth.lib.ts"],"sourcesContent":["import {\n adminClient,\n inferAdditionalFields,\n lastLoginMethodClient,\n organizationClient,\n} from \"better-auth/client/plugins\";\nimport { createAuthClient } from \"better-auth/react\";\n\nexport const authClient = createAuthClient({\n baseURL: import.meta.env.VITE_SERVER_URL,\n plugins: [\n lastLoginMethodClient(),\n organizationClient({\n teams: {\n enabled: true,\n },\n }),\n adminClient(),\n inferAdditionalFields({\n session: {\n activeOrganizationId: {\n type: \"string\",\n required: false,\n },\n activeTeamId: {\n type: \"string\",\n required: false,\n },\n activeTeamRole: {\n type: \"string\",\n required: false,\n },\n activeOrganizationRole: {\n type: \"string\",\n required: false,\n },\n activeOrganizationType: {\n type: \"string\",\n required: false,\n },\n },\n user: {\n onboarding: {\n type: \"number\",\n required: false,\n },\n preferences: {\n type: \"string\",\n required: false,\n },\n flags: {\n type: \"string\",\n required: false,\n },\n stripeCustomerId: {\n type: \"string\",\n required: false,\n },\n },\n teamMembers: {\n role: {\n type: \"string\",\n required: true,\n },\n },\n }),\n ],\n});\n"],"mappings":";;;AAQA,MAAa,cAAA,gCAAA,kBAA8B;CACzC,SAAA,EAAA,CAAqB,IAAI;CACzB,SAAS;yDACgB;qDACJ,EACjB,OAAO,EACL,SAAS,MACV,EACF,CAAC;+CACW;wDACS;GACpB,SAAS;IACP,sBAAsB;KACpB,MAAM;KACN,UAAU;KACX;IACD,cAAc;KACZ,MAAM;KACN,UAAU;KACX;IACD,gBAAgB;KACd,MAAM;KACN,UAAU;KACX;IACD,wBAAwB;KACtB,MAAM;KACN,UAAU;KACX;IACD,wBAAwB;KACtB,MAAM;KACN,UAAU;KACX;IACF;GACD,MAAM;IACJ,YAAY;KACV,MAAM;KACN,UAAU;KACX;IACD,aAAa;KACX,MAAM;KACN,UAAU;KACX;IACD,OAAO;KACL,MAAM;KACN,UAAU;KACX;IACD,kBAAkB;KAChB,MAAM;KACN,UAAU;KACX;IACF;GACD,aAAa,EACX,MAAM;IACJ,MAAM;IACN,UAAU;IACX,EACF;GACF,CAAC;EACH;CACF,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { adminClient, inferAdditionalFields, lastLoginMethodClient, organizationClient } from "better-auth/client/plugins";
|
|
2
2
|
import { createAuthClient } from "better-auth/react";
|
|
3
|
+
//#region src/modules/auth/auth.lib.ts
|
|
3
4
|
const authClient = createAuthClient({
|
|
4
5
|
baseURL: import.meta.env.VITE_SERVER_URL,
|
|
5
6
|
plugins: [
|
|
@@ -7,6 +8,28 @@ const authClient = createAuthClient({
|
|
|
7
8
|
organizationClient({ teams: { enabled: true } }),
|
|
8
9
|
adminClient(),
|
|
9
10
|
inferAdditionalFields({
|
|
11
|
+
session: {
|
|
12
|
+
activeOrganizationId: {
|
|
13
|
+
type: "string",
|
|
14
|
+
required: false
|
|
15
|
+
},
|
|
16
|
+
activeTeamId: {
|
|
17
|
+
type: "string",
|
|
18
|
+
required: false
|
|
19
|
+
},
|
|
20
|
+
activeTeamRole: {
|
|
21
|
+
type: "string",
|
|
22
|
+
required: false
|
|
23
|
+
},
|
|
24
|
+
activeOrganizationRole: {
|
|
25
|
+
type: "string",
|
|
26
|
+
required: false
|
|
27
|
+
},
|
|
28
|
+
activeOrganizationType: {
|
|
29
|
+
type: "string",
|
|
30
|
+
required: false
|
|
31
|
+
}
|
|
32
|
+
},
|
|
10
33
|
user: {
|
|
11
34
|
onboarding: {
|
|
12
35
|
type: "number",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.lib.mjs","names":[],"sources":["../../../../src/modules/auth/auth.lib.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"auth.lib.mjs","names":[],"sources":["../../../../src/modules/auth/auth.lib.ts"],"sourcesContent":["import {\n adminClient,\n inferAdditionalFields,\n lastLoginMethodClient,\n organizationClient,\n} from \"better-auth/client/plugins\";\nimport { createAuthClient } from \"better-auth/react\";\n\nexport const authClient = createAuthClient({\n baseURL: import.meta.env.VITE_SERVER_URL,\n plugins: [\n lastLoginMethodClient(),\n organizationClient({\n teams: {\n enabled: true,\n },\n }),\n adminClient(),\n inferAdditionalFields({\n session: {\n activeOrganizationId: {\n type: \"string\",\n required: false,\n },\n activeTeamId: {\n type: \"string\",\n required: false,\n },\n activeTeamRole: {\n type: \"string\",\n required: false,\n },\n activeOrganizationRole: {\n type: \"string\",\n required: false,\n },\n activeOrganizationType: {\n type: \"string\",\n required: false,\n },\n },\n user: {\n onboarding: {\n type: \"number\",\n required: false,\n },\n preferences: {\n type: \"string\",\n required: false,\n },\n flags: {\n type: \"string\",\n required: false,\n },\n stripeCustomerId: {\n type: \"string\",\n required: false,\n },\n },\n teamMembers: {\n role: {\n type: \"string\",\n required: true,\n },\n },\n }),\n ],\n});\n"],"mappings":";;;AAQA,MAAa,aAAa,iBAAiB;CACzC,SAAS,OAAO,KAAK,IAAI;CACzB,SAAS;EACP,uBAAuB;EACvB,mBAAmB,EACjB,OAAO,EACL,SAAS,MACV,EACF,CAAC;EACF,aAAa;EACb,sBAAsB;GACpB,SAAS;IACP,sBAAsB;KACpB,MAAM;KACN,UAAU;KACX;IACD,cAAc;KACZ,MAAM;KACN,UAAU;KACX;IACD,gBAAgB;KACd,MAAM;KACN,UAAU;KACX;IACD,wBAAwB;KACtB,MAAM;KACN,UAAU;KACX;IACD,wBAAwB;KACtB,MAAM;KACN,UAAU;KACX;IACF;GACD,MAAM;IACJ,YAAY;KACV,MAAM;KACN,UAAU;KACX;IACD,aAAa;KACX,MAAM;KACN,UAAU;KACX;IACD,OAAO;KACL,MAAM;KACN,UAAU;KACX;IACD,kBAAkB;KAChB,MAAM;KACN,UAAU;KACX;IACF;GACD,aAAa,EACX,MAAM;IACJ,MAAM;IACN,UAAU;IACX,EACF;GACF,CAAC;EACH;CACF,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_src_modules_auth_auth_lib = require("../auth.lib.js");
|
|
3
|
-
let posthog_js_react_dist_umd_index_js = require("posthog-js/react/dist/umd/index.js");
|
|
4
3
|
let react = require("react");
|
|
5
4
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
|
+
let posthog_js_react_dist_umd_index_js = require("posthog-js/react/dist/umd/index.js");
|
|
6
6
|
//#region src/modules/auth/components/AuthProvider.tsx
|
|
7
7
|
function isImpersonatedSession(session) {
|
|
8
8
|
const sessionData = session?.session;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { authClient } from "../auth.lib.mjs";
|
|
2
|
-
import { usePostHog } from "posthog-js/react/dist/esm/index.js";
|
|
3
2
|
import { createContext, useCallback, useEffect, useState } from "react";
|
|
4
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { usePostHog } from "posthog-js/react/dist/esm/index.js";
|
|
5
5
|
//#region src/modules/auth/components/AuthProvider.tsx
|
|
6
6
|
function isImpersonatedSession(session) {
|
|
7
7
|
const sessionData = session?.session;
|
|
@@ -1,10 +1,39 @@
|
|
|
1
1
|
import { authClient } from "../auth.lib.mjs";
|
|
2
2
|
import * as _$_tanstack_react_query0 from "@tanstack/react-query";
|
|
3
|
-
import { AnyUseMutationOptions } from "@tanstack/react-query";
|
|
3
|
+
import { AnyUseMutationOptions, QueryClient, UseQueryOptions } from "@tanstack/react-query";
|
|
4
|
+
import { QueryFilters } from "@m5kdev/commons/modules/schemas/query.schema";
|
|
4
5
|
import * as _$better_auth_plugins0 from "better-auth/plugins";
|
|
5
6
|
|
|
6
7
|
//#region src/modules/auth/hooks/useAuthAdmin.d.ts
|
|
7
8
|
type ListUsersArgs = Parameters<typeof authClient.admin.listUsers>;
|
|
9
|
+
type ListUsersResult = Awaited<ReturnType<typeof authClient.admin.listUsers>>;
|
|
10
|
+
/**
|
|
11
|
+
* Data shape returned from Better Auth `admin.listUsers` (tRPC-style query data).
|
|
12
|
+
*/
|
|
13
|
+
type ListUsersQueryData = NonNullable<ListUsersResult["data"]>;
|
|
14
|
+
declare const AUTH_ADMIN_LIST_USERS_KEY: "auth-admin-list-users";
|
|
15
|
+
/**
|
|
16
|
+
* Input aligned with `useQueryWithParams` / Nuqs table URL state (page, limit, sort, order, q, filters).
|
|
17
|
+
* Maps to Better Auth `listUsers` query payload.
|
|
18
|
+
*/
|
|
19
|
+
interface ListUsersNuqsInput {
|
|
20
|
+
page: number;
|
|
21
|
+
limit: number;
|
|
22
|
+
sort?: string;
|
|
23
|
+
order?: "asc" | "desc" | null;
|
|
24
|
+
q?: string;
|
|
25
|
+
filters?: QueryFilters;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Query key factory (tRPC-style). Omit input to match all list-users queries for invalidation.
|
|
29
|
+
*/
|
|
30
|
+
declare function listUsersQueryKey(input?: ListUsersNuqsInput): readonly unknown[];
|
|
31
|
+
/**
|
|
32
|
+
* Query options factory for use with `useQuery`, `useNuqsTable` / `useQueryWithParams`, or `queryClient.fetchQuery`.
|
|
33
|
+
* Signature mirrors tRPC `procedure.queryOptions(input, opts?)`.
|
|
34
|
+
*/
|
|
35
|
+
declare function listUsersQueryOptions(input: ListUsersNuqsInput, opts?: Omit<UseQueryOptions<ListUsersQueryData, Error, ListUsersQueryData, readonly unknown[]>, "queryKey" | "queryFn">): UseQueryOptions<ListUsersQueryData, Error, ListUsersQueryData, readonly unknown[]>;
|
|
36
|
+
declare function invalidateListUsersQuery(queryClient: QueryClient): Promise<void>;
|
|
8
37
|
declare function useInvalidateListUsers(...args: ListUsersArgs): () => Promise<void>;
|
|
9
38
|
declare function useListUsers(...args: ListUsersArgs): _$_tanstack_react_query0.UseQueryResult<NonNullable<{
|
|
10
39
|
users: _$better_auth_plugins0.UserWithRole[];
|
|
@@ -22,5 +51,5 @@ declare function useUnbanUser(options: AnyUseMutationOptions): _$_tanstack_react
|
|
|
22
51
|
declare function useImpersonateUser(options: AnyUseMutationOptions): _$_tanstack_react_query0.UseMutationResult<any, any, any, any>;
|
|
23
52
|
declare function useStopImpersonating(options: AnyUseMutationOptions): _$_tanstack_react_query0.UseMutationResult<any, any, any, any>;
|
|
24
53
|
//#endregion
|
|
25
|
-
export { useBanUser, useImpersonateUser, useInvalidateListUsers, useListUsers, useRemoveUser, useStopImpersonating, useUnbanUser, useUpdateUser };
|
|
54
|
+
export { AUTH_ADMIN_LIST_USERS_KEY, ListUsersNuqsInput, ListUsersQueryData, invalidateListUsersQuery, listUsersQueryKey, listUsersQueryOptions, useBanUser, useImpersonateUser, useInvalidateListUsers, useListUsers, useRemoveUser, useStopImpersonating, useUnbanUser, useUpdateUser };
|
|
26
55
|
//# 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":";;;;;;;KAWK,aAAA,GAAgB,UAAA,QAAkB,UAAA,CAAW,KAAA,CAAM,SAAA;AAAA,KAEnD,eAAA,GAAkB,OAAA,CAAQ,UAAA,QAAkB,UAAA,CAAW,KAAA,CAAM,SAAA;;;AAJzB;KAS7B,kBAAA,GAAqB,WAAA,CAAY,eAAA;AAAA,cAEhC,yBAAA;;;;;UAMI,kBAAA;EACf,IAAA;EACA,KAAA;EACA,IAAA;EACA,KAAA;EACA,CAAA;EACA,OAAA,GAAU,YAAA;AAAA;;;;iBAuBI,iBAAA,CAAkB,KAAA,GAAQ,kBAAA;;;;;iBAW1B,qBAAA,CACd,KAAA,EAAO,kBAAA,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,4BAAa,cAAA,CAAA,WAAA;SAAA,sBAAA,CAAA,YAAA;;;;;;;;iBAWnC,aAAA,CAAc,OAAA,EAAS,qBAAA,GAAqB,wBAAA,CAAA,iBAAA;AAAA,iBAQ5C,aAAA,CAAc,OAAA,EAAS,qBAAA,GAAqB,wBAAA,CAAA,iBAAA;AAAA,iBAQ5C,UAAA,CAAW,OAAA,EAAS,qBAAA,GAAqB,wBAAA,CAAA,iBAAA;AAAA,iBAQzC,YAAA,CAAa,OAAA,EAAS,qBAAA,GAAqB,wBAAA,CAAA,iBAAA;AAAA,iBAQ3C,kBAAA,CAAmB,OAAA,EAAS,qBAAA,GAAqB,wBAAA,CAAA,iBAAA;AAAA,iBAQjD,oBAAA,CAAqB,OAAA,EAAS,qBAAA,GAAqB,wBAAA,CAAA,iBAAA"}
|
|
@@ -1,10 +1,39 @@
|
|
|
1
1
|
import { authClient } from "../auth.lib.js";
|
|
2
2
|
import * as _$_tanstack_react_query0 from "@tanstack/react-query";
|
|
3
|
-
import { AnyUseMutationOptions } from "@tanstack/react-query";
|
|
3
|
+
import { AnyUseMutationOptions, QueryClient, UseQueryOptions } from "@tanstack/react-query";
|
|
4
4
|
import * as _$better_auth_plugins0 from "better-auth/plugins";
|
|
5
|
+
import { QueryFilters } from "@m5kdev/commons/modules/schemas/query.schema";
|
|
5
6
|
|
|
6
7
|
//#region src/modules/auth/hooks/useAuthAdmin.d.ts
|
|
7
8
|
type ListUsersArgs = Parameters<typeof authClient.admin.listUsers>;
|
|
9
|
+
type ListUsersResult = Awaited<ReturnType<typeof authClient.admin.listUsers>>;
|
|
10
|
+
/**
|
|
11
|
+
* Data shape returned from Better Auth `admin.listUsers` (tRPC-style query data).
|
|
12
|
+
*/
|
|
13
|
+
type ListUsersQueryData = NonNullable<ListUsersResult["data"]>;
|
|
14
|
+
declare const AUTH_ADMIN_LIST_USERS_KEY: "auth-admin-list-users";
|
|
15
|
+
/**
|
|
16
|
+
* Input aligned with `useQueryWithParams` / Nuqs table URL state (page, limit, sort, order, q, filters).
|
|
17
|
+
* Maps to Better Auth `listUsers` query payload.
|
|
18
|
+
*/
|
|
19
|
+
interface ListUsersNuqsInput {
|
|
20
|
+
page: number;
|
|
21
|
+
limit: number;
|
|
22
|
+
sort?: string;
|
|
23
|
+
order?: "asc" | "desc" | null;
|
|
24
|
+
q?: string;
|
|
25
|
+
filters?: QueryFilters;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Query key factory (tRPC-style). Omit input to match all list-users queries for invalidation.
|
|
29
|
+
*/
|
|
30
|
+
declare function listUsersQueryKey(input?: ListUsersNuqsInput): readonly unknown[];
|
|
31
|
+
/**
|
|
32
|
+
* Query options factory for use with `useQuery`, `useNuqsTable` / `useQueryWithParams`, or `queryClient.fetchQuery`.
|
|
33
|
+
* Signature mirrors tRPC `procedure.queryOptions(input, opts?)`.
|
|
34
|
+
*/
|
|
35
|
+
declare function listUsersQueryOptions(input: ListUsersNuqsInput, opts?: Omit<UseQueryOptions<ListUsersQueryData, Error, ListUsersQueryData, readonly unknown[]>, "queryKey" | "queryFn">): UseQueryOptions<ListUsersQueryData, Error, ListUsersQueryData, readonly unknown[]>;
|
|
36
|
+
declare function invalidateListUsersQuery(queryClient: QueryClient): Promise<void>;
|
|
8
37
|
declare function useInvalidateListUsers(...args: ListUsersArgs): () => Promise<void>;
|
|
9
38
|
declare function useListUsers(...args: ListUsersArgs): _$_tanstack_react_query0.UseQueryResult<NonNullable<{
|
|
10
39
|
users: _$better_auth_plugins0.UserWithRole[];
|
|
@@ -22,5 +51,5 @@ declare function useUnbanUser(options: AnyUseMutationOptions): _$_tanstack_react
|
|
|
22
51
|
declare function useImpersonateUser(options: AnyUseMutationOptions): _$_tanstack_react_query0.UseMutationResult<any, any, any, any>;
|
|
23
52
|
declare function useStopImpersonating(options: AnyUseMutationOptions): _$_tanstack_react_query0.UseMutationResult<any, any, any, any>;
|
|
24
53
|
//#endregion
|
|
25
|
-
export { useBanUser, useImpersonateUser, useInvalidateListUsers, useListUsers, useRemoveUser, useStopImpersonating, useUnbanUser, useUpdateUser };
|
|
54
|
+
export { AUTH_ADMIN_LIST_USERS_KEY, ListUsersNuqsInput, ListUsersQueryData, invalidateListUsersQuery, listUsersQueryKey, listUsersQueryOptions, useBanUser, useImpersonateUser, useInvalidateListUsers, useListUsers, useRemoveUser, useStopImpersonating, useUnbanUser, useUpdateUser };
|
|
26
55
|
//# 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":";;;;;;;KAWK,aAAA,GAAgB,UAAA,QAAkB,UAAA,CAAW,KAAA,CAAM,SAAA;AAAA,KAEnD,eAAA,GAAkB,OAAA,CAAQ,UAAA,QAAkB,UAAA,CAAW,KAAA,CAAM,SAAA;;;AAJzB;KAS7B,kBAAA,GAAqB,WAAA,CAAY,eAAA;AAAA,cAEhC,yBAAA;;;;;UAMI,kBAAA;EACf,IAAA;EACA,KAAA;EACA,IAAA;EACA,KAAA;EACA,CAAA;EACA,OAAA,GAAU,YAAA;AAAA;;;;iBAuBI,iBAAA,CAAkB,KAAA,GAAQ,kBAAA;;;;;iBAW1B,qBAAA,CACd,KAAA,EAAO,kBAAA,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,4BAAa,cAAA,CAAA,WAAA;SAAA,sBAAA,CAAA,YAAA;;;;;;;;iBAWnC,aAAA,CAAc,OAAA,EAAS,qBAAA,GAAqB,wBAAA,CAAA,iBAAA;AAAA,iBAQ5C,aAAA,CAAc,OAAA,EAAS,qBAAA,GAAqB,wBAAA,CAAA,iBAAA;AAAA,iBAQ5C,UAAA,CAAW,OAAA,EAAS,qBAAA,GAAqB,wBAAA,CAAA,iBAAA;AAAA,iBAQzC,YAAA,CAAa,OAAA,EAAS,qBAAA,GAAqB,wBAAA,CAAA,iBAAA;AAAA,iBAQ3C,kBAAA,CAAmB,OAAA,EAAS,qBAAA,GAAqB,wBAAA,CAAA,iBAAA;AAAA,iBAQjD,oBAAA,CAAqB,OAAA,EAAS,qBAAA,GAAqB,wBAAA,CAAA,iBAAA"}
|
|
@@ -2,16 +2,55 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_src_modules_auth_auth_lib = require("../auth.lib.js");
|
|
3
3
|
let _tanstack_react_query = require("@tanstack/react-query");
|
|
4
4
|
//#region src/modules/auth/hooks/useAuthAdmin.ts
|
|
5
|
+
const AUTH_ADMIN_LIST_USERS_KEY = "auth-admin-list-users";
|
|
6
|
+
function mapNuqsInputToListUsersArg(input) {
|
|
7
|
+
const page = Math.max(1, input.page);
|
|
8
|
+
return { query: {
|
|
9
|
+
searchField: "name",
|
|
10
|
+
searchOperator: "contains",
|
|
11
|
+
searchValue: input.q?.trim() ?? "",
|
|
12
|
+
limit: input.limit,
|
|
13
|
+
offset: (page - 1) * input.limit,
|
|
14
|
+
sortBy: input.sort ?? "createdAt",
|
|
15
|
+
sortDirection: input.order ?? "desc"
|
|
16
|
+
} };
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Query key factory (tRPC-style). Omit input to match all list-users queries for invalidation.
|
|
20
|
+
*/
|
|
21
|
+
function listUsersQueryKey(input) {
|
|
22
|
+
if (input === void 0) return [AUTH_ADMIN_LIST_USERS_KEY];
|
|
23
|
+
return [AUTH_ADMIN_LIST_USERS_KEY, mapNuqsInputToListUsersArg(input)];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Query options factory for use with `useQuery`, `useNuqsTable` / `useQueryWithParams`, or `queryClient.fetchQuery`.
|
|
27
|
+
* Signature mirrors tRPC `procedure.queryOptions(input, opts?)`.
|
|
28
|
+
*/
|
|
29
|
+
function listUsersQueryOptions(input, opts) {
|
|
30
|
+
const arg = mapNuqsInputToListUsersArg(input);
|
|
31
|
+
return {
|
|
32
|
+
queryKey: listUsersQueryKey(input),
|
|
33
|
+
queryFn: async () => {
|
|
34
|
+
const { data, error } = await require_src_modules_auth_auth_lib.authClient.admin.listUsers(arg);
|
|
35
|
+
if (error) return Promise.reject(error);
|
|
36
|
+
if (data == null) return Promise.reject(/* @__PURE__ */ new Error("listUsers returned no data"));
|
|
37
|
+
return data;
|
|
38
|
+
},
|
|
39
|
+
...opts
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function invalidateListUsersQuery(queryClient) {
|
|
43
|
+
return queryClient.invalidateQueries({ queryKey: [AUTH_ADMIN_LIST_USERS_KEY] });
|
|
44
|
+
}
|
|
5
45
|
function useInvalidateListUsers(...args) {
|
|
6
46
|
const queryClient = (0, _tanstack_react_query.useQueryClient)();
|
|
7
|
-
return () => queryClient.invalidateQueries({ queryKey: [
|
|
47
|
+
return () => queryClient.invalidateQueries({ queryKey: [AUTH_ADMIN_LIST_USERS_KEY, ...args] });
|
|
8
48
|
}
|
|
9
49
|
function useListUsers(...args) {
|
|
10
50
|
return (0, _tanstack_react_query.useQuery)({
|
|
11
|
-
queryKey: [
|
|
12
|
-
queryFn: async (
|
|
13
|
-
const
|
|
14
|
-
const { data, error } = await require_src_modules_auth_auth_lib.authClient.admin.listUsers(...listUserArgs);
|
|
51
|
+
queryKey: [AUTH_ADMIN_LIST_USERS_KEY, ...args],
|
|
52
|
+
queryFn: async () => {
|
|
53
|
+
const { data, error } = await require_src_modules_auth_auth_lib.authClient.admin.listUsers(...args);
|
|
15
54
|
if (error) return Promise.reject(error);
|
|
16
55
|
return data;
|
|
17
56
|
}
|
|
@@ -54,6 +93,10 @@ function useStopImpersonating(options) {
|
|
|
54
93
|
});
|
|
55
94
|
}
|
|
56
95
|
//#endregion
|
|
96
|
+
exports.AUTH_ADMIN_LIST_USERS_KEY = AUTH_ADMIN_LIST_USERS_KEY;
|
|
97
|
+
exports.invalidateListUsersQuery = invalidateListUsersQuery;
|
|
98
|
+
exports.listUsersQueryKey = listUsersQueryKey;
|
|
99
|
+
exports.listUsersQueryOptions = listUsersQueryOptions;
|
|
57
100
|
exports.useBanUser = useBanUser;
|
|
58
101
|
exports.useImpersonateUser = useImpersonateUser;
|
|
59
102
|
exports.useInvalidateListUsers = useInvalidateListUsers;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuthAdmin.js","names":["authClient"],"sources":["../../../../../src/modules/auth/hooks/useAuthAdmin.ts"],"sourcesContent":["import {\r\n type AnyUseMutationOptions,\r\n useMutation,\r\n useQuery,\r\n useQueryClient,\r\n} from \"@tanstack/react-query\";\r\nimport { authClient } from \"../auth.lib\";\r\n\r\
|
|
1
|
+
{"version":3,"file":"useAuthAdmin.js","names":["authClient"],"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 { authClient } from \"../auth.lib\";\r\n\r\ntype ListUsersArgs = Parameters<typeof authClient.admin.listUsers>;\r\n\r\ntype ListUsersResult = Awaited<ReturnType<typeof 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` / Nuqs table URL state (page, limit, sort, order, q, filters).\r\n * Maps to Better Auth `listUsers` query payload.\r\n */\r\nexport interface ListUsersNuqsInput {\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 mapNuqsInputToListUsersArg(input: ListUsersNuqsInput): 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?: ListUsersNuqsInput): 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, mapNuqsInputToListUsersArg(input)] as const;\r\n}\r\n\r\n/**\r\n * Query options factory for use with `useQuery`, `useNuqsTable` / `useQueryWithParams`, or `queryClient.fetchQuery`.\r\n * Signature mirrors tRPC `procedure.queryOptions(input, opts?)`.\r\n */\r\nexport function listUsersQueryOptions(\r\n input: ListUsersNuqsInput,\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 = mapNuqsInputToListUsersArg(input);\r\n return {\r\n queryKey: listUsersQueryKey(input),\r\n queryFn: async (): Promise<ListUsersQueryData> => {\r\n const { data, error } = await authClient.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 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 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 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 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 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 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 return useMutation({\r\n mutationFn: () => authClient.admin.stopImpersonating(),\r\n ...options,\r\n });\r\n}\r\n"],"mappings":";;;;AAoBA,MAAa,4BAA4B;AAiBzC,SAAS,2BAA2B,OAA8C;CAChF,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,OAAgD;AAChF,KAAI,UAAU,KAAA,EACZ,QAAO,CAAC,0BAA0B;AAEpC,QAAO,CAAC,2BAA2B,2BAA2B,MAAM,CAAC;;;;;;AAOvE,SAAgB,sBACd,OACA,MAIoF;CACpF,MAAM,MAAM,2BAA2B,MAAM;AAC7C,QAAO;EACL,UAAU,kBAAkB,MAAM;EAClC,SAAS,YAAyC;GAChD,MAAM,EAAE,MAAM,UAAU,MAAMA,kCAAAA,WAAW,MAAM,UAAU,IAAI;AAC7D,OAAI,MAAO,QAAO,QAAQ,OAAO,MAAM;AACvC,OAAI,QAAQ,KACV,QAAO,QAAQ,uBAAO,IAAI,MAAM,6BAA6B,CAAC;AAEhE,UAAO;;EAET,GAAG;EACJ;;AAGH,SAAgB,yBAAyB,aAAyC;AAChF,QAAO,YAAY,kBAAkB,EAAE,UAAU,CAAC,0BAA0B,EAAE,CAAC;;AAGjF,SAAgB,uBAAuB,GAAG,MAAqB;CAC7D,MAAM,eAAA,GAAA,sBAAA,iBAA8B;AACpC,cAAa,YAAY,kBAAkB,EAAE,UAAU,CAAC,2BAA2B,GAAG,KAAK,EAAE,CAAC;;AAGhG,SAAgB,aAAa,GAAG,MAAqB;AACnD,SAAA,GAAA,sBAAA,UAAgB;EACd,UAAU,CAAC,2BAA2B,GAAG,KAAK;EAC9C,SAAS,YAAY;GACnB,MAAM,EAAE,MAAM,UAAU,MAAMA,kCAAAA,WAAW,MAAM,UAAU,GAAG,KAAK;AACjE,OAAI,MAAO,QAAO,QAAQ,OAAO,MAAM;AACvC,UAAO;;EAEV,CAAC;;AAGJ,SAAgB,cAAc,SAAgC;AAC5D,SAAA,GAAA,sBAAA,aAAmB;EACjB,aAAa,GAAG,SACdA,kCAAAA,WAAW,MAAM,WAAW,GAAG,KAAK;EACtC,GAAG;EACJ,CAAC;;AAGJ,SAAgB,cAAc,SAAgC;AAC5D,SAAA,GAAA,sBAAA,aAAmB;EACjB,aAAa,GAAG,SACdA,kCAAAA,WAAW,MAAM,WAAW,GAAG,KAAK;EACtC,GAAG;EACJ,CAAC;;AAGJ,SAAgB,WAAW,SAAgC;AACzD,SAAA,GAAA,sBAAA,aAAmB;EACjB,aAAa,GAAG,SACdA,kCAAAA,WAAW,MAAM,QAAQ,GAAG,KAAK;EACnC,GAAG;EACJ,CAAC;;AAGJ,SAAgB,aAAa,SAAgC;AAC3D,SAAA,GAAA,sBAAA,aAAmB;EACjB,aAAa,GAAG,SACdA,kCAAAA,WAAW,MAAM,UAAU,GAAG,KAAK;EACrC,GAAG;EACJ,CAAC;;AAGJ,SAAgB,mBAAmB,SAAgC;AACjE,SAAA,GAAA,sBAAA,aAAmB;EACjB,aAAa,GAAG,SACdA,kCAAAA,WAAW,MAAM,gBAAgB,GAAG,KAAK;EAC3C,GAAG;EACJ,CAAC;;AAGJ,SAAgB,qBAAqB,SAAgC;AACnE,SAAA,GAAA,sBAAA,aAAmB;EACjB,kBAAkBA,kCAAAA,WAAW,MAAM,mBAAmB;EACtD,GAAG;EACJ,CAAC"}
|
|
@@ -1,16 +1,55 @@
|
|
|
1
1
|
import { authClient } from "../auth.lib.mjs";
|
|
2
2
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
3
3
|
//#region src/modules/auth/hooks/useAuthAdmin.ts
|
|
4
|
+
const AUTH_ADMIN_LIST_USERS_KEY = "auth-admin-list-users";
|
|
5
|
+
function mapNuqsInputToListUsersArg(input) {
|
|
6
|
+
const page = Math.max(1, input.page);
|
|
7
|
+
return { query: {
|
|
8
|
+
searchField: "name",
|
|
9
|
+
searchOperator: "contains",
|
|
10
|
+
searchValue: input.q?.trim() ?? "",
|
|
11
|
+
limit: input.limit,
|
|
12
|
+
offset: (page - 1) * input.limit,
|
|
13
|
+
sortBy: input.sort ?? "createdAt",
|
|
14
|
+
sortDirection: input.order ?? "desc"
|
|
15
|
+
} };
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Query key factory (tRPC-style). Omit input to match all list-users queries for invalidation.
|
|
19
|
+
*/
|
|
20
|
+
function listUsersQueryKey(input) {
|
|
21
|
+
if (input === void 0) return [AUTH_ADMIN_LIST_USERS_KEY];
|
|
22
|
+
return [AUTH_ADMIN_LIST_USERS_KEY, mapNuqsInputToListUsersArg(input)];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Query options factory for use with `useQuery`, `useNuqsTable` / `useQueryWithParams`, or `queryClient.fetchQuery`.
|
|
26
|
+
* Signature mirrors tRPC `procedure.queryOptions(input, opts?)`.
|
|
27
|
+
*/
|
|
28
|
+
function listUsersQueryOptions(input, opts) {
|
|
29
|
+
const arg = mapNuqsInputToListUsersArg(input);
|
|
30
|
+
return {
|
|
31
|
+
queryKey: listUsersQueryKey(input),
|
|
32
|
+
queryFn: async () => {
|
|
33
|
+
const { data, error } = await authClient.admin.listUsers(arg);
|
|
34
|
+
if (error) return Promise.reject(error);
|
|
35
|
+
if (data == null) return Promise.reject(/* @__PURE__ */ new Error("listUsers returned no data"));
|
|
36
|
+
return data;
|
|
37
|
+
},
|
|
38
|
+
...opts
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function invalidateListUsersQuery(queryClient) {
|
|
42
|
+
return queryClient.invalidateQueries({ queryKey: [AUTH_ADMIN_LIST_USERS_KEY] });
|
|
43
|
+
}
|
|
4
44
|
function useInvalidateListUsers(...args) {
|
|
5
45
|
const queryClient = useQueryClient();
|
|
6
|
-
return () => queryClient.invalidateQueries({ queryKey: [
|
|
46
|
+
return () => queryClient.invalidateQueries({ queryKey: [AUTH_ADMIN_LIST_USERS_KEY, ...args] });
|
|
7
47
|
}
|
|
8
48
|
function useListUsers(...args) {
|
|
9
49
|
return useQuery({
|
|
10
|
-
queryKey: [
|
|
11
|
-
queryFn: async (
|
|
12
|
-
const
|
|
13
|
-
const { data, error } = await authClient.admin.listUsers(...listUserArgs);
|
|
50
|
+
queryKey: [AUTH_ADMIN_LIST_USERS_KEY, ...args],
|
|
51
|
+
queryFn: async () => {
|
|
52
|
+
const { data, error } = await authClient.admin.listUsers(...args);
|
|
14
53
|
if (error) return Promise.reject(error);
|
|
15
54
|
return data;
|
|
16
55
|
}
|
|
@@ -53,6 +92,6 @@ function useStopImpersonating(options) {
|
|
|
53
92
|
});
|
|
54
93
|
}
|
|
55
94
|
//#endregion
|
|
56
|
-
export { useBanUser, useImpersonateUser, useInvalidateListUsers, useListUsers, useRemoveUser, useStopImpersonating, useUnbanUser, useUpdateUser };
|
|
95
|
+
export { AUTH_ADMIN_LIST_USERS_KEY, invalidateListUsersQuery, listUsersQueryKey, listUsersQueryOptions, useBanUser, useImpersonateUser, useInvalidateListUsers, useListUsers, useRemoveUser, useStopImpersonating, useUnbanUser, useUpdateUser };
|
|
57
96
|
|
|
58
97
|
//# sourceMappingURL=useAuthAdmin.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuthAdmin.mjs","names":[],"sources":["../../../../../src/modules/auth/hooks/useAuthAdmin.ts"],"sourcesContent":["import {\r\n type AnyUseMutationOptions,\r\n useMutation,\r\n useQuery,\r\n useQueryClient,\r\n} from \"@tanstack/react-query\";\r\nimport { authClient } from \"../auth.lib\";\r\n\r\
|
|
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 { authClient } from \"../auth.lib\";\r\n\r\ntype ListUsersArgs = Parameters<typeof authClient.admin.listUsers>;\r\n\r\ntype ListUsersResult = Awaited<ReturnType<typeof 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` / Nuqs table URL state (page, limit, sort, order, q, filters).\r\n * Maps to Better Auth `listUsers` query payload.\r\n */\r\nexport interface ListUsersNuqsInput {\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 mapNuqsInputToListUsersArg(input: ListUsersNuqsInput): 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?: ListUsersNuqsInput): 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, mapNuqsInputToListUsersArg(input)] as const;\r\n}\r\n\r\n/**\r\n * Query options factory for use with `useQuery`, `useNuqsTable` / `useQueryWithParams`, or `queryClient.fetchQuery`.\r\n * Signature mirrors tRPC `procedure.queryOptions(input, opts?)`.\r\n */\r\nexport function listUsersQueryOptions(\r\n input: ListUsersNuqsInput,\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 = mapNuqsInputToListUsersArg(input);\r\n return {\r\n queryKey: listUsersQueryKey(input),\r\n queryFn: async (): Promise<ListUsersQueryData> => {\r\n const { data, error } = await authClient.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 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 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 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 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 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 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 return useMutation({\r\n mutationFn: () => authClient.admin.stopImpersonating(),\r\n ...options,\r\n });\r\n}\r\n"],"mappings":";;;AAoBA,MAAa,4BAA4B;AAiBzC,SAAS,2BAA2B,OAA8C;CAChF,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,OAAgD;AAChF,KAAI,UAAU,KAAA,EACZ,QAAO,CAAC,0BAA0B;AAEpC,QAAO,CAAC,2BAA2B,2BAA2B,MAAM,CAAC;;;;;;AAOvE,SAAgB,sBACd,OACA,MAIoF;CACpF,MAAM,MAAM,2BAA2B,MAAM;AAC7C,QAAO;EACL,UAAU,k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AgB,mBAAmB,SAAgC;AACjE,QAAO,YAAY;EACjB,aAAa,GAAG,SACd,WAAW,MAAM,gBAAgB,GAAG,KAAK;EAC3C,GAAG;EACJ,CAAC;;AAGJ,SAAgB,qBAAqB,SAAgC;AACnE,QAAO,YAAY;EACjB,kBAAkB,WAAW,MAAM,mBAAmB;EACtD,GAAG;EACJ,CAAC"}
|
|
@@ -31,6 +31,9 @@ declare function useSession(): {
|
|
|
31
31
|
activeOrganizationId?: string | null | undefined;
|
|
32
32
|
activeTeamId?: string | null | undefined;
|
|
33
33
|
impersonatedBy?: string | null | undefined;
|
|
34
|
+
activeTeamRole?: string | null | undefined;
|
|
35
|
+
activeOrganizationRole?: string | null | undefined;
|
|
36
|
+
activeOrganizationType?: string | null | undefined;
|
|
34
37
|
};
|
|
35
38
|
} | null) | null;
|
|
36
39
|
signOut: () => void;
|
|
@@ -31,6 +31,9 @@ declare function useSession(): {
|
|
|
31
31
|
activeOrganizationId?: string | null | undefined;
|
|
32
32
|
activeTeamId?: string | null | undefined;
|
|
33
33
|
impersonatedBy?: string | null | undefined;
|
|
34
|
+
activeTeamRole?: string | null | undefined;
|
|
35
|
+
activeOrganizationRole?: string | null | undefined;
|
|
36
|
+
activeOrganizationType?: string | null | undefined;
|
|
34
37
|
};
|
|
35
38
|
} | null) | null;
|
|
36
39
|
signOut: () => void;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as _$_tanstack_react_query0 from "@tanstack/react-query";
|
|
2
|
+
import * as _$_trpc_client0 from "@trpc/client";
|
|
3
|
+
import * as _$_trpc_server0 from "@trpc/server";
|
|
4
|
+
|
|
5
|
+
//#region src/modules/auth/hooks/useUserOrganizations.d.ts
|
|
6
|
+
declare const useUserOrganizations: () => _$_tanstack_react_query0.UseQueryResult<{
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
type: string | null;
|
|
10
|
+
createdAt: Date;
|
|
11
|
+
slug: string | null;
|
|
12
|
+
logo: string | null;
|
|
13
|
+
parentId: string | null;
|
|
14
|
+
}[], _$_trpc_client0.TRPCClientErrorLike<{
|
|
15
|
+
transformer: true;
|
|
16
|
+
errorShape: _$_trpc_server0.TRPCDefaultErrorShape;
|
|
17
|
+
}>>;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { useUserOrganizations };
|
|
20
|
+
//# sourceMappingURL=useUserOrganizations.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useUserOrganizations.d.mts","names":[],"sources":["../../../../../src/modules/auth/hooks/useUserOrganizations.ts"],"mappings":";;;;;cAKa,oBAAA,iCAAoB,cAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as _$_tanstack_react_query0 from "@tanstack/react-query";
|
|
2
|
+
import * as _$_trpc_client0 from "@trpc/client";
|
|
3
|
+
import * as _$_trpc_server0 from "@trpc/server";
|
|
4
|
+
|
|
5
|
+
//#region src/modules/auth/hooks/useUserOrganizations.d.ts
|
|
6
|
+
declare const useUserOrganizations: () => _$_tanstack_react_query0.UseQueryResult<{
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
type: string | null;
|
|
10
|
+
createdAt: Date;
|
|
11
|
+
slug: string | null;
|
|
12
|
+
logo: string | null;
|
|
13
|
+
parentId: string | null;
|
|
14
|
+
}[], _$_trpc_client0.TRPCClientErrorLike<{
|
|
15
|
+
transformer: true;
|
|
16
|
+
errorShape: _$_trpc_server0.TRPCDefaultErrorShape;
|
|
17
|
+
}>>;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { useUserOrganizations };
|
|
20
|
+
//# sourceMappingURL=useUserOrganizations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useUserOrganizations.d.ts","names":[],"sources":["../../../../../src/modules/auth/hooks/useUserOrganizations.ts"],"mappings":";;;;;cAKa,oBAAA,iCAAoB,cAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_src_modules_app_hooks_useAppTrpc = require("../../app/hooks/useAppTrpc.js");
|
|
3
|
+
const require_src_modules_auth_hooks_useSession = require("./useSession.js");
|
|
4
|
+
let _tanstack_react_query = require("@tanstack/react-query");
|
|
5
|
+
//#region src/modules/auth/hooks/useUserOrganizations.ts
|
|
6
|
+
const useUserOrganizations = () => {
|
|
7
|
+
const trpc = require_src_modules_app_hooks_useAppTrpc.useAppTRPC();
|
|
8
|
+
const { data, isLoading } = require_src_modules_auth_hooks_useSession.useSession();
|
|
9
|
+
return (0, _tanstack_react_query.useQuery)(trpc.auth.listUserOrganizations.queryOptions(void 0, { enabled: !isLoading && Boolean(data?.session.userId) }));
|
|
10
|
+
};
|
|
11
|
+
//#endregion
|
|
12
|
+
exports.useUserOrganizations = useUserOrganizations;
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=useUserOrganizations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useUserOrganizations.js","names":["useAppTRPC","useSession"],"sources":["../../../../../src/modules/auth/hooks/useUserOrganizations.ts"],"sourcesContent":["import type { BackendTRPCRouter } from \"@m5kdev/backend/types\";\r\nimport { useSession } from \"./useSession\";\r\nimport { useQuery } from \"@tanstack/react-query\";\r\nimport { useAppTRPC } from \"../../app/hooks/useAppTrpc\";\r\n\r\nexport const useUserOrganizations = () => {\r\n const trpc = useAppTRPC<BackendTRPCRouter>();\r\n const { data, isLoading } = useSession();\r\n return useQuery(\r\n trpc.auth.listUserOrganizations.queryOptions(undefined, {\r\n enabled: !isLoading && Boolean(data?.session.userId),\r\n })\r\n );\r\n};\r\n"],"mappings":";;;;;AAKA,MAAa,6BAA6B;CACxC,MAAM,OAAOA,yCAAAA,YAA+B;CAC5C,MAAM,EAAE,MAAM,cAAcC,0CAAAA,YAAY;AACxC,SAAA,GAAA,sBAAA,UACE,KAAK,KAAK,sBAAsB,aAAa,KAAA,GAAW,EACtD,SAAS,CAAC,aAAa,QAAQ,MAAM,QAAQ,OAAO,EACrD,CAAC,CACH"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useAppTRPC } from "../../app/hooks/useAppTrpc.mjs";
|
|
2
|
+
import { useSession } from "./useSession.mjs";
|
|
3
|
+
import { useQuery } from "@tanstack/react-query";
|
|
4
|
+
//#region src/modules/auth/hooks/useUserOrganizations.ts
|
|
5
|
+
const useUserOrganizations = () => {
|
|
6
|
+
const trpc = useAppTRPC();
|
|
7
|
+
const { data, isLoading } = useSession();
|
|
8
|
+
return useQuery(trpc.auth.listUserOrganizations.queryOptions(void 0, { enabled: !isLoading && Boolean(data?.session.userId) }));
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { useUserOrganizations };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=useUserOrganizations.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useUserOrganizations.mjs","names":[],"sources":["../../../../../src/modules/auth/hooks/useUserOrganizations.ts"],"sourcesContent":["import type { BackendTRPCRouter } from \"@m5kdev/backend/types\";\r\nimport { useSession } from \"./useSession\";\r\nimport { useQuery } from \"@tanstack/react-query\";\r\nimport { useAppTRPC } from \"../../app/hooks/useAppTrpc\";\r\n\r\nexport const useUserOrganizations = () => {\r\n const trpc = useAppTRPC<BackendTRPCRouter>();\r\n const { data, isLoading } = useSession();\r\n return useQuery(\r\n trpc.auth.listUserOrganizations.queryOptions(undefined, {\r\n enabled: !isLoading && Boolean(data?.session.userId),\r\n })\r\n );\r\n};\r\n"],"mappings":";;;;AAKA,MAAa,6BAA6B;CACxC,MAAM,OAAO,YAA+B;CAC5C,MAAM,EAAE,MAAM,cAAc,YAAY;AACxC,QAAO,SACL,KAAK,KAAK,sBAAsB,aAAa,KAAA,GAAW,EACtD,SAAS,CAAC,aAAa,QAAQ,MAAM,QAAQ,OAAO,EACrD,CAAC,CACH"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@m5kdev/frontend",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.5",
|
|
4
4
|
"license": "GPL-3.0-only",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"react": "19.2.1",
|
|
27
27
|
"react-dom": "19.2.1",
|
|
28
28
|
"zod": "4.2.1",
|
|
29
|
-
"@m5kdev/commons": "0.
|
|
29
|
+
"@m5kdev/commons": "0.20.5"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"@trpc/server": "11.4.3"
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
"@trpc/server": "11.4.3",
|
|
40
40
|
"globals": "16.3.0",
|
|
41
41
|
"tsdown": "0.21.7",
|
|
42
|
-
"typescript": "
|
|
42
|
+
"typescript": "6.0.3",
|
|
43
43
|
"vite": "7.0.4",
|
|
44
|
-
"@m5kdev/config": "0.
|
|
45
|
-
"@m5kdev/backend": "0.
|
|
44
|
+
"@m5kdev/config": "0.20.5",
|
|
45
|
+
"@m5kdev/backend": "0.20.5"
|
|
46
46
|
},
|
|
47
47
|
"exports": {
|
|
48
48
|
"./modules/app/components/*": {
|