@voyantjs/auth-react 0.2.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/README.md +23 -0
- package/dist/client.d.ts +16 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +81 -0
- package/dist/hooks/index.d.ts +9 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +8 -0
- package/dist/hooks/use-auth-status.d.ts +9 -0
- package/dist/hooks/use-auth-status.d.ts.map +1 -0
- package/dist/hooks/use-auth-status.js +12 -0
- package/dist/hooks/use-current-user.d.ts +15 -0
- package/dist/hooks/use-current-user.d.ts.map +1 -0
- package/dist/hooks/use-current-user.js +12 -0
- package/dist/hooks/use-current-workspace.d.ts +18 -0
- package/dist/hooks/use-current-workspace.d.ts.map +1 -0
- package/dist/hooks/use-current-workspace.js +12 -0
- package/dist/hooks/use-organization-invitation-mutation.d.ts +36 -0
- package/dist/hooks/use-organization-invitation-mutation.d.ts.map +1 -0
- package/dist/hooks/use-organization-invitation-mutation.js +23 -0
- package/dist/hooks/use-organization-invitations.d.ts +17 -0
- package/dist/hooks/use-organization-invitations.d.ts.map +1 -0
- package/dist/hooks/use-organization-invitations.js +12 -0
- package/dist/hooks/use-organization-member-mutation.d.ts +44 -0
- package/dist/hooks/use-organization-member-mutation.d.ts.map +1 -0
- package/dist/hooks/use-organization-member-mutation.js +25 -0
- package/dist/hooks/use-organization-members.d.ts +23 -0
- package/dist/hooks/use-organization-members.d.ts.map +1 -0
- package/dist/hooks/use-organization-members.js +12 -0
- package/dist/hooks/use-workspace-mutation.d.ts +28 -0
- package/dist/hooks/use-workspace-mutation.d.ts.map +1 -0
- package/dist/hooks/use-workspace-mutation.js +27 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/provider.d.ts +2 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +1 -0
- package/dist/query-keys.d.ts +25 -0
- package/dist/query-keys.d.ts.map +1 -0
- package/dist/query-keys.js +10 -0
- package/dist/query-options.d.ts +256 -0
- package/dist/query-options.d.ts.map +1 -0
- package/dist/query-options.js +35 -0
- package/dist/schemas.d.ts +130 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +68 -0
- package/package.json +79 -0
package/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# @voyantjs/auth-react
|
|
2
|
+
|
|
3
|
+
React runtime package for Voyant authentication and workspace state.
|
|
4
|
+
|
|
5
|
+
This package wraps the shared Voyant auth HTTP contract:
|
|
6
|
+
|
|
7
|
+
- `/auth/me`
|
|
8
|
+
- `/auth/status`
|
|
9
|
+
- `/auth/workspace`
|
|
10
|
+
- `/auth/workspace/active-organization`
|
|
11
|
+
- `/auth/organization/list-members`
|
|
12
|
+
- `/auth/organization/list-invitations`
|
|
13
|
+
- `/auth/organization/invite-member`
|
|
14
|
+
- `/auth/organization/update-member-role`
|
|
15
|
+
- `/auth/organization/remove-member`
|
|
16
|
+
- `/auth/organization/cancel-invitation`
|
|
17
|
+
|
|
18
|
+
It provides reusable React surfaces for:
|
|
19
|
+
|
|
20
|
+
- current user and workspace state
|
|
21
|
+
- organization member listing
|
|
22
|
+
- organization invitation listing
|
|
23
|
+
- invite, cancel, remove, and role update mutations
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
export type VoyantFetcher = (url: string, init?: RequestInit) => Promise<Response>;
|
|
3
|
+
export declare const defaultFetcher: VoyantFetcher;
|
|
4
|
+
export declare class VoyantApiError extends Error {
|
|
5
|
+
readonly status: number;
|
|
6
|
+
readonly body: unknown;
|
|
7
|
+
constructor(message: string, status: number, body: unknown);
|
|
8
|
+
}
|
|
9
|
+
export interface FetchWithValidationOptions {
|
|
10
|
+
baseUrl: string;
|
|
11
|
+
fetcher: VoyantFetcher;
|
|
12
|
+
}
|
|
13
|
+
export type QueryParamValue = string | number | boolean | null | undefined | Array<string | number | boolean>;
|
|
14
|
+
export declare function fetchWithValidation<TOut>(path: string, schema: z.ZodType<TOut>, options: FetchWithValidationOptions, init?: RequestInit): Promise<TOut>;
|
|
15
|
+
export declare function withQueryParams(path: string, query?: object): string;
|
|
16
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAE5B,MAAM,MAAM,aAAa,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;AAElF,eAAO,MAAM,cAAc,EAAE,aACoB,CAAA;AAEjD,qBAAa,cAAe,SAAQ,KAAK;IACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;gBAEV,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO;CAM3D;AAaD,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,aAAa,CAAA;CACvB;AAED,MAAM,MAAM,eAAe,GACvB,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,GACT,KAAK,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAA;AAEpC,wBAAsB,mBAAmB,CAAC,IAAI,EAC5C,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EACvB,OAAO,EAAE,0BAA0B,EACnC,IAAI,CAAC,EAAE,WAAW,GACjB,OAAO,CAAC,IAAI,CAAC,CA8Bf;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CA4BpE"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export const defaultFetcher = (url, init) => fetch(url, { credentials: "include", ...init });
|
|
2
|
+
export class VoyantApiError extends Error {
|
|
3
|
+
status;
|
|
4
|
+
body;
|
|
5
|
+
constructor(message, status, body) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = "VoyantApiError";
|
|
8
|
+
this.status = status;
|
|
9
|
+
this.body = body;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function extractErrorMessage(status, statusText, body) {
|
|
13
|
+
if (typeof body === "object" && body !== null && "error" in body) {
|
|
14
|
+
const err = body.error;
|
|
15
|
+
if (typeof err === "string")
|
|
16
|
+
return err;
|
|
17
|
+
if (typeof err === "object" && err !== null && "message" in err) {
|
|
18
|
+
return String(err.message);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return `Voyant API error: ${status} ${statusText}`;
|
|
22
|
+
}
|
|
23
|
+
export async function fetchWithValidation(path, schema, options, init) {
|
|
24
|
+
const url = joinUrl(options.baseUrl, path);
|
|
25
|
+
const headers = new Headers(init?.headers);
|
|
26
|
+
if (init?.body !== undefined && !headers.has("Content-Type")) {
|
|
27
|
+
headers.set("Content-Type", "application/json");
|
|
28
|
+
}
|
|
29
|
+
const response = await options.fetcher(url, { ...init, headers });
|
|
30
|
+
if (!response.ok) {
|
|
31
|
+
const body = await safeJson(response);
|
|
32
|
+
throw new VoyantApiError(extractErrorMessage(response.status, response.statusText, body), response.status, body);
|
|
33
|
+
}
|
|
34
|
+
if (response.status === 204)
|
|
35
|
+
return schema.parse(undefined);
|
|
36
|
+
const body = await safeJson(response);
|
|
37
|
+
const parsed = schema.safeParse(body);
|
|
38
|
+
if (!parsed.success) {
|
|
39
|
+
throw new VoyantApiError(`Voyant API response failed validation: ${parsed.error.message}`, response.status, body);
|
|
40
|
+
}
|
|
41
|
+
return parsed.data;
|
|
42
|
+
}
|
|
43
|
+
export function withQueryParams(path, query) {
|
|
44
|
+
if (!query) {
|
|
45
|
+
return path;
|
|
46
|
+
}
|
|
47
|
+
const params = new URLSearchParams();
|
|
48
|
+
for (const [key, value] of Object.entries(query)) {
|
|
49
|
+
if (value === undefined || value === null) {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (Array.isArray(value)) {
|
|
53
|
+
for (const item of value) {
|
|
54
|
+
params.append(key, String(item));
|
|
55
|
+
}
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
params.set(key, String(value));
|
|
59
|
+
}
|
|
60
|
+
const serialized = params.toString();
|
|
61
|
+
if (!serialized) {
|
|
62
|
+
return path;
|
|
63
|
+
}
|
|
64
|
+
return `${path}?${serialized}`;
|
|
65
|
+
}
|
|
66
|
+
async function safeJson(response) {
|
|
67
|
+
const text = await response.text();
|
|
68
|
+
if (!text)
|
|
69
|
+
return undefined;
|
|
70
|
+
try {
|
|
71
|
+
return JSON.parse(text);
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
return text;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function joinUrl(baseUrl, path) {
|
|
78
|
+
const trimmedBase = baseUrl.endsWith("/") ? baseUrl.slice(0, -1) : baseUrl;
|
|
79
|
+
const trimmedPath = path.startsWith("/") ? path : `/${path}`;
|
|
80
|
+
return `${trimmedBase}${trimmedPath}`;
|
|
81
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { type UseAuthStatusOptions, useAuthStatus } from "./use-auth-status.js";
|
|
2
|
+
export { type UseCurrentUserOptions, useCurrentUser } from "./use-current-user.js";
|
|
3
|
+
export { type UseCurrentWorkspaceOptions, useCurrentWorkspace } from "./use-current-workspace.js";
|
|
4
|
+
export { type CancelOrganizationInvitationInput, type InviteOrganizationMemberInput, useOrganizationInvitationMutation, } from "./use-organization-invitation-mutation.js";
|
|
5
|
+
export { type UseOrganizationInvitationsOptions, useOrganizationInvitations, } from "./use-organization-invitations.js";
|
|
6
|
+
export { type RemoveOrganizationMemberInput, type UpdateOrganizationMemberRoleInput, useOrganizationMemberMutation, } from "./use-organization-member-mutation.js";
|
|
7
|
+
export { type UseOrganizationMembersOptions, useOrganizationMembers, } from "./use-organization-members.js";
|
|
8
|
+
export { useWorkspaceMutation } from "./use-workspace-mutation.js";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,oBAAoB,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAC/E,OAAO,EAAE,KAAK,qBAAqB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAClF,OAAO,EAAE,KAAK,0BAA0B,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AACjG,OAAO,EACL,KAAK,iCAAiC,EACtC,KAAK,6BAA6B,EAClC,iCAAiC,GAClC,MAAM,2CAA2C,CAAA;AAClD,OAAO,EACL,KAAK,iCAAiC,EACtC,0BAA0B,GAC3B,MAAM,mCAAmC,CAAA;AAC1C,OAAO,EACL,KAAK,6BAA6B,EAClC,KAAK,iCAAiC,EACtC,6BAA6B,GAC9B,MAAM,uCAAuC,CAAA;AAC9C,OAAO,EACL,KAAK,6BAA6B,EAClC,sBAAsB,GACvB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { useAuthStatus } from "./use-auth-status.js";
|
|
2
|
+
export { useCurrentUser } from "./use-current-user.js";
|
|
3
|
+
export { useCurrentWorkspace } from "./use-current-workspace.js";
|
|
4
|
+
export { useOrganizationInvitationMutation, } from "./use-organization-invitation-mutation.js";
|
|
5
|
+
export { useOrganizationInvitations, } from "./use-organization-invitations.js";
|
|
6
|
+
export { useOrganizationMemberMutation, } from "./use-organization-member-mutation.js";
|
|
7
|
+
export { useOrganizationMembers, } from "./use-organization-members.js";
|
|
8
|
+
export { useWorkspaceMutation } from "./use-workspace-mutation.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface UseAuthStatusOptions {
|
|
2
|
+
enabled?: boolean;
|
|
3
|
+
}
|
|
4
|
+
export declare function useAuthStatus(options?: UseAuthStatusOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
5
|
+
userExists: boolean;
|
|
6
|
+
authenticated: boolean;
|
|
7
|
+
reason?: string | undefined;
|
|
8
|
+
}, Error>;
|
|
9
|
+
//# sourceMappingURL=use-auth-status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-auth-status.d.ts","sourceRoot":"","sources":["../../src/hooks/use-auth-status.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,oBAAoB;IACnC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,aAAa,CAAC,OAAO,GAAE,oBAAyB;;;;UAQ/D"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantAuthContext } from "../provider.js";
|
|
4
|
+
import { getAuthStatusQueryOptions } from "../query-options.js";
|
|
5
|
+
export function useAuthStatus(options = {}) {
|
|
6
|
+
const { baseUrl, fetcher } = useVoyantAuthContext();
|
|
7
|
+
const { enabled = true } = options;
|
|
8
|
+
return useQuery({
|
|
9
|
+
...getAuthStatusQueryOptions({ baseUrl, fetcher }),
|
|
10
|
+
enabled,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface UseCurrentUserOptions {
|
|
2
|
+
enabled?: boolean;
|
|
3
|
+
}
|
|
4
|
+
export declare function useCurrentUser(options?: UseCurrentUserOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
5
|
+
id: string;
|
|
6
|
+
email: string;
|
|
7
|
+
firstName: string | null;
|
|
8
|
+
lastName: string | null;
|
|
9
|
+
isSuperAdmin: boolean;
|
|
10
|
+
isSupportUser: boolean;
|
|
11
|
+
createdAt: string;
|
|
12
|
+
profilePictureUrl?: string | null | undefined;
|
|
13
|
+
activeOrganizationId?: string | null | undefined;
|
|
14
|
+
}, Error>;
|
|
15
|
+
//# sourceMappingURL=use-current-user.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-current-user.d.ts","sourceRoot":"","sources":["../../src/hooks/use-current-user.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,qBAAqB;IACpC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,cAAc,CAAC,OAAO,GAAE,qBAA0B;;;;;;;;;;UAQjE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantAuthContext } from "../provider.js";
|
|
4
|
+
import { getCurrentUserQueryOptions } from "../query-options.js";
|
|
5
|
+
export function useCurrentUser(options = {}) {
|
|
6
|
+
const { baseUrl, fetcher } = useVoyantAuthContext();
|
|
7
|
+
const { enabled = true } = options;
|
|
8
|
+
return useQuery({
|
|
9
|
+
...getCurrentUserQueryOptions({ baseUrl, fetcher }),
|
|
10
|
+
enabled,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface UseCurrentWorkspaceOptions {
|
|
2
|
+
enabled?: boolean;
|
|
3
|
+
}
|
|
4
|
+
export declare function useCurrentWorkspace(options?: UseCurrentWorkspaceOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
5
|
+
organizations: {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
slug: string;
|
|
9
|
+
logo?: string | null | undefined;
|
|
10
|
+
}[];
|
|
11
|
+
activeOrganization: {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
slug: string;
|
|
15
|
+
logo?: string | null | undefined;
|
|
16
|
+
} | null;
|
|
17
|
+
}, Error>;
|
|
18
|
+
//# sourceMappingURL=use-current-workspace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-current-workspace.d.ts","sourceRoot":"","sources":["../../src/hooks/use-current-workspace.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,0BAA0B;IACzC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,0BAA+B;;;;;;;;;;;;;UAQ3E"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantAuthContext } from "../provider.js";
|
|
4
|
+
import { getCurrentWorkspaceQueryOptions } from "../query-options.js";
|
|
5
|
+
export function useCurrentWorkspace(options = {}) {
|
|
6
|
+
const { baseUrl, fetcher } = useVoyantAuthContext();
|
|
7
|
+
const { enabled = true } = options;
|
|
8
|
+
return useQuery({
|
|
9
|
+
...getCurrentWorkspaceQueryOptions({ baseUrl, fetcher }),
|
|
10
|
+
enabled,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
import { type organizationRoleSchema } from "../schemas.js";
|
|
3
|
+
export interface InviteOrganizationMemberInput {
|
|
4
|
+
email: string;
|
|
5
|
+
role: z.input<typeof organizationRoleSchema>;
|
|
6
|
+
organizationId?: string | undefined;
|
|
7
|
+
resend?: boolean | undefined;
|
|
8
|
+
}
|
|
9
|
+
export interface CancelOrganizationInvitationInput {
|
|
10
|
+
invitationId: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function useOrganizationInvitationMutation(): {
|
|
13
|
+
invite: import("@tanstack/react-query").UseMutationResult<{
|
|
14
|
+
id: string;
|
|
15
|
+
organizationId: string;
|
|
16
|
+
email: string;
|
|
17
|
+
role: string | string[];
|
|
18
|
+
status: "pending" | "accepted" | "rejected" | "canceled";
|
|
19
|
+
inviterId: string;
|
|
20
|
+
expiresAt: string;
|
|
21
|
+
createdAt: string;
|
|
22
|
+
teamId?: string | undefined;
|
|
23
|
+
}, Error, InviteOrganizationMemberInput, unknown>;
|
|
24
|
+
cancel: import("@tanstack/react-query").UseMutationResult<{
|
|
25
|
+
id: string;
|
|
26
|
+
organizationId: string;
|
|
27
|
+
email: string;
|
|
28
|
+
role: string | string[];
|
|
29
|
+
status: "pending" | "accepted" | "rejected" | "canceled";
|
|
30
|
+
inviterId: string;
|
|
31
|
+
expiresAt: string;
|
|
32
|
+
createdAt: string;
|
|
33
|
+
teamId?: string | undefined;
|
|
34
|
+
} | null, Error, CancelOrganizationInvitationInput, unknown>;
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=use-organization-invitation-mutation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-organization-invitation-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-organization-invitation-mutation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAK5B,OAAO,EAAgC,KAAK,sBAAsB,EAAE,MAAM,eAAe,CAAA;AAEzF,MAAM,WAAW,6BAA6B;IAC5C,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAA;IAC5C,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACnC,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAC7B;AAED,MAAM,WAAW,iCAAiC;IAChD,YAAY,EAAE,MAAM,CAAA;CACrB;AAED,wBAAgB,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;EA+BhD"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { fetchWithValidation } from "../client.js";
|
|
4
|
+
import { useVoyantAuthContext } from "../provider.js";
|
|
5
|
+
import { authQueryKeys } from "../query-keys.js";
|
|
6
|
+
import { organizationInvitationSchema } from "../schemas.js";
|
|
7
|
+
export function useOrganizationInvitationMutation() {
|
|
8
|
+
const { baseUrl, fetcher } = useVoyantAuthContext();
|
|
9
|
+
const queryClient = useQueryClient();
|
|
10
|
+
const invite = useMutation({
|
|
11
|
+
mutationFn: async (input) => fetchWithValidation("/auth/organization/invite-member", organizationInvitationSchema, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) }),
|
|
12
|
+
onSuccess: () => {
|
|
13
|
+
void queryClient.invalidateQueries({ queryKey: authQueryKeys.organizationInvitations() });
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
const cancel = useMutation({
|
|
17
|
+
mutationFn: async (input) => fetchWithValidation("/auth/organization/cancel-invitation", organizationInvitationSchema.nullable(), { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) }),
|
|
18
|
+
onSuccess: () => {
|
|
19
|
+
void queryClient.invalidateQueries({ queryKey: authQueryKeys.organizationInvitations() });
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
return { invite, cancel };
|
|
23
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { OrganizationInvitationsListFilters } from "../query-keys.js";
|
|
2
|
+
export interface UseOrganizationInvitationsOptions {
|
|
3
|
+
filters?: OrganizationInvitationsListFilters;
|
|
4
|
+
enabled?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare function useOrganizationInvitations(options?: UseOrganizationInvitationsOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
7
|
+
id: string;
|
|
8
|
+
organizationId: string;
|
|
9
|
+
email: string;
|
|
10
|
+
role: string | string[];
|
|
11
|
+
status: "pending" | "accepted" | "rejected" | "canceled";
|
|
12
|
+
inviterId: string;
|
|
13
|
+
expiresAt: string;
|
|
14
|
+
createdAt: string;
|
|
15
|
+
teamId?: string | undefined;
|
|
16
|
+
}[], Error>;
|
|
17
|
+
//# sourceMappingURL=use-organization-invitations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-organization-invitations.d.ts","sourceRoot":"","sources":["../../src/hooks/use-organization-invitations.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,kBAAkB,CAAA;AAG1E,MAAM,WAAW,iCAAiC;IAChD,OAAO,CAAC,EAAE,kCAAkC,CAAA;IAC5C,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,0BAA0B,CAAC,OAAO,GAAE,iCAAsC;;;;;;;;;;YAQzF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantAuthContext } from "../provider.js";
|
|
4
|
+
import { getOrganizationInvitationsQueryOptions } from "../query-options.js";
|
|
5
|
+
export function useOrganizationInvitations(options = {}) {
|
|
6
|
+
const { baseUrl, fetcher } = useVoyantAuthContext();
|
|
7
|
+
const { filters = {}, enabled = true } = options;
|
|
8
|
+
return useQuery({
|
|
9
|
+
...getOrganizationInvitationsQueryOptions(filters, { baseUrl, fetcher }),
|
|
10
|
+
enabled,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
import { type organizationRoleSchema } from "../schemas.js";
|
|
3
|
+
export interface UpdateOrganizationMemberRoleInput {
|
|
4
|
+
memberId: string;
|
|
5
|
+
role: z.input<typeof organizationRoleSchema>;
|
|
6
|
+
organizationId?: string | undefined;
|
|
7
|
+
}
|
|
8
|
+
export interface RemoveOrganizationMemberInput {
|
|
9
|
+
memberIdOrEmail: string;
|
|
10
|
+
organizationId?: string | undefined;
|
|
11
|
+
}
|
|
12
|
+
export declare function useOrganizationMemberMutation(): {
|
|
13
|
+
updateRole: import("@tanstack/react-query").UseMutationResult<{
|
|
14
|
+
id: string;
|
|
15
|
+
organizationId: string;
|
|
16
|
+
userId: string;
|
|
17
|
+
role: string | string[];
|
|
18
|
+
createdAt: string;
|
|
19
|
+
user: {
|
|
20
|
+
id: string;
|
|
21
|
+
email: string;
|
|
22
|
+
name: string;
|
|
23
|
+
image?: string | null | undefined;
|
|
24
|
+
};
|
|
25
|
+
teamId?: string | undefined;
|
|
26
|
+
}, Error, UpdateOrganizationMemberRoleInput, unknown>;
|
|
27
|
+
remove: import("@tanstack/react-query").UseMutationResult<{
|
|
28
|
+
member: {
|
|
29
|
+
id: string;
|
|
30
|
+
organizationId: string;
|
|
31
|
+
userId: string;
|
|
32
|
+
role: string | string[];
|
|
33
|
+
createdAt: string;
|
|
34
|
+
user: {
|
|
35
|
+
id: string;
|
|
36
|
+
email: string;
|
|
37
|
+
name: string;
|
|
38
|
+
image?: string | null | undefined;
|
|
39
|
+
};
|
|
40
|
+
teamId?: string | undefined;
|
|
41
|
+
};
|
|
42
|
+
}, Error, RemoveOrganizationMemberInput, unknown>;
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=use-organization-member-mutation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-organization-member-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-organization-member-mutation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAK5B,OAAO,EAGL,KAAK,sBAAsB,EAC5B,MAAM,eAAe,CAAA;AAEtB,MAAM,WAAW,iCAAiC;IAChD,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAA;IAC5C,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CACpC;AAED,MAAM,WAAW,6BAA6B;IAC5C,eAAe,EAAE,MAAM,CAAA;IACvB,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CACpC;AAED,wBAAgB,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiC5C"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { fetchWithValidation } from "../client.js";
|
|
4
|
+
import { useVoyantAuthContext } from "../provider.js";
|
|
5
|
+
import { authQueryKeys } from "../query-keys.js";
|
|
6
|
+
import { organizationMemberSchema, organizationRemoveMemberSchema, } from "../schemas.js";
|
|
7
|
+
export function useOrganizationMemberMutation() {
|
|
8
|
+
const { baseUrl, fetcher } = useVoyantAuthContext();
|
|
9
|
+
const queryClient = useQueryClient();
|
|
10
|
+
const updateRole = useMutation({
|
|
11
|
+
mutationFn: async (input) => fetchWithValidation("/auth/organization/update-member-role", organizationMemberSchema, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) }),
|
|
12
|
+
onSuccess: () => {
|
|
13
|
+
void queryClient.invalidateQueries({ queryKey: authQueryKeys.organizationMembers() });
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
const remove = useMutation({
|
|
17
|
+
mutationFn: async (input) => fetchWithValidation("/auth/organization/remove-member", organizationRemoveMemberSchema, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) }),
|
|
18
|
+
onSuccess: () => {
|
|
19
|
+
void queryClient.invalidateQueries({ queryKey: authQueryKeys.organizationMembers() });
|
|
20
|
+
void queryClient.invalidateQueries({ queryKey: authQueryKeys.currentWorkspace() });
|
|
21
|
+
void queryClient.invalidateQueries({ queryKey: authQueryKeys.currentUser() });
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
return { updateRole, remove };
|
|
25
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { OrganizationMembersListFilters } from "../query-keys.js";
|
|
2
|
+
export interface UseOrganizationMembersOptions {
|
|
3
|
+
filters?: OrganizationMembersListFilters;
|
|
4
|
+
enabled?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare function useOrganizationMembers(options?: UseOrganizationMembersOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
7
|
+
members: {
|
|
8
|
+
id: string;
|
|
9
|
+
organizationId: string;
|
|
10
|
+
userId: string;
|
|
11
|
+
role: string | string[];
|
|
12
|
+
createdAt: string;
|
|
13
|
+
user: {
|
|
14
|
+
id: string;
|
|
15
|
+
email: string;
|
|
16
|
+
name: string;
|
|
17
|
+
image?: string | null | undefined;
|
|
18
|
+
};
|
|
19
|
+
teamId?: string | undefined;
|
|
20
|
+
}[];
|
|
21
|
+
total: number;
|
|
22
|
+
}, Error>;
|
|
23
|
+
//# sourceMappingURL=use-organization-members.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-organization-members.d.ts","sourceRoot":"","sources":["../../src/hooks/use-organization-members.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,kBAAkB,CAAA;AAGtE,MAAM,WAAW,6BAA6B;IAC5C,OAAO,CAAC,EAAE,8BAA8B,CAAA;IACxC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,sBAAsB,CAAC,OAAO,GAAE,6BAAkC;;;;;;;;;;;;;;;;UAQjF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantAuthContext } from "../provider.js";
|
|
4
|
+
import { getOrganizationMembersQueryOptions } from "../query-options.js";
|
|
5
|
+
export function useOrganizationMembers(options = {}) {
|
|
6
|
+
const { baseUrl, fetcher } = useVoyantAuthContext();
|
|
7
|
+
const { filters = {}, enabled = true } = options;
|
|
8
|
+
return useQuery({
|
|
9
|
+
...getOrganizationMembersQueryOptions(filters, { baseUrl, fetcher }),
|
|
10
|
+
enabled,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare function useWorkspaceMutation(): {
|
|
2
|
+
setActiveOrganization: import("@tanstack/react-query").UseMutationResult<{
|
|
3
|
+
organizations: {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
slug: string;
|
|
7
|
+
logo?: string | null | undefined;
|
|
8
|
+
}[];
|
|
9
|
+
activeOrganization: {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
slug: string;
|
|
13
|
+
logo?: string | null | undefined;
|
|
14
|
+
} | null;
|
|
15
|
+
}, Error, string, unknown>;
|
|
16
|
+
refreshCurrentUser: import("@tanstack/react-query").UseMutationResult<{
|
|
17
|
+
id: string;
|
|
18
|
+
email: string;
|
|
19
|
+
firstName: string | null;
|
|
20
|
+
lastName: string | null;
|
|
21
|
+
isSuperAdmin: boolean;
|
|
22
|
+
isSupportUser: boolean;
|
|
23
|
+
createdAt: string;
|
|
24
|
+
profilePictureUrl?: string | null | undefined;
|
|
25
|
+
activeOrganizationId?: string | null | undefined;
|
|
26
|
+
}, Error, void, unknown>;
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=use-workspace-mutation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-workspace-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-workspace-mutation.ts"],"names":[],"mappings":"AASA,wBAAgB,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;EA8BnC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { fetchWithValidation } from "../client.js";
|
|
4
|
+
import { useVoyantAuthContext } from "../provider.js";
|
|
5
|
+
import { authQueryKeys } from "../query-keys.js";
|
|
6
|
+
import { currentUserSchema, currentWorkspaceSchema } from "../schemas.js";
|
|
7
|
+
export function useWorkspaceMutation() {
|
|
8
|
+
const { baseUrl, fetcher } = useVoyantAuthContext();
|
|
9
|
+
const queryClient = useQueryClient();
|
|
10
|
+
const setActiveOrganization = useMutation({
|
|
11
|
+
mutationFn: async (organizationId) => fetchWithValidation("/auth/workspace/active-organization", currentWorkspaceSchema, { baseUrl, fetcher }, {
|
|
12
|
+
method: "POST",
|
|
13
|
+
body: JSON.stringify({ organizationId }),
|
|
14
|
+
}),
|
|
15
|
+
onSuccess: (workspace) => {
|
|
16
|
+
queryClient.setQueryData(authQueryKeys.currentWorkspace(), workspace);
|
|
17
|
+
void queryClient.invalidateQueries({ queryKey: authQueryKeys.currentUser() });
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
const refreshCurrentUser = useMutation({
|
|
21
|
+
mutationFn: async () => fetchWithValidation("/auth/me", currentUserSchema, { baseUrl, fetcher }),
|
|
22
|
+
onSuccess: (user) => {
|
|
23
|
+
queryClient.setQueryData(authQueryKeys.currentUser(), user);
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
return { setActiveOrganization, refreshCurrentUser };
|
|
27
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type { AuthStatus, CurrentUser, CurrentWorkspace, WorkspaceOrganization, } from "@voyantjs/auth/workspace";
|
|
2
|
+
export { defaultFetcher, fetchWithValidation, VoyantApiError, type VoyantFetcher, withQueryParams, } from "./client.js";
|
|
3
|
+
export * from "./hooks/index.js";
|
|
4
|
+
export { useVoyantAuthContext, type VoyantAuthContextValue, VoyantAuthProvider, type VoyantAuthProviderProps, } from "./provider.js";
|
|
5
|
+
export type { OrganizationInvitationsListFilters, OrganizationMembersListFilters, } from "./query-keys.js";
|
|
6
|
+
export { authQueryKeys } from "./query-keys.js";
|
|
7
|
+
export { getAuthStatusQueryOptions, getCurrentUserQueryOptions, getCurrentWorkspaceQueryOptions, getOrganizationInvitationsQueryOptions, getOrganizationMembersQueryOptions, } from "./query-options.js";
|
|
8
|
+
export * from "./schemas.js";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,KAAK,aAAa,EAClB,eAAe,GAChB,MAAM,aAAa,CAAA;AACpB,cAAc,kBAAkB,CAAA;AAChC,OAAO,EACL,oBAAoB,EACpB,KAAK,sBAAsB,EAC3B,kBAAkB,EAClB,KAAK,uBAAuB,GAC7B,MAAM,eAAe,CAAA;AACtB,YAAY,EACV,kCAAkC,EAClC,8BAA8B,GAC/B,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EACL,yBAAyB,EACzB,0BAA0B,EAC1B,+BAA+B,EAC/B,sCAAsC,EACtC,kCAAkC,GACnC,MAAM,oBAAoB,CAAA;AAC3B,cAAc,cAAc,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { defaultFetcher, fetchWithValidation, VoyantApiError, withQueryParams, } from "./client.js";
|
|
2
|
+
export * from "./hooks/index.js";
|
|
3
|
+
export { useVoyantAuthContext, VoyantAuthProvider, } from "./provider.js";
|
|
4
|
+
export { authQueryKeys } from "./query-keys.js";
|
|
5
|
+
export { getAuthStatusQueryOptions, getCurrentUserQueryOptions, getCurrentWorkspaceQueryOptions, getOrganizationInvitationsQueryOptions, getOrganizationMembersQueryOptions, } from "./query-options.js";
|
|
6
|
+
export * from "./schemas.js";
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { useVoyantReactContext as useVoyantAuthContext, type VoyantReactContextValue as VoyantAuthContextValue, VoyantReactProvider as VoyantAuthProvider, type VoyantReactProviderProps as VoyantAuthProviderProps, } from "@voyantjs/react";
|
|
2
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,IAAI,oBAAoB,EAC7C,KAAK,uBAAuB,IAAI,sBAAsB,EACtD,mBAAmB,IAAI,kBAAkB,EACzC,KAAK,wBAAwB,IAAI,uBAAuB,GACzD,MAAM,iBAAiB,CAAA"}
|
package/dist/provider.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useVoyantReactContext as useVoyantAuthContext, VoyantReactProvider as VoyantAuthProvider, } from "@voyantjs/react";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface OrganizationMembersListFilters {
|
|
2
|
+
limit?: number | string | undefined;
|
|
3
|
+
offset?: number | string | undefined;
|
|
4
|
+
sortBy?: string | undefined;
|
|
5
|
+
sortDirection?: "asc" | "desc" | undefined;
|
|
6
|
+
filterField?: string | undefined;
|
|
7
|
+
filterValue?: string | number | boolean | Array<string | number> | undefined;
|
|
8
|
+
filterOperator?: "eq" | "ne" | "gt" | "gte" | "lt" | "lte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
9
|
+
organizationId?: string | undefined;
|
|
10
|
+
organizationSlug?: string | undefined;
|
|
11
|
+
}
|
|
12
|
+
export interface OrganizationInvitationsListFilters {
|
|
13
|
+
organizationId?: string | undefined;
|
|
14
|
+
}
|
|
15
|
+
export declare const authQueryKeys: {
|
|
16
|
+
all: readonly ["auth"];
|
|
17
|
+
currentUser: () => readonly ["auth", "current-user"];
|
|
18
|
+
currentWorkspace: () => readonly ["auth", "current-workspace"];
|
|
19
|
+
authStatus: () => readonly ["auth", "status"];
|
|
20
|
+
organizationMembers: () => readonly ["auth", "organization-members"];
|
|
21
|
+
organizationMembersList: (filters?: OrganizationMembersListFilters) => readonly ["auth", "organization-members", "list", OrganizationMembersListFilters];
|
|
22
|
+
organizationInvitations: () => readonly ["auth", "organization-invitations"];
|
|
23
|
+
organizationInvitationsList: (filters?: OrganizationInvitationsListFilters) => readonly ["auth", "organization-invitations", "list", OrganizationInvitationsListFilters];
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=query-keys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-keys.d.ts","sourceRoot":"","sources":["../src/query-keys.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,8BAA8B;IAC7C,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;IACnC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;IACpC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,aAAa,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,SAAS,CAAA;IAC1C,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAChC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,SAAS,CAAA;IAC5E,cAAc,CAAC,EACX,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,KAAK,GACL,IAAI,GACJ,KAAK,GACL,IAAI,GACJ,QAAQ,GACR,UAAU,GACV,aAAa,GACb,WAAW,GACX,SAAS,CAAA;IACb,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACnC,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CACtC;AAED,MAAM,WAAW,kCAAkC;IACjD,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CACpC;AAED,eAAO,MAAM,aAAa;;;;;;wCAMW,8BAA8B;;4CAG1B,kCAAkC;CAE1E,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const authQueryKeys = {
|
|
2
|
+
all: ["auth"],
|
|
3
|
+
currentUser: () => [...authQueryKeys.all, "current-user"],
|
|
4
|
+
currentWorkspace: () => [...authQueryKeys.all, "current-workspace"],
|
|
5
|
+
authStatus: () => [...authQueryKeys.all, "status"],
|
|
6
|
+
organizationMembers: () => [...authQueryKeys.all, "organization-members"],
|
|
7
|
+
organizationMembersList: (filters = {}) => [...authQueryKeys.organizationMembers(), "list", filters],
|
|
8
|
+
organizationInvitations: () => [...authQueryKeys.all, "organization-invitations"],
|
|
9
|
+
organizationInvitationsList: (filters = {}) => [...authQueryKeys.organizationInvitations(), "list", filters],
|
|
10
|
+
};
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { type FetchWithValidationOptions } from "./client.js";
|
|
2
|
+
import { type OrganizationInvitationsListFilters, type OrganizationMembersListFilters } from "./query-keys.js";
|
|
3
|
+
export declare function getCurrentUserQueryOptions(client: FetchWithValidationOptions): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<{
|
|
4
|
+
id: string;
|
|
5
|
+
email: string;
|
|
6
|
+
firstName: string | null;
|
|
7
|
+
lastName: string | null;
|
|
8
|
+
isSuperAdmin: boolean;
|
|
9
|
+
isSupportUser: boolean;
|
|
10
|
+
createdAt: string;
|
|
11
|
+
profilePictureUrl?: string | null | undefined;
|
|
12
|
+
activeOrganizationId?: string | null | undefined;
|
|
13
|
+
}, Error, {
|
|
14
|
+
id: string;
|
|
15
|
+
email: string;
|
|
16
|
+
firstName: string | null;
|
|
17
|
+
lastName: string | null;
|
|
18
|
+
isSuperAdmin: boolean;
|
|
19
|
+
isSupportUser: boolean;
|
|
20
|
+
createdAt: string;
|
|
21
|
+
profilePictureUrl?: string | null | undefined;
|
|
22
|
+
activeOrganizationId?: string | null | undefined;
|
|
23
|
+
}, readonly ["auth", "current-user"]>, "queryFn"> & {
|
|
24
|
+
queryFn?: import("@tanstack/react-query").QueryFunction<{
|
|
25
|
+
id: string;
|
|
26
|
+
email: string;
|
|
27
|
+
firstName: string | null;
|
|
28
|
+
lastName: string | null;
|
|
29
|
+
isSuperAdmin: boolean;
|
|
30
|
+
isSupportUser: boolean;
|
|
31
|
+
createdAt: string;
|
|
32
|
+
profilePictureUrl?: string | null | undefined;
|
|
33
|
+
activeOrganizationId?: string | null | undefined;
|
|
34
|
+
}, readonly ["auth", "current-user"], never> | undefined;
|
|
35
|
+
} & {
|
|
36
|
+
queryKey: readonly ["auth", "current-user"] & {
|
|
37
|
+
[dataTagSymbol]: {
|
|
38
|
+
id: string;
|
|
39
|
+
email: string;
|
|
40
|
+
firstName: string | null;
|
|
41
|
+
lastName: string | null;
|
|
42
|
+
isSuperAdmin: boolean;
|
|
43
|
+
isSupportUser: boolean;
|
|
44
|
+
createdAt: string;
|
|
45
|
+
profilePictureUrl?: string | null | undefined;
|
|
46
|
+
activeOrganizationId?: string | null | undefined;
|
|
47
|
+
};
|
|
48
|
+
[dataTagErrorSymbol]: Error;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
export declare function getCurrentWorkspaceQueryOptions(client: FetchWithValidationOptions): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<{
|
|
52
|
+
organizations: {
|
|
53
|
+
id: string;
|
|
54
|
+
name: string;
|
|
55
|
+
slug: string;
|
|
56
|
+
logo?: string | null | undefined;
|
|
57
|
+
}[];
|
|
58
|
+
activeOrganization: {
|
|
59
|
+
id: string;
|
|
60
|
+
name: string;
|
|
61
|
+
slug: string;
|
|
62
|
+
logo?: string | null | undefined;
|
|
63
|
+
} | null;
|
|
64
|
+
}, Error, {
|
|
65
|
+
organizations: {
|
|
66
|
+
id: string;
|
|
67
|
+
name: string;
|
|
68
|
+
slug: string;
|
|
69
|
+
logo?: string | null | undefined;
|
|
70
|
+
}[];
|
|
71
|
+
activeOrganization: {
|
|
72
|
+
id: string;
|
|
73
|
+
name: string;
|
|
74
|
+
slug: string;
|
|
75
|
+
logo?: string | null | undefined;
|
|
76
|
+
} | null;
|
|
77
|
+
}, readonly ["auth", "current-workspace"]>, "queryFn"> & {
|
|
78
|
+
queryFn?: import("@tanstack/react-query").QueryFunction<{
|
|
79
|
+
organizations: {
|
|
80
|
+
id: string;
|
|
81
|
+
name: string;
|
|
82
|
+
slug: string;
|
|
83
|
+
logo?: string | null | undefined;
|
|
84
|
+
}[];
|
|
85
|
+
activeOrganization: {
|
|
86
|
+
id: string;
|
|
87
|
+
name: string;
|
|
88
|
+
slug: string;
|
|
89
|
+
logo?: string | null | undefined;
|
|
90
|
+
} | null;
|
|
91
|
+
}, readonly ["auth", "current-workspace"], never> | undefined;
|
|
92
|
+
} & {
|
|
93
|
+
queryKey: readonly ["auth", "current-workspace"] & {
|
|
94
|
+
[dataTagSymbol]: {
|
|
95
|
+
organizations: {
|
|
96
|
+
id: string;
|
|
97
|
+
name: string;
|
|
98
|
+
slug: string;
|
|
99
|
+
logo?: string | null | undefined;
|
|
100
|
+
}[];
|
|
101
|
+
activeOrganization: {
|
|
102
|
+
id: string;
|
|
103
|
+
name: string;
|
|
104
|
+
slug: string;
|
|
105
|
+
logo?: string | null | undefined;
|
|
106
|
+
} | null;
|
|
107
|
+
};
|
|
108
|
+
[dataTagErrorSymbol]: Error;
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
export declare function getAuthStatusQueryOptions(client: FetchWithValidationOptions): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<{
|
|
112
|
+
userExists: boolean;
|
|
113
|
+
authenticated: boolean;
|
|
114
|
+
reason?: string | undefined;
|
|
115
|
+
}, Error, {
|
|
116
|
+
userExists: boolean;
|
|
117
|
+
authenticated: boolean;
|
|
118
|
+
reason?: string | undefined;
|
|
119
|
+
}, readonly ["auth", "status"]>, "queryFn"> & {
|
|
120
|
+
queryFn?: import("@tanstack/react-query").QueryFunction<{
|
|
121
|
+
userExists: boolean;
|
|
122
|
+
authenticated: boolean;
|
|
123
|
+
reason?: string | undefined;
|
|
124
|
+
}, readonly ["auth", "status"], never> | undefined;
|
|
125
|
+
} & {
|
|
126
|
+
queryKey: readonly ["auth", "status"] & {
|
|
127
|
+
[dataTagSymbol]: {
|
|
128
|
+
userExists: boolean;
|
|
129
|
+
authenticated: boolean;
|
|
130
|
+
reason?: string | undefined;
|
|
131
|
+
};
|
|
132
|
+
[dataTagErrorSymbol]: Error;
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
export declare function getOrganizationMembersQueryOptions(filters: OrganizationMembersListFilters, client: FetchWithValidationOptions): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<{
|
|
136
|
+
members: {
|
|
137
|
+
id: string;
|
|
138
|
+
organizationId: string;
|
|
139
|
+
userId: string;
|
|
140
|
+
role: string | string[];
|
|
141
|
+
createdAt: string;
|
|
142
|
+
user: {
|
|
143
|
+
id: string;
|
|
144
|
+
email: string;
|
|
145
|
+
name: string;
|
|
146
|
+
image?: string | null | undefined;
|
|
147
|
+
};
|
|
148
|
+
teamId?: string | undefined;
|
|
149
|
+
}[];
|
|
150
|
+
total: number;
|
|
151
|
+
}, Error, {
|
|
152
|
+
members: {
|
|
153
|
+
id: string;
|
|
154
|
+
organizationId: string;
|
|
155
|
+
userId: string;
|
|
156
|
+
role: string | string[];
|
|
157
|
+
createdAt: string;
|
|
158
|
+
user: {
|
|
159
|
+
id: string;
|
|
160
|
+
email: string;
|
|
161
|
+
name: string;
|
|
162
|
+
image?: string | null | undefined;
|
|
163
|
+
};
|
|
164
|
+
teamId?: string | undefined;
|
|
165
|
+
}[];
|
|
166
|
+
total: number;
|
|
167
|
+
}, readonly ["auth", "organization-members", "list", OrganizationMembersListFilters]>, "queryFn"> & {
|
|
168
|
+
queryFn?: import("@tanstack/react-query").QueryFunction<{
|
|
169
|
+
members: {
|
|
170
|
+
id: string;
|
|
171
|
+
organizationId: string;
|
|
172
|
+
userId: string;
|
|
173
|
+
role: string | string[];
|
|
174
|
+
createdAt: string;
|
|
175
|
+
user: {
|
|
176
|
+
id: string;
|
|
177
|
+
email: string;
|
|
178
|
+
name: string;
|
|
179
|
+
image?: string | null | undefined;
|
|
180
|
+
};
|
|
181
|
+
teamId?: string | undefined;
|
|
182
|
+
}[];
|
|
183
|
+
total: number;
|
|
184
|
+
}, readonly ["auth", "organization-members", "list", OrganizationMembersListFilters], never> | undefined;
|
|
185
|
+
} & {
|
|
186
|
+
queryKey: readonly ["auth", "organization-members", "list", OrganizationMembersListFilters] & {
|
|
187
|
+
[dataTagSymbol]: {
|
|
188
|
+
members: {
|
|
189
|
+
id: string;
|
|
190
|
+
organizationId: string;
|
|
191
|
+
userId: string;
|
|
192
|
+
role: string | string[];
|
|
193
|
+
createdAt: string;
|
|
194
|
+
user: {
|
|
195
|
+
id: string;
|
|
196
|
+
email: string;
|
|
197
|
+
name: string;
|
|
198
|
+
image?: string | null | undefined;
|
|
199
|
+
};
|
|
200
|
+
teamId?: string | undefined;
|
|
201
|
+
}[];
|
|
202
|
+
total: number;
|
|
203
|
+
};
|
|
204
|
+
[dataTagErrorSymbol]: Error;
|
|
205
|
+
};
|
|
206
|
+
};
|
|
207
|
+
export declare function getOrganizationInvitationsQueryOptions(filters: OrganizationInvitationsListFilters, client: FetchWithValidationOptions): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<{
|
|
208
|
+
id: string;
|
|
209
|
+
organizationId: string;
|
|
210
|
+
email: string;
|
|
211
|
+
role: string | string[];
|
|
212
|
+
status: "pending" | "accepted" | "rejected" | "canceled";
|
|
213
|
+
inviterId: string;
|
|
214
|
+
expiresAt: string;
|
|
215
|
+
createdAt: string;
|
|
216
|
+
teamId?: string | undefined;
|
|
217
|
+
}[], Error, {
|
|
218
|
+
id: string;
|
|
219
|
+
organizationId: string;
|
|
220
|
+
email: string;
|
|
221
|
+
role: string | string[];
|
|
222
|
+
status: "pending" | "accepted" | "rejected" | "canceled";
|
|
223
|
+
inviterId: string;
|
|
224
|
+
expiresAt: string;
|
|
225
|
+
createdAt: string;
|
|
226
|
+
teamId?: string | undefined;
|
|
227
|
+
}[], readonly ["auth", "organization-invitations", "list", OrganizationInvitationsListFilters]>, "queryFn"> & {
|
|
228
|
+
queryFn?: import("@tanstack/react-query").QueryFunction<{
|
|
229
|
+
id: string;
|
|
230
|
+
organizationId: string;
|
|
231
|
+
email: string;
|
|
232
|
+
role: string | string[];
|
|
233
|
+
status: "pending" | "accepted" | "rejected" | "canceled";
|
|
234
|
+
inviterId: string;
|
|
235
|
+
expiresAt: string;
|
|
236
|
+
createdAt: string;
|
|
237
|
+
teamId?: string | undefined;
|
|
238
|
+
}[], readonly ["auth", "organization-invitations", "list", OrganizationInvitationsListFilters], never> | undefined;
|
|
239
|
+
} & {
|
|
240
|
+
queryKey: readonly ["auth", "organization-invitations", "list", OrganizationInvitationsListFilters] & {
|
|
241
|
+
[dataTagSymbol]: {
|
|
242
|
+
id: string;
|
|
243
|
+
organizationId: string;
|
|
244
|
+
email: string;
|
|
245
|
+
role: string | string[];
|
|
246
|
+
status: "pending" | "accepted" | "rejected" | "canceled";
|
|
247
|
+
inviterId: string;
|
|
248
|
+
expiresAt: string;
|
|
249
|
+
createdAt: string;
|
|
250
|
+
teamId?: string | undefined;
|
|
251
|
+
}[];
|
|
252
|
+
[dataTagErrorSymbol]: Error;
|
|
253
|
+
};
|
|
254
|
+
};
|
|
255
|
+
export type { OrganizationInvitationsListFilters, OrganizationMembersListFilters, } from "./query-keys.js";
|
|
256
|
+
//# sourceMappingURL=query-options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-options.d.ts","sourceRoot":"","sources":["../src/query-options.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,0BAA0B,EAAwC,MAAM,aAAa,CAAA;AACnG,OAAO,EAEL,KAAK,kCAAkC,EACvC,KAAK,8BAA8B,EACpC,MAAM,iBAAiB,CAAA;AASxB,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAK5E;AAED,wBAAgB,+BAA+B,CAAC,MAAM,EAAE,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKjF;AAED,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;EAK3E;AAED,wBAAgB,kCAAkC,CAChD,OAAO,EAAE,8BAA8B,EACvC,MAAM,EAAE,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWnC;AAED,wBAAgB,sCAAsC,CACpD,OAAO,EAAE,kCAAkC,EAC3C,MAAM,EAAE,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWnC;AAED,YAAY,EACV,kCAAkC,EAClC,8BAA8B,GAC/B,MAAM,iBAAiB,CAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { queryOptions } from "@tanstack/react-query";
|
|
3
|
+
import { fetchWithValidation, withQueryParams } from "./client.js";
|
|
4
|
+
import { authQueryKeys, } from "./query-keys.js";
|
|
5
|
+
import { authStatusSchema, currentUserSchema, currentWorkspaceSchema, organizationInvitationsListSchema, organizationMembersListSchema, } from "./schemas.js";
|
|
6
|
+
export function getCurrentUserQueryOptions(client) {
|
|
7
|
+
return queryOptions({
|
|
8
|
+
queryKey: authQueryKeys.currentUser(),
|
|
9
|
+
queryFn: () => fetchWithValidation("/auth/me", currentUserSchema, client),
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
export function getCurrentWorkspaceQueryOptions(client) {
|
|
13
|
+
return queryOptions({
|
|
14
|
+
queryKey: authQueryKeys.currentWorkspace(),
|
|
15
|
+
queryFn: () => fetchWithValidation("/auth/workspace", currentWorkspaceSchema, client),
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export function getAuthStatusQueryOptions(client) {
|
|
19
|
+
return queryOptions({
|
|
20
|
+
queryKey: authQueryKeys.authStatus(),
|
|
21
|
+
queryFn: () => fetchWithValidation("/auth/status", authStatusSchema, client),
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
export function getOrganizationMembersQueryOptions(filters, client) {
|
|
25
|
+
return queryOptions({
|
|
26
|
+
queryKey: authQueryKeys.organizationMembersList(filters),
|
|
27
|
+
queryFn: () => fetchWithValidation(withQueryParams("/auth/organization/list-members", filters), organizationMembersListSchema, client),
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
export function getOrganizationInvitationsQueryOptions(filters, client) {
|
|
31
|
+
return queryOptions({
|
|
32
|
+
queryKey: authQueryKeys.organizationInvitationsList(filters),
|
|
33
|
+
queryFn: () => fetchWithValidation(withQueryParams("/auth/organization/list-invitations", filters), organizationInvitationsListSchema, client),
|
|
34
|
+
});
|
|
35
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const organizationRoleSchema: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
|
|
3
|
+
export declare const organizationInvitationStatusSchema: z.ZodEnum<{
|
|
4
|
+
pending: "pending";
|
|
5
|
+
accepted: "accepted";
|
|
6
|
+
rejected: "rejected";
|
|
7
|
+
canceled: "canceled";
|
|
8
|
+
}>;
|
|
9
|
+
export declare const workspaceOrganizationSchema: z.ZodObject<{
|
|
10
|
+
id: z.ZodString;
|
|
11
|
+
name: z.ZodString;
|
|
12
|
+
slug: z.ZodString;
|
|
13
|
+
logo: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
export declare const currentWorkspaceSchema: z.ZodObject<{
|
|
16
|
+
organizations: z.ZodArray<z.ZodObject<{
|
|
17
|
+
id: z.ZodString;
|
|
18
|
+
name: z.ZodString;
|
|
19
|
+
slug: z.ZodString;
|
|
20
|
+
logo: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
21
|
+
}, z.core.$strip>>;
|
|
22
|
+
activeOrganization: z.ZodNullable<z.ZodObject<{
|
|
23
|
+
id: z.ZodString;
|
|
24
|
+
name: z.ZodString;
|
|
25
|
+
slug: z.ZodString;
|
|
26
|
+
logo: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
27
|
+
}, z.core.$strip>>;
|
|
28
|
+
}, z.core.$strip>;
|
|
29
|
+
export declare const currentUserSchema: z.ZodObject<{
|
|
30
|
+
id: z.ZodString;
|
|
31
|
+
email: z.ZodString;
|
|
32
|
+
firstName: z.ZodNullable<z.ZodString>;
|
|
33
|
+
lastName: z.ZodNullable<z.ZodString>;
|
|
34
|
+
isSuperAdmin: z.ZodBoolean;
|
|
35
|
+
isSupportUser: z.ZodBoolean;
|
|
36
|
+
createdAt: z.ZodString;
|
|
37
|
+
profilePictureUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
38
|
+
activeOrganizationId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
39
|
+
}, z.core.$strip>;
|
|
40
|
+
export declare const authStatusSchema: z.ZodObject<{
|
|
41
|
+
userExists: z.ZodBoolean;
|
|
42
|
+
authenticated: z.ZodBoolean;
|
|
43
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
44
|
+
}, z.core.$strip>;
|
|
45
|
+
export declare const organizationMemberUserSchema: z.ZodObject<{
|
|
46
|
+
id: z.ZodString;
|
|
47
|
+
email: z.ZodString;
|
|
48
|
+
name: z.ZodString;
|
|
49
|
+
image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
50
|
+
}, z.core.$strip>;
|
|
51
|
+
export declare const organizationMemberSchema: z.ZodObject<{
|
|
52
|
+
id: z.ZodString;
|
|
53
|
+
organizationId: z.ZodString;
|
|
54
|
+
userId: z.ZodString;
|
|
55
|
+
role: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
|
|
56
|
+
createdAt: z.ZodString;
|
|
57
|
+
teamId: z.ZodOptional<z.ZodString>;
|
|
58
|
+
user: z.ZodObject<{
|
|
59
|
+
id: z.ZodString;
|
|
60
|
+
email: z.ZodString;
|
|
61
|
+
name: z.ZodString;
|
|
62
|
+
image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
63
|
+
}, z.core.$strip>;
|
|
64
|
+
}, z.core.$strip>;
|
|
65
|
+
export declare const organizationMembersListSchema: z.ZodObject<{
|
|
66
|
+
members: z.ZodArray<z.ZodObject<{
|
|
67
|
+
id: z.ZodString;
|
|
68
|
+
organizationId: z.ZodString;
|
|
69
|
+
userId: z.ZodString;
|
|
70
|
+
role: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
|
|
71
|
+
createdAt: z.ZodString;
|
|
72
|
+
teamId: z.ZodOptional<z.ZodString>;
|
|
73
|
+
user: z.ZodObject<{
|
|
74
|
+
id: z.ZodString;
|
|
75
|
+
email: z.ZodString;
|
|
76
|
+
name: z.ZodString;
|
|
77
|
+
image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
78
|
+
}, z.core.$strip>;
|
|
79
|
+
}, z.core.$strip>>;
|
|
80
|
+
total: z.ZodNumber;
|
|
81
|
+
}, z.core.$strip>;
|
|
82
|
+
export declare const organizationRemoveMemberSchema: z.ZodObject<{
|
|
83
|
+
member: z.ZodObject<{
|
|
84
|
+
id: z.ZodString;
|
|
85
|
+
organizationId: z.ZodString;
|
|
86
|
+
userId: z.ZodString;
|
|
87
|
+
role: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
|
|
88
|
+
createdAt: z.ZodString;
|
|
89
|
+
teamId: z.ZodOptional<z.ZodString>;
|
|
90
|
+
user: z.ZodObject<{
|
|
91
|
+
id: z.ZodString;
|
|
92
|
+
email: z.ZodString;
|
|
93
|
+
name: z.ZodString;
|
|
94
|
+
image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
95
|
+
}, z.core.$strip>;
|
|
96
|
+
}, z.core.$strip>;
|
|
97
|
+
}, z.core.$strip>;
|
|
98
|
+
export declare const organizationInvitationSchema: z.ZodObject<{
|
|
99
|
+
id: z.ZodString;
|
|
100
|
+
organizationId: z.ZodString;
|
|
101
|
+
email: z.ZodString;
|
|
102
|
+
role: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
|
|
103
|
+
status: z.ZodEnum<{
|
|
104
|
+
pending: "pending";
|
|
105
|
+
accepted: "accepted";
|
|
106
|
+
rejected: "rejected";
|
|
107
|
+
canceled: "canceled";
|
|
108
|
+
}>;
|
|
109
|
+
inviterId: z.ZodString;
|
|
110
|
+
expiresAt: z.ZodString;
|
|
111
|
+
createdAt: z.ZodString;
|
|
112
|
+
teamId: z.ZodOptional<z.ZodString>;
|
|
113
|
+
}, z.core.$strip>;
|
|
114
|
+
export declare const organizationInvitationsListSchema: z.ZodArray<z.ZodObject<{
|
|
115
|
+
id: z.ZodString;
|
|
116
|
+
organizationId: z.ZodString;
|
|
117
|
+
email: z.ZodString;
|
|
118
|
+
role: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
|
|
119
|
+
status: z.ZodEnum<{
|
|
120
|
+
pending: "pending";
|
|
121
|
+
accepted: "accepted";
|
|
122
|
+
rejected: "rejected";
|
|
123
|
+
canceled: "canceled";
|
|
124
|
+
}>;
|
|
125
|
+
inviterId: z.ZodString;
|
|
126
|
+
expiresAt: z.ZodString;
|
|
127
|
+
createdAt: z.ZodString;
|
|
128
|
+
teamId: z.ZodOptional<z.ZodString>;
|
|
129
|
+
}, z.core.$strip>>;
|
|
130
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,sBAAsB,6DAA6C,CAAA;AAEhF,eAAO,MAAM,kCAAkC;;;;;EAK7C,CAAA;AAEF,eAAO,MAAM,2BAA2B;;;;;iBAKtC,CAAA;AAEF,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;iBAGjC,CAAA;AAEF,eAAO,MAAM,iBAAiB;;;;;;;;;;iBAU5B,CAAA;AAEF,eAAO,MAAM,gBAAgB;;;;iBAI3B,CAAA;AAEF,eAAO,MAAM,4BAA4B;;;;;iBAKvC,CAAA;AAEF,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;iBAQnC,CAAA;AAEF,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;iBAGxC,CAAA;AAEF,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;iBAEzC,CAAA;AAEF,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;iBAUvC,CAAA;AAEF,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;kBAAwC,CAAA"}
|
package/dist/schemas.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const organizationRoleSchema = z.union([z.string(), z.array(z.string())]);
|
|
3
|
+
export const organizationInvitationStatusSchema = z.enum([
|
|
4
|
+
"pending",
|
|
5
|
+
"accepted",
|
|
6
|
+
"rejected",
|
|
7
|
+
"canceled",
|
|
8
|
+
]);
|
|
9
|
+
export const workspaceOrganizationSchema = z.object({
|
|
10
|
+
id: z.string(),
|
|
11
|
+
name: z.string(),
|
|
12
|
+
slug: z.string(),
|
|
13
|
+
logo: z.string().nullable().optional(),
|
|
14
|
+
});
|
|
15
|
+
export const currentWorkspaceSchema = z.object({
|
|
16
|
+
organizations: z.array(workspaceOrganizationSchema),
|
|
17
|
+
activeOrganization: workspaceOrganizationSchema.nullable(),
|
|
18
|
+
});
|
|
19
|
+
export const currentUserSchema = z.object({
|
|
20
|
+
id: z.string(),
|
|
21
|
+
email: z.string(),
|
|
22
|
+
firstName: z.string().nullable(),
|
|
23
|
+
lastName: z.string().nullable(),
|
|
24
|
+
isSuperAdmin: z.boolean(),
|
|
25
|
+
isSupportUser: z.boolean(),
|
|
26
|
+
createdAt: z.string(),
|
|
27
|
+
profilePictureUrl: z.string().nullable().optional(),
|
|
28
|
+
activeOrganizationId: z.string().nullable().optional(),
|
|
29
|
+
});
|
|
30
|
+
export const authStatusSchema = z.object({
|
|
31
|
+
userExists: z.boolean(),
|
|
32
|
+
authenticated: z.boolean(),
|
|
33
|
+
reason: z.string().optional(),
|
|
34
|
+
});
|
|
35
|
+
export const organizationMemberUserSchema = z.object({
|
|
36
|
+
id: z.string(),
|
|
37
|
+
email: z.string(),
|
|
38
|
+
name: z.string(),
|
|
39
|
+
image: z.string().nullable().optional(),
|
|
40
|
+
});
|
|
41
|
+
export const organizationMemberSchema = z.object({
|
|
42
|
+
id: z.string(),
|
|
43
|
+
organizationId: z.string(),
|
|
44
|
+
userId: z.string(),
|
|
45
|
+
role: organizationRoleSchema,
|
|
46
|
+
createdAt: z.string(),
|
|
47
|
+
teamId: z.string().optional(),
|
|
48
|
+
user: organizationMemberUserSchema,
|
|
49
|
+
});
|
|
50
|
+
export const organizationMembersListSchema = z.object({
|
|
51
|
+
members: z.array(organizationMemberSchema),
|
|
52
|
+
total: z.number(),
|
|
53
|
+
});
|
|
54
|
+
export const organizationRemoveMemberSchema = z.object({
|
|
55
|
+
member: organizationMemberSchema,
|
|
56
|
+
});
|
|
57
|
+
export const organizationInvitationSchema = z.object({
|
|
58
|
+
id: z.string(),
|
|
59
|
+
organizationId: z.string(),
|
|
60
|
+
email: z.string(),
|
|
61
|
+
role: organizationRoleSchema,
|
|
62
|
+
status: organizationInvitationStatusSchema,
|
|
63
|
+
inviterId: z.string(),
|
|
64
|
+
expiresAt: z.string(),
|
|
65
|
+
createdAt: z.string(),
|
|
66
|
+
teamId: z.string().optional(),
|
|
67
|
+
});
|
|
68
|
+
export const organizationInvitationsListSchema = z.array(organizationInvitationSchema);
|
package/package.json
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@voyantjs/auth-react",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"license": "FSL-1.1-Apache-2.0",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/voyantjs/voyant.git",
|
|
8
|
+
"directory": "packages/auth-react"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": "./src/index.ts",
|
|
13
|
+
"./provider": "./src/provider.tsx",
|
|
14
|
+
"./hooks": "./src/hooks/index.ts",
|
|
15
|
+
"./client": "./src/client.ts",
|
|
16
|
+
"./query-keys": "./src/query-keys.ts"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc -p tsconfig.json",
|
|
20
|
+
"clean": "rm -rf dist",
|
|
21
|
+
"prepack": "pnpm run build",
|
|
22
|
+
"typecheck": "tsc --noEmit",
|
|
23
|
+
"lint": "biome check src/",
|
|
24
|
+
"test": "vitest run --passWithNoTests"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"@voyantjs/auth": "workspace:*",
|
|
28
|
+
"@tanstack/react-query": "^5.0.0",
|
|
29
|
+
"react": "^19.0.0",
|
|
30
|
+
"react-dom": "^19.0.0",
|
|
31
|
+
"zod": "^4.0.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@tanstack/react-query": "^5.96.2",
|
|
35
|
+
"@types/react": "^19.2.14",
|
|
36
|
+
"@types/react-dom": "^19.2.3",
|
|
37
|
+
"@voyantjs/auth": "workspace:*",
|
|
38
|
+
"@voyantjs/react": "workspace:*",
|
|
39
|
+
"@voyantjs/voyant-typescript-config": "workspace:*",
|
|
40
|
+
"react": "^19.2.4",
|
|
41
|
+
"react-dom": "^19.2.4",
|
|
42
|
+
"typescript": "^6.0.2",
|
|
43
|
+
"vitest": "^4.1.2",
|
|
44
|
+
"zod": "^4.3.6"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@voyantjs/react": "workspace:*"
|
|
48
|
+
},
|
|
49
|
+
"files": [
|
|
50
|
+
"dist"
|
|
51
|
+
],
|
|
52
|
+
"publishConfig": {
|
|
53
|
+
"access": "public",
|
|
54
|
+
"exports": {
|
|
55
|
+
".": {
|
|
56
|
+
"types": "./dist/index.d.ts",
|
|
57
|
+
"import": "./dist/index.js"
|
|
58
|
+
},
|
|
59
|
+
"./provider": {
|
|
60
|
+
"types": "./dist/provider.d.ts",
|
|
61
|
+
"import": "./dist/provider.js"
|
|
62
|
+
},
|
|
63
|
+
"./hooks": {
|
|
64
|
+
"types": "./dist/hooks/index.d.ts",
|
|
65
|
+
"import": "./dist/hooks/index.js"
|
|
66
|
+
},
|
|
67
|
+
"./client": {
|
|
68
|
+
"types": "./dist/client.d.ts",
|
|
69
|
+
"import": "./dist/client.js"
|
|
70
|
+
},
|
|
71
|
+
"./query-keys": {
|
|
72
|
+
"types": "./dist/query-keys.d.ts",
|
|
73
|
+
"import": "./dist/query-keys.js"
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
"main": "./dist/index.js",
|
|
77
|
+
"types": "./dist/index.d.ts"
|
|
78
|
+
}
|
|
79
|
+
}
|