@lark-apaas/fullstack-nestjs-core 1.0.15-alpha.2 → 1.0.15-alpha.21

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/dist/index.d.cts CHANGED
@@ -1,9 +1,14 @@
1
1
  import { NestModule, DynamicModule, MiddlewareConsumer, NestMiddleware } from '@nestjs/common';
2
+ import { HttpClientConfig, PlatformPluginOptions } from '@lark-apaas/http-client';
2
3
  import { NestExpressApplication } from '@nestjs/platform-express';
3
4
  export { DevToolsModule, DevToolsOptions, DevToolsV2Module, DevToolsV2Options } from '@lark-apaas/nestjs-openapi-devtools';
4
5
  import { Request, Response, NextFunction } from 'express';
6
+ import { PlatformHttpClient } from '@lark-apaas/nestjs-common';
5
7
  export * from '@lark-apaas/nestjs-authnpaas';
6
8
  export * from '@lark-apaas/nestjs-datapaas';
9
+ export * from '@lark-apaas/nestjs-observable';
10
+ export * from '@lark-apaas/nestjs-trigger';
11
+ export { CanRole } from '@lark-apaas/nestjs-authzpaas';
7
12
 
8
13
  declare global {
9
14
  namespace Express {
@@ -20,7 +25,11 @@ declare global {
20
25
  appId?: string;
21
26
  loginUrl?: string;
22
27
  userType?: string;
23
- };
28
+ env?: 'preview' | 'runtime';
29
+ userName?: string; // 默认中文名
30
+ userNameEn?: string; // 冗余一份英文名
31
+ userNameI18n?: Record<string, string>; // 带多语的用户名
32
+ },
24
33
  csrfToken?: string;
25
34
  }
26
35
  }
@@ -29,6 +38,13 @@ declare global {
29
38
  /**
30
39
  * PlatformModule 配置选项
31
40
  */
41
+
42
+ interface PlatformHttpClientOptions {
43
+ /** HttpClient 基础配置(超时、headers 等) */
44
+ config?: Omit<HttpClientConfig, 'platform'>;
45
+ /** 平台插件配置(默认启用) */
46
+ platform?: PlatformPluginOptions;
47
+ }
32
48
  interface PlatformModuleOptions {
33
49
  /**
34
50
  * 是否启用 CSRF 保护
@@ -40,6 +56,10 @@ interface PlatformModuleOptions {
40
56
  * 默认: '/api/*'
41
57
  */
42
58
  csrfRoutes?: string | string[];
59
+ /**
60
+ * 平台 HttpClient 配置
61
+ */
62
+ httpClient?: PlatformHttpClientOptions;
43
63
  }
44
64
 
45
65
  declare class PlatformModule implements NestModule {
@@ -51,7 +71,16 @@ declare class PlatformModule implements NestModule {
51
71
  configure(consumer: MiddlewareConsumer): void;
52
72
  }
53
73
 
54
- declare function configureApp(app: NestExpressApplication): Promise<void>;
74
+ /**
75
+ * 初始化应用的基础能力(中间件、过滤器、Swagger 等)。
76
+ *
77
+ * @param app NestExpressApplication 实例
78
+ * @param perms 配置项
79
+ * @param perms.disableSwagger 是否禁用 Swagger(默认:false)
80
+ */
81
+ declare function configureApp(app: NestExpressApplication, perms?: {
82
+ disableSwagger?: boolean;
83
+ }): Promise<void>;
55
84
 
56
85
  interface CsrfTokenOptions {
57
86
  cookieKey?: string;
@@ -81,7 +110,22 @@ declare class UserContextMiddleware implements NestMiddleware {
81
110
  }
82
111
 
83
112
  declare class ViewContextMiddleware implements NestMiddleware {
84
- use(req: Request, res: Response, next: NextFunction): void;
113
+ private readonly client;
114
+ private readonly logger;
115
+ constructor(client: PlatformHttpClient);
116
+ private getAppInfo;
117
+ use(req: Request, res: Response, next: NextFunction): Promise<void>;
118
+ }
119
+
120
+ /**
121
+ * API 404 响应格式
122
+ */
123
+ interface ApiNotFoundResponse {
124
+ code: number;
125
+ message: string;
126
+ error: string;
127
+ path: string;
128
+ timestamp: string;
85
129
  }
86
130
 
87
- export { CsrfMiddleware, CsrfTokenMiddleware, PlatformModule, type PlatformModuleOptions, UserContextMiddleware, ViewContextMiddleware, configureApp };
131
+ export { type ApiNotFoundResponse, CsrfMiddleware, CsrfTokenMiddleware, type PlatformHttpClientOptions, PlatformModule, type PlatformModuleOptions, UserContextMiddleware, ViewContextMiddleware, configureApp };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,14 @@
1
1
  import { NestModule, DynamicModule, MiddlewareConsumer, NestMiddleware } from '@nestjs/common';
2
+ import { HttpClientConfig, PlatformPluginOptions } from '@lark-apaas/http-client';
2
3
  import { NestExpressApplication } from '@nestjs/platform-express';
3
4
  export { DevToolsModule, DevToolsOptions, DevToolsV2Module, DevToolsV2Options } from '@lark-apaas/nestjs-openapi-devtools';
4
5
  import { Request, Response, NextFunction } from 'express';
6
+ import { PlatformHttpClient } from '@lark-apaas/nestjs-common';
5
7
  export * from '@lark-apaas/nestjs-authnpaas';
6
8
  export * from '@lark-apaas/nestjs-datapaas';
9
+ export * from '@lark-apaas/nestjs-observable';
10
+ export * from '@lark-apaas/nestjs-trigger';
11
+ export { CanRole } from '@lark-apaas/nestjs-authzpaas';
7
12
 
8
13
  declare global {
9
14
  namespace Express {
@@ -20,7 +25,11 @@ declare global {
20
25
  appId?: string;
21
26
  loginUrl?: string;
22
27
  userType?: string;
23
- };
28
+ env?: 'preview' | 'runtime';
29
+ userName?: string; // 默认中文名
30
+ userNameEn?: string; // 冗余一份英文名
31
+ userNameI18n?: Record<string, string>; // 带多语的用户名
32
+ },
24
33
  csrfToken?: string;
25
34
  }
26
35
  }
@@ -29,6 +38,13 @@ declare global {
29
38
  /**
30
39
  * PlatformModule 配置选项
31
40
  */
41
+
42
+ interface PlatformHttpClientOptions {
43
+ /** HttpClient 基础配置(超时、headers 等) */
44
+ config?: Omit<HttpClientConfig, 'platform'>;
45
+ /** 平台插件配置(默认启用) */
46
+ platform?: PlatformPluginOptions;
47
+ }
32
48
  interface PlatformModuleOptions {
33
49
  /**
34
50
  * 是否启用 CSRF 保护
@@ -40,6 +56,10 @@ interface PlatformModuleOptions {
40
56
  * 默认: '/api/*'
41
57
  */
42
58
  csrfRoutes?: string | string[];
59
+ /**
60
+ * 平台 HttpClient 配置
61
+ */
62
+ httpClient?: PlatformHttpClientOptions;
43
63
  }
44
64
 
45
65
  declare class PlatformModule implements NestModule {
@@ -51,7 +71,16 @@ declare class PlatformModule implements NestModule {
51
71
  configure(consumer: MiddlewareConsumer): void;
52
72
  }
53
73
 
54
- declare function configureApp(app: NestExpressApplication): Promise<void>;
74
+ /**
75
+ * 初始化应用的基础能力(中间件、过滤器、Swagger 等)。
76
+ *
77
+ * @param app NestExpressApplication 实例
78
+ * @param perms 配置项
79
+ * @param perms.disableSwagger 是否禁用 Swagger(默认:false)
80
+ */
81
+ declare function configureApp(app: NestExpressApplication, perms?: {
82
+ disableSwagger?: boolean;
83
+ }): Promise<void>;
55
84
 
56
85
  interface CsrfTokenOptions {
57
86
  cookieKey?: string;
@@ -81,7 +110,22 @@ declare class UserContextMiddleware implements NestMiddleware {
81
110
  }
82
111
 
83
112
  declare class ViewContextMiddleware implements NestMiddleware {
84
- use(req: Request, res: Response, next: NextFunction): void;
113
+ private readonly client;
114
+ private readonly logger;
115
+ constructor(client: PlatformHttpClient);
116
+ private getAppInfo;
117
+ use(req: Request, res: Response, next: NextFunction): Promise<void>;
118
+ }
119
+
120
+ /**
121
+ * API 404 响应格式
122
+ */
123
+ interface ApiNotFoundResponse {
124
+ code: number;
125
+ message: string;
126
+ error: string;
127
+ path: string;
128
+ timestamp: string;
85
129
  }
86
130
 
87
- export { CsrfMiddleware, CsrfTokenMiddleware, PlatformModule, type PlatformModuleOptions, UserContextMiddleware, ViewContextMiddleware, configureApp };
131
+ export { type ApiNotFoundResponse, CsrfMiddleware, CsrfTokenMiddleware, type PlatformHttpClientOptions, PlatformModule, type PlatformModuleOptions, UserContextMiddleware, ViewContextMiddleware, configureApp };