@lark-apaas/fullstack-nestjs-core 1.1.50-alpha.7 → 1.1.50-alpha.8
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 +47 -5
- package/dist/index.d.cts +5 -9
- package/dist/index.d.ts +5 -9
- package/dist/index.js +45 -5
- package/package.json +1 -2
package/dist/index.cjs
CHANGED
|
@@ -34423,7 +34423,9 @@ __export(index_exports, {
|
|
|
34423
34423
|
UserContextMiddleware: () => UserContextMiddleware,
|
|
34424
34424
|
ViewContextMiddleware: () => ViewContextMiddleware,
|
|
34425
34425
|
configureApp: () => configureApp,
|
|
34426
|
-
createLegacyPathRedirectMiddleware: () => createLegacyPathRedirectMiddleware
|
|
34426
|
+
createLegacyPathRedirectMiddleware: () => createLegacyPathRedirectMiddleware,
|
|
34427
|
+
createLocalDevMiddleware: () => createLocalDevMiddleware,
|
|
34428
|
+
isLocalDev: () => isLocalDev
|
|
34427
34429
|
});
|
|
34428
34430
|
module.exports = __toCommonJS(index_exports);
|
|
34429
34431
|
|
|
@@ -34437,7 +34439,6 @@ var import_axios2 = require("@nestjs/axios");
|
|
|
34437
34439
|
var import_nestjs_logger2 = require("@lark-apaas/nestjs-logger");
|
|
34438
34440
|
var import_nestjs_datapaas = require("@lark-apaas/nestjs-datapaas");
|
|
34439
34441
|
var import_nestjs_authnpaas = require("@lark-apaas/nestjs-authnpaas");
|
|
34440
|
-
var import_nestjs_http_forwarder = require("@lark-apaas/nestjs-http-forwarder");
|
|
34441
34442
|
var import_nestjs_trigger = require("@lark-apaas/nestjs-trigger");
|
|
34442
34443
|
var import_nestjs_common7 = require("@lark-apaas/nestjs-common");
|
|
34443
34444
|
var import_nestjs_capability = require("@lark-apaas/nestjs-capability");
|
|
@@ -36404,9 +36405,6 @@ var PlatformModule = class _PlatformModule {
|
|
|
36404
36405
|
...options.authz || {}
|
|
36405
36406
|
}),
|
|
36406
36407
|
import_nestjs_trigger.AutomationModule.forRoot(),
|
|
36407
|
-
// 通用内网转发:自动注册 ALL /api/__platform__/http-forward?targetUrl=...
|
|
36408
|
-
// 业务方接入 PlatformModule 后零改动获得内网代理路由
|
|
36409
|
-
import_nestjs_http_forwarder.HttpForwarderModule.forRoot(options.httpForwarder),
|
|
36410
36408
|
import_nestjs_capability.CapabilityModule.forRoot({
|
|
36411
36409
|
capabilitiesDir: options.capabilitiesDir,
|
|
36412
36410
|
enableWatching: process.env.NODE_ENV === "development"
|
|
@@ -36550,6 +36548,45 @@ function createLegacyPathRedirectMiddleware() {
|
|
|
36550
36548
|
}
|
|
36551
36549
|
__name(createLegacyPathRedirectMiddleware, "createLegacyPathRedirectMiddleware");
|
|
36552
36550
|
|
|
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
|
+
|
|
36553
36590
|
// src/setup.ts
|
|
36554
36591
|
var DEFAULT_BODY_LIMIT = "1mb";
|
|
36555
36592
|
var defaultPerms = {
|
|
@@ -36567,6 +36604,9 @@ async function configureApp(app, perms = defaultPerms) {
|
|
|
36567
36604
|
extended: true
|
|
36568
36605
|
}));
|
|
36569
36606
|
app.use((0, import_cookie_parser.default)());
|
|
36607
|
+
if (isLocalDev()) {
|
|
36608
|
+
app.use(createLocalDevMiddleware());
|
|
36609
|
+
}
|
|
36570
36610
|
app.use(createLegacyPathRedirectMiddleware());
|
|
36571
36611
|
const globalPrefix = process.env.CLIENT_BASE_PATH ?? "";
|
|
36572
36612
|
app.setGlobalPrefix(globalPrefix);
|
|
@@ -36618,6 +36658,8 @@ var import_nestjs_authzpaas2 = require("@lark-apaas/nestjs-authzpaas");
|
|
|
36618
36658
|
ViewContextMiddleware,
|
|
36619
36659
|
configureApp,
|
|
36620
36660
|
createLegacyPathRedirectMiddleware,
|
|
36661
|
+
createLocalDevMiddleware,
|
|
36662
|
+
isLocalDev,
|
|
36621
36663
|
...require("@lark-apaas/nestjs-authnpaas"),
|
|
36622
36664
|
...require("@lark-apaas/nestjs-capability"),
|
|
36623
36665
|
...require("@lark-apaas/nestjs-datapaas"),
|
package/dist/index.d.cts
CHANGED
|
@@ -2,12 +2,11 @@ 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';
|
|
6
5
|
import { NestExpressApplication } from '@nestjs/platform-express';
|
|
7
6
|
import { PlatformHttpClient, RequestContextService, ObservableService } from '@lark-apaas/nestjs-common';
|
|
8
7
|
export { AutoTrace } from '@lark-apaas/nestjs-common';
|
|
9
8
|
export { DevToolsModule, DevToolsOptions, DevToolsV2Module, DevToolsV2Options } from '@lark-apaas/nestjs-openapi-devtools';
|
|
10
|
-
import { Request, Response, NextFunction } from 'express';
|
|
9
|
+
import { Request, Response, NextFunction, RequestHandler } from 'express';
|
|
11
10
|
import * as _lark_apaas_file_service from '@lark-apaas/file-service';
|
|
12
11
|
import { FileBody, UploadOptions, FileDownloadBuilder, SearchOptions } from '@lark-apaas/file-service';
|
|
13
12
|
export * from '@lark-apaas/file-service';
|
|
@@ -79,12 +78,6 @@ interface PlatformModuleOptions {
|
|
|
79
78
|
* 可传入 permissionResolver 等选项,透传给 AuthZPaasModule.forRoot()
|
|
80
79
|
*/
|
|
81
80
|
authz?: AuthZPaasModuleOptions;
|
|
82
|
-
/**
|
|
83
|
-
* HttpForwarder 模块配置(默认自动启用,注册 ALL /api/__platform__/http-forward 路由)
|
|
84
|
-
* 透传给 HttpForwarderModule.forRoot();不传则使用模块默认值
|
|
85
|
-
* (requestTimeoutMs=30s, maxResponseBytes=10MB)。
|
|
86
|
-
*/
|
|
87
|
-
httpForwarder?: HttpForwarderModuleOptions;
|
|
88
81
|
}
|
|
89
82
|
|
|
90
83
|
declare class PlatformModule implements NestModule {
|
|
@@ -228,6 +221,9 @@ declare class ViewContextMiddleware implements NestMiddleware {
|
|
|
228
221
|
*/
|
|
229
222
|
declare function createLegacyPathRedirectMiddleware(): (req: Request, res: Response, next: NextFunction) => void;
|
|
230
223
|
|
|
224
|
+
declare function isLocalDev(): boolean;
|
|
225
|
+
declare function createLocalDevMiddleware(): RequestHandler;
|
|
226
|
+
|
|
231
227
|
/**
|
|
232
228
|
* API 404 响应格式
|
|
233
229
|
*/
|
|
@@ -409,4 +405,4 @@ declare class PlatformHttpClientService {
|
|
|
409
405
|
private registerInterceptorsForClient;
|
|
410
406
|
}
|
|
411
407
|
|
|
412
|
-
export { type ApiNotFoundResponse, CsrfMiddleware, CsrfTokenMiddleware, FileService, HtmlHotUpdateModule, HtmlHotUpdateService, type PlatformHttpClientOptions, PlatformHttpClientService, PlatformModule, type PlatformModuleOptions, StaticModule, UserContextMiddleware, ViewContextMiddleware, configureApp, createLegacyPathRedirectMiddleware };
|
|
408
|
+
export { type ApiNotFoundResponse, CsrfMiddleware, CsrfTokenMiddleware, FileService, HtmlHotUpdateModule, HtmlHotUpdateService, type PlatformHttpClientOptions, PlatformHttpClientService, PlatformModule, type PlatformModuleOptions, StaticModule, UserContextMiddleware, ViewContextMiddleware, configureApp, createLegacyPathRedirectMiddleware, createLocalDevMiddleware, isLocalDev };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,12 +2,11 @@ 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';
|
|
6
5
|
import { NestExpressApplication } from '@nestjs/platform-express';
|
|
7
6
|
import { PlatformHttpClient, RequestContextService, ObservableService } from '@lark-apaas/nestjs-common';
|
|
8
7
|
export { AutoTrace } from '@lark-apaas/nestjs-common';
|
|
9
8
|
export { DevToolsModule, DevToolsOptions, DevToolsV2Module, DevToolsV2Options } from '@lark-apaas/nestjs-openapi-devtools';
|
|
10
|
-
import { Request, Response, NextFunction } from 'express';
|
|
9
|
+
import { Request, Response, NextFunction, RequestHandler } from 'express';
|
|
11
10
|
import * as _lark_apaas_file_service from '@lark-apaas/file-service';
|
|
12
11
|
import { FileBody, UploadOptions, FileDownloadBuilder, SearchOptions } from '@lark-apaas/file-service';
|
|
13
12
|
export * from '@lark-apaas/file-service';
|
|
@@ -79,12 +78,6 @@ interface PlatformModuleOptions {
|
|
|
79
78
|
* 可传入 permissionResolver 等选项,透传给 AuthZPaasModule.forRoot()
|
|
80
79
|
*/
|
|
81
80
|
authz?: AuthZPaasModuleOptions;
|
|
82
|
-
/**
|
|
83
|
-
* HttpForwarder 模块配置(默认自动启用,注册 ALL /api/__platform__/http-forward 路由)
|
|
84
|
-
* 透传给 HttpForwarderModule.forRoot();不传则使用模块默认值
|
|
85
|
-
* (requestTimeoutMs=30s, maxResponseBytes=10MB)。
|
|
86
|
-
*/
|
|
87
|
-
httpForwarder?: HttpForwarderModuleOptions;
|
|
88
81
|
}
|
|
89
82
|
|
|
90
83
|
declare class PlatformModule implements NestModule {
|
|
@@ -228,6 +221,9 @@ declare class ViewContextMiddleware implements NestMiddleware {
|
|
|
228
221
|
*/
|
|
229
222
|
declare function createLegacyPathRedirectMiddleware(): (req: Request, res: Response, next: NextFunction) => void;
|
|
230
223
|
|
|
224
|
+
declare function isLocalDev(): boolean;
|
|
225
|
+
declare function createLocalDevMiddleware(): RequestHandler;
|
|
226
|
+
|
|
231
227
|
/**
|
|
232
228
|
* API 404 响应格式
|
|
233
229
|
*/
|
|
@@ -409,4 +405,4 @@ declare class PlatformHttpClientService {
|
|
|
409
405
|
private registerInterceptorsForClient;
|
|
410
406
|
}
|
|
411
407
|
|
|
412
|
-
export { type ApiNotFoundResponse, CsrfMiddleware, CsrfTokenMiddleware, FileService, HtmlHotUpdateModule, HtmlHotUpdateService, type PlatformHttpClientOptions, PlatformHttpClientService, PlatformModule, type PlatformModuleOptions, StaticModule, UserContextMiddleware, ViewContextMiddleware, configureApp, createLegacyPathRedirectMiddleware };
|
|
408
|
+
export { type ApiNotFoundResponse, CsrfMiddleware, CsrfTokenMiddleware, FileService, HtmlHotUpdateModule, HtmlHotUpdateService, type PlatformHttpClientOptions, PlatformHttpClientService, PlatformModule, type PlatformModuleOptions, StaticModule, UserContextMiddleware, ViewContextMiddleware, configureApp, createLegacyPathRedirectMiddleware, createLocalDevMiddleware, isLocalDev };
|
package/dist/index.js
CHANGED
|
@@ -34410,7 +34410,6 @@ import { HttpModule } from "@nestjs/axios";
|
|
|
34410
34410
|
import { LoggerModule, AppLogger as AppLogger2, LoggerContextMiddleware } from "@lark-apaas/nestjs-logger";
|
|
34411
34411
|
import { DataPaasModule, SqlExecutionContextMiddleware } from "@lark-apaas/nestjs-datapaas";
|
|
34412
34412
|
import { AuthNPaasModule } from "@lark-apaas/nestjs-authnpaas";
|
|
34413
|
-
import { HttpForwarderModule } from "@lark-apaas/nestjs-http-forwarder";
|
|
34414
34413
|
import { AutomationModule } from "@lark-apaas/nestjs-trigger";
|
|
34415
34414
|
import { PLATFORM_HTTP_CLIENT as PLATFORM_HTTP_CLIENT4 } from "@lark-apaas/nestjs-common";
|
|
34416
34415
|
import { CapabilityModule } from "@lark-apaas/nestjs-capability";
|
|
@@ -36377,9 +36376,6 @@ var PlatformModule = class _PlatformModule {
|
|
|
36377
36376
|
...options.authz || {}
|
|
36378
36377
|
}),
|
|
36379
36378
|
AutomationModule.forRoot(),
|
|
36380
|
-
// 通用内网转发:自动注册 ALL /api/__platform__/http-forward?targetUrl=...
|
|
36381
|
-
// 业务方接入 PlatformModule 后零改动获得内网代理路由
|
|
36382
|
-
HttpForwarderModule.forRoot(options.httpForwarder),
|
|
36383
36379
|
CapabilityModule.forRoot({
|
|
36384
36380
|
capabilitiesDir: options.capabilitiesDir,
|
|
36385
36381
|
enableWatching: process.env.NODE_ENV === "development"
|
|
@@ -36523,6 +36519,45 @@ function createLegacyPathRedirectMiddleware() {
|
|
|
36523
36519
|
}
|
|
36524
36520
|
__name(createLegacyPathRedirectMiddleware, "createLegacyPathRedirectMiddleware");
|
|
36525
36521
|
|
|
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
|
+
|
|
36526
36561
|
// src/setup.ts
|
|
36527
36562
|
var DEFAULT_BODY_LIMIT = "1mb";
|
|
36528
36563
|
var defaultPerms = {
|
|
@@ -36540,6 +36575,9 @@ async function configureApp(app, perms = defaultPerms) {
|
|
|
36540
36575
|
extended: true
|
|
36541
36576
|
}));
|
|
36542
36577
|
app.use(cookieParser());
|
|
36578
|
+
if (isLocalDev()) {
|
|
36579
|
+
app.use(createLocalDevMiddleware());
|
|
36580
|
+
}
|
|
36543
36581
|
app.use(createLegacyPathRedirectMiddleware());
|
|
36544
36582
|
const globalPrefix = process.env.CLIENT_BASE_PATH ?? "";
|
|
36545
36583
|
app.setGlobalPrefix(globalPrefix);
|
|
@@ -36589,7 +36627,9 @@ export {
|
|
|
36589
36627
|
UserContextMiddleware,
|
|
36590
36628
|
ViewContextMiddleware,
|
|
36591
36629
|
configureApp,
|
|
36592
|
-
createLegacyPathRedirectMiddleware
|
|
36630
|
+
createLegacyPathRedirectMiddleware,
|
|
36631
|
+
createLocalDevMiddleware,
|
|
36632
|
+
isLocalDev
|
|
36593
36633
|
};
|
|
36594
36634
|
/*! Bundled license information:
|
|
36595
36635
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lark-apaas/fullstack-nestjs-core",
|
|
3
|
-
"version": "1.1.50-alpha.
|
|
3
|
+
"version": "1.1.50-alpha.8",
|
|
4
4
|
"description": "FullStack Nestjs Core",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -46,7 +46,6 @@
|
|
|
46
46
|
"@lark-apaas/nestjs-capability": "^0.1.13",
|
|
47
47
|
"@lark-apaas/nestjs-common": "^0.1.8",
|
|
48
48
|
"@lark-apaas/nestjs-datapaas": "^1.0.20",
|
|
49
|
-
"@lark-apaas/nestjs-http-forwarder": "0.1.3-alpha.9",
|
|
50
49
|
"@lark-apaas/nestjs-logger": "^1.0.16",
|
|
51
50
|
"@lark-apaas/nestjs-observable": "^0.0.11",
|
|
52
51
|
"@lark-apaas/nestjs-openapi-devtools": "^1.0.10",
|