@lark-apaas/fullstack-nestjs-core 1.1.34-alpha.55 → 1.1.34-alpha.57

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.cjs CHANGED
@@ -5492,9 +5492,9 @@ var require_read = __commonJS({
5492
5492
  }
5493
5493
  });
5494
5494
 
5495
- // ../../../node_modules/media-typer/index.js
5495
+ // ../../../node_modules/type-is/node_modules/media-typer/index.js
5496
5496
  var require_media_typer = __commonJS({
5497
- "../../../node_modules/media-typer/index.js"(exports2) {
5497
+ "../../../node_modules/type-is/node_modules/media-typer/index.js"(exports2) {
5498
5498
  "use strict";
5499
5499
  var paramRegExp = /; *([!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+) *= *("(?:[ !\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u0020-\u007e])*"|[!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+) */g;
5500
5500
  var textRegExp = /^[\u0020-\u007e\u0080-\u00ff]+$/;
@@ -34627,31 +34627,55 @@ var ViewContextMiddleware = class _ViewContextMiddleware {
34627
34627
  constructor(client) {
34628
34628
  this.client = client;
34629
34629
  }
34630
- async getAppInfo(appId) {
34630
+ async getAppPublished(appId) {
34631
34631
  if (!appId) {
34632
- this.logger.warn(`appId is empty, skip get app info`);
34632
+ this.logger.warn(`appId is empty, skip get app published`);
34633
34633
  return null;
34634
34634
  }
34635
34635
  try {
34636
34636
  const resp = await this.client.get(`/b/${appId}/get_published_v2`);
34637
34637
  if (resp.status !== 200) {
34638
- throw new Error(`Failed to get app info, status: ${resp.status}`);
34638
+ throw new Error(`Failed to get app published, status: ${resp.status}`);
34639
34639
  }
34640
34640
  const data = await resp.json();
34641
34641
  if (data.status_code !== "0") {
34642
- throw new Error(`Failed to get app info, status_code: ${data.status_code}`);
34642
+ throw new Error(`Failed to get app published, status_code: ${data.status_code}`);
34643
34643
  }
34644
- return data.data.app_info ?? {};
34644
+ return data.data ?? null;
34645
34645
  } catch (err) {
34646
- this.logger.error(err, "Failed to get app info");
34646
+ this.logger.error(err, "Failed to get app published");
34647
+ return null;
34648
+ }
34649
+ }
34650
+ async getTenantInfo(appId) {
34651
+ if (!appId) {
34652
+ this.logger.warn(`appId is empty, skip get tenant info`);
34653
+ return null;
34654
+ }
34655
+ try {
34656
+ const resp = await this.client.get(`/b/${appId}/tenant_info`);
34657
+ if (resp.status !== 200) {
34658
+ throw new Error(`Failed to get tenant info, status: ${resp.status}`);
34659
+ }
34660
+ const data = await resp.json();
34661
+ if (data.status_code !== "0") {
34662
+ throw new Error(`Failed to get tenant info, status_code: ${data.status_code}`);
34663
+ }
34664
+ return data.data ?? null;
34665
+ } catch (err) {
34666
+ this.logger.error(err, "Failed to get tenant info");
34647
34667
  return null;
34648
34668
  }
34649
34669
  }
34650
34670
  async use(req, res, next) {
34651
34671
  const { userId, tenantId, appId, loginUrl, userType } = req.userContext;
34652
34672
  const csrfToken = req.csrfToken;
34653
- const appInfo = await this.getAppInfo(appId);
34654
34673
  const environment = mapToWindowEnvironment(process.env.FORCE_FRAMEWORK_ENVIRONMENT);
34674
+ const [appPublishedData, tenantInfoData] = await Promise.all([
34675
+ this.getAppPublished(appId),
34676
+ this.getTenantInfo(appId)
34677
+ ]);
34678
+ const appInfo = appPublishedData?.app_info ?? null;
34655
34679
  req.__platform_data__ = {
34656
34680
  csrfToken: csrfToken ?? "",
34657
34681
  userId: userId ?? "",
@@ -34662,7 +34686,12 @@ var ViewContextMiddleware = class _ViewContextMiddleware {
34662
34686
  loginUrl: loginUrl ?? "",
34663
34687
  userType: userType ?? "",
34664
34688
  tenantId,
34665
- environment
34689
+ environment,
34690
+ // 预注入字段,前端无需再发 API 请求
34691
+ showBadge: appInfo?.show_badge !== false,
34692
+ tenantName: safeEscape(tenantInfoData?.tenant_info?.name ?? ""),
34693
+ isInternetVisible: tenantInfoData?.is_internet_visible ?? false,
34694
+ appPublished: appPublishedData ?? null
34666
34695
  };
34667
34696
  res.locals = {
34668
34697
  ...res.locals ?? {},
package/dist/index.d.cts CHANGED
@@ -201,7 +201,8 @@ declare class ViewContextMiddleware implements NestMiddleware {
201
201
  private readonly client;
202
202
  private readonly logger;
203
203
  constructor(client: PlatformHttpClient);
204
- private getAppInfo;
204
+ private getAppPublished;
205
+ private getTenantInfo;
205
206
  use(req: Request, res: Response, next: NextFunction): Promise<void>;
206
207
  }
207
208
 
package/dist/index.d.ts CHANGED
@@ -201,7 +201,8 @@ declare class ViewContextMiddleware implements NestMiddleware {
201
201
  private readonly client;
202
202
  private readonly logger;
203
203
  constructor(client: PlatformHttpClient);
204
- private getAppInfo;
204
+ private getAppPublished;
205
+ private getTenantInfo;
205
206
  use(req: Request, res: Response, next: NextFunction): Promise<void>;
206
207
  }
207
208
 
package/dist/index.js CHANGED
@@ -5491,9 +5491,9 @@ var require_read = __commonJS({
5491
5491
  }
5492
5492
  });
5493
5493
 
5494
- // ../../../node_modules/media-typer/index.js
5494
+ // ../../../node_modules/type-is/node_modules/media-typer/index.js
5495
5495
  var require_media_typer = __commonJS({
5496
- "../../../node_modules/media-typer/index.js"(exports) {
5496
+ "../../../node_modules/type-is/node_modules/media-typer/index.js"(exports) {
5497
5497
  "use strict";
5498
5498
  var paramRegExp = /; *([!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+) *= *("(?:[ !\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u0020-\u007e])*"|[!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+) */g;
5499
5499
  var textRegExp = /^[\u0020-\u007e\u0080-\u00ff]+$/;
@@ -34600,31 +34600,55 @@ var ViewContextMiddleware = class _ViewContextMiddleware {
34600
34600
  constructor(client) {
34601
34601
  this.client = client;
34602
34602
  }
34603
- async getAppInfo(appId) {
34603
+ async getAppPublished(appId) {
34604
34604
  if (!appId) {
34605
- this.logger.warn(`appId is empty, skip get app info`);
34605
+ this.logger.warn(`appId is empty, skip get app published`);
34606
34606
  return null;
34607
34607
  }
34608
34608
  try {
34609
34609
  const resp = await this.client.get(`/b/${appId}/get_published_v2`);
34610
34610
  if (resp.status !== 200) {
34611
- throw new Error(`Failed to get app info, status: ${resp.status}`);
34611
+ throw new Error(`Failed to get app published, status: ${resp.status}`);
34612
34612
  }
34613
34613
  const data = await resp.json();
34614
34614
  if (data.status_code !== "0") {
34615
- throw new Error(`Failed to get app info, status_code: ${data.status_code}`);
34615
+ throw new Error(`Failed to get app published, status_code: ${data.status_code}`);
34616
34616
  }
34617
- return data.data.app_info ?? {};
34617
+ return data.data ?? null;
34618
34618
  } catch (err) {
34619
- this.logger.error(err, "Failed to get app info");
34619
+ this.logger.error(err, "Failed to get app published");
34620
+ return null;
34621
+ }
34622
+ }
34623
+ async getTenantInfo(appId) {
34624
+ if (!appId) {
34625
+ this.logger.warn(`appId is empty, skip get tenant info`);
34626
+ return null;
34627
+ }
34628
+ try {
34629
+ const resp = await this.client.get(`/b/${appId}/tenant_info`);
34630
+ if (resp.status !== 200) {
34631
+ throw new Error(`Failed to get tenant info, status: ${resp.status}`);
34632
+ }
34633
+ const data = await resp.json();
34634
+ if (data.status_code !== "0") {
34635
+ throw new Error(`Failed to get tenant info, status_code: ${data.status_code}`);
34636
+ }
34637
+ return data.data ?? null;
34638
+ } catch (err) {
34639
+ this.logger.error(err, "Failed to get tenant info");
34620
34640
  return null;
34621
34641
  }
34622
34642
  }
34623
34643
  async use(req, res, next) {
34624
34644
  const { userId, tenantId, appId, loginUrl, userType } = req.userContext;
34625
34645
  const csrfToken = req.csrfToken;
34626
- const appInfo = await this.getAppInfo(appId);
34627
34646
  const environment = mapToWindowEnvironment(process.env.FORCE_FRAMEWORK_ENVIRONMENT);
34647
+ const [appPublishedData, tenantInfoData] = await Promise.all([
34648
+ this.getAppPublished(appId),
34649
+ this.getTenantInfo(appId)
34650
+ ]);
34651
+ const appInfo = appPublishedData?.app_info ?? null;
34628
34652
  req.__platform_data__ = {
34629
34653
  csrfToken: csrfToken ?? "",
34630
34654
  userId: userId ?? "",
@@ -34635,7 +34659,12 @@ var ViewContextMiddleware = class _ViewContextMiddleware {
34635
34659
  loginUrl: loginUrl ?? "",
34636
34660
  userType: userType ?? "",
34637
34661
  tenantId,
34638
- environment
34662
+ environment,
34663
+ // 预注入字段,前端无需再发 API 请求
34664
+ showBadge: appInfo?.show_badge !== false,
34665
+ tenantName: safeEscape(tenantInfoData?.tenant_info?.name ?? ""),
34666
+ isInternetVisible: tenantInfoData?.is_internet_visible ?? false,
34667
+ appPublished: appPublishedData ?? null
34639
34668
  };
34640
34669
  res.locals = {
34641
34670
  ...res.locals ?? {},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/fullstack-nestjs-core",
3
- "version": "1.1.34-alpha.55",
3
+ "version": "1.1.34-alpha.57",
4
4
  "description": "FullStack Nestjs Core",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -45,7 +45,7 @@
45
45
  "@lark-apaas/nestjs-authzpaas": "^0.1.8",
46
46
  "@lark-apaas/nestjs-capability": "^0.1.11",
47
47
  "@lark-apaas/nestjs-common": "^0.1.8",
48
- "@lark-apaas/nestjs-datapaas": "1.0.10-alpha.65",
48
+ "@lark-apaas/nestjs-datapaas": "^1.0.18",
49
49
  "@lark-apaas/nestjs-logger": "^1.0.16",
50
50
  "@lark-apaas/nestjs-observable": "^0.0.11",
51
51
  "@lark-apaas/nestjs-openapi-devtools": "^1.0.10",