@lark-apaas/fullstack-nestjs-core 1.1.39 → 1.1.41

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
@@ -20771,9 +20771,9 @@ var require_safe_buffer = __commonJS({
20771
20771
  }
20772
20772
  });
20773
20773
 
20774
- // ../../../node_modules/content-disposition/index.js
20774
+ // ../../../node_modules/express/node_modules/content-disposition/index.js
20775
20775
  var require_content_disposition = __commonJS({
20776
- "../../../node_modules/content-disposition/index.js"(exports2, module2) {
20776
+ "../../../node_modules/express/node_modules/content-disposition/index.js"(exports2, module2) {
20777
20777
  "use strict";
20778
20778
  module2.exports = contentDisposition;
20779
20779
  module2.exports.parse = parse;
@@ -34627,31 +34627,32 @@ 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
34647
  return null;
34648
34648
  }
34649
34649
  }
34650
34650
  async use(req, res, next) {
34651
34651
  const { userId, tenantId, appId, loginUrl, userType } = req.userContext;
34652
34652
  const csrfToken = req.csrfToken;
34653
- const appInfo = await this.getAppInfo(appId);
34654
34653
  const environment = mapToWindowEnvironment(process.env.FORCE_FRAMEWORK_ENVIRONMENT);
34654
+ const appPublishedData = await this.getAppPublished(appId);
34655
+ const appInfo = appPublishedData?.app_info ?? null;
34655
34656
  req.__platform_data__ = {
34656
34657
  csrfToken: csrfToken ?? "",
34657
34658
  userId: userId ?? "",
@@ -34662,7 +34663,9 @@ var ViewContextMiddleware = class _ViewContextMiddleware {
34662
34663
  loginUrl: loginUrl ?? "",
34663
34664
  userType: userType ?? "",
34664
34665
  tenantId,
34665
- environment
34666
+ environment,
34667
+ showBadge: appInfo?.show_badge !== false,
34668
+ appPublished: appPublishedData ?? null
34666
34669
  };
34667
34670
  res.locals = {
34668
34671
  ...res.locals ?? {},
package/dist/index.d.cts CHANGED
@@ -201,7 +201,7 @@ 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
205
  use(req: Request, res: Response, next: NextFunction): Promise<void>;
206
206
  }
207
207
 
package/dist/index.d.ts CHANGED
@@ -201,7 +201,7 @@ 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
205
  use(req: Request, res: Response, next: NextFunction): Promise<void>;
206
206
  }
207
207
 
package/dist/index.js CHANGED
@@ -20770,9 +20770,9 @@ var require_safe_buffer = __commonJS({
20770
20770
  }
20771
20771
  });
20772
20772
 
20773
- // ../../../node_modules/content-disposition/index.js
20773
+ // ../../../node_modules/express/node_modules/content-disposition/index.js
20774
20774
  var require_content_disposition = __commonJS({
20775
- "../../../node_modules/content-disposition/index.js"(exports, module) {
20775
+ "../../../node_modules/express/node_modules/content-disposition/index.js"(exports, module) {
20776
20776
  "use strict";
20777
20777
  module.exports = contentDisposition;
20778
20778
  module.exports.parse = parse;
@@ -34600,31 +34600,32 @@ 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
34620
  return null;
34621
34621
  }
34622
34622
  }
34623
34623
  async use(req, res, next) {
34624
34624
  const { userId, tenantId, appId, loginUrl, userType } = req.userContext;
34625
34625
  const csrfToken = req.csrfToken;
34626
- const appInfo = await this.getAppInfo(appId);
34627
34626
  const environment = mapToWindowEnvironment(process.env.FORCE_FRAMEWORK_ENVIRONMENT);
34627
+ const appPublishedData = await this.getAppPublished(appId);
34628
+ const appInfo = appPublishedData?.app_info ?? null;
34628
34629
  req.__platform_data__ = {
34629
34630
  csrfToken: csrfToken ?? "",
34630
34631
  userId: userId ?? "",
@@ -34635,7 +34636,9 @@ var ViewContextMiddleware = class _ViewContextMiddleware {
34635
34636
  loginUrl: loginUrl ?? "",
34636
34637
  userType: userType ?? "",
34637
34638
  tenantId,
34638
- environment
34639
+ environment,
34640
+ showBadge: appInfo?.show_badge !== false,
34641
+ appPublished: appPublishedData ?? null
34639
34642
  };
34640
34643
  res.locals = {
34641
34644
  ...res.locals ?? {},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/fullstack-nestjs-core",
3
- "version": "1.1.39",
3
+ "version": "1.1.41",
4
4
  "description": "FullStack Nestjs Core",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",