@krak-stack/auth 0.1.25 → 0.1.28
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/auth-api-client.d.ts +252 -0
- package/dist/components/auth-api-client.js +29 -0
- package/dist/components/organization-switcher.d.ts +2 -0
- package/dist/components/organization-switcher.js +71 -71
- package/dist/components/user-button.js +26 -39
- 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 +141 -133
- 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,9 @@
|
|
|
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
5
|
import { Schema } from "effect";
|
|
5
|
-
import { Building2, Check, ChevronsUpDown, KeyRound, Mail, PencilIcon, Plus, Trash2, UserPlus, Users, X, } from "lucide-react";
|
|
6
|
+
import { Building2, Check, ChevronsUpDown, Copy, KeyRound, Mail, PencilIcon, Plus, Trash2, UserIcon, UserPlus, Users, X, } from "lucide-react";
|
|
6
7
|
import { createContext, useContext, useEffect, useEffectEvent, useState, } from "react";
|
|
7
8
|
import { DataTable } from "@/components/ui/data-table";
|
|
8
9
|
import { EditingLocaleSwitcher } from "@/components/ui/editing-locale-switcher";
|
|
@@ -16,13 +17,17 @@ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "
|
|
|
16
17
|
import { Separator } from "@/components/ui/separator";
|
|
17
18
|
import { cn } from "@/lib/utils";
|
|
18
19
|
import { OrganizationMetadata, } from "@krak-stack/auth/schema";
|
|
19
|
-
import {
|
|
20
|
+
import { authApiClient } from "./auth-api-client";
|
|
21
|
+
import { createApiKey } from "./api-key";
|
|
22
|
+
import { ExtraPresignedUpload } from "../extra/schema";
|
|
23
|
+
import { assetPath, assetUrl } from "./utils";
|
|
20
24
|
const messages = {
|
|
21
25
|
en: {
|
|
22
26
|
api_key_rate_limit_notice: "API keys are subject to the same rate limits as your account.",
|
|
23
27
|
organization_contact_email: "Contact email",
|
|
24
28
|
organization_create_description: "Create a workspace for team-based access.",
|
|
25
29
|
organization_create_error: "Could not create the organization.",
|
|
30
|
+
organization_copy_id: "Copy organization ID",
|
|
26
31
|
organization_create_slug_conflict: "That organization slug is already in use. Choose a different slug.",
|
|
27
32
|
organization_create_title: "Create organization",
|
|
28
33
|
organization_edit_description: "Update the active organization's canonical details and localized profile.",
|
|
@@ -101,6 +106,7 @@ const messages = {
|
|
|
101
106
|
organization_contact_email: "E-mail de contact",
|
|
102
107
|
organization_create_description: "Créez un espace de travail pour l'accès en équipe.",
|
|
103
108
|
organization_create_error: "Impossible de créer l'organisation.",
|
|
109
|
+
organization_copy_id: "Copier l'ID de l'organisation",
|
|
104
110
|
organization_create_slug_conflict: "Ce slug d'organisation est déjà utilisé. Choisissez un autre slug.",
|
|
105
111
|
organization_create_title: "Créer une organisation",
|
|
106
112
|
organization_edit_description: "Mettez à jour les détails canoniques et le profil localisé de l'organisation active.",
|
|
@@ -200,34 +206,24 @@ const slugify = (value) => value
|
|
|
200
206
|
.replace(/[^a-z0-9]+/g, "-")
|
|
201
207
|
.replace(/^-+|-+$/g, "");
|
|
202
208
|
const isOrganizationSlugConflict = (error) => {
|
|
203
|
-
if (
|
|
209
|
+
if (typeof error !== "object" || error === null)
|
|
204
210
|
return false;
|
|
205
|
-
const code =
|
|
206
|
-
const message =
|
|
211
|
+
const code = Reflect.get(error, "code");
|
|
212
|
+
const message = Reflect.get(error, "message");
|
|
207
213
|
return [code, message].some((value) => {
|
|
214
|
+
if (typeof value !== "string")
|
|
215
|
+
return false;
|
|
208
216
|
const normalized = value.toLowerCase().replaceAll("_", " ");
|
|
209
217
|
return normalized.includes("organization already exists");
|
|
210
218
|
});
|
|
211
219
|
};
|
|
212
220
|
const nullableString = (value) => typeof value === "string" && value.trim() ? value.trim() : null;
|
|
213
|
-
const
|
|
214
|
-
|
|
215
|
-
typeof value.uploadUrl !== "string" ||
|
|
216
|
-
typeof value.url !== "string") {
|
|
217
|
-
throw new Error(m.organization_logo_upload_error());
|
|
218
|
-
}
|
|
219
|
-
return { uploadUrl: value.uploadUrl, url: value.url };
|
|
220
|
-
};
|
|
221
|
-
const uploadOrganizationLogo = async (authClient, file, m) => {
|
|
221
|
+
const decodePresignedUpload = Schema.decodeUnknownPromise(ExtraPresignedUpload);
|
|
222
|
+
const uploadOrganizationLogo = async (file, m, presignOrganizationLogo) => {
|
|
222
223
|
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);
|
|
224
|
+
const presigned = await decodePresignedUpload(await presignOrganizationLogo({
|
|
225
|
+
payload: { fileName: file.name, contentType },
|
|
226
|
+
}));
|
|
231
227
|
const uploadResponse = await fetch(presigned.uploadUrl, {
|
|
232
228
|
method: "PUT",
|
|
233
229
|
headers: { "Content-Type": contentType },
|
|
@@ -285,9 +281,9 @@ const organizationFormDefaults = (organization, baseUrl) => {
|
|
|
285
281
|
frLocation: fr?.location ?? "",
|
|
286
282
|
};
|
|
287
283
|
};
|
|
288
|
-
const organizationLogoFromForm = async (
|
|
284
|
+
const organizationLogoFromForm = async (value, m, presignOrganizationLogo) => {
|
|
289
285
|
if (value instanceof File)
|
|
290
|
-
return await uploadOrganizationLogo(
|
|
286
|
+
return await uploadOrganizationLogo(value, m, presignOrganizationLogo);
|
|
291
287
|
if (typeof value === "string")
|
|
292
288
|
return assetPath(value);
|
|
293
289
|
return null;
|
|
@@ -305,21 +301,14 @@ const organizationRoleLabel = (role, m) => {
|
|
|
305
301
|
}
|
|
306
302
|
};
|
|
307
303
|
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) => {
|
|
304
|
+
const organizationMetadataFromForm = async (value, m, presignOrganizationLogo) => {
|
|
316
305
|
const translations = [];
|
|
317
306
|
const enName = value.enName.trim() || value.name.trim();
|
|
318
307
|
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(
|
|
308
|
+
const enLogo = await organizationLogoFromForm(value.enLogo, m, presignOrganizationLogo);
|
|
309
|
+
const enIcon = await organizationLogoFromForm(value.enIcon, m, presignOrganizationLogo);
|
|
310
|
+
const frLogo = await organizationLogoFromForm(value.frLogo, m, presignOrganizationLogo);
|
|
311
|
+
const frIcon = await organizationLogoFromForm(value.frIcon, m, presignOrganizationLogo);
|
|
323
312
|
if (enName) {
|
|
324
313
|
translations.push({
|
|
325
314
|
locale: "en",
|
|
@@ -432,7 +421,9 @@ export function OrganizationSwitcher({ authClient, baseUrl, side = "bottom", cla
|
|
|
432
421
|
: m.organization_switcher_empty() })) : null, _jsx(DropdownMenuSeparator, {}), !locked ? (_jsxs(DropdownMenuItem, { onClick: openCreate, children: [_jsx(Plus, {}), m.organization_create_title()] })) : null, _jsxs(DropdownMenuItem, { onClick: () => {
|
|
433
422
|
setDialog("invitations");
|
|
434
423
|
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: () =>
|
|
424
|
+
}, 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: () => {
|
|
425
|
+
void navigator.clipboard.writeText(activeOrganization.data.id);
|
|
426
|
+
}, 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
427
|
setDialog((current) => open ? "create" : current === "create" ? null : current);
|
|
437
428
|
}, 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
429
|
setDialog(null);
|
|
@@ -448,7 +439,7 @@ export function OrganizationSwitcher({ authClient, baseUrl, side = "bottom", cla
|
|
|
448
439
|
setDialog((current) => open ? "manage" : current === "manage" ? null : current);
|
|
449
440
|
}, 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
441
|
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) => {
|
|
442
|
+
}, 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
443
|
setDialog((current) => open ? "apiKeys" : current === "apiKeys" ? null : current);
|
|
453
444
|
}, 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
445
|
setDialog((current) => open ? "invitations" : current === "invitations" ? null : current);
|
|
@@ -532,6 +523,7 @@ const userInvitationRowActions = ({ m, actingInvitationId, onAccept, onReject, }
|
|
|
532
523
|
];
|
|
533
524
|
function EditOrganizationSection({ authClient, baseUrl, organization, onUpdated, }) {
|
|
534
525
|
const m = useOrganizationMessages();
|
|
526
|
+
const presignOrganizationLogo = useAtomSet(authApiClient(baseUrl).mutation("authExtra", "presign"), { mode: "promise" });
|
|
535
527
|
const [editingLocale, setEditingLocale] = useState(currentOrganizationLocale());
|
|
536
528
|
const defaultValues = organizationFormDefaults(organization, baseUrl);
|
|
537
529
|
const form = useAppForm({
|
|
@@ -541,7 +533,7 @@ function EditOrganizationSection({ authClient, baseUrl, organization, onUpdated,
|
|
|
541
533
|
try {
|
|
542
534
|
const name = value.name.trim();
|
|
543
535
|
const slug = value.slug.trim().toLowerCase();
|
|
544
|
-
const metadata = await organizationMetadataFromForm(
|
|
536
|
+
const metadata = await organizationMetadataFromForm(value, m, presignOrganizationLogo);
|
|
545
537
|
const result = await authClient.organization.update({
|
|
546
538
|
organizationId: organization.id,
|
|
547
539
|
data: { name, slug, metadata },
|
|
@@ -607,6 +599,7 @@ function CreateOrganizationSlugAutoFill({ form, }) {
|
|
|
607
599
|
}
|
|
608
600
|
function CreateOrganizationSection({ authClient, baseUrl, onCreated, }) {
|
|
609
601
|
const m = useOrganizationMessages();
|
|
602
|
+
const presignOrganizationLogo = useAtomSet(authApiClient(baseUrl).mutation("authExtra", "presign"), { mode: "promise" });
|
|
610
603
|
const [editingLocale, setEditingLocale] = useState(currentOrganizationLocale());
|
|
611
604
|
const defaultValues = organizationFormDefaults(undefined, baseUrl);
|
|
612
605
|
const form = useAppForm({
|
|
@@ -616,11 +609,11 @@ function CreateOrganizationSection({ authClient, baseUrl, onCreated, }) {
|
|
|
616
609
|
try {
|
|
617
610
|
const name = value.name.trim();
|
|
618
611
|
const slug = (value.slug.trim() || slugify(name)).toLowerCase();
|
|
619
|
-
const metadata = await organizationMetadataFromForm(
|
|
612
|
+
const metadata = await organizationMetadataFromForm({
|
|
620
613
|
...value,
|
|
621
614
|
name,
|
|
622
615
|
slug,
|
|
623
|
-
}, m);
|
|
616
|
+
}, m, presignOrganizationLogo);
|
|
624
617
|
const result = await authClient.organization.create({
|
|
625
618
|
name,
|
|
626
619
|
slug,
|
|
@@ -693,7 +686,7 @@ function OrganizationTranslationHeader({ locale, editingLocale, onEditingLocaleC
|
|
|
693
686
|
: m.organization_translation_french();
|
|
694
687
|
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
688
|
}
|
|
696
|
-
function OrganizationMembersManager({ authClient, organization, currentUserId, }) {
|
|
689
|
+
function OrganizationMembersManager({ authClient, baseUrl, organization, currentUserId, }) {
|
|
697
690
|
const m = useOrganizationMessages();
|
|
698
691
|
const [members, setMembers] = useState([]);
|
|
699
692
|
const [invitations, setInvitations] = useState([]);
|
|
@@ -794,34 +787,38 @@ function OrganizationMembersManager({ authClient, organization, currentUserId, }
|
|
|
794
787
|
}
|
|
795
788
|
await loadMembers();
|
|
796
789
|
};
|
|
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) => {
|
|
790
|
+
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
791
|
event.preventDefault();
|
|
799
792
|
event.stopPropagation();
|
|
800
793
|
inviteForm.handleSubmit();
|
|
801
794
|
}, 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
795
|
label: organizationRoleLabel(role, m),
|
|
803
796
|
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
|
-
|
|
797
|
+
})) })) }), _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({
|
|
798
|
+
m,
|
|
799
|
+
baseUrl,
|
|
800
|
+
updatingMemberId,
|
|
801
|
+
onRoleChange: updateRole,
|
|
802
|
+
}), data: members, emptyLabel: loading ? m.user_loading() : m.organization_members_empty(), exportFileName: `${organization.slug}-members.csv`, features: { gallery: false }, rowActions: memberRowActions({
|
|
803
|
+
m,
|
|
804
|
+
currentUserId,
|
|
805
|
+
onRemove: removeMember,
|
|
806
|
+
}) }) })] }), _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({
|
|
807
|
+
m,
|
|
808
|
+
}), data: invitations, emptyLabel: loading ? m.user_loading() : m.organization_invitations_empty(), exportFileName: `${organization.slug}-invitations.csv`, features: { gallery: false }, rowActions: invitationRowActions({
|
|
809
|
+
m,
|
|
810
|
+
cancellingInvitationId,
|
|
811
|
+
onCancel: cancelInvitation,
|
|
812
|
+
}) }) })] })] }));
|
|
819
813
|
}
|
|
820
|
-
const memberColumns = ({ m, updatingMemberId, onRoleChange, }) => [
|
|
814
|
+
const memberColumns = ({ m, baseUrl, updatingMemberId, onRoleChange, }) => [
|
|
821
815
|
{
|
|
822
816
|
id: "user",
|
|
823
817
|
header: m.organization_member_user(),
|
|
824
|
-
cell: ({ row }) =>
|
|
818
|
+
cell: ({ row }) => {
|
|
819
|
+
const image = assetUrl(row.original.user.image, baseUrl);
|
|
820
|
+
return (_jsx(AppBrand, { to: null, label: row.original.user.name, subtitle: row.original.user.email, icon: UserIcon, className: "min-w-0", ...(image ? { imageSrc: image } : {}) }));
|
|
821
|
+
},
|
|
825
822
|
},
|
|
826
823
|
{
|
|
827
824
|
accessorKey: "role",
|
|
@@ -913,23 +910,26 @@ function OrganizationApiKeyManager({ authClient, organization, }) {
|
|
|
913
910
|
onSubmit: async ({ value, formApi }) => {
|
|
914
911
|
formApi.setErrorMap({ onSubmit: undefined });
|
|
915
912
|
setCreatedKey(null);
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
913
|
+
try {
|
|
914
|
+
const created = await createApiKey({
|
|
915
|
+
configId: "organization",
|
|
916
|
+
organizationId: organization.id,
|
|
917
|
+
name: value.name.trim(),
|
|
918
|
+
}, m.user_api_key_create_error());
|
|
919
|
+
setCreatedKey(created.key);
|
|
920
|
+
createForm.reset();
|
|
921
|
+
await loadKeys();
|
|
922
|
+
}
|
|
923
|
+
catch (cause) {
|
|
922
924
|
formApi.setErrorMap({
|
|
923
925
|
onSubmit: {
|
|
924
|
-
form:
|
|
926
|
+
form: cause instanceof Error
|
|
927
|
+
? cause.message
|
|
928
|
+
: m.user_api_key_create_error(),
|
|
925
929
|
fields: {},
|
|
926
930
|
},
|
|
927
931
|
});
|
|
928
|
-
return;
|
|
929
932
|
}
|
|
930
|
-
setCreatedKey(result.data.key);
|
|
931
|
-
createForm.reset();
|
|
932
|
-
await loadKeys();
|
|
933
933
|
},
|
|
934
934
|
});
|
|
935
935
|
const deleteKey = async (key) => {
|
|
@@ -1,6 +1,8 @@
|
|
|
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 {} from "@tanstack/react-table";
|
|
3
4
|
import { useNavigate, useRouterState, } from "@tanstack/react-router";
|
|
5
|
+
import { Schema } from "effect";
|
|
4
6
|
import { Check, Copy, KeyRound, LogOutIcon, ShieldCheck, Trash2, UserCircleIcon, UserIcon, } from "lucide-react";
|
|
5
7
|
import { QRCode } from "react-qr-code";
|
|
6
8
|
import { createContext, useContext, useEffect, useEffectEvent, useState, } from "react";
|
|
@@ -14,7 +16,10 @@ import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, }
|
|
|
14
16
|
import { Field, FieldContent, FieldDescription, FieldGroup, FieldLabel, FieldLegend, FieldSet, } from "@/components/ui/field";
|
|
15
17
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu";
|
|
16
18
|
import { Separator } from "@/components/ui/separator";
|
|
17
|
-
import {
|
|
19
|
+
import { authApiClient } from "./auth-api-client";
|
|
20
|
+
import { createApiKey } from "./api-key";
|
|
21
|
+
import { ExtraPresignedUpload } from "../extra/schema";
|
|
22
|
+
import { assetPath, assetUrl } from "./utils";
|
|
18
23
|
const messages = {
|
|
19
24
|
en: {
|
|
20
25
|
api_key_rate_limit_notice: "API keys are subject to the same rate limits as your account.",
|
|
@@ -199,21 +204,12 @@ const userButtonMessageFns = (labels) => new Proxy({}, {
|
|
|
199
204
|
const UserButtonMessagesContext = createContext(userButtonMessageFns(userButtonMessages()));
|
|
200
205
|
const useUserButtonMessages = () => useContext(UserButtonMessagesContext);
|
|
201
206
|
const isFile = (value) => value instanceof File;
|
|
202
|
-
const
|
|
207
|
+
const decodePresignedUpload = Schema.decodeUnknownPromise(ExtraPresignedUpload);
|
|
208
|
+
const presignUserImageUpload = async (file, m, presignUserImage) => {
|
|
203
209
|
const contentType = file.type || "image/png";
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
});
|
|
208
|
-
if (result.error || !isRecord(result.data)) {
|
|
209
|
-
throw new Error(m.user_profile_image_upload_error());
|
|
210
|
-
}
|
|
211
|
-
const uploadUrl = Reflect.get(result.data, "uploadUrl");
|
|
212
|
-
const url = Reflect.get(result.data, "url");
|
|
213
|
-
if (typeof uploadUrl !== "string" || typeof url !== "string") {
|
|
214
|
-
throw new Error(m.user_profile_image_upload_error());
|
|
215
|
-
}
|
|
216
|
-
return { uploadUrl, url };
|
|
210
|
+
return await decodePresignedUpload(await presignUserImage({
|
|
211
|
+
payload: { fileName: file.name, contentType },
|
|
212
|
+
}));
|
|
217
213
|
};
|
|
218
214
|
export const UserButton = ({ authClient, baseUrl, signOutRedirect = "/", side = "bottom", defaultDialog = null, hideTrigger = false, renderUnauthenticated, apiKeyPermissions, messages, dialog: controlledDialog, onDialogChange, }) => {
|
|
219
215
|
const labels = userButtonMessages(messages);
|
|
@@ -226,6 +222,7 @@ export const UserButton = ({ authClient, baseUrl, signOutRedirect = "/", side =
|
|
|
226
222
|
const [uncontrolledDialog, setUncontrolledDialog] = useState(defaultDialog);
|
|
227
223
|
const settingsDialog = controlledDialog !== undefined ? controlledDialog : uncontrolledDialog;
|
|
228
224
|
const [formError, setFormError] = useState(null);
|
|
225
|
+
const presignUserImage = useAtomSet(authApiClient(baseUrl).mutation("authExtra", "presignUserImageUpload"), { mode: "promise" });
|
|
229
226
|
const setSettingsDialog = (next) => {
|
|
230
227
|
const nextDialog = typeof next === "function" ? next(settingsDialog) : next;
|
|
231
228
|
if (nextDialog === settingsDialog)
|
|
@@ -252,7 +249,7 @@ export const UserButton = ({ authClient, baseUrl, signOutRedirect = "/", side =
|
|
|
252
249
|
const imageFile = isFile(values.image) ? values.image : null;
|
|
253
250
|
const image = imageFile
|
|
254
251
|
? await (async () => {
|
|
255
|
-
const presigned = await presignUserImageUpload(
|
|
252
|
+
const presigned = await presignUserImageUpload(imageFile, m, presignUserImage);
|
|
256
253
|
const uploadResponse = await fetch(presigned.uploadUrl, {
|
|
257
254
|
method: "PUT",
|
|
258
255
|
headers: { "Content-Type": imageFile.type || "image/png" },
|
|
@@ -276,7 +273,7 @@ export const UserButton = ({ authClient, baseUrl, signOutRedirect = "/", side =
|
|
|
276
273
|
await refetch();
|
|
277
274
|
setSettingsDialog(null);
|
|
278
275
|
};
|
|
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) => {
|
|
276
|
+
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
277
|
setSettingsDialog((current) => open ? "account" : current === "account" ? null : current);
|
|
281
278
|
}, 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
279
|
name: displayName ?? "",
|
|
@@ -651,28 +648,27 @@ function ApiKeyManager({ authClient, permissions = {}, }) {
|
|
|
651
648
|
setCreatedKey(null);
|
|
652
649
|
setCopiedKey(false);
|
|
653
650
|
const selectedPermissionObject = getSelectedPermissionObject(permissionOptions, selectedPermissions);
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
body: {
|
|
651
|
+
try {
|
|
652
|
+
const created = await createApiKey({
|
|
657
653
|
configId: "user",
|
|
658
654
|
name: value.name.trim(),
|
|
659
655
|
permissions: selectedPermissionObject,
|
|
660
|
-
},
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
656
|
+
}, m.user_api_key_create_error());
|
|
657
|
+
setCreatedKey(created.key);
|
|
658
|
+
createForm.reset();
|
|
659
|
+
setSelectedPermissions({});
|
|
660
|
+
await loadKeys();
|
|
661
|
+
}
|
|
662
|
+
catch (cause) {
|
|
664
663
|
formApi.setErrorMap({
|
|
665
664
|
onSubmit: {
|
|
666
|
-
form:
|
|
665
|
+
form: cause instanceof Error
|
|
666
|
+
? cause.message
|
|
667
|
+
: m.user_api_key_create_error(),
|
|
667
668
|
fields: {},
|
|
668
669
|
},
|
|
669
670
|
});
|
|
670
|
-
return;
|
|
671
671
|
}
|
|
672
|
-
setCreatedKey(created.key);
|
|
673
|
-
createForm.reset();
|
|
674
|
-
setSelectedPermissions({});
|
|
675
|
-
await loadKeys();
|
|
676
672
|
},
|
|
677
673
|
});
|
|
678
674
|
const togglePermission = (id, checked) => {
|
|
@@ -776,12 +772,3 @@ const isAuthErrorResult = (result) => {
|
|
|
776
772
|
typeof result.error === "object" &&
|
|
777
773
|
result.error !== null);
|
|
778
774
|
};
|
|
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,
|