@lark-apaas/fullstack-nestjs-core 1.1.73 → 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 +24 -3
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +24 -3
- package/package.json +1 -1
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
|
|
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 ??
|
|
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 ??
|
|
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
|
|
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 ??
|
|
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 ??
|
|
34739
|
+
appName: safeEscape(appInfo?.app_name ?? fallbackAppName),
|
|
34719
34740
|
appAvatar: appInfo?.app_avatar ?? "",
|
|
34720
34741
|
appDescription: safeEscape(appInfo?.app_description ?? ""),
|
|
34721
34742
|
environment,
|