@lark-apaas/fullstack-nestjs-core 1.1.51-alpha.3 → 1.1.51-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 +12 -63
- package/dist/index.d.cts +11 -5
- package/dist/index.d.ts +11 -5
- package/dist/index.js +12 -61
- package/package.json +11 -11
package/dist/index.cjs
CHANGED
|
@@ -34423,24 +34423,10 @@ __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
|
|
|
34432
|
-
// src/load-env.ts
|
|
34433
|
-
try {
|
|
34434
|
-
const dotenv = require("dotenv");
|
|
34435
|
-
dotenv.config({
|
|
34436
|
-
path: ".env.local"
|
|
34437
|
-
});
|
|
34438
|
-
dotenv.config({
|
|
34439
|
-
path: ".env"
|
|
34440
|
-
});
|
|
34441
|
-
} catch {
|
|
34442
|
-
}
|
|
34443
|
-
|
|
34444
34430
|
// src/modules/platform/module.ts
|
|
34445
34431
|
var import_common16 = require("@nestjs/common");
|
|
34446
34432
|
var import_core2 = require("@nestjs/core");
|
|
@@ -34451,6 +34437,7 @@ var import_axios2 = require("@nestjs/axios");
|
|
|
34451
34437
|
var import_nestjs_logger2 = require("@lark-apaas/nestjs-logger");
|
|
34452
34438
|
var import_nestjs_datapaas = require("@lark-apaas/nestjs-datapaas");
|
|
34453
34439
|
var import_nestjs_authnpaas = require("@lark-apaas/nestjs-authnpaas");
|
|
34440
|
+
var import_nestjs_http_forwarder = require("@lark-apaas/nestjs-http-forwarder");
|
|
34454
34441
|
var import_nestjs_trigger = require("@lark-apaas/nestjs-trigger");
|
|
34455
34442
|
var import_nestjs_common7 = require("@lark-apaas/nestjs-common");
|
|
34456
34443
|
var import_nestjs_capability = require("@lark-apaas/nestjs-capability");
|
|
@@ -34567,7 +34554,7 @@ CsrfMiddleware = _ts_decorate2([
|
|
|
34567
34554
|
(0, import_common2.Injectable)()
|
|
34568
34555
|
], CsrfMiddleware);
|
|
34569
34556
|
|
|
34570
|
-
// src/middlewares/view-context/
|
|
34557
|
+
// src/middlewares/view-context/middleware.ts
|
|
34571
34558
|
var import_common3 = require("@nestjs/common");
|
|
34572
34559
|
var import_nestjs_common = require("@lark-apaas/nestjs-common");
|
|
34573
34560
|
|
|
@@ -34614,7 +34601,7 @@ function safeEscape(s) {
|
|
|
34614
34601
|
}
|
|
34615
34602
|
__name(safeEscape, "safeEscape");
|
|
34616
34603
|
|
|
34617
|
-
// src/middlewares/view-context/
|
|
34604
|
+
// src/middlewares/view-context/middleware.ts
|
|
34618
34605
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
34619
34606
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
34620
34607
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -34665,6 +34652,7 @@ var ViewContextMiddleware = class _ViewContextMiddleware {
|
|
|
34665
34652
|
const { userId, tenantId, appId, loginUrl, userType } = req.userContext;
|
|
34666
34653
|
const csrfToken = req.csrfToken;
|
|
34667
34654
|
const environment = mapToWindowEnvironment(process.env.FORCE_FRAMEWORK_ENVIRONMENT);
|
|
34655
|
+
const basename = safeEscape(req.headers["x-miaoda-custom-host"] !== void 0 ? "/" : `/app/${appId || ""}`);
|
|
34668
34656
|
const appPublishedData = await this.getAppPublished(appId);
|
|
34669
34657
|
const appInfo = appPublishedData?.app_info ?? null;
|
|
34670
34658
|
req.__platform_data__ = {
|
|
@@ -34679,7 +34667,8 @@ var ViewContextMiddleware = class _ViewContextMiddleware {
|
|
|
34679
34667
|
tenantId,
|
|
34680
34668
|
environment,
|
|
34681
34669
|
showBadge: appInfo?.show_badge !== false,
|
|
34682
|
-
appPublished: appPublishedData ?? null
|
|
34670
|
+
appPublished: appPublishedData ?? null,
|
|
34671
|
+
basename
|
|
34683
34672
|
};
|
|
34684
34673
|
res.locals = {
|
|
34685
34674
|
...res.locals ?? {},
|
|
@@ -34692,7 +34681,8 @@ var ViewContextMiddleware = class _ViewContextMiddleware {
|
|
|
34692
34681
|
appName: safeEscape(appInfo?.app_name ?? "\u5999\u642D\u5E94\u7528"),
|
|
34693
34682
|
appAvatar: appInfo?.app_avatar ?? "",
|
|
34694
34683
|
appDescription: safeEscape(appInfo?.app_description ?? ""),
|
|
34695
|
-
environment
|
|
34684
|
+
environment,
|
|
34685
|
+
basename
|
|
34696
34686
|
};
|
|
34697
34687
|
next();
|
|
34698
34688
|
}
|
|
@@ -36417,6 +36407,9 @@ var PlatformModule = class _PlatformModule {
|
|
|
36417
36407
|
...options.authz || {}
|
|
36418
36408
|
}),
|
|
36419
36409
|
import_nestjs_trigger.AutomationModule.forRoot(),
|
|
36410
|
+
// 通用内网转发:自动注册 ALL /api/__platform__/http-forward?targetUrl=...
|
|
36411
|
+
// 业务方接入 PlatformModule 后零改动获得内网代理路由
|
|
36412
|
+
import_nestjs_http_forwarder.HttpForwarderModule.forRoot(options.httpForwarder),
|
|
36420
36413
|
import_nestjs_capability.CapabilityModule.forRoot({
|
|
36421
36414
|
capabilitiesDir: options.capabilitiesDir,
|
|
36422
36415
|
enableWatching: process.env.NODE_ENV === "development"
|
|
@@ -36560,45 +36553,6 @@ function createLegacyPathRedirectMiddleware() {
|
|
|
36560
36553
|
}
|
|
36561
36554
|
__name(createLegacyPathRedirectMiddleware, "createLegacyPathRedirectMiddleware");
|
|
36562
36555
|
|
|
36563
|
-
// src/middlewares/local-dev/index.ts
|
|
36564
|
-
var CSRF_COOKIE_KEY = "suda-csrf-token";
|
|
36565
|
-
var CSRF_HEADER_KEY = "x-suda-csrf-token";
|
|
36566
|
-
var WEBUSER_HEADER_KEY = "x-larkgw-suda-webuser";
|
|
36567
|
-
function isLocalDev() {
|
|
36568
|
-
if (process.env.NODE_ENV === "production") return false;
|
|
36569
|
-
const flag = process.env.MIAODA_LOCAL_DEV;
|
|
36570
|
-
return flag === "1" || flag === "true";
|
|
36571
|
-
}
|
|
36572
|
-
__name(isLocalDev, "isLocalDev");
|
|
36573
|
-
function extractCsrfFromCookie(cookieHeader) {
|
|
36574
|
-
if (!cookieHeader) return void 0;
|
|
36575
|
-
const re = new RegExp(`(?:^|;\\s*)${CSRF_COOKIE_KEY}=([^;]+)`);
|
|
36576
|
-
const m = cookieHeader.match(re);
|
|
36577
|
-
return m?.[1];
|
|
36578
|
-
}
|
|
36579
|
-
__name(extractCsrfFromCookie, "extractCsrfFromCookie");
|
|
36580
|
-
function createLocalDevMiddleware() {
|
|
36581
|
-
let webUserHeader = "";
|
|
36582
|
-
if (process.env.SUDA_WEBUSER) {
|
|
36583
|
-
try {
|
|
36584
|
-
webUserHeader = encodeURIComponent(JSON.stringify(JSON.parse(process.env.SUDA_WEBUSER)));
|
|
36585
|
-
} catch {
|
|
36586
|
-
}
|
|
36587
|
-
}
|
|
36588
|
-
return /* @__PURE__ */ __name(function localDevMiddleware(req, _res, next) {
|
|
36589
|
-
const headers = req.headers;
|
|
36590
|
-
if (!headers[CSRF_HEADER_KEY]) {
|
|
36591
|
-
const token = extractCsrfFromCookie(req.headers.cookie);
|
|
36592
|
-
if (token) headers[CSRF_HEADER_KEY] = token;
|
|
36593
|
-
}
|
|
36594
|
-
if (webUserHeader && !headers[WEBUSER_HEADER_KEY]) {
|
|
36595
|
-
headers[WEBUSER_HEADER_KEY] = webUserHeader;
|
|
36596
|
-
}
|
|
36597
|
-
next();
|
|
36598
|
-
}, "localDevMiddleware");
|
|
36599
|
-
}
|
|
36600
|
-
__name(createLocalDevMiddleware, "createLocalDevMiddleware");
|
|
36601
|
-
|
|
36602
36556
|
// src/setup.ts
|
|
36603
36557
|
var DEFAULT_BODY_LIMIT = "1mb";
|
|
36604
36558
|
var defaultPerms = {
|
|
@@ -36616,9 +36570,6 @@ async function configureApp(app, perms = defaultPerms) {
|
|
|
36616
36570
|
extended: true
|
|
36617
36571
|
}));
|
|
36618
36572
|
app.use((0, import_cookie_parser.default)());
|
|
36619
|
-
if (isLocalDev()) {
|
|
36620
|
-
app.use(createLocalDevMiddleware());
|
|
36621
|
-
}
|
|
36622
36573
|
app.use(createLegacyPathRedirectMiddleware());
|
|
36623
36574
|
const globalPrefix = process.env.CLIENT_BASE_PATH ?? "";
|
|
36624
36575
|
app.setGlobalPrefix(globalPrefix);
|
|
@@ -36670,8 +36621,6 @@ var import_nestjs_authzpaas2 = require("@lark-apaas/nestjs-authzpaas");
|
|
|
36670
36621
|
ViewContextMiddleware,
|
|
36671
36622
|
configureApp,
|
|
36672
36623
|
createLegacyPathRedirectMiddleware,
|
|
36673
|
-
createLocalDevMiddleware,
|
|
36674
|
-
isLocalDev,
|
|
36675
36624
|
...require("@lark-apaas/nestjs-authnpaas"),
|
|
36676
36625
|
...require("@lark-apaas/nestjs-capability"),
|
|
36677
36626
|
...require("@lark-apaas/nestjs-datapaas"),
|
package/dist/index.d.cts
CHANGED
|
@@ -2,11 +2,12 @@ import { NestModule, DynamicModule, MiddlewareConsumer, OnModuleInit, NestMiddle
|
|
|
2
2
|
import { HttpClientConfig, PlatformPluginOptions, HttpClient } from '@lark-apaas/http-client';
|
|
3
3
|
import { AuthZPaasModuleOptions } from '@lark-apaas/nestjs-authzpaas';
|
|
4
4
|
export { AddMembersParams, AuthZPaasModule, AuthorizationSDK, Can, CanRole, ChatSimpleDTO, CommonParam, CreateRoleParams, CreateRoleResponse, DepartmentDTO, DepartmentEntity, DepartmentSimpleDTO, FilterParams, ForceRoleDTO, I18nText, IPermissionResolver, ListMembersParams, ListMembersResponse, ListRolesParams, MemberMutationData, MemberType, PERMISSION_RESOLVER_TOKEN, PermissionPoint, PermissionRequirement, PresetGroupDTO, RemoveMembersParams, RoleMemberDTO, SearchChatEntity, SearchParams, SearchResponse, SearchResult, SearchUserEntity, UpdateRoleParams, UserSimpleDTO } from '@lark-apaas/nestjs-authzpaas';
|
|
5
|
+
import { HttpForwarderModuleOptions } from '@lark-apaas/nestjs-http-forwarder';
|
|
5
6
|
import { NestExpressApplication } from '@nestjs/platform-express';
|
|
6
7
|
import { PlatformHttpClient, RequestContextService, ObservableService } from '@lark-apaas/nestjs-common';
|
|
7
8
|
export { AutoTrace } from '@lark-apaas/nestjs-common';
|
|
8
9
|
export { DevToolsModule, DevToolsOptions, DevToolsV2Module, DevToolsV2Options } from '@lark-apaas/nestjs-openapi-devtools';
|
|
9
|
-
import { Request, Response, NextFunction
|
|
10
|
+
import { Request, Response, NextFunction } from 'express';
|
|
10
11
|
import * as _lark_apaas_file_service from '@lark-apaas/file-service';
|
|
11
12
|
import { FileBody, UploadOptions, FileDownloadBuilder, SearchOptions } from '@lark-apaas/file-service';
|
|
12
13
|
export * from '@lark-apaas/file-service';
|
|
@@ -23,6 +24,8 @@ declare global {
|
|
|
23
24
|
userId?: string;
|
|
24
25
|
tenantId?: number;
|
|
25
26
|
csrfToken?: string;
|
|
27
|
+
/** React Router basename,由 ViewContextMiddleware 注入;自定义域名场景下 = / 或 /<alias>,默认域名 = /app/<appId> */
|
|
28
|
+
basename?: string;
|
|
26
29
|
[key: string]: unknown;
|
|
27
30
|
};
|
|
28
31
|
userContext: {
|
|
@@ -78,6 +81,12 @@ interface PlatformModuleOptions {
|
|
|
78
81
|
* 可传入 permissionResolver 等选项,透传给 AuthZPaasModule.forRoot()
|
|
79
82
|
*/
|
|
80
83
|
authz?: AuthZPaasModuleOptions;
|
|
84
|
+
/**
|
|
85
|
+
* HttpForwarder 模块配置(默认自动启用,注册 ALL /api/__platform__/http-forward 路由)
|
|
86
|
+
* 透传给 HttpForwarderModule.forRoot();不传则使用模块默认值
|
|
87
|
+
* (requestTimeoutMs=30s, maxResponseBytes=10MB)。
|
|
88
|
+
*/
|
|
89
|
+
httpForwarder?: HttpForwarderModuleOptions;
|
|
81
90
|
}
|
|
82
91
|
|
|
83
92
|
declare class PlatformModule implements NestModule {
|
|
@@ -221,9 +230,6 @@ declare class ViewContextMiddleware implements NestMiddleware {
|
|
|
221
230
|
*/
|
|
222
231
|
declare function createLegacyPathRedirectMiddleware(): (req: Request, res: Response, next: NextFunction) => void;
|
|
223
232
|
|
|
224
|
-
declare function isLocalDev(): boolean;
|
|
225
|
-
declare function createLocalDevMiddleware(): RequestHandler;
|
|
226
|
-
|
|
227
233
|
/**
|
|
228
234
|
* API 404 响应格式
|
|
229
235
|
*/
|
|
@@ -405,4 +411,4 @@ declare class PlatformHttpClientService {
|
|
|
405
411
|
private registerInterceptorsForClient;
|
|
406
412
|
}
|
|
407
413
|
|
|
408
|
-
export { type ApiNotFoundResponse, CsrfMiddleware, CsrfTokenMiddleware, FileService, HtmlHotUpdateModule, HtmlHotUpdateService, type PlatformHttpClientOptions, PlatformHttpClientService, PlatformModule, type PlatformModuleOptions, StaticModule, UserContextMiddleware, ViewContextMiddleware, configureApp, createLegacyPathRedirectMiddleware
|
|
414
|
+
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
|
@@ -2,11 +2,12 @@ import { NestModule, DynamicModule, MiddlewareConsumer, OnModuleInit, NestMiddle
|
|
|
2
2
|
import { HttpClientConfig, PlatformPluginOptions, HttpClient } from '@lark-apaas/http-client';
|
|
3
3
|
import { AuthZPaasModuleOptions } from '@lark-apaas/nestjs-authzpaas';
|
|
4
4
|
export { AddMembersParams, AuthZPaasModule, AuthorizationSDK, Can, CanRole, ChatSimpleDTO, CommonParam, CreateRoleParams, CreateRoleResponse, DepartmentDTO, DepartmentEntity, DepartmentSimpleDTO, FilterParams, ForceRoleDTO, I18nText, IPermissionResolver, ListMembersParams, ListMembersResponse, ListRolesParams, MemberMutationData, MemberType, PERMISSION_RESOLVER_TOKEN, PermissionPoint, PermissionRequirement, PresetGroupDTO, RemoveMembersParams, RoleMemberDTO, SearchChatEntity, SearchParams, SearchResponse, SearchResult, SearchUserEntity, UpdateRoleParams, UserSimpleDTO } from '@lark-apaas/nestjs-authzpaas';
|
|
5
|
+
import { HttpForwarderModuleOptions } from '@lark-apaas/nestjs-http-forwarder';
|
|
5
6
|
import { NestExpressApplication } from '@nestjs/platform-express';
|
|
6
7
|
import { PlatformHttpClient, RequestContextService, ObservableService } from '@lark-apaas/nestjs-common';
|
|
7
8
|
export { AutoTrace } from '@lark-apaas/nestjs-common';
|
|
8
9
|
export { DevToolsModule, DevToolsOptions, DevToolsV2Module, DevToolsV2Options } from '@lark-apaas/nestjs-openapi-devtools';
|
|
9
|
-
import { Request, Response, NextFunction
|
|
10
|
+
import { Request, Response, NextFunction } from 'express';
|
|
10
11
|
import * as _lark_apaas_file_service from '@lark-apaas/file-service';
|
|
11
12
|
import { FileBody, UploadOptions, FileDownloadBuilder, SearchOptions } from '@lark-apaas/file-service';
|
|
12
13
|
export * from '@lark-apaas/file-service';
|
|
@@ -23,6 +24,8 @@ declare global {
|
|
|
23
24
|
userId?: string;
|
|
24
25
|
tenantId?: number;
|
|
25
26
|
csrfToken?: string;
|
|
27
|
+
/** React Router basename,由 ViewContextMiddleware 注入;自定义域名场景下 = / 或 /<alias>,默认域名 = /app/<appId> */
|
|
28
|
+
basename?: string;
|
|
26
29
|
[key: string]: unknown;
|
|
27
30
|
};
|
|
28
31
|
userContext: {
|
|
@@ -78,6 +81,12 @@ interface PlatformModuleOptions {
|
|
|
78
81
|
* 可传入 permissionResolver 等选项,透传给 AuthZPaasModule.forRoot()
|
|
79
82
|
*/
|
|
80
83
|
authz?: AuthZPaasModuleOptions;
|
|
84
|
+
/**
|
|
85
|
+
* HttpForwarder 模块配置(默认自动启用,注册 ALL /api/__platform__/http-forward 路由)
|
|
86
|
+
* 透传给 HttpForwarderModule.forRoot();不传则使用模块默认值
|
|
87
|
+
* (requestTimeoutMs=30s, maxResponseBytes=10MB)。
|
|
88
|
+
*/
|
|
89
|
+
httpForwarder?: HttpForwarderModuleOptions;
|
|
81
90
|
}
|
|
82
91
|
|
|
83
92
|
declare class PlatformModule implements NestModule {
|
|
@@ -221,9 +230,6 @@ declare class ViewContextMiddleware implements NestMiddleware {
|
|
|
221
230
|
*/
|
|
222
231
|
declare function createLegacyPathRedirectMiddleware(): (req: Request, res: Response, next: NextFunction) => void;
|
|
223
232
|
|
|
224
|
-
declare function isLocalDev(): boolean;
|
|
225
|
-
declare function createLocalDevMiddleware(): RequestHandler;
|
|
226
|
-
|
|
227
233
|
/**
|
|
228
234
|
* API 404 响应格式
|
|
229
235
|
*/
|
|
@@ -405,4 +411,4 @@ declare class PlatformHttpClientService {
|
|
|
405
411
|
private registerInterceptorsForClient;
|
|
406
412
|
}
|
|
407
413
|
|
|
408
|
-
export { type ApiNotFoundResponse, CsrfMiddleware, CsrfTokenMiddleware, FileService, HtmlHotUpdateModule, HtmlHotUpdateService, type PlatformHttpClientOptions, PlatformHttpClientService, PlatformModule, type PlatformModuleOptions, StaticModule, UserContextMiddleware, ViewContextMiddleware, configureApp, createLegacyPathRedirectMiddleware
|
|
414
|
+
export { type ApiNotFoundResponse, CsrfMiddleware, CsrfTokenMiddleware, FileService, HtmlHotUpdateModule, HtmlHotUpdateService, type PlatformHttpClientOptions, PlatformHttpClientService, PlatformModule, type PlatformModuleOptions, StaticModule, UserContextMiddleware, ViewContextMiddleware, configureApp, createLegacyPathRedirectMiddleware };
|
package/dist/index.js
CHANGED
|
@@ -34400,18 +34400,6 @@ var require_express2 = __commonJS({
|
|
|
34400
34400
|
}
|
|
34401
34401
|
});
|
|
34402
34402
|
|
|
34403
|
-
// src/load-env.ts
|
|
34404
|
-
try {
|
|
34405
|
-
const dotenv = __require("dotenv");
|
|
34406
|
-
dotenv.config({
|
|
34407
|
-
path: ".env.local"
|
|
34408
|
-
});
|
|
34409
|
-
dotenv.config({
|
|
34410
|
-
path: ".env"
|
|
34411
|
-
});
|
|
34412
|
-
} catch {
|
|
34413
|
-
}
|
|
34414
|
-
|
|
34415
34403
|
// src/modules/platform/module.ts
|
|
34416
34404
|
import { Global, Module as Module3, ValidationPipe } from "@nestjs/common";
|
|
34417
34405
|
import { APP_INTERCEPTOR, APP_PIPE } from "@nestjs/core";
|
|
@@ -34422,6 +34410,7 @@ import { HttpModule } from "@nestjs/axios";
|
|
|
34422
34410
|
import { LoggerModule, AppLogger as AppLogger2, LoggerContextMiddleware } from "@lark-apaas/nestjs-logger";
|
|
34423
34411
|
import { DataPaasModule, SqlExecutionContextMiddleware } from "@lark-apaas/nestjs-datapaas";
|
|
34424
34412
|
import { AuthNPaasModule } from "@lark-apaas/nestjs-authnpaas";
|
|
34413
|
+
import { HttpForwarderModule } from "@lark-apaas/nestjs-http-forwarder";
|
|
34425
34414
|
import { AutomationModule } from "@lark-apaas/nestjs-trigger";
|
|
34426
34415
|
import { PLATFORM_HTTP_CLIENT as PLATFORM_HTTP_CLIENT4 } from "@lark-apaas/nestjs-common";
|
|
34427
34416
|
import { CapabilityModule } from "@lark-apaas/nestjs-capability";
|
|
@@ -34538,7 +34527,7 @@ CsrfMiddleware = _ts_decorate2([
|
|
|
34538
34527
|
Injectable2()
|
|
34539
34528
|
], CsrfMiddleware);
|
|
34540
34529
|
|
|
34541
|
-
// src/middlewares/view-context/
|
|
34530
|
+
// src/middlewares/view-context/middleware.ts
|
|
34542
34531
|
import { Inject, Injectable as Injectable3, Logger } from "@nestjs/common";
|
|
34543
34532
|
import { PLATFORM_HTTP_CLIENT } from "@lark-apaas/nestjs-common";
|
|
34544
34533
|
|
|
@@ -34585,7 +34574,7 @@ function safeEscape(s) {
|
|
|
34585
34574
|
}
|
|
34586
34575
|
__name(safeEscape, "safeEscape");
|
|
34587
34576
|
|
|
34588
|
-
// src/middlewares/view-context/
|
|
34577
|
+
// src/middlewares/view-context/middleware.ts
|
|
34589
34578
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
34590
34579
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
34591
34580
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -34636,6 +34625,7 @@ var ViewContextMiddleware = class _ViewContextMiddleware {
|
|
|
34636
34625
|
const { userId, tenantId, appId, loginUrl, userType } = req.userContext;
|
|
34637
34626
|
const csrfToken = req.csrfToken;
|
|
34638
34627
|
const environment = mapToWindowEnvironment(process.env.FORCE_FRAMEWORK_ENVIRONMENT);
|
|
34628
|
+
const basename = safeEscape(req.headers["x-miaoda-custom-host"] !== void 0 ? "/" : `/app/${appId || ""}`);
|
|
34639
34629
|
const appPublishedData = await this.getAppPublished(appId);
|
|
34640
34630
|
const appInfo = appPublishedData?.app_info ?? null;
|
|
34641
34631
|
req.__platform_data__ = {
|
|
@@ -34650,7 +34640,8 @@ var ViewContextMiddleware = class _ViewContextMiddleware {
|
|
|
34650
34640
|
tenantId,
|
|
34651
34641
|
environment,
|
|
34652
34642
|
showBadge: appInfo?.show_badge !== false,
|
|
34653
|
-
appPublished: appPublishedData ?? null
|
|
34643
|
+
appPublished: appPublishedData ?? null,
|
|
34644
|
+
basename
|
|
34654
34645
|
};
|
|
34655
34646
|
res.locals = {
|
|
34656
34647
|
...res.locals ?? {},
|
|
@@ -34663,7 +34654,8 @@ var ViewContextMiddleware = class _ViewContextMiddleware {
|
|
|
34663
34654
|
appName: safeEscape(appInfo?.app_name ?? "\u5999\u642D\u5E94\u7528"),
|
|
34664
34655
|
appAvatar: appInfo?.app_avatar ?? "",
|
|
34665
34656
|
appDescription: safeEscape(appInfo?.app_description ?? ""),
|
|
34666
|
-
environment
|
|
34657
|
+
environment,
|
|
34658
|
+
basename
|
|
34667
34659
|
};
|
|
34668
34660
|
next();
|
|
34669
34661
|
}
|
|
@@ -36388,6 +36380,9 @@ var PlatformModule = class _PlatformModule {
|
|
|
36388
36380
|
...options.authz || {}
|
|
36389
36381
|
}),
|
|
36390
36382
|
AutomationModule.forRoot(),
|
|
36383
|
+
// 通用内网转发:自动注册 ALL /api/__platform__/http-forward?targetUrl=...
|
|
36384
|
+
// 业务方接入 PlatformModule 后零改动获得内网代理路由
|
|
36385
|
+
HttpForwarderModule.forRoot(options.httpForwarder),
|
|
36391
36386
|
CapabilityModule.forRoot({
|
|
36392
36387
|
capabilitiesDir: options.capabilitiesDir,
|
|
36393
36388
|
enableWatching: process.env.NODE_ENV === "development"
|
|
@@ -36531,45 +36526,6 @@ function createLegacyPathRedirectMiddleware() {
|
|
|
36531
36526
|
}
|
|
36532
36527
|
__name(createLegacyPathRedirectMiddleware, "createLegacyPathRedirectMiddleware");
|
|
36533
36528
|
|
|
36534
|
-
// src/middlewares/local-dev/index.ts
|
|
36535
|
-
var CSRF_COOKIE_KEY = "suda-csrf-token";
|
|
36536
|
-
var CSRF_HEADER_KEY = "x-suda-csrf-token";
|
|
36537
|
-
var WEBUSER_HEADER_KEY = "x-larkgw-suda-webuser";
|
|
36538
|
-
function isLocalDev() {
|
|
36539
|
-
if (process.env.NODE_ENV === "production") return false;
|
|
36540
|
-
const flag = process.env.MIAODA_LOCAL_DEV;
|
|
36541
|
-
return flag === "1" || flag === "true";
|
|
36542
|
-
}
|
|
36543
|
-
__name(isLocalDev, "isLocalDev");
|
|
36544
|
-
function extractCsrfFromCookie(cookieHeader) {
|
|
36545
|
-
if (!cookieHeader) return void 0;
|
|
36546
|
-
const re = new RegExp(`(?:^|;\\s*)${CSRF_COOKIE_KEY}=([^;]+)`);
|
|
36547
|
-
const m = cookieHeader.match(re);
|
|
36548
|
-
return m?.[1];
|
|
36549
|
-
}
|
|
36550
|
-
__name(extractCsrfFromCookie, "extractCsrfFromCookie");
|
|
36551
|
-
function createLocalDevMiddleware() {
|
|
36552
|
-
let webUserHeader = "";
|
|
36553
|
-
if (process.env.SUDA_WEBUSER) {
|
|
36554
|
-
try {
|
|
36555
|
-
webUserHeader = encodeURIComponent(JSON.stringify(JSON.parse(process.env.SUDA_WEBUSER)));
|
|
36556
|
-
} catch {
|
|
36557
|
-
}
|
|
36558
|
-
}
|
|
36559
|
-
return /* @__PURE__ */ __name(function localDevMiddleware(req, _res, next) {
|
|
36560
|
-
const headers = req.headers;
|
|
36561
|
-
if (!headers[CSRF_HEADER_KEY]) {
|
|
36562
|
-
const token = extractCsrfFromCookie(req.headers.cookie);
|
|
36563
|
-
if (token) headers[CSRF_HEADER_KEY] = token;
|
|
36564
|
-
}
|
|
36565
|
-
if (webUserHeader && !headers[WEBUSER_HEADER_KEY]) {
|
|
36566
|
-
headers[WEBUSER_HEADER_KEY] = webUserHeader;
|
|
36567
|
-
}
|
|
36568
|
-
next();
|
|
36569
|
-
}, "localDevMiddleware");
|
|
36570
|
-
}
|
|
36571
|
-
__name(createLocalDevMiddleware, "createLocalDevMiddleware");
|
|
36572
|
-
|
|
36573
36529
|
// src/setup.ts
|
|
36574
36530
|
var DEFAULT_BODY_LIMIT = "1mb";
|
|
36575
36531
|
var defaultPerms = {
|
|
@@ -36587,9 +36543,6 @@ async function configureApp(app, perms = defaultPerms) {
|
|
|
36587
36543
|
extended: true
|
|
36588
36544
|
}));
|
|
36589
36545
|
app.use(cookieParser());
|
|
36590
|
-
if (isLocalDev()) {
|
|
36591
|
-
app.use(createLocalDevMiddleware());
|
|
36592
|
-
}
|
|
36593
36546
|
app.use(createLegacyPathRedirectMiddleware());
|
|
36594
36547
|
const globalPrefix = process.env.CLIENT_BASE_PATH ?? "";
|
|
36595
36548
|
app.setGlobalPrefix(globalPrefix);
|
|
@@ -36639,9 +36592,7 @@ export {
|
|
|
36639
36592
|
UserContextMiddleware,
|
|
36640
36593
|
ViewContextMiddleware,
|
|
36641
36594
|
configureApp,
|
|
36642
|
-
createLegacyPathRedirectMiddleware
|
|
36643
|
-
createLocalDevMiddleware,
|
|
36644
|
-
isLocalDev
|
|
36595
|
+
createLegacyPathRedirectMiddleware
|
|
36645
36596
|
};
|
|
36646
36597
|
/*! Bundled license information:
|
|
36647
36598
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lark-apaas/fullstack-nestjs-core",
|
|
3
|
-
"version": "1.1.51-
|
|
3
|
+
"version": "1.1.51-beta.0",
|
|
4
4
|
"description": "FullStack Nestjs Core",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -40,20 +40,20 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@lark-apaas/file-service": "^0.1.2",
|
|
43
|
-
"@lark-apaas/http-client": "0.1.
|
|
44
|
-
"@lark-apaas/nestjs-authnpaas": "
|
|
45
|
-
"@lark-apaas/nestjs-authzpaas": "
|
|
46
|
-
"@lark-apaas/nestjs-capability": "
|
|
47
|
-
"@lark-apaas/nestjs-common": "
|
|
48
|
-
"@lark-apaas/nestjs-datapaas": "
|
|
49
|
-
"@lark-apaas/nestjs-
|
|
50
|
-
"@lark-apaas/nestjs-
|
|
43
|
+
"@lark-apaas/http-client": "^0.1.6",
|
|
44
|
+
"@lark-apaas/nestjs-authnpaas": "1.0.4-beta.0",
|
|
45
|
+
"@lark-apaas/nestjs-authzpaas": "0.1.9-beta.0",
|
|
46
|
+
"@lark-apaas/nestjs-capability": "0.1.14-beta.0",
|
|
47
|
+
"@lark-apaas/nestjs-common": "0.1.9-beta.0",
|
|
48
|
+
"@lark-apaas/nestjs-datapaas": "1.0.21-beta.0",
|
|
49
|
+
"@lark-apaas/nestjs-http-forwarder": "0.1.3-beta.0",
|
|
50
|
+
"@lark-apaas/nestjs-logger": "1.0.17-beta.0",
|
|
51
|
+
"@lark-apaas/nestjs-observable": "0.0.12-beta.0",
|
|
51
52
|
"@lark-apaas/nestjs-openapi-devtools": "^1.0.10",
|
|
52
53
|
"@lark-apaas/nestjs-trigger": "^0.0.3",
|
|
53
54
|
"@nestjs/axios": "^4.0.1",
|
|
54
55
|
"axios": "^1.13.2",
|
|
55
|
-
"cookie-parser": "^1.4.7"
|
|
56
|
-
"dotenv": "^16.4.5"
|
|
56
|
+
"cookie-parser": "^1.4.7"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@nestjs/common": "^10.4.20",
|