@qlover/create-app 0.10.2 → 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 +37 -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/eslint.config.mjs +5 -1
- package/dist/templates/next-app/package.json +4 -2
- 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 +8 -2
- 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 +24 -6
- 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/I18nServiceInterface.ts +27 -7
- 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/core/bootstraps/BootstrapClient.ts +2 -2
- package/dist/templates/next-app/src/core/bootstraps/BootstrapServer.ts +25 -7
- package/dist/templates/next-app/src/core/bootstraps/BootstrapsRegistry.ts +6 -3
- package/dist/templates/next-app/src/core/clientIoc/ClientIOC.ts +11 -2
- package/dist/templates/next-app/src/core/clientIoc/ClientIOCRegister.ts +5 -0
- package/dist/templates/next-app/src/core/serverIoc/ServerIOC.ts +13 -4
- package/dist/templates/next-app/src/core/serverIoc/ServerIOCRegister.ts +8 -1
- package/dist/templates/next-app/src/pages/_app.tsx +1 -1
- package/dist/templates/next-app/src/server/AppErrorApi.ts +1 -1
- package/dist/templates/next-app/src/server/AppPageRouteParams.ts +13 -0
- package/dist/templates/next-app/src/server/AppSuccessApi.ts +1 -1
- package/dist/templates/next-app/src/server/NextApiServer.ts +11 -2
- package/dist/templates/next-app/src/server/PagesRouteParams.ts +11 -1
- 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/SupabaseBridge.ts +48 -8
- package/dist/templates/next-app/src/server/UserCredentialToken.ts +8 -2
- package/dist/templates/next-app/src/server/controllers/AdminLocalesController.ts +16 -4
- package/dist/templates/next-app/src/server/controllers/AdminUserController.ts +4 -1
- package/dist/templates/next-app/src/server/controllers/LocalesController.ts +4 -1
- package/dist/templates/next-app/src/server/controllers/UserController.ts +12 -3
- package/dist/templates/next-app/src/server/repositorys/LocalesRepository.ts +23 -7
- 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/server/services/ApiLocaleService.ts +5 -5
- package/dist/templates/next-app/src/server/services/ApiUserService.ts +1 -1
- package/dist/templates/next-app/src/server/services/UserService.ts +12 -3
- package/dist/templates/next-app/src/server/validators/LocalesValidator.ts +20 -5
- package/dist/templates/next-app/src/server/validators/LoginValidator.ts +16 -4
- package/dist/templates/next-app/src/server/validators/PaginationValidator.ts +8 -2
- package/dist/templates/next-app/src/uikit/components/IOCProvider.tsx +1 -1
- package/dist/templates/next-app/src/uikit/components/localesImportButton/LocalesImportEvent.ts +7 -1
- 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/react-app/makes/eslint-utils.mjs +0 -195
|
@@ -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
|
}
|
|
@@ -17,15 +17,27 @@ export class InversifyContainer implements IOCContainerInterface {
|
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
/**
|
|
21
|
+
* @override
|
|
22
|
+
*/
|
|
23
|
+
public bind<T>(key: ServiceIdentifier<T>, value: T): void {
|
|
21
24
|
this.container.bind<T>(key).toConstantValue(value);
|
|
22
25
|
}
|
|
23
26
|
|
|
24
|
-
|
|
27
|
+
/**
|
|
28
|
+
* @override
|
|
29
|
+
*/
|
|
30
|
+
public get<K extends keyof IOCIdentifierMap>(
|
|
25
31
|
serviceIdentifier: K
|
|
26
32
|
): IOCIdentifierMap[K];
|
|
27
|
-
|
|
28
|
-
|
|
33
|
+
/**
|
|
34
|
+
* @override
|
|
35
|
+
*/
|
|
36
|
+
public get<T>(serviceIdentifier: ServiceIdentifier<T>): T;
|
|
37
|
+
/**
|
|
38
|
+
* @override
|
|
39
|
+
*/
|
|
40
|
+
public get<T, K extends keyof IOCIdentifierMap>(
|
|
29
41
|
serviceIdentifier: ServiceIdentifier<T> | K
|
|
30
42
|
): T | IOCIdentifierMap[K] {
|
|
31
43
|
return this.container.get<T>(serviceIdentifier);
|
|
@@ -12,11 +12,17 @@ export class NavigateBridge implements UIBridgeInterface<AppRouterInstance> {
|
|
|
12
12
|
|
|
13
13
|
constructor(@inject(I.Logger) protected logger: LoggerInterface) {}
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
/**
|
|
16
|
+
* @override
|
|
17
|
+
*/
|
|
18
|
+
public setUIBridge(ui: AppRouterInstance): void {
|
|
16
19
|
this.navigate = ui;
|
|
17
20
|
}
|
|
18
21
|
|
|
19
|
-
|
|
22
|
+
/**
|
|
23
|
+
* @override
|
|
24
|
+
*/
|
|
25
|
+
public getUIBridge(): AppRouterInstance | null {
|
|
20
26
|
if (!this.navigate) {
|
|
21
27
|
this.logger.debug('NavigateBridge this.navigate is not set');
|
|
22
28
|
}
|
|
@@ -20,11 +20,14 @@ export interface RequestEncryptPluginProps<
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export class RequestEncryptPlugin implements ExecutorPlugin<RequestEncryptPluginProps> {
|
|
23
|
-
readonly pluginName = 'RequestEncryptPlugin';
|
|
23
|
+
public readonly pluginName = 'RequestEncryptPlugin';
|
|
24
24
|
|
|
25
25
|
constructor(protected encryptor: Encryptor<string, string>) {}
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
/**
|
|
28
|
+
* @override
|
|
29
|
+
*/
|
|
30
|
+
public onBefore(
|
|
28
31
|
context: ExecutorContext<RequestEncryptPluginProps>
|
|
29
32
|
): void | Promise<void> {
|
|
30
33
|
const { responseType, encryptProps } = context.parameters;
|
|
@@ -41,6 +44,9 @@ export class RequestEncryptPlugin implements ExecutorPlugin<RequestEncryptPlugin
|
|
|
41
44
|
}
|
|
42
45
|
}
|
|
43
46
|
|
|
47
|
+
/**
|
|
48
|
+
* @override
|
|
49
|
+
*/
|
|
44
50
|
protected encryptData<T extends object>(
|
|
45
51
|
data: T,
|
|
46
52
|
encryptProps?: string | string[]
|
|
@@ -6,12 +6,12 @@ import type {
|
|
|
6
6
|
} from '@qlover/corekit-bridge';
|
|
7
7
|
|
|
8
8
|
export class ResourceState implements ResourceStateInterface {
|
|
9
|
-
searchParams: ResourceQuery = {
|
|
9
|
+
public searchParams: ResourceQuery = {
|
|
10
10
|
page: 1,
|
|
11
11
|
pageSize: 10,
|
|
12
12
|
orderBy: 'updated_at',
|
|
13
13
|
order: 1
|
|
14
14
|
};
|
|
15
|
-
initState = new RequestState<unknown>();
|
|
16
|
-
listState = new RequestState<PaginationInterface<unknown>>();
|
|
15
|
+
public initState = new RequestState<unknown>();
|
|
16
|
+
public listState = new RequestState<PaginationInterface<unknown>>();
|
|
17
17
|
}
|
|
@@ -13,27 +13,45 @@ export class RouterService implements RouterInterface {
|
|
|
13
13
|
protected uiBridge: UIBridgeInterface<AppRouterInstance>
|
|
14
14
|
) {}
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
/**
|
|
17
|
+
* @override
|
|
18
|
+
*/
|
|
19
|
+
public goto(href: RouterPathname): void {
|
|
17
20
|
this.uiBridge.getUIBridge()?.push(href as string);
|
|
18
21
|
}
|
|
19
22
|
|
|
20
|
-
|
|
23
|
+
/**
|
|
24
|
+
* @override
|
|
25
|
+
*/
|
|
26
|
+
public gotoHome(): void {
|
|
21
27
|
this.goto('/');
|
|
22
28
|
}
|
|
23
29
|
|
|
24
|
-
|
|
30
|
+
/**
|
|
31
|
+
* @override
|
|
32
|
+
*/
|
|
33
|
+
public gotoLogin(): void {
|
|
25
34
|
this.goto('/login');
|
|
26
35
|
}
|
|
27
36
|
|
|
28
|
-
|
|
37
|
+
/**
|
|
38
|
+
* @override
|
|
39
|
+
*/
|
|
40
|
+
public replaceHome(): void {
|
|
29
41
|
this.uiBridge.getUIBridge()?.replace('/');
|
|
30
42
|
}
|
|
31
43
|
|
|
32
|
-
|
|
44
|
+
/**
|
|
45
|
+
* @override
|
|
46
|
+
*/
|
|
47
|
+
public setLocale(locale: string): void {
|
|
33
48
|
this.locale = locale;
|
|
34
49
|
}
|
|
35
50
|
|
|
36
|
-
|
|
51
|
+
/**
|
|
52
|
+
* @override
|
|
53
|
+
*/
|
|
54
|
+
public getLocale(): string {
|
|
37
55
|
return this.locale;
|
|
38
56
|
}
|
|
39
57
|
}
|
|
@@ -18,6 +18,9 @@ export class StringEncryptor implements Encryptor<string, string> {
|
|
|
18
18
|
this.key = appConfig.stringEncryptorKey;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* @override
|
|
23
|
+
*/
|
|
21
24
|
protected encryptWithKey(str: string, key: string): string {
|
|
22
25
|
const result = [];
|
|
23
26
|
for (let i = 0; i < str.length; i++) {
|
|
@@ -31,6 +34,9 @@ export class StringEncryptor implements Encryptor<string, string> {
|
|
|
31
34
|
return result.join('');
|
|
32
35
|
}
|
|
33
36
|
|
|
37
|
+
/**
|
|
38
|
+
* @override
|
|
39
|
+
*/
|
|
34
40
|
protected decryptWithKey(str: string, key: string): string {
|
|
35
41
|
const result = [];
|
|
36
42
|
for (let i = 0; i < str.length; i++) {
|
|
@@ -43,7 +49,10 @@ export class StringEncryptor implements Encryptor<string, string> {
|
|
|
43
49
|
return result.join('');
|
|
44
50
|
}
|
|
45
51
|
|
|
46
|
-
|
|
52
|
+
/**
|
|
53
|
+
* @override
|
|
54
|
+
*/
|
|
55
|
+
public encrypt(value: string): string {
|
|
47
56
|
try {
|
|
48
57
|
const encrypted = this.encryptWithKey(value, this.key);
|
|
49
58
|
return this.base64Serializer.serialize(encrypted);
|
|
@@ -53,7 +62,10 @@ export class StringEncryptor implements Encryptor<string, string> {
|
|
|
53
62
|
}
|
|
54
63
|
}
|
|
55
64
|
|
|
56
|
-
|
|
65
|
+
/**
|
|
66
|
+
* @override
|
|
67
|
+
*/
|
|
68
|
+
public decrypt(encryptedValue: string): string {
|
|
57
69
|
try {
|
|
58
70
|
// 1. 先用 base64 反序列化
|
|
59
71
|
const decoded = this.base64Serializer.deserialize(encryptedValue);
|
|
@@ -9,7 +9,7 @@ import type { useTranslations } from 'next-intl';
|
|
|
9
9
|
* @returns The translated i18n interface
|
|
10
10
|
*/
|
|
11
11
|
export class TranslateI18nInterface {
|
|
12
|
-
static translate<T extends PageI18nInterface | Record<string, string>>(
|
|
12
|
+
public static translate<T extends PageI18nInterface | Record<string, string>>(
|
|
13
13
|
source: T,
|
|
14
14
|
t: ReturnType<typeof useTranslations>
|
|
15
15
|
): T {
|
|
@@ -17,7 +17,10 @@ export class UserServiceApi implements UserServiceGateway<
|
|
|
17
17
|
> {
|
|
18
18
|
constructor(@inject(AppUserApi) protected appUserApi: AppUserApiInterface) {}
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
/**
|
|
21
|
+
* @override
|
|
22
|
+
*/
|
|
23
|
+
public getUserInfo(_params?: unknown): Promise<UserSchema | null> {
|
|
21
24
|
if (_params && isWebUserSchema(_params).success) {
|
|
22
25
|
return Promise.resolve(omit(_params, 'credential_token') as UserSchema);
|
|
23
26
|
}
|
|
@@ -25,13 +28,19 @@ export class UserServiceApi implements UserServiceGateway<
|
|
|
25
28
|
return Promise.resolve(null);
|
|
26
29
|
}
|
|
27
30
|
|
|
28
|
-
|
|
31
|
+
/**
|
|
32
|
+
* @override
|
|
33
|
+
*/
|
|
34
|
+
public refreshUserInfo<Params>(
|
|
29
35
|
_params?: Params | undefined
|
|
30
36
|
): Promise<UserSchema | null> {
|
|
31
37
|
return this.getUserInfo(_params);
|
|
32
38
|
}
|
|
33
39
|
|
|
34
|
-
|
|
40
|
+
/**
|
|
41
|
+
* @override
|
|
42
|
+
*/
|
|
43
|
+
public async login(params: LoginValidatorData): Promise<UserCredential> {
|
|
35
44
|
const response = await this.appUserApi.login(params);
|
|
36
45
|
|
|
37
46
|
if (!response.data.success) {
|
|
@@ -41,7 +50,10 @@ export class UserServiceApi implements UserServiceGateway<
|
|
|
41
50
|
return response.data.data as UserCredential;
|
|
42
51
|
}
|
|
43
52
|
|
|
44
|
-
|
|
53
|
+
/**
|
|
54
|
+
* @override
|
|
55
|
+
*/
|
|
56
|
+
public async register(params: LoginValidatorData): Promise<UserSchema> {
|
|
45
57
|
const response = await this.appUserApi.register(params);
|
|
46
58
|
|
|
47
59
|
if (!response.data.success) {
|
|
@@ -51,7 +63,10 @@ export class UserServiceApi implements UserServiceGateway<
|
|
|
51
63
|
return response.data.data as UserSchema;
|
|
52
64
|
}
|
|
53
65
|
|
|
54
|
-
|
|
66
|
+
/**
|
|
67
|
+
* @override
|
|
68
|
+
*/
|
|
69
|
+
public async logout<P = unknown, Result = void>(params?: P): Promise<Result> {
|
|
55
70
|
const response = await this.appUserApi.logout(params);
|
|
56
71
|
|
|
57
72
|
if (!response.data.success) {
|
|
@@ -45,7 +45,12 @@ export class ZodColumnBuilder<
|
|
|
45
45
|
this.optionMap = optionMap ? merge(baseOptions, optionMap) : baseOptions;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
/**
|
|
49
|
+
* @override
|
|
50
|
+
*/
|
|
51
|
+
public static zodType2RenderForm(
|
|
52
|
+
zod: ZodType
|
|
53
|
+
): ResourceTableFormType | undefined {
|
|
49
54
|
// @ts-expect-error - zod._def.typeName is not typed
|
|
50
55
|
const typeName = zod._def?.typeName as ZodFirstPartyTypeKind;
|
|
51
56
|
|
|
@@ -65,7 +70,10 @@ export class ZodColumnBuilder<
|
|
|
65
70
|
];
|
|
66
71
|
}
|
|
67
72
|
|
|
68
|
-
|
|
73
|
+
/**
|
|
74
|
+
* @override
|
|
75
|
+
*/
|
|
76
|
+
public zod2BaseOption(
|
|
69
77
|
key: string,
|
|
70
78
|
zod: ZodType
|
|
71
79
|
): ResourceTableOption<z.infer<Input>> {
|
|
@@ -91,7 +99,10 @@ export class ZodColumnBuilder<
|
|
|
91
99
|
};
|
|
92
100
|
}
|
|
93
101
|
|
|
94
|
-
|
|
102
|
+
/**
|
|
103
|
+
* @override
|
|
104
|
+
*/
|
|
105
|
+
public getBaseOptions(input: Input): OptionMap<Value, Input> {
|
|
95
106
|
return Object.entries(input.shape).reduce(
|
|
96
107
|
(acc, [key, zod]) => {
|
|
97
108
|
acc[key as keyof Input['shape']] = this.zod2BaseOption(
|
|
@@ -104,7 +115,10 @@ export class ZodColumnBuilder<
|
|
|
104
115
|
);
|
|
105
116
|
}
|
|
106
117
|
|
|
107
|
-
|
|
118
|
+
/**
|
|
119
|
+
* @override
|
|
120
|
+
*/
|
|
121
|
+
public bind(
|
|
108
122
|
key: keyof Input['shape'],
|
|
109
123
|
params?: Partial<ResourceTableOption<z.infer<Input>>>
|
|
110
124
|
): this {
|
|
@@ -115,7 +129,10 @@ export class ZodColumnBuilder<
|
|
|
115
129
|
return this;
|
|
116
130
|
}
|
|
117
131
|
|
|
118
|
-
|
|
132
|
+
/**
|
|
133
|
+
* @override
|
|
134
|
+
*/
|
|
135
|
+
public render<K extends keyof Input['shape']>(
|
|
119
136
|
key: K,
|
|
120
137
|
render: (
|
|
121
138
|
value: unknown,
|
|
@@ -129,10 +146,11 @@ export class ZodColumnBuilder<
|
|
|
129
146
|
|
|
130
147
|
/**
|
|
131
148
|
* Translate all i18n keys in options to actual text
|
|
149
|
+
* @override
|
|
132
150
|
* @param t - Translation function from next-intl
|
|
133
151
|
* @returns this for chaining
|
|
134
152
|
*/
|
|
135
|
-
translate(t: ReturnType<typeof useTranslations>): this {
|
|
153
|
+
public translate(t: ReturnType<typeof useTranslations>): this {
|
|
136
154
|
Object.values(this.optionMap).forEach((option) => {
|
|
137
155
|
const { tt } = option;
|
|
138
156
|
// Translate title if it's a string (i18n key)
|
|
@@ -167,11 +185,15 @@ export class ZodColumnBuilder<
|
|
|
167
185
|
|
|
168
186
|
/**
|
|
169
187
|
* Build a single option by key
|
|
188
|
+
* @override
|
|
170
189
|
* @param key - The key of the option to build
|
|
171
190
|
* @param params - Optional additional parameters to merge
|
|
172
191
|
* @returns The built option
|
|
173
192
|
*/
|
|
174
|
-
build(
|
|
193
|
+
public build(
|
|
194
|
+
key: string,
|
|
195
|
+
params?: unknown
|
|
196
|
+
): ResourceTableOption<z.infer<Input>> {
|
|
175
197
|
const option = this.optionMap[key as keyof Input['shape']];
|
|
176
198
|
if (!option) {
|
|
177
199
|
throw new Error(`Option with key "${key}" not found`);
|
|
@@ -190,10 +212,11 @@ export class ZodColumnBuilder<
|
|
|
190
212
|
|
|
191
213
|
/**
|
|
192
214
|
* Build all options
|
|
215
|
+
* @override
|
|
193
216
|
* @param params - Optional additional parameters (currently unused)
|
|
194
217
|
* @returns Array of all built options
|
|
195
218
|
*/
|
|
196
|
-
buildAll(_params?: unknown): ResourceTableOption<z.infer<Input>>[] {
|
|
219
|
+
public buildAll(_params?: unknown): ResourceTableOption<z.infer<Input>>[] {
|
|
197
220
|
return Object.values(this.optionMap);
|
|
198
221
|
}
|
|
199
222
|
}
|
|
@@ -10,17 +10,37 @@ export type SupportedNamespace = typeof i18nConfig.fallbackLng;
|
|
|
10
10
|
export type I18nServiceLocale = Locale;
|
|
11
11
|
|
|
12
12
|
export class I18nServiceState implements StoreStateInterface {
|
|
13
|
-
loading: boolean = false;
|
|
13
|
+
public loading: boolean = false;
|
|
14
14
|
constructor(public language: I18nServiceLocale) {}
|
|
15
15
|
}
|
|
16
16
|
export abstract class I18nServiceInterface
|
|
17
17
|
extends StoreInterface<I18nServiceState>
|
|
18
18
|
implements I18nServiceInterface
|
|
19
19
|
{
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
abstract
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
/**
|
|
21
|
+
* @override
|
|
22
|
+
*/
|
|
23
|
+
public abstract t(key: string, params?: Record<string, unknown>): string;
|
|
24
|
+
/**
|
|
25
|
+
* @override
|
|
26
|
+
*/
|
|
27
|
+
public abstract changeLanguage(language: I18nServiceLocale): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* @override
|
|
30
|
+
*/
|
|
31
|
+
public abstract changeLoading(loading: boolean): void;
|
|
32
|
+
/**
|
|
33
|
+
* @override
|
|
34
|
+
*/
|
|
35
|
+
public abstract getCurrentLanguage(): Promise<I18nServiceLocale>;
|
|
36
|
+
/**
|
|
37
|
+
* @override
|
|
38
|
+
*/
|
|
39
|
+
public abstract isValidLanguage(
|
|
40
|
+
language: string
|
|
41
|
+
): language is I18nServiceLocale;
|
|
42
|
+
/**
|
|
43
|
+
* @override
|
|
44
|
+
*/
|
|
45
|
+
public abstract getSupportedLanguages(): I18nServiceLocale[];
|
|
26
46
|
}
|
|
@@ -16,7 +16,7 @@ export class AdminPageEvent extends ResourceEvent {
|
|
|
16
16
|
super(namespace, resource, undefined, schemaFormRef);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
override onDeleted(_params: ResourceTableEventCommonParams): void {
|
|
19
|
+
public override onDeleted(_params: ResourceTableEventCommonParams): void {
|
|
20
20
|
this.uiDialog?.confirm({
|
|
21
21
|
title: 'Confirm Delete',
|
|
22
22
|
content: 'Are you sure you want to delete this item?',
|
|
@@ -5,7 +5,7 @@ export class AdminPageScheduler implements LifecycleInterface {
|
|
|
5
5
|
/**
|
|
6
6
|
* @override
|
|
7
7
|
*/
|
|
8
|
-
async created(parmas: {
|
|
8
|
+
public async created(parmas: {
|
|
9
9
|
resource: ResourceService<unknown>;
|
|
10
10
|
}): Promise<unknown> {
|
|
11
11
|
const { resource } = parmas;
|
|
@@ -28,7 +28,7 @@ export class AdminPageScheduler implements LifecycleInterface {
|
|
|
28
28
|
/**
|
|
29
29
|
* @override
|
|
30
30
|
*/
|
|
31
|
-
destroyed(parmas: { resource: ResourceService<unknown> }): void {
|
|
31
|
+
public destroyed(parmas: { resource: ResourceService<unknown> }): void {
|
|
32
32
|
const { resource } = parmas;
|
|
33
33
|
const store = resource.getStore();
|
|
34
34
|
|
|
@@ -38,5 +38,5 @@ export class AdminPageScheduler implements LifecycleInterface {
|
|
|
38
38
|
/**
|
|
39
39
|
* @override
|
|
40
40
|
*/
|
|
41
|
-
updated(): void {}
|
|
41
|
+
public updated(): void {}
|
|
42
42
|
}
|