@krak-stack/auth 0.2.0 → 0.2.2
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/access.d.ts +1 -3
- package/dist/access.js +1 -3
- package/dist/admin/api.group.d.ts +36 -36
- package/dist/admin/api.group.js +13 -13
- package/dist/api.d.ts +2109 -865
- package/dist/auth/api.group.d.ts +664 -106
- package/dist/auth/api.group.js +8 -8
- package/dist/auth/schema.d.ts +537 -70
- package/dist/auth/schema.js +26 -10
- package/dist/components/admin-organization-form.js +1 -0
- package/dist/components/admin-organizations.d.ts +4 -5
- package/dist/components/admin-organizations.js +34 -31
- package/dist/components/admin-users.d.ts +5 -6
- package/dist/components/admin-users.js +51 -50
- package/dist/components/api-key-edit-form.js +2 -1
- package/dist/components/auth-atoms.d.ts +213 -103
- package/dist/components/auth-client-api.d.ts +1412 -2371
- package/dist/components/auth-client-api.js +11 -7
- package/dist/components/auth-forms.js +6 -1
- package/dist/components/auth-provider.d.ts +13 -13
- package/dist/components/contact-fields.d.ts +40 -0
- package/dist/components/contact-fields.js +86 -0
- package/dist/components/member-required.js +2 -2
- package/dist/components/organization-switcher.js +101 -193
- package/dist/components/user-button.d.ts +73 -0
- package/dist/components/user-button.js +179 -29
- package/dist/extra/api.group.d.ts +19 -19
- package/dist/extra/api.group.js +3 -3
- package/dist/extra/schema.d.ts +1 -2
- package/dist/extra/schema.js +1 -2
- package/dist/query.js +5 -5
- package/dist/schema.d.ts +279 -12
- package/dist/schema.js +162 -42
- package/dist/server/api.group.d.ts +157 -29
- package/dist/server/api.group.js +12 -12
- package/dist/server/schema.d.ts +64 -0
- package/dist/service.d.ts +3380 -2446
- package/package.json +4 -4
|
@@ -9,6 +9,7 @@ import { QRCode } from "react-qr-code";
|
|
|
9
9
|
import { createContext, useContext, useRef, useState, } from "react";
|
|
10
10
|
import { DataTable, } from "@krak-stack/registry/data-table";
|
|
11
11
|
import { AppBrand } from "@krak-stack/registry/app-brand";
|
|
12
|
+
import { EditingLocaleSwitcher } from "@krak-stack/registry/editing-locale-switcher";
|
|
12
13
|
import { effectFormMessages, ImageField, SubmitButton, SubmitError, TextAreaField, TextField, } from "@krak-stack/registry/effect-form";
|
|
13
14
|
import { Badge } from "@/components/ui/badge";
|
|
14
15
|
import { Button } from "@/components/ui/button";
|
|
@@ -29,6 +30,8 @@ import { ExtraUploadedAsset } from "../extra/schema.js";
|
|
|
29
30
|
import { assetPath, assetUrl } from "./utils.js";
|
|
30
31
|
import { AdminOrganizationsTable } from "./admin-organizations.js";
|
|
31
32
|
import { AdminUsersTable } from "./admin-users.js";
|
|
33
|
+
import { ContactEmailsField, ContactPhonesField, ContactSocialsField, ContactWebsitesField, } from "./contact-fields.js";
|
|
34
|
+
import { decodeUserMetadata, ContactLocale, SocialPlatform, USER_CONTACT_LIMIT, UserMetadata, } from "../schema.js";
|
|
32
35
|
const messages = {
|
|
33
36
|
en: {
|
|
34
37
|
table_empty: "No results.",
|
|
@@ -118,6 +121,22 @@ const messages = {
|
|
|
118
121
|
user_form_title: "Account",
|
|
119
122
|
user_form_update_error: "Unable to update your account.",
|
|
120
123
|
user_loading: "Loading...",
|
|
124
|
+
user_contact_add_email: "Add email",
|
|
125
|
+
user_contact_add_phone: "Add phone",
|
|
126
|
+
user_contact_add_social: "Add social profile",
|
|
127
|
+
user_contact_add_website: "Add website",
|
|
128
|
+
user_contact_description: "Add up to 8 public contacts of each type, separately from the email used to sign in.",
|
|
129
|
+
user_contact_email_type: "Email",
|
|
130
|
+
user_contact_extension: "Extension",
|
|
131
|
+
user_contact_label: "Label",
|
|
132
|
+
user_contact_phone_type: "Phone",
|
|
133
|
+
user_contact_platform: "Platform",
|
|
134
|
+
user_contact_remove: "Remove contact method",
|
|
135
|
+
user_contact_social_type: "Social",
|
|
136
|
+
user_contact_title: "Contact methods",
|
|
137
|
+
user_contact_url: "URL",
|
|
138
|
+
user_contact_validation_error: "Review your contact methods and keep the total metadata below 2 KB.",
|
|
139
|
+
user_contact_website_type: "Website",
|
|
121
140
|
user_profile_description: "Update your public profile details.",
|
|
122
141
|
user_profile_image_upload_error: "Could not upload your profile photo.",
|
|
123
142
|
user_profile_photo_upload_label: "Profile photo",
|
|
@@ -227,6 +246,22 @@ const messages = {
|
|
|
227
246
|
user_form_title: "Compte",
|
|
228
247
|
user_form_update_error: "Impossible de mettre à jour votre compte.",
|
|
229
248
|
user_loading: "Chargement...",
|
|
249
|
+
user_contact_add_email: "Ajouter un courriel",
|
|
250
|
+
user_contact_add_phone: "Ajouter un téléphone",
|
|
251
|
+
user_contact_add_social: "Ajouter un profil social",
|
|
252
|
+
user_contact_add_website: "Ajouter un site Web",
|
|
253
|
+
user_contact_description: "Ajoutez jusqu’à 8 coordonnées publiques de chaque type, distinctes du courriel utilisé pour vous connecter.",
|
|
254
|
+
user_contact_email_type: "Courriel",
|
|
255
|
+
user_contact_extension: "Poste",
|
|
256
|
+
user_contact_label: "Libellé",
|
|
257
|
+
user_contact_phone_type: "Téléphone",
|
|
258
|
+
user_contact_platform: "Plateforme",
|
|
259
|
+
user_contact_remove: "Supprimer le moyen de contact",
|
|
260
|
+
user_contact_social_type: "Réseau social",
|
|
261
|
+
user_contact_title: "Moyens de contact",
|
|
262
|
+
user_contact_url: "URL",
|
|
263
|
+
user_contact_validation_error: "Vérifiez vos moyens de contact et limitez les métadonnées totales à 2 Ko.",
|
|
264
|
+
user_contact_website_type: "Site Web",
|
|
230
265
|
user_profile_description: "Mettez à jour les informations de votre profil public.",
|
|
231
266
|
user_profile_image_upload_error: "Impossible de téléverser votre photo de profil.",
|
|
232
267
|
user_profile_photo_upload_label: "Photo de profil",
|
|
@@ -274,6 +309,19 @@ const userButtonMessageFns = (labels) => {
|
|
|
274
309
|
};
|
|
275
310
|
const UserButtonMessagesContext = createContext(userButtonMessageFns(userButtonMessages()));
|
|
276
311
|
const useUserButtonMessages = () => useContext(UserButtonMessagesContext);
|
|
312
|
+
const userContactFieldMessages = (m) => ({
|
|
313
|
+
addEmail: m.user_contact_add_email(),
|
|
314
|
+
addPhone: m.user_contact_add_phone(),
|
|
315
|
+
addSocial: m.user_contact_add_social(),
|
|
316
|
+
addWebsite: m.user_contact_add_website(),
|
|
317
|
+
email: m.user_contact_email_type(),
|
|
318
|
+
extension: m.user_contact_extension(),
|
|
319
|
+
label: m.user_contact_label(),
|
|
320
|
+
phone: m.user_contact_phone_type(),
|
|
321
|
+
platform: m.user_contact_platform(),
|
|
322
|
+
remove: m.user_contact_remove(),
|
|
323
|
+
url: m.user_contact_url(),
|
|
324
|
+
});
|
|
277
325
|
const UserRole = Schema.Struct({ role: Schema.String });
|
|
278
326
|
const hasRole = (role, roles) => {
|
|
279
327
|
const decoded = Schema.decodeUnknownOption(Schema.String)(role);
|
|
@@ -290,9 +338,87 @@ const changePasswordFormBuilder = FormBuilder.empty
|
|
|
290
338
|
.addField("currentPassword", Schema.NonEmptyString)
|
|
291
339
|
.addField("newPassword", Schema.NonEmptyString);
|
|
292
340
|
const passwordFormBuilder = (required) => FormBuilder.empty.addField("password", required ? Schema.NonEmptyString : Schema.String);
|
|
341
|
+
const ContactFormTranslation = Schema.Struct({
|
|
342
|
+
locale: ContactLocale,
|
|
343
|
+
label: Schema.String,
|
|
344
|
+
}).annotate({ identifier: "ContactFormTranslation" });
|
|
345
|
+
const ContactFormTranslations = Schema.Array(ContactFormTranslation).annotate({
|
|
346
|
+
identifier: "ContactFormTranslations",
|
|
347
|
+
});
|
|
348
|
+
export const UserContactEmailsForm = Schema.Array(Schema.Struct({
|
|
349
|
+
email: Schema.String,
|
|
350
|
+
translations: ContactFormTranslations,
|
|
351
|
+
}).annotate({ identifier: "UserContactEmailForm" }))
|
|
352
|
+
.check(Schema.isMaxLength(USER_CONTACT_LIMIT))
|
|
353
|
+
.annotate({ identifier: "UserContactEmailsForm" });
|
|
354
|
+
export const UserContactPhonesForm = Schema.Array(Schema.Struct({
|
|
355
|
+
number: Schema.String,
|
|
356
|
+
extension: Schema.optional(Schema.String),
|
|
357
|
+
translations: ContactFormTranslations,
|
|
358
|
+
}).annotate({ identifier: "UserContactPhoneForm" }))
|
|
359
|
+
.check(Schema.isMaxLength(USER_CONTACT_LIMIT))
|
|
360
|
+
.annotate({ identifier: "UserContactPhonesForm" });
|
|
361
|
+
export const UserContactWebsitesForm = Schema.Array(Schema.Struct({
|
|
362
|
+
url: Schema.String,
|
|
363
|
+
translations: ContactFormTranslations,
|
|
364
|
+
}).annotate({ identifier: "UserContactWebsiteForm" }))
|
|
365
|
+
.check(Schema.isMaxLength(USER_CONTACT_LIMIT))
|
|
366
|
+
.annotate({ identifier: "UserContactWebsitesForm" });
|
|
367
|
+
export const UserContactSocialsForm = Schema.Array(Schema.Struct({
|
|
368
|
+
platform: SocialPlatform,
|
|
369
|
+
url: Schema.String,
|
|
370
|
+
translations: ContactFormTranslations,
|
|
371
|
+
}).annotate({ identifier: "UserContactSocialForm" }))
|
|
372
|
+
.check(Schema.isMaxLength(USER_CONTACT_LIMIT))
|
|
373
|
+
.annotate({ identifier: "UserContactSocialsForm" });
|
|
293
374
|
const userFormBuilder = FormBuilder.empty
|
|
294
375
|
.addField("name", Schema.NonEmptyString)
|
|
295
|
-
.addField("image", Schema.UndefinedOr(Schema.NullOr(Schema.Union([Schema.String, Schema.instanceOf(File)]))))
|
|
376
|
+
.addField("image", Schema.UndefinedOr(Schema.NullOr(Schema.Union([Schema.String, Schema.instanceOf(File)]))))
|
|
377
|
+
.addField("emails", UserContactEmailsForm)
|
|
378
|
+
.addField("phones", UserContactPhonesForm)
|
|
379
|
+
.addField("websites", UserContactWebsitesForm)
|
|
380
|
+
.addField("socials", UserContactSocialsForm);
|
|
381
|
+
const decodeUserMetadataForm = Schema.decodeUnknownSync(UserMetadata);
|
|
382
|
+
export const userMetadataFromForm = (value) => {
|
|
383
|
+
const localized = (translations) => (translations ?? []).flatMap((translation) => {
|
|
384
|
+
const label = translation.label.trim();
|
|
385
|
+
return label ? [{ ...translation, label }] : [];
|
|
386
|
+
});
|
|
387
|
+
const emails = value.emails.flatMap((email) => {
|
|
388
|
+
const address = email.email.trim();
|
|
389
|
+
return address
|
|
390
|
+
? [{ email: address, translations: localized(email.translations) }]
|
|
391
|
+
: [];
|
|
392
|
+
});
|
|
393
|
+
const phones = value.phones.flatMap((phone) => {
|
|
394
|
+
const number = phone.number.trim();
|
|
395
|
+
if (!number)
|
|
396
|
+
return [];
|
|
397
|
+
const normalized = {
|
|
398
|
+
number,
|
|
399
|
+
translations: localized(phone.translations),
|
|
400
|
+
};
|
|
401
|
+
const extension = phone.extension?.trim();
|
|
402
|
+
return extension ? [{ ...normalized, extension }] : [normalized];
|
|
403
|
+
});
|
|
404
|
+
const websites = value.websites.flatMap((website) => {
|
|
405
|
+
const url = website.url.trim();
|
|
406
|
+
return url ? [{ url, translations: localized(website.translations) }] : [];
|
|
407
|
+
});
|
|
408
|
+
const socials = value.socials.flatMap((social) => {
|
|
409
|
+
const url = social.url.trim();
|
|
410
|
+
return url
|
|
411
|
+
? [
|
|
412
|
+
{
|
|
413
|
+
platform: social.platform,
|
|
414
|
+
url,
|
|
415
|
+
translations: localized(social.translations),
|
|
416
|
+
},
|
|
417
|
+
]
|
|
418
|
+
: [];
|
|
419
|
+
});
|
|
420
|
+
return decodeUserMetadataForm({ emails, phones, websites, socials });
|
|
421
|
+
};
|
|
296
422
|
const totpCodeFormBuilder = FormBuilder.empty.addField("code", Schema.NonEmptyString);
|
|
297
423
|
const apiKeyFormBuilder = FormBuilder.empty
|
|
298
424
|
.addField("name", Schema.NonEmptyString)
|
|
@@ -348,10 +474,10 @@ export const UserButton = ({ baseUrl, signOutRedirect = "/", side = "bottom", de
|
|
|
348
474
|
const refreshAccounts = shouldLoadAccounts
|
|
349
475
|
? refreshLoadedAccounts
|
|
350
476
|
: refreshEmptyAccounts;
|
|
351
|
-
const [signOutAction] = useState(() =>
|
|
477
|
+
const [signOutAction] = useState(() => authClientApi(resolvedBaseUrl).runtime.fn(({ baseUrl, redirectUrl, }) => authHttpClient(baseUrl).pipe(Effect.flatMap((client) => client.auth.signOut()), Effect.tap(() => Effect.sync(notifyAuthChange)), Effect.flatMap(() => Effect.tryPromise(() => navigate({ href: redirectUrl }))))));
|
|
352
478
|
const signOut = useAtomSet(signOutAction);
|
|
353
479
|
const signOutResult = useAtomValue(signOutAction);
|
|
354
|
-
const [stopImpersonatingAction] = useState(() =>
|
|
480
|
+
const [stopImpersonatingAction] = useState(() => authClientApi(resolvedBaseUrl).runtime.fn((input) => Effect.gen(function* () {
|
|
355
481
|
setIsStoppingImpersonation(true);
|
|
356
482
|
yield* authHttpClient(input.baseUrl).pipe(Effect.flatMap((client) => client.auth.adminStopImpersonating()), Effect.tap(() => Effect.sync(notifyAuthChange)), Effect.tap(() => Effect.sync(input.refreshSession)), Effect.flatMap(() => Effect.tryPromise(() => navigate({ href: input.currentSiteHref }))), Effect.ensuring(Effect.sync(() => setIsStoppingImpersonation(false))));
|
|
357
483
|
})));
|
|
@@ -389,6 +515,7 @@ export const UserButton = ({ baseUrl, signOutRedirect = "/", side = "bottom", de
|
|
|
389
515
|
const displayName = session.user.name.trim();
|
|
390
516
|
const displayEmail = session.user.email.trim();
|
|
391
517
|
const displayImage = assetUrl(session.user.image, resolvedBaseUrl);
|
|
518
|
+
const metadata = decodeUserMetadata(session.user.metadata);
|
|
392
519
|
const isImpersonating = Boolean(session.session.impersonatedBy);
|
|
393
520
|
const isOrganizationImpersonating = Boolean(session.session.impersonatedByOrganizationId);
|
|
394
521
|
const canManageUserSettings = !isOrganizationImpersonating;
|
|
@@ -409,8 +536,16 @@ export const UserButton = ({ baseUrl, signOutRedirect = "/", side = "bottom", de
|
|
|
409
536
|
}, children: _jsxs(DialogContent, { className: "max-h-[85vh] min-w-0 overflow-x-hidden 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: {
|
|
410
537
|
name: displayName ?? "",
|
|
411
538
|
image: displayImage || null,
|
|
539
|
+
emails: Array.from(metadata.emails ?? []),
|
|
540
|
+
phones: Array.from(metadata.phones ?? []),
|
|
541
|
+
websites: Array.from(metadata.websites ?? []),
|
|
542
|
+
socials: Array.from(metadata.socials ?? []),
|
|
412
543
|
}, error: formError, onSubmit: (values) => Effect.gen(function* () {
|
|
413
544
|
setFormError(null);
|
|
545
|
+
const metadata = yield* Effect.try({
|
|
546
|
+
try: () => userMetadataFromForm(values),
|
|
547
|
+
catch: () => new Error(m.user_contact_validation_error()),
|
|
548
|
+
});
|
|
414
549
|
const imageFile = isFile(values.image)
|
|
415
550
|
? values.image
|
|
416
551
|
: null;
|
|
@@ -424,6 +559,7 @@ export const UserButton = ({ baseUrl, signOutRedirect = "/", side = "bottom", de
|
|
|
424
559
|
payload: {
|
|
425
560
|
name: values.name.trim(),
|
|
426
561
|
image: image?.trim() ?? "",
|
|
562
|
+
metadata,
|
|
427
563
|
},
|
|
428
564
|
});
|
|
429
565
|
notifyAuthChange();
|
|
@@ -450,7 +586,7 @@ function ConnectedAccounts({ baseUrl, accountCache, googleEnabled, currentSiteHr
|
|
|
450
586
|
const [error, setError] = useState(null);
|
|
451
587
|
const [isLinking, setIsLinking] = useState(false);
|
|
452
588
|
const [revokingAccount, setRevokingAccount] = useState(null);
|
|
453
|
-
const [linkGoogleAction] = useState(() =>
|
|
589
|
+
const [linkGoogleAction] = useState(() => authClientApi(baseUrl).runtime.fn((input) => Effect.gen(function* () {
|
|
454
590
|
setError(null);
|
|
455
591
|
setIsLinking(true);
|
|
456
592
|
const client = yield* authHttpClient(input.baseUrl);
|
|
@@ -527,6 +663,7 @@ function ChangePasswordForm({ baseUrl }) {
|
|
|
527
663
|
const [saved, setSaved] = useState(false);
|
|
528
664
|
let reset = () => { };
|
|
529
665
|
const [form] = useState(() => FormReact.make(changePasswordFormBuilder, {
|
|
666
|
+
runtime: authClientApi(baseUrl).runtime,
|
|
530
667
|
fields: { currentPassword: TextField, newPassword: TextField },
|
|
531
668
|
mode: { validation: "onSubmit" },
|
|
532
669
|
onSubmit: (_, { decoded }) => authHttpClient(baseUrl).pipe(Effect.tap(() => Effect.sync(() => setSaved(false))), Effect.flatMap((client) => client.auth.changePassword({
|
|
@@ -551,6 +688,7 @@ function SetPasswordForm({ baseUrl, onSaved, }) {
|
|
|
551
688
|
const m = useUserButtonMessages();
|
|
552
689
|
let reset = () => { };
|
|
553
690
|
const [form] = useState(() => FormReact.make(passwordFormBuilder(true), {
|
|
691
|
+
runtime: authClientApi(baseUrl).runtime,
|
|
554
692
|
fields: { password: TextField },
|
|
555
693
|
mode: { validation: "onSubmit" },
|
|
556
694
|
onSubmit: (_, { decoded }) => authHttpClient(baseUrl).pipe(Effect.flatMap((client) => client.authExtra.setPassword({
|
|
@@ -571,6 +709,7 @@ function SetPasswordForm({ baseUrl, onSaved, }) {
|
|
|
571
709
|
function RevokeAccountForm({ baseUrl, account, requirePassword, onCancel, onRevoke, }) {
|
|
572
710
|
const m = useUserButtonMessages();
|
|
573
711
|
const [form] = useState(() => FormReact.make(passwordFormBuilder(requirePassword), {
|
|
712
|
+
runtime: authClientApi(baseUrl).runtime,
|
|
574
713
|
fields: { password: TextField },
|
|
575
714
|
mode: { validation: "onSubmit" },
|
|
576
715
|
onSubmit: (_, { decoded }) => Effect.gen(function* () {
|
|
@@ -604,8 +743,16 @@ const providerName = (providerId, m) => {
|
|
|
604
743
|
};
|
|
605
744
|
const UserForm = ({ defaultValues, error, onSubmit, }) => {
|
|
606
745
|
const m = useUserButtonMessages();
|
|
746
|
+
const [editingLocale, setEditingLocale] = useState(getLocale());
|
|
607
747
|
const [form] = useState(() => FormReact.make(userFormBuilder, {
|
|
608
|
-
fields: {
|
|
748
|
+
fields: {
|
|
749
|
+
name: TextField,
|
|
750
|
+
image: ImageField,
|
|
751
|
+
emails: ContactEmailsField,
|
|
752
|
+
phones: ContactPhonesField,
|
|
753
|
+
websites: ContactWebsitesField,
|
|
754
|
+
socials: ContactSocialsField,
|
|
755
|
+
},
|
|
609
756
|
mode: { validation: "onSubmit" },
|
|
610
757
|
onSubmit: (_, { decoded }) => onSubmit({ ...decoded, image: decoded.image ?? null }).pipe(Effect.mapError((cause) => cause instanceof Error
|
|
611
758
|
? cause
|
|
@@ -621,8 +768,9 @@ const UserForm = ({ defaultValues, error, onSubmit, }) => {
|
|
|
621
768
|
height: 96,
|
|
622
769
|
suggestedWidth: 512,
|
|
623
770
|
suggestedHeight: 512,
|
|
624
|
-
} }), _jsx(form.name, { label: m.user_form_name_label(), autoComplete: "name", required: true }), error && (_jsx("p", { role: "alert", className: "text-destructive text-sm", children: error })), _jsx(SubmitButton, { form: form })] }) })] }));
|
|
771
|
+
} }), _jsx(form.name, { label: m.user_form_name_label(), autoComplete: "name", required: true }), _jsx(Separator, {}), _jsxs("div", { className: "flex flex-col gap-4", children: [_jsxs("div", { className: "flex flex-wrap items-start justify-between gap-3", children: [_jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx("h3", { className: "text-sm leading-none font-medium", children: m.user_contact_title() }), _jsx("p", { className: "text-muted-foreground text-sm", children: m.user_contact_description() })] }), _jsx(EditingLocaleSwitcher, { value: editingLocale, onValueChange: setEditingLocale })] }), _jsx(UserContactGroup, { title: m.user_contact_email_type(), children: _jsx(form.emails, { locale: editingLocale, maxItems: USER_CONTACT_LIMIT, messages: userContactFieldMessages(m) }) }), _jsx(UserContactGroup, { title: m.user_contact_phone_type(), children: _jsx(form.phones, { locale: editingLocale, maxItems: USER_CONTACT_LIMIT, messages: userContactFieldMessages(m) }) }), _jsx(UserContactGroup, { title: m.user_contact_website_type(), children: _jsx(form.websites, { locale: editingLocale, maxItems: USER_CONTACT_LIMIT, messages: userContactFieldMessages(m) }) }), _jsx(UserContactGroup, { title: m.user_contact_social_type(), children: _jsx(form.socials, { locale: editingLocale, maxItems: USER_CONTACT_LIMIT, messages: userContactFieldMessages(m) }) })] }), error && (_jsx("p", { role: "alert", className: "text-destructive text-sm", children: error })), _jsx(SubmitButton, { form: form })] }) })] }));
|
|
625
772
|
};
|
|
773
|
+
const UserContactGroup = ({ children, title, }) => (_jsxs("div", { className: "flex flex-col gap-3", children: [_jsx("h4", { className: "text-sm font-medium", children: title }), children] }));
|
|
626
774
|
function AccountSecuritySettings({ baseUrl, accountCache, }) {
|
|
627
775
|
const m = useUserButtonMessages();
|
|
628
776
|
const sessionAtom = authSessionAtom(baseUrl);
|
|
@@ -655,6 +803,7 @@ function AccountSecuritySettings({ baseUrl, accountCache, }) {
|
|
|
655
803
|
function EnableTotpForm({ baseUrl, requirePassword, onEnabled, }) {
|
|
656
804
|
const m = useUserButtonMessages();
|
|
657
805
|
const [form] = useState(() => FormReact.make(passwordFormBuilder(requirePassword), {
|
|
806
|
+
runtime: authClientApi(baseUrl).runtime,
|
|
658
807
|
fields: { password: TextField },
|
|
659
808
|
mode: { validation: "onSubmit" },
|
|
660
809
|
onSubmit: (_, { decoded }) => authHttpClient(baseUrl).pipe(Effect.flatMap((client) => client.auth.twoFactorEnable({
|
|
@@ -677,6 +826,7 @@ function EnableTotpForm({ baseUrl, requirePassword, onEnabled, }) {
|
|
|
677
826
|
function VerifyTotpSetup({ baseUrl, setup, onVerified, }) {
|
|
678
827
|
const m = useUserButtonMessages();
|
|
679
828
|
const [form] = useState(() => FormReact.make(totpCodeFormBuilder, {
|
|
829
|
+
runtime: authClientApi(baseUrl).runtime,
|
|
680
830
|
fields: { code: TextField },
|
|
681
831
|
mode: { validation: "onSubmit" },
|
|
682
832
|
onSubmit: (_, { decoded }) => authHttpClient(baseUrl).pipe(Effect.flatMap((client) => client.auth.twoFactorVerifyTotp({
|
|
@@ -696,6 +846,7 @@ function VerifyTotpSetup({ baseUrl, setup, onVerified, }) {
|
|
|
696
846
|
function DisableTotpForm({ baseUrl, requirePassword, onDisabled, }) {
|
|
697
847
|
const m = useUserButtonMessages();
|
|
698
848
|
const [form] = useState(() => FormReact.make(passwordFormBuilder(requirePassword), {
|
|
849
|
+
runtime: authClientApi(baseUrl).runtime,
|
|
699
850
|
fields: { password: TextField },
|
|
700
851
|
mode: { validation: "onSubmit" },
|
|
701
852
|
onSubmit: (_, { decoded }) => authHttpClient(baseUrl).pipe(Effect.flatMap((client) => client.auth.twoFactorDisable({
|
|
@@ -743,6 +894,7 @@ function ApiKeyManager({ baseUrl, active, permissionLabels, permissions = {}, })
|
|
|
743
894
|
permissionOptionsRef.current = permissionOptions;
|
|
744
895
|
selectedPermissionsRef.current = selectedPermissions;
|
|
745
896
|
const [createForm] = useState(() => FormReact.make(apiKeyFormBuilder, {
|
|
897
|
+
runtime: authClientApi(baseUrl).runtime,
|
|
746
898
|
fields: { name: TextField, referrers: TextAreaField },
|
|
747
899
|
mode: { validation: "onSubmit" },
|
|
748
900
|
onSubmit: (_, { decoded }) => Effect.gen(function* () {
|
|
@@ -775,7 +927,7 @@ function ApiKeyManager({ baseUrl, active, permissionLabels, permissions = {}, })
|
|
|
775
927
|
const togglePermission = (id, checked) => {
|
|
776
928
|
setSelectedPermissions((current) => ({ ...current, [id]: checked }));
|
|
777
929
|
};
|
|
778
|
-
const [deleteKeyAction] = useState(() =>
|
|
930
|
+
const [deleteKeyAction] = useState(() => authClientApi(baseUrl).runtime.fn((key) => authHttpClient(baseUrl).pipe(Effect.flatMap((client) => client.auth.apiKeyDelete({
|
|
779
931
|
payload: { configId: "user", keyId: key.id },
|
|
780
932
|
})), Effect.tap(() => Effect.sync(refreshKeys)), Effect.catch((cause) => Effect.sync(() => setError(cause instanceof Error && cause.message
|
|
781
933
|
? cause.message
|
|
@@ -807,7 +959,7 @@ function ApiKeyManager({ baseUrl, active, permissionLabels, permissions = {}, })
|
|
|
807
959
|
}, children: [_jsx(createForm.name, { label: m.user_api_key_name(), required: true }), _jsx(createForm.referrers, { label: m.user_api_key_referrers(), description: m.user_api_key_referrers_description(), placeholder: m.user_api_key_referrers_placeholder(), rows: 3 }), _jsx(ApiKeyPermissions, { description: m.user_api_key_permissions_description(), idPrefix: "user-create", permissions: permissions, labels: permissionLabels, selected: selectedPermissions, title: m.user_api_key_permissions(), onChange: togglePermission }), _jsx(SubmitError, { result: createSubmitResult }), _jsx(SubmitButton, { form: createForm })] }) }) })) : null, creating && createdKey ? (_jsx("div", { className: "flex min-w-0 flex-col gap-3", children: _jsxs("div", { className: "bg-muted/50 flex min-w-0 items-center justify-between gap-3 rounded-md border px-3 py-2", children: [_jsx("code", { className: "block min-w-0 flex-1 overflow-x-auto text-sm whitespace-nowrap", children: createdKey }), _jsx(CopyButton, { className: "shrink-0", messages: {
|
|
808
960
|
copied: m.user_api_key_copied(),
|
|
809
961
|
copy: m.user_api_key_copy(),
|
|
810
|
-
}, value: createdKey, variant: "ghost" })] }) })) : null, !creating && !editingKey && keysError ? (_jsx("p", { className: "text-destructive text-sm", children: keysError })) : null, !creating && !editingKey && error ? (_jsx("p", { className: "text-destructive text-sm", children: error })) : null, !creating && !editingKey ? (_jsx("div", { className: "max-w-full min-w-0 overflow-x-hidden", children: _jsx(DataTable, {
|
|
962
|
+
}, value: createdKey, variant: "ghost" })] }) })) : null, !creating && !editingKey && keysError ? (_jsx("p", { className: "text-destructive text-sm", children: keysError })) : null, !creating && !editingKey && error ? (_jsx("p", { className: "text-destructive text-sm", children: error })) : null, !creating && !editingKey ? (_jsx("div", { className: "max-w-full min-w-0 overflow-x-hidden", children: _jsx(DataTable, { columnDefs: apiKeyColumns({ m }), rowData: keys, features: {
|
|
811
963
|
export: { baseName: m.user_api_keys_export_file_name() },
|
|
812
964
|
gallery: false,
|
|
813
965
|
rowActions: {
|
|
@@ -817,7 +969,7 @@ function ApiKeyManager({ baseUrl, active, permissionLabels, permissions = {}, })
|
|
|
817
969
|
onEdit: (key) => setEditingKey(key),
|
|
818
970
|
}),
|
|
819
971
|
},
|
|
820
|
-
},
|
|
972
|
+
}, status: {
|
|
821
973
|
empty: loading ? m.user_loading() : m.table_empty(),
|
|
822
974
|
loading,
|
|
823
975
|
} }) })) : null, editingKey ? (_jsx(ApiKeyEditForm, { baseUrl: baseUrl, configId: "user", keyData: editingKey, permissions: permissions, permissionLabels: permissionLabels, messages: {
|
|
@@ -837,28 +989,26 @@ function ApiKeyManager({ baseUrl, active, permissionLabels, permissions = {}, })
|
|
|
837
989
|
}
|
|
838
990
|
const apiKeyColumns = ({ m, }) => [
|
|
839
991
|
{
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
992
|
+
field: "name",
|
|
993
|
+
headerName: m.user_api_key_name(),
|
|
994
|
+
cellRenderer: ({ data }) => (_jsx("div", { className: "min-w-0", children: _jsx("p", { className: "truncate font-medium", children: data.name ?? m.user_api_key_hidden() }) })),
|
|
843
995
|
},
|
|
844
996
|
{
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
? m.user_api_key_enabled()
|
|
849
|
-
: m.user_api_key_disabled() })),
|
|
997
|
+
field: "enabled",
|
|
998
|
+
headerName: m.user_api_key_status(),
|
|
999
|
+
cellRenderer: ({ data }) => (_jsx(Badge, { variant: data.enabled ? "default" : "secondary", children: data.enabled ? m.user_api_key_enabled() : m.user_api_key_disabled() })),
|
|
850
1000
|
},
|
|
851
1001
|
{
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
1002
|
+
colId: "referrers",
|
|
1003
|
+
valueGetter: ({ data }) => data.metadata,
|
|
1004
|
+
headerName: m.user_api_key_referrers_column(),
|
|
1005
|
+
cellRenderer: ({ data }) => (_jsx(ApiKeyReferrers, { metadata: data.metadata, unrestrictedLabel: m.user_api_key_referrers_any() })),
|
|
856
1006
|
},
|
|
857
1007
|
{
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
1008
|
+
colId: "rateLimit",
|
|
1009
|
+
valueGetter: ({ data }) => apiKeyUsagePercent(data),
|
|
1010
|
+
headerName: m.user_api_key_rate_limit(),
|
|
1011
|
+
cellRenderer: ({ data }) => (_jsx(ApiKeyRateLimit, { keyData: data, messages: {
|
|
862
1012
|
disabled: m.user_api_key_disabled(),
|
|
863
1013
|
none: m.user_api_key_window_none(),
|
|
864
1014
|
unlimited: m.user_api_key_unlimited(),
|
|
@@ -870,10 +1020,10 @@ const apiKeyColumns = ({ m, }) => [
|
|
|
870
1020
|
} })),
|
|
871
1021
|
},
|
|
872
1022
|
{
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
const permissions = formatPermissions(
|
|
1023
|
+
field: "permissions",
|
|
1024
|
+
headerName: m.user_api_key_permissions(),
|
|
1025
|
+
cellRenderer: ({ data }) => {
|
|
1026
|
+
const permissions = formatPermissions(data.permissions);
|
|
877
1027
|
if (permissions.length === 0) {
|
|
878
1028
|
return (_jsx("span", { className: "text-muted-foreground text-sm", children: m.user_api_key_no_permissions() }));
|
|
879
1029
|
}
|
|
@@ -3,19 +3,19 @@ import { HttpApiEndpoint, HttpApiError, HttpApiGroup } from "effect/unstable/htt
|
|
|
3
3
|
import { ExtraBadRequest } from "./schema.js";
|
|
4
4
|
export * from "./schema.js";
|
|
5
5
|
export type { Organization, OrganizationMetadata } from "../schema.js";
|
|
6
|
-
export declare const ExtraApiGroup: HttpApiGroup.HttpApiGroup<"authExtra", HttpApiEndpoint.HttpApiEndpoint<"createApiKey", "POST", "/auth/create-api-key",
|
|
6
|
+
export declare const ExtraApiGroup: HttpApiGroup.HttpApiGroup<"authExtra", HttpApiEndpoint.HttpApiEndpoint<"createApiKey", "POST", "/auth/create-api-key", never, never, Schema.toCodecJson<Schema.Struct<{
|
|
7
7
|
readonly configId: Schema.Union<readonly [Schema.Literal<"user">, Schema.Literal<"organization">, Schema.Literal<"service">]>;
|
|
8
8
|
readonly name: Schema.optional<Schema.NonEmptyString>;
|
|
9
9
|
readonly organizationId: Schema.optional<Schema.String>;
|
|
10
10
|
readonly permissions: Schema.optional<Schema.$Record<Schema.String, Schema.$Array<Schema.String>>>;
|
|
11
11
|
readonly referrers: Schema.optional<Schema.$Array<Schema.String>>;
|
|
12
|
-
}>>,
|
|
12
|
+
}>>, never, Schema.toCodecJson<Schema.Struct<{
|
|
13
13
|
readonly id: Schema.String;
|
|
14
14
|
readonly key: Schema.String;
|
|
15
|
-
}>>,
|
|
15
|
+
}>>, Schema.toCodecJson<typeof HttpApiError.Unauthorized | typeof HttpApiError.Forbidden | typeof HttpApiError.InternalServerError | typeof ExtraBadRequest>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"getOrganizationPublicProfile", "GET", "/auth/organization-profile", never, Schema.toCodecStringTree<Schema.Struct<{
|
|
16
16
|
readonly organizationId: Schema.String;
|
|
17
17
|
readonly locale: Schema.optional<Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>>;
|
|
18
|
-
}>>,
|
|
18
|
+
}>>, never, never, Schema.toCodecJson<Schema.Struct<{
|
|
19
19
|
readonly id: Schema.String;
|
|
20
20
|
readonly name: Schema.String;
|
|
21
21
|
readonly slug: Schema.String;
|
|
@@ -65,12 +65,12 @@ export declare const ExtraApiGroup: HttpApiGroup.HttpApiGroup<"authExtra", HttpA
|
|
|
65
65
|
}>>>;
|
|
66
66
|
readonly logo: Schema.NullOr<Schema.String>;
|
|
67
67
|
readonly icon: Schema.NullOr<Schema.String>;
|
|
68
|
-
}>>,
|
|
68
|
+
}>>, Schema.toCodecJson<typeof HttpApiError.NotFound | typeof HttpApiError.InternalServerError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"getProjectPublicConfig", "GET", "/auth/project-config", never, Schema.toCodecStringTree<Schema.Struct<{
|
|
69
69
|
readonly projectId: Schema.optional<Schema.String>;
|
|
70
70
|
readonly clientId: Schema.optional<Schema.String>;
|
|
71
71
|
readonly host: Schema.optional<Schema.String>;
|
|
72
72
|
readonly rootHost: Schema.optional<Schema.String>;
|
|
73
|
-
}>>,
|
|
73
|
+
}>>, never, never, Schema.toCodecJson<Schema.Struct<{
|
|
74
74
|
readonly projectKey: Schema.String;
|
|
75
75
|
readonly name: Schema.NullOr<Schema.String>;
|
|
76
76
|
readonly logoUrl: Schema.NullOr<Schema.String>;
|
|
@@ -82,28 +82,28 @@ export declare const ExtraApiGroup: HttpApiGroup.HttpApiGroup<"authExtra", HttpA
|
|
|
82
82
|
readonly emailOtp: Schema.Boolean;
|
|
83
83
|
readonly google: Schema.Boolean;
|
|
84
84
|
}>;
|
|
85
|
-
}>>,
|
|
85
|
+
}>>, Schema.toCodecJson<typeof HttpApiError.InternalServerError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"setPassword", "POST", "/auth/set-password", never, never, Schema.toCodecJson<Schema.Struct<{
|
|
86
86
|
readonly newPassword: Schema.NonEmptyString;
|
|
87
|
-
}>>,
|
|
87
|
+
}>>, never, Schema.toCodecJson<Schema.Struct<{
|
|
88
88
|
readonly ok: Schema.Boolean;
|
|
89
|
-
}>>,
|
|
90
|
-
|
|
91
|
-
}>>,
|
|
89
|
+
}>>, Schema.toCodecJson<typeof HttpApiError.Unauthorized | typeof HttpApiError.Forbidden | typeof HttpApiError.InternalServerError | typeof ExtraBadRequest>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"updateApiKey", "PATCH", "/auth/api-key/:keyId", Schema.toCodecStringTree<Schema.Struct<{
|
|
90
|
+
keyId: Schema.NonEmptyString;
|
|
91
|
+
}>>, never, Schema.toCodecJson<Schema.Struct<{
|
|
92
92
|
readonly configId: Schema.Union<readonly [Schema.Literal<"user">, Schema.Literal<"organization">, Schema.Literal<"service">]>;
|
|
93
93
|
readonly name: Schema.NonEmptyString;
|
|
94
94
|
readonly enabled: Schema.Boolean;
|
|
95
95
|
readonly permissions: Schema.optional<Schema.$Record<Schema.String, Schema.$Array<Schema.String>>>;
|
|
96
96
|
readonly referrers: Schema.optional<Schema.$Array<Schema.String>>;
|
|
97
|
-
}>>,
|
|
97
|
+
}>>, never, Schema.toCodecJson<Schema.Struct<{
|
|
98
98
|
readonly ok: Schema.Boolean;
|
|
99
|
-
}>>,
|
|
99
|
+
}>>, Schema.toCodecJson<typeof HttpApiError.Unauthorized | typeof HttpApiError.Forbidden | typeof HttpApiError.InternalServerError | typeof ExtraBadRequest>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"uploadUserImage", "POST", "/auth/image/upload", never, never, Schema.toCodecJson<import("effect/unstable/httpapi/HttpApiSchema").asMultipartStream<Schema.Struct<{
|
|
100
100
|
readonly file: Schema.decodeTo<import("effect/unstable/http/Multipart").PersistedFileSchema, Schema.$Array<import("effect/unstable/http/Multipart").PersistedFileSchema>, never, never>;
|
|
101
|
-
}>>>,
|
|
101
|
+
}>>>, never, Schema.toCodecJson<Schema.Struct<{
|
|
102
102
|
readonly url: Schema.String;
|
|
103
|
-
}>>,
|
|
103
|
+
}>>, Schema.toCodecJson<typeof HttpApiError.Unauthorized | typeof HttpApiError.Forbidden | typeof HttpApiError.InternalServerError | typeof ExtraBadRequest>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"verifyApiKey", "POST", "/auth/verify-api-key", never, never, Schema.toCodecJson<Schema.Struct<{
|
|
104
104
|
readonly key: Schema.NonEmptyString;
|
|
105
105
|
readonly configId: Schema.optional<Schema.Union<readonly [Schema.Literal<"user">, Schema.Literal<"organization">, Schema.Literal<"service">]>>;
|
|
106
|
-
}>>,
|
|
106
|
+
}>>, never, Schema.toCodecJson<Schema.Struct<{
|
|
107
107
|
readonly valid: Schema.Boolean;
|
|
108
108
|
readonly error: Schema.NullOr<Schema.Struct<{
|
|
109
109
|
readonly message: Schema.String;
|
|
@@ -123,8 +123,8 @@ export declare const ExtraApiGroup: HttpApiGroup.HttpApiGroup<"authExtra", HttpA
|
|
|
123
123
|
readonly permissions: Schema.NullOr<Schema.$Record<Schema.String, Schema.$Array<Schema.String>>>;
|
|
124
124
|
readonly metadata: Schema.NullOr<Schema.Unknown>;
|
|
125
125
|
}>>;
|
|
126
|
-
}>>,
|
|
126
|
+
}>>, Schema.toCodecJson<typeof ExtraBadRequest>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"verifyPassword", "POST", "/auth/verify-password", never, never, Schema.toCodecJson<Schema.Struct<{
|
|
127
127
|
readonly password: Schema.NonEmptyString;
|
|
128
|
-
}>>,
|
|
128
|
+
}>>, never, Schema.toCodecJson<Schema.Struct<{
|
|
129
129
|
readonly ok: Schema.Boolean;
|
|
130
|
-
}>>,
|
|
130
|
+
}>>, Schema.toCodecJson<typeof HttpApiError.Unauthorized | typeof HttpApiError.Forbidden | typeof HttpApiError.InternalServerError | typeof ExtraBadRequest>, never, never>, false>;
|
package/dist/extra/api.group.js
CHANGED
|
@@ -5,7 +5,7 @@ import { ExtraBadRequest, ExtraCreateApiKeyPayload, ExtraCreateApiKeyResponse, E
|
|
|
5
5
|
export * from "./schema.js";
|
|
6
6
|
export const ExtraApiGroup = HttpApiGroup.make("authExtra")
|
|
7
7
|
.add(HttpApiEndpoint.get("getProjectPublicConfig", "/auth/project-config", {
|
|
8
|
-
query: ExtraProjectPublicConfigQuery,
|
|
8
|
+
query: ExtraProjectPublicConfigQuery.fields,
|
|
9
9
|
success: ExtraProjectPublicConfig,
|
|
10
10
|
error: [HttpApiError.InternalServerError],
|
|
11
11
|
}).annotateMerge(OpenApi.annotations({
|
|
@@ -14,7 +14,7 @@ export const ExtraApiGroup = HttpApiGroup.make("authExtra")
|
|
|
14
14
|
description: "Returns resolved public branding and authentication options through the proxied auth API.",
|
|
15
15
|
})))
|
|
16
16
|
.add(HttpApiEndpoint.patch("updateApiKey", "/auth/api-key/:keyId", {
|
|
17
|
-
params:
|
|
17
|
+
params: { keyId: Schema.NonEmptyString },
|
|
18
18
|
payload: Schema.Struct({
|
|
19
19
|
configId: ExtraUpdateApiKeyPayload.fields.configId,
|
|
20
20
|
name: ExtraUpdateApiKeyPayload.fields.name,
|
|
@@ -35,7 +35,7 @@ export const ExtraApiGroup = HttpApiGroup.make("authExtra")
|
|
|
35
35
|
description: "Updates API key details and server-only permissions after verifying user ownership or organization key-management access.",
|
|
36
36
|
})))
|
|
37
37
|
.add(HttpApiEndpoint.get("getOrganizationPublicProfile", "/auth/organization-profile", {
|
|
38
|
-
query: ExtraOrganizationPublicProfileQuery,
|
|
38
|
+
query: ExtraOrganizationPublicProfileQuery.fields,
|
|
39
39
|
success: ExtraOrganizationPublicProfile,
|
|
40
40
|
error: [HttpApiError.NotFound, HttpApiError.InternalServerError],
|
|
41
41
|
}).annotateMerge(OpenApi.annotations({
|
package/dist/extra/schema.d.ts
CHANGED
|
@@ -162,8 +162,7 @@ export declare const ExtraOkResponse: Schema.Struct<{
|
|
|
162
162
|
export declare const ExtraUploadedAsset: Schema.Struct<{
|
|
163
163
|
readonly url: Schema.String;
|
|
164
164
|
}>;
|
|
165
|
-
declare const ExtraBadRequest_base: Schema.Class<ExtraBadRequest, Schema.
|
|
166
|
-
readonly _tag: Schema.tag<"ExtraBadRequest">;
|
|
165
|
+
declare const ExtraBadRequest_base: Schema.Class<ExtraBadRequest, Schema.TaggedStruct<"ExtraBadRequest", {
|
|
167
166
|
readonly message: Schema.String;
|
|
168
167
|
}>, import("effect/Cause").YieldableError>;
|
|
169
168
|
export declare class ExtraBadRequest extends ExtraBadRequest_base {
|
package/dist/extra/schema.js
CHANGED
|
@@ -283,8 +283,7 @@ export const ExtraUploadedAsset = Schema.Struct({
|
|
|
283
283
|
},
|
|
284
284
|
],
|
|
285
285
|
});
|
|
286
|
-
export class ExtraBadRequest extends Schema.
|
|
287
|
-
_tag: Schema.tag("ExtraBadRequest"),
|
|
286
|
+
export class ExtraBadRequest extends Schema.TaggedError()("ExtraBadRequest", {
|
|
288
287
|
message: Schema.String,
|
|
289
288
|
}, {
|
|
290
289
|
identifier: "ExtraBadRequest",
|
package/dist/query.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Effect,
|
|
1
|
+
import { Effect, Schema, SchemaIssue, SchemaTransformation } from "effect";
|
|
2
2
|
const parseSortParam = (sort) => {
|
|
3
3
|
const id = sort.startsWith("-") ? sort.slice(1) : sort;
|
|
4
4
|
if (!id || id.includes(",") || id.includes(":")) {
|
|
@@ -28,9 +28,9 @@ export const SortParamFromString = Schema.String.pipe(Schema.decodeTo(SortParam,
|
|
|
28
28
|
decode: (sort) => {
|
|
29
29
|
const sortParam = parseSortParam(sort);
|
|
30
30
|
if (!sortParam) {
|
|
31
|
-
return Effect.fail(new SchemaIssue.InvalidValue(
|
|
31
|
+
return Effect.fail(new SchemaIssue.InvalidValue({
|
|
32
32
|
message: 'Expected sort in the format "field" or "-field"',
|
|
33
|
-
}));
|
|
33
|
+
}, sort));
|
|
34
34
|
}
|
|
35
35
|
return Effect.succeed(sortParam);
|
|
36
36
|
},
|
|
@@ -48,9 +48,9 @@ export const SortParamsFromString = Schema.String.pipe(Schema.decodeTo(Schema.Ar
|
|
|
48
48
|
for (const part of parts) {
|
|
49
49
|
const sortParam = parseSortParam(part);
|
|
50
50
|
if (!sortParam) {
|
|
51
|
-
return Effect.fail(new SchemaIssue.InvalidValue(
|
|
51
|
+
return Effect.fail(new SchemaIssue.InvalidValue({
|
|
52
52
|
message: 'Expected sort in the format "field,-otherField"',
|
|
53
|
-
}));
|
|
53
|
+
}, sort));
|
|
54
54
|
}
|
|
55
55
|
sortParams.push(sortParam);
|
|
56
56
|
}
|