@lark-apaas/fullstack-nestjs-core 1.1.50-alpha.8 → 1.1.50-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 +8 -51
- package/dist/index.d.cts +4 -5
- package/dist/index.d.ts +4 -5
- package/dist/index.js +8 -49
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -34423,9 +34423,7 @@ __export(index_exports, {
|
|
|
34423
34423
|
UserContextMiddleware: () => UserContextMiddleware,
|
|
34424
34424
|
ViewContextMiddleware: () => ViewContextMiddleware,
|
|
34425
34425
|
configureApp: () => configureApp,
|
|
34426
|
-
createLegacyPathRedirectMiddleware: () => createLegacyPathRedirectMiddleware
|
|
34427
|
-
createLocalDevMiddleware: () => createLocalDevMiddleware,
|
|
34428
|
-
isLocalDev: () => isLocalDev
|
|
34426
|
+
createLegacyPathRedirectMiddleware: () => createLegacyPathRedirectMiddleware
|
|
34429
34427
|
});
|
|
34430
34428
|
module.exports = __toCommonJS(index_exports);
|
|
34431
34429
|
|
|
@@ -34555,7 +34553,7 @@ CsrfMiddleware = _ts_decorate2([
|
|
|
34555
34553
|
(0, import_common2.Injectable)()
|
|
34556
34554
|
], CsrfMiddleware);
|
|
34557
34555
|
|
|
34558
|
-
// src/middlewares/view-context/
|
|
34556
|
+
// src/middlewares/view-context/middleware.ts
|
|
34559
34557
|
var import_common3 = require("@nestjs/common");
|
|
34560
34558
|
var import_nestjs_common = require("@lark-apaas/nestjs-common");
|
|
34561
34559
|
|
|
@@ -34602,7 +34600,7 @@ function safeEscape(s) {
|
|
|
34602
34600
|
}
|
|
34603
34601
|
__name(safeEscape, "safeEscape");
|
|
34604
34602
|
|
|
34605
|
-
// src/middlewares/view-context/
|
|
34603
|
+
// src/middlewares/view-context/middleware.ts
|
|
34606
34604
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
34607
34605
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
34608
34606
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -34653,6 +34651,7 @@ var ViewContextMiddleware = class _ViewContextMiddleware {
|
|
|
34653
34651
|
const { userId, tenantId, appId, loginUrl, userType } = req.userContext;
|
|
34654
34652
|
const csrfToken = req.csrfToken;
|
|
34655
34653
|
const environment = mapToWindowEnvironment(process.env.FORCE_FRAMEWORK_ENVIRONMENT);
|
|
34654
|
+
const basename = safeEscape(req.headers["x-miaoda-custom-host"] !== void 0 ? "/" : `/app/${appId || ""}`);
|
|
34656
34655
|
const appPublishedData = await this.getAppPublished(appId);
|
|
34657
34656
|
const appInfo = appPublishedData?.app_info ?? null;
|
|
34658
34657
|
req.__platform_data__ = {
|
|
@@ -34667,7 +34666,8 @@ var ViewContextMiddleware = class _ViewContextMiddleware {
|
|
|
34667
34666
|
tenantId,
|
|
34668
34667
|
environment,
|
|
34669
34668
|
showBadge: appInfo?.show_badge !== false,
|
|
34670
|
-
appPublished: appPublishedData ?? null
|
|
34669
|
+
appPublished: appPublishedData ?? null,
|
|
34670
|
+
basename
|
|
34671
34671
|
};
|
|
34672
34672
|
res.locals = {
|
|
34673
34673
|
...res.locals ?? {},
|
|
@@ -34680,7 +34680,8 @@ var ViewContextMiddleware = class _ViewContextMiddleware {
|
|
|
34680
34680
|
appName: safeEscape(appInfo?.app_name ?? "\u5999\u642D\u5E94\u7528"),
|
|
34681
34681
|
appAvatar: appInfo?.app_avatar ?? "",
|
|
34682
34682
|
appDescription: safeEscape(appInfo?.app_description ?? ""),
|
|
34683
|
-
environment
|
|
34683
|
+
environment,
|
|
34684
|
+
basename
|
|
34684
34685
|
};
|
|
34685
34686
|
next();
|
|
34686
34687
|
}
|
|
@@ -36548,45 +36549,6 @@ function createLegacyPathRedirectMiddleware() {
|
|
|
36548
36549
|
}
|
|
36549
36550
|
__name(createLegacyPathRedirectMiddleware, "createLegacyPathRedirectMiddleware");
|
|
36550
36551
|
|
|
36551
|
-
// src/middlewares/local-dev/index.ts
|
|
36552
|
-
var CSRF_COOKIE_KEY = "suda-csrf-token";
|
|
36553
|
-
var CSRF_HEADER_KEY = "x-suda-csrf-token";
|
|
36554
|
-
var WEBUSER_HEADER_KEY = "x-larkgw-suda-webuser";
|
|
36555
|
-
function isLocalDev() {
|
|
36556
|
-
if (process.env.NODE_ENV === "production") return false;
|
|
36557
|
-
const flag = process.env.MIAODA_LOCAL_DEV;
|
|
36558
|
-
return flag === "1" || flag === "true";
|
|
36559
|
-
}
|
|
36560
|
-
__name(isLocalDev, "isLocalDev");
|
|
36561
|
-
function extractCsrfFromCookie(cookieHeader) {
|
|
36562
|
-
if (!cookieHeader) return void 0;
|
|
36563
|
-
const re = new RegExp(`(?:^|;\\s*)${CSRF_COOKIE_KEY}=([^;]+)`);
|
|
36564
|
-
const m = cookieHeader.match(re);
|
|
36565
|
-
return m?.[1];
|
|
36566
|
-
}
|
|
36567
|
-
__name(extractCsrfFromCookie, "extractCsrfFromCookie");
|
|
36568
|
-
function createLocalDevMiddleware() {
|
|
36569
|
-
let webUserHeader = "";
|
|
36570
|
-
if (process.env.SUDA_WEBUSER) {
|
|
36571
|
-
try {
|
|
36572
|
-
webUserHeader = encodeURIComponent(JSON.stringify(JSON.parse(process.env.SUDA_WEBUSER)));
|
|
36573
|
-
} catch {
|
|
36574
|
-
}
|
|
36575
|
-
}
|
|
36576
|
-
return /* @__PURE__ */ __name(function localDevMiddleware(req, _res, next) {
|
|
36577
|
-
const headers = req.headers;
|
|
36578
|
-
if (!headers[CSRF_HEADER_KEY]) {
|
|
36579
|
-
const token = extractCsrfFromCookie(req.headers.cookie);
|
|
36580
|
-
if (token) headers[CSRF_HEADER_KEY] = token;
|
|
36581
|
-
}
|
|
36582
|
-
if (webUserHeader && !headers[WEBUSER_HEADER_KEY]) {
|
|
36583
|
-
headers[WEBUSER_HEADER_KEY] = webUserHeader;
|
|
36584
|
-
}
|
|
36585
|
-
next();
|
|
36586
|
-
}, "localDevMiddleware");
|
|
36587
|
-
}
|
|
36588
|
-
__name(createLocalDevMiddleware, "createLocalDevMiddleware");
|
|
36589
|
-
|
|
36590
36552
|
// src/setup.ts
|
|
36591
36553
|
var DEFAULT_BODY_LIMIT = "1mb";
|
|
36592
36554
|
var defaultPerms = {
|
|
@@ -36604,9 +36566,6 @@ async function configureApp(app, perms = defaultPerms) {
|
|
|
36604
36566
|
extended: true
|
|
36605
36567
|
}));
|
|
36606
36568
|
app.use((0, import_cookie_parser.default)());
|
|
36607
|
-
if (isLocalDev()) {
|
|
36608
|
-
app.use(createLocalDevMiddleware());
|
|
36609
|
-
}
|
|
36610
36569
|
app.use(createLegacyPathRedirectMiddleware());
|
|
36611
36570
|
const globalPrefix = process.env.CLIENT_BASE_PATH ?? "";
|
|
36612
36571
|
app.setGlobalPrefix(globalPrefix);
|
|
@@ -36658,8 +36617,6 @@ var import_nestjs_authzpaas2 = require("@lark-apaas/nestjs-authzpaas");
|
|
|
36658
36617
|
ViewContextMiddleware,
|
|
36659
36618
|
configureApp,
|
|
36660
36619
|
createLegacyPathRedirectMiddleware,
|
|
36661
|
-
createLocalDevMiddleware,
|
|
36662
|
-
isLocalDev,
|
|
36663
36620
|
...require("@lark-apaas/nestjs-authnpaas"),
|
|
36664
36621
|
...require("@lark-apaas/nestjs-capability"),
|
|
36665
36622
|
...require("@lark-apaas/nestjs-datapaas"),
|
package/dist/index.d.cts
CHANGED
|
@@ -6,7 +6,7 @@ import { NestExpressApplication } from '@nestjs/platform-express';
|
|
|
6
6
|
import { PlatformHttpClient, RequestContextService, ObservableService } from '@lark-apaas/nestjs-common';
|
|
7
7
|
export { AutoTrace } from '@lark-apaas/nestjs-common';
|
|
8
8
|
export { DevToolsModule, DevToolsOptions, DevToolsV2Module, DevToolsV2Options } from '@lark-apaas/nestjs-openapi-devtools';
|
|
9
|
-
import { Request, Response, NextFunction
|
|
9
|
+
import { Request, Response, NextFunction } from 'express';
|
|
10
10
|
import * as _lark_apaas_file_service from '@lark-apaas/file-service';
|
|
11
11
|
import { FileBody, UploadOptions, FileDownloadBuilder, SearchOptions } from '@lark-apaas/file-service';
|
|
12
12
|
export * from '@lark-apaas/file-service';
|
|
@@ -23,6 +23,8 @@ declare global {
|
|
|
23
23
|
userId?: string;
|
|
24
24
|
tenantId?: number;
|
|
25
25
|
csrfToken?: string;
|
|
26
|
+
/** React Router basename,由 ViewContextMiddleware 注入;自定义域名场景下 = / 或 /<alias>,默认域名 = /app/<appId> */
|
|
27
|
+
basename?: string;
|
|
26
28
|
[key: string]: unknown;
|
|
27
29
|
};
|
|
28
30
|
userContext: {
|
|
@@ -221,9 +223,6 @@ declare class ViewContextMiddleware implements NestMiddleware {
|
|
|
221
223
|
*/
|
|
222
224
|
declare function createLegacyPathRedirectMiddleware(): (req: Request, res: Response, next: NextFunction) => void;
|
|
223
225
|
|
|
224
|
-
declare function isLocalDev(): boolean;
|
|
225
|
-
declare function createLocalDevMiddleware(): RequestHandler;
|
|
226
|
-
|
|
227
226
|
/**
|
|
228
227
|
* API 404 响应格式
|
|
229
228
|
*/
|
|
@@ -405,4 +404,4 @@ declare class PlatformHttpClientService {
|
|
|
405
404
|
private registerInterceptorsForClient;
|
|
406
405
|
}
|
|
407
406
|
|
|
408
|
-
export { type ApiNotFoundResponse, CsrfMiddleware, CsrfTokenMiddleware, FileService, HtmlHotUpdateModule, HtmlHotUpdateService, type PlatformHttpClientOptions, PlatformHttpClientService, PlatformModule, type PlatformModuleOptions, StaticModule, UserContextMiddleware, ViewContextMiddleware, configureApp, createLegacyPathRedirectMiddleware
|
|
407
|
+
export { type ApiNotFoundResponse, CsrfMiddleware, CsrfTokenMiddleware, FileService, HtmlHotUpdateModule, HtmlHotUpdateService, type PlatformHttpClientOptions, PlatformHttpClientService, PlatformModule, type PlatformModuleOptions, StaticModule, UserContextMiddleware, ViewContextMiddleware, configureApp, createLegacyPathRedirectMiddleware };
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { NestExpressApplication } from '@nestjs/platform-express';
|
|
|
6
6
|
import { PlatformHttpClient, RequestContextService, ObservableService } from '@lark-apaas/nestjs-common';
|
|
7
7
|
export { AutoTrace } from '@lark-apaas/nestjs-common';
|
|
8
8
|
export { DevToolsModule, DevToolsOptions, DevToolsV2Module, DevToolsV2Options } from '@lark-apaas/nestjs-openapi-devtools';
|
|
9
|
-
import { Request, Response, NextFunction
|
|
9
|
+
import { Request, Response, NextFunction } from 'express';
|
|
10
10
|
import * as _lark_apaas_file_service from '@lark-apaas/file-service';
|
|
11
11
|
import { FileBody, UploadOptions, FileDownloadBuilder, SearchOptions } from '@lark-apaas/file-service';
|
|
12
12
|
export * from '@lark-apaas/file-service';
|
|
@@ -23,6 +23,8 @@ declare global {
|
|
|
23
23
|
userId?: string;
|
|
24
24
|
tenantId?: number;
|
|
25
25
|
csrfToken?: string;
|
|
26
|
+
/** React Router basename,由 ViewContextMiddleware 注入;自定义域名场景下 = / 或 /<alias>,默认域名 = /app/<appId> */
|
|
27
|
+
basename?: string;
|
|
26
28
|
[key: string]: unknown;
|
|
27
29
|
};
|
|
28
30
|
userContext: {
|
|
@@ -221,9 +223,6 @@ declare class ViewContextMiddleware implements NestMiddleware {
|
|
|
221
223
|
*/
|
|
222
224
|
declare function createLegacyPathRedirectMiddleware(): (req: Request, res: Response, next: NextFunction) => void;
|
|
223
225
|
|
|
224
|
-
declare function isLocalDev(): boolean;
|
|
225
|
-
declare function createLocalDevMiddleware(): RequestHandler;
|
|
226
|
-
|
|
227
226
|
/**
|
|
228
227
|
* API 404 响应格式
|
|
229
228
|
*/
|
|
@@ -405,4 +404,4 @@ declare class PlatformHttpClientService {
|
|
|
405
404
|
private registerInterceptorsForClient;
|
|
406
405
|
}
|
|
407
406
|
|
|
408
|
-
export { type ApiNotFoundResponse, CsrfMiddleware, CsrfTokenMiddleware, FileService, HtmlHotUpdateModule, HtmlHotUpdateService, type PlatformHttpClientOptions, PlatformHttpClientService, PlatformModule, type PlatformModuleOptions, StaticModule, UserContextMiddleware, ViewContextMiddleware, configureApp, createLegacyPathRedirectMiddleware
|
|
407
|
+
export { type ApiNotFoundResponse, CsrfMiddleware, CsrfTokenMiddleware, FileService, HtmlHotUpdateModule, HtmlHotUpdateService, type PlatformHttpClientOptions, PlatformHttpClientService, PlatformModule, type PlatformModuleOptions, StaticModule, UserContextMiddleware, ViewContextMiddleware, configureApp, createLegacyPathRedirectMiddleware };
|
package/dist/index.js
CHANGED
|
@@ -34526,7 +34526,7 @@ CsrfMiddleware = _ts_decorate2([
|
|
|
34526
34526
|
Injectable2()
|
|
34527
34527
|
], CsrfMiddleware);
|
|
34528
34528
|
|
|
34529
|
-
// src/middlewares/view-context/
|
|
34529
|
+
// src/middlewares/view-context/middleware.ts
|
|
34530
34530
|
import { Inject, Injectable as Injectable3, Logger } from "@nestjs/common";
|
|
34531
34531
|
import { PLATFORM_HTTP_CLIENT } from "@lark-apaas/nestjs-common";
|
|
34532
34532
|
|
|
@@ -34573,7 +34573,7 @@ function safeEscape(s) {
|
|
|
34573
34573
|
}
|
|
34574
34574
|
__name(safeEscape, "safeEscape");
|
|
34575
34575
|
|
|
34576
|
-
// src/middlewares/view-context/
|
|
34576
|
+
// src/middlewares/view-context/middleware.ts
|
|
34577
34577
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
34578
34578
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
34579
34579
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -34624,6 +34624,7 @@ var ViewContextMiddleware = class _ViewContextMiddleware {
|
|
|
34624
34624
|
const { userId, tenantId, appId, loginUrl, userType } = req.userContext;
|
|
34625
34625
|
const csrfToken = req.csrfToken;
|
|
34626
34626
|
const environment = mapToWindowEnvironment(process.env.FORCE_FRAMEWORK_ENVIRONMENT);
|
|
34627
|
+
const basename = safeEscape(req.headers["x-miaoda-custom-host"] !== void 0 ? "/" : `/app/${appId || ""}`);
|
|
34627
34628
|
const appPublishedData = await this.getAppPublished(appId);
|
|
34628
34629
|
const appInfo = appPublishedData?.app_info ?? null;
|
|
34629
34630
|
req.__platform_data__ = {
|
|
@@ -34638,7 +34639,8 @@ var ViewContextMiddleware = class _ViewContextMiddleware {
|
|
|
34638
34639
|
tenantId,
|
|
34639
34640
|
environment,
|
|
34640
34641
|
showBadge: appInfo?.show_badge !== false,
|
|
34641
|
-
appPublished: appPublishedData ?? null
|
|
34642
|
+
appPublished: appPublishedData ?? null,
|
|
34643
|
+
basename
|
|
34642
34644
|
};
|
|
34643
34645
|
res.locals = {
|
|
34644
34646
|
...res.locals ?? {},
|
|
@@ -34651,7 +34653,8 @@ var ViewContextMiddleware = class _ViewContextMiddleware {
|
|
|
34651
34653
|
appName: safeEscape(appInfo?.app_name ?? "\u5999\u642D\u5E94\u7528"),
|
|
34652
34654
|
appAvatar: appInfo?.app_avatar ?? "",
|
|
34653
34655
|
appDescription: safeEscape(appInfo?.app_description ?? ""),
|
|
34654
|
-
environment
|
|
34656
|
+
environment,
|
|
34657
|
+
basename
|
|
34655
34658
|
};
|
|
34656
34659
|
next();
|
|
34657
34660
|
}
|
|
@@ -36519,45 +36522,6 @@ function createLegacyPathRedirectMiddleware() {
|
|
|
36519
36522
|
}
|
|
36520
36523
|
__name(createLegacyPathRedirectMiddleware, "createLegacyPathRedirectMiddleware");
|
|
36521
36524
|
|
|
36522
|
-
// src/middlewares/local-dev/index.ts
|
|
36523
|
-
var CSRF_COOKIE_KEY = "suda-csrf-token";
|
|
36524
|
-
var CSRF_HEADER_KEY = "x-suda-csrf-token";
|
|
36525
|
-
var WEBUSER_HEADER_KEY = "x-larkgw-suda-webuser";
|
|
36526
|
-
function isLocalDev() {
|
|
36527
|
-
if (process.env.NODE_ENV === "production") return false;
|
|
36528
|
-
const flag = process.env.MIAODA_LOCAL_DEV;
|
|
36529
|
-
return flag === "1" || flag === "true";
|
|
36530
|
-
}
|
|
36531
|
-
__name(isLocalDev, "isLocalDev");
|
|
36532
|
-
function extractCsrfFromCookie(cookieHeader) {
|
|
36533
|
-
if (!cookieHeader) return void 0;
|
|
36534
|
-
const re = new RegExp(`(?:^|;\\s*)${CSRF_COOKIE_KEY}=([^;]+)`);
|
|
36535
|
-
const m = cookieHeader.match(re);
|
|
36536
|
-
return m?.[1];
|
|
36537
|
-
}
|
|
36538
|
-
__name(extractCsrfFromCookie, "extractCsrfFromCookie");
|
|
36539
|
-
function createLocalDevMiddleware() {
|
|
36540
|
-
let webUserHeader = "";
|
|
36541
|
-
if (process.env.SUDA_WEBUSER) {
|
|
36542
|
-
try {
|
|
36543
|
-
webUserHeader = encodeURIComponent(JSON.stringify(JSON.parse(process.env.SUDA_WEBUSER)));
|
|
36544
|
-
} catch {
|
|
36545
|
-
}
|
|
36546
|
-
}
|
|
36547
|
-
return /* @__PURE__ */ __name(function localDevMiddleware(req, _res, next) {
|
|
36548
|
-
const headers = req.headers;
|
|
36549
|
-
if (!headers[CSRF_HEADER_KEY]) {
|
|
36550
|
-
const token = extractCsrfFromCookie(req.headers.cookie);
|
|
36551
|
-
if (token) headers[CSRF_HEADER_KEY] = token;
|
|
36552
|
-
}
|
|
36553
|
-
if (webUserHeader && !headers[WEBUSER_HEADER_KEY]) {
|
|
36554
|
-
headers[WEBUSER_HEADER_KEY] = webUserHeader;
|
|
36555
|
-
}
|
|
36556
|
-
next();
|
|
36557
|
-
}, "localDevMiddleware");
|
|
36558
|
-
}
|
|
36559
|
-
__name(createLocalDevMiddleware, "createLocalDevMiddleware");
|
|
36560
|
-
|
|
36561
36525
|
// src/setup.ts
|
|
36562
36526
|
var DEFAULT_BODY_LIMIT = "1mb";
|
|
36563
36527
|
var defaultPerms = {
|
|
@@ -36575,9 +36539,6 @@ async function configureApp(app, perms = defaultPerms) {
|
|
|
36575
36539
|
extended: true
|
|
36576
36540
|
}));
|
|
36577
36541
|
app.use(cookieParser());
|
|
36578
|
-
if (isLocalDev()) {
|
|
36579
|
-
app.use(createLocalDevMiddleware());
|
|
36580
|
-
}
|
|
36581
36542
|
app.use(createLegacyPathRedirectMiddleware());
|
|
36582
36543
|
const globalPrefix = process.env.CLIENT_BASE_PATH ?? "";
|
|
36583
36544
|
app.setGlobalPrefix(globalPrefix);
|
|
@@ -36627,9 +36588,7 @@ export {
|
|
|
36627
36588
|
UserContextMiddleware,
|
|
36628
36589
|
ViewContextMiddleware,
|
|
36629
36590
|
configureApp,
|
|
36630
|
-
createLegacyPathRedirectMiddleware
|
|
36631
|
-
createLocalDevMiddleware,
|
|
36632
|
-
isLocalDev
|
|
36591
|
+
createLegacyPathRedirectMiddleware
|
|
36633
36592
|
};
|
|
36634
36593
|
/*! Bundled license information:
|
|
36635
36594
|
|