@krak-stack/auth 0.1.25 → 0.1.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.d.ts +252 -0
- package/dist/api.js +12 -0
- package/dist/better-auth/api.d.ts +4 -4
- package/dist/better-auth/api.js +1 -1
- package/dist/better-auth/index.d.ts +2 -2
- package/dist/components/api-key.d.ts +4 -0
- package/dist/components/api-key.js +20 -0
- package/dist/components/organization-switcher.d.ts +2 -0
- package/dist/components/organization-switcher.js +86 -60
- package/dist/components/user-button.js +14 -23
- package/dist/extra/api.d.ts +37 -37
- package/dist/extra/api.js +1 -1
- package/dist/extra/index.d.ts +22 -22
- package/dist/extra/index.js +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/server/api.d.ts +181 -173
- package/dist/server/api.js +3 -3
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +1 -1
- package/dist/server/schema.d.ts +9 -1
- package/dist/server/schema.js +21 -1
- package/dist/service.d.ts +694 -0
- package/dist/service.js +67 -0
- package/package.json +11 -1
- package/dist/client.d.ts +0 -1352
- package/dist/client.js +0 -105
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useAtomSet } from "@effect/atom-react";
|
|
2
3
|
import { useStore } from "@tanstack/react-form";
|
|
3
4
|
import {} from "@tanstack/react-table";
|
|
4
|
-
import { Schema } from "effect";
|
|
5
|
-
import {
|
|
5
|
+
import { Layer, Schema } from "effect";
|
|
6
|
+
import { FetchHttpClient } from "effect/unstable/http";
|
|
7
|
+
import { AtomHttpApi } from "effect/unstable/reactivity";
|
|
8
|
+
import { Building2, Check, ChevronsUpDown, Copy, KeyRound, Mail, PencilIcon, Plus, Trash2, UserIcon, UserPlus, Users, X, } from "lucide-react";
|
|
6
9
|
import { createContext, useContext, useEffect, useEffectEvent, useState, } from "react";
|
|
7
10
|
import { DataTable } from "@/components/ui/data-table";
|
|
8
11
|
import { EditingLocaleSwitcher } from "@/components/ui/editing-locale-switcher";
|
|
@@ -16,6 +19,8 @@ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "
|
|
|
16
19
|
import { Separator } from "@/components/ui/separator";
|
|
17
20
|
import { cn } from "@/lib/utils";
|
|
18
21
|
import { OrganizationMetadata, } from "@krak-stack/auth/schema";
|
|
22
|
+
import { createApiKey } from "./api-key";
|
|
23
|
+
import { AuthApi } from "../api";
|
|
19
24
|
import { assetPath, assetUrl, isRecord } from "./utils";
|
|
20
25
|
const messages = {
|
|
21
26
|
en: {
|
|
@@ -23,6 +28,7 @@ const messages = {
|
|
|
23
28
|
organization_contact_email: "Contact email",
|
|
24
29
|
organization_create_description: "Create a workspace for team-based access.",
|
|
25
30
|
organization_create_error: "Could not create the organization.",
|
|
31
|
+
organization_copy_id: "Copy organization ID",
|
|
26
32
|
organization_create_slug_conflict: "That organization slug is already in use. Choose a different slug.",
|
|
27
33
|
organization_create_title: "Create organization",
|
|
28
34
|
organization_edit_description: "Update the active organization's canonical details and localized profile.",
|
|
@@ -101,6 +107,7 @@ const messages = {
|
|
|
101
107
|
organization_contact_email: "E-mail de contact",
|
|
102
108
|
organization_create_description: "Créez un espace de travail pour l'accès en équipe.",
|
|
103
109
|
organization_create_error: "Impossible de créer l'organisation.",
|
|
110
|
+
organization_copy_id: "Copier l'ID de l'organisation",
|
|
104
111
|
organization_create_slug_conflict: "Ce slug d'organisation est déjà utilisé. Choisissez un autre slug.",
|
|
105
112
|
organization_create_title: "Créer une organisation",
|
|
106
113
|
organization_edit_description: "Mettez à jour les détails canoniques et le profil localisé de l'organisation active.",
|
|
@@ -218,16 +225,31 @@ const parsePresignedUpload = (value, m) => {
|
|
|
218
225
|
}
|
|
219
226
|
return { uploadUrl: value.uploadUrl, url: value.url };
|
|
220
227
|
};
|
|
221
|
-
const
|
|
228
|
+
const credentialedFetchLayer = Layer.provide(FetchHttpClient.layer, Layer.succeed(FetchHttpClient.RequestInit, { credentials: "include" }));
|
|
229
|
+
const createAuthApiClient = (key) => AtomHttpApi.Service()(`OrganizationSwitcherAuthApi:${key}`, {
|
|
230
|
+
api: AuthApi,
|
|
231
|
+
baseUrl: key,
|
|
232
|
+
httpClient: credentialedFetchLayer,
|
|
233
|
+
});
|
|
234
|
+
const authApiClients = new Map();
|
|
235
|
+
const authApiClient = (baseUrl) => {
|
|
236
|
+
const url = baseUrl?.trim() ||
|
|
237
|
+
(typeof window === "undefined"
|
|
238
|
+
? "http://localhost:3000"
|
|
239
|
+
: window.location.origin);
|
|
240
|
+
const key = url.replace(/\/$/, "");
|
|
241
|
+
const existing = authApiClients.get(key);
|
|
242
|
+
if (existing)
|
|
243
|
+
return existing;
|
|
244
|
+
const client = createAuthApiClient(key);
|
|
245
|
+
authApiClients.set(key, client);
|
|
246
|
+
return client;
|
|
247
|
+
};
|
|
248
|
+
const uploadOrganizationLogo = async (file, m, presignOrganizationLogo) => {
|
|
222
249
|
const contentType = file.type || "image/png";
|
|
223
|
-
const
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
});
|
|
227
|
-
if (presignResult.error) {
|
|
228
|
-
throw new Error(m.organization_logo_upload_error());
|
|
229
|
-
}
|
|
230
|
-
const presigned = parsePresignedUpload(presignResult.data, m);
|
|
250
|
+
const presigned = parsePresignedUpload(await presignOrganizationLogo({
|
|
251
|
+
payload: { fileName: file.name, contentType },
|
|
252
|
+
}), m);
|
|
231
253
|
const uploadResponse = await fetch(presigned.uploadUrl, {
|
|
232
254
|
method: "PUT",
|
|
233
255
|
headers: { "Content-Type": contentType },
|
|
@@ -285,9 +307,9 @@ const organizationFormDefaults = (organization, baseUrl) => {
|
|
|
285
307
|
frLocation: fr?.location ?? "",
|
|
286
308
|
};
|
|
287
309
|
};
|
|
288
|
-
const organizationLogoFromForm = async (
|
|
310
|
+
const organizationLogoFromForm = async (value, m, presignOrganizationLogo) => {
|
|
289
311
|
if (value instanceof File)
|
|
290
|
-
return await uploadOrganizationLogo(
|
|
312
|
+
return await uploadOrganizationLogo(value, m, presignOrganizationLogo);
|
|
291
313
|
if (typeof value === "string")
|
|
292
314
|
return assetPath(value);
|
|
293
315
|
return null;
|
|
@@ -305,21 +327,14 @@ const organizationRoleLabel = (role, m) => {
|
|
|
305
327
|
}
|
|
306
328
|
};
|
|
307
329
|
const formatOrganizationDate = (date) => new Intl.DateTimeFormat(getLocale(), { dateStyle: "medium" }).format(new Date(date));
|
|
308
|
-
const
|
|
309
|
-
.trim()
|
|
310
|
-
.split(/\s+/)
|
|
311
|
-
.slice(0, 2)
|
|
312
|
-
.map((part) => part[0])
|
|
313
|
-
.join("")
|
|
314
|
-
.toUpperCase() || "?";
|
|
315
|
-
const organizationMetadataFromForm = async (authClient, value, m) => {
|
|
330
|
+
const organizationMetadataFromForm = async (value, m, presignOrganizationLogo) => {
|
|
316
331
|
const translations = [];
|
|
317
332
|
const enName = value.enName.trim() || value.name.trim();
|
|
318
333
|
const frName = value.frName.trim();
|
|
319
|
-
const enLogo = await organizationLogoFromForm(
|
|
320
|
-
const enIcon = await organizationLogoFromForm(
|
|
321
|
-
const frLogo = await organizationLogoFromForm(
|
|
322
|
-
const frIcon = await organizationLogoFromForm(
|
|
334
|
+
const enLogo = await organizationLogoFromForm(value.enLogo, m, presignOrganizationLogo);
|
|
335
|
+
const enIcon = await organizationLogoFromForm(value.enIcon, m, presignOrganizationLogo);
|
|
336
|
+
const frLogo = await organizationLogoFromForm(value.frLogo, m, presignOrganizationLogo);
|
|
337
|
+
const frIcon = await organizationLogoFromForm(value.frIcon, m, presignOrganizationLogo);
|
|
323
338
|
if (enName) {
|
|
324
339
|
translations.push({
|
|
325
340
|
locale: "en",
|
|
@@ -432,7 +447,9 @@ export function OrganizationSwitcher({ authClient, baseUrl, side = "bottom", cla
|
|
|
432
447
|
: m.organization_switcher_empty() })) : null, _jsx(DropdownMenuSeparator, {}), !locked ? (_jsxs(DropdownMenuItem, { onClick: openCreate, children: [_jsx(Plus, {}), m.organization_create_title()] })) : null, _jsxs(DropdownMenuItem, { onClick: () => {
|
|
433
448
|
setDialog("invitations");
|
|
434
449
|
void loadUserInvitations();
|
|
435
|
-
}, children: [_jsx(Mail, {}), _jsxs("span", { className: "flex flex-1 items-center justify-between gap-3", children: [m.organization_user_invitations_title(), userInvitations.length ? (_jsx(Badge, { variant: "secondary", children: userInvitations.length })) : null] })] }), activeOrganization.data ? (_jsxs(_Fragment, { children: [_jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuItem, { onClick: () =>
|
|
450
|
+
}, children: [_jsx(Mail, {}), _jsxs("span", { className: "flex flex-1 items-center justify-between gap-3", children: [m.organization_user_invitations_title(), userInvitations.length ? (_jsx(Badge, { variant: "secondary", children: userInvitations.length })) : null] })] }), activeOrganization.data ? (_jsxs(_Fragment, { children: [_jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuItem, { onClick: () => {
|
|
451
|
+
void navigator.clipboard.writeText(activeOrganization.data.id);
|
|
452
|
+
}, children: [_jsx(Copy, {}), m.organization_copy_id()] }), _jsxs(DropdownMenuItem, { onClick: () => setDialog("manage"), children: [_jsx(PencilIcon, {}), m.organization_switcher_manage()] }), _jsxs(DropdownMenuItem, { onClick: () => setDialog("members"), children: [_jsx(Users, {}), m.organization_members_title()] }), _jsxs(DropdownMenuItem, { onClick: () => setDialog("apiKeys"), children: [_jsx(KeyRound, {}), m.user_button_api_keys()] })] })) : null] }) })] })), _jsx(Dialog, { open: dialog === "create", onOpenChange: (open) => {
|
|
436
453
|
setDialog((current) => open ? "create" : current === "create" ? null : current);
|
|
437
454
|
}, children: _jsxs(DialogContent, { className: "max-h-[85vh] overflow-y-auto sm:max-w-xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.organization_create_title() }), _jsx(DialogDescription, { children: m.organization_create_description() })] }), _jsx(Separator, {}), _jsx(CreateOrganizationSection, { authClient: authClient, baseUrl: baseUrl, onCreated: async (organization) => {
|
|
438
455
|
setDialog(null);
|
|
@@ -448,7 +465,7 @@ export function OrganizationSwitcher({ authClient, baseUrl, side = "bottom", cla
|
|
|
448
465
|
setDialog((current) => open ? "manage" : current === "manage" ? null : current);
|
|
449
466
|
}, children: _jsxs(DialogContent, { className: "max-h-[85vh] overflow-y-auto sm:max-w-xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.organization_switcher_manage() }), _jsx(DialogDescription, { children: m.organization_edit_description() })] }), _jsx(Separator, {}), activeOrganization.data ? (_jsx(EditOrganizationSection, { authClient: authClient, baseUrl: baseUrl, organization: activeOrganization.data, onUpdated: refresh })) : null] }) }), _jsx(Dialog, { open: dialog === "members", onOpenChange: (open) => {
|
|
450
467
|
setDialog((current) => open ? "members" : current === "members" ? null : current);
|
|
451
|
-
}, children: _jsxs(DialogContent, { className: "max-h-[85vh] overflow-y-auto sm:max-w-4xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.organization_members_title() }), _jsx(DialogDescription, { children: activeOrganization.data?.name })] }), _jsx(Separator, {}), activeOrganization.data ? (_jsx(OrganizationMembersManager, { authClient: authClient, organization: activeOrganization.data, currentUserId: session.data.user.id })) : null] }) }), _jsx(Dialog, { open: dialog === "apiKeys", onOpenChange: (open) => {
|
|
468
|
+
}, children: _jsxs(DialogContent, { className: "max-h-[85vh] overflow-x-hidden overflow-y-auto sm:max-w-4xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.organization_members_title() }), _jsx(DialogDescription, { children: activeOrganization.data?.name })] }), _jsx(Separator, {}), activeOrganization.data ? (_jsx(OrganizationMembersManager, { authClient: authClient, baseUrl: baseUrl, organization: activeOrganization.data, currentUserId: session.data.user.id })) : null] }) }), _jsx(Dialog, { open: dialog === "apiKeys", onOpenChange: (open) => {
|
|
452
469
|
setDialog((current) => open ? "apiKeys" : current === "apiKeys" ? null : current);
|
|
453
470
|
}, children: _jsxs(DialogContent, { className: "max-h-[85vh] overflow-y-auto sm:max-w-3xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.user_api_keys_title() }), _jsx(DialogDescription, { children: activeOrganization.data?.name })] }), _jsx(Separator, {}), activeOrganization.data ? (_jsx(OrganizationApiKeyManager, { authClient: authClient, organization: activeOrganization.data })) : null] }) }), _jsx(Dialog, { open: dialog === "invitations", onOpenChange: (open) => {
|
|
454
471
|
setDialog((current) => open ? "invitations" : current === "invitations" ? null : current);
|
|
@@ -532,6 +549,7 @@ const userInvitationRowActions = ({ m, actingInvitationId, onAccept, onReject, }
|
|
|
532
549
|
];
|
|
533
550
|
function EditOrganizationSection({ authClient, baseUrl, organization, onUpdated, }) {
|
|
534
551
|
const m = useOrganizationMessages();
|
|
552
|
+
const presignOrganizationLogo = useAtomSet(authApiClient(baseUrl).mutation("authExtra", "presign"), { mode: "promise" });
|
|
535
553
|
const [editingLocale, setEditingLocale] = useState(currentOrganizationLocale());
|
|
536
554
|
const defaultValues = organizationFormDefaults(organization, baseUrl);
|
|
537
555
|
const form = useAppForm({
|
|
@@ -541,7 +559,7 @@ function EditOrganizationSection({ authClient, baseUrl, organization, onUpdated,
|
|
|
541
559
|
try {
|
|
542
560
|
const name = value.name.trim();
|
|
543
561
|
const slug = value.slug.trim().toLowerCase();
|
|
544
|
-
const metadata = await organizationMetadataFromForm(
|
|
562
|
+
const metadata = await organizationMetadataFromForm(value, m, presignOrganizationLogo);
|
|
545
563
|
const result = await authClient.organization.update({
|
|
546
564
|
organizationId: organization.id,
|
|
547
565
|
data: { name, slug, metadata },
|
|
@@ -607,6 +625,7 @@ function CreateOrganizationSlugAutoFill({ form, }) {
|
|
|
607
625
|
}
|
|
608
626
|
function CreateOrganizationSection({ authClient, baseUrl, onCreated, }) {
|
|
609
627
|
const m = useOrganizationMessages();
|
|
628
|
+
const presignOrganizationLogo = useAtomSet(authApiClient(baseUrl).mutation("authExtra", "presign"), { mode: "promise" });
|
|
610
629
|
const [editingLocale, setEditingLocale] = useState(currentOrganizationLocale());
|
|
611
630
|
const defaultValues = organizationFormDefaults(undefined, baseUrl);
|
|
612
631
|
const form = useAppForm({
|
|
@@ -616,11 +635,11 @@ function CreateOrganizationSection({ authClient, baseUrl, onCreated, }) {
|
|
|
616
635
|
try {
|
|
617
636
|
const name = value.name.trim();
|
|
618
637
|
const slug = (value.slug.trim() || slugify(name)).toLowerCase();
|
|
619
|
-
const metadata = await organizationMetadataFromForm(
|
|
638
|
+
const metadata = await organizationMetadataFromForm({
|
|
620
639
|
...value,
|
|
621
640
|
name,
|
|
622
641
|
slug,
|
|
623
|
-
}, m);
|
|
642
|
+
}, m, presignOrganizationLogo);
|
|
624
643
|
const result = await authClient.organization.create({
|
|
625
644
|
name,
|
|
626
645
|
slug,
|
|
@@ -693,7 +712,7 @@ function OrganizationTranslationHeader({ locale, editingLocale, onEditingLocaleC
|
|
|
693
712
|
: m.organization_translation_french();
|
|
694
713
|
return (_jsxs("div", { className: "flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between", children: [_jsxs("div", { children: [_jsx("h3", { className: "font-medium", children: title }), _jsx("p", { className: "text-muted-foreground text-sm", children: m.organization_translation_description() })] }), _jsx(EditingLocaleSwitcher, { value: editingLocale, onValueChange: onEditingLocaleChange })] }));
|
|
695
714
|
}
|
|
696
|
-
function OrganizationMembersManager({ authClient, organization, currentUserId, }) {
|
|
715
|
+
function OrganizationMembersManager({ authClient, baseUrl, organization, currentUserId, }) {
|
|
697
716
|
const m = useOrganizationMessages();
|
|
698
717
|
const [members, setMembers] = useState([]);
|
|
699
718
|
const [invitations, setInvitations] = useState([]);
|
|
@@ -794,34 +813,38 @@ function OrganizationMembersManager({ authClient, organization, currentUserId, }
|
|
|
794
813
|
}
|
|
795
814
|
await loadMembers();
|
|
796
815
|
};
|
|
797
|
-
return (_jsxs("div", { className: "flex flex-col gap-5", children: [_jsx(inviteForm.AppForm, { children: _jsxs("form", { className: "grid gap-4 rounded-lg border p-4 sm:grid-cols-[minmax(0,1fr)_12rem_auto] sm:items-end", onSubmit: (event) => {
|
|
816
|
+
return (_jsxs("div", { className: "flex min-w-0 flex-col gap-5", children: [_jsx(inviteForm.AppForm, { children: _jsxs("form", { className: "grid gap-4 rounded-lg border p-4 sm:grid-cols-[minmax(0,1fr)_12rem_auto] sm:items-end", onSubmit: (event) => {
|
|
798
817
|
event.preventDefault();
|
|
799
818
|
event.stopPropagation();
|
|
800
819
|
inviteForm.handleSubmit();
|
|
801
820
|
}, children: [_jsxs("div", { className: "sm:col-span-3", children: [_jsxs("div", { className: "flex items-center gap-2 font-medium", children: [_jsx(UserPlus, { className: "size-4" }), m.organization_invite_member_title()] }), _jsx("p", { className: "text-muted-foreground text-sm", children: m.organization_invite_member_description() })] }), _jsx(inviteForm.AppField, { name: "email", children: (field) => (_jsx(field.TextField, { label: m.organization_member_email(), placeholder: "teammate@example.com", type: "email", required: true })) }), _jsx(inviteForm.AppField, { name: "role", children: (field) => (_jsx(field.SelectField, { label: m.organization_member_role(), options: organizationRoles.map((role) => ({
|
|
802
821
|
label: organizationRoleLabel(role, m),
|
|
803
822
|
value: role,
|
|
804
|
-
})) })) }), _jsx("div", { className: "self-end", children: _jsx(inviteForm.SubmitButton, {}) }), _jsx(inviteForm.FormError, {})] }) }), error ? _jsx("p", { className: "text-destructive text-sm", children: error }) : null, _jsxs("section", { className: "flex flex-col gap-3", children: [_jsxs("div", { children: [_jsx("h3", { className: "font-medium", children: m.organization_members_heading() }), _jsx("p", { className: "text-muted-foreground text-sm", children: m.organization_members_description() })] }), _jsx(DataTable, { columns: memberColumns({
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
m,
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
m,
|
|
814
|
-
|
|
815
|
-
m,
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
823
|
+
})) })) }), _jsx("div", { className: "self-end", children: _jsx(inviteForm.SubmitButton, {}) }), _jsx(inviteForm.FormError, {})] }) }), error ? _jsx("p", { className: "text-destructive text-sm", children: error }) : null, _jsxs("section", { className: "flex min-w-0 flex-col gap-3", children: [_jsxs("div", { children: [_jsx("h3", { className: "font-medium", children: m.organization_members_heading() }), _jsx("p", { className: "text-muted-foreground text-sm", children: m.organization_members_description() })] }), _jsx("div", { className: "min-w-0 overflow-x-auto", children: _jsx(DataTable, { columns: memberColumns({
|
|
824
|
+
m,
|
|
825
|
+
baseUrl,
|
|
826
|
+
updatingMemberId,
|
|
827
|
+
onRoleChange: updateRole,
|
|
828
|
+
}), data: members, emptyLabel: loading ? m.user_loading() : m.organization_members_empty(), exportFileName: `${organization.slug}-members.csv`, features: { gallery: false }, rowActions: memberRowActions({
|
|
829
|
+
m,
|
|
830
|
+
currentUserId,
|
|
831
|
+
onRemove: removeMember,
|
|
832
|
+
}) }) })] }), _jsxs("section", { className: "flex min-w-0 flex-col gap-3", children: [_jsxs("div", { children: [_jsx("h3", { className: "font-medium", children: m.organization_invitations_heading() }), _jsx("p", { className: "text-muted-foreground text-sm", children: m.organization_invitations_description() })] }), _jsx("div", { className: "min-w-0 overflow-x-auto", children: _jsx(DataTable, { columns: invitationColumns({
|
|
833
|
+
m,
|
|
834
|
+
}), data: invitations, emptyLabel: loading ? m.user_loading() : m.organization_invitations_empty(), exportFileName: `${organization.slug}-invitations.csv`, features: { gallery: false }, rowActions: invitationRowActions({
|
|
835
|
+
m,
|
|
836
|
+
cancellingInvitationId,
|
|
837
|
+
onCancel: cancelInvitation,
|
|
838
|
+
}) }) })] })] }));
|
|
819
839
|
}
|
|
820
|
-
const memberColumns = ({ m, updatingMemberId, onRoleChange, }) => [
|
|
840
|
+
const memberColumns = ({ m, baseUrl, updatingMemberId, onRoleChange, }) => [
|
|
821
841
|
{
|
|
822
842
|
id: "user",
|
|
823
843
|
header: m.organization_member_user(),
|
|
824
|
-
cell: ({ row }) =>
|
|
844
|
+
cell: ({ row }) => {
|
|
845
|
+
const image = assetUrl(row.original.user.image, baseUrl);
|
|
846
|
+
return (_jsx(AppBrand, { to: null, label: row.original.user.name, subtitle: row.original.user.email, icon: UserIcon, className: "min-w-0", ...(image ? { imageSrc: image } : {}) }));
|
|
847
|
+
},
|
|
825
848
|
},
|
|
826
849
|
{
|
|
827
850
|
accessorKey: "role",
|
|
@@ -913,23 +936,26 @@ function OrganizationApiKeyManager({ authClient, organization, }) {
|
|
|
913
936
|
onSubmit: async ({ value, formApi }) => {
|
|
914
937
|
formApi.setErrorMap({ onSubmit: undefined });
|
|
915
938
|
setCreatedKey(null);
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
939
|
+
try {
|
|
940
|
+
const created = await createApiKey({
|
|
941
|
+
configId: "organization",
|
|
942
|
+
organizationId: organization.id,
|
|
943
|
+
name: value.name.trim(),
|
|
944
|
+
}, m.user_api_key_create_error());
|
|
945
|
+
setCreatedKey(created.key);
|
|
946
|
+
createForm.reset();
|
|
947
|
+
await loadKeys();
|
|
948
|
+
}
|
|
949
|
+
catch (cause) {
|
|
922
950
|
formApi.setErrorMap({
|
|
923
951
|
onSubmit: {
|
|
924
|
-
form:
|
|
952
|
+
form: cause instanceof Error
|
|
953
|
+
? cause.message
|
|
954
|
+
: m.user_api_key_create_error(),
|
|
925
955
|
fields: {},
|
|
926
956
|
},
|
|
927
957
|
});
|
|
928
|
-
return;
|
|
929
958
|
}
|
|
930
|
-
setCreatedKey(result.data.key);
|
|
931
|
-
createForm.reset();
|
|
932
|
-
await loadKeys();
|
|
933
959
|
},
|
|
934
960
|
});
|
|
935
961
|
const deleteKey = async (key) => {
|
|
@@ -14,6 +14,7 @@ import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, }
|
|
|
14
14
|
import { Field, FieldContent, FieldDescription, FieldGroup, FieldLabel, FieldLegend, FieldSet, } from "@/components/ui/field";
|
|
15
15
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu";
|
|
16
16
|
import { Separator } from "@/components/ui/separator";
|
|
17
|
+
import { createApiKey } from "./api-key";
|
|
17
18
|
import { assetPath, assetUrl, isRecord } from "./utils";
|
|
18
19
|
const messages = {
|
|
19
20
|
en: {
|
|
@@ -276,7 +277,7 @@ export const UserButton = ({ authClient, baseUrl, signOutRedirect = "/", side =
|
|
|
276
277
|
await refetch();
|
|
277
278
|
setSettingsDialog(null);
|
|
278
279
|
};
|
|
279
|
-
return (_jsxs(UserButtonMessagesContext.Provider, { value: m, children: [hideTrigger ? null : (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { render: _jsxs(Button, { variant: "outline", size: "icon", children: [_jsx(UserIcon, { className: "size-4.5" }), _jsx("span", { className: "sr-only", children: m.user_button_aria_label() })] }) }), _jsx(DropdownMenuContent, { className: "w-56 rounded-lg", side: side, align: "end", sideOffset: 4, children: _jsxs(DropdownMenuGroup, { children: [_jsx(DropdownMenuLabel, { className: "p-0 font-normal", children: _jsx(AppBrand, { to: null, label: displayName || displayEmail, subtitle: displayName ? displayEmail : m.user_button_account(), icon: UserIcon, className: "px-1 py-1.5 text-left text-sm", ...(displayImage ? { imageSrc: displayImage } : {}) }) }), _jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuItem, { disabled: isPending, onClick: () => setSettingsDialog("account"), children: [_jsx(UserCircleIcon, {}), m.user_button_account()] }), _jsxs(DropdownMenuItem, { onClick: () => setSettingsDialog("security"), children: [_jsx(ShieldCheck, {}), m.user_button_security()] }), _jsxs(DropdownMenuItem, { onClick: () => setSettingsDialog("apiKeys"), children: [_jsx(KeyRound, {}), m.user_button_api_keys()] }), _jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuItem, { onClick: signOut, children: [_jsx(LogOutIcon, {}), m.user_button_logout()] })] }) })] })), _jsx(Dialog, { open: settingsDialog === "account", onOpenChange: (open) => {
|
|
280
|
+
return (_jsxs(UserButtonMessagesContext.Provider, { value: m, children: [hideTrigger ? null : (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { render: _jsxs(Button, { variant: "outline", size: "icon", children: [displayImage ? (_jsx("img", { src: displayImage, alt: displayName || displayEmail, className: "size-full rounded-md object-cover" })) : (_jsx(UserIcon, { className: "size-4.5" })), _jsx("span", { className: "sr-only", children: m.user_button_aria_label() })] }) }), _jsx(DropdownMenuContent, { className: "w-56 rounded-lg", side: side, align: "end", sideOffset: 4, children: _jsxs(DropdownMenuGroup, { children: [_jsx(DropdownMenuLabel, { className: "p-0 font-normal", children: _jsx(AppBrand, { to: null, label: displayName || displayEmail, subtitle: displayName ? displayEmail : m.user_button_account(), icon: UserIcon, className: "px-1 py-1.5 text-left text-sm", ...(displayImage ? { imageSrc: displayImage } : {}) }) }), _jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuItem, { disabled: isPending, onClick: () => setSettingsDialog("account"), children: [_jsx(UserCircleIcon, {}), m.user_button_account()] }), _jsxs(DropdownMenuItem, { onClick: () => setSettingsDialog("security"), children: [_jsx(ShieldCheck, {}), m.user_button_security()] }), _jsxs(DropdownMenuItem, { onClick: () => setSettingsDialog("apiKeys"), children: [_jsx(KeyRound, {}), m.user_button_api_keys()] }), _jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuItem, { onClick: signOut, children: [_jsx(LogOutIcon, {}), m.user_button_logout()] })] }) })] })), _jsx(Dialog, { open: settingsDialog === "account", onOpenChange: (open) => {
|
|
280
281
|
setSettingsDialog((current) => open ? "account" : current === "account" ? null : current);
|
|
281
282
|
}, children: _jsxs(DialogContent, { className: "max-h-[85vh] overflow-y-auto sm:max-w-3xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.user_form_title() }), _jsx(DialogDescription, { children: m.user_form_description() })] }), _jsx(Separator, {}), isPending ? (_jsx("p", { className: "text-muted-foreground text-sm", children: m.user_loading() })) : (_jsxs("div", { className: "flex flex-col gap-6", children: [_jsx(UserForm, { defaultValues: {
|
|
282
283
|
name: displayName ?? "",
|
|
@@ -651,28 +652,27 @@ function ApiKeyManager({ authClient, permissions = {}, }) {
|
|
|
651
652
|
setCreatedKey(null);
|
|
652
653
|
setCopiedKey(false);
|
|
653
654
|
const selectedPermissionObject = getSelectedPermissionObject(permissionOptions, selectedPermissions);
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
body: {
|
|
655
|
+
try {
|
|
656
|
+
const created = await createApiKey({
|
|
657
657
|
configId: "user",
|
|
658
658
|
name: value.name.trim(),
|
|
659
659
|
permissions: selectedPermissionObject,
|
|
660
|
-
},
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
660
|
+
}, m.user_api_key_create_error());
|
|
661
|
+
setCreatedKey(created.key);
|
|
662
|
+
createForm.reset();
|
|
663
|
+
setSelectedPermissions({});
|
|
664
|
+
await loadKeys();
|
|
665
|
+
}
|
|
666
|
+
catch (cause) {
|
|
664
667
|
formApi.setErrorMap({
|
|
665
668
|
onSubmit: {
|
|
666
|
-
form:
|
|
669
|
+
form: cause instanceof Error
|
|
670
|
+
? cause.message
|
|
671
|
+
: m.user_api_key_create_error(),
|
|
667
672
|
fields: {},
|
|
668
673
|
},
|
|
669
674
|
});
|
|
670
|
-
return;
|
|
671
675
|
}
|
|
672
|
-
setCreatedKey(created.key);
|
|
673
|
-
createForm.reset();
|
|
674
|
-
setSelectedPermissions({});
|
|
675
|
-
await loadKeys();
|
|
676
676
|
},
|
|
677
677
|
});
|
|
678
678
|
const togglePermission = (id, checked) => {
|
|
@@ -776,12 +776,3 @@ const isAuthErrorResult = (result) => {
|
|
|
776
776
|
typeof result.error === "object" &&
|
|
777
777
|
result.error !== null);
|
|
778
778
|
};
|
|
779
|
-
const getCreatedApiKey = (data) => {
|
|
780
|
-
if (typeof data === "object" &&
|
|
781
|
-
data !== null &&
|
|
782
|
-
"key" in data &&
|
|
783
|
-
typeof data.key === "string") {
|
|
784
|
-
return { key: data.key };
|
|
785
|
-
}
|
|
786
|
-
return null;
|
|
787
|
-
};
|
package/dist/extra/api.d.ts
CHANGED
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
import { HttpApi } from "effect/unstable/httpapi";
|
|
2
2
|
import { HttpApiEndpoint, HttpApiError, HttpApiGroup } from "effect/unstable/httpapi";
|
|
3
3
|
import { ExtraBadRequest } from "./schema";
|
|
4
|
-
export declare const ExtraApiGroup: HttpApiGroup.HttpApiGroup<"
|
|
5
|
-
readonly newPassword: import("effect/Schema").NonEmptyString;
|
|
6
|
-
}>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
7
|
-
readonly ok: import("effect/Schema").Boolean;
|
|
8
|
-
}>>, HttpApiEndpoint.Json<typeof ExtraBadRequest>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"verifyPassword", "POST", "/auth/verify-password", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
9
|
-
readonly password: import("effect/Schema").NonEmptyString;
|
|
10
|
-
}>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
11
|
-
readonly ok: import("effect/Schema").Boolean;
|
|
12
|
-
}>>, HttpApiEndpoint.Json<typeof ExtraBadRequest>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"createApiKey", "POST", "/auth/create-api-key", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
4
|
+
export declare const ExtraApiGroup: HttpApiGroup.HttpApiGroup<"authExtra", HttpApiEndpoint.HttpApiEndpoint<"createApiKey", "POST", "/auth/create-api-key", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
13
5
|
readonly configId: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"user">, import("effect/Schema").Literal<"organization">, import("effect/Schema").Literal<"service">]>;
|
|
14
6
|
readonly name: import("effect/Schema").optional<import("effect/Schema").NonEmptyString>;
|
|
15
7
|
readonly organizationId: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
@@ -17,6 +9,22 @@ export declare const ExtraApiGroup: HttpApiGroup.HttpApiGroup<"extra", HttpApiEn
|
|
|
17
9
|
}>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
18
10
|
readonly id: import("effect/Schema").String;
|
|
19
11
|
readonly key: import("effect/Schema").String;
|
|
12
|
+
}>>, HttpApiEndpoint.Json<typeof ExtraBadRequest>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"presign", "POST", "/organizations/logo/presign", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
13
|
+
readonly fileName: import("effect/Schema").NonEmptyString;
|
|
14
|
+
readonly contentType: import("effect/Schema").NonEmptyString;
|
|
15
|
+
}>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
16
|
+
readonly uploadUrl: import("effect/Schema").String;
|
|
17
|
+
readonly url: import("effect/Schema").String;
|
|
18
|
+
}>>, HttpApiEndpoint.Json<typeof HttpApiError.BadRequest | typeof HttpApiError.Unauthorized | typeof HttpApiError.Forbidden | typeof HttpApiError.InternalServerError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"presignUserImageUpload", "POST", "/auth/image/presign", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
19
|
+
readonly fileName: import("effect/Schema").NonEmptyString;
|
|
20
|
+
readonly contentType: import("effect/Schema").NonEmptyString;
|
|
21
|
+
}>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
22
|
+
readonly uploadUrl: import("effect/Schema").String;
|
|
23
|
+
readonly url: import("effect/Schema").String;
|
|
24
|
+
}>>, HttpApiEndpoint.Json<typeof HttpApiError.Unauthorized | typeof HttpApiError.InternalServerError | typeof ExtraBadRequest>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"setPassword", "POST", "/auth/set-password", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
25
|
+
readonly newPassword: import("effect/Schema").NonEmptyString;
|
|
26
|
+
}>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
27
|
+
readonly ok: import("effect/Schema").Boolean;
|
|
20
28
|
}>>, HttpApiEndpoint.Json<typeof ExtraBadRequest>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"verifyApiKey", "POST", "/auth/verify-api-key", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
21
29
|
readonly key: import("effect/Schema").NonEmptyString;
|
|
22
30
|
readonly configId: import("effect/Schema").optional<import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"user">, import("effect/Schema").Literal<"organization">, import("effect/Schema").Literal<"service">]>>;
|
|
@@ -41,35 +49,35 @@ export declare const ExtraApiGroup: HttpApiGroup.HttpApiGroup<"extra", HttpApiEn
|
|
|
41
49
|
readonly permissions: import("effect/Schema").NullOr<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").$Array<import("effect/Schema").String>>>;
|
|
42
50
|
readonly metadata: import("effect/Schema").NullOr<import("effect/Schema").Unknown>;
|
|
43
51
|
}>>;
|
|
44
|
-
}>>, HttpApiEndpoint.Json<typeof ExtraBadRequest>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"
|
|
52
|
+
}>>, HttpApiEndpoint.Json<typeof ExtraBadRequest>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"verifyPassword", "POST", "/auth/verify-password", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
53
|
+
readonly password: import("effect/Schema").NonEmptyString;
|
|
54
|
+
}>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
55
|
+
readonly ok: import("effect/Schema").Boolean;
|
|
56
|
+
}>>, HttpApiEndpoint.Json<typeof ExtraBadRequest>, never, never>, false>;
|
|
57
|
+
export declare const ExtraApi: HttpApi.HttpApi<"ExtraApi", HttpApiGroup.HttpApiGroup<"authExtra", HttpApiEndpoint.HttpApiEndpoint<"createApiKey", "POST", "/api/auth/create-api-key", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
58
|
+
readonly configId: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"user">, import("effect/Schema").Literal<"organization">, import("effect/Schema").Literal<"service">]>;
|
|
59
|
+
readonly name: import("effect/Schema").optional<import("effect/Schema").NonEmptyString>;
|
|
60
|
+
readonly organizationId: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
61
|
+
readonly permissions: import("effect/Schema").optional<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").$Array<import("effect/Schema").String>>>;
|
|
62
|
+
}>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
63
|
+
readonly id: import("effect/Schema").String;
|
|
64
|
+
readonly key: import("effect/Schema").String;
|
|
65
|
+
}>>, HttpApiEndpoint.Json<typeof ExtraBadRequest>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"presign", "POST", "/api/organizations/logo/presign", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
45
66
|
readonly fileName: import("effect/Schema").NonEmptyString;
|
|
46
67
|
readonly contentType: import("effect/Schema").NonEmptyString;
|
|
47
68
|
}>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
48
69
|
readonly uploadUrl: import("effect/Schema").String;
|
|
49
70
|
readonly url: import("effect/Schema").String;
|
|
50
|
-
}>>, HttpApiEndpoint.Json<typeof HttpApiError.Unauthorized | typeof HttpApiError.
|
|
71
|
+
}>>, HttpApiEndpoint.Json<typeof HttpApiError.BadRequest | typeof HttpApiError.Unauthorized | typeof HttpApiError.Forbidden | typeof HttpApiError.InternalServerError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"presignUserImageUpload", "POST", "/api/auth/image/presign", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
51
72
|
readonly fileName: import("effect/Schema").NonEmptyString;
|
|
52
73
|
readonly contentType: import("effect/Schema").NonEmptyString;
|
|
53
74
|
}>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
54
75
|
readonly uploadUrl: import("effect/Schema").String;
|
|
55
76
|
readonly url: import("effect/Schema").String;
|
|
56
|
-
}>>, HttpApiEndpoint.Json<typeof HttpApiError.
|
|
57
|
-
export declare const ExtraApi: HttpApi.HttpApi<"ExtraApi", HttpApiGroup.HttpApiGroup<"extra", HttpApiEndpoint.HttpApiEndpoint<"setPassword", "POST", "/api/auth/set-password", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
77
|
+
}>>, HttpApiEndpoint.Json<typeof HttpApiError.Unauthorized | typeof HttpApiError.InternalServerError | typeof ExtraBadRequest>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"setPassword", "POST", "/api/auth/set-password", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
58
78
|
readonly newPassword: import("effect/Schema").NonEmptyString;
|
|
59
79
|
}>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
60
80
|
readonly ok: import("effect/Schema").Boolean;
|
|
61
|
-
}>>, HttpApiEndpoint.Json<typeof ExtraBadRequest>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"verifyPassword", "POST", "/api/auth/verify-password", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
62
|
-
readonly password: import("effect/Schema").NonEmptyString;
|
|
63
|
-
}>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
64
|
-
readonly ok: import("effect/Schema").Boolean;
|
|
65
|
-
}>>, HttpApiEndpoint.Json<typeof ExtraBadRequest>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"createApiKey", "POST", "/api/auth/create-api-key", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
66
|
-
readonly configId: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"user">, import("effect/Schema").Literal<"organization">, import("effect/Schema").Literal<"service">]>;
|
|
67
|
-
readonly name: import("effect/Schema").optional<import("effect/Schema").NonEmptyString>;
|
|
68
|
-
readonly organizationId: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
69
|
-
readonly permissions: import("effect/Schema").optional<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").$Array<import("effect/Schema").String>>>;
|
|
70
|
-
}>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
71
|
-
readonly id: import("effect/Schema").String;
|
|
72
|
-
readonly key: import("effect/Schema").String;
|
|
73
81
|
}>>, HttpApiEndpoint.Json<typeof ExtraBadRequest>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"verifyApiKey", "POST", "/api/auth/verify-api-key", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
74
82
|
readonly key: import("effect/Schema").NonEmptyString;
|
|
75
83
|
readonly configId: import("effect/Schema").optional<import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"user">, import("effect/Schema").Literal<"organization">, import("effect/Schema").Literal<"service">]>>;
|
|
@@ -94,16 +102,8 @@ export declare const ExtraApi: HttpApi.HttpApi<"ExtraApi", HttpApiGroup.HttpApiG
|
|
|
94
102
|
readonly permissions: import("effect/Schema").NullOr<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").$Array<import("effect/Schema").String>>>;
|
|
95
103
|
readonly metadata: import("effect/Schema").NullOr<import("effect/Schema").Unknown>;
|
|
96
104
|
}>>;
|
|
97
|
-
}>>, HttpApiEndpoint.Json<typeof ExtraBadRequest>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"
|
|
98
|
-
readonly
|
|
99
|
-
readonly contentType: import("effect/Schema").NonEmptyString;
|
|
100
|
-
}>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
101
|
-
readonly uploadUrl: import("effect/Schema").String;
|
|
102
|
-
readonly url: import("effect/Schema").String;
|
|
103
|
-
}>>, HttpApiEndpoint.Json<typeof HttpApiError.Unauthorized | typeof HttpApiError.InternalServerError | typeof ExtraBadRequest>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"presign", "POST", "/api/organizations/logo/presign", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
104
|
-
readonly fileName: import("effect/Schema").NonEmptyString;
|
|
105
|
-
readonly contentType: import("effect/Schema").NonEmptyString;
|
|
105
|
+
}>>, HttpApiEndpoint.Json<typeof ExtraBadRequest>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"verifyPassword", "POST", "/api/auth/verify-password", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
106
|
+
readonly password: import("effect/Schema").NonEmptyString;
|
|
106
107
|
}>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
107
|
-
readonly
|
|
108
|
-
|
|
109
|
-
}>>, HttpApiEndpoint.Json<typeof HttpApiError.BadRequest | typeof HttpApiError.Unauthorized | typeof HttpApiError.Forbidden | typeof HttpApiError.InternalServerError>, never, never>, false>>;
|
|
108
|
+
readonly ok: import("effect/Schema").Boolean;
|
|
109
|
+
}>>, HttpApiEndpoint.Json<typeof ExtraBadRequest>, never, never>, false>>;
|
package/dist/extra/api.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { HttpApi, OpenApi } from "effect/unstable/httpapi";
|
|
2
2
|
import { HttpApiEndpoint, HttpApiError, HttpApiGroup, } from "effect/unstable/httpapi";
|
|
3
3
|
import { ExtraBadRequest, ExtraCreateApiKeyPayload, ExtraCreateApiKeyResponse, ExtraOkResponse, ExtraPresignedUpload, ExtraPresignUploadPayload, ExtraSetPasswordPayload, ExtraVerifyApiKeyPayload, ExtraVerifyApiKeyResponse, ExtraVerifyPasswordPayload, } from "./schema";
|
|
4
|
-
export const ExtraApiGroup = HttpApiGroup.make("
|
|
4
|
+
export const ExtraApiGroup = HttpApiGroup.make("authExtra")
|
|
5
5
|
.add(HttpApiEndpoint.post("setPassword", "/auth/set-password", {
|
|
6
6
|
payload: ExtraSetPasswordPayload,
|
|
7
7
|
success: ExtraOkResponse,
|
package/dist/extra/index.d.ts
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import { AtomHttpApi } from "effect/unstable/reactivity";
|
|
2
|
-
declare const ExtraApiClient_base: AtomHttpApi.AtomHttpApiClient<ExtraApiClient, "ExtraApiClient", import("effect/unstable/httpapi/HttpApiGroup").HttpApiGroup<"
|
|
3
|
-
readonly newPassword: import("effect/Schema").NonEmptyString;
|
|
4
|
-
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
5
|
-
readonly ok: import("effect/Schema").Boolean;
|
|
6
|
-
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("./schema").ExtraBadRequest>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"verifyPassword", "POST", "/api/auth/verify-password", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
7
|
-
readonly password: import("effect/Schema").NonEmptyString;
|
|
8
|
-
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
9
|
-
readonly ok: import("effect/Schema").Boolean;
|
|
10
|
-
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("./schema").ExtraBadRequest>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"createApiKey", "POST", "/api/auth/create-api-key", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
2
|
+
declare const ExtraApiClient_base: AtomHttpApi.AtomHttpApiClient<ExtraApiClient, "ExtraApiClient", import("effect/unstable/httpapi/HttpApiGroup").HttpApiGroup<"authExtra", import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"createApiKey", "POST", "/api/auth/create-api-key", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
11
3
|
readonly configId: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"user">, import("effect/Schema").Literal<"organization">, import("effect/Schema").Literal<"service">]>;
|
|
12
4
|
readonly name: import("effect/Schema").optional<import("effect/Schema").NonEmptyString>;
|
|
13
5
|
readonly organizationId: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
@@ -15,6 +7,22 @@ declare const ExtraApiClient_base: AtomHttpApi.AtomHttpApiClient<ExtraApiClient,
|
|
|
15
7
|
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
16
8
|
readonly id: import("effect/Schema").String;
|
|
17
9
|
readonly key: import("effect/Schema").String;
|
|
10
|
+
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("./schema").ExtraBadRequest>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"presign", "POST", "/api/organizations/logo/presign", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
11
|
+
readonly fileName: import("effect/Schema").NonEmptyString;
|
|
12
|
+
readonly contentType: import("effect/Schema").NonEmptyString;
|
|
13
|
+
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
14
|
+
readonly uploadUrl: import("effect/Schema").String;
|
|
15
|
+
readonly url: import("effect/Schema").String;
|
|
16
|
+
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("effect/unstable/httpapi/HttpApiError").BadRequest | typeof import("effect/unstable/httpapi/HttpApiError").Unauthorized | typeof import("effect/unstable/httpapi/HttpApiError").Forbidden | typeof import("effect/unstable/httpapi/HttpApiError").InternalServerError>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"presignUserImageUpload", "POST", "/api/auth/image/presign", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
17
|
+
readonly fileName: import("effect/Schema").NonEmptyString;
|
|
18
|
+
readonly contentType: import("effect/Schema").NonEmptyString;
|
|
19
|
+
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
20
|
+
readonly uploadUrl: import("effect/Schema").String;
|
|
21
|
+
readonly url: import("effect/Schema").String;
|
|
22
|
+
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("effect/unstable/httpapi/HttpApiError").Unauthorized | typeof import("effect/unstable/httpapi/HttpApiError").InternalServerError | typeof import("./schema").ExtraBadRequest>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"setPassword", "POST", "/api/auth/set-password", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
23
|
+
readonly newPassword: import("effect/Schema").NonEmptyString;
|
|
24
|
+
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
25
|
+
readonly ok: import("effect/Schema").Boolean;
|
|
18
26
|
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("./schema").ExtraBadRequest>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"verifyApiKey", "POST", "/api/auth/verify-api-key", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
19
27
|
readonly key: import("effect/Schema").NonEmptyString;
|
|
20
28
|
readonly configId: import("effect/Schema").optional<import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"user">, import("effect/Schema").Literal<"organization">, import("effect/Schema").Literal<"service">]>>;
|
|
@@ -39,22 +47,14 @@ declare const ExtraApiClient_base: AtomHttpApi.AtomHttpApiClient<ExtraApiClient,
|
|
|
39
47
|
readonly permissions: import("effect/Schema").NullOr<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").$Array<import("effect/Schema").String>>>;
|
|
40
48
|
readonly metadata: import("effect/Schema").NullOr<import("effect/Schema").Unknown>;
|
|
41
49
|
}>>;
|
|
42
|
-
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("./schema").ExtraBadRequest>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"
|
|
43
|
-
readonly
|
|
44
|
-
readonly contentType: import("effect/Schema").NonEmptyString;
|
|
45
|
-
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
46
|
-
readonly uploadUrl: import("effect/Schema").String;
|
|
47
|
-
readonly url: import("effect/Schema").String;
|
|
48
|
-
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("effect/unstable/httpapi/HttpApiError").Unauthorized | typeof import("effect/unstable/httpapi/HttpApiError").InternalServerError | typeof import("./schema").ExtraBadRequest>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"presign", "POST", "/api/organizations/logo/presign", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
49
|
-
readonly fileName: import("effect/Schema").NonEmptyString;
|
|
50
|
-
readonly contentType: import("effect/Schema").NonEmptyString;
|
|
50
|
+
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("./schema").ExtraBadRequest>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"verifyPassword", "POST", "/api/auth/verify-password", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
51
|
+
readonly password: import("effect/Schema").NonEmptyString;
|
|
51
52
|
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
52
|
-
readonly
|
|
53
|
-
|
|
54
|
-
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("effect/unstable/httpapi/HttpApiError").BadRequest | typeof import("effect/unstable/httpapi/HttpApiError").Unauthorized | typeof import("effect/unstable/httpapi/HttpApiError").Forbidden | typeof import("effect/unstable/httpapi/HttpApiError").InternalServerError>, never, never>, false>>;
|
|
53
|
+
readonly ok: import("effect/Schema").Boolean;
|
|
54
|
+
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("./schema").ExtraBadRequest>, never, never>, false>>;
|
|
55
55
|
export declare class ExtraApiClient extends ExtraApiClient_base {
|
|
56
56
|
}
|
|
57
|
-
export {
|
|
57
|
+
export { AuthService } from "../service";
|
|
58
58
|
export { AuthClientConfig } from "../config";
|
|
59
59
|
export { ExtraApi, ExtraApiGroup } from "./api";
|
|
60
60
|
export * from "./schema";
|
package/dist/extra/index.js
CHANGED
|
@@ -8,7 +8,7 @@ export class ExtraApiClient extends AtomHttpApi.Service()("ExtraApiClient", {
|
|
|
8
8
|
httpClient: FetchHttpClient.layer,
|
|
9
9
|
}) {
|
|
10
10
|
}
|
|
11
|
-
export {
|
|
11
|
+
export { AuthService } from "../service";
|
|
12
12
|
export { AuthClientConfig } from "../config";
|
|
13
13
|
export { ExtraApi, ExtraApiGroup } from "./api";
|
|
14
14
|
export * from "./schema";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from "./schema";
|
|
2
|
-
export {
|
|
2
|
+
export { AuthApi } from "./api";
|
|
3
|
+
export { AuthService, type AuthServiceLayerOptions } from "./service";
|
|
3
4
|
export { AuthClientConfig } from "./config";
|
|
4
5
|
export { OrganizationSwitcher, UserButton, type AuthUiClient, type OrganizationSwitcherDialog, type UserButtonDialog, } from "./components";
|
|
5
6
|
export * as BetterAuth from "./better-auth";
|