@lark-apaas/fullstack-nestjs-core 1.1.72 → 1.1.74-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/dist/index.cjs CHANGED
@@ -34685,12 +34685,14 @@ function _ts_param(paramIndex, decorator) {
34685
34685
  };
34686
34686
  }
34687
34687
  __name(_ts_param, "_ts_param");
34688
+ var APP_PUBLISHED_CACHE_TTL_MS = 30 * 1e3;
34688
34689
  var ViewContextMiddleware = class _ViewContextMiddleware {
34689
34690
  static {
34690
34691
  __name(this, "ViewContextMiddleware");
34691
34692
  }
34692
34693
  client;
34693
34694
  logger = new import_common3.Logger(_ViewContextMiddleware.name);
34695
+ appPublishedCache = /* @__PURE__ */ new Map();
34694
34696
  constructor(client) {
34695
34697
  this.client = client;
34696
34698
  }
@@ -34714,18 +34716,37 @@ var ViewContextMiddleware = class _ViewContextMiddleware {
34714
34716
  return null;
34715
34717
  }
34716
34718
  }
34719
+ async getAppPublishedCached(appId) {
34720
+ if (!appId) {
34721
+ return this.getAppPublished(appId);
34722
+ }
34723
+ const hit = this.appPublishedCache.get(appId);
34724
+ if (hit && hit.expiresAt > Date.now()) {
34725
+ return hit.data;
34726
+ }
34727
+ const data = await this.getAppPublished(appId);
34728
+ if (data) {
34729
+ this.appPublishedCache.set(appId, {
34730
+ data,
34731
+ expiresAt: Date.now() + APP_PUBLISHED_CACHE_TTL_MS
34732
+ });
34733
+ }
34734
+ return data;
34735
+ }
34717
34736
  async use(req, res, next) {
34718
34737
  const { userId, tenantId, appId, loginUrl, userType } = req.userContext;
34719
34738
  const csrfToken = req.csrfToken;
34720
34739
  const environment = mapToWindowEnvironment(process.env.FORCE_FRAMEWORK_ENVIRONMENT);
34721
34740
  const basename = safeEscape(resolveBasename(req.headers, appId));
34722
- const appPublishedData = await this.getAppPublished(appId);
34741
+ const isDevelopment = process.env.NODE_ENV === "development";
34742
+ const appPublishedData = isDevelopment ? null : await this.getAppPublishedCached(appId);
34723
34743
  const appInfo = appPublishedData?.app_info ?? null;
34744
+ const fallbackAppName = isDevelopment ? "" : "\u5999\u642D\u5E94\u7528";
34724
34745
  req.__platform_data__ = {
34725
34746
  csrfToken: csrfToken ?? "",
34726
34747
  userId: userId ?? "",
34727
34748
  appId: appId ?? "",
34728
- appName: safeEscape(appInfo?.app_name ?? "\u5999\u642D\u5E94\u7528"),
34749
+ appName: safeEscape(appInfo?.app_name ?? fallbackAppName),
34729
34750
  appAvatar: appInfo?.app_avatar ?? "",
34730
34751
  appDescription: safeEscape(appInfo?.app_description ?? ""),
34731
34752
  loginUrl: loginUrl ?? "",
@@ -34747,7 +34768,7 @@ var ViewContextMiddleware = class _ViewContextMiddleware {
34747
34768
  loginUrl: loginUrl ?? "",
34748
34769
  userType: userType ?? "",
34749
34770
  appId: appId ?? "",
34750
- appName: safeEscape(appInfo?.app_name ?? "\u5999\u642D\u5E94\u7528"),
34771
+ appName: safeEscape(appInfo?.app_name ?? fallbackAppName),
34751
34772
  appAvatar: appInfo?.app_avatar ?? "",
34752
34773
  appDescription: safeEscape(appInfo?.app_description ?? ""),
34753
34774
  environment,
package/dist/index.d.cts CHANGED
@@ -226,8 +226,10 @@ declare class UserContextMiddleware implements NestMiddleware {
226
226
  declare class ViewContextMiddleware implements NestMiddleware {
227
227
  private readonly client;
228
228
  private readonly logger;
229
+ private readonly appPublishedCache;
229
230
  constructor(client: PlatformHttpClient);
230
231
  private getAppPublished;
232
+ private getAppPublishedCached;
231
233
  use(req: Request, res: Response, next: NextFunction): Promise<void>;
232
234
  }
233
235
 
package/dist/index.d.ts CHANGED
@@ -226,8 +226,10 @@ declare class UserContextMiddleware implements NestMiddleware {
226
226
  declare class ViewContextMiddleware implements NestMiddleware {
227
227
  private readonly client;
228
228
  private readonly logger;
229
+ private readonly appPublishedCache;
229
230
  constructor(client: PlatformHttpClient);
230
231
  private getAppPublished;
232
+ private getAppPublishedCached;
231
233
  use(req: Request, res: Response, next: NextFunction): Promise<void>;
232
234
  }
233
235
 
package/dist/index.js CHANGED
@@ -34653,12 +34653,14 @@ function _ts_param(paramIndex, decorator) {
34653
34653
  };
34654
34654
  }
34655
34655
  __name(_ts_param, "_ts_param");
34656
+ var APP_PUBLISHED_CACHE_TTL_MS = 30 * 1e3;
34656
34657
  var ViewContextMiddleware = class _ViewContextMiddleware {
34657
34658
  static {
34658
34659
  __name(this, "ViewContextMiddleware");
34659
34660
  }
34660
34661
  client;
34661
34662
  logger = new Logger(_ViewContextMiddleware.name);
34663
+ appPublishedCache = /* @__PURE__ */ new Map();
34662
34664
  constructor(client) {
34663
34665
  this.client = client;
34664
34666
  }
@@ -34682,18 +34684,37 @@ var ViewContextMiddleware = class _ViewContextMiddleware {
34682
34684
  return null;
34683
34685
  }
34684
34686
  }
34687
+ async getAppPublishedCached(appId) {
34688
+ if (!appId) {
34689
+ return this.getAppPublished(appId);
34690
+ }
34691
+ const hit = this.appPublishedCache.get(appId);
34692
+ if (hit && hit.expiresAt > Date.now()) {
34693
+ return hit.data;
34694
+ }
34695
+ const data = await this.getAppPublished(appId);
34696
+ if (data) {
34697
+ this.appPublishedCache.set(appId, {
34698
+ data,
34699
+ expiresAt: Date.now() + APP_PUBLISHED_CACHE_TTL_MS
34700
+ });
34701
+ }
34702
+ return data;
34703
+ }
34685
34704
  async use(req, res, next) {
34686
34705
  const { userId, tenantId, appId, loginUrl, userType } = req.userContext;
34687
34706
  const csrfToken = req.csrfToken;
34688
34707
  const environment = mapToWindowEnvironment(process.env.FORCE_FRAMEWORK_ENVIRONMENT);
34689
34708
  const basename = safeEscape(resolveBasename(req.headers, appId));
34690
- const appPublishedData = await this.getAppPublished(appId);
34709
+ const isDevelopment = process.env.NODE_ENV === "development";
34710
+ const appPublishedData = isDevelopment ? null : await this.getAppPublishedCached(appId);
34691
34711
  const appInfo = appPublishedData?.app_info ?? null;
34712
+ const fallbackAppName = isDevelopment ? "" : "\u5999\u642D\u5E94\u7528";
34692
34713
  req.__platform_data__ = {
34693
34714
  csrfToken: csrfToken ?? "",
34694
34715
  userId: userId ?? "",
34695
34716
  appId: appId ?? "",
34696
- appName: safeEscape(appInfo?.app_name ?? "\u5999\u642D\u5E94\u7528"),
34717
+ appName: safeEscape(appInfo?.app_name ?? fallbackAppName),
34697
34718
  appAvatar: appInfo?.app_avatar ?? "",
34698
34719
  appDescription: safeEscape(appInfo?.app_description ?? ""),
34699
34720
  loginUrl: loginUrl ?? "",
@@ -34715,7 +34736,7 @@ var ViewContextMiddleware = class _ViewContextMiddleware {
34715
34736
  loginUrl: loginUrl ?? "",
34716
34737
  userType: userType ?? "",
34717
34738
  appId: appId ?? "",
34718
- appName: safeEscape(appInfo?.app_name ?? "\u5999\u642D\u5E94\u7528"),
34739
+ appName: safeEscape(appInfo?.app_name ?? fallbackAppName),
34719
34740
  appAvatar: appInfo?.app_avatar ?? "",
34720
34741
  appDescription: safeEscape(appInfo?.app_description ?? ""),
34721
34742
  environment,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/fullstack-nestjs-core",
3
- "version": "1.1.72",
3
+ "version": "1.1.74-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.5",
42
+ "@lark-apaas/cache-service": "^0.1.6",
43
43
  "@lark-apaas/file-service": "^0.1.2",
44
44
  "@lark-apaas/http-client": "^0.1.9",
45
45
  "@lark-apaas/nestjs-authnpaas": "^1.0.9",
46
46
  "@lark-apaas/nestjs-authzpaas": "^0.1.16",
47
47
  "@lark-apaas/nestjs-capability": "^0.1.14",
48
48
  "@lark-apaas/nestjs-common": "^0.1.9",
49
- "@lark-apaas/nestjs-datapaas": "^1.0.25",
49
+ "@lark-apaas/nestjs-datapaas": "^1.0.26",
50
50
  "@lark-apaas/nestjs-http-forwarder": "^0.1.4",
51
- "@lark-apaas/nestjs-logger": "^1.0.21",
51
+ "@lark-apaas/nestjs-logger": "^1.0.22",
52
52
  "@lark-apaas/nestjs-mcp": "^0.1.2",
53
- "@lark-apaas/nestjs-observable": "^0.0.15",
53
+ "@lark-apaas/nestjs-observable": "^0.0.16",
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",