@qlover/create-app 0.10.1 → 0.10.3
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/CHANGELOG.md +178 -0
- package/dist/configs/_common/.github/workflows/general-check.yml +1 -1
- package/dist/configs/_common/.github/workflows/release.yml +2 -2
- package/dist/index.cjs +4 -4
- package/dist/index.js +4 -4
- package/dist/templates/next-app/config/IOCIdentifier.ts +2 -2
- package/dist/templates/next-app/config/Identifier/common/common.ts +14 -0
- package/dist/templates/next-app/config/Identifier/pages/index.ts +1 -0
- package/dist/templates/next-app/config/Identifier/pages/page.about.ts +20 -0
- package/dist/templates/next-app/config/common.ts +1 -1
- package/dist/templates/next-app/config/cookies.ts +23 -0
- package/dist/templates/next-app/config/i18n/AboutI18n.ts +14 -0
- package/dist/templates/next-app/config/i18n/i18nConfig.ts +3 -1
- package/dist/templates/next-app/config/i18n/index.ts +1 -0
- package/dist/templates/next-app/config/i18n/loginI18n.ts +8 -0
- package/dist/templates/next-app/config/theme.ts +4 -0
- package/dist/templates/next-app/eslint.config.mjs +9 -2
- package/dist/templates/next-app/next.config.ts +1 -0
- package/dist/templates/next-app/package.json +17 -6
- package/dist/templates/next-app/public/locales/en.json +5 -0
- package/dist/templates/next-app/public/locales/zh.json +5 -0
- package/dist/templates/next-app/src/app/[locale]/admin/AdminI18nProvider.tsx +37 -0
- package/dist/templates/next-app/src/app/[locale]/admin/layout.tsx +30 -6
- package/dist/templates/next-app/src/app/[locale]/admin/locales/page.tsx +1 -1
- package/dist/templates/next-app/src/app/[locale]/layout.tsx +47 -10
- package/dist/templates/next-app/src/app/[locale]/login/LoginForm.tsx +1 -1
- package/dist/templates/next-app/src/app/[locale]/login/page.tsx +22 -10
- package/dist/templates/next-app/src/app/[locale]/page.tsx +23 -8
- package/dist/templates/next-app/src/app/[locale]/register/page.tsx +21 -9
- package/dist/templates/next-app/src/app/api/admin/locales/create/route.ts +7 -28
- package/dist/templates/next-app/src/app/api/admin/locales/import/route.ts +7 -34
- package/dist/templates/next-app/src/app/api/admin/locales/route.ts +12 -34
- package/dist/templates/next-app/src/app/api/admin/locales/update/route.ts +7 -26
- package/dist/templates/next-app/src/app/api/admin/users/route.ts +14 -33
- package/dist/templates/next-app/src/app/api/locales/json/route.ts +13 -25
- package/dist/templates/next-app/src/app/api/user/login/route.ts +6 -46
- package/dist/templates/next-app/src/app/api/user/logout/route.ts +5 -24
- package/dist/templates/next-app/src/app/api/user/register/route.ts +6 -45
- package/dist/templates/next-app/src/app/manifest.ts +16 -0
- package/dist/templates/next-app/src/app/robots.txt +2 -0
- package/dist/templates/next-app/src/base/cases/AdminPageManager.ts +3 -3
- package/dist/templates/next-app/src/base/cases/AppConfig.ts +14 -13
- package/dist/templates/next-app/src/base/cases/Datetime.ts +3 -3
- package/dist/templates/next-app/src/base/cases/DialogErrorPlugin.ts +8 -2
- package/dist/templates/next-app/src/base/cases/DialogHandler.ts +30 -4
- package/dist/templates/next-app/src/base/cases/InversifyContainer.ts +16 -4
- package/dist/templates/next-app/src/base/cases/NavigateBridge.ts +20 -4
- package/dist/templates/next-app/src/base/cases/RequestEncryptPlugin.ts +8 -2
- package/dist/templates/next-app/src/base/cases/ResourceState.ts +3 -3
- package/dist/templates/next-app/src/base/cases/RouterService.ts +28 -10
- package/dist/templates/next-app/src/base/cases/StringEncryptor.ts +14 -2
- package/dist/templates/next-app/src/base/cases/TranslateI18nInterface.ts +1 -1
- package/dist/templates/next-app/src/base/cases/UserServiceApi.ts +20 -5
- package/dist/templates/next-app/src/base/cases/ZodColumnBuilder.ts +31 -8
- package/dist/templates/next-app/src/base/port/AdminLayoutInterface.ts +4 -1
- package/dist/templates/next-app/src/base/port/AppApiInterface.ts +22 -0
- package/dist/templates/next-app/src/base/port/I18nServiceInterface.ts +27 -7
- package/dist/templates/next-app/src/base/port/IOCInterface.ts +9 -0
- package/dist/templates/next-app/src/base/services/AdminPageEvent.ts +1 -1
- package/dist/templates/next-app/src/base/services/AdminPageScheduler.ts +3 -3
- package/dist/templates/next-app/src/base/services/I18nService.ts +20 -10
- package/dist/templates/next-app/src/base/services/ResourceService.ts +32 -11
- package/dist/templates/next-app/src/base/services/UserService.ts +12 -3
- package/dist/templates/next-app/src/base/services/adminApi/AdminLocalesApi.ts +9 -6
- package/dist/templates/next-app/src/base/services/adminApi/AdminUserApi.ts +20 -5
- package/dist/templates/next-app/src/base/services/appApi/AppApiPlugin.ts +21 -4
- package/dist/templates/next-app/src/base/services/appApi/AppUserApi.ts +12 -3
- package/dist/templates/next-app/src/base/services/appApi/AppUserApiBootstrap.ts +10 -2
- package/dist/templates/next-app/src/base/types/{PageProps.ts → AppPageRouter.ts} +4 -1
- package/dist/templates/next-app/src/base/types/PagesRouter.ts +9 -0
- package/dist/templates/next-app/src/core/bootstraps/BootstrapClient.ts +20 -6
- package/dist/templates/next-app/src/core/bootstraps/BootstrapServer.ts +27 -9
- package/dist/templates/next-app/src/core/bootstraps/BootstrapsRegistry.ts +6 -4
- package/dist/templates/next-app/src/core/clientIoc/ClientIOC.ts +39 -9
- package/dist/templates/next-app/src/core/clientIoc/ClientIOCRegister.ts +9 -2
- package/dist/templates/next-app/src/core/serverIoc/ServerIOC.ts +37 -10
- package/dist/templates/next-app/src/core/serverIoc/ServerIOCRegister.ts +9 -2
- package/dist/templates/next-app/src/i18n/loadMessages.ts +103 -0
- package/dist/templates/next-app/src/i18n/request.ts +3 -22
- package/dist/templates/next-app/src/pages/[locale]/about.tsx +61 -0
- package/dist/templates/next-app/src/pages/_app.tsx +50 -0
- package/dist/templates/next-app/src/pages/_document.tsx +13 -0
- package/dist/templates/next-app/src/{middleware.ts → proxy.ts} +2 -1
- package/dist/templates/next-app/src/server/AppErrorApi.ts +1 -1
- package/dist/templates/next-app/src/server/AppPageRouteParams.ts +107 -0
- package/dist/templates/next-app/src/server/AppSuccessApi.ts +1 -1
- package/dist/templates/next-app/src/server/NextApiServer.ts +62 -0
- package/dist/templates/next-app/src/server/PagesRouteParams.ts +146 -0
- package/dist/templates/next-app/src/server/PasswordEncrypt.ts +8 -2
- package/dist/templates/next-app/src/server/ServerAuth.ts +20 -5
- package/dist/templates/next-app/src/server/{sqlBridges/SupabaseBridge.ts → SupabaseBridge.ts} +50 -8
- package/dist/templates/next-app/src/server/UserCredentialToken.ts +8 -2
- package/dist/templates/next-app/src/server/controllers/AdminLocalesController.ts +86 -0
- package/dist/templates/next-app/src/server/controllers/AdminUserController.ts +42 -0
- package/dist/templates/next-app/src/server/controllers/LocalesController.ts +36 -0
- package/dist/templates/next-app/src/server/controllers/UserController.ts +86 -0
- package/dist/templates/next-app/src/server/port/AIControllerInterface.ts +8 -0
- package/dist/templates/next-app/src/server/port/AdminLocalesControllerInterface.ts +21 -0
- package/dist/templates/next-app/src/server/port/AdminUserControllerInterface.ts +11 -0
- package/dist/templates/next-app/src/server/port/LocalesControllerInterface.ts +10 -0
- package/dist/templates/next-app/src/server/port/{ParamsHandlerInterface.ts → RouteParamsnHandlerInterface.ts} +9 -2
- package/dist/templates/next-app/src/server/port/ServerInterface.ts +2 -2
- package/dist/templates/next-app/src/server/port/UserControllerInerface.ts +8 -0
- package/dist/templates/next-app/src/server/port/UserServiceInterface.ts +1 -1
- package/dist/templates/next-app/src/server/port/ValidatorInterface.ts +2 -2
- package/dist/templates/next-app/src/server/repositorys/LocalesRepository.ts +31 -9
- package/dist/templates/next-app/src/server/repositorys/UserRepository.ts +15 -6
- package/dist/templates/next-app/src/server/services/AIService.ts +3 -1
- package/dist/templates/next-app/src/server/services/AdminAuthPlugin.ts +5 -2
- package/dist/templates/next-app/src/{base → server}/services/AdminLocalesService.ts +2 -2
- package/dist/templates/next-app/src/server/services/ApiLocaleService.ts +29 -14
- package/dist/templates/next-app/src/server/services/ApiUserService.ts +6 -3
- package/dist/templates/next-app/src/server/services/UserService.ts +12 -3
- package/dist/templates/next-app/src/server/validators/LocalesValidator.ts +24 -7
- package/dist/templates/next-app/src/server/validators/LoginValidator.ts +17 -5
- package/dist/templates/next-app/src/server/validators/PaginationValidator.ts +17 -11
- package/dist/templates/next-app/src/styles/css/antd-themes/_common/_default.css +0 -44
- package/dist/templates/next-app/src/styles/css/antd-themes/_common/dark.css +0 -44
- package/dist/templates/next-app/src/styles/css/antd-themes/_common/pink.css +0 -44
- package/dist/templates/next-app/src/styles/css/index.css +1 -1
- package/dist/templates/next-app/src/styles/css/scrollbar.css +34 -0
- package/dist/templates/next-app/src/uikit/components/AdminLayout.tsx +34 -11
- package/dist/templates/next-app/src/uikit/components/BootstrapsProvider.tsx +69 -39
- package/dist/templates/next-app/src/uikit/components/ClientRootProvider.tsx +64 -0
- package/dist/templates/next-app/src/uikit/components/ClinetRenderProvider.tsx +42 -0
- package/dist/templates/next-app/src/uikit/components/IOCProvider.tsx +34 -0
- package/dist/templates/next-app/src/uikit/components/localesImportButton/LocalesImportEvent.ts +7 -1
- package/dist/templates/next-app/src/uikit/components-app/AppBridge.tsx +17 -0
- package/dist/templates/next-app/src/uikit/components-app/AppRoutePage.tsx +112 -0
- package/dist/templates/next-app/src/uikit/{components → components-app}/LanguageSwitcher.tsx +15 -19
- package/dist/templates/next-app/src/uikit/{components → components-app}/ThemeSwitcher.tsx +53 -52
- package/dist/templates/next-app/src/uikit/components-pages/LanguageSwitcher.tsx +98 -0
- package/dist/templates/next-app/src/uikit/components-pages/PagesRoutePage.tsx +93 -0
- package/dist/templates/next-app/src/uikit/context/IOCContext.ts +16 -4
- package/dist/templates/next-app/src/uikit/hook/useStrictEffect.ts +32 -0
- package/dist/templates/next-app/tsconfig.json +3 -2
- package/dist/templates/react-app/__tests__/__mocks__/BootstrapTest.ts +3 -1
- package/dist/templates/react-app/__tests__/__mocks__/MockAppConfig.ts +19 -19
- package/dist/templates/react-app/__tests__/__mocks__/MockDialogHandler.ts +8 -8
- package/dist/templates/react-app/__tests__/__mocks__/MockLogger.ts +9 -9
- package/dist/templates/react-app/__tests__/__mocks__/components/TestBootstrapsProvider.tsx +1 -1
- package/dist/templates/react-app/__tests__/__mocks__/i18nextHttpBackend.ts +5 -5
- package/dist/templates/react-app/__tests__/__mocks__/testIOC/TestIOC.ts +9 -5
- package/dist/templates/react-app/__tests__/__mocks__/testIOC/TestIOCRegister.ts +8 -4
- package/dist/templates/react-app/__tests__/src/base/cases/I18nKeyErrorPlugin.test.ts +4 -4
- package/dist/templates/react-app/__tests__/src/base/cases/InversifyContainer.test.ts +5 -5
- package/dist/templates/react-app/__tests__/src/core/bootstraps/BootstrapClient.test.ts +3 -3
- package/dist/templates/react-app/__tests__/src/uikit/components/chatMessage/ChatRoot.test.tsx +1 -1
- package/dist/templates/react-app/docs/en/components/chat-message-component.md +35 -29
- package/dist/templates/react-app/docs/en/components/chat-message-refactor.md +18 -5
- package/dist/templates/react-app/docs/en/components/message-base-list-component.md +11 -12
- package/dist/templates/react-app/docs/en/request.md +1 -3
- package/dist/templates/react-app/docs/zh/components/chat-message-component.md +35 -29
- package/dist/templates/react-app/docs/zh/components/chat-message-refactor.md +18 -5
- package/dist/templates/react-app/docs/zh/components/message-base-list-component.md +11 -12
- package/dist/templates/react-app/docs/zh/request.md +1 -3
- package/dist/templates/react-app/eslint.config.mjs +10 -5
- package/dist/templates/react-app/src/App.tsx +1 -1
- package/dist/templates/react-app/src/base/apis/feApi/FeApi.ts +2 -2
- package/dist/templates/react-app/src/base/apis/feApi/FeApiBootstarp.ts +14 -11
- package/dist/templates/react-app/src/base/apis/userApi/UserApi.ts +10 -16
- package/dist/templates/react-app/src/base/apis/userApi/UserApiBootstarp.ts +12 -10
- package/dist/templates/react-app/src/base/cases/AppConfig.ts +19 -19
- package/dist/templates/react-app/src/base/cases/DialogHandler.ts +28 -5
- package/dist/templates/react-app/src/base/cases/I18nKeyErrorPlugin.ts +5 -2
- package/dist/templates/react-app/src/base/cases/InversifyContainer.ts +16 -4
- package/dist/templates/react-app/src/base/cases/PublicAssetsPath.ts +1 -1
- package/dist/templates/react-app/src/base/cases/RequestLanguages.ts +6 -3
- package/dist/templates/react-app/src/base/cases/RequestLogger.ts +17 -8
- package/dist/templates/react-app/src/base/cases/RequestStatusCatcher.ts +4 -6
- package/dist/templates/react-app/src/base/cases/ResourceState.ts +3 -3
- package/dist/templates/react-app/src/base/cases/RouterLoader.ts +3 -3
- package/dist/templates/react-app/src/base/cases/TranslateI18nInterface.ts +1 -1
- package/dist/templates/react-app/src/base/port/ExecutorPageBridgeInterface.ts +2 -2
- package/dist/templates/react-app/src/base/port/IOCInterface.ts +4 -2
- package/dist/templates/react-app/src/base/port/JSONStoragePageBridgeInterface.ts +5 -5
- package/dist/templates/react-app/src/base/port/RequestPageBridgeInterface.ts +7 -7
- package/dist/templates/react-app/src/base/port/RouteServiceInterface.ts +8 -8
- package/dist/templates/react-app/src/base/port/UserServiceInterface.ts +4 -2
- package/dist/templates/react-app/src/base/services/BaseLayoutService.ts +3 -3
- package/dist/templates/react-app/src/base/services/I18nService.ts +24 -13
- package/dist/templates/react-app/src/base/services/IdentifierService.ts +21 -26
- package/dist/templates/react-app/src/base/services/RouteService.ts +8 -8
- package/dist/templates/react-app/src/base/services/UserBootstrap.ts +2 -2
- package/dist/templates/react-app/src/base/services/UserGatewayPlugin.ts +9 -5
- package/dist/templates/react-app/src/base/services/UserService.ts +10 -4
- package/dist/templates/react-app/src/core/bootstraps/BootstrapClient.ts +3 -1
- package/dist/templates/react-app/src/core/bootstraps/BootstrapsRegistry.ts +5 -2
- package/dist/templates/react-app/src/core/clientIoc/ClientIOC.ts +11 -4
- package/dist/templates/react-app/src/core/clientIoc/ClientIOCRegister.ts +5 -4
- package/dist/templates/react-app/src/pages/base/Layout.tsx +1 -1
- package/dist/templates/react-app/src/styles/css/antd-themes/_common/_default.css +0 -44
- package/dist/templates/react-app/src/styles/css/antd-themes/_common/dark.css +0 -44
- package/dist/templates/react-app/src/styles/css/antd-themes/_common/pink.css +0 -44
- package/dist/templates/react-app/src/styles/css/index.css +1 -1
- package/dist/templates/react-app/src/styles/css/scrollbar.css +34 -0
- package/dist/templates/react-app/src/uikit/bridges/ExecutorPageBridge.ts +2 -2
- package/dist/templates/react-app/src/uikit/bridges/JSONStoragePageBridge.ts +4 -4
- package/dist/templates/react-app/src/uikit/bridges/NavigateBridge.ts +8 -2
- package/dist/templates/react-app/src/uikit/bridges/RequestPageBridge.ts +6 -6
- package/dist/templates/react-app/src/uikit/components/AppRouterProvider.tsx +1 -1
- package/dist/templates/react-app/src/uikit/components/BootstrapsProvider.tsx +1 -3
- package/dist/templates/react-app/src/uikit/components/MessageBaseList.tsx +4 -1
- package/dist/templates/react-app/src/uikit/components/chatMessage/ChatMessageBridge.ts +39 -16
- package/dist/templates/react-app/src/uikit/components/chatMessage/MessageApi.ts +4 -2
- package/package.json +3 -3
- package/dist/templates/next-app/src/server/PageParams.ts +0 -66
- package/dist/templates/next-app/src/uikit/components/BaseHeader.tsx +0 -80
- package/dist/templates/next-app/src/uikit/components/BaseLayout.tsx +0 -65
- package/dist/templates/next-app/src/uikit/components/ComboProvider.tsx +0 -58
- package/dist/templates/next-app/src/uikit/components/NextIntlProvider.tsx +0 -21
- package/dist/templates/react-app/makes/eslint-utils.mjs +0 -195
- /package/dist/templates/next-app/{src/app/[locale] → public}/favicon.ico +0 -0
- /package/dist/templates/next-app/src/uikit/{components → components-app}/LogoutButton.tsx +0 -0
|
@@ -1,34 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { BootstrapServer } from '@/core/bootstraps/BootstrapServer';
|
|
4
|
-
import { AppErrorApi } from '@/server/AppErrorApi';
|
|
5
|
-
import { AppSuccessApi } from '@/server/AppSuccessApi';
|
|
1
|
+
import { AdminLocalesController } from '@/server/controllers/AdminLocalesController';
|
|
2
|
+
import { NextApiServer } from '@/server/NextApiServer';
|
|
6
3
|
import { AdminAuthPlugin } from '@/server/services/AdminAuthPlugin';
|
|
7
|
-
import { ApiLocaleService } from '@/server/services/ApiLocaleService';
|
|
8
|
-
import { LocalesValidator } from '@/server/validators/LocalesValidator';
|
|
9
4
|
import type { NextRequest } from 'next/server';
|
|
10
5
|
|
|
11
6
|
export async function POST(req: NextRequest) {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
const result = await server
|
|
7
|
+
const requestBody = await req.json();
|
|
8
|
+
return await new NextApiServer()
|
|
15
9
|
.use(new AdminAuthPlugin())
|
|
16
|
-
.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const adminLocalesService = IOC(ApiLocaleService);
|
|
20
|
-
await adminLocalesService.create(localesParams);
|
|
21
|
-
return {
|
|
22
|
-
success: true
|
|
23
|
-
};
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
if (result instanceof ExecutorError) {
|
|
27
|
-
console.error(result);
|
|
28
|
-
return NextResponse.json(new AppErrorApi(result.id, result.message), {
|
|
29
|
-
status: 400
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return NextResponse.json(new AppSuccessApi(result));
|
|
10
|
+
.runWithJson(async ({ parameters: { IOC } }) =>
|
|
11
|
+
IOC(AdminLocalesController).createLocale(requestBody)
|
|
12
|
+
);
|
|
34
13
|
}
|
|
@@ -1,40 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { BootstrapServer } from '@/core/bootstraps/BootstrapServer';
|
|
4
|
-
import { AppErrorApi } from '@/server/AppErrorApi';
|
|
5
|
-
import { AppSuccessApi } from '@/server/AppSuccessApi';
|
|
1
|
+
import { AdminLocalesController } from '@/server/controllers/AdminLocalesController';
|
|
2
|
+
import { NextApiServer } from '@/server/NextApiServer';
|
|
6
3
|
import { AdminAuthPlugin } from '@/server/services/AdminAuthPlugin';
|
|
7
|
-
import { ApiLocaleService } from '@/server/services/ApiLocaleService';
|
|
8
|
-
import { LocalesImportValidator } from '@/server/validators/LocalesValidator';
|
|
9
4
|
import type { NextRequest } from 'next/server';
|
|
10
5
|
|
|
11
6
|
export async function POST(req: NextRequest) {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
const result = await server
|
|
7
|
+
const formData = await req.formData();
|
|
8
|
+
return await new NextApiServer()
|
|
15
9
|
.use(new AdminAuthPlugin())
|
|
16
|
-
.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const localesParams = await IOC(LocalesImportValidator).getThrow({
|
|
20
|
-
values: formData
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
const adminLocalesService = IOC(ApiLocaleService);
|
|
24
|
-
|
|
25
|
-
const result = await adminLocalesService.importLocales(localesParams);
|
|
26
|
-
return {
|
|
27
|
-
success: true,
|
|
28
|
-
data: result
|
|
29
|
-
};
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
if (result instanceof ExecutorError) {
|
|
33
|
-
console.error(result);
|
|
34
|
-
return NextResponse.json(new AppErrorApi(result.id, result.message), {
|
|
35
|
-
status: 400
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return NextResponse.json(new AppSuccessApi(result));
|
|
10
|
+
.runWithJson(async ({ parameters: { IOC } }) =>
|
|
11
|
+
IOC(AdminLocalesController).importLocales(formData)
|
|
12
|
+
);
|
|
40
13
|
}
|
|
@@ -1,42 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { AppErrorApi } from '@/server/AppErrorApi';
|
|
5
|
-
import { AppSuccessApi } from '@/server/AppSuccessApi';
|
|
1
|
+
import { AdminLocalesController } from '@/server/controllers/AdminLocalesController';
|
|
2
|
+
import { NextApiServer } from '@/server/NextApiServer';
|
|
3
|
+
import type { BridgeOrderBy } from '@/server/port/DBBridgeInterface';
|
|
6
4
|
import { AdminAuthPlugin } from '@/server/services/AdminAuthPlugin';
|
|
7
|
-
import { ApiLocaleService } from '@/server/services/ApiLocaleService';
|
|
8
|
-
import { PaginationValidator } from '@/server/validators/PaginationValidator';
|
|
9
5
|
import type { NextRequest } from 'next/server';
|
|
10
6
|
|
|
11
7
|
export async function GET(req: NextRequest) {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
const result = await server
|
|
8
|
+
const searchParams = Object.fromEntries(req.nextUrl.searchParams.entries());
|
|
9
|
+
return await new NextApiServer()
|
|
15
10
|
.use(new AdminAuthPlugin())
|
|
16
|
-
.
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
.runWithJson(async ({ parameters: { IOC } }) => {
|
|
12
|
+
return IOC(AdminLocalesController).getLocales(
|
|
13
|
+
searchParams as unknown as {
|
|
14
|
+
page: number;
|
|
15
|
+
pageSize: number;
|
|
16
|
+
orders?: BridgeOrderBy;
|
|
17
|
+
}
|
|
19
18
|
);
|
|
20
|
-
|
|
21
|
-
const paginationParams = IOC(PaginationValidator).getThrow(searchParams);
|
|
22
|
-
|
|
23
|
-
const apiUserService = IOC(ApiLocaleService);
|
|
24
|
-
|
|
25
|
-
const result = await apiUserService.getLocales({
|
|
26
|
-
page: paginationParams.page,
|
|
27
|
-
pageSize: paginationParams.pageSize,
|
|
28
|
-
orderBy: paginationParams.orders
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
return result;
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
if (result instanceof ExecutorError) {
|
|
35
|
-
console.error(result);
|
|
36
|
-
return NextResponse.json(new AppErrorApi(result.id, result.message), {
|
|
37
|
-
status: 400
|
|
38
19
|
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return NextResponse.json(new AppSuccessApi(result));
|
|
42
20
|
}
|
|
@@ -1,32 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { BootstrapServer } from '@/core/bootstraps/BootstrapServer';
|
|
4
|
-
import { AppErrorApi } from '@/server/AppErrorApi';
|
|
5
|
-
import { AppSuccessApi } from '@/server/AppSuccessApi';
|
|
1
|
+
import { AdminLocalesController } from '@/server/controllers/AdminLocalesController';
|
|
2
|
+
import { NextApiServer } from '@/server/NextApiServer';
|
|
6
3
|
import { AdminAuthPlugin } from '@/server/services/AdminAuthPlugin';
|
|
7
|
-
import { ApiLocaleService } from '@/server/services/ApiLocaleService';
|
|
8
4
|
import type { NextRequest } from 'next/server';
|
|
9
5
|
|
|
10
6
|
export async function POST(req: NextRequest) {
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
const result = await server
|
|
7
|
+
const requestBody = await req.json();
|
|
8
|
+
return await new NextApiServer()
|
|
14
9
|
.use(new AdminAuthPlugin())
|
|
15
|
-
.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
await adminLocalesService.update(requestBody);
|
|
19
|
-
return {
|
|
20
|
-
success: true
|
|
21
|
-
};
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
if (result instanceof ExecutorError) {
|
|
25
|
-
console.error(result);
|
|
26
|
-
return NextResponse.json(new AppErrorApi(result.id, result.message), {
|
|
27
|
-
status: 400
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return NextResponse.json(new AppSuccessApi(result));
|
|
10
|
+
.runWithJson(async ({ parameters: { IOC } }) =>
|
|
11
|
+
IOC(AdminLocalesController).updateLocale(requestBody)
|
|
12
|
+
);
|
|
32
13
|
}
|
|
@@ -1,39 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { AppErrorApi } from '@/server/AppErrorApi';
|
|
5
|
-
import { AppSuccessApi } from '@/server/AppSuccessApi';
|
|
1
|
+
import { AdminUserController } from '@/server/controllers/AdminUserController';
|
|
2
|
+
import { NextApiServer } from '@/server/NextApiServer';
|
|
3
|
+
import type { BridgeOrderBy } from '@/server/port/DBBridgeInterface';
|
|
6
4
|
import { AdminAuthPlugin } from '@/server/services/AdminAuthPlugin';
|
|
7
|
-
import { ApiUserService } from '@/server/services/ApiUserService';
|
|
8
|
-
import { PaginationValidator } from '@/server/validators/PaginationValidator';
|
|
9
5
|
import type { NextRequest } from 'next/server';
|
|
10
6
|
|
|
11
7
|
export async function GET(req: NextRequest) {
|
|
12
|
-
const
|
|
8
|
+
const searchParams = Object.fromEntries(req.nextUrl.searchParams.entries());
|
|
13
9
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const result = await apiUserService.getUsers({
|
|
25
|
-
page: paginationParams.page,
|
|
26
|
-
pageSize: paginationParams.pageSize
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
return result;
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
if (result instanceof ExecutorError) {
|
|
33
|
-
return NextResponse.json(new AppErrorApi(result.id, result.message), {
|
|
34
|
-
status: 400
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return NextResponse.json(new AppSuccessApi(result));
|
|
10
|
+
return await new NextApiServer().use(new AdminAuthPlugin()).runWithJson(
|
|
11
|
+
async ({ parameters: { IOC } }) =>
|
|
12
|
+
await IOC(AdminUserController).getUsers(
|
|
13
|
+
searchParams as unknown as {
|
|
14
|
+
page: number;
|
|
15
|
+
pageSize: number;
|
|
16
|
+
orderBy?: BridgeOrderBy;
|
|
17
|
+
}
|
|
18
|
+
)
|
|
19
|
+
);
|
|
39
20
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ExecutorError } from '@qlover/fe-corekit';
|
|
2
1
|
import { NextResponse, type NextRequest } from 'next/server';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { LocalesController } from '@/server/controllers/LocalesController';
|
|
3
|
+
import { NextApiServer } from '@/server/NextApiServer';
|
|
4
|
+
import type { LocalesControllerJsonQuery } from '@/server/port/LocalesControllerInterface';
|
|
6
5
|
import type { LocaleType } from '@config/i18n';
|
|
6
|
+
import { i18nConfig } from '@config/i18n';
|
|
7
7
|
|
|
8
8
|
// Use literal value instead of imported config to ensure static analysis
|
|
9
9
|
export const revalidate = 60; // Cache time in seconds (matches i18nConfig.localeCacheTime)
|
|
@@ -12,30 +12,18 @@ export async function GET(req: NextRequest) {
|
|
|
12
12
|
const searchParams = Object.fromEntries(req.nextUrl.searchParams.entries());
|
|
13
13
|
const locale = searchParams.locale as LocaleType;
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const result = await server.execNoError(async ({ parameters: { IOC } }) => {
|
|
22
|
-
const localesService = IOC(ApiLocaleService);
|
|
23
|
-
const result = await localesService.getLocalesJson(locale);
|
|
24
|
-
|
|
25
|
-
return result;
|
|
26
|
-
});
|
|
15
|
+
const result = await new NextApiServer().run(
|
|
16
|
+
async ({ parameters: { IOC } }) =>
|
|
17
|
+
IOC(LocalesController).json(
|
|
18
|
+
searchParams as unknown as LocalesControllerJsonQuery
|
|
19
|
+
)
|
|
20
|
+
);
|
|
27
21
|
|
|
28
|
-
if (result
|
|
29
|
-
|
|
30
|
-
return NextResponse.json(
|
|
31
|
-
{},
|
|
32
|
-
{
|
|
33
|
-
status: 400
|
|
34
|
-
}
|
|
35
|
-
);
|
|
22
|
+
if (!result.success) {
|
|
23
|
+
return NextResponse.json({});
|
|
36
24
|
}
|
|
37
25
|
|
|
38
|
-
const response = NextResponse.json(result);
|
|
26
|
+
const response = NextResponse.json(result.data);
|
|
39
27
|
response.headers.set(
|
|
40
28
|
'Cache-Control',
|
|
41
29
|
`s-maxage=${i18nConfig.localeCacheTime}`
|
|
@@ -1,50 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { StringEncryptor } from '@/base/cases/StringEncryptor';
|
|
4
|
-
import { BootstrapServer } from '@/core/bootstraps/BootstrapServer';
|
|
5
|
-
import { AppErrorApi } from '@/server/AppErrorApi';
|
|
6
|
-
import { AppSuccessApi } from '@/server/AppSuccessApi';
|
|
7
|
-
import type { UserServiceInterface } from '@/server/port/UserServiceInterface';
|
|
8
|
-
import { ServerAuth } from '@/server/ServerAuth';
|
|
9
|
-
import { UserService } from '@/server/services/UserService';
|
|
10
|
-
import { LoginValidator } from '@/server/validators/LoginValidator';
|
|
11
|
-
import type { UserSchema } from '@migrations/schema/UserSchema';
|
|
1
|
+
import { UserController } from '@/server/controllers/UserController';
|
|
2
|
+
import { NextApiServer } from '@/server/NextApiServer';
|
|
12
3
|
import type { NextRequest } from 'next/server';
|
|
13
4
|
|
|
14
5
|
export async function POST(req: NextRequest) {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
try {
|
|
21
|
-
if (requestBody.password) {
|
|
22
|
-
requestBody.password = IOC(StringEncryptor).decrypt(
|
|
23
|
-
requestBody.password
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
} catch {
|
|
27
|
-
throw new ExecutorError(
|
|
28
|
-
'encrypt_password_failed',
|
|
29
|
-
'Encrypt password failed'
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
const body = IOC(LoginValidator).getThrow(requestBody);
|
|
33
|
-
|
|
34
|
-
const userService: UserServiceInterface = IOC(UserService);
|
|
35
|
-
|
|
36
|
-
const user = (await userService.login(body)) as UserSchema;
|
|
37
|
-
|
|
38
|
-
await IOC(ServerAuth).setAuth(user.credential_token);
|
|
39
|
-
|
|
40
|
-
return user;
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
if (result instanceof ExecutorError) {
|
|
44
|
-
return NextResponse.json(new AppErrorApi(result.id, result.message), {
|
|
45
|
-
status: 400
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return NextResponse.json(new AppSuccessApi(result));
|
|
6
|
+
const requestBody = await req.json();
|
|
7
|
+
return await new NextApiServer().runWithJson(
|
|
8
|
+
async ({ parameters: { IOC } }) => IOC(UserController).login(requestBody)
|
|
9
|
+
);
|
|
50
10
|
}
|
|
@@ -1,27 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { BootstrapServer } from '@/core/bootstraps/BootstrapServer';
|
|
4
|
-
import { AppErrorApi } from '@/server/AppErrorApi';
|
|
5
|
-
import { AppSuccessApi } from '@/server/AppSuccessApi';
|
|
6
|
-
import type { UserServiceInterface } from '@/server/port/UserServiceInterface';
|
|
7
|
-
import { UserService } from '@/server/services/UserService';
|
|
1
|
+
import { UserController } from '@/server/controllers/UserController';
|
|
2
|
+
import { NextApiServer } from '@/server/NextApiServer';
|
|
8
3
|
|
|
9
4
|
export async function POST() {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const userService: UserServiceInterface = IOC(UserService);
|
|
14
|
-
|
|
15
|
-
await userService.logout();
|
|
16
|
-
|
|
17
|
-
return true;
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
if (result instanceof ExecutorError) {
|
|
21
|
-
return NextResponse.json(new AppErrorApi(result.id, result.message), {
|
|
22
|
-
status: 400
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return NextResponse.json(new AppSuccessApi(result));
|
|
5
|
+
return await new NextApiServer().runWithJson(
|
|
6
|
+
async ({ parameters: { IOC } }) => IOC(UserController).logout()
|
|
7
|
+
);
|
|
27
8
|
}
|
|
@@ -1,50 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { StringEncryptor } from '@/base/cases/StringEncryptor';
|
|
4
|
-
import { BootstrapServer } from '@/core/bootstraps/BootstrapServer';
|
|
5
|
-
import { AppErrorApi } from '@/server/AppErrorApi';
|
|
6
|
-
import { AppSuccessApi } from '@/server/AppSuccessApi';
|
|
7
|
-
import type { UserServiceInterface } from '@/server/port/UserServiceInterface';
|
|
8
|
-
import { UserService } from '@/server/services/UserService';
|
|
9
|
-
import { LoginValidator } from '@/server/validators/LoginValidator';
|
|
1
|
+
import { UserController } from '@/server/controllers/UserController';
|
|
2
|
+
import { NextApiServer } from '@/server/NextApiServer';
|
|
10
3
|
import type { NextRequest } from 'next/server';
|
|
11
4
|
|
|
12
5
|
export async function POST(req: NextRequest) {
|
|
13
|
-
const
|
|
6
|
+
const requestBody = await req.json();
|
|
14
7
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
try {
|
|
19
|
-
if (requestBody.password) {
|
|
20
|
-
requestBody.password = IOC(StringEncryptor).decrypt(
|
|
21
|
-
requestBody.password
|
|
22
|
-
);
|
|
23
|
-
}
|
|
24
|
-
} catch {
|
|
25
|
-
throw new ExecutorError(
|
|
26
|
-
'encrypt_password_failed',
|
|
27
|
-
'Encrypt password failed'
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const body = IOC(LoginValidator).getThrow(requestBody);
|
|
32
|
-
|
|
33
|
-
const userService: UserServiceInterface = IOC(UserService);
|
|
34
|
-
|
|
35
|
-
const user = await userService.register({
|
|
36
|
-
email: body.email,
|
|
37
|
-
password: body.password
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
return user;
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
if (result instanceof ExecutorError) {
|
|
44
|
-
return NextResponse.json(new AppErrorApi(result.id, result.message), {
|
|
45
|
-
status: 400
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return NextResponse.json(new AppSuccessApi(result));
|
|
8
|
+
return await new NextApiServer().runWithJson(
|
|
9
|
+
async ({ parameters: { IOC } }) => IOC(UserController).register(requestBody)
|
|
10
|
+
);
|
|
50
11
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { getTranslations } from 'next-intl/server';
|
|
2
|
+
import { routing } from '@/i18n/routing';
|
|
3
|
+
import { COMMON_MANIFEST_NAME } from '@config/Identifier';
|
|
4
|
+
import type { MetadataRoute } from 'next';
|
|
5
|
+
|
|
6
|
+
export default async function manifest(): Promise<MetadataRoute.Manifest> {
|
|
7
|
+
const t = await getTranslations({
|
|
8
|
+
locale: routing.defaultLocale
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
return {
|
|
12
|
+
name: t(COMMON_MANIFEST_NAME),
|
|
13
|
+
start_url: '/',
|
|
14
|
+
theme_color: '#101E33'
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -7,9 +7,9 @@ import type {
|
|
|
7
7
|
} from '../port/AdminLayoutInterface';
|
|
8
8
|
|
|
9
9
|
class AdminPageManagerState implements AdminPageState {
|
|
10
|
-
collapsedSidebar = false;
|
|
10
|
+
public collapsedSidebar = false;
|
|
11
11
|
|
|
12
|
-
navItems: NavItemInterface[] = defaultNavItems;
|
|
12
|
+
public navItems: NavItemInterface[] = defaultNavItems;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
@injectable()
|
|
@@ -18,7 +18,7 @@ export class AdminPageManager extends AdminLayoutInterface {
|
|
|
18
18
|
super(() => new AdminPageManagerState());
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
override toggleSidebar(): void {
|
|
21
|
+
public override toggleSidebar(): void {
|
|
22
22
|
this.emit(
|
|
23
23
|
this.cloneState({
|
|
24
24
|
collapsedSidebar: !this.state.collapsedSidebar
|
|
@@ -8,30 +8,31 @@ export class AppConfig implements EnvConfigInterface {
|
|
|
8
8
|
* @description Represents the running environment (development, production, etc.)
|
|
9
9
|
* Automatically set based on the current .env file being used
|
|
10
10
|
*/
|
|
11
|
-
readonly env: string = process.env.APP_ENV!;
|
|
12
|
-
readonly appName: string = name;
|
|
13
|
-
readonly appVersion: string = version;
|
|
11
|
+
public readonly env: string = process.env.APP_ENV!;
|
|
12
|
+
public readonly appName: string = name;
|
|
13
|
+
public readonly appVersion: string = version;
|
|
14
14
|
|
|
15
|
-
readonly userTokenKey: string = '_user_token';
|
|
15
|
+
public readonly userTokenKey: string = '_user_token';
|
|
16
16
|
|
|
17
|
-
readonly testLoginEmail: string = process.env.NEXT_PUBLIC_LOGIN_USER!;
|
|
18
|
-
readonly testLoginPassword: string =
|
|
17
|
+
public readonly testLoginEmail: string = process.env.NEXT_PUBLIC_LOGIN_USER!;
|
|
18
|
+
public readonly testLoginPassword: string =
|
|
19
|
+
process.env.NEXT_PUBLIC_LOGIN_PASSWORD!;
|
|
19
20
|
|
|
20
|
-
readonly supabaseUrl: string = process.env.SUPABASE_URL!;
|
|
21
|
-
readonly supabaseAnonKey: string = process.env.SUPABASE_ANON_KEY!;
|
|
21
|
+
public readonly supabaseUrl: string = process.env.SUPABASE_URL!;
|
|
22
|
+
public readonly supabaseAnonKey: string = process.env.SUPABASE_ANON_KEY!;
|
|
22
23
|
|
|
23
|
-
readonly stringEncryptorKey: string =
|
|
24
|
+
public readonly stringEncryptorKey: string =
|
|
24
25
|
process.env.NEXT_PUBLIC_STRING_ENCRYPT_KEY!;
|
|
25
26
|
|
|
26
|
-
readonly jwtSecret: string = process.env.JWT_SECRET!;
|
|
27
|
+
public readonly jwtSecret: string = process.env.JWT_SECRET!;
|
|
27
28
|
/**
|
|
28
29
|
* login user token expires in
|
|
29
30
|
*
|
|
30
31
|
* @example '30 days'
|
|
31
32
|
* @example '1 year'
|
|
32
33
|
*/
|
|
33
|
-
readonly jwtExpiresIn: StringValue = '30 days';
|
|
34
|
+
public readonly jwtExpiresIn: StringValue = '30 days';
|
|
34
35
|
|
|
35
|
-
readonly openaiBaseUrl: string = process.env.CEREBRAS_BASE_URL!;
|
|
36
|
-
readonly openaiApiKey: string = process.env.CEREBRAS_API_KEY!;
|
|
36
|
+
public readonly openaiBaseUrl: string = process.env.CEREBRAS_BASE_URL!;
|
|
37
|
+
public readonly openaiApiKey: string = process.env.CEREBRAS_API_KEY!;
|
|
37
38
|
}
|
|
@@ -3,16 +3,16 @@ import { injectable } from 'inversify';
|
|
|
3
3
|
|
|
4
4
|
@injectable()
|
|
5
5
|
export class Datetime {
|
|
6
|
-
timestamp(): number {
|
|
6
|
+
public timestamp(): number {
|
|
7
7
|
return dayjs().unix();
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
timestampz(): string {
|
|
10
|
+
public timestampz(): string {
|
|
11
11
|
const now = new Date();
|
|
12
12
|
return now.toISOString().replace('T', ' ').replace('Z', '+00');
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
format(format: string, date?: Date): string {
|
|
15
|
+
public format(format: string, date?: Date): string {
|
|
16
16
|
return dayjs(date).format(format);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
@@ -14,7 +14,7 @@ import type { UIDialogInterface } from '@qlover/corekit-bridge';
|
|
|
14
14
|
|
|
15
15
|
@injectable()
|
|
16
16
|
export class DialogErrorPlugin implements ExecutorPlugin {
|
|
17
|
-
readonly pluginName = 'DialogErrorPlugin';
|
|
17
|
+
public readonly pluginName = 'DialogErrorPlugin';
|
|
18
18
|
|
|
19
19
|
constructor(
|
|
20
20
|
@inject(I.DialogHandler)
|
|
@@ -24,7 +24,10 @@ export class DialogErrorPlugin implements ExecutorPlugin {
|
|
|
24
24
|
protected routerService: RouterService
|
|
25
25
|
) {}
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
/**
|
|
28
|
+
* @override
|
|
29
|
+
*/
|
|
30
|
+
public onError(context: ExecutorContext<unknown>): void | Promise<void> {
|
|
28
31
|
const { error, hooksRuntimes } = context;
|
|
29
32
|
const runtimesError = hooksRuntimes.returnValue;
|
|
30
33
|
|
|
@@ -46,6 +49,9 @@ export class DialogErrorPlugin implements ExecutorPlugin {
|
|
|
46
49
|
}
|
|
47
50
|
}
|
|
48
51
|
|
|
52
|
+
/**
|
|
53
|
+
* @override
|
|
54
|
+
*/
|
|
49
55
|
protected isI18nMessage(message: string): boolean {
|
|
50
56
|
return i18nKeySchema.safeParse(message).success;
|
|
51
57
|
}
|
|
@@ -45,31 +45,48 @@ export class DialogHandler
|
|
|
45
45
|
notification?: NotificationApi;
|
|
46
46
|
} = {};
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
/**
|
|
49
|
+
* @override
|
|
50
|
+
*/
|
|
51
|
+
public setMessage(message: MessageApi): void {
|
|
49
52
|
this.antds.message = message;
|
|
50
53
|
}
|
|
51
54
|
|
|
52
|
-
|
|
55
|
+
/**
|
|
56
|
+
* @override
|
|
57
|
+
*/
|
|
58
|
+
public setModal(modal: ModalApi): void {
|
|
53
59
|
this.antds.modal = modal;
|
|
54
60
|
}
|
|
55
61
|
|
|
56
|
-
|
|
62
|
+
/**
|
|
63
|
+
* @override
|
|
64
|
+
*/
|
|
65
|
+
public setNotification(notification: NotificationApi): void {
|
|
57
66
|
this.antds.notification = notification;
|
|
58
67
|
}
|
|
59
68
|
|
|
60
69
|
/**
|
|
61
70
|
* Formats error message from various error types
|
|
62
|
-
|
|
71
|
+
|
|
72
|
+
* @override
|
|
73
|
+
*/
|
|
63
74
|
protected formatErrorMessage(error: unknown): string {
|
|
64
75
|
if (error instanceof Error) return error.message;
|
|
65
76
|
if (typeof error === 'string') return error;
|
|
66
77
|
return 'An unknown error occurred';
|
|
67
78
|
}
|
|
68
79
|
|
|
80
|
+
/**
|
|
81
|
+
* @override
|
|
82
|
+
*/
|
|
69
83
|
public success(msg: string, options?: NotificationOptions): void {
|
|
70
84
|
this.antds.message?.success({ content: msg, ...options });
|
|
71
85
|
}
|
|
72
86
|
|
|
87
|
+
/**
|
|
88
|
+
* @override
|
|
89
|
+
*/
|
|
73
90
|
public error(msg: string, options?: NotificationOptions): void {
|
|
74
91
|
this.antds.message?.error({
|
|
75
92
|
content: options?.error ? this.formatErrorMessage(options.error) : msg,
|
|
@@ -77,14 +94,23 @@ export class DialogHandler
|
|
|
77
94
|
});
|
|
78
95
|
}
|
|
79
96
|
|
|
97
|
+
/**
|
|
98
|
+
* @override
|
|
99
|
+
*/
|
|
80
100
|
public info(msg: string, options?: NotificationOptions): void {
|
|
81
101
|
this.antds.message?.info({ content: msg, ...options });
|
|
82
102
|
}
|
|
83
103
|
|
|
104
|
+
/**
|
|
105
|
+
* @override
|
|
106
|
+
*/
|
|
84
107
|
public warn(msg: string, options?: NotificationOptions): void {
|
|
85
108
|
this.antds.message?.warning({ content: msg, ...options });
|
|
86
109
|
}
|
|
87
110
|
|
|
111
|
+
/**
|
|
112
|
+
* @override
|
|
113
|
+
*/
|
|
88
114
|
public confirm(options: DialogHandlerOptions): void {
|
|
89
115
|
this.antds.modal?.confirm(options);
|
|
90
116
|
}
|