@krak-stack/auth 0.2.30 → 0.2.32
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/CHANGELOG.md +17 -0
- package/README.md +79 -1
- package/dist/admin/api.group.d.ts +94 -0
- package/dist/admin/api.group.js +3 -3
- package/dist/admin/schema.d.ts +215 -0
- package/dist/admin/schema.js +39 -1
- package/dist/api.d.ts +1531 -1377
- package/dist/auth/api.group.d.ts +19 -1
- package/dist/auth/api.group.js +17 -1
- package/dist/auth/schema.d.ts +12 -0
- package/dist/auth/schema.js +12 -0
- package/dist/components/account-deletion-request.d.ts +5 -0
- package/dist/components/account-deletion-request.js +7 -0
- package/dist/components/account-deletion.d.ts +8 -0
- package/dist/components/account-deletion.js +59 -0
- package/dist/components/admin-organizations.js +13 -3
- package/dist/components/admin-users.js +18 -1
- package/dist/components/associated-projects-notice.js +1 -1
- package/dist/components/auth-client-api.d.ts +127 -0
- package/dist/components/deletion-visibility.d.ts +1 -0
- package/dist/components/deletion-visibility.js +3 -0
- package/dist/components/organization-deletion-request.d.ts +17 -0
- package/dist/components/organization-deletion-request.js +9 -0
- package/dist/components/organization-switcher.js +31 -2
- package/dist/components/user-button.d.ts +29 -1
- package/dist/components/user-button.js +39 -2
- package/dist/extra/api.group.d.ts +13 -1
- package/dist/extra/api.group.js +5 -1
- package/dist/extra/schema.d.ts +13 -0
- package/dist/extra/schema.js +13 -0
- package/dist/schema.d.ts +35 -0
- package/dist/schema.js +25 -0
- package/dist/server/index.d.ts +2 -1
- package/dist/server/index.js +1 -0
- package/dist/server/middleware.d.ts +10 -2
- package/dist/server/middleware.js +4 -1
- package/dist/server/webhook-layer.d.ts +6 -0
- package/dist/server/webhook-layer.js +37 -0
- package/dist/server/webhooks.d.ts +38 -0
- package/dist/server/webhooks.js +39 -0
- package/dist/service.d.ts +66 -0
- package/package.json +7 -3
package/dist/auth/api.group.d.ts
CHANGED
|
@@ -327,7 +327,14 @@ export declare const AuthApiGroup: HttpApiGroup.HttpApiGroup<"auth", HttpApiEndp
|
|
|
327
327
|
readonly createdAt: Schema.DateFromString;
|
|
328
328
|
readonly updatedAt: Schema.DateFromString;
|
|
329
329
|
}>;
|
|
330
|
-
}>>, Schema.toCodecJson<typeof AuthBadRequest | typeof AuthUnauthorized | typeof AuthForbidden | typeof AuthNotFound | typeof AuthConflict | typeof AuthExpectationFailed | typeof AuthTooManyRequests | typeof AuthInternalServerError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"
|
|
330
|
+
}>>, Schema.toCodecJson<typeof AuthBadRequest | typeof AuthUnauthorized | typeof AuthForbidden | typeof AuthNotFound | typeof AuthConflict | typeof AuthExpectationFailed | typeof AuthTooManyRequests | typeof AuthInternalServerError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"deleteUser", "POST", "/delete-user", never, never, Schema.toCodecJson<Schema.Struct<{
|
|
331
|
+
readonly password: Schema.optional<Schema.String>;
|
|
332
|
+
readonly token: Schema.optional<Schema.String>;
|
|
333
|
+
readonly callbackURL: Schema.optional<Schema.String>;
|
|
334
|
+
}>>, never, Schema.toCodecJson<Schema.Struct<{
|
|
335
|
+
readonly success: Schema.Boolean;
|
|
336
|
+
readonly message: Schema.String;
|
|
337
|
+
}>>, Schema.toCodecJson<typeof AuthBadRequest | typeof AuthUnauthorized | typeof AuthForbidden | typeof AuthNotFound | typeof AuthInternalServerError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"getSession", "GET", "/get-session", never, Schema.toCodecStringTree<Schema.Struct<{
|
|
331
338
|
readonly disableCookieCache: Schema.optional<Schema.String>;
|
|
332
339
|
readonly disableRefresh: Schema.optional<Schema.String>;
|
|
333
340
|
}>>, never, never, Schema.toCodecJson<Schema.NullOr<Schema.Struct<{
|
|
@@ -537,6 +544,17 @@ export declare const AuthApiGroup: HttpApiGroup.HttpApiGroup<"auth", HttpApiEndp
|
|
|
537
544
|
readonly userId: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
538
545
|
readonly parentId: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
539
546
|
readonly createdAt: Schema.DateFromString;
|
|
547
|
+
}>>, Schema.toCodecJson<typeof AuthBadRequest | typeof AuthUnauthorized | typeof AuthForbidden | typeof AuthNotFound | typeof AuthConflict | typeof AuthExpectationFailed | typeof AuthTooManyRequests | typeof AuthInternalServerError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"organizationDelete", "POST", "/organization/delete", never, never, Schema.toCodecJson<Schema.Struct<{
|
|
548
|
+
readonly organizationId: Schema.NonEmptyString;
|
|
549
|
+
}>>, never, Schema.toCodecJson<Schema.Struct<{
|
|
550
|
+
readonly id: Schema.String;
|
|
551
|
+
readonly name: Schema.String;
|
|
552
|
+
readonly slug: Schema.String;
|
|
553
|
+
readonly logo: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
554
|
+
readonly metadata: Schema.optional<Schema.NullOr<Schema.Union<readonly [Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.String]>>>;
|
|
555
|
+
readonly userId: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
556
|
+
readonly parentId: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
557
|
+
readonly createdAt: Schema.DateFromString;
|
|
540
558
|
}>>, Schema.toCodecJson<typeof AuthBadRequest | typeof AuthUnauthorized | typeof AuthForbidden | typeof AuthNotFound | typeof AuthConflict | typeof AuthExpectationFailed | typeof AuthTooManyRequests | typeof AuthInternalServerError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"organizationGetFull", "GET", "/organization/get-full-organization", never, Schema.toCodecStringTree<Schema.Struct<{
|
|
541
559
|
readonly organizationId: Schema.optional<Schema.String>;
|
|
542
560
|
readonly organizationSlug: Schema.optional<Schema.String>;
|
package/dist/auth/api.group.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
2
|
import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/http-api";
|
|
3
|
-
import { AdminBanUserPayload, AdminStopImpersonatingPayload, AdminUserIdPayload, AdminUserResponse, AuthBadRequest, AuthConflict, AuthExpectationFailed, AuthForbidden, AuthInternalServerError, AuthInvitation, AuthNotFound, AuthOrganization, AuthSessionResponse, AuthStatusResponse, AuthSuccessResponse, AuthTooManyRequests, AuthUnauthorized, ChangePasswordPayload, ChangePasswordResponse, CreateOrganizationPayload, DeleteApiKeyPayload, FullAuthOrganization, GetFullOrganizationQuery, GetInvitationQuery, GetInvitationResponse, GetSessionQuery, GetSessionResponse, InvitationActionResponse, InvitationIdPayload, InviteMemberPayload, LeaveOrganizationPayload, LinkedAccount, LinkSocialPayload, ListApiKeysQuery, ListApiKeysResponse, MemberResponse, OAuthConsentPayload, OAuthPublicClient, OAuthPublicClientQuery, OAuthRedirectResponse, OrganizationImpersonateUserPayload, OrganizationImpersonateUserResponse, OrganizationInvitationsQuery, OrganizationListMembersQuery, OrganizationListMembersResponse, RemoveMemberPayload, RequestPasswordResetPayload, RequestPasswordResetResponse, ResetPasswordPayload, SendVerificationOtpPayload, SetActiveOrganizationPayload, SignInEmailOtpPayload, SignInEmailPayload, SignInEmailResponse, SignInResponse, SignInSocialPayload, SignOutPayload, SocialRedirectResponse, TwoFactorBackupVerifyPayload, TwoFactorDisablePayload, TwoFactorEnablePayload, TwoFactorEnableResponse, TwoFactorSendPayload, TwoFactorVerifyPayload, UnlinkAccountPayload, UpdateMemberRolePayload, UpdateOrganizationPayload, UpdateUserPayload, UserInvitationsQuery, VerifyEmailOtpPayload, VerifyEmailOtpResponse, } from "./schema.js";
|
|
3
|
+
import { DeleteUserPayload, DeleteOrganizationPayload, DeleteUserResponse, AdminBanUserPayload, AdminStopImpersonatingPayload, AdminUserIdPayload, AdminUserResponse, AuthBadRequest, AuthConflict, AuthExpectationFailed, AuthForbidden, AuthInternalServerError, AuthInvitation, AuthNotFound, AuthOrganization, AuthSessionResponse, AuthStatusResponse, AuthSuccessResponse, AuthTooManyRequests, AuthUnauthorized, ChangePasswordPayload, ChangePasswordResponse, CreateOrganizationPayload, DeleteApiKeyPayload, FullAuthOrganization, GetFullOrganizationQuery, GetInvitationQuery, GetInvitationResponse, GetSessionQuery, GetSessionResponse, InvitationActionResponse, InvitationIdPayload, InviteMemberPayload, LeaveOrganizationPayload, LinkedAccount, LinkSocialPayload, ListApiKeysQuery, ListApiKeysResponse, MemberResponse, OAuthConsentPayload, OAuthPublicClient, OAuthPublicClientQuery, OAuthRedirectResponse, OrganizationImpersonateUserPayload, OrganizationImpersonateUserResponse, OrganizationInvitationsQuery, OrganizationListMembersQuery, OrganizationListMembersResponse, RemoveMemberPayload, RequestPasswordResetPayload, RequestPasswordResetResponse, ResetPasswordPayload, SendVerificationOtpPayload, SetActiveOrganizationPayload, SignInEmailOtpPayload, SignInEmailPayload, SignInEmailResponse, SignInResponse, SignInSocialPayload, SignOutPayload, SocialRedirectResponse, TwoFactorBackupVerifyPayload, TwoFactorDisablePayload, TwoFactorEnablePayload, TwoFactorEnableResponse, TwoFactorSendPayload, TwoFactorVerifyPayload, UnlinkAccountPayload, UpdateMemberRolePayload, UpdateOrganizationPayload, UpdateUserPayload, UserInvitationsQuery, VerifyEmailOtpPayload, VerifyEmailOtpResponse, } from "./schema.js";
|
|
4
4
|
export * from "./schema.js";
|
|
5
5
|
const errors = [
|
|
6
6
|
AuthBadRequest,
|
|
@@ -14,6 +14,17 @@ const errors = [
|
|
|
14
14
|
];
|
|
15
15
|
const docs = (title, description) => OpenApi.annotations({ title, summary: title, description });
|
|
16
16
|
export const AuthApiGroup = HttpApiGroup.make("auth")
|
|
17
|
+
.add(HttpApiEndpoint.post("deleteUser", "/delete-user", {
|
|
18
|
+
payload: DeleteUserPayload,
|
|
19
|
+
success: DeleteUserResponse,
|
|
20
|
+
error: [
|
|
21
|
+
AuthBadRequest,
|
|
22
|
+
AuthUnauthorized,
|
|
23
|
+
AuthForbidden,
|
|
24
|
+
AuthNotFound,
|
|
25
|
+
AuthInternalServerError,
|
|
26
|
+
],
|
|
27
|
+
}))
|
|
17
28
|
.add(HttpApiEndpoint.get("getSession", "/get-session", {
|
|
18
29
|
query: GetSessionQuery.fields,
|
|
19
30
|
success: GetSessionResponse,
|
|
@@ -132,6 +143,11 @@ export const AuthApiGroup = HttpApiGroup.make("auth")
|
|
|
132
143
|
success: AuthOrganization,
|
|
133
144
|
error: errors,
|
|
134
145
|
}).annotateMerge(docs("Create organization", "Creates an organization.")))
|
|
146
|
+
.add(HttpApiEndpoint.post("organizationDelete", "/organization/delete", {
|
|
147
|
+
payload: DeleteOrganizationPayload,
|
|
148
|
+
success: AuthOrganization,
|
|
149
|
+
error: errors,
|
|
150
|
+
}).annotateMerge(docs("Delete organization", "Permanently deletes an organization owned by the current user. Personal organizations are protected.")))
|
|
135
151
|
.add(HttpApiEndpoint.post("organizationUpdate", "/organization/update", {
|
|
136
152
|
payload: UpdateOrganizationPayload,
|
|
137
153
|
success: AuthOrganization,
|
package/dist/auth/schema.d.ts
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
|
+
export declare const DeleteUserPayload: Schema.Struct<{
|
|
3
|
+
readonly password: Schema.optional<Schema.String>;
|
|
4
|
+
readonly token: Schema.optional<Schema.String>;
|
|
5
|
+
readonly callbackURL: Schema.optional<Schema.String>;
|
|
6
|
+
}>;
|
|
7
|
+
export declare const DeleteUserResponse: Schema.Struct<{
|
|
8
|
+
readonly success: Schema.Boolean;
|
|
9
|
+
readonly message: Schema.String;
|
|
10
|
+
}>;
|
|
2
11
|
export declare const AuthRedirectURLFromString: (origin?: string) => Schema.decodeTo<Schema.URL, Schema.String, never, never>;
|
|
3
12
|
export declare const AuthUser: Schema.Struct<{
|
|
4
13
|
readonly id: Schema.String;
|
|
@@ -991,6 +1000,9 @@ export declare const RemoveMemberPayload: Schema.Struct<{
|
|
|
991
1000
|
readonly memberIdOrEmail: Schema.String;
|
|
992
1001
|
readonly organizationId: Schema.optional<Schema.String>;
|
|
993
1002
|
}>;
|
|
1003
|
+
export declare const DeleteOrganizationPayload: Schema.Struct<{
|
|
1004
|
+
readonly organizationId: Schema.NonEmptyString;
|
|
1005
|
+
}>;
|
|
994
1006
|
export declare const LeaveOrganizationPayload: Schema.Struct<{
|
|
995
1007
|
readonly organizationId: Schema.String;
|
|
996
1008
|
}>;
|
package/dist/auth/schema.js
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import { Effect, Schema, SchemaIssue, SchemaTransformation } from "effect";
|
|
2
|
+
export const DeleteUserPayload = Schema.Struct({
|
|
3
|
+
password: Schema.optional(Schema.String),
|
|
4
|
+
token: Schema.optional(Schema.String),
|
|
5
|
+
callbackURL: Schema.optional(Schema.String),
|
|
6
|
+
}).annotate({ identifier: "DeleteUserPayload" });
|
|
7
|
+
export const DeleteUserResponse = Schema.Struct({
|
|
8
|
+
success: Schema.Boolean,
|
|
9
|
+
message: Schema.String,
|
|
10
|
+
}).annotate({ identifier: "DeleteUserResponse" });
|
|
2
11
|
import { User, UserLocale, UserMetadata } from "../schema.js";
|
|
3
12
|
const JsonRecord = Schema.Record(Schema.String, Schema.Json);
|
|
4
13
|
const StringArrayRecord = Schema.Record(Schema.String, Schema.Array(Schema.String));
|
|
@@ -501,6 +510,9 @@ export const RemoveMemberPayload = Schema.Struct({
|
|
|
501
510
|
identifier: "RemoveMemberPayload",
|
|
502
511
|
title: "Remove member payload",
|
|
503
512
|
});
|
|
513
|
+
export const DeleteOrganizationPayload = Schema.Struct({
|
|
514
|
+
organizationId: Schema.NonEmptyString,
|
|
515
|
+
}).annotate({ identifier: "DeleteOrganizationPayload" });
|
|
504
516
|
export const LeaveOrganizationPayload = Schema.Struct({
|
|
505
517
|
organizationId: Schema.String,
|
|
506
518
|
}).annotate({
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
export declare const requestAccountDeletion: (password: string, baseUrl?: string) => Effect.Effect<{
|
|
3
|
+
readonly success: boolean;
|
|
4
|
+
readonly message: string;
|
|
5
|
+
}, import("../auth/schema.js").AuthBadRequest | import("../auth/schema.js").AuthForbidden | import("../auth/schema.js").AuthInternalServerError | import("../auth/schema.js").AuthNotFound | import("../auth/schema.js").AuthUnauthorized | import("effect/http/HttpClientError").HttpClientError | import("effect/Schema").SchemaError, never>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { authHttpClient } from "./auth-client-api.js";
|
|
3
|
+
export const requestAccountDeletion = (password, baseUrl) => authHttpClient(baseUrl).pipe(Effect.flatMap((client) => client.auth.deleteUser({
|
|
4
|
+
// Better Auth accepts an absent password, not null. Explicit undefined
|
|
5
|
+
// values are encoded as null by the HTTP API's JSON codec.
|
|
6
|
+
payload: password ? { password } : {},
|
|
7
|
+
})));
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type AccountDeletionLabels = Record<"title" | "description" | "projects" | "organizations" | "retention" | "missing" | "owner" | "admin" | "confirm" | "password" | "error" | "loadError" | "cancel" | "submit" | "done" | "complete", string>;
|
|
2
|
+
export declare const AccountDeletionDialog: (props: {
|
|
3
|
+
baseUrl?: string | undefined;
|
|
4
|
+
userId: string;
|
|
5
|
+
labels: AccountDeletionLabels;
|
|
6
|
+
onClose: () => void;
|
|
7
|
+
onDeleted: () => void;
|
|
8
|
+
}) => import("react").JSX.Element;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useAtomSet, useAtomValue } from "@effect/atom-react";
|
|
3
|
+
import { AsyncResult, Atom } from "effect/reactivity";
|
|
4
|
+
import { Schema } from "effect";
|
|
5
|
+
import { useId, useState } from "react";
|
|
6
|
+
import { AppWindow, Building2, TriangleAlert, UserRound } from "lucide-react";
|
|
7
|
+
import { Button } from "@/components/ui/button";
|
|
8
|
+
import { Card, CardContent } from "@/components/ui/card";
|
|
9
|
+
import { Input } from "@/components/ui/input";
|
|
10
|
+
import { FieldLabel } from "@/components/ui/field";
|
|
11
|
+
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter, } from "@/components/ui/dialog";
|
|
12
|
+
import { authClientApi } from "./auth-client-api.js";
|
|
13
|
+
import { requestAccountDeletion } from "./account-deletion-request.js";
|
|
14
|
+
import { refreshOnAuthChange } from "./auth-atoms.js";
|
|
15
|
+
const planQueries = Atom.family((baseUrl) => Atom.family((userId) => authClientApi(baseUrl)
|
|
16
|
+
.query("authExtra", "getAccountDeletionPlan", {
|
|
17
|
+
timeToLive: "0 seconds",
|
|
18
|
+
serializationKey: `account-deletion:${userId}`,
|
|
19
|
+
})
|
|
20
|
+
.pipe(refreshOnAuthChange)));
|
|
21
|
+
const plans = Atom.family((baseUrl) => Atom.family((userId) => Atom.optimistic(planQueries(baseUrl)(userId))));
|
|
22
|
+
export const AccountDeletionDialog = (props) => {
|
|
23
|
+
const [confirmation, setConfirmation] = useState("");
|
|
24
|
+
const passwordId = useId();
|
|
25
|
+
const confirmationId = useId();
|
|
26
|
+
const projectsId = useId();
|
|
27
|
+
const organizationsId = useId();
|
|
28
|
+
const [password, setPassword] = useState("");
|
|
29
|
+
const planResult = useAtomValue(plans(props.baseUrl)(props.userId));
|
|
30
|
+
const [mutation] = useState(() => authClientApi(props.baseUrl).runtime.fn((password) => requestAccountDeletion(password, props.baseUrl)));
|
|
31
|
+
const remove = useAtomSet(mutation);
|
|
32
|
+
const result = useAtomValue(mutation);
|
|
33
|
+
const plan = AsyncResult.match(planResult, {
|
|
34
|
+
onInitial: () => null,
|
|
35
|
+
onFailure: () => null,
|
|
36
|
+
onSuccess: ({ value }) => value,
|
|
37
|
+
});
|
|
38
|
+
const completed = AsyncResult.isSuccess(result) && result.value.success;
|
|
39
|
+
const blockedByOrganizations = (plan?.organizations.length ?? 0) > 0;
|
|
40
|
+
const busy = result.waiting;
|
|
41
|
+
const disabled = !plan ||
|
|
42
|
+
plan.organizations.length > 0 ||
|
|
43
|
+
plan.adminAccount ||
|
|
44
|
+
!Schema.is(Schema.Literal("DELETE"))(confirmation) ||
|
|
45
|
+
busy;
|
|
46
|
+
const labels = props.labels;
|
|
47
|
+
return (_jsx(Dialog, { open: true, onOpenChange: (open) => {
|
|
48
|
+
if (!open && !busy) {
|
|
49
|
+
if (completed)
|
|
50
|
+
props.onDeleted();
|
|
51
|
+
else
|
|
52
|
+
props.onClose();
|
|
53
|
+
}
|
|
54
|
+
}, children: _jsxs(DialogContent, { className: "max-h-[85vh] overflow-y-auto sm:max-w-xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: labels.title }), _jsx(DialogDescription, { children: completed ? labels.complete : labels.description })] }), completed ? (_jsx(Button, { onClick: props.onDeleted, children: labels.done })) : (_jsxs("form", { className: "flex flex-col gap-4", onSubmit: (event) => {
|
|
55
|
+
event.preventDefault();
|
|
56
|
+
if (!disabled)
|
|
57
|
+
remove(password);
|
|
58
|
+
}, children: [plan ? (_jsxs(_Fragment, { children: [plan.projects.length ? (_jsxs("section", { "aria-labelledby": projectsId, className: "space-y-2", children: [_jsxs("h3", { id: projectsId, className: "text-muted-foreground text-xs font-medium", children: [labels.projects, " ", _jsx("span", { className: "ml-1 tabular-nums", children: plan.projects.length })] }), _jsx("ul", { className: "grid gap-2 sm:grid-cols-2", children: plan.projects.map((project) => (_jsx("li", { children: _jsx(Card, { size: "sm", className: "h-full py-3 shadow-none", children: _jsxs(CardContent, { className: "flex items-center gap-3 px-3", children: [_jsx("span", { className: "bg-muted text-muted-foreground flex size-9 shrink-0 items-center justify-center rounded-lg", children: _jsx(AppWindow, { "aria-hidden": "true", className: "size-4" }) }), _jsx("span", { className: "min-w-0 flex-1 text-sm font-medium break-words", children: project.name }), !project.ready ? (_jsxs("span", { title: labels.missing, className: "text-muted-foreground shrink-0", children: [_jsx(TriangleAlert, { "aria-hidden": "true", className: "size-4" }), _jsx("span", { className: "sr-only", children: labels.missing })] })) : null] }) }) }, project.id))) }), plan.projects.some((project) => !project.ready) ? (_jsx("p", { role: "status", className: "text-muted-foreground text-xs", children: labels.missing })) : null] })) : null, plan.organizations.length ? (_jsxs("section", { "aria-labelledby": organizationsId, className: "space-y-2", children: [_jsxs("h3", { id: organizationsId, className: "text-destructive text-xs font-medium", children: [labels.organizations, " ", _jsx("span", { className: "ml-1 tabular-nums", children: plan.organizations.length })] }), _jsx("ul", { className: "grid gap-2 sm:grid-cols-2", children: plan.organizations.map((organization) => (_jsx("li", { children: _jsx(Card, { size: "sm", className: "bg-destructive/5 ring-destructive/20 h-full py-3 shadow-none", children: _jsxs(CardContent, { className: "flex items-center gap-3 px-3", children: [_jsx("span", { className: "bg-destructive/10 text-destructive flex size-9 shrink-0 items-center justify-center rounded-lg", children: organization.personal ? (_jsx(UserRound, { "aria-hidden": "true", className: "size-4" })) : (_jsx(Building2, { "aria-hidden": "true", className: "size-4" })) }), _jsx("span", { className: "min-w-0 text-sm font-medium break-words", children: organization.name })] }) }) }, organization.id))) }), _jsx("p", { role: "alert", className: "text-destructive text-xs", children: labels.owner })] })) : null, plan.adminAccount ? (_jsx("p", { role: "alert", className: "text-destructive text-sm", children: labels.admin })) : null] })) : (_jsx("p", { role: "status", className: "text-muted-foreground text-sm", children: labels.loadError })), !blockedByOrganizations ? (_jsxs(_Fragment, { children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(FieldLabel, { htmlFor: passwordId, children: labels.password }), _jsx(Input, { id: passwordId, type: "password", autoComplete: "current-password", value: password, onChange: (event) => setPassword(event.target.value) })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(FieldLabel, { htmlFor: confirmationId, children: labels.confirm }), _jsx(Input, { id: confirmationId, value: confirmation, autoComplete: "off", onChange: (event) => setConfirmation(event.target.value) })] }), AsyncResult.isFailure(result) ? (_jsx("p", { role: "alert", className: "text-destructive text-sm", children: labels.error })) : null] })) : null, _jsx("p", { className: "text-muted-foreground text-xs", children: labels.retention }), _jsxs(DialogFooter, { children: [_jsx(Button, { type: "button", variant: "outline", disabled: busy, onClick: props.onClose, children: labels.cancel }), !blockedByOrganizations ? (_jsx(Button, { type: "submit", variant: "destructive", disabled: disabled, children: labels.submit })) : null] })] }))] }) }));
|
|
59
|
+
};
|
|
@@ -13,6 +13,7 @@ import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent,
|
|
|
13
13
|
import { AdminListQuery } from "../admin/schema.js";
|
|
14
14
|
import { normalizeOrganizationRoles } from "../roles.js";
|
|
15
15
|
import { AdminOrganizationForm } from "./admin-organization-form.js";
|
|
16
|
+
import { deletionControlsEnabled } from "./deletion-visibility.js";
|
|
16
17
|
import { authClientApi, authHttpClient } from "./auth-client-api.js";
|
|
17
18
|
import { useKrakstackAuth } from "./auth-provider.js";
|
|
18
19
|
import { assetUrl, organizationBranding } from "./utils.js";
|
|
@@ -220,16 +221,17 @@ export function AdminOrganizationsTable({ messages: messageOverrides, onSearchCh
|
|
|
220
221
|
icon: _jsx(Trash2, { className: "size-4" }),
|
|
221
222
|
variant: "destructive",
|
|
222
223
|
onClick: setDeletingOrganization,
|
|
223
|
-
visible: (organization) => !organization.userId,
|
|
224
|
+
visible: (organization) => deletionControlsEnabled && !organization.userId,
|
|
224
225
|
},
|
|
225
226
|
],
|
|
226
227
|
},
|
|
227
|
-
}, state: tableRequest.search, onStateChange: ({ page, pageSize, globalFilter, sort }) => {
|
|
228
|
+
}, state: tableRequest.search, onStateChange: ({ page, pageSize, globalFilter, sort, filters }) => {
|
|
228
229
|
const nextSearch = Schema.decodeUnknownSync(Query)({
|
|
229
230
|
page,
|
|
230
231
|
pageSize,
|
|
231
232
|
globalFilter,
|
|
232
233
|
sort,
|
|
234
|
+
filters,
|
|
233
235
|
});
|
|
234
236
|
setTableRequest((current) => ({
|
|
235
237
|
...current,
|
|
@@ -241,7 +243,7 @@ export function AdminOrganizationsTable({ messages: messageOverrides, onSearchCh
|
|
|
241
243
|
}, status: { loading: isLoading } }), editingOrganization ? (_jsx(AdminOrganizationForm, { organization: editingOrganization, onClose: () => setEditingOrganization(null), onSaved: () => setTableRequest((current) => ({
|
|
242
244
|
...current,
|
|
243
245
|
refreshKey: current.refreshKey + 1,
|
|
244
|
-
})) })) : null, deletingOrganization ? (_jsx(DeleteOrganizationDialog, { labels: m, organization: deletingOrganization, baseUrl: baseUrl, onClose: () => setDeletingOrganization(null), onDeleted: () => {
|
|
246
|
+
})) })) : null, deletionControlsEnabled && deletingOrganization ? (_jsx(DeleteOrganizationDialog, { labels: m, organization: deletingOrganization, baseUrl: baseUrl, onClose: () => setDeletingOrganization(null), onDeleted: () => {
|
|
245
247
|
setDeletingOrganization(null);
|
|
246
248
|
setTableRequest((current) => ({
|
|
247
249
|
...current,
|
|
@@ -261,6 +263,7 @@ const organizationColumns = (m, locale, baseUrl, impersonate, impersonateAsOrgan
|
|
|
261
263
|
{
|
|
262
264
|
field: "memberCount",
|
|
263
265
|
headerName: m.admin_column_members,
|
|
266
|
+
filterable: false,
|
|
264
267
|
type: "list",
|
|
265
268
|
typeOptions: {
|
|
266
269
|
emptyLabel: "0",
|
|
@@ -302,6 +305,11 @@ const organizationColumns = (m, locale, baseUrl, impersonate, impersonateAsOrgan
|
|
|
302
305
|
{
|
|
303
306
|
field: "userId",
|
|
304
307
|
headerName: m.organization_type,
|
|
308
|
+
filterOptions: [
|
|
309
|
+
{ value: "personal", label: m.organization_type_personal },
|
|
310
|
+
{ value: "standard", label: m.organization_type_standard },
|
|
311
|
+
],
|
|
312
|
+
filterValueGetter: ({ data }) => (data.userId ? "personal" : "standard"),
|
|
305
313
|
cellRenderer: ({ data }) => (_jsx(Badge, { variant: data.userId ? "secondary" : "outline", children: data.userId
|
|
306
314
|
? m.organization_type_personal
|
|
307
315
|
: m.organization_type_standard })),
|
|
@@ -309,6 +317,7 @@ const organizationColumns = (m, locale, baseUrl, impersonate, impersonateAsOrgan
|
|
|
309
317
|
{
|
|
310
318
|
field: "projects",
|
|
311
319
|
headerName: m.admin_column_projects,
|
|
320
|
+
filterable: false,
|
|
312
321
|
type: "list",
|
|
313
322
|
typeOptions: {
|
|
314
323
|
emptyLabel: "-",
|
|
@@ -326,6 +335,7 @@ const organizationColumns = (m, locale, baseUrl, impersonate, impersonateAsOrgan
|
|
|
326
335
|
{
|
|
327
336
|
field: "createdAt",
|
|
328
337
|
headerName: m.admin_column_created,
|
|
338
|
+
type: "date",
|
|
329
339
|
cellRenderer: ({ data }) => (_jsx("span", { className: "text-muted-foreground text-sm", children: new Date(data.createdAt).toLocaleDateString() })),
|
|
330
340
|
},
|
|
331
341
|
];
|
|
@@ -199,12 +199,13 @@ export function AdminUsersTable({ onSearchChange, reloadKey = 0, search, }) {
|
|
|
199
199
|
},
|
|
200
200
|
],
|
|
201
201
|
},
|
|
202
|
-
}, state: tableRequest.search, onStateChange: ({ page, pageSize, globalFilter, sort }) => {
|
|
202
|
+
}, state: tableRequest.search, onStateChange: ({ page, pageSize, globalFilter, sort, filters }) => {
|
|
203
203
|
const nextSearch = Schema.decodeUnknownSync(Query)({
|
|
204
204
|
page,
|
|
205
205
|
pageSize,
|
|
206
206
|
globalFilter,
|
|
207
207
|
sort,
|
|
208
|
+
filters,
|
|
208
209
|
});
|
|
209
210
|
setTableRequest((current) => ({
|
|
210
211
|
...current,
|
|
@@ -242,6 +243,7 @@ const userColumns = (m, baseUrl) => [
|
|
|
242
243
|
{
|
|
243
244
|
field: "organizations",
|
|
244
245
|
headerName: m.admin_column_organizations,
|
|
246
|
+
filterable: false,
|
|
245
247
|
type: "list",
|
|
246
248
|
typeOptions: {
|
|
247
249
|
emptyLabel: "-",
|
|
@@ -259,6 +261,7 @@ const userColumns = (m, baseUrl) => [
|
|
|
259
261
|
{
|
|
260
262
|
field: "projects",
|
|
261
263
|
headerName: m.admin_column_projects,
|
|
264
|
+
filterable: false,
|
|
262
265
|
type: "list",
|
|
263
266
|
typeOptions: {
|
|
264
267
|
emptyLabel: "-",
|
|
@@ -276,11 +279,17 @@ const userColumns = (m, baseUrl) => [
|
|
|
276
279
|
{
|
|
277
280
|
field: "emailVerified",
|
|
278
281
|
headerName: m.admin_column_verified,
|
|
282
|
+
type: "boolean",
|
|
283
|
+
typeOptions: {
|
|
284
|
+
trueLabel: m.admin_column_verified,
|
|
285
|
+
falseLabel: m.admin_column_unverified,
|
|
286
|
+
},
|
|
279
287
|
cellRenderer: ({ data }) => data.emailVerified ? (_jsx(Badge, { variant: "outline", children: m.admin_column_verified })) : (_jsx(Badge, { variant: "secondary", children: m.admin_column_unverified })),
|
|
280
288
|
},
|
|
281
289
|
{
|
|
282
290
|
field: "role",
|
|
283
291
|
headerName: m.admin_column_role,
|
|
292
|
+
filterValueGetter: ({ data }) => data.role ?? "user",
|
|
284
293
|
cellRenderer: ({ data }) => {
|
|
285
294
|
const role = data.role;
|
|
286
295
|
if (!role)
|
|
@@ -291,16 +300,24 @@ const userColumns = (m, baseUrl) => [
|
|
|
291
300
|
{
|
|
292
301
|
field: "banned",
|
|
293
302
|
headerName: m.admin_column_status,
|
|
303
|
+
type: "boolean",
|
|
304
|
+
filterValueGetter: ({ data }) => Boolean(data.banned),
|
|
305
|
+
typeOptions: {
|
|
306
|
+
trueLabel: m.admin_status_banned,
|
|
307
|
+
falseLabel: m.admin_status_active,
|
|
308
|
+
},
|
|
294
309
|
cellRenderer: ({ data }) => data.banned ? (_jsx(Badge, { variant: "destructive", children: m.admin_status_banned })) : (_jsx(Badge, { variant: "outline", children: m.admin_status_active })),
|
|
295
310
|
},
|
|
296
311
|
{
|
|
297
312
|
field: "lastSignedIn",
|
|
298
313
|
headerName: m.admin_column_last_signed_in,
|
|
314
|
+
type: "dateTime",
|
|
299
315
|
cellRenderer: ({ data }) => (_jsx("span", { className: "text-muted-foreground text-sm", children: data.lastSignedIn ? new Date(data.lastSignedIn).toLocaleString() : "-" })),
|
|
300
316
|
},
|
|
301
317
|
{
|
|
302
318
|
field: "createdAt",
|
|
303
319
|
headerName: m.admin_column_created,
|
|
320
|
+
type: "date",
|
|
304
321
|
cellRenderer: ({ data }) => (_jsx("span", { className: "text-muted-foreground text-sm", children: new Date(data.createdAt).toLocaleDateString() })),
|
|
305
322
|
},
|
|
306
323
|
];
|
|
@@ -20,5 +20,5 @@ export const AssociatedProjectsNotice = ({ baseUrl, getSummary, organizationId =
|
|
|
20
20
|
});
|
|
21
21
|
if (projects.length <= 1)
|
|
22
22
|
return null;
|
|
23
|
-
return (_jsxs("details", { className: "border-primary/60 text-muted-foreground border-l-2 pl-3 text-sm", children: [_jsxs("summary", { className: "cursor-pointer list-none [&::-webkit-details-marker]:hidden", children: [getSummary(projects.length), " ", _jsx("span", { className: "text-foreground underline underline-offset-4", children: viewLabel })] }), _jsx("div", { className: "mt-2 flex flex-wrap gap-2", children: projects.map((project) => (_jsx(Badge, { variant: "secondary", children: project.name }, project.id))) })] }));
|
|
23
|
+
return (_jsx("div", { className: "px-1 py-2", children: _jsxs("details", { className: "border-primary/60 text-muted-foreground border-l-2 pl-3 text-sm", children: [_jsxs("summary", { className: "cursor-pointer list-none [&::-webkit-details-marker]:hidden", children: [getSummary(projects.length), " ", _jsx("span", { className: "text-foreground underline underline-offset-4", children: viewLabel })] }), _jsx("div", { className: "mt-2 flex flex-wrap gap-2", children: projects.map((project) => (_jsx(Badge, { variant: "secondary", children: project.name }, project.id))) })] }) }));
|
|
24
24
|
};
|
|
@@ -243,6 +243,53 @@ export declare const authHttpClient: (baseUrl?: string | undefined, getLocale?:
|
|
|
243
243
|
readonly direction: "asc" | "desc";
|
|
244
244
|
}[]>>;
|
|
245
245
|
readonly projectId: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
246
|
+
readonly filters: import("effect/Schema").optional<import("effect/Schema").declare<readonly ({
|
|
247
|
+
readonly id: string;
|
|
248
|
+
readonly kind: "number";
|
|
249
|
+
readonly min?: number | undefined;
|
|
250
|
+
readonly max?: number | undefined;
|
|
251
|
+
} | {
|
|
252
|
+
readonly id: string;
|
|
253
|
+
readonly kind: "date";
|
|
254
|
+
readonly from?: string | undefined;
|
|
255
|
+
readonly to?: string | undefined;
|
|
256
|
+
} | {
|
|
257
|
+
readonly id: string;
|
|
258
|
+
readonly kind: "text";
|
|
259
|
+
readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
|
|
260
|
+
readonly value: string;
|
|
261
|
+
} | {
|
|
262
|
+
readonly id: string;
|
|
263
|
+
readonly kind: "boolean";
|
|
264
|
+
readonly value: boolean;
|
|
265
|
+
} | {
|
|
266
|
+
readonly id: string;
|
|
267
|
+
readonly kind: "values";
|
|
268
|
+
readonly values: readonly [string, ...string[]];
|
|
269
|
+
})[], readonly ({
|
|
270
|
+
readonly id: string;
|
|
271
|
+
readonly kind: "number";
|
|
272
|
+
readonly min?: number | undefined;
|
|
273
|
+
readonly max?: number | undefined;
|
|
274
|
+
} | {
|
|
275
|
+
readonly id: string;
|
|
276
|
+
readonly kind: "date";
|
|
277
|
+
readonly from?: string | undefined;
|
|
278
|
+
readonly to?: string | undefined;
|
|
279
|
+
} | {
|
|
280
|
+
readonly id: string;
|
|
281
|
+
readonly kind: "text";
|
|
282
|
+
readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
|
|
283
|
+
readonly value: string;
|
|
284
|
+
} | {
|
|
285
|
+
readonly id: string;
|
|
286
|
+
readonly kind: "boolean";
|
|
287
|
+
readonly value: boolean;
|
|
288
|
+
} | {
|
|
289
|
+
readonly id: string;
|
|
290
|
+
readonly kind: "values";
|
|
291
|
+
readonly values: readonly [string, ...string[]];
|
|
292
|
+
})[]>>;
|
|
246
293
|
}>>, never, never, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{
|
|
247
294
|
readonly data: import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
248
295
|
readonly id: import("effect/Schema").String;
|
|
@@ -285,6 +332,53 @@ export declare const authHttpClient: (baseUrl?: string | undefined, getLocale?:
|
|
|
285
332
|
readonly direction: "asc" | "desc";
|
|
286
333
|
}[]>>;
|
|
287
334
|
readonly projectId: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
335
|
+
readonly filters: import("effect/Schema").optional<import("effect/Schema").declare<readonly ({
|
|
336
|
+
readonly id: string;
|
|
337
|
+
readonly kind: "number";
|
|
338
|
+
readonly min?: number | undefined;
|
|
339
|
+
readonly max?: number | undefined;
|
|
340
|
+
} | {
|
|
341
|
+
readonly id: string;
|
|
342
|
+
readonly kind: "date";
|
|
343
|
+
readonly from?: string | undefined;
|
|
344
|
+
readonly to?: string | undefined;
|
|
345
|
+
} | {
|
|
346
|
+
readonly id: string;
|
|
347
|
+
readonly kind: "text";
|
|
348
|
+
readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
|
|
349
|
+
readonly value: string;
|
|
350
|
+
} | {
|
|
351
|
+
readonly id: string;
|
|
352
|
+
readonly kind: "boolean";
|
|
353
|
+
readonly value: boolean;
|
|
354
|
+
} | {
|
|
355
|
+
readonly id: string;
|
|
356
|
+
readonly kind: "values";
|
|
357
|
+
readonly values: readonly [string, ...string[]];
|
|
358
|
+
})[], readonly ({
|
|
359
|
+
readonly id: string;
|
|
360
|
+
readonly kind: "number";
|
|
361
|
+
readonly min?: number | undefined;
|
|
362
|
+
readonly max?: number | undefined;
|
|
363
|
+
} | {
|
|
364
|
+
readonly id: string;
|
|
365
|
+
readonly kind: "date";
|
|
366
|
+
readonly from?: string | undefined;
|
|
367
|
+
readonly to?: string | undefined;
|
|
368
|
+
} | {
|
|
369
|
+
readonly id: string;
|
|
370
|
+
readonly kind: "text";
|
|
371
|
+
readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
|
|
372
|
+
readonly value: string;
|
|
373
|
+
} | {
|
|
374
|
+
readonly id: string;
|
|
375
|
+
readonly kind: "boolean";
|
|
376
|
+
readonly value: boolean;
|
|
377
|
+
} | {
|
|
378
|
+
readonly id: string;
|
|
379
|
+
readonly kind: "values";
|
|
380
|
+
readonly values: readonly [string, ...string[]];
|
|
381
|
+
})[]>>;
|
|
288
382
|
}>>, never, never, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{
|
|
289
383
|
readonly data: import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
290
384
|
readonly id: import("effect/Schema").String;
|
|
@@ -754,6 +848,14 @@ export declare const authHttpClient: (baseUrl?: string | undefined, getLocale?:
|
|
|
754
848
|
readonly updatedAt: import("effect/Schema").DateFromString;
|
|
755
849
|
}>;
|
|
756
850
|
}>>, import("effect/Schema").toCodecJson<typeof import("../auth/schema.js").AuthBadRequest | typeof import("../auth/schema.js").AuthUnauthorized | typeof import("../auth/schema.js").AuthForbidden | typeof import("../auth/schema.js").AuthNotFound | typeof import("../auth/schema.js").AuthConflict | typeof import("../auth/schema.js").AuthExpectationFailed | typeof import("../auth/schema.js").AuthTooManyRequests | typeof import("../auth/schema.js").AuthInternalServerError>, never, never>, never, never>;
|
|
851
|
+
readonly deleteUser: HttpApiClient.Client.Method<import("effect/http-api/HttpApiEndpoint").HttpApiEndpoint<"deleteUser", "POST", "/api/auth/delete-user", never, never, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{
|
|
852
|
+
readonly password: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
853
|
+
readonly token: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
854
|
+
readonly callbackURL: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
855
|
+
}>>, never, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{
|
|
856
|
+
readonly success: import("effect/Schema").Boolean;
|
|
857
|
+
readonly message: import("effect/Schema").String;
|
|
858
|
+
}>>, import("effect/Schema").toCodecJson<typeof import("../auth/schema.js").AuthBadRequest | typeof import("../auth/schema.js").AuthUnauthorized | typeof import("../auth/schema.js").AuthForbidden | typeof import("../auth/schema.js").AuthNotFound | typeof import("../auth/schema.js").AuthInternalServerError>, never, never>, never, never>;
|
|
757
859
|
readonly getSession: HttpApiClient.Client.Method<import("effect/http-api/HttpApiEndpoint").HttpApiEndpoint<"getSession", "GET", "/api/auth/get-session", never, import("effect/Schema").toCodecStringTree<import("effect/Schema").Struct<{
|
|
758
860
|
readonly disableCookieCache: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
759
861
|
readonly disableRefresh: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
@@ -972,6 +1074,18 @@ export declare const authHttpClient: (baseUrl?: string | undefined, getLocale?:
|
|
|
972
1074
|
readonly parentId: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
973
1075
|
readonly createdAt: import("effect/Schema").DateFromString;
|
|
974
1076
|
}>>, import("effect/Schema").toCodecJson<typeof import("../auth/schema.js").AuthBadRequest | typeof import("../auth/schema.js").AuthUnauthorized | typeof import("../auth/schema.js").AuthForbidden | typeof import("../auth/schema.js").AuthNotFound | typeof import("../auth/schema.js").AuthConflict | typeof import("../auth/schema.js").AuthExpectationFailed | typeof import("../auth/schema.js").AuthTooManyRequests | typeof import("../auth/schema.js").AuthInternalServerError>, never, never>, never, never>;
|
|
1077
|
+
readonly organizationDelete: HttpApiClient.Client.Method<import("effect/http-api/HttpApiEndpoint").HttpApiEndpoint<"organizationDelete", "POST", "/api/auth/organization/delete", never, never, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{
|
|
1078
|
+
readonly organizationId: import("effect/Schema").NonEmptyString;
|
|
1079
|
+
}>>, never, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{
|
|
1080
|
+
readonly id: import("effect/Schema").String;
|
|
1081
|
+
readonly name: import("effect/Schema").String;
|
|
1082
|
+
readonly slug: import("effect/Schema").String;
|
|
1083
|
+
readonly logo: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
1084
|
+
readonly metadata: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").Union<readonly [import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").Codec<import("effect/Schema").Json, import("effect/Schema").Json, never, never>>, import("effect/Schema").String]>>>;
|
|
1085
|
+
readonly userId: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
1086
|
+
readonly parentId: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
1087
|
+
readonly createdAt: import("effect/Schema").DateFromString;
|
|
1088
|
+
}>>, import("effect/Schema").toCodecJson<typeof import("../auth/schema.js").AuthBadRequest | typeof import("../auth/schema.js").AuthUnauthorized | typeof import("../auth/schema.js").AuthForbidden | typeof import("../auth/schema.js").AuthNotFound | typeof import("../auth/schema.js").AuthConflict | typeof import("../auth/schema.js").AuthExpectationFailed | typeof import("../auth/schema.js").AuthTooManyRequests | typeof import("../auth/schema.js").AuthInternalServerError>, never, never>, never, never>;
|
|
975
1089
|
readonly organizationGetFull: HttpApiClient.Client.Method<import("effect/http-api/HttpApiEndpoint").HttpApiEndpoint<"organizationGetFull", "GET", "/api/auth/organization/get-full-organization", never, import("effect/Schema").toCodecStringTree<import("effect/Schema").Struct<{
|
|
976
1090
|
readonly organizationId: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
977
1091
|
readonly organizationSlug: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
@@ -1841,6 +1955,19 @@ export declare const authHttpClient: (baseUrl?: string | undefined, getLocale?:
|
|
|
1841
1955
|
readonly id: import("effect/Schema").String;
|
|
1842
1956
|
readonly key: import("effect/Schema").String;
|
|
1843
1957
|
}>>, import("effect/Schema").toCodecJson<typeof import("effect/http-api/HttpApiError").Unauthorized | typeof import("effect/http-api/HttpApiError").Forbidden | typeof import("effect/http-api/HttpApiError").InternalServerError | typeof import("../extra/schema.js").ExtraBadRequest>, never, never>, never, never>;
|
|
1958
|
+
readonly getAccountDeletionPlan: HttpApiClient.Client.Method<import("effect/http-api/HttpApiEndpoint").HttpApiEndpoint<"getAccountDeletionPlan", "GET", "/api/auth/account-deletion", never, never, never, never, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{
|
|
1959
|
+
readonly projects: import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
1960
|
+
readonly id: import("effect/Schema").String;
|
|
1961
|
+
readonly name: import("effect/Schema").String;
|
|
1962
|
+
readonly ready: import("effect/Schema").Boolean;
|
|
1963
|
+
}>>;
|
|
1964
|
+
readonly organizations: import("effect/Schema").$Array<import("effect/Schema").Struct<{
|
|
1965
|
+
readonly id: import("effect/Schema").String;
|
|
1966
|
+
readonly name: import("effect/Schema").String;
|
|
1967
|
+
readonly personal: import("effect/Schema").Boolean;
|
|
1968
|
+
}>>;
|
|
1969
|
+
readonly adminAccount: import("effect/Schema").Boolean;
|
|
1970
|
+
}>>, import("effect/Schema").toCodecJson<typeof import("effect/http-api/HttpApiError").Unauthorized | typeof import("effect/http-api/HttpApiError").Forbidden | typeof import("effect/http-api/HttpApiError").InternalServerError>, never, never>, never, never>;
|
|
1844
1971
|
readonly getOrganizationPublicProfile: HttpApiClient.Client.Method<import("effect/http-api/HttpApiEndpoint").HttpApiEndpoint<"getOrganizationPublicProfile", "GET", "/api/auth/organization-profile", never, import("effect/Schema").toCodecStringTree<import("effect/Schema").Struct<{
|
|
1845
1972
|
readonly organizationId: import("effect/Schema").String;
|
|
1846
1973
|
readonly locale: import("effect/Schema").optional<import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"en">, import("effect/Schema").Literal<"fr">]>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const deletionControlsEnabled: boolean;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import type { AuthMember, FullAuthOrganization } from "../auth/schema.js";
|
|
3
|
+
export declare const canDeleteOrganization: (organization: (Pick<FullAuthOrganization, "userId"> & {
|
|
4
|
+
readonly members: ReadonlyArray<Pick<AuthMember, "userId" | "role">>;
|
|
5
|
+
}) | null, userId: string | undefined) => boolean;
|
|
6
|
+
export declare const requestOrganizationDeletion: (organizationId: string, baseUrl?: string) => Effect.Effect<{
|
|
7
|
+
readonly id: string;
|
|
8
|
+
readonly name: string;
|
|
9
|
+
readonly slug: string;
|
|
10
|
+
readonly logo?: string | null | undefined;
|
|
11
|
+
readonly metadata?: string | {
|
|
12
|
+
readonly [x: string]: import("effect/Schema").Json;
|
|
13
|
+
} | null | undefined;
|
|
14
|
+
readonly userId?: string | null | undefined;
|
|
15
|
+
readonly parentId?: string | null | undefined;
|
|
16
|
+
readonly createdAt: Date;
|
|
17
|
+
}, import("../auth/schema.js").AuthBadRequest | import("../auth/schema.js").AuthConflict | import("../auth/schema.js").AuthExpectationFailed | import("../auth/schema.js").AuthForbidden | import("../auth/schema.js").AuthInternalServerError | import("../auth/schema.js").AuthNotFound | import("../auth/schema.js").AuthTooManyRequests | import("../auth/schema.js").AuthUnauthorized | import("effect/http/HttpClientError").HttpClientError | import("effect/Schema").SchemaError, never>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { parseRoleList } from "../roles.js";
|
|
3
|
+
import { authHttpClient } from "./auth-client-api.js";
|
|
4
|
+
export const canDeleteOrganization = (organization, userId) => Boolean(organization &&
|
|
5
|
+
!organization.userId &&
|
|
6
|
+
userId &&
|
|
7
|
+
organization.members.some((member) => member.userId === userId &&
|
|
8
|
+
parseRoleList(member.role).includes("owner")));
|
|
9
|
+
export const requestOrganizationDeletion = (organizationId, baseUrl) => authHttpClient(baseUrl).pipe(Effect.flatMap((client) => client.auth.organizationDelete({ payload: { organizationId } })));
|