@lark-apaas/fullstack-nestjs-core 1.1.75-beta.0 → 1.1.76-beta.0

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/README.md CHANGED
@@ -24,6 +24,26 @@ npm install @lark-apaas/fullstack-nestjs-core
24
24
  yarn add @lark-apaas/fullstack-nestjs-core
25
25
  ```
26
26
 
27
+ ## 请求上下文
28
+
29
+ 应用已引入 `PlatformModule.forRoot()` 时,业务服务可从统一入口导入并注入 `RequestContextService`,复用平台的请求上下文。`RequestContextState` 类型也由本包导出。
30
+
31
+ ```typescript
32
+ import { Injectable } from '@nestjs/common';
33
+ import { RequestContextService } from '@lark-apaas/fullstack-nestjs-core';
34
+
35
+ @Injectable()
36
+ export class BusinessService {
37
+ constructor(private readonly requestContext: RequestContextService) {}
38
+
39
+ getInternalToken(): string | undefined {
40
+ return this.requestContext.get('internalToken');
41
+ }
42
+ }
43
+ ```
44
+
45
+ 业务模块无需重复注册该 provider。未建立请求上下文时,`get()` 返回 `undefined`。
46
+
27
47
  ## 环境要求
28
48
 
29
49
  - Node.js >= 18.0.0
package/dist/index.cjs CHANGED
@@ -34419,6 +34419,7 @@ __export(index_exports, {
34419
34419
  PERMISSION_RESOLVER_TOKEN: () => import_nestjs_authzpaas2.PERMISSION_RESOLVER_TOKEN,
34420
34420
  PlatformHttpClientService: () => PlatformHttpClientService,
34421
34421
  PlatformModule: () => PlatformModule,
34422
+ RequestContextService: () => import_nestjs_common8.RequestContextService,
34422
34423
  StaticModule: () => StaticModule,
34423
34424
  UserContextMiddleware: () => UserContextMiddleware,
34424
34425
  ViewContextMiddleware: () => ViewContextMiddleware,
@@ -34463,11 +34464,10 @@ function getWebUserFromHeader(req) {
34463
34464
  const sudaWebUserJsonStr = decodeURIComponent(sudaWebUserContent);
34464
34465
  const sudaWebUserJson = JSON.parse(sudaWebUserJsonStr);
34465
34466
  return sudaWebUserJson;
34466
- } catch (err) {
34467
- console.error("parse suda webuser from header failed, err=%o", err);
34467
+ } catch {
34468
+ console.error("parse suda webuser from header failed");
34468
34469
  return null;
34469
34470
  }
34470
- return null;
34471
34471
  }
34472
34472
  __name(getWebUserFromHeader, "getWebUserFromHeader");
34473
34473
 
@@ -34487,6 +34487,7 @@ var UserContextMiddleware = class {
34487
34487
  const webUser = getWebUserFromHeader(req);
34488
34488
  req.userContext = {
34489
34489
  userId: webUser?.user_id,
34490
+ internalToken: webUser?.internal_token,
34490
34491
  tenantId: webUser?.tenant_id,
34491
34492
  appId: webUser?.app_id ?? "",
34492
34493
  loginUrl: webUser?.login_url ?? "",
@@ -34931,6 +34932,7 @@ var RequestContextMiddleware = class {
34931
34932
  path: path3,
34932
34933
  method: req.method,
34933
34934
  userId: userContext.userId,
34935
+ internalToken: userContext.internalToken,
34934
34936
  tenantId: userContext.tenantId,
34935
34937
  appId: userContext.appId,
34936
34938
  isSystemAccount: userContext.isSystemAccount,
@@ -36899,6 +36901,7 @@ var import_nestjs_authzpaas2 = require("@lark-apaas/nestjs-authzpaas");
36899
36901
  PERMISSION_RESOLVER_TOKEN,
36900
36902
  PlatformHttpClientService,
36901
36903
  PlatformModule,
36904
+ RequestContextService,
36902
36905
  StaticModule,
36903
36906
  UserContextMiddleware,
36904
36907
  ViewContextMiddleware,
package/dist/index.d.cts CHANGED
@@ -7,7 +7,7 @@ import { McpModuleOptions } from '@lark-apaas/nestjs-mcp';
7
7
  export * from '@lark-apaas/nestjs-mcp';
8
8
  import { NestExpressApplication } from '@nestjs/platform-express';
9
9
  import { PlatformHttpClient, RequestContextService, ObservableService } from '@lark-apaas/nestjs-common';
10
- export { AutoTrace } from '@lark-apaas/nestjs-common';
10
+ export { AutoTrace, RequestContextService, RequestContextState } from '@lark-apaas/nestjs-common';
11
11
  import { DevToolsOptions, DevToolsV2Options } from '@lark-apaas/nestjs-openapi-devtools';
12
12
  export { DevToolsOptions, DevToolsV2Options } from '@lark-apaas/nestjs-openapi-devtools';
13
13
  import { Request, Response, NextFunction } from 'express';
@@ -33,6 +33,7 @@ declare global {
33
33
  };
34
34
  userContext: {
35
35
  userId?: string;
36
+ internalToken?: string;
36
37
  tenantId?: number;
37
38
  appId?: string;
38
39
  loginUrl?: string;
package/dist/index.d.ts CHANGED
@@ -7,7 +7,7 @@ import { McpModuleOptions } from '@lark-apaas/nestjs-mcp';
7
7
  export * from '@lark-apaas/nestjs-mcp';
8
8
  import { NestExpressApplication } from '@nestjs/platform-express';
9
9
  import { PlatformHttpClient, RequestContextService, ObservableService } from '@lark-apaas/nestjs-common';
10
- export { AutoTrace } from '@lark-apaas/nestjs-common';
10
+ export { AutoTrace, RequestContextService, RequestContextState } from '@lark-apaas/nestjs-common';
11
11
  import { DevToolsOptions, DevToolsV2Options } from '@lark-apaas/nestjs-openapi-devtools';
12
12
  export { DevToolsOptions, DevToolsV2Options } from '@lark-apaas/nestjs-openapi-devtools';
13
13
  import { Request, Response, NextFunction } from 'express';
@@ -33,6 +33,7 @@ declare global {
33
33
  };
34
34
  userContext: {
35
35
  userId?: string;
36
+ internalToken?: string;
36
37
  tenantId?: number;
37
38
  appId?: string;
38
39
  loginUrl?: string;
package/dist/index.js CHANGED
@@ -34431,11 +34431,10 @@ function getWebUserFromHeader(req) {
34431
34431
  const sudaWebUserJsonStr = decodeURIComponent(sudaWebUserContent);
34432
34432
  const sudaWebUserJson = JSON.parse(sudaWebUserJsonStr);
34433
34433
  return sudaWebUserJson;
34434
- } catch (err) {
34435
- console.error("parse suda webuser from header failed, err=%o", err);
34434
+ } catch {
34435
+ console.error("parse suda webuser from header failed");
34436
34436
  return null;
34437
34437
  }
34438
- return null;
34439
34438
  }
34440
34439
  __name(getWebUserFromHeader, "getWebUserFromHeader");
34441
34440
 
@@ -34455,6 +34454,7 @@ var UserContextMiddleware = class {
34455
34454
  const webUser = getWebUserFromHeader(req);
34456
34455
  req.userContext = {
34457
34456
  userId: webUser?.user_id,
34457
+ internalToken: webUser?.internal_token,
34458
34458
  tenantId: webUser?.tenant_id,
34459
34459
  appId: webUser?.app_id ?? "",
34460
34460
  loginUrl: webUser?.login_url ?? "",
@@ -34899,6 +34899,7 @@ var RequestContextMiddleware = class {
34899
34899
  path: path3,
34900
34900
  method: req.method,
34901
34901
  userId: userContext.userId,
34902
+ internalToken: userContext.internalToken,
34902
34903
  tenantId: userContext.tenantId,
34903
34904
  appId: userContext.appId,
34904
34905
  isSystemAccount: userContext.isSystemAccount,
@@ -36847,7 +36848,7 @@ export * from "@lark-apaas/nestjs-observable";
36847
36848
  export * from "@lark-apaas/nestjs-trigger";
36848
36849
  export * from "@lark-apaas/nestjs-mcp";
36849
36850
  export * from "@lark-apaas/file-service";
36850
- import { AutoTrace } from "@lark-apaas/nestjs-common";
36851
+ import { AutoTrace, RequestContextService as RequestContextService4 } from "@lark-apaas/nestjs-common";
36851
36852
  import { AuthZPaasModule as AuthZPaasModule2, CanRole, Can, AuthorizationSDK, PERMISSION_RESOLVER_TOKEN } from "@lark-apaas/nestjs-authzpaas";
36852
36853
  export {
36853
36854
  AuthZPaasModule2 as AuthZPaasModule,
@@ -36865,6 +36866,7 @@ export {
36865
36866
  PERMISSION_RESOLVER_TOKEN,
36866
36867
  PlatformHttpClientService,
36867
36868
  PlatformModule,
36869
+ RequestContextService4 as RequestContextService,
36868
36870
  StaticModule,
36869
36871
  UserContextMiddleware,
36870
36872
  ViewContextMiddleware,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/fullstack-nestjs-core",
3
- "version": "1.1.75-beta.0",
3
+ "version": "1.1.76-beta.0",
4
4
  "description": "FullStack Nestjs Core",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -39,18 +39,18 @@
39
39
  "prepublishOnly": "npm run build"
40
40
  },
41
41
  "dependencies": {
42
- "@lark-apaas/cache-service": "^0.1.6",
42
+ "@lark-apaas/cache-service": "0.1.7-beta.0",
43
43
  "@lark-apaas/file-service": "^0.1.2",
44
44
  "@lark-apaas/http-client": "^0.1.9",
45
- "@lark-apaas/nestjs-authnpaas": "^1.0.9",
46
- "@lark-apaas/nestjs-authzpaas": "^0.1.16",
47
- "@lark-apaas/nestjs-capability": "^0.1.14",
48
- "@lark-apaas/nestjs-common": "^0.1.9",
49
- "@lark-apaas/nestjs-datapaas": "1.0.27-beta.0",
50
- "@lark-apaas/nestjs-http-forwarder": "^0.1.4",
51
- "@lark-apaas/nestjs-logger": "^1.0.22",
45
+ "@lark-apaas/nestjs-authnpaas": "1.0.10-beta.0",
46
+ "@lark-apaas/nestjs-authzpaas": "0.1.17-beta.0",
47
+ "@lark-apaas/nestjs-capability": "0.1.15-beta.0",
48
+ "@lark-apaas/nestjs-common": "0.1.10-beta.0",
49
+ "@lark-apaas/nestjs-datapaas": "1.0.28-beta.0",
50
+ "@lark-apaas/nestjs-http-forwarder": "0.1.5-beta.0",
51
+ "@lark-apaas/nestjs-logger": "1.0.23-beta.0",
52
52
  "@lark-apaas/nestjs-mcp": "^0.1.2",
53
- "@lark-apaas/nestjs-observable": "^0.0.16",
53
+ "@lark-apaas/nestjs-observable": "0.0.17-beta.0",
54
54
  "@lark-apaas/nestjs-openapi-devtools": "^1.0.10",
55
55
  "@lark-apaas/nestjs-trigger": "^0.0.3",
56
56
  "@nestjs/axios": "^4.0.1",