@qlover/create-app 0.10.2 → 0.10.5
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 +41 -0
- package/README.md +22 -3
- 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
|
@@ -18,7 +18,7 @@ export class ApiUserService {
|
|
|
18
18
|
protected paginationValidator: ValidatorInterface<PaginationParams>
|
|
19
19
|
) {}
|
|
20
20
|
|
|
21
|
-
async getUsers(params: {
|
|
21
|
+
public async getUsers(params: {
|
|
22
22
|
page: number;
|
|
23
23
|
pageSize: number;
|
|
24
24
|
}): Promise<PaginationInterface<UserSchema>> {
|
|
@@ -31,7 +31,10 @@ export class UserService implements UserServiceInterface {
|
|
|
31
31
|
protected credentialToken: CrentialTokenInterface<UserCredentialTokenValue>
|
|
32
32
|
) {}
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
/**
|
|
35
|
+
* @override
|
|
36
|
+
*/
|
|
37
|
+
public async register(params: {
|
|
35
38
|
email: string;
|
|
36
39
|
password: string;
|
|
37
40
|
}): Promise<UserSchema> {
|
|
@@ -54,7 +57,10 @@ export class UserService implements UserServiceInterface {
|
|
|
54
57
|
return omit(target, 'password') as UserSchema;
|
|
55
58
|
}
|
|
56
59
|
|
|
57
|
-
|
|
60
|
+
/**
|
|
61
|
+
* @override
|
|
62
|
+
*/
|
|
63
|
+
public async login(params: {
|
|
58
64
|
email: string;
|
|
59
65
|
password: string;
|
|
60
66
|
}): Promise<UserSchema> {
|
|
@@ -81,7 +87,10 @@ export class UserService implements UserServiceInterface {
|
|
|
81
87
|
});
|
|
82
88
|
}
|
|
83
89
|
|
|
84
|
-
|
|
90
|
+
/**
|
|
91
|
+
* @override
|
|
92
|
+
*/
|
|
93
|
+
public async logout(): Promise<void> {
|
|
85
94
|
const auth = await this.userAuth.getAuth();
|
|
86
95
|
|
|
87
96
|
if (!auth) {
|
|
@@ -14,7 +14,10 @@ import type { ImportLocalesData } from '../services/ApiLocaleService';
|
|
|
14
14
|
export class LocalesValidator implements ValidatorInterface<
|
|
15
15
|
Omit<LocalesSchema, 'id' | 'created_at' | 'updated_at'>
|
|
16
16
|
> {
|
|
17
|
-
|
|
17
|
+
/**
|
|
18
|
+
* @override
|
|
19
|
+
*/
|
|
20
|
+
public validate(data: unknown): void | ValidationFaildResult {
|
|
18
21
|
if (typeof data !== 'object' || data === null) {
|
|
19
22
|
return {
|
|
20
23
|
path: ['form'],
|
|
@@ -31,7 +34,10 @@ export class LocalesValidator implements ValidatorInterface<
|
|
|
31
34
|
}
|
|
32
35
|
}
|
|
33
36
|
|
|
34
|
-
|
|
37
|
+
/**
|
|
38
|
+
* @override
|
|
39
|
+
*/
|
|
40
|
+
public getThrow(
|
|
35
41
|
data: unknown
|
|
36
42
|
): Omit<LocalesSchema, 'id' | 'created_at' | 'updated_at'> {
|
|
37
43
|
const result = this.validate(data);
|
|
@@ -47,7 +53,10 @@ export class LocalesValidator implements ValidatorInterface<
|
|
|
47
53
|
}
|
|
48
54
|
|
|
49
55
|
export class LocalesImportValidator implements ValidatorInterface<ImportLocalesData> {
|
|
50
|
-
|
|
56
|
+
/**
|
|
57
|
+
* @override
|
|
58
|
+
*/
|
|
59
|
+
public getHasAnyFilesLocale(
|
|
51
60
|
values: FormData
|
|
52
61
|
): { language: LocaleType; value: FormDataEntryValue }[] {
|
|
53
62
|
const hasAnyFilesLocale = [];
|
|
@@ -60,7 +69,10 @@ export class LocalesImportValidator implements ValidatorInterface<ImportLocalesD
|
|
|
60
69
|
return hasAnyFilesLocale;
|
|
61
70
|
}
|
|
62
71
|
|
|
63
|
-
|
|
72
|
+
/**
|
|
73
|
+
* @override
|
|
74
|
+
*/
|
|
75
|
+
public async validate(data: {
|
|
64
76
|
namespace?: string;
|
|
65
77
|
values: unknown;
|
|
66
78
|
}): Promise<void | ValidationFaildResult> {
|
|
@@ -101,7 +113,10 @@ export class LocalesImportValidator implements ValidatorInterface<ImportLocalesD
|
|
|
101
113
|
}
|
|
102
114
|
}
|
|
103
115
|
|
|
104
|
-
|
|
116
|
+
/**
|
|
117
|
+
* @override
|
|
118
|
+
*/
|
|
119
|
+
public async getThrow(data: {
|
|
105
120
|
namespace?: string;
|
|
106
121
|
values: unknown;
|
|
107
122
|
}): Promise<ImportLocalesData> {
|
|
@@ -27,21 +27,30 @@ const passwordSchema = z
|
|
|
27
27
|
.regex(/^\S+$/, { message: V_PASSWORD_SPECIAL_CHARS });
|
|
28
28
|
|
|
29
29
|
export class LoginValidator implements ValidatorInterface<LoginValidatorData> {
|
|
30
|
-
|
|
30
|
+
/**
|
|
31
|
+
* @override
|
|
32
|
+
*/
|
|
33
|
+
public validateEmail(data: unknown): void | ValidationFaildResult {
|
|
31
34
|
const emailResult = emailSchema.safeParse(data);
|
|
32
35
|
if (!emailResult.success) {
|
|
33
36
|
return emailResult.error.issues[0];
|
|
34
37
|
}
|
|
35
38
|
}
|
|
36
39
|
|
|
37
|
-
|
|
40
|
+
/**
|
|
41
|
+
* @override
|
|
42
|
+
*/
|
|
43
|
+
public validatePassword(data: unknown): void | ValidationFaildResult {
|
|
38
44
|
const passwordResult = passwordSchema.safeParse(data);
|
|
39
45
|
if (!passwordResult.success) {
|
|
40
46
|
return passwordResult.error.issues[0];
|
|
41
47
|
}
|
|
42
48
|
}
|
|
43
49
|
|
|
44
|
-
|
|
50
|
+
/**
|
|
51
|
+
* @override
|
|
52
|
+
*/
|
|
53
|
+
public validate(data: unknown): void | ValidationFaildResult {
|
|
45
54
|
if (typeof data !== 'object' || data === null) {
|
|
46
55
|
return {
|
|
47
56
|
path: ['form'],
|
|
@@ -62,7 +71,10 @@ export class LoginValidator implements ValidatorInterface<LoginValidatorData> {
|
|
|
62
71
|
}
|
|
63
72
|
}
|
|
64
73
|
|
|
65
|
-
|
|
74
|
+
/**
|
|
75
|
+
* @override
|
|
76
|
+
*/
|
|
77
|
+
public getThrow(data: unknown): LoginValidatorData {
|
|
66
78
|
const result = this.validate(data);
|
|
67
79
|
|
|
68
80
|
if (result == null) {
|
|
@@ -30,7 +30,10 @@ export type PaginationParams = {
|
|
|
30
30
|
export class PaginationValidator implements ValidatorInterface<PaginationParams> {
|
|
31
31
|
protected defaultPageSize = 10;
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
/**
|
|
34
|
+
* @override
|
|
35
|
+
*/
|
|
36
|
+
public validate(data: unknown): void | ValidationFaildResult {
|
|
34
37
|
if (typeof data !== 'object' || data === null) {
|
|
35
38
|
return {
|
|
36
39
|
path: ['form'],
|
|
@@ -44,7 +47,10 @@ export class PaginationValidator implements ValidatorInterface<PaginationParams>
|
|
|
44
47
|
}
|
|
45
48
|
}
|
|
46
49
|
|
|
47
|
-
|
|
50
|
+
/**
|
|
51
|
+
* @override
|
|
52
|
+
*/
|
|
53
|
+
public getThrow<T>(data: unknown): T {
|
|
48
54
|
const result = paginationSchema.safeParse(data);
|
|
49
55
|
if (!result.success) {
|
|
50
56
|
throw new Error(result.error.issues[0].message);
|
|
@@ -27,7 +27,7 @@ export function IOCProvider(props: { children: React.ReactNode }) {
|
|
|
27
27
|
}, []);
|
|
28
28
|
|
|
29
29
|
return (
|
|
30
|
-
<IOCContext.Provider
|
|
30
|
+
<IOCContext.Provider value={IOCInstance}>
|
|
31
31
|
{props.children}
|
|
32
32
|
</IOCContext.Provider>
|
|
33
33
|
);
|
package/dist/templates/next-app/src/uikit/components/localesImportButton/LocalesImportEvent.ts
CHANGED
|
@@ -10,13 +10,19 @@ export class LocalesImportEvent extends StoreInterface<LocalesImportEventState>
|
|
|
10
10
|
super(() => new LocalesImportEventState());
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* @override
|
|
15
|
+
*/
|
|
13
16
|
protected validate(file: File): void {
|
|
14
17
|
if (file.type !== 'application/json') {
|
|
15
18
|
throw new Error('File must be a JSON file');
|
|
16
19
|
}
|
|
17
20
|
}
|
|
18
21
|
|
|
19
|
-
|
|
22
|
+
/**
|
|
23
|
+
* @override
|
|
24
|
+
*/
|
|
25
|
+
public async onImport(type: LocaleType, file: File): Promise<void> {
|
|
20
26
|
try {
|
|
21
27
|
this.validate(file);
|
|
22
28
|
|
|
@@ -7,7 +7,9 @@ export interface BootstrapTestArgs extends Omit<BootstrapClientArgs, 'ioc'> {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export class BootstrapTest {
|
|
10
|
-
static async main(
|
|
10
|
+
public static async main(
|
|
11
|
+
args: BootstrapTestArgs
|
|
12
|
+
): Promise<BootstrapClientArgs> {
|
|
11
13
|
const result = await BootstrapClient.main({ ...args, ioc: testIOC });
|
|
12
14
|
return result;
|
|
13
15
|
}
|
|
@@ -2,17 +2,17 @@ import { name, version } from '../../package.json';
|
|
|
2
2
|
import type { EnvConfigInterface } from '@qlover/corekit-bridge';
|
|
3
3
|
|
|
4
4
|
export class MockAppConfig implements EnvConfigInterface {
|
|
5
|
-
appName = name;
|
|
5
|
+
public appName = name;
|
|
6
6
|
|
|
7
|
-
appVersion = version;
|
|
7
|
+
public appVersion = version;
|
|
8
8
|
|
|
9
|
-
env: string = 'test';
|
|
9
|
+
public env: string = 'test';
|
|
10
10
|
|
|
11
|
-
userTokenStorageKey = '__fe_user_token__';
|
|
11
|
+
public userTokenStorageKey = '__fe_user_token__';
|
|
12
12
|
|
|
13
|
-
userInfoStorageKey = '__fe_user_info__';
|
|
13
|
+
public userInfoStorageKey = '__fe_user_info__';
|
|
14
14
|
|
|
15
|
-
openAiModels = [
|
|
15
|
+
public openAiModels = [
|
|
16
16
|
'gpt-4o-mini',
|
|
17
17
|
'gpt-3.5-turbo',
|
|
18
18
|
'gpt-3.5-turbo-2',
|
|
@@ -20,29 +20,29 @@ export class MockAppConfig implements EnvConfigInterface {
|
|
|
20
20
|
'gpt-4-32k'
|
|
21
21
|
];
|
|
22
22
|
|
|
23
|
-
openAiBaseUrl = '';
|
|
23
|
+
public openAiBaseUrl = '';
|
|
24
24
|
|
|
25
|
-
openAiToken = '';
|
|
25
|
+
public openAiToken = '';
|
|
26
26
|
|
|
27
|
-
openAiTokenPrefix = '';
|
|
27
|
+
public openAiTokenPrefix = '';
|
|
28
28
|
|
|
29
|
-
openAiRequireToken = true;
|
|
29
|
+
public openAiRequireToken = true;
|
|
30
30
|
|
|
31
|
-
loginUser = '';
|
|
31
|
+
public loginUser = '';
|
|
32
32
|
|
|
33
|
-
loginPassword = '';
|
|
33
|
+
public loginPassword = '';
|
|
34
34
|
|
|
35
|
-
feApiBaseUrl = '';
|
|
35
|
+
public feApiBaseUrl = '';
|
|
36
36
|
|
|
37
|
-
userApiBaseUrl = '';
|
|
37
|
+
public userApiBaseUrl = '';
|
|
38
38
|
|
|
39
|
-
aiApiBaseUrl = 'https://api.openai.com/v1';
|
|
39
|
+
public aiApiBaseUrl = 'https://api.openai.com/v1';
|
|
40
40
|
|
|
41
|
-
aiApiToken = '';
|
|
41
|
+
public aiApiToken = '';
|
|
42
42
|
|
|
43
|
-
aiApiTokenPrefix = 'Bearer';
|
|
43
|
+
public aiApiTokenPrefix = 'Bearer';
|
|
44
44
|
|
|
45
|
-
aiApiRequireToken = true;
|
|
45
|
+
public aiApiRequireToken = true;
|
|
46
46
|
|
|
47
|
-
bootHref = '';
|
|
47
|
+
public bootHref = '';
|
|
48
48
|
}
|
|
@@ -5,12 +5,12 @@ import type { AntdStaticApiInterface } from '@brain-toolkit/antd-theme-override/
|
|
|
5
5
|
export class MockDialogHandler
|
|
6
6
|
implements InteractionHubInterface, AntdStaticApiInterface
|
|
7
7
|
{
|
|
8
|
-
setMessage = vi.fn();
|
|
9
|
-
setModal = vi.fn();
|
|
10
|
-
setNotification = vi.fn();
|
|
11
|
-
success = vi.fn();
|
|
12
|
-
error = vi.fn();
|
|
13
|
-
info = vi.fn();
|
|
14
|
-
warn = vi.fn();
|
|
15
|
-
confirm = vi.fn();
|
|
8
|
+
public setMessage = vi.fn();
|
|
9
|
+
public setModal = vi.fn();
|
|
10
|
+
public setNotification = vi.fn();
|
|
11
|
+
public success = vi.fn();
|
|
12
|
+
public error = vi.fn();
|
|
13
|
+
public info = vi.fn();
|
|
14
|
+
public warn = vi.fn();
|
|
15
|
+
public confirm = vi.fn();
|
|
16
16
|
}
|
|
@@ -2,13 +2,13 @@ import { vi } from 'vitest';
|
|
|
2
2
|
import type { LoggerInterface } from '@qlover/logger';
|
|
3
3
|
|
|
4
4
|
export class MockLogger implements LoggerInterface {
|
|
5
|
-
info = vi.fn();
|
|
6
|
-
error = vi.fn();
|
|
7
|
-
debug = vi.fn();
|
|
8
|
-
warn = vi.fn();
|
|
9
|
-
trace = vi.fn();
|
|
10
|
-
log = vi.fn();
|
|
11
|
-
fatal = vi.fn();
|
|
12
|
-
addAppender = vi.fn();
|
|
13
|
-
context = vi.fn();
|
|
5
|
+
public info = vi.fn();
|
|
6
|
+
public error = vi.fn();
|
|
7
|
+
public debug = vi.fn();
|
|
8
|
+
public warn = vi.fn();
|
|
9
|
+
public trace = vi.fn();
|
|
10
|
+
public log = vi.fn();
|
|
11
|
+
public fatal = vi.fn();
|
|
12
|
+
public addAppender = vi.fn();
|
|
13
|
+
public context = vi.fn();
|
|
14
14
|
}
|
|
@@ -41,7 +41,7 @@ export function TestBootstrapsProvider({
|
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
return (
|
|
44
|
-
<IOCContext.Provider
|
|
44
|
+
<IOCContext.Provider value={IOC}>
|
|
45
45
|
<TestRouter
|
|
46
46
|
initialEntries={routerInitialEntries}
|
|
47
47
|
initialIndex={routerInitialIndex}
|
|
@@ -24,13 +24,13 @@ const resources: Record<string, Record<string, Record<string, string>>> = {
|
|
|
24
24
|
* Implements the backend interface to avoid network requests
|
|
25
25
|
*/
|
|
26
26
|
export class MockHttpBackend {
|
|
27
|
-
type = 'backend';
|
|
27
|
+
public type = 'backend';
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* Initialize the backend
|
|
31
31
|
* This is called by i18next when .use() is called
|
|
32
32
|
*/
|
|
33
|
-
init(
|
|
33
|
+
public init(
|
|
34
34
|
_services: unknown,
|
|
35
35
|
_backendOptions: unknown,
|
|
36
36
|
_i18nextOptions: unknown,
|
|
@@ -60,7 +60,7 @@ export class MockHttpBackend {
|
|
|
60
60
|
* Read translation data for a language and namespace
|
|
61
61
|
* This method is called by i18next to load translations
|
|
62
62
|
*/
|
|
63
|
-
read(
|
|
63
|
+
public read(
|
|
64
64
|
language: string,
|
|
65
65
|
namespace: string,
|
|
66
66
|
callback: (error: Error | null, data?: Record<string, string>) => void
|
|
@@ -82,7 +82,7 @@ export class MockHttpBackend {
|
|
|
82
82
|
* Load URL - called by i18next-http-backend to load from URL
|
|
83
83
|
* We intercept this and return data from memory instead
|
|
84
84
|
*/
|
|
85
|
-
loadUrl(
|
|
85
|
+
public loadUrl(
|
|
86
86
|
_url: string,
|
|
87
87
|
callback: (error: Error | null, data?: Record<string, string>) => void
|
|
88
88
|
): void {
|
|
@@ -104,7 +104,7 @@ export class MockHttpBackend {
|
|
|
104
104
|
/**
|
|
105
105
|
* Create - not used in our mock
|
|
106
106
|
*/
|
|
107
|
-
create(): void {
|
|
107
|
+
public create(): void {
|
|
108
108
|
// No-op
|
|
109
109
|
}
|
|
110
110
|
}
|
|
@@ -11,22 +11,26 @@ import type {
|
|
|
11
11
|
IOCFunctionInterface
|
|
12
12
|
} from '@qlover/corekit-bridge';
|
|
13
13
|
|
|
14
|
-
export class TestIOC
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
export class TestIOC implements IOCInterface<
|
|
15
|
+
IOCIdentifierMap,
|
|
16
|
+
IOCContainerInterface
|
|
17
|
+
> {
|
|
17
18
|
protected ioc: IOCFunctionInterface<
|
|
18
19
|
IOCIdentifierMap,
|
|
19
20
|
IOCContainerInterface
|
|
20
21
|
> | null = null;
|
|
21
22
|
|
|
22
|
-
getIoc(): IOCFunctionInterface<
|
|
23
|
+
public getIoc(): IOCFunctionInterface<
|
|
23
24
|
IOCIdentifierMap,
|
|
24
25
|
IOCContainerInterface
|
|
25
26
|
> | null {
|
|
26
27
|
return this.ioc;
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
|
|
30
|
+
/**
|
|
31
|
+
* @override
|
|
32
|
+
*/
|
|
33
|
+
public create(
|
|
30
34
|
options: IocRegisterOptions
|
|
31
35
|
): IOCFunctionInterface<IOCIdentifierMap, IOCContainerInterface> {
|
|
32
36
|
if (this.ioc) {
|
|
@@ -18,9 +18,10 @@ import type {
|
|
|
18
18
|
/**
|
|
19
19
|
* TestIOCRegister - Register mock services for testing
|
|
20
20
|
*/
|
|
21
|
-
export class TestIOCRegister
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
export class TestIOCRegister implements IOCRegisterInterface<
|
|
22
|
+
IOCContainerInterface,
|
|
23
|
+
IocRegisterOptions
|
|
24
|
+
> {
|
|
24
25
|
constructor(protected options: IocRegisterOptions) {}
|
|
25
26
|
|
|
26
27
|
protected registerGlobals(ioc: IOCContainerInterface): void {
|
|
@@ -39,7 +40,10 @@ export class TestIOCRegister
|
|
|
39
40
|
ioc.bind(I.CookieStorage, globals.cookieStorage);
|
|
40
41
|
}
|
|
41
42
|
|
|
42
|
-
|
|
43
|
+
/**
|
|
44
|
+
* @override
|
|
45
|
+
*/
|
|
46
|
+
public register(
|
|
43
47
|
ioc: IOCContainerInterface,
|
|
44
48
|
_manager: IOCManagerInterface<IOCContainerInterface>
|
|
45
49
|
): void {
|
|
@@ -19,10 +19,10 @@ class MockI18nService extends I18nService {
|
|
|
19
19
|
super('/');
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
t = vi.fn((key: string) => key);
|
|
23
|
-
changeLanguage = vi.fn();
|
|
24
|
-
changeLoading = vi.fn();
|
|
25
|
-
onBefore = vi.fn();
|
|
22
|
+
public t = vi.fn((key: string) => key);
|
|
23
|
+
public changeLanguage = vi.fn();
|
|
24
|
+
public changeLoading = vi.fn();
|
|
25
|
+
public onBefore = vi.fn();
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
describe('I18nKeyErrorPlugin', () => {
|
|
@@ -86,7 +86,7 @@ describe('InversifyContainer', () => {
|
|
|
86
86
|
it('should auto bind injectable class', () => {
|
|
87
87
|
@injectable()
|
|
88
88
|
class TestService {
|
|
89
|
-
getValue(): string {
|
|
89
|
+
public getValue(): string {
|
|
90
90
|
return 'test';
|
|
91
91
|
}
|
|
92
92
|
}
|
|
@@ -100,7 +100,7 @@ describe('InversifyContainer', () => {
|
|
|
100
100
|
it('should handle manual dependency injection', () => {
|
|
101
101
|
@injectable()
|
|
102
102
|
class ServiceA {
|
|
103
|
-
getValue(): string {
|
|
103
|
+
public getValue(): string {
|
|
104
104
|
return 'A';
|
|
105
105
|
}
|
|
106
106
|
}
|
|
@@ -109,7 +109,7 @@ describe('InversifyContainer', () => {
|
|
|
109
109
|
class ServiceB {
|
|
110
110
|
constructor(private serviceA: ServiceA) {}
|
|
111
111
|
|
|
112
|
-
getValueWithA(): string {
|
|
112
|
+
public getValueWithA(): string {
|
|
113
113
|
return `B with ${this.serviceA.getValue()}`;
|
|
114
114
|
}
|
|
115
115
|
}
|
|
@@ -129,7 +129,7 @@ describe('InversifyContainer', () => {
|
|
|
129
129
|
@injectable()
|
|
130
130
|
class TestService {
|
|
131
131
|
private count = 0;
|
|
132
|
-
increment(): number {
|
|
132
|
+
public increment(): number {
|
|
133
133
|
return ++this.count;
|
|
134
134
|
}
|
|
135
135
|
}
|
|
@@ -147,7 +147,7 @@ describe('InversifyContainer', () => {
|
|
|
147
147
|
class ComplexService {
|
|
148
148
|
private state = { count: 0 };
|
|
149
149
|
|
|
150
|
-
updateState(): { count: number } {
|
|
150
|
+
public updateState(): { count: number } {
|
|
151
151
|
this.state.count++;
|
|
152
152
|
return this.state;
|
|
153
153
|
}
|
|
@@ -37,7 +37,7 @@ describe('BootstrapClient', () => {
|
|
|
37
37
|
const mockRegister = vi.fn().mockReturnValue([testBootstrapPlugin]);
|
|
38
38
|
|
|
39
39
|
class TestBootstrapsRegistry implements BootstrapsRegistryInterface {
|
|
40
|
-
register = mockRegister;
|
|
40
|
+
public register = mockRegister;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
const args: BootstrapClientArgs = {
|
|
@@ -70,7 +70,7 @@ describe('BootstrapClient', () => {
|
|
|
70
70
|
);
|
|
71
71
|
|
|
72
72
|
class TestBootstrapsRegistry implements BootstrapsRegistryInterface {
|
|
73
|
-
register = mockRegister;
|
|
73
|
+
public register = mockRegister;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
const args: BootstrapClientArgs = {
|
|
@@ -114,7 +114,7 @@ describe('BootstrapClient', () => {
|
|
|
114
114
|
);
|
|
115
115
|
|
|
116
116
|
class TestBootstrapsRegistry implements BootstrapsRegistryInterface {
|
|
117
|
-
register = mockRegister;
|
|
117
|
+
public register = mockRegister;
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
const args: BootstrapClientArgs = {
|