@yimingliao/cms 0.0.89 → 0.0.92

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.
@@ -1,6 +1,6 @@
1
1
  import { clsx } from 'clsx';
2
2
  import { twMerge } from 'tailwind-merge';
3
- import { useState, useEffect } from 'react';
3
+ import { useState, useRef, useCallback, useEffect } from 'react';
4
4
  import { UAParser } from 'ua-parser-js';
5
5
  import { Slot } from '@radix-ui/react-slot';
6
6
  import { cva } from 'class-variance-authority';
@@ -12,6 +12,36 @@ import * as LabelPrimitive from '@radix-ui/react-label';
12
12
  var cn = (...inputs) => {
13
13
  return twMerge(clsx(inputs));
14
14
  };
15
+ var useCountdown = (initialTime) => {
16
+ const [timeLeft, setTimeLeft] = useState(initialTime);
17
+ const [isCounting, setIsCounting] = useState(false);
18
+ const intervalRef = useRef(null);
19
+ const startCountdown = useCallback(() => {
20
+ setTimeLeft(initialTime);
21
+ setIsCounting(true);
22
+ }, [initialTime]);
23
+ useEffect(() => {
24
+ if (!isCounting) return;
25
+ intervalRef.current = setInterval(() => {
26
+ setTimeLeft((prev) => {
27
+ if (prev <= 1) {
28
+ clearInterval(intervalRef.current);
29
+ intervalRef.current = null;
30
+ setIsCounting(false);
31
+ return 0;
32
+ }
33
+ return prev - 1;
34
+ });
35
+ }, 1e3);
36
+ return () => {
37
+ if (intervalRef.current) {
38
+ clearInterval(intervalRef.current);
39
+ intervalRef.current = null;
40
+ }
41
+ };
42
+ }, [isCounting]);
43
+ return { timeLeft, isCounting, startCountdown };
44
+ };
15
45
  function useDeviceInfo() {
16
46
  const [deviceInfo, setDeviceInfo] = useState(null);
17
47
  useEffect(() => {
@@ -355,4 +385,4 @@ function Label({ className, ...props }) {
355
385
  );
356
386
  }
357
387
 
358
- export { Button, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, Label, Spinner, Textarea, cn, useDeviceInfo };
388
+ export { Button, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, Label, Spinner, Textarea, cn, useCountdown, useDeviceInfo };
@@ -4,7 +4,7 @@ import * as _tanstack_react_query from '@tanstack/react-query';
4
4
  import { QueryClient, UseMutationOptions, UseQueryOptions } from '@tanstack/react-query';
5
5
  import * as _tanstack_query_core from '@tanstack/query-core';
6
6
  import * as react_jsx_runtime from 'react/jsx-runtime';
7
- import { c as createVerifyAction, a as createSignInAction } from '../create-verify-action-lojNGPwl.js';
7
+ import { c as createVerifyAction, a as createSignInAction, b as createVerifyEmailAction, d as createEmailUnverifiedAction, e as createForgotPasswordAction, f as createResetPasswordAction, g as createChangePasswordAction } from '../create-reset-password-action-D6aTuuqO.js';
8
8
  import * as React$1 from 'react';
9
9
  import { ComponentProps, ReactNode, HTMLAttributes } from 'react';
10
10
  import { L as LabelProps, B as ButtonProps$1 } from '../label-BF4qxS03.js';
@@ -392,8 +392,68 @@ declare function createSignInPage({ useCommand, signInAction, }: {
392
392
  signInAction: ReturnType<typeof createSignInAction>;
393
393
  }): () => react_jsx_runtime.JSX.Element;
394
394
 
395
+ /**
396
+ * [Auth] verify email
397
+ *
398
+ * http://localhost:3000/cms/verify-email
399
+ *
400
+ * src/app/cms/(auth)/verify-email/page.tsx
401
+ */
402
+ declare function createVerifyEmailPage({ useCommand, verifyEmailAction, }: {
403
+ useCommand: ReturnType<typeof createUseCommand>;
404
+ verifyEmailAction: ReturnType<typeof createVerifyEmailAction>;
405
+ }): () => react_jsx_runtime.JSX.Element;
406
+
407
+ /**
408
+ * [Auth] email unverified
409
+ *
410
+ * http://localhost:3000/cms/email-unverified
411
+ *
412
+ * src/app/cms/(auth)/email-unverified/page.tsx
413
+ */
414
+ declare function createEmailUnverifiedPage({ useCommand, emailUnverifiedAction, }: {
415
+ useCommand: ReturnType<typeof createUseCommand>;
416
+ emailUnverifiedAction: ReturnType<typeof createEmailUnverifiedAction>;
417
+ }): () => react_jsx_runtime.JSX.Element;
418
+
419
+ /**
420
+ * [Auth] forgot-password
421
+ *
422
+ * http://localhost:3000/cms/forgot-password
423
+ *
424
+ * src/app/cms/(auth)/forgot-password/page.tsx
425
+ */
426
+ declare function createForgotPasswordPage({ useCommand, forgotPasswordAction, }: {
427
+ useCommand: ReturnType<typeof createUseCommand>;
428
+ forgotPasswordAction: ReturnType<typeof createForgotPasswordAction>;
429
+ }): () => react_jsx_runtime.JSX.Element;
430
+
431
+ /**
432
+ * [Auth] reset-password
433
+ *
434
+ * http://localhost:3000/cms/reset-password
435
+ *
436
+ * src/app/cms/(auth)/reset-password/page.tsx
437
+ */
438
+ declare function createResetPasswordPage({ useCommand, resetPasswordAction, }: {
439
+ useCommand: ReturnType<typeof createUseCommand>;
440
+ resetPasswordAction: ReturnType<typeof createResetPasswordAction>;
441
+ }): () => react_jsx_runtime.JSX.Element;
442
+
443
+ /**
444
+ * [Auth] change-password
445
+ *
446
+ * http://localhost:3000/cms/dashboard/change-password
447
+ *
448
+ * src/app/cms/dashboard/(auth)/change-password/page.tsx
449
+ */
450
+ declare function createChangePasswordPage({ useCommand, changePasswordAction, }: {
451
+ useCommand: ReturnType<typeof createUseCommand>;
452
+ changePasswordAction: ReturnType<typeof createChangePasswordAction>;
453
+ }): () => react_jsx_runtime.JSX.Element;
454
+
395
455
  declare const cn: (...inputs: ClassValue[]) => string;
396
456
 
397
457
  declare function useDeviceInfo(): DeviceInfo | null;
398
458
 
399
- export { AdminProvider, Button, type ButtonProps, Field, FieldBody, Form, Input, type InputProps, PasswordInput, type ShowToastOption, cn, createAdminInitializer, createRequestInterceptor, createResponseInterceptor, createSignInPage, createSmartFetch, createUseCommand, createUseQuery, handleToast, useAdmin, useDeviceInfo };
459
+ export { AdminProvider, Button, type ButtonProps, Field, FieldBody, Form, Input, type InputProps, PasswordInput, type ShowToastOption, cn, createAdminInitializer, createChangePasswordPage, createEmailUnverifiedPage, createForgotPasswordPage, createRequestInterceptor, createResetPasswordPage, createResponseInterceptor, createSignInPage, createSmartFetch, createUseCommand, createUseQuery, createVerifyEmailPage, handleToast, useAdmin, useDeviceInfo };
@@ -1,14 +1,13 @@
1
- import { cn, Label, Spinner, Button, InputGroup, InputGroupAddon, InputGroupInput, InputGroupButton, useDeviceInfo, Card, CardHeader, CardTitle, CardContent } from '../chunk-OQGJBZXQ.js';
2
- export { cn, useDeviceInfo } from '../chunk-OQGJBZXQ.js';
1
+ import { cn, Label, Spinner, Button, InputGroup, InputGroupAddon, InputGroupInput, InputGroupButton, useDeviceInfo, Card, CardHeader, CardTitle, CardContent, useCountdown, CardDescription } from '../chunk-BVWT2DIB.js';
2
+ export { cn, useDeviceInfo } from '../chunk-BVWT2DIB.js';
3
3
  import { ensureArray } from '../chunk-OAENV763.js';
4
4
  import { toast } from 'sonner';
5
5
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
6
6
  import { useMutation, useQuery } from '@tanstack/react-query';
7
- import * as React from 'react';
8
- import { createContext, useState, useContext, useEffect } from 'react';
9
- import { Asterisk, Eye, EyeOff } from 'lucide-react';
7
+ import { createContext, useState, useContext, useEffect, createElement } from 'react';
8
+ import { Asterisk, Eye, EyeOff, Mail } from 'lucide-react';
10
9
  import { useTranslator } from 'intor/react';
11
- import { useRouter } from 'next/navigation';
10
+ import { useRouter, useSearchParams } from 'next/navigation';
12
11
  import Link from 'next/link';
13
12
 
14
13
  // src/client/infrastructure/fetch/smart-fetch.ts
@@ -266,7 +265,7 @@ function Field({
266
265
  /* @__PURE__ */ jsxs(Label, { className: "flex gap-1 truncate", ...props, children: [
267
266
  label,
268
267
  isRequired && /* @__PURE__ */ jsx(Asterisk, { className: "text-destructive size-3" }),
269
- hint && /* @__PURE__ */ jsx("span", { className: "ml-2 text-xs text-muted-foreground", children: hint })
268
+ hint && /* @__PURE__ */ jsx("span", { className: "text-muted-foreground ml-2 text-xs", children: hint })
270
269
  ] }),
271
270
  /* @__PURE__ */ jsx("span", { children: labelChildren })
272
271
  ] }),
@@ -356,7 +355,7 @@ function Button2({
356
355
  onClick: props.onClick ?? handleClick,
357
356
  ...props,
358
357
  children: isLoading ? /* @__PURE__ */ jsx(Spinner, {}) : /* @__PURE__ */ jsxs(Fragment, { children: [
359
- icon && React.createElement(icon),
358
+ icon && createElement(icon),
360
359
  children
361
360
  ] })
362
361
  }
@@ -406,29 +405,62 @@ function PasswordInput({ ...props }) {
406
405
 
407
406
  // src/constants/keys/auth.ts
408
407
  var AUTH_KEYS = {
408
+ signIn: { key: "sign-in" },
409
409
  forgotPassword: { key: "forgot-password" }};
410
410
 
411
+ // src/constants/keys/main.ts
412
+ var MAIN_KEYS = {
413
+ dashboard: { key: "dashboard" },
414
+ cmsSettings: { key: "cms-settings" }};
415
+
416
+ // src/constants/keys/resources.ts
417
+ var RESOURCES_KEYS = {
418
+ admin: { key: "admin" }};
419
+
411
420
  // src/constants/keys/index.ts
412
421
  var KEYS = {
413
- auth: AUTH_KEYS};
422
+ main: MAIN_KEYS,
423
+ auth: AUTH_KEYS,
424
+ resources: RESOURCES_KEYS};
414
425
 
415
426
  // src/constants/paths/cms-path.ts
416
427
  var CMS_PATH = "/cms";
417
428
 
429
+ // src/constants/paths/main.ts
430
+ var MAIN_PATHS = {
431
+ dashboard: {
432
+ path: `${CMS_PATH}/${KEYS.main.dashboard.key}`
433
+ },
434
+ cmsSettings: {
435
+ path: `${CMS_PATH}/${KEYS.main.dashboard.key}/${KEYS.main.cmsSettings.key}`
436
+ }};
437
+
418
438
  // src/constants/paths/auth.ts
419
439
  var AUTH_PATHS = {
440
+ signIn: {
441
+ path: `${CMS_PATH}/${KEYS.auth.signIn.key}`
442
+ },
420
443
  forgotPassword: {
421
444
  path: `${CMS_PATH}/${KEYS.auth.forgotPassword.key}`
422
445
  }};
423
446
 
447
+ // src/constants/paths/resources.ts
448
+ var RESOURCES_PATHS = {
449
+ admin: {
450
+ path: `${MAIN_PATHS.cmsSettings.path}/${KEYS.resources.admin.key}`
451
+ }};
452
+
424
453
  // src/constants/paths/index.ts
425
454
  var PATHS = {
426
- auth: AUTH_PATHS};
455
+ main: MAIN_PATHS,
456
+ auth: AUTH_PATHS,
457
+ resources: RESOURCES_PATHS
458
+ };
427
459
  function createSignInPage({
428
460
  useCommand,
429
461
  signInAction
430
462
  }) {
431
- return function CmsSignInPage() {
463
+ return function SignInPage() {
432
464
  const { t } = useTranslator();
433
465
  const { setAdmin } = useAdmin();
434
466
  const deviceInfo = useDeviceInfo();
@@ -487,5 +519,324 @@ function createSignInPage({
487
519
  ] }) });
488
520
  };
489
521
  }
522
+ function createVerifyEmailPage({
523
+ useCommand,
524
+ verifyEmailAction
525
+ }) {
526
+ return function VerifyEmailPage() {
527
+ const router = useRouter();
528
+ const searchParams = useSearchParams();
529
+ const email = searchParams.get("email") ?? "";
530
+ const emailVerificationToken = searchParams.get("emailVerificationToken") ?? "";
531
+ const { execute } = useCommand(
532
+ () => verifyEmailAction({ formData: { email, emailVerificationToken } }),
533
+ {
534
+ onSuccess: (data) => router.push(`${PATHS.resources.admin.path}/${data?.admin.id}`),
535
+ onError: () => router.push(PATHS.auth.signIn.path)
536
+ }
537
+ );
538
+ useEffect(() => {
539
+ void (async () => {
540
+ if (email && emailVerificationToken) {
541
+ await execute();
542
+ } else {
543
+ router.push(PATHS.auth.signIn.path);
544
+ }
545
+ })();
546
+ }, [email, emailVerificationToken]);
547
+ return /* @__PURE__ */ jsx("div", { className: "flex-center relative flex-1 flex-col", children: /* @__PURE__ */ jsx(Spinner, { className: "size-10" }) });
548
+ };
549
+ }
550
+ function createEmailUnverifiedPage({
551
+ useCommand,
552
+ emailUnverifiedAction
553
+ }) {
554
+ return function EmailUnverifiedPage() {
555
+ const { t } = useTranslator();
556
+ const router = useRouter();
557
+ const { admin, isLoading } = useAdmin();
558
+ const { timeLeft, isCounting, startCountdown } = useCountdown(30);
559
+ useEffect(() => {
560
+ if (!admin && !isLoading) {
561
+ router.replace(PATHS.auth.signIn.path);
562
+ }
563
+ if (admin?.emailVerifiedAt) {
564
+ router.replace(PATHS.main.dashboard.path);
565
+ }
566
+ }, [admin, isLoading, router]);
567
+ const { execute, isPending } = useCommand(
568
+ () => emailUnverifiedAction({ formData: { email: admin?.email ?? "" } }),
569
+ { onSuccess: () => startCountdown() }
570
+ );
571
+ const buttonText = !isCounting ? t("auth.email-unverified.button.send-email.text") : /* @__PURE__ */ jsxs("span", { children: [
572
+ t("auth.email-unverified.button.please-wait.text"),
573
+ /* @__PURE__ */ jsx("span", { className: "ml-1 inline-block w-5 text-end", children: timeLeft }),
574
+ "\xA0",
575
+ t("auth.email-unverified.button.second.text"),
576
+ "\xA0",
577
+ t("auth.email-unverified.button.send-again.text")
578
+ ] });
579
+ return /* @__PURE__ */ jsx(Form, { className: "mx-auto mt-20 w-96", onSubmit: () => void execute(), children: /* @__PURE__ */ jsxs(Card, { children: [
580
+ /* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, { className: "mx-auto", children: t("auth.email-unverified.text") }) }),
581
+ /* @__PURE__ */ jsxs(CardContent, { className: "relative flex flex-col gap-6", children: [
582
+ /* @__PURE__ */ jsxs(InputGroup, { children: [
583
+ /* @__PURE__ */ jsx(InputGroupAddon, { children: /* @__PURE__ */ jsx(Label, { htmlFor: "email", className: "text-foreground", children: /* @__PURE__ */ jsx(Mail, { className: "size-4" }) }) }),
584
+ isLoading ? /* @__PURE__ */ jsx("div", { className: "px-2", children: /* @__PURE__ */ jsx(Spinner, {}) }) : /* @__PURE__ */ jsx(
585
+ InputGroupInput,
586
+ {
587
+ id: "email",
588
+ placeholder: "shadcn@vercel.com",
589
+ disabled: true,
590
+ value: admin?.email
591
+ }
592
+ )
593
+ ] }),
594
+ /* @__PURE__ */ jsx(CardDescription, { children: /* @__PURE__ */ jsx("p", { className: "text-sm whitespace-pre-line", children: t("auth.email-unverified.notice.text") }) }),
595
+ /* @__PURE__ */ jsx(
596
+ Button2,
597
+ {
598
+ type: "submit",
599
+ isLoading: isLoading || isPending,
600
+ isDisabled: isCounting,
601
+ children: buttonText
602
+ }
603
+ )
604
+ ] })
605
+ ] }) });
606
+ };
607
+ }
608
+ function createForgotPasswordPage({
609
+ useCommand,
610
+ forgotPasswordAction
611
+ }) {
612
+ return function ForgotPasswordPage() {
613
+ const { t } = useTranslator();
614
+ const { timeLeft, isCounting, startCountdown } = useCountdown(30);
615
+ const [formData, setFormData] = useState({
616
+ email: ""
617
+ });
618
+ const { execute, isPending, errors } = useCommand(
619
+ () => forgotPasswordAction({ formData: { email: formData.email } }),
620
+ { onSuccess: () => startCountdown() }
621
+ );
622
+ const buttonText = !isCounting ? t("auth.forgot-password.button.send-email.text") : /* @__PURE__ */ jsxs("span", { children: [
623
+ t("auth.forgot-password.button.please-wait.text"),
624
+ /* @__PURE__ */ jsx("span", { className: "ml-1 inline-block w-5 text-end", children: timeLeft }),
625
+ "\xA0",
626
+ t("auth.forgot-password.button.second.text"),
627
+ "\xA0",
628
+ t("auth.forgot-password.button.send-again.text")
629
+ ] });
630
+ return /* @__PURE__ */ jsx(Form, { className: "mx-auto mt-20 w-96", onSubmit: () => void execute(), children: /* @__PURE__ */ jsxs(Card, { children: [
631
+ /* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, { className: "mx-auto", children: t("auth.forgot-password.text") }) }),
632
+ /* @__PURE__ */ jsxs(CardContent, { className: "relative flex flex-col gap-6", children: [
633
+ /* @__PURE__ */ jsx(Field, { htmlFor: "email", label: t("auth.forgot-password.email.text"), children: /* @__PURE__ */ jsx(
634
+ Input,
635
+ {
636
+ id: "email",
637
+ placeholder: t("auth.forgot-password.email.placeholder.text"),
638
+ autoComplete: "email",
639
+ fieldName: "email",
640
+ value: formData.email,
641
+ setFormData,
642
+ isDisabled: isPending || isCounting,
643
+ isError: errors.includes("email")
644
+ }
645
+ ) }),
646
+ /* @__PURE__ */ jsx(
647
+ Button2,
648
+ {
649
+ size: "xs",
650
+ variant: "link",
651
+ className: "w-fit",
652
+ isDisabled: isPending,
653
+ children: /* @__PURE__ */ jsx(Link, { href: PATHS.auth.signIn.path, children: t("auth.forgot-password.anchor.text") })
654
+ }
655
+ ),
656
+ /* @__PURE__ */ jsx(Button2, { type: "submit", isLoading: isPending, isDisabled: isCounting, children: buttonText })
657
+ ] })
658
+ ] }) });
659
+ };
660
+ }
661
+ function createResetPasswordPage({
662
+ useCommand,
663
+ resetPasswordAction
664
+ }) {
665
+ return function ResetPasswordPage() {
666
+ const { t } = useTranslator();
667
+ const router = useRouter();
668
+ const passwordResetToken = useSearchParams().get("passwordResetToken") ?? "";
669
+ const [formData, setFormData] = useState({
670
+ newPassword: "",
671
+ newPasswordConfirm: ""
672
+ });
673
+ const { execute, isRedirecting, errors } = useCommand(
674
+ () => resetPasswordAction({ formData: { passwordResetToken, ...formData } }),
675
+ { onSuccess: () => router.push(PATHS.auth.signIn.path) }
676
+ );
677
+ return /* @__PURE__ */ jsx(Form, { className: "mx-auto mt-20 w-96", onSubmit: () => void execute(), children: /* @__PURE__ */ jsxs(Card, { children: [
678
+ /* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, { className: "mx-auto", children: t("auth.reset-password.text") }) }),
679
+ /* @__PURE__ */ jsxs(CardContent, { className: "relative flex flex-col gap-6", children: [
680
+ /* @__PURE__ */ jsx(
681
+ Field,
682
+ {
683
+ htmlFor: "newPassword",
684
+ label: t("auth.reset-password.new-password.text"),
685
+ children: /* @__PURE__ */ jsx(
686
+ PasswordInput,
687
+ {
688
+ id: "newPassword",
689
+ placeholder: t(
690
+ "auth.reset-password.new-password.placeholder.text"
691
+ ),
692
+ fieldName: "newPassword",
693
+ value: formData.newPassword,
694
+ setFormData,
695
+ isDisabled: isRedirecting,
696
+ isError: errors.includes("newPassword")
697
+ }
698
+ )
699
+ }
700
+ ),
701
+ /* @__PURE__ */ jsx(
702
+ Field,
703
+ {
704
+ htmlFor: "newPasswordConfirm",
705
+ label: t("auth.reset-password.new-password-confirm.text"),
706
+ children: /* @__PURE__ */ jsx(
707
+ PasswordInput,
708
+ {
709
+ id: "newPasswordConfirm",
710
+ placeholder: t(
711
+ `auth.reset-password.new-password-confirm.placeholder.text`
712
+ ),
713
+ fieldName: "newPasswordConfirm",
714
+ value: formData.newPasswordConfirm,
715
+ setFormData,
716
+ isDisabled: isRedirecting,
717
+ isError: errors.includes("newPasswordConfirm")
718
+ }
719
+ )
720
+ }
721
+ ),
722
+ /* @__PURE__ */ jsx(
723
+ Button2,
724
+ {
725
+ size: "xs",
726
+ variant: "link",
727
+ className: "w-fit",
728
+ isDisabled: isRedirecting,
729
+ children: /* @__PURE__ */ jsx(Link, { href: PATHS.auth.signIn.path, children: t("auth.reset-password.anchor.text") })
730
+ }
731
+ ),
732
+ /* @__PURE__ */ jsx(Button2, { type: "submit", isLoading: isRedirecting, children: t("auth.reset-password.button.text") })
733
+ ] })
734
+ ] }) });
735
+ };
736
+ }
737
+ function createChangePasswordPage({
738
+ useCommand,
739
+ changePasswordAction
740
+ }) {
741
+ return function ChangePasswordPage() {
742
+ const { t } = useTranslator();
743
+ const router = useRouter();
744
+ const [formData, setFormData] = useState({
745
+ password: "",
746
+ newPassword: "",
747
+ newPasswordConfirm: ""
748
+ });
749
+ const { execute, isRedirecting, errors } = useCommand(
750
+ () => changePasswordAction({
751
+ formData: {
752
+ password: formData.password,
753
+ newPassword: formData.newPassword,
754
+ newPasswordConfirm: formData.newPasswordConfirm
755
+ }
756
+ }),
757
+ { onSuccess: () => router.push(PATHS.main.dashboard.path) }
758
+ );
759
+ return /* @__PURE__ */ jsx(Form, { className: "mx-auto mt-20 w-96", onSubmit: () => void execute(), children: /* @__PURE__ */ jsxs(Card, { children: [
760
+ /* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, { className: "mx-auto", children: t("auth.change-password.text") }) }),
761
+ /* @__PURE__ */ jsxs(CardContent, { className: "relative flex flex-col gap-6", children: [
762
+ /* @__PURE__ */ jsx(
763
+ Field,
764
+ {
765
+ htmlFor: "password",
766
+ label: t("auth.change-password.password.text"),
767
+ children: /* @__PURE__ */ jsx(
768
+ PasswordInput,
769
+ {
770
+ id: "password",
771
+ placeholder: t(
772
+ "auth.change-password.password.placeholder.text"
773
+ ),
774
+ fieldName: "password",
775
+ value: formData.password,
776
+ setFormData,
777
+ isDisabled: isRedirecting,
778
+ isError: errors.includes("password")
779
+ }
780
+ )
781
+ }
782
+ ),
783
+ /* @__PURE__ */ jsx(
784
+ Field,
785
+ {
786
+ htmlFor: "newPassword",
787
+ label: t("auth.change-password.new-password.text"),
788
+ children: /* @__PURE__ */ jsx(
789
+ PasswordInput,
790
+ {
791
+ id: "newPassword",
792
+ placeholder: t(
793
+ "auth.change-password.new-password.placeholder.text"
794
+ ),
795
+ fieldName: "newPassword",
796
+ value: formData.newPassword,
797
+ setFormData,
798
+ isDisabled: isRedirecting,
799
+ isError: errors.includes("newPassword")
800
+ }
801
+ )
802
+ }
803
+ ),
804
+ /* @__PURE__ */ jsx(
805
+ Field,
806
+ {
807
+ htmlFor: "newPasswordConfirm",
808
+ label: t("auth.change-password.new-password-confirm.text"),
809
+ children: /* @__PURE__ */ jsx(
810
+ PasswordInput,
811
+ {
812
+ id: "newPasswordConfirm",
813
+ placeholder: t(
814
+ "auth.change-password.new-password-confirm.placeholder.text"
815
+ ),
816
+ fieldName: "newPasswordConfirm",
817
+ value: formData.newPasswordConfirm,
818
+ setFormData,
819
+ isDisabled: isRedirecting,
820
+ isError: errors.includes("newPasswordConfirm")
821
+ }
822
+ )
823
+ }
824
+ ),
825
+ /* @__PURE__ */ jsx(
826
+ Button2,
827
+ {
828
+ size: "xs",
829
+ variant: "link",
830
+ className: "w-fit",
831
+ isDisabled: isRedirecting,
832
+ children: /* @__PURE__ */ jsx(Link, { href: PATHS.main.dashboard.path, children: t("auth.change-password.anchor.text") })
833
+ }
834
+ ),
835
+ /* @__PURE__ */ jsx(Button2, { type: "submit", isLoading: isRedirecting, children: t("auth.change-password.button.text") }),
836
+ " "
837
+ ] })
838
+ ] }) });
839
+ };
840
+ }
490
841
 
491
- export { AdminProvider, Button2 as Button, Field, FieldBody, Form, Input, PasswordInput, createAdminInitializer, createRequestInterceptor, createResponseInterceptor, createSignInPage, createSmartFetch, createUseCommand, createUseQuery, handleToast, useAdmin };
842
+ export { AdminProvider, Button2 as Button, Field, FieldBody, Form, Input, PasswordInput, createAdminInitializer, createChangePasswordPage, createEmailUnverifiedPage, createForgotPasswordPage, createRequestInterceptor, createResetPasswordPage, createResponseInterceptor, createSignInPage, createSmartFetch, createUseCommand, createUseQuery, createVerifyEmailPage, handleToast, useAdmin };
@@ -1 +1 @@
1
- export { Button, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, Label, Spinner, Textarea } from '../../chunk-OQGJBZXQ.js';
1
+ export { Button, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, Label, Spinner, Textarea } from '../../chunk-BVWT2DIB.js';
@@ -856,10 +856,10 @@ interface ActionContext {
856
856
  };
857
857
  }
858
858
 
859
- declare const signInValidator: (schemas: ReturnType<typeof createSchemas>) => zod.ZodObject<{
860
- email: zod.ZodEmail;
861
- password: zod.ZodString;
862
- }, zod_v4_core.$strip>;
859
+ declare const signInValidator: (schemas: ReturnType<typeof createSchemas>) => zod__default.ZodObject<{
860
+ email: zod__default.ZodEmail;
861
+ password: zod__default.ZodString;
862
+ }, zod__default.core.$strip>;
863
863
 
864
864
  type SignInFormData = zod__default.infer<ReturnType<typeof signInValidator>>;
865
865
  declare function createSignInAction(ctx: ActionContext): ({ formData, deviceInfo, }: {
@@ -873,4 +873,56 @@ declare function createVerifyAction(ctx: ActionContext): () => Promise<Result<{
873
873
  admin: AdminFull;
874
874
  }>>;
875
875
 
876
- export { type ActionContext as A, createPostQueryRepository as B, createRenderEmailTemplate as C, createSendEmail as D, createSeoMetadataCommandRepository as E, createUnique as F, createVerifyAccessToken as G, createVerifyRefreshToken as H, normalizeCacheKey as I, type RawCacheKey as R, type SignInFormData as S, createSignInAction as a, createZod as b, createVerifyAction as c, createSchemas as d, createTocItemSchema as e, createAdminCommandRepository as f, createAdminQueryRepository as g, createAdminRefreshTokenCommandRepository as h, createAdminRefreshTokenQueryRepository as i, createArgon2Service as j, createAuthMiddleware as k, createAuthUseCases as l, createCacheResult as m, createCookieService as n, createCryptoService as o, createEmailVerificationEmail as p, createExecuteAction as q, createExist as r, createFileCommandRepository as s, createFileQueryRepository as t, createFolderCommandRepository as u, createFolderQueryRepository as v, createForgotPasswordEmail as w, createIpRateLimiter as x, createJwtService as y, createPostCommandRepository as z };
876
+ declare const changePasswordValidator: (schemas: ReturnType<typeof createSchemas>) => zod.ZodObject<{
877
+ password: zod.ZodString;
878
+ newPassword: zod.ZodString;
879
+ newPasswordConfirm: zod.ZodString;
880
+ }, zod_v4_core.$strip>;
881
+
882
+ type ChangePasswordFormData = zod__default.infer<ReturnType<typeof changePasswordValidator>>;
883
+ declare function createChangePasswordAction(ctx: ActionContext): ({ formData, }: {
884
+ formData: ChangePasswordFormData;
885
+ }) => Promise<Result<void>>;
886
+
887
+ declare const verifyEmailValidator: (schemas: ReturnType<typeof createSchemas>) => zod.ZodObject<{
888
+ email: zod.ZodEmail;
889
+ emailVerificationToken: zod.ZodString;
890
+ }, zod_v4_core.$strip>;
891
+
892
+ type VerifyEmailFormData = zod__default.infer<ReturnType<typeof verifyEmailValidator>>;
893
+ declare function createVerifyEmailAction(ctx: ActionContext): ({ formData, }: {
894
+ formData: VerifyEmailFormData;
895
+ }) => Promise<Result<{
896
+ admin: AdminSafe;
897
+ }>>;
898
+
899
+ declare const emailUnverifiedValidator: (schemas: ReturnType<typeof createSchemas>) => zod.ZodObject<{
900
+ email: zod.ZodEmail;
901
+ }, zod_v4_core.$strip>;
902
+
903
+ type EmailUnverifiedFormData = zod__default.infer<ReturnType<typeof emailUnverifiedValidator>>;
904
+ declare function createEmailUnverifiedAction(ctx: ActionContext): ({ formData, }: {
905
+ formData: EmailUnverifiedFormData;
906
+ }) => Promise<Result<void>>;
907
+
908
+ declare const forgetPasswordValidator: (schemas: ReturnType<typeof createSchemas>) => zod.ZodObject<{
909
+ email: zod.ZodEmail;
910
+ }, zod_v4_core.$strip>;
911
+
912
+ type ForgotPasswordFormData = zod__default.infer<ReturnType<typeof forgetPasswordValidator>>;
913
+ declare function createForgotPasswordAction(ctx: ActionContext): ({ formData, }: {
914
+ formData: ForgotPasswordFormData;
915
+ }) => Promise<Result<void>>;
916
+
917
+ declare const resetPasswordValidator: (schemas: ReturnType<typeof createSchemas>) => zod.ZodObject<{
918
+ passwordResetToken: zod.ZodString;
919
+ newPassword: zod.ZodString;
920
+ newPasswordConfirm: zod.ZodString;
921
+ }, zod_v4_core.$strip>;
922
+
923
+ type ResetPasswordFormData = zod__default.infer<ReturnType<typeof resetPasswordValidator>>;
924
+ declare function createResetPasswordAction(ctx: ActionContext): ({ formData, }: {
925
+ formData: ResetPasswordFormData;
926
+ }) => Promise<Result<void>>;
927
+
928
+ export { type ActionContext as A, createFolderQueryRepository as B, createForgotPasswordEmail as C, createIpRateLimiter as D, createJwtService as E, createPostCommandRepository as F, createPostQueryRepository as G, createRenderEmailTemplate as H, createSendEmail as I, createSeoMetadataCommandRepository as J, createUnique as K, createVerifyAccessToken as L, createVerifyRefreshToken as M, normalizeCacheKey as N, type RawCacheKey as R, createSignInAction as a, createVerifyEmailAction as b, createVerifyAction as c, createEmailUnverifiedAction as d, createForgotPasswordAction as e, createResetPasswordAction as f, createChangePasswordAction as g, createZod as h, createSchemas as i, createTocItemSchema as j, createAdminCommandRepository as k, createAdminQueryRepository as l, createAdminRefreshTokenCommandRepository as m, createAdminRefreshTokenQueryRepository as n, createArgon2Service as o, createAuthMiddleware as p, createAuthUseCases as q, createCacheResult as r, createCookieService as s, createCryptoService as t, createEmailVerificationEmail as u, createExecuteAction as v, createExist as w, createFileCommandRepository as x, createFileQueryRepository as y, createFolderCommandRepository as z };
@@ -1,5 +1,5 @@
1
- import { b as createZod, A as ActionContext, d as createSchemas, e as createTocItemSchema } from '../create-verify-action-lojNGPwl.js';
2
- export { R as RawCacheKey, S as SignInFormData, f as createAdminCommandRepository, g as createAdminQueryRepository, h as createAdminRefreshTokenCommandRepository, i as createAdminRefreshTokenQueryRepository, j as createArgon2Service, k as createAuthMiddleware, l as createAuthUseCases, m as createCacheResult, n as createCookieService, o as createCryptoService, p as createEmailVerificationEmail, q as createExecuteAction, r as createExist, s as createFileCommandRepository, t as createFileQueryRepository, u as createFolderCommandRepository, v as createFolderQueryRepository, w as createForgotPasswordEmail, x as createIpRateLimiter, y as createJwtService, z as createPostCommandRepository, B as createPostQueryRepository, C as createRenderEmailTemplate, D as createSendEmail, E as createSeoMetadataCommandRepository, a as createSignInAction, F as createUnique, G as createVerifyAccessToken, c as createVerifyAction, H as createVerifyRefreshToken, I as normalizeCacheKey } from '../create-verify-action-lojNGPwl.js';
1
+ import { h as createZod, A as ActionContext, i as createSchemas, j as createTocItemSchema } from '../create-reset-password-action-D6aTuuqO.js';
2
+ export { R as RawCacheKey, k as createAdminCommandRepository, l as createAdminQueryRepository, m as createAdminRefreshTokenCommandRepository, n as createAdminRefreshTokenQueryRepository, o as createArgon2Service, p as createAuthMiddleware, q as createAuthUseCases, r as createCacheResult, g as createChangePasswordAction, s as createCookieService, t as createCryptoService, d as createEmailUnverifiedAction, u as createEmailVerificationEmail, v as createExecuteAction, w as createExist, x as createFileCommandRepository, y as createFileQueryRepository, z as createFolderCommandRepository, B as createFolderQueryRepository, e as createForgotPasswordAction, C as createForgotPasswordEmail, D as createIpRateLimiter, E as createJwtService, F as createPostCommandRepository, G as createPostQueryRepository, H as createRenderEmailTemplate, f as createResetPasswordAction, I as createSendEmail, J as createSeoMetadataCommandRepository, a as createSignInAction, K as createUnique, L as createVerifyAccessToken, c as createVerifyAction, b as createVerifyEmailAction, M as createVerifyRefreshToken, N as normalizeCacheKey } from '../create-reset-password-action-D6aTuuqO.js';
3
3
  import Keyv from 'keyv';
4
4
  import * as zod from 'zod';
5
5
  import zod__default from 'zod';
@@ -9,7 +9,7 @@ import nodemailer from 'nodemailer';
9
9
  import { BaseTranslator, LocaleMessages } from 'intor';
10
10
  import { Logger } from 'logry';
11
11
  import { NextResponse } from 'next/server';
12
- import { R as Result, j as AdminSafe, e as Admin, g as AdminFull, h as AdminRefreshToken, a as Folder, b as FileFull, p as File$1, r as FileType, F as FolderFull, T as TocItem, f as AdminCard, u as PostListCard, c as FileCard, t as Post, w as PostType, v as PostTranslation, P as PostFull } from '../types-BGsFazJr.js';
12
+ import { R as Result, e as Admin, g as AdminFull, h as AdminRefreshToken, a as Folder, b as FileFull, p as File$1, r as FileType, F as FolderFull, T as TocItem, f as AdminCard, u as PostListCard, c as FileCard, t as Post, w as PostType, v as PostTranslation, P as PostFull } from '../types-BGsFazJr.js';
13
13
  import * as zod_v4_core from 'zod/v4/core';
14
14
  import '../types-J25u1G6t.js';
15
15
  import 'jsonwebtoken';
@@ -82,58 +82,6 @@ declare function createExecuteApi({ initI18n, logger }: CreateExecuteApiParams):
82
82
 
83
83
  declare function createSignOutAction(ctx: ActionContext): () => Promise<Result<void>>;
84
84
 
85
- declare const changePasswordValidator: (schemas: ReturnType<typeof createSchemas>) => zod.ZodObject<{
86
- password: zod.ZodString;
87
- newPassword: zod.ZodString;
88
- newPasswordConfirm: zod.ZodString;
89
- }, zod_v4_core.$strip>;
90
-
91
- type ChangePasswordFormData = zod__default.infer<ReturnType<typeof changePasswordValidator>>;
92
- declare function createChangePasswordAction(ctx: ActionContext): ({ formData, }: {
93
- formData: ChangePasswordFormData;
94
- }) => Promise<Result<void>>;
95
-
96
- declare const verifyEmailValidator: (schemas: ReturnType<typeof createSchemas>) => zod.ZodObject<{
97
- email: zod.ZodEmail;
98
- emailVerificationToken: zod.ZodString;
99
- }, zod_v4_core.$strip>;
100
-
101
- type VerifyEmailFormData = zod__default.infer<ReturnType<typeof verifyEmailValidator>>;
102
- declare function createVerifyEmailAction(ctx: ActionContext): ({ formData, }: {
103
- formData: VerifyEmailFormData;
104
- }) => Promise<Result<{
105
- admin: AdminSafe;
106
- }>>;
107
-
108
- declare const emailUnverifiedValidator: (schemas: ReturnType<typeof createSchemas>) => zod.ZodObject<{
109
- email: zod.ZodEmail;
110
- }, zod_v4_core.$strip>;
111
-
112
- type EmailUnverifiedFormData = zod__default.infer<ReturnType<typeof emailUnverifiedValidator>>;
113
- declare function createEmailUnverifiedAction(ctx: ActionContext): ({ formData, }: {
114
- formData: EmailUnverifiedFormData;
115
- }) => Promise<Result<void>>;
116
-
117
- declare const forgetPasswordValidator: (schemas: ReturnType<typeof createSchemas>) => zod.ZodObject<{
118
- email: zod.ZodEmail;
119
- }, zod_v4_core.$strip>;
120
-
121
- type ForgotPasswordFormData = zod__default.infer<ReturnType<typeof forgetPasswordValidator>>;
122
- declare function createForgotPasswordAction(ctx: ActionContext): ({ formData, }: {
123
- formData: ForgotPasswordFormData;
124
- }) => Promise<Result<void>>;
125
-
126
- declare const resetPasswordValidator: (schemas: ReturnType<typeof createSchemas>) => zod.ZodObject<{
127
- passwordResetToken: zod.ZodString;
128
- newPassword: zod.ZodString;
129
- newPasswordConfirm: zod.ZodString;
130
- }, zod_v4_core.$strip>;
131
-
132
- type ResetPasswordFormData = zod__default.infer<ReturnType<typeof resetPasswordValidator>>;
133
- declare function createResetPasswordAction(ctx: ActionContext): ({ formData, }: {
134
- formData: ResetPasswordFormData;
135
- }) => Promise<Result<void>>;
136
-
137
85
  declare const adminCreateValidator: (schemas: ReturnType<typeof createSchemas>) => zod.ZodObject<{
138
86
  role: zod.ZodEnum<{
139
87
  SUPER_ADMIN: "SUPER_ADMIN";
@@ -1595,4 +1543,4 @@ declare class ServerError extends Error {
1595
1543
  static internalServerError(): ServerError;
1596
1544
  }
1597
1545
 
1598
- export { ADMIN_ORDER_BY, ActionContext, type AdminCreateFormData, type AdminUpdateFormData, type ChangePasswordFormData, type EmailUnverifiedFormData, type FileCreateFormData, type FileCreateManyFormData, type FileUpdateFormData, type FolderCreateFormData, type FolderUpdateFormData, type ForgotPasswordFormData, ORDER_BY, POST_ORDER_BY, type PostCreateFormData, type PostUpdateFormData, type ResetPasswordFormData, type SeoMetadataUpsertFormData, ServerError, type VerifyEmailFormData, createAdminCreateAction, createAdminDeleteAction, createAdminFindFullAction, createAdminFindListCardsAction, createAdminRefreshTokenDeleteAction, createAdminRefreshTokenFindManyAction, createAdminUpdateAction, createCache, createChangePasswordAction, createEmailUnverifiedAction, createExecuteApi, createFileCreateAction, createFileCreateManyAction, createFileFindFullAction, createFileFindListCardsAction, createFilePurgeManyAction, createFileRestoreManyAction, createFileSchema, createFileSoftDeleteAction, createFileSoftDeleteManyAction, createFileUpdateAction, createFolderCreateAction, createFolderDeleteAction, createFolderFindFullAction, createFolderFindListCardsAction, createFolderUpdateAction, createForgotPasswordAction, createMultiFileSchema, createPostCreateAction, createPostDeleteAction, createPostFindAction, createPostFindFullAction, createPostFindListCardsAction, createPostFindManyAction, createPostUpdateAction, createResetPasswordAction, createSchemas, createSeoMetadataUpsertAction, createSignOutAction, createTocItemSchema, createTransporter, createVerifyEmailAction, createZod };
1546
+ export { ADMIN_ORDER_BY, ActionContext, type AdminCreateFormData, type AdminUpdateFormData, type FileCreateFormData, type FileCreateManyFormData, type FileUpdateFormData, type FolderCreateFormData, type FolderUpdateFormData, ORDER_BY, POST_ORDER_BY, type PostCreateFormData, type PostUpdateFormData, type SeoMetadataUpsertFormData, ServerError, createAdminCreateAction, createAdminDeleteAction, createAdminFindFullAction, createAdminFindListCardsAction, createAdminRefreshTokenDeleteAction, createAdminRefreshTokenFindManyAction, createAdminUpdateAction, createCache, createExecuteApi, createFileCreateAction, createFileCreateManyAction, createFileFindFullAction, createFileFindListCardsAction, createFilePurgeManyAction, createFileRestoreManyAction, createFileSchema, createFileSoftDeleteAction, createFileSoftDeleteManyAction, createFileUpdateAction, createFolderCreateAction, createFolderDeleteAction, createFolderFindFullAction, createFolderFindListCardsAction, createFolderUpdateAction, createMultiFileSchema, createPostCreateAction, createPostDeleteAction, createPostFindAction, createPostFindFullAction, createPostFindListCardsAction, createPostFindManyAction, createPostUpdateAction, createSchemas, createSeoMetadataUpsertAction, createSignOutAction, createTocItemSchema, createTransporter, createZod };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yimingliao/cms",
3
- "version": "0.0.89",
3
+ "version": "0.0.92",
4
4
  "author": "Yiming Liao",
5
5
  "license": "MIT",
6
6
  "type": "module",