@yimingliao/cms 0.0.88 → 0.0.89

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.
@@ -4,23 +4,23 @@ 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 } from '../create-verify-action-DBwWOXPO.js';
7
+ import { c as createVerifyAction, a as createSignInAction } from '../create-verify-action-lojNGPwl.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';
11
11
  import { LucideIcon } from 'lucide-react';
12
12
  import { ClassValue } from 'clsx';
13
+ import 'zod';
14
+ import 'zod/v4/core';
13
15
  import '../types-J25u1G6t.js';
14
16
  import '../types-0oS1A2K5.js';
15
17
  import 'jsonwebtoken';
16
18
  import 'node:crypto';
17
19
  import 'next/headers';
18
20
  import '@prisma/client';
19
- import 'zod';
20
21
  import 'nodemailer';
21
22
  import 'intor';
22
23
  import 'keyv';
23
- import 'zod/v4/core';
24
24
  import 'class-variance-authority/types';
25
25
  import 'class-variance-authority';
26
26
  import '@radix-ui/react-label';
@@ -380,8 +380,20 @@ declare function Input<T>({ fieldName, setFormData, isLoading, isDisabled, isErr
380
380
 
381
381
  declare function PasswordInput<T>({ ...props }: InputProps<T>): react_jsx_runtime.JSX.Element;
382
382
 
383
+ /**
384
+ * [Auth] sign-in
385
+ *
386
+ * http://localhost:3000/cms/sign-in
387
+ *
388
+ * src/app/cms/(auth)/sign-in/page.tsx
389
+ */
390
+ declare function createSignInPage({ useCommand, signInAction, }: {
391
+ useCommand: ReturnType<typeof createUseCommand>;
392
+ signInAction: ReturnType<typeof createSignInAction>;
393
+ }): () => react_jsx_runtime.JSX.Element;
394
+
383
395
  declare const cn: (...inputs: ClassValue[]) => string;
384
396
 
385
397
  declare function useDeviceInfo(): DeviceInfo | null;
386
398
 
387
- export { AdminProvider, Button, type ButtonProps, Field, FieldBody, Form, Input, type InputProps, PasswordInput, type ShowToastOption, cn, createAdminInitializer, createRequestInterceptor, createResponseInterceptor, createSmartFetch, createUseCommand, createUseQuery, handleToast, useAdmin, useDeviceInfo };
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 };
@@ -1,4 +1,4 @@
1
- import { cn, Label, Spinner, Button, InputGroup, InputGroupAddon, InputGroupInput, InputGroupButton } from '../chunk-OQGJBZXQ.js';
1
+ import { cn, Label, Spinner, Button, InputGroup, InputGroupAddon, InputGroupInput, InputGroupButton, useDeviceInfo, Card, CardHeader, CardTitle, CardContent } from '../chunk-OQGJBZXQ.js';
2
2
  export { cn, useDeviceInfo } from '../chunk-OQGJBZXQ.js';
3
3
  import { ensureArray } from '../chunk-OAENV763.js';
4
4
  import { toast } from 'sonner';
@@ -9,6 +9,7 @@ import { createContext, useState, useContext, useEffect } from 'react';
9
9
  import { Asterisk, Eye, EyeOff } from 'lucide-react';
10
10
  import { useTranslator } from 'intor/react';
11
11
  import { useRouter } from 'next/navigation';
12
+ import Link from 'next/link';
12
13
 
13
14
  // src/client/infrastructure/fetch/smart-fetch.ts
14
15
  function createSmartFetch({
@@ -403,4 +404,88 @@ function PasswordInput({ ...props }) {
403
404
  ) }) });
404
405
  }
405
406
 
406
- export { AdminProvider, Button2 as Button, Field, FieldBody, Form, Input, PasswordInput, createAdminInitializer, createRequestInterceptor, createResponseInterceptor, createSmartFetch, createUseCommand, createUseQuery, handleToast, useAdmin };
407
+ // src/constants/keys/auth.ts
408
+ var AUTH_KEYS = {
409
+ forgotPassword: { key: "forgot-password" }};
410
+
411
+ // src/constants/keys/index.ts
412
+ var KEYS = {
413
+ auth: AUTH_KEYS};
414
+
415
+ // src/constants/paths/cms-path.ts
416
+ var CMS_PATH = "/cms";
417
+
418
+ // src/constants/paths/auth.ts
419
+ var AUTH_PATHS = {
420
+ forgotPassword: {
421
+ path: `${CMS_PATH}/${KEYS.auth.forgotPassword.key}`
422
+ }};
423
+
424
+ // src/constants/paths/index.ts
425
+ var PATHS = {
426
+ auth: AUTH_PATHS};
427
+ function createSignInPage({
428
+ useCommand,
429
+ signInAction
430
+ }) {
431
+ return function CmsSignInPage() {
432
+ const { t } = useTranslator();
433
+ const { setAdmin } = useAdmin();
434
+ const deviceInfo = useDeviceInfo();
435
+ const [formData, setFormData] = useState({
436
+ email: "",
437
+ password: ""
438
+ });
439
+ const { execute, isRedirecting, errors } = useCommand(
440
+ () => signInAction({
441
+ formData,
442
+ deviceInfo: deviceInfo ?? {}
443
+ }),
444
+ { onSuccess: (data) => setAdmin(data?.admin || null) }
445
+ );
446
+ return /* @__PURE__ */ jsx(Form, { className: "mx-auto mt-20 w-96", onSubmit: () => void execute(), children: /* @__PURE__ */ jsxs(Card, { children: [
447
+ /* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, { className: "mx-auto", children: t("auth.sign-in.text") }) }),
448
+ /* @__PURE__ */ jsxs(CardContent, { className: "relative flex flex-col gap-6", children: [
449
+ /* @__PURE__ */ jsx(Field, { htmlFor: "email", label: t("auth.sign-in.email.text"), children: /* @__PURE__ */ jsx(
450
+ Input,
451
+ {
452
+ id: "email",
453
+ type: "email",
454
+ placeholder: t("auth.sign-in.email.placeholder.text"),
455
+ autoComplete: "email",
456
+ fieldName: "email",
457
+ value: formData.email,
458
+ setFormData,
459
+ isDisabled: isRedirecting,
460
+ isError: errors.includes("email")
461
+ }
462
+ ) }),
463
+ /* @__PURE__ */ jsx(Field, { htmlFor: "password", label: t("auth.sign-in.password.text"), children: /* @__PURE__ */ jsx(
464
+ PasswordInput,
465
+ {
466
+ id: "password",
467
+ placeholder: t("auth.sign-in.password.placeholder.text"),
468
+ fieldName: "password",
469
+ value: formData.password,
470
+ setFormData,
471
+ isDisabled: isRedirecting,
472
+ isError: errors.includes("password")
473
+ }
474
+ ) }),
475
+ /* @__PURE__ */ jsx(
476
+ Button2,
477
+ {
478
+ size: "xs",
479
+ variant: "link",
480
+ className: "w-fit",
481
+ isDisabled: isRedirecting,
482
+ children: /* @__PURE__ */ jsx(Link, { href: PATHS.auth.forgotPassword.path, children: t("auth.sign-in.anchor.text") })
483
+ }
484
+ ),
485
+ /* @__PURE__ */ jsx(Button2, { type: "submit", isLoading: isRedirecting, children: t("auth.sign-in.button.text") })
486
+ ] })
487
+ ] }) });
488
+ };
489
+ }
490
+
491
+ export { AdminProvider, Button2 as Button, Field, FieldBody, Form, Input, PasswordInput, createAdminInitializer, createRequestInterceptor, createResponseInterceptor, createSignInPage, createSmartFetch, createUseCommand, createUseQuery, handleToast, useAdmin };
@@ -1,15 +1,16 @@
1
1
  import { T as TocItem, i as AdminRole, y as SingleItem, B as BaseTranslation, e as Admin, g as AdminFull, j as AdminSafe, D as DeviceInfo, h as AdminRefreshToken, p as File, b as FileFull, r as FileType, a as Folder, F as FolderFull, M as MultiItems, m as ExternalLink, o as Faq, t as Post, w as PostType, u as PostListCard, v as PostTranslation, P as PostFull, l as Alternate, S as SuccessResult, R as Result } from './types-BGsFazJr.js';
2
+ import * as zod from 'zod';
3
+ import zod__default, { z, ZodType } from 'zod';
4
+ import * as zod_v4_core from 'zod/v4/core';
2
5
  import { S as StorageService } from './types-J25u1G6t.js';
3
6
  import jwt from 'jsonwebtoken';
4
7
  import { BinaryLike } from 'node:crypto';
5
8
  import { cookies } from 'next/headers';
6
9
  import { PrismaClient } from '@prisma/client';
7
- import zod__default, { z, ZodType } from 'zod';
8
10
  import { Transporter, SentMessageInfo } from 'nodemailer';
9
11
  import { Logger } from 'logry';
10
12
  import { BaseTranslator, LocaleMessages } from 'intor';
11
13
  import Keyv from 'keyv';
12
- import * as zod_v4_core from 'zod/v4/core';
13
14
 
14
15
  interface CreateJwtServiceParams {
15
16
  defaultSecret: string;
@@ -855,8 +856,21 @@ interface ActionContext {
855
856
  };
856
857
  }
857
858
 
859
+ declare const signInValidator: (schemas: ReturnType<typeof createSchemas>) => zod.ZodObject<{
860
+ email: zod.ZodEmail;
861
+ password: zod.ZodString;
862
+ }, zod_v4_core.$strip>;
863
+
864
+ type SignInFormData = zod__default.infer<ReturnType<typeof signInValidator>>;
865
+ declare function createSignInAction(ctx: ActionContext): ({ formData, deviceInfo, }: {
866
+ formData: SignInFormData;
867
+ deviceInfo: DeviceInfo;
868
+ }) => Promise<Result<{
869
+ admin: AdminFull;
870
+ }>>;
871
+
858
872
  declare function createVerifyAction(ctx: ActionContext): () => Promise<Result<{
859
873
  admin: AdminFull;
860
874
  }>>;
861
875
 
862
- export { type ActionContext as A, createRenderEmailTemplate as B, createSendEmail as C, createSeoMetadataCommandRepository as D, createUnique as E, createVerifyAccessToken as F, createVerifyRefreshToken as G, normalizeCacheKey as H, type RawCacheKey as R, createZod as a, createSchemas as b, createVerifyAction as c, createTocItemSchema as d, createAdminCommandRepository as e, createAdminQueryRepository as f, createAdminRefreshTokenCommandRepository as g, createAdminRefreshTokenQueryRepository as h, createArgon2Service as i, createAuthMiddleware as j, createAuthUseCases as k, createCacheResult as l, createCookieService as m, createCryptoService as n, createEmailVerificationEmail as o, createExecuteAction as p, createExist as q, createFileCommandRepository as r, createFileQueryRepository as s, createFolderCommandRepository as t, createFolderQueryRepository as u, createForgotPasswordEmail as v, createIpRateLimiter as w, createJwtService as x, createPostCommandRepository as y, createPostQueryRepository as z };
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 };
@@ -1,5 +1,5 @@
1
- import { a as createZod, b as createSchemas, A as ActionContext, d as createTocItemSchema } from '../create-verify-action-DBwWOXPO.js';
2
- export { R as RawCacheKey, e as createAdminCommandRepository, f as createAdminQueryRepository, g as createAdminRefreshTokenCommandRepository, h as createAdminRefreshTokenQueryRepository, i as createArgon2Service, j as createAuthMiddleware, k as createAuthUseCases, l as createCacheResult, m as createCookieService, n as createCryptoService, o as createEmailVerificationEmail, p as createExecuteAction, q as createExist, r as createFileCommandRepository, s as createFileQueryRepository, t as createFolderCommandRepository, u as createFolderQueryRepository, v as createForgotPasswordEmail, w as createIpRateLimiter, x as createJwtService, y as createPostCommandRepository, z as createPostQueryRepository, B as createRenderEmailTemplate, C as createSendEmail, D as createSeoMetadataCommandRepository, E as createUnique, F as createVerifyAccessToken, c as createVerifyAction, G as createVerifyRefreshToken, H as normalizeCacheKey } from '../create-verify-action-DBwWOXPO.js';
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';
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 { D as DeviceInfo, R as Result, g as AdminFull, j as AdminSafe, e as Admin, 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, 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';
13
13
  import * as zod_v4_core from 'zod/v4/core';
14
14
  import '../types-J25u1G6t.js';
15
15
  import 'jsonwebtoken';
@@ -80,19 +80,6 @@ interface CreateExecuteApiParams {
80
80
  }
81
81
  declare function createExecuteApi({ initI18n, logger }: CreateExecuteApiParams): (fn: Api) => Promise<NextResponse<unknown>>;
82
82
 
83
- declare const signInValidator: (schemas: ReturnType<typeof createSchemas>) => zod.ZodObject<{
84
- email: zod.ZodEmail;
85
- password: zod.ZodString;
86
- }, zod_v4_core.$strip>;
87
-
88
- type SignInFormData = zod__default.infer<ReturnType<typeof signInValidator>>;
89
- declare function createSignInAction(ctx: ActionContext): ({ formData, deviceInfo, }: {
90
- formData: SignInFormData;
91
- deviceInfo: DeviceInfo;
92
- }) => Promise<Result<{
93
- admin: AdminFull;
94
- }>>;
95
-
96
83
  declare function createSignOutAction(ctx: ActionContext): () => Promise<Result<void>>;
97
84
 
98
85
  declare const changePasswordValidator: (schemas: ReturnType<typeof createSchemas>) => zod.ZodObject<{
@@ -1608,4 +1595,4 @@ declare class ServerError extends Error {
1608
1595
  static internalServerError(): ServerError;
1609
1596
  }
1610
1597
 
1611
- 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 SignInFormData, 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, createSignInAction, createSignOutAction, createTocItemSchema, createTransporter, createVerifyEmailAction, createZod };
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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yimingliao/cms",
3
- "version": "0.0.88",
3
+ "version": "0.0.89",
4
4
  "author": "Yiming Liao",
5
5
  "license": "MIT",
6
6
  "type": "module",