@qlover/create-app 1.0.0 → 1.0.2

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.
Files changed (85) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/index.cjs +1 -1
  3. package/dist/index.js +1 -1
  4. package/dist/templates/next-app/config/Identifier/api.ts +7 -0
  5. package/dist/templates/next-app/config/Identifier/pages/page.register.ts +8 -0
  6. package/dist/templates/next-app/config/common.ts +1 -1
  7. package/dist/templates/next-app/config/i18n/HomeI18n.ts +2 -0
  8. package/dist/templates/next-app/config/i18n/register18n.ts +2 -1
  9. package/dist/templates/next-app/config/route.ts +9 -0
  10. package/dist/templates/next-app/migrations/schema/UserSchema.ts +1 -1
  11. package/dist/templates/next-app/next.config.ts +5 -4
  12. package/dist/templates/next-app/package.json +7 -8
  13. package/dist/templates/next-app/public/locales/en.json +4 -1
  14. package/dist/templates/next-app/public/locales/zh.json +4 -1
  15. package/dist/templates/next-app/src/app/[locale]/auth/layout.tsx +18 -0
  16. package/dist/templates/next-app/src/app/[locale]/{login → auth/login}/LoginForm.tsx +2 -1
  17. package/dist/templates/next-app/src/app/[locale]/{login → auth/login}/page.tsx +4 -5
  18. package/dist/templates/next-app/src/app/[locale]/auth/page.tsx +8 -0
  19. package/dist/templates/next-app/src/app/[locale]/{register → auth/register}/RegisterForm.tsx +24 -3
  20. package/dist/templates/next-app/src/app/[locale]/{register → auth/register}/page.tsx +4 -5
  21. package/dist/templates/next-app/src/app/[locale]/page.tsx +18 -45
  22. package/dist/templates/next-app/src/app/api/ai/completions/route.ts +13 -13
  23. package/dist/templates/next-app/src/app/api/auth/callback/route.ts +11 -0
  24. package/dist/templates/next-app/src/app/api/callback/route.ts +49 -0
  25. package/dist/templates/next-app/src/base/cases/AppConfig.ts +2 -0
  26. package/dist/templates/next-app/src/base/cases/DialogErrorPlugin.ts +3 -6
  27. package/dist/templates/next-app/src/base/cases/DialogHandler.ts +0 -1
  28. package/dist/templates/next-app/src/base/cases/RequestEncryptPlugin.ts +13 -15
  29. package/dist/templates/next-app/src/base/cases/RouterService.ts +2 -7
  30. package/dist/templates/next-app/src/base/cases/StringEncryptor.ts +0 -6
  31. package/dist/templates/next-app/src/base/cases/TranslateI18nUtil.ts +53 -0
  32. package/dist/templates/next-app/src/base/cases/ZodColumnBuilder.ts +0 -10
  33. package/dist/templates/next-app/src/base/port/AdminLayoutInterface.ts +0 -3
  34. package/dist/templates/next-app/src/base/port/AppUserApiInterface.ts +1 -1
  35. package/dist/templates/next-app/src/base/port/I18nServiceInterface.ts +0 -18
  36. package/dist/templates/next-app/src/base/port/UserServiceInterface.ts +10 -5
  37. package/dist/templates/next-app/src/base/services/{appApi/AppApiRequester.ts → AppApiRequester.ts} +16 -11
  38. package/dist/templates/next-app/src/base/services/AppUserGateway.ts +110 -0
  39. package/dist/templates/next-app/src/base/services/I18nService.ts +1 -7
  40. package/dist/templates/next-app/src/base/services/ResourceService.ts +1 -4
  41. package/dist/templates/next-app/src/base/services/UserService.ts +28 -17
  42. package/dist/templates/next-app/src/base/services/adminApi/AdminLocalesApi.ts +5 -7
  43. package/dist/templates/next-app/src/base/services/adminApi/AdminUserApi.ts +4 -3
  44. package/dist/templates/next-app/src/base/services/appApi/AppApiPlugin.ts +24 -16
  45. package/dist/templates/next-app/src/base/services/appApi/AppUserApiBootstrap.ts +2 -5
  46. package/dist/templates/next-app/src/core/bootstraps/BootstrapServer.ts +15 -18
  47. package/dist/templates/next-app/src/core/clientIoc/ClientIOCRegister.ts +0 -5
  48. package/dist/templates/next-app/src/core/globals.ts +1 -0
  49. package/dist/templates/next-app/src/core/serverIoc/ServerIOCRegister.ts +2 -8
  50. package/dist/templates/next-app/src/i18n/routing.ts +8 -3
  51. package/dist/templates/next-app/src/lib/supabase/client.ts +8 -0
  52. package/dist/templates/next-app/src/lib/supabase/conts.ts +2 -0
  53. package/dist/templates/next-app/src/lib/supabase/proxy.ts +84 -0
  54. package/dist/templates/next-app/src/lib/supabase/server.ts +38 -0
  55. package/dist/templates/next-app/src/proxy.ts +8 -1
  56. package/dist/templates/next-app/src/server/AppPageRouteParams.ts +5 -2
  57. package/dist/templates/next-app/src/server/NextApiServer.ts +2 -9
  58. package/dist/templates/next-app/src/server/PagesRouteParams.ts +3 -4
  59. package/dist/templates/next-app/src/server/ServerAuth.ts +18 -12
  60. package/dist/templates/next-app/src/server/SupabaseBridge.ts +66 -59
  61. package/dist/templates/next-app/src/server/controllers/UserController.ts +7 -2
  62. package/dist/templates/next-app/src/server/port/ServerAuthInterface.ts +4 -0
  63. package/dist/templates/next-app/src/server/port/ServerInterface.ts +2 -1
  64. package/dist/templates/next-app/src/server/port/UserServiceInterface.ts +7 -1
  65. package/dist/templates/next-app/src/server/repositorys/LocalesRepository.ts +0 -3
  66. package/dist/templates/next-app/src/server/repositorys/UserRepository.ts +0 -3
  67. package/dist/templates/next-app/src/server/services/UserService.ts +71 -51
  68. package/dist/templates/next-app/src/server/validators/LocalesValidator.ts +0 -3
  69. package/dist/templates/next-app/src/server/validators/LoginValidator.ts +0 -6
  70. package/dist/templates/next-app/src/server/validators/SignupVerifyValidator.ts +68 -0
  71. package/dist/templates/next-app/src/uikit/components/BootstrapsProvider.tsx +3 -3
  72. package/dist/templates/next-app/src/uikit/components/localesImportButton/LocalesImportEvent.ts +0 -6
  73. package/dist/templates/next-app/src/uikit/components-app/AdminButton.tsx +29 -0
  74. package/dist/templates/next-app/src/uikit/components-app/AppRoutePage.tsx +21 -28
  75. package/dist/templates/next-app/src/uikit/components-app/AuthButton.tsx +20 -0
  76. package/dist/templates/next-app/src/uikit/hook/useI18nInterface.ts +2 -2
  77. package/dist/templates/next-app/src/uikit/hook/useWarnTranslations.ts +3 -17
  78. package/dist/templates/next-app/src/uikit/utils/getHashParams.ts +8 -0
  79. package/dist/templates/next-app/src/uikit/utils/getHashVerifyEmailParams.ts +42 -0
  80. package/package.json +1 -1
  81. package/dist/templates/next-app/src/base/cases/TranslateI18nInterface.ts +0 -25
  82. package/dist/templates/next-app/src/base/cases/UserServiceApi.ts +0 -78
  83. package/dist/templates/next-app/src/base/services/adminApi/AdminApiRequester.ts +0 -25
  84. package/dist/templates/next-app/src/base/services/appApi/AppUserApi.ts +0 -78
  85. package/dist/templates/next-app/src/server/port/UserControllerInerface.ts +0 -8
@@ -13,9 +13,9 @@ import type { I18nServiceInterface } from '../port/I18nServiceInterface';
13
13
  import type { UIDialogInterface } from '@qlover/corekit-bridge';
14
14
 
15
15
  @injectable()
16
- export class DialogErrorPlugin
17
- implements LifecyclePluginInterface<ExecutorContextInterface<unknown>>
18
- {
16
+ export class DialogErrorPlugin implements LifecyclePluginInterface<
17
+ ExecutorContextInterface<unknown>
18
+ > {
19
19
  public readonly pluginName = 'DialogErrorPlugin';
20
20
 
21
21
  constructor(
@@ -51,9 +51,6 @@ export class DialogErrorPlugin
51
51
  }
52
52
  }
53
53
 
54
- /**
55
- * @override
56
- */
57
54
  protected isI18nMessage(message: string): boolean {
58
55
  return i18nKeySchema.safeParse(message).success;
59
56
  }
@@ -69,7 +69,6 @@ export class DialogHandler
69
69
  /**
70
70
  * Formats error message from various error types
71
71
 
72
- * @override
73
72
  */
74
73
  protected formatErrorMessage(error: unknown): string {
75
74
  if (error instanceof Error) return error.message;
@@ -6,8 +6,9 @@ import type {
6
6
  EncryptorInterface
7
7
  } from '@qlover/fe-corekit';
8
8
 
9
- export interface RequestEncryptPluginProps<Request = unknown>
10
- extends RequestAdapterConfig<Request> {
9
+ export interface RequestEncryptPluginProps<
10
+ Request = unknown
11
+ > extends RequestAdapterConfig<Request> {
11
12
  /**
12
13
  * 加密密码在 HTTP 请求中
13
14
  *
@@ -18,12 +19,9 @@ export interface RequestEncryptPluginProps<Request = unknown>
18
19
  encryptProps?: string[] | string;
19
20
  }
20
21
 
21
- export class RequestEncryptPlugin
22
- implements
23
- LifecyclePluginInterface<
24
- ExecutorContextInterface<RequestEncryptPluginProps>
25
- >
26
- {
22
+ export class RequestEncryptPlugin implements LifecyclePluginInterface<
23
+ ExecutorContextInterface<RequestEncryptPluginProps>
24
+ > {
27
25
  public readonly pluginName = 'RequestEncryptPlugin';
28
26
 
29
27
  constructor(protected encryptor: EncryptorInterface<string, string>) {}
@@ -41,16 +39,16 @@ export class RequestEncryptPlugin
41
39
  isObject(context.parameters.data) &&
42
40
  encryptProps
43
41
  ) {
44
- context.parameters.data = this.encryptData(
45
- clone(context.parameters.data),
46
- encryptProps
47
- );
42
+ context.setParameters({
43
+ ...context.parameters,
44
+ data: {
45
+ ...context.parameters.data,
46
+ ...this.encryptData(clone(context.parameters.data), encryptProps)
47
+ }
48
+ });
48
49
  }
49
50
  }
50
51
 
51
- /**
52
- * @override
53
- */
54
52
  protected encryptData<T extends object>(
55
53
  data: T,
56
54
  encryptProps?: string | string[]
@@ -1,4 +1,5 @@
1
1
  import { inject, injectable } from 'inversify';
2
+ import { ROUTE_LOGIN } from '@config/route';
2
3
  import { NavigateBridge } from './NavigateBridge';
3
4
  import type { RouterInterface, RouterPathname } from '../port/RouterInterface';
4
5
  import type { UIBridgeInterface } from '@qlover/corekit-bridge';
@@ -27,16 +28,10 @@ export class RouterService implements RouterInterface {
27
28
  this.goto('/');
28
29
  }
29
30
 
30
- /**
31
- * @override
32
- */
33
31
  public gotoLogin(): void {
34
- this.goto('/login');
32
+ this.goto(ROUTE_LOGIN);
35
33
  }
36
34
 
37
- /**
38
- * @override
39
- */
40
35
  public replaceHome(): void {
41
36
  this.uiBridge.getUIBridge()?.replace('/');
42
37
  }
@@ -18,9 +18,6 @@ export class StringEncryptor implements EncryptorInterface<string, string> {
18
18
  this.key = appConfig.stringEncryptorKey;
19
19
  }
20
20
 
21
- /**
22
- * @override
23
- */
24
21
  protected encryptWithKey(str: string, key: string): string {
25
22
  const result = [];
26
23
  for (let i = 0; i < str.length; i++) {
@@ -34,9 +31,6 @@ export class StringEncryptor implements EncryptorInterface<string, string> {
34
31
  return result.join('');
35
32
  }
36
33
 
37
- /**
38
- * @override
39
- */
40
34
  protected decryptWithKey(str: string, key: string): string {
41
35
  const result = [];
42
36
  for (let i = 0; i < str.length; i++) {
@@ -0,0 +1,53 @@
1
+ import { logger } from '@/core/globals';
2
+ import { i18nWarnMissingTranslation } from '@config/common';
3
+ import type { PageI18nInterface } from '@config/i18n';
4
+ import type { Formats, useTranslations } from 'next-intl';
5
+
6
+ /**
7
+ * Translate I18n Interface tools class
8
+ *
9
+ * @param i18nInterface - The i18n interface to translate
10
+ * @param t - The translations function
11
+ * @returns The translated i18n interface
12
+ */
13
+ export class TranslateI18nUtil {
14
+ public static translate<T extends PageI18nInterface | Record<string, string>>(
15
+ source: T,
16
+ t: ReturnType<typeof useTranslations>
17
+ ): T {
18
+ return Object.fromEntries(
19
+ Object.entries(source).map(([key, value]) => {
20
+ if (typeof value === 'string') {
21
+ return [key, t(value)];
22
+ }
23
+ return [key, value];
24
+ })
25
+ ) as T;
26
+ }
27
+
28
+ public static overrideTranslateT(
29
+ t: ReturnType<typeof useTranslations>
30
+ ): ReturnType<typeof useTranslations> {
31
+ return function ot(
32
+ key: string,
33
+ values?: Record<string, string | number | Date> | undefined,
34
+ formats?: Formats | undefined
35
+ ) {
36
+ try {
37
+ if (!i18nWarnMissingTranslation) {
38
+ return t(key, values, formats);
39
+ }
40
+
41
+ if (t.has(key)) {
42
+ return t(key, values, formats);
43
+ }
44
+
45
+ logger.warn(`[i18n] Missing translation: ${key}`);
46
+ } catch (e) {
47
+ logger.error(`[i18n] Error translation: ${key}`, String(e));
48
+ return t.raw(key);
49
+ }
50
+ return key;
51
+ } as ReturnType<typeof useTranslations>;
52
+ }
53
+ }
@@ -70,9 +70,6 @@ export class ZodColumnBuilder<
70
70
  ];
71
71
  }
72
72
 
73
- /**
74
- * @override
75
- */
76
73
  public zod2BaseOption(
77
74
  key: string,
78
75
  zod: ZodType
@@ -99,9 +96,6 @@ export class ZodColumnBuilder<
99
96
  };
100
97
  }
101
98
 
102
- /**
103
- * @override
104
- */
105
99
  public getBaseOptions(input: Input): OptionMap<Value, Input> {
106
100
  return Object.entries(input.shape).reduce(
107
101
  (acc, [key, zod]) => {
@@ -129,9 +123,6 @@ export class ZodColumnBuilder<
129
123
  return this;
130
124
  }
131
125
 
132
- /**
133
- * @override
134
- */
135
126
  public render<K extends keyof Input['shape']>(
136
127
  key: K,
137
128
  render: (
@@ -146,7 +137,6 @@ export class ZodColumnBuilder<
146
137
 
147
138
  /**
148
139
  * Translate all i18n keys in options to actual text
149
- * @override
150
140
  * @param t - Translation function from next-intl
151
141
  * @returns this for chaining
152
142
  */
@@ -22,8 +22,5 @@ export abstract class AdminLayoutInterface extends StoreInterface<AdminPageState
22
22
  navItems: (state: AdminPageState) => state.navItems
23
23
  };
24
24
 
25
- /**
26
- * @override
27
- */
28
25
  public abstract toggleSidebar(): void;
29
26
  }
@@ -1,6 +1,6 @@
1
1
  import type { LoginValidatorData } from '@/server/validators/LoginValidator';
2
2
  import type { UserSchema } from '@migrations/schema/UserSchema';
3
- import type { AppApiTransaction } from '../services/appApi/AppApiRequester';
3
+ import type { AppApiTransaction } from '../services/AppApiRequester';
4
4
 
5
5
  export type UserApiLoginTransaction = AppApiTransaction<
6
6
  LoginValidatorData,
@@ -14,30 +14,12 @@ export class I18nServiceState implements StoreStateInterface {
14
14
  constructor(public language: I18nServiceLocale) {}
15
15
  }
16
16
  export abstract class I18nServiceInterface extends StoreInterface<I18nServiceState> {
17
- /**
18
- * @override
19
- */
20
17
  public abstract t(key: string, params?: Record<string, unknown>): string;
21
- /**
22
- * @override
23
- */
24
18
  public abstract changeLanguage(language: I18nServiceLocale): Promise<void>;
25
- /**
26
- * @override
27
- */
28
19
  public abstract changeLoading(loading: boolean): void;
29
- /**
30
- * @override
31
- */
32
20
  public abstract getCurrentLanguage(): Promise<I18nServiceLocale>;
33
- /**
34
- * @override
35
- */
36
21
  public abstract isValidLanguage(
37
22
  language: string
38
23
  ): language is I18nServiceLocale;
39
- /**
40
- * @override
41
- */
42
24
  public abstract getSupportedLanguages(): I18nServiceLocale[];
43
25
  }
@@ -1,5 +1,8 @@
1
1
  import type { UserCredential, UserSchema } from '@migrations/schema/UserSchema';
2
- import type { UserService as CorekitBridgeUserServiceInterface } from '@qlover/corekit-bridge';
2
+ import type {
3
+ UserService as CorekitBridgeUserServiceInterface,
4
+ UserServiceGateway
5
+ } from '@qlover/corekit-bridge';
3
6
 
4
7
  export interface UserServiceInterface extends CorekitBridgeUserServiceInterface<
5
8
  UserSchema,
@@ -13,8 +16,10 @@ export interface UserServiceInterface extends CorekitBridgeUserServiceInterface<
13
16
  * This is a extends method from the corekit-bridge UserServiceInterface.
14
17
  */
15
18
  getToken(): string;
16
-
17
- isUserInfo(value: unknown): value is UserSchema;
18
-
19
- isUserCredential(value: unknown): value is UserCredential;
20
19
  }
20
+
21
+ export interface UserServiceGatewayInterface extends UserServiceGateway<
22
+ UserSchema,
23
+ UserCredential,
24
+ {}
25
+ > {}
@@ -1,4 +1,8 @@
1
- import { LifecycleExecutor, RequestAdapterFetch, RequestExecutor } from '@qlover/fe-corekit';
1
+ import {
2
+ LifecycleExecutor,
3
+ RequestAdapterFetch,
4
+ RequestExecutor
5
+ } from '@qlover/fe-corekit';
2
6
  import { injectable } from 'inversify';
3
7
  import type { RequestEncryptPluginProps } from '@/base/cases/RequestEncryptPlugin';
4
8
  import type { AppApiResult } from '@/base/port/AppApiInterface';
@@ -14,11 +18,9 @@ export interface RequestTransactionInterface<Request, Response> {
14
18
  }
15
19
 
16
20
  export interface AppApiConfig<Request = unknown>
17
- extends RequestAdapterConfig<Request>,
18
- RequestEncryptPluginProps<Request> {}
21
+ extends RequestAdapterConfig<Request>, RequestEncryptPluginProps<Request> {}
19
22
 
20
- export interface AppApiRequesterContext
21
- extends ExecutorContextInterface<AppApiConfig> {}
23
+ export interface AppApiRequesterContext extends ExecutorContextInterface<AppApiConfig> {}
22
24
 
23
25
  /**
24
26
  * UserApiResponse
@@ -37,11 +39,13 @@ export type AppApiResponse<
37
39
  /**
38
40
  * UserApi common transaction
39
41
  */
40
- export interface AppApiTransaction<Request = unknown, Response = unknown>
41
- extends RequestTransactionInterface<
42
- AppApiConfig<Request>,
43
- AppApiResponse<Request, Response>
44
- > {
42
+ export interface AppApiTransaction<
43
+ Request = unknown,
44
+ Response = unknown
45
+ > extends RequestTransactionInterface<
46
+ AppApiConfig<Request>,
47
+ AppApiResponse<Request, Response>
48
+ > {
45
49
  data: AppApiConfig<Request>['data'];
46
50
  }
47
51
 
@@ -53,7 +57,8 @@ export class AppApiRequester extends RequestExecutor<
53
57
  constructor() {
54
58
  super(
55
59
  new RequestAdapterFetch({
56
- baseURL: '/api',
60
+ // TODO: ReqeustPlugin build url 最后需要带上/
61
+ baseURL: '/api/',
57
62
  responseType: 'json'
58
63
  }),
59
64
  new LifecycleExecutor()
@@ -0,0 +1,110 @@
1
+ import { HttpMethods, RequestExecutor } from '@qlover/fe-corekit';
2
+ import { inject, injectable } from 'inversify';
3
+ import type {
4
+ UserApiLoginTransaction,
5
+ UserApiLogoutTransaction,
6
+ UserApiRegisterTransaction
7
+ } from '@/base/port/AppUserApiInterface';
8
+ import { UserCredential, UserSchema } from '@migrations/schema/UserSchema';
9
+ import {
10
+ AppApiConfig,
11
+ AppApiRequester,
12
+ AppApiRequesterContext
13
+ } from './AppApiRequester';
14
+ import { UserServiceGatewayInterface } from '../port/UserServiceInterface';
15
+ import type { LoginParams } from '@qlover/corekit-bridge';
16
+
17
+ /**
18
+ * UserApi
19
+ *
20
+ * @description
21
+ * UserApi is a client for the user API.
22
+ *
23
+ */
24
+ @injectable()
25
+ export class AppUserGateway implements UserServiceGatewayInterface {
26
+ constructor(
27
+ @inject(AppApiRequester)
28
+ protected client: RequestExecutor<AppApiConfig, AppApiRequesterContext>
29
+ ) {}
30
+
31
+ /**
32
+ * @override
33
+ */
34
+ public getUserInfo(
35
+ _params?: unknown,
36
+ _config?: unknown
37
+ ): Promise<UserSchema | null> {
38
+ throw new Error('Method not implemented.');
39
+ }
40
+ /**
41
+ * @override
42
+ */
43
+ public refreshUserInfo(
44
+ _params?: unknown,
45
+ _config?: {} | undefined
46
+ ): Promise<UserSchema | null> {
47
+ throw new Error('Method not implemented.');
48
+ }
49
+
50
+ /**
51
+ * @override
52
+ */
53
+ public async login(
54
+ params: UserApiLoginTransaction['data'] & LoginParams
55
+ ): Promise<UserCredential> {
56
+ const response = await this.client.request<
57
+ UserApiLoginTransaction['response'],
58
+ UserApiLoginTransaction['request']
59
+ >({
60
+ url: '/user/login',
61
+ method: HttpMethods.POST,
62
+ data: params,
63
+ encryptProps: 'password'
64
+ });
65
+
66
+ if (!response.data.success) {
67
+ throw new Error(response.data.message);
68
+ }
69
+
70
+ return response.data.data as UserCredential;
71
+ }
72
+
73
+ /**
74
+ * @override
75
+ */
76
+ public async register(
77
+ params: UserApiRegisterTransaction['data']
78
+ ): Promise<UserSchema> {
79
+ const response = await this.client.request<
80
+ UserApiRegisterTransaction['response'],
81
+ UserApiRegisterTransaction['request']
82
+ >({
83
+ url: '/user/register',
84
+ method: HttpMethods.POST,
85
+ data: params,
86
+ encryptProps: 'password'
87
+ });
88
+
89
+ if (!response.data.success) {
90
+ throw new Error(response.data.message);
91
+ }
92
+
93
+ return response.data.data as UserSchema;
94
+ }
95
+
96
+ /**
97
+ * @override
98
+ */
99
+ public async logout<R = void>(_params?: unknown): Promise<R> {
100
+ await this.client.request<
101
+ UserApiLogoutTransaction['response'],
102
+ UserApiLogoutTransaction['request']
103
+ >({
104
+ url: '/user/logout',
105
+ method: HttpMethods.POST
106
+ });
107
+
108
+ return undefined as R;
109
+ }
110
+ }
@@ -4,8 +4,8 @@ import {
4
4
  I18nServiceState
5
5
  } from '../port/I18nServiceInterface';
6
6
  import type { I18nServiceLocale } from '../port/I18nServiceInterface';
7
+ import type { BootstrapExecutorPlugin } from '@qlover/corekit-bridge';
7
8
  import type { useTranslations } from 'next-intl';
8
- import { BootstrapExecutorPlugin } from '@qlover/corekit-bridge';
9
9
 
10
10
  type TranslationFunction = ReturnType<typeof useTranslations>;
11
11
 
@@ -21,16 +21,10 @@ export class I18nService
21
21
  super(() => new I18nServiceState(i18nConfig.fallbackLng));
22
22
  }
23
23
 
24
- /**
25
- * @override
26
- */
27
24
  public setPathname(pathname: string): void {
28
25
  this.pathname = pathname;
29
26
  }
30
27
 
31
- /**
32
- * @override
33
- */
34
28
  public setTranslator(translator: TranslationFunction): void {
35
29
  this.translator = translator;
36
30
  }
@@ -6,7 +6,7 @@ import {
6
6
  type ResourceInterface,
7
7
  type ResourceQuery
8
8
  } from '@qlover/corekit-bridge';
9
- import type { AppApiResponse } from '@/base/services/appApi/AppApiRequester';
9
+ import type { AppApiResponse } from '@/base/services/AppApiRequester';
10
10
  import type { PaginationInterface } from '@/server/port/PaginationInterface';
11
11
 
12
12
  export class ResourceService<
@@ -90,9 +90,6 @@ export class ResourceService<
90
90
  return this.store.state.listState.result! as PaginationInterface<T>;
91
91
  }
92
92
 
93
- /**
94
- * @override
95
- */
96
93
  public refresh(): Promise<unknown> {
97
94
  return this.search(this.store.state.searchParams);
98
95
  }
@@ -6,9 +6,15 @@ import {
6
6
  type UserCredential,
7
7
  type UserSchema
8
8
  } from '@migrations/schema/UserSchema';
9
- import { UserServiceApi } from '../cases/UserServiceApi';
10
- import type { UserServiceInterface } from '../port/UserServiceInterface';
11
- import type { UserServiceGateway } from '@qlover/corekit-bridge';
9
+ import { AppUserGateway } from './AppUserGateway';
10
+ import type {
11
+ UserServiceGatewayInterface,
12
+ UserServiceInterface
13
+ } from '../port/UserServiceInterface';
14
+ import type {
15
+ StoreInterface,
16
+ UserStateInterface
17
+ } from '@qlover/corekit-bridge';
12
18
 
13
19
  @injectable()
14
20
  export class UserService
@@ -16,38 +22,43 @@ export class UserService
16
22
  implements UserServiceInterface
17
23
  {
18
24
  constructor(
19
- @inject(UserServiceApi)
20
- userApi: UserServiceGateway<UserSchema, UserCredential>
25
+ @inject(AppUserGateway)
26
+ userApi: UserServiceGatewayInterface
21
27
  ) {
22
- super({
23
- gateway: userApi
24
- // next-js ssr 将 credential 存储在 cookie 中无需存储用户信息到本地
25
- // store: {
26
- // storageKey: appConfig.userInfoKey,
27
- // credentialStorageKey: appConfig.userTokenKey,
28
- // persistUserInfo: true,
29
- // }
30
- });
28
+ super(userApi);
29
+ }
30
+
31
+ /**
32
+ * @override
33
+ */
34
+ public override get gateway(): UserServiceGatewayInterface {
35
+ return super.gateway as UserServiceGatewayInterface;
31
36
  }
32
37
 
33
38
  /**
34
39
  * @override
35
40
  */
36
41
  public getToken(): string {
37
- return this.store.getCredential()?.credential_token ?? '';
42
+ return this.getStore().getCredential()?.credential_token ?? '';
43
+ }
44
+
45
+ public getUIStore(): StoreInterface<
46
+ UserStateInterface<UserSchema, UserCredential>
47
+ > {
48
+ return this.getStore().getStore();
38
49
  }
39
50
 
40
51
  /**
41
52
  * @override
42
53
  */
43
- public isUserInfo(value: unknown): value is UserSchema {
54
+ public isUser(value: unknown): value is UserSchema {
44
55
  return userSchema.safeParse(value).success;
45
56
  }
46
57
 
47
58
  /**
48
59
  * @override
49
60
  */
50
- public isUserCredential(value: unknown): value is UserCredential {
61
+ public isCredential(value: unknown): value is UserCredential {
51
62
  return (
52
63
  isObject(value) &&
53
64
  'credential_token' in value &&
@@ -1,15 +1,16 @@
1
+ import { RequestExecutor } from '@qlover/fe-corekit';
1
2
  import { inject, injectable } from 'inversify';
2
3
  import type { PaginationInterface } from '@/server/port/PaginationInterface';
3
4
  import type { LocalesSchema } from '@migrations/schema/LocalesSchema';
4
5
  import type { LocaleType } from '@config/i18n';
6
+
5
7
  import {
6
8
  AppApiRequester,
9
+ AppApiRequesterContext,
7
10
  type AppApiConfig,
8
11
  type AppApiTransaction
9
- } from '../appApi/AppApiRequester';
12
+ } from '../AppApiRequester';
10
13
  import type { ResourceInterface, ResourceQuery } from '@qlover/corekit-bridge';
11
- import { RequestExecutor } from '@qlover/fe-corekit';
12
- import { AdminApiRequesterContext } from './AdminApiRequester';
13
14
 
14
15
  export type AdminLocalesListTransaction = AppApiTransaction<
15
16
  ResourceQuery,
@@ -25,7 +26,7 @@ export type AdminLocalesUpdateTransaction = AppApiTransaction<
25
26
  export class AdminLocalesApi implements ResourceInterface<LocalesSchema> {
26
27
  constructor(
27
28
  @inject(AppApiRequester)
28
- protected client: RequestExecutor<AppApiConfig, AdminApiRequesterContext>
29
+ protected client: RequestExecutor<AppApiConfig, AppApiRequesterContext>
29
30
  ) {}
30
31
 
31
32
  /**
@@ -87,9 +88,6 @@ export class AdminLocalesApi implements ResourceInterface<LocalesSchema> {
87
88
  });
88
89
  }
89
90
 
90
- /**
91
- * @override
92
- */
93
91
  public import(data: {
94
92
  [key in LocaleType]?: File;
95
93
  }): Promise<unknown> {
@@ -1,3 +1,4 @@
1
+ import { ExecutorContextInterface, RequestExecutor } from '@qlover/fe-corekit';
1
2
  import { inject, injectable } from 'inversify';
2
3
  import type { PaginationInterface } from '@/server/port/PaginationInterface';
3
4
  import type { UserSchema } from '@migrations/schema/UserSchema';
@@ -5,10 +6,10 @@ import {
5
6
  AppApiRequester,
6
7
  type AppApiConfig,
7
8
  type AppApiTransaction
8
- } from '../appApi/AppApiRequester';
9
+ } from '../AppApiRequester';
9
10
  import type { ResourceInterface, ResourceQuery } from '@qlover/corekit-bridge';
10
- import { RequestExecutor } from '@qlover/fe-corekit';
11
- import { AdminApiRequesterContext } from './AdminApiRequester';
11
+
12
+ export interface AdminApiRequesterContext extends ExecutorContextInterface<AppApiConfig> {}
12
13
 
13
14
  export type AdminUserListTransaction = AppApiTransaction<
14
15
  ResourceQuery,