@lark-apaas/fullstack-nestjs-core 1.1.34-alpha.63 → 1.1.34-alpha.65

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
@@ -34423,8 +34423,7 @@ __export(index_exports, {
34423
34423
  UserContextMiddleware: () => UserContextMiddleware,
34424
34424
  ViewContextMiddleware: () => ViewContextMiddleware,
34425
34425
  configureApp: () => configureApp,
34426
- createLegacyPathRedirectMiddleware: () => createLegacyPathRedirectMiddleware,
34427
- registerOpenApiSpecEndpoint: () => registerOpenApiSpecEndpoint
34426
+ createLegacyPathRedirectMiddleware: () => createLegacyPathRedirectMiddleware
34428
34427
  });
34429
34428
  module.exports = __toCommonJS(index_exports);
34430
34429
 
@@ -34628,31 +34627,32 @@ var ViewContextMiddleware = class _ViewContextMiddleware {
34628
34627
  constructor(client) {
34629
34628
  this.client = client;
34630
34629
  }
34631
- async getAppInfo(appId) {
34630
+ async getAppPublished(appId) {
34632
34631
  if (!appId) {
34633
- this.logger.warn(`appId is empty, skip get app info`);
34632
+ this.logger.warn(`appId is empty, skip get app published`);
34634
34633
  return null;
34635
34634
  }
34636
34635
  try {
34637
34636
  const resp = await this.client.get(`/b/${appId}/get_published_v2`);
34638
34637
  if (resp.status !== 200) {
34639
- throw new Error(`Failed to get app info, status: ${resp.status}`);
34638
+ throw new Error(`Failed to get app published, status: ${resp.status}`);
34640
34639
  }
34641
34640
  const data = await resp.json();
34642
34641
  if (data.status_code !== "0") {
34643
- throw new Error(`Failed to get app info, status_code: ${data.status_code}`);
34642
+ throw new Error(`Failed to get app published, status_code: ${data.status_code}`);
34644
34643
  }
34645
- return data.data.app_info ?? {};
34644
+ return data.data ?? null;
34646
34645
  } catch (err) {
34647
- this.logger.error(err, "Failed to get app info");
34646
+ this.logger.error(err, "Failed to get app published");
34648
34647
  return null;
34649
34648
  }
34650
34649
  }
34651
34650
  async use(req, res, next) {
34652
34651
  const { userId, tenantId, appId, loginUrl, userType } = req.userContext;
34653
34652
  const csrfToken = req.csrfToken;
34654
- const appInfo = await this.getAppInfo(appId);
34655
34653
  const environment = mapToWindowEnvironment(process.env.FORCE_FRAMEWORK_ENVIRONMENT);
34654
+ const appPublishedData = await this.getAppPublished(appId);
34655
+ const appInfo = appPublishedData?.app_info ?? null;
34656
34656
  req.__platform_data__ = {
34657
34657
  csrfToken: csrfToken ?? "",
34658
34658
  userId: userId ?? "",
@@ -34663,7 +34663,9 @@ var ViewContextMiddleware = class _ViewContextMiddleware {
34663
34663
  loginUrl: loginUrl ?? "",
34664
34664
  userType: userType ?? "",
34665
34665
  tenantId,
34666
- environment
34666
+ environment,
34667
+ showBadge: appInfo?.show_badge !== false,
34668
+ appPublished: appPublishedData ?? null
34667
34669
  };
34668
34670
  res.locals = {
34669
34671
  ...res.locals ?? {},
@@ -34774,24 +34776,18 @@ function createApiNotFoundResponse(req) {
34774
34776
  };
34775
34777
  }
34776
34778
  __name(createApiNotFoundResponse, "createApiNotFoundResponse");
34777
- function getApiPathPrefixes() {
34779
+ function getApiPathPrefix() {
34778
34780
  const globalPrefix = process.env.CLIENT_BASE_PATH ?? "";
34779
34781
  if (!globalPrefix) {
34780
- return [
34781
- "/api/",
34782
- "/openapi/"
34783
- ];
34782
+ return "/api/";
34784
34783
  }
34785
34784
  const normalizedPrefix = globalPrefix.replace(/\/+$/, "");
34786
- return [
34787
- `${normalizedPrefix}/api/`,
34788
- `${normalizedPrefix}/openapi/`
34789
- ];
34785
+ return `${normalizedPrefix}/api/`;
34790
34786
  }
34791
- __name(getApiPathPrefixes, "getApiPathPrefixes");
34787
+ __name(getApiPathPrefix, "getApiPathPrefix");
34792
34788
  function apiResponseInterceptor(req, res, next) {
34793
- const apiPrefixes = getApiPathPrefixes();
34794
- if (!apiPrefixes.some((prefix) => req.baseUrl.startsWith(prefix))) {
34789
+ const apiPrefix = getApiPathPrefix();
34790
+ if (!req.baseUrl.startsWith(apiPrefix)) {
34795
34791
  return next();
34796
34792
  }
34797
34793
  res.render = function() {
@@ -36444,18 +36440,16 @@ var PlatformModule = class _PlatformModule {
36444
36440
  */
36445
36441
  configure(consumer) {
36446
36442
  const options = _PlatformModule.moduleOptions;
36447
- consumer.apply(apiResponseInterceptor).forRoutes("/api/*", "/openapi/*");
36443
+ consumer.apply(apiResponseInterceptor).forRoutes("/api/*");
36448
36444
  if (process.env.NODE_ENV === "development") {
36449
36445
  consumer.apply(FrameworkDebugMiddleware).forRoutes("/api/__framework__/debug");
36450
36446
  }
36451
36447
  consumer.apply(UserContextMiddleware, RequestContextMiddleware, import_nestjs_logger2.LoggerContextMiddleware, import_nestjs_observable.ObservableTraceMiddleware, ...DISABLE_DATAPASS ? [] : [
36452
36448
  import_nestjs_datapaas.SqlExecutionContextMiddleware
36453
36449
  ]).forRoutes("/*");
36454
- consumer.apply(CsrfTokenMiddleware, ViewContextMiddleware, HtmlHotUpdateViewMiddleware).exclude("/api/(.*)", "/openapi/(.*)", "/static/(.*)").forRoutes("*");
36450
+ consumer.apply(CsrfTokenMiddleware, ViewContextMiddleware, HtmlHotUpdateViewMiddleware).exclude("/api/(.*)", "/static/(.*)").forRoutes("*");
36455
36451
  if (options.enableCsrf !== false) {
36456
- const csrfRoutes = options.csrfRoutes || [
36457
- "/api/*"
36458
- ];
36452
+ const csrfRoutes = options.csrfRoutes || "/api/*";
36459
36453
  if (Array.isArray(csrfRoutes)) {
36460
36454
  csrfRoutes.forEach((route) => {
36461
36455
  consumer.apply(CsrfMiddleware).forRoutes(route);
@@ -36512,108 +36506,6 @@ function createLegacyPathRedirectMiddleware() {
36512
36506
  }
36513
36507
  __name(createLegacyPathRedirectMiddleware, "createLegacyPathRedirectMiddleware");
36514
36508
 
36515
- // src/middlewares/openapi-spec/index.ts
36516
- var import_swagger3 = require("@nestjs/swagger");
36517
- function registerOpenApiSpecEndpoint(app) {
36518
- const globalPrefix = process.env.CLIENT_BASE_PATH ?? "";
36519
- let cachedResult = null;
36520
- const httpAdapter = app.getHttpAdapter();
36521
- httpAdapter.get(`${globalPrefix}/api/__framework__/openapi-spec`, (_req, res) => {
36522
- try {
36523
- if (!cachedResult) {
36524
- const config = new import_swagger3.DocumentBuilder().setTitle("OpenAPI Spec").setVersion("1.0").build();
36525
- const spec = import_swagger3.SwaggerModule.createDocument(app, config);
36526
- cachedResult = buildFilteredSpec(spec, globalPrefix);
36527
- }
36528
- res.json(cachedResult);
36529
- } catch (err) {
36530
- console.error("[openapi-spec] Failed to generate spec:", err);
36531
- res.json({
36532
- openapi: "3.0.0",
36533
- paths: {},
36534
- components: {
36535
- schemas: {}
36536
- }
36537
- });
36538
- }
36539
- });
36540
- console.log(`[OpenAPI] Registered GET ${globalPrefix}/api/__framework__/openapi-spec`);
36541
- }
36542
- __name(registerOpenApiSpecEndpoint, "registerOpenApiSpecEndpoint");
36543
- function buildFilteredSpec(spec, globalPrefix) {
36544
- const schemas = spec.components?.schemas ?? {};
36545
- const paths = spec.paths ?? {};
36546
- const filteredPaths = {};
36547
- for (const [pathKey, methods] of Object.entries(paths)) {
36548
- const cleanPath = stripPrefix(pathKey, globalPrefix);
36549
- if (!cleanPath.startsWith("/openapi")) continue;
36550
- filteredPaths[cleanPath] = {};
36551
- for (const [method, operation] of Object.entries(methods)) {
36552
- if ([
36553
- "parameters",
36554
- "summary",
36555
- "description",
36556
- "servers"
36557
- ].includes(method)) continue;
36558
- filteredPaths[cleanPath][method] = resolveRefsDeep(structuredClone(operation), schemas);
36559
- }
36560
- }
36561
- return {
36562
- openapi: spec.openapi,
36563
- paths: filteredPaths,
36564
- components: {
36565
- schemas: resolveAllSchemaRefs(structuredClone(schemas))
36566
- }
36567
- };
36568
- }
36569
- __name(buildFilteredSpec, "buildFilteredSpec");
36570
- function stripPrefix(path2, prefix) {
36571
- if (prefix && path2.startsWith(prefix)) {
36572
- return path2.slice(prefix.length);
36573
- }
36574
- return path2;
36575
- }
36576
- __name(stripPrefix, "stripPrefix");
36577
- var MAX_REF_DEPTH = 5;
36578
- function resolveRefsDeep(obj, schemas, depth = 0) {
36579
- if (depth > MAX_REF_DEPTH || obj === null || obj === void 0) return obj;
36580
- if (typeof obj !== "object") return obj;
36581
- if (Array.isArray(obj)) {
36582
- return obj.map((item) => resolveRefsDeep(item, schemas, depth));
36583
- }
36584
- const record = obj;
36585
- if (typeof record["$ref"] === "string") {
36586
- const resolved = resolveRef(record["$ref"], schemas);
36587
- if (resolved !== void 0) {
36588
- return resolveRefsDeep(structuredClone(resolved), schemas, depth + 1);
36589
- }
36590
- return record;
36591
- }
36592
- const result = {};
36593
- for (const [key, value] of Object.entries(record)) {
36594
- result[key] = resolveRefsDeep(value, schemas, depth);
36595
- }
36596
- return result;
36597
- }
36598
- __name(resolveRefsDeep, "resolveRefsDeep");
36599
- function resolveRef(ref, schemas) {
36600
- const prefix = "#/components/schemas/";
36601
- if (ref.startsWith(prefix)) {
36602
- const name = ref.slice(prefix.length);
36603
- return schemas[name];
36604
- }
36605
- return void 0;
36606
- }
36607
- __name(resolveRef, "resolveRef");
36608
- function resolveAllSchemaRefs(schemas) {
36609
- const result = {};
36610
- for (const [name, schema] of Object.entries(schemas)) {
36611
- result[name] = resolveRefsDeep(schema, schemas);
36612
- }
36613
- return result;
36614
- }
36615
- __name(resolveAllSchemaRefs, "resolveAllSchemaRefs");
36616
-
36617
36509
  // src/setup.ts
36618
36510
  var DEFAULT_BODY_LIMIT = "1mb";
36619
36511
  var defaultPerms = {
@@ -36646,9 +36538,6 @@ async function configureApp(app, perms = defaultPerms) {
36646
36538
  console.error("[OpenAPI] OpenAPI \u751F\u6210\u5931\u8D25:", err);
36647
36539
  }
36648
36540
  }
36649
- if (process.env.NODE_ENV !== "production") {
36650
- registerOpenApiSpecEndpoint(app);
36651
- }
36652
36541
  console.log("App Started Successfully.");
36653
36542
  }
36654
36543
  __name(configureApp, "configureApp");
@@ -36685,7 +36574,6 @@ var import_nestjs_authzpaas2 = require("@lark-apaas/nestjs-authzpaas");
36685
36574
  ViewContextMiddleware,
36686
36575
  configureApp,
36687
36576
  createLegacyPathRedirectMiddleware,
36688
- registerOpenApiSpecEndpoint,
36689
36577
  ...require("@lark-apaas/nestjs-authnpaas"),
36690
36578
  ...require("@lark-apaas/nestjs-capability"),
36691
36579
  ...require("@lark-apaas/nestjs-datapaas"),
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { NestModule, DynamicModule, MiddlewareConsumer, OnModuleInit, NestMiddleware, INestApplication } from '@nestjs/common';
1
+ import { NestModule, DynamicModule, MiddlewareConsumer, OnModuleInit, NestMiddleware } from '@nestjs/common';
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';
@@ -201,7 +201,7 @@ declare class ViewContextMiddleware implements NestMiddleware {
201
201
  private readonly client;
202
202
  private readonly logger;
203
203
  constructor(client: PlatformHttpClient);
204
- private getAppInfo;
204
+ private getAppPublished;
205
205
  use(req: Request, res: Response, next: NextFunction): Promise<void>;
206
206
  }
207
207
 
@@ -221,14 +221,6 @@ declare class ViewContextMiddleware implements NestMiddleware {
221
221
  */
222
222
  declare function createLegacyPathRedirectMiddleware(): (req: Request, res: Response, next: NextFunction) => void;
223
223
 
224
- /**
225
- * 注册 OpenAPI spec 端点(仅开发环境)
226
- *
227
- * 在 NestJS 进程中注册 GET /api/__framework__/openapi-spec,
228
- * 返回过滤后的 OpenAPI 3.0 子集(仅 /openapi/** 路由,$ref 已解引用)。
229
- */
230
- declare function registerOpenApiSpecEndpoint(app: INestApplication): void;
231
-
232
224
  /**
233
225
  * API 404 响应格式
234
226
  */
@@ -409,4 +401,4 @@ declare class PlatformHttpClientService {
409
401
  private registerInterceptorsForClient;
410
402
  }
411
403
 
412
- export { type ApiNotFoundResponse, CsrfMiddleware, CsrfTokenMiddleware, FileService, HtmlHotUpdateModule, HtmlHotUpdateService, type PlatformHttpClientOptions, PlatformHttpClientService, PlatformModule, type PlatformModuleOptions, StaticModule, UserContextMiddleware, ViewContextMiddleware, configureApp, createLegacyPathRedirectMiddleware, registerOpenApiSpecEndpoint };
404
+ 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
@@ -1,4 +1,4 @@
1
- import { NestModule, DynamicModule, MiddlewareConsumer, OnModuleInit, NestMiddleware, INestApplication } from '@nestjs/common';
1
+ import { NestModule, DynamicModule, MiddlewareConsumer, OnModuleInit, NestMiddleware } from '@nestjs/common';
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';
@@ -201,7 +201,7 @@ declare class ViewContextMiddleware implements NestMiddleware {
201
201
  private readonly client;
202
202
  private readonly logger;
203
203
  constructor(client: PlatformHttpClient);
204
- private getAppInfo;
204
+ private getAppPublished;
205
205
  use(req: Request, res: Response, next: NextFunction): Promise<void>;
206
206
  }
207
207
 
@@ -221,14 +221,6 @@ declare class ViewContextMiddleware implements NestMiddleware {
221
221
  */
222
222
  declare function createLegacyPathRedirectMiddleware(): (req: Request, res: Response, next: NextFunction) => void;
223
223
 
224
- /**
225
- * 注册 OpenAPI spec 端点(仅开发环境)
226
- *
227
- * 在 NestJS 进程中注册 GET /api/__framework__/openapi-spec,
228
- * 返回过滤后的 OpenAPI 3.0 子集(仅 /openapi/** 路由,$ref 已解引用)。
229
- */
230
- declare function registerOpenApiSpecEndpoint(app: INestApplication): void;
231
-
232
224
  /**
233
225
  * API 404 响应格式
234
226
  */
@@ -409,4 +401,4 @@ declare class PlatformHttpClientService {
409
401
  private registerInterceptorsForClient;
410
402
  }
411
403
 
412
- export { type ApiNotFoundResponse, CsrfMiddleware, CsrfTokenMiddleware, FileService, HtmlHotUpdateModule, HtmlHotUpdateService, type PlatformHttpClientOptions, PlatformHttpClientService, PlatformModule, type PlatformModuleOptions, StaticModule, UserContextMiddleware, ViewContextMiddleware, configureApp, createLegacyPathRedirectMiddleware, registerOpenApiSpecEndpoint };
404
+ export { type ApiNotFoundResponse, CsrfMiddleware, CsrfTokenMiddleware, FileService, HtmlHotUpdateModule, HtmlHotUpdateService, type PlatformHttpClientOptions, PlatformHttpClientService, PlatformModule, type PlatformModuleOptions, StaticModule, UserContextMiddleware, ViewContextMiddleware, configureApp, createLegacyPathRedirectMiddleware };
package/dist/index.js CHANGED
@@ -34600,31 +34600,32 @@ var ViewContextMiddleware = class _ViewContextMiddleware {
34600
34600
  constructor(client) {
34601
34601
  this.client = client;
34602
34602
  }
34603
- async getAppInfo(appId) {
34603
+ async getAppPublished(appId) {
34604
34604
  if (!appId) {
34605
- this.logger.warn(`appId is empty, skip get app info`);
34605
+ this.logger.warn(`appId is empty, skip get app published`);
34606
34606
  return null;
34607
34607
  }
34608
34608
  try {
34609
34609
  const resp = await this.client.get(`/b/${appId}/get_published_v2`);
34610
34610
  if (resp.status !== 200) {
34611
- throw new Error(`Failed to get app info, status: ${resp.status}`);
34611
+ throw new Error(`Failed to get app published, status: ${resp.status}`);
34612
34612
  }
34613
34613
  const data = await resp.json();
34614
34614
  if (data.status_code !== "0") {
34615
- throw new Error(`Failed to get app info, status_code: ${data.status_code}`);
34615
+ throw new Error(`Failed to get app published, status_code: ${data.status_code}`);
34616
34616
  }
34617
- return data.data.app_info ?? {};
34617
+ return data.data ?? null;
34618
34618
  } catch (err) {
34619
- this.logger.error(err, "Failed to get app info");
34619
+ this.logger.error(err, "Failed to get app published");
34620
34620
  return null;
34621
34621
  }
34622
34622
  }
34623
34623
  async use(req, res, next) {
34624
34624
  const { userId, tenantId, appId, loginUrl, userType } = req.userContext;
34625
34625
  const csrfToken = req.csrfToken;
34626
- const appInfo = await this.getAppInfo(appId);
34627
34626
  const environment = mapToWindowEnvironment(process.env.FORCE_FRAMEWORK_ENVIRONMENT);
34627
+ const appPublishedData = await this.getAppPublished(appId);
34628
+ const appInfo = appPublishedData?.app_info ?? null;
34628
34629
  req.__platform_data__ = {
34629
34630
  csrfToken: csrfToken ?? "",
34630
34631
  userId: userId ?? "",
@@ -34635,7 +34636,9 @@ var ViewContextMiddleware = class _ViewContextMiddleware {
34635
34636
  loginUrl: loginUrl ?? "",
34636
34637
  userType: userType ?? "",
34637
34638
  tenantId,
34638
- environment
34639
+ environment,
34640
+ showBadge: appInfo?.show_badge !== false,
34641
+ appPublished: appPublishedData ?? null
34639
34642
  };
34640
34643
  res.locals = {
34641
34644
  ...res.locals ?? {},
@@ -34746,24 +34749,18 @@ function createApiNotFoundResponse(req) {
34746
34749
  };
34747
34750
  }
34748
34751
  __name(createApiNotFoundResponse, "createApiNotFoundResponse");
34749
- function getApiPathPrefixes() {
34752
+ function getApiPathPrefix() {
34750
34753
  const globalPrefix = process.env.CLIENT_BASE_PATH ?? "";
34751
34754
  if (!globalPrefix) {
34752
- return [
34753
- "/api/",
34754
- "/openapi/"
34755
- ];
34755
+ return "/api/";
34756
34756
  }
34757
34757
  const normalizedPrefix = globalPrefix.replace(/\/+$/, "");
34758
- return [
34759
- `${normalizedPrefix}/api/`,
34760
- `${normalizedPrefix}/openapi/`
34761
- ];
34758
+ return `${normalizedPrefix}/api/`;
34762
34759
  }
34763
- __name(getApiPathPrefixes, "getApiPathPrefixes");
34760
+ __name(getApiPathPrefix, "getApiPathPrefix");
34764
34761
  function apiResponseInterceptor(req, res, next) {
34765
- const apiPrefixes = getApiPathPrefixes();
34766
- if (!apiPrefixes.some((prefix) => req.baseUrl.startsWith(prefix))) {
34762
+ const apiPrefix = getApiPathPrefix();
34763
+ if (!req.baseUrl.startsWith(apiPrefix)) {
34767
34764
  return next();
34768
34765
  }
34769
34766
  res.render = function() {
@@ -36416,18 +36413,16 @@ var PlatformModule = class _PlatformModule {
36416
36413
  */
36417
36414
  configure(consumer) {
36418
36415
  const options = _PlatformModule.moduleOptions;
36419
- consumer.apply(apiResponseInterceptor).forRoutes("/api/*", "/openapi/*");
36416
+ consumer.apply(apiResponseInterceptor).forRoutes("/api/*");
36420
36417
  if (process.env.NODE_ENV === "development") {
36421
36418
  consumer.apply(FrameworkDebugMiddleware).forRoutes("/api/__framework__/debug");
36422
36419
  }
36423
36420
  consumer.apply(UserContextMiddleware, RequestContextMiddleware, LoggerContextMiddleware, ObservableTraceMiddleware, ...DISABLE_DATAPASS ? [] : [
36424
36421
  SqlExecutionContextMiddleware
36425
36422
  ]).forRoutes("/*");
36426
- consumer.apply(CsrfTokenMiddleware, ViewContextMiddleware, HtmlHotUpdateViewMiddleware).exclude("/api/(.*)", "/openapi/(.*)", "/static/(.*)").forRoutes("*");
36423
+ consumer.apply(CsrfTokenMiddleware, ViewContextMiddleware, HtmlHotUpdateViewMiddleware).exclude("/api/(.*)", "/static/(.*)").forRoutes("*");
36427
36424
  if (options.enableCsrf !== false) {
36428
- const csrfRoutes = options.csrfRoutes || [
36429
- "/api/*"
36430
- ];
36425
+ const csrfRoutes = options.csrfRoutes || "/api/*";
36431
36426
  if (Array.isArray(csrfRoutes)) {
36432
36427
  csrfRoutes.forEach((route) => {
36433
36428
  consumer.apply(CsrfMiddleware).forRoutes(route);
@@ -36484,108 +36479,6 @@ function createLegacyPathRedirectMiddleware() {
36484
36479
  }
36485
36480
  __name(createLegacyPathRedirectMiddleware, "createLegacyPathRedirectMiddleware");
36486
36481
 
36487
- // src/middlewares/openapi-spec/index.ts
36488
- import { SwaggerModule, DocumentBuilder } from "@nestjs/swagger";
36489
- function registerOpenApiSpecEndpoint(app) {
36490
- const globalPrefix = process.env.CLIENT_BASE_PATH ?? "";
36491
- let cachedResult = null;
36492
- const httpAdapter = app.getHttpAdapter();
36493
- httpAdapter.get(`${globalPrefix}/api/__framework__/openapi-spec`, (_req, res) => {
36494
- try {
36495
- if (!cachedResult) {
36496
- const config = new DocumentBuilder().setTitle("OpenAPI Spec").setVersion("1.0").build();
36497
- const spec = SwaggerModule.createDocument(app, config);
36498
- cachedResult = buildFilteredSpec(spec, globalPrefix);
36499
- }
36500
- res.json(cachedResult);
36501
- } catch (err) {
36502
- console.error("[openapi-spec] Failed to generate spec:", err);
36503
- res.json({
36504
- openapi: "3.0.0",
36505
- paths: {},
36506
- components: {
36507
- schemas: {}
36508
- }
36509
- });
36510
- }
36511
- });
36512
- console.log(`[OpenAPI] Registered GET ${globalPrefix}/api/__framework__/openapi-spec`);
36513
- }
36514
- __name(registerOpenApiSpecEndpoint, "registerOpenApiSpecEndpoint");
36515
- function buildFilteredSpec(spec, globalPrefix) {
36516
- const schemas = spec.components?.schemas ?? {};
36517
- const paths = spec.paths ?? {};
36518
- const filteredPaths = {};
36519
- for (const [pathKey, methods] of Object.entries(paths)) {
36520
- const cleanPath = stripPrefix(pathKey, globalPrefix);
36521
- if (!cleanPath.startsWith("/openapi")) continue;
36522
- filteredPaths[cleanPath] = {};
36523
- for (const [method, operation] of Object.entries(methods)) {
36524
- if ([
36525
- "parameters",
36526
- "summary",
36527
- "description",
36528
- "servers"
36529
- ].includes(method)) continue;
36530
- filteredPaths[cleanPath][method] = resolveRefsDeep(structuredClone(operation), schemas);
36531
- }
36532
- }
36533
- return {
36534
- openapi: spec.openapi,
36535
- paths: filteredPaths,
36536
- components: {
36537
- schemas: resolveAllSchemaRefs(structuredClone(schemas))
36538
- }
36539
- };
36540
- }
36541
- __name(buildFilteredSpec, "buildFilteredSpec");
36542
- function stripPrefix(path2, prefix) {
36543
- if (prefix && path2.startsWith(prefix)) {
36544
- return path2.slice(prefix.length);
36545
- }
36546
- return path2;
36547
- }
36548
- __name(stripPrefix, "stripPrefix");
36549
- var MAX_REF_DEPTH = 5;
36550
- function resolveRefsDeep(obj, schemas, depth = 0) {
36551
- if (depth > MAX_REF_DEPTH || obj === null || obj === void 0) return obj;
36552
- if (typeof obj !== "object") return obj;
36553
- if (Array.isArray(obj)) {
36554
- return obj.map((item) => resolveRefsDeep(item, schemas, depth));
36555
- }
36556
- const record = obj;
36557
- if (typeof record["$ref"] === "string") {
36558
- const resolved = resolveRef(record["$ref"], schemas);
36559
- if (resolved !== void 0) {
36560
- return resolveRefsDeep(structuredClone(resolved), schemas, depth + 1);
36561
- }
36562
- return record;
36563
- }
36564
- const result = {};
36565
- for (const [key, value] of Object.entries(record)) {
36566
- result[key] = resolveRefsDeep(value, schemas, depth);
36567
- }
36568
- return result;
36569
- }
36570
- __name(resolveRefsDeep, "resolveRefsDeep");
36571
- function resolveRef(ref, schemas) {
36572
- const prefix = "#/components/schemas/";
36573
- if (ref.startsWith(prefix)) {
36574
- const name = ref.slice(prefix.length);
36575
- return schemas[name];
36576
- }
36577
- return void 0;
36578
- }
36579
- __name(resolveRef, "resolveRef");
36580
- function resolveAllSchemaRefs(schemas) {
36581
- const result = {};
36582
- for (const [name, schema] of Object.entries(schemas)) {
36583
- result[name] = resolveRefsDeep(schema, schemas);
36584
- }
36585
- return result;
36586
- }
36587
- __name(resolveAllSchemaRefs, "resolveAllSchemaRefs");
36588
-
36589
36482
  // src/setup.ts
36590
36483
  var DEFAULT_BODY_LIMIT = "1mb";
36591
36484
  var defaultPerms = {
@@ -36618,9 +36511,6 @@ async function configureApp(app, perms = defaultPerms) {
36618
36511
  console.error("[OpenAPI] OpenAPI \u751F\u6210\u5931\u8D25:", err);
36619
36512
  }
36620
36513
  }
36621
- if (process.env.NODE_ENV !== "production") {
36622
- registerOpenApiSpecEndpoint(app);
36623
- }
36624
36514
  console.log("App Started Successfully.");
36625
36515
  }
36626
36516
  __name(configureApp, "configureApp");
@@ -36655,8 +36545,7 @@ export {
36655
36545
  UserContextMiddleware,
36656
36546
  ViewContextMiddleware,
36657
36547
  configureApp,
36658
- createLegacyPathRedirectMiddleware,
36659
- registerOpenApiSpecEndpoint
36548
+ createLegacyPathRedirectMiddleware
36660
36549
  };
36661
36550
  /*! Bundled license information:
36662
36551
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/fullstack-nestjs-core",
3
- "version": "1.1.34-alpha.63",
3
+ "version": "1.1.34-alpha.65",
4
4
  "description": "FullStack Nestjs Core",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -45,7 +45,7 @@
45
45
  "@lark-apaas/nestjs-authzpaas": "^0.1.8",
46
46
  "@lark-apaas/nestjs-capability": "^0.1.11",
47
47
  "@lark-apaas/nestjs-common": "^0.1.8",
48
- "@lark-apaas/nestjs-datapaas": "^1.0.18",
48
+ "@lark-apaas/nestjs-datapaas": "^1.0.19",
49
49
  "@lark-apaas/nestjs-logger": "^1.0.16",
50
50
  "@lark-apaas/nestjs-observable": "^0.0.11",
51
51
  "@lark-apaas/nestjs-openapi-devtools": "^1.0.10",