@lark-apaas/fullstack-nestjs-core 1.1.34-alpha.64 → 1.1.34-alpha.66
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 +233 -96
- package/dist/index.d.cts +9 -3
- package/dist/index.d.ts +9 -3
- package/dist/index.js +194 -58
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -34423,12 +34423,13 @@ __export(index_exports, {
|
|
|
34423
34423
|
UserContextMiddleware: () => UserContextMiddleware,
|
|
34424
34424
|
ViewContextMiddleware: () => ViewContextMiddleware,
|
|
34425
34425
|
configureApp: () => configureApp,
|
|
34426
|
-
createLegacyPathRedirectMiddleware: () => createLegacyPathRedirectMiddleware
|
|
34426
|
+
createLegacyPathRedirectMiddleware: () => createLegacyPathRedirectMiddleware,
|
|
34427
|
+
registerOpenApiSpecEndpoint: () => registerOpenApiSpecEndpoint
|
|
34427
34428
|
});
|
|
34428
34429
|
module.exports = __toCommonJS(index_exports);
|
|
34429
34430
|
|
|
34430
34431
|
// src/modules/platform/module.ts
|
|
34431
|
-
var
|
|
34432
|
+
var import_common17 = require("@nestjs/common");
|
|
34432
34433
|
var import_core2 = require("@nestjs/core");
|
|
34433
34434
|
var import_nestjs_common6 = require("@lark-apaas/nestjs-common");
|
|
34434
34435
|
var import_config2 = require("@nestjs/config");
|
|
@@ -34627,32 +34628,31 @@ var ViewContextMiddleware = class _ViewContextMiddleware {
|
|
|
34627
34628
|
constructor(client) {
|
|
34628
34629
|
this.client = client;
|
|
34629
34630
|
}
|
|
34630
|
-
async
|
|
34631
|
+
async getAppInfo(appId) {
|
|
34631
34632
|
if (!appId) {
|
|
34632
|
-
this.logger.warn(`appId is empty, skip get app
|
|
34633
|
+
this.logger.warn(`appId is empty, skip get app info`);
|
|
34633
34634
|
return null;
|
|
34634
34635
|
}
|
|
34635
34636
|
try {
|
|
34636
34637
|
const resp = await this.client.get(`/b/${appId}/get_published_v2`);
|
|
34637
34638
|
if (resp.status !== 200) {
|
|
34638
|
-
throw new Error(`Failed to get app
|
|
34639
|
+
throw new Error(`Failed to get app info, status: ${resp.status}`);
|
|
34639
34640
|
}
|
|
34640
34641
|
const data = await resp.json();
|
|
34641
34642
|
if (data.status_code !== "0") {
|
|
34642
|
-
throw new Error(`Failed to get app
|
|
34643
|
+
throw new Error(`Failed to get app info, status_code: ${data.status_code}`);
|
|
34643
34644
|
}
|
|
34644
|
-
return data.data ??
|
|
34645
|
+
return data.data.app_info ?? {};
|
|
34645
34646
|
} catch (err) {
|
|
34646
|
-
this.logger.error(err, "Failed to get app
|
|
34647
|
+
this.logger.error(err, "Failed to get app info");
|
|
34647
34648
|
return null;
|
|
34648
34649
|
}
|
|
34649
34650
|
}
|
|
34650
34651
|
async use(req, res, next) {
|
|
34651
34652
|
const { userId, tenantId, appId, loginUrl, userType } = req.userContext;
|
|
34652
34653
|
const csrfToken = req.csrfToken;
|
|
34654
|
+
const appInfo = await this.getAppInfo(appId);
|
|
34653
34655
|
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,9 +34663,7 @@ var ViewContextMiddleware = class _ViewContextMiddleware {
|
|
|
34663
34663
|
loginUrl: loginUrl ?? "",
|
|
34664
34664
|
userType: userType ?? "",
|
|
34665
34665
|
tenantId,
|
|
34666
|
-
environment
|
|
34667
|
-
showBadge: appInfo?.show_badge !== false,
|
|
34668
|
-
appPublished: appPublishedData ?? null
|
|
34666
|
+
environment
|
|
34669
34667
|
};
|
|
34670
34668
|
res.locals = {
|
|
34671
34669
|
...res.locals ?? {},
|
|
@@ -34776,18 +34774,24 @@ function createApiNotFoundResponse(req) {
|
|
|
34776
34774
|
};
|
|
34777
34775
|
}
|
|
34778
34776
|
__name(createApiNotFoundResponse, "createApiNotFoundResponse");
|
|
34779
|
-
function
|
|
34777
|
+
function getApiPathPrefixes() {
|
|
34780
34778
|
const globalPrefix = process.env.CLIENT_BASE_PATH ?? "";
|
|
34781
34779
|
if (!globalPrefix) {
|
|
34782
|
-
return
|
|
34780
|
+
return [
|
|
34781
|
+
"/api/",
|
|
34782
|
+
"/openapi/"
|
|
34783
|
+
];
|
|
34783
34784
|
}
|
|
34784
34785
|
const normalizedPrefix = globalPrefix.replace(/\/+$/, "");
|
|
34785
|
-
return
|
|
34786
|
+
return [
|
|
34787
|
+
`${normalizedPrefix}/api/`,
|
|
34788
|
+
`${normalizedPrefix}/openapi/`
|
|
34789
|
+
];
|
|
34786
34790
|
}
|
|
34787
|
-
__name(
|
|
34791
|
+
__name(getApiPathPrefixes, "getApiPathPrefixes");
|
|
34788
34792
|
function apiResponseInterceptor(req, res, next) {
|
|
34789
|
-
const
|
|
34790
|
-
if (!req.baseUrl.startsWith(
|
|
34793
|
+
const apiPrefixes = getApiPathPrefixes();
|
|
34794
|
+
if (!apiPrefixes.some((prefix) => req.baseUrl.startsWith(prefix))) {
|
|
34791
34795
|
return next();
|
|
34792
34796
|
}
|
|
34793
34797
|
res.render = function() {
|
|
@@ -35017,10 +35021,9 @@ FrameworkDebugMiddleware = _ts_decorate7([
|
|
|
35017
35021
|
])
|
|
35018
35022
|
], FrameworkDebugMiddleware);
|
|
35019
35023
|
|
|
35020
|
-
// src/
|
|
35024
|
+
// src/middlewares/openapi-spec/index.ts
|
|
35025
|
+
var import_swagger = require("@nestjs/swagger");
|
|
35021
35026
|
var import_common8 = require("@nestjs/common");
|
|
35022
|
-
var import_http_client = require("@lark-apaas/http-client");
|
|
35023
|
-
var import_nestjs_common3 = require("@lark-apaas/nestjs-common");
|
|
35024
35027
|
function _ts_decorate8(decorators, target, key, desc) {
|
|
35025
35028
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
35026
35029
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -35028,6 +35031,131 @@ function _ts_decorate8(decorators, target, key, desc) {
|
|
|
35028
35031
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
35029
35032
|
}
|
|
35030
35033
|
__name(_ts_decorate8, "_ts_decorate");
|
|
35034
|
+
var _app = null;
|
|
35035
|
+
var _cachedSpec = null;
|
|
35036
|
+
function registerOpenApiSpecEndpoint(app) {
|
|
35037
|
+
const globalPrefix = (process.env.CLIENT_BASE_PATH ?? "").replace(/\/+$/, "");
|
|
35038
|
+
_app = app;
|
|
35039
|
+
console.log(`[OpenAPI] Registered GET ${globalPrefix}/api/__framework__/openapi-spec`);
|
|
35040
|
+
}
|
|
35041
|
+
__name(registerOpenApiSpecEndpoint, "registerOpenApiSpecEndpoint");
|
|
35042
|
+
var OpenApiSpecMiddleware = class {
|
|
35043
|
+
static {
|
|
35044
|
+
__name(this, "OpenApiSpecMiddleware");
|
|
35045
|
+
}
|
|
35046
|
+
use(_req, res, next) {
|
|
35047
|
+
if (!_app) {
|
|
35048
|
+
next();
|
|
35049
|
+
return;
|
|
35050
|
+
}
|
|
35051
|
+
try {
|
|
35052
|
+
if (!_cachedSpec) {
|
|
35053
|
+
const globalPrefix = (process.env.CLIENT_BASE_PATH ?? "").replace(/\/+$/, "");
|
|
35054
|
+
const config = new import_swagger.DocumentBuilder().setTitle("OpenAPI Spec").setVersion("1.0").build();
|
|
35055
|
+
const spec = import_swagger.SwaggerModule.createDocument(_app, config);
|
|
35056
|
+
_cachedSpec = buildFilteredSpec(spec, globalPrefix);
|
|
35057
|
+
}
|
|
35058
|
+
res.json(_cachedSpec);
|
|
35059
|
+
} catch (err) {
|
|
35060
|
+
console.error("[openapi-spec] Failed to generate spec:", err);
|
|
35061
|
+
res.json({
|
|
35062
|
+
openapi: "3.0.0",
|
|
35063
|
+
paths: {},
|
|
35064
|
+
components: {
|
|
35065
|
+
schemas: {}
|
|
35066
|
+
}
|
|
35067
|
+
});
|
|
35068
|
+
}
|
|
35069
|
+
}
|
|
35070
|
+
};
|
|
35071
|
+
OpenApiSpecMiddleware = _ts_decorate8([
|
|
35072
|
+
(0, import_common8.Injectable)()
|
|
35073
|
+
], OpenApiSpecMiddleware);
|
|
35074
|
+
function buildFilteredSpec(spec, globalPrefix) {
|
|
35075
|
+
const schemas = spec.components?.schemas ?? {};
|
|
35076
|
+
const paths = spec.paths ?? {};
|
|
35077
|
+
const filteredPaths = {};
|
|
35078
|
+
for (const [pathKey, methods] of Object.entries(paths)) {
|
|
35079
|
+
const cleanPath = stripPrefix(pathKey, globalPrefix);
|
|
35080
|
+
if (!cleanPath.startsWith("/openapi")) continue;
|
|
35081
|
+
filteredPaths[cleanPath] = {};
|
|
35082
|
+
for (const [method, operation] of Object.entries(methods)) {
|
|
35083
|
+
if ([
|
|
35084
|
+
"parameters",
|
|
35085
|
+
"summary",
|
|
35086
|
+
"description",
|
|
35087
|
+
"servers"
|
|
35088
|
+
].includes(method)) continue;
|
|
35089
|
+
filteredPaths[cleanPath][method] = resolveRefsDeep(structuredClone(operation), schemas);
|
|
35090
|
+
}
|
|
35091
|
+
}
|
|
35092
|
+
return {
|
|
35093
|
+
openapi: spec.openapi,
|
|
35094
|
+
paths: filteredPaths,
|
|
35095
|
+
components: {
|
|
35096
|
+
schemas: resolveAllSchemaRefs(structuredClone(schemas))
|
|
35097
|
+
}
|
|
35098
|
+
};
|
|
35099
|
+
}
|
|
35100
|
+
__name(buildFilteredSpec, "buildFilteredSpec");
|
|
35101
|
+
function stripPrefix(path2, prefix) {
|
|
35102
|
+
if (prefix && path2.startsWith(prefix)) {
|
|
35103
|
+
return path2.slice(prefix.length);
|
|
35104
|
+
}
|
|
35105
|
+
return path2;
|
|
35106
|
+
}
|
|
35107
|
+
__name(stripPrefix, "stripPrefix");
|
|
35108
|
+
var MAX_REF_DEPTH = 5;
|
|
35109
|
+
function resolveRefsDeep(obj, schemas, depth = 0) {
|
|
35110
|
+
if (depth > MAX_REF_DEPTH || obj === null || obj === void 0) return obj;
|
|
35111
|
+
if (typeof obj !== "object") return obj;
|
|
35112
|
+
if (Array.isArray(obj)) {
|
|
35113
|
+
return obj.map((item) => resolveRefsDeep(item, schemas, depth));
|
|
35114
|
+
}
|
|
35115
|
+
const record = obj;
|
|
35116
|
+
if (typeof record["$ref"] === "string") {
|
|
35117
|
+
const resolved = resolveRef(record["$ref"], schemas);
|
|
35118
|
+
if (resolved !== void 0) {
|
|
35119
|
+
return resolveRefsDeep(structuredClone(resolved), schemas, depth + 1);
|
|
35120
|
+
}
|
|
35121
|
+
return record;
|
|
35122
|
+
}
|
|
35123
|
+
const result = {};
|
|
35124
|
+
for (const [key, value] of Object.entries(record)) {
|
|
35125
|
+
result[key] = resolveRefsDeep(value, schemas, depth);
|
|
35126
|
+
}
|
|
35127
|
+
return result;
|
|
35128
|
+
}
|
|
35129
|
+
__name(resolveRefsDeep, "resolveRefsDeep");
|
|
35130
|
+
function resolveRef(ref, schemas) {
|
|
35131
|
+
const prefix = "#/components/schemas/";
|
|
35132
|
+
if (ref.startsWith(prefix)) {
|
|
35133
|
+
const name = ref.slice(prefix.length);
|
|
35134
|
+
return schemas[name];
|
|
35135
|
+
}
|
|
35136
|
+
return void 0;
|
|
35137
|
+
}
|
|
35138
|
+
__name(resolveRef, "resolveRef");
|
|
35139
|
+
function resolveAllSchemaRefs(schemas) {
|
|
35140
|
+
const result = {};
|
|
35141
|
+
for (const [name, schema] of Object.entries(schemas)) {
|
|
35142
|
+
result[name] = resolveRefsDeep(schema, schemas);
|
|
35143
|
+
}
|
|
35144
|
+
return result;
|
|
35145
|
+
}
|
|
35146
|
+
__name(resolveAllSchemaRefs, "resolveAllSchemaRefs");
|
|
35147
|
+
|
|
35148
|
+
// src/services/platform-http-client.service.ts
|
|
35149
|
+
var import_common9 = require("@nestjs/common");
|
|
35150
|
+
var import_http_client = require("@lark-apaas/http-client");
|
|
35151
|
+
var import_nestjs_common3 = require("@lark-apaas/nestjs-common");
|
|
35152
|
+
function _ts_decorate9(decorators, target, key, desc) {
|
|
35153
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
35154
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
35155
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
35156
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
35157
|
+
}
|
|
35158
|
+
__name(_ts_decorate9, "_ts_decorate");
|
|
35031
35159
|
function _ts_metadata5(k, v) {
|
|
35032
35160
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
35033
35161
|
}
|
|
@@ -35066,7 +35194,7 @@ var PlatformHttpClientService = class _PlatformHttpClientService {
|
|
|
35066
35194
|
requestContext;
|
|
35067
35195
|
client;
|
|
35068
35196
|
protectedClient;
|
|
35069
|
-
logger = new
|
|
35197
|
+
logger = new import_common9.Logger(_PlatformHttpClientService.name);
|
|
35070
35198
|
constructor(requestContext) {
|
|
35071
35199
|
this.requestContext = requestContext;
|
|
35072
35200
|
const baseConfig = {
|
|
@@ -35222,8 +35350,8 @@ var PlatformHttpClientService = class _PlatformHttpClientService {
|
|
|
35222
35350
|
});
|
|
35223
35351
|
}
|
|
35224
35352
|
};
|
|
35225
|
-
PlatformHttpClientService =
|
|
35226
|
-
(0,
|
|
35353
|
+
PlatformHttpClientService = _ts_decorate9([
|
|
35354
|
+
(0, import_common9.Injectable)(),
|
|
35227
35355
|
_ts_metadata5("design:type", Function),
|
|
35228
35356
|
_ts_metadata5("design:paramtypes", [
|
|
35229
35357
|
typeof import_nestjs_common3.RequestContextService === "undefined" ? Object : import_nestjs_common3.RequestContextService
|
|
@@ -35234,16 +35362,16 @@ PlatformHttpClientService = _ts_decorate8([
|
|
|
35234
35362
|
var DISABLE_DATAPASS = process.env.FORCE_FRAMEWORK_DISABLE_DATAPASS === "true";
|
|
35235
35363
|
|
|
35236
35364
|
// src/services/file.service.ts
|
|
35237
|
-
var
|
|
35365
|
+
var import_common10 = require("@nestjs/common");
|
|
35238
35366
|
var import_nestjs_common4 = require("@lark-apaas/nestjs-common");
|
|
35239
35367
|
var import_file_service = require("@lark-apaas/file-service");
|
|
35240
|
-
function
|
|
35368
|
+
function _ts_decorate10(decorators, target, key, desc) {
|
|
35241
35369
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
35242
35370
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
35243
35371
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
35244
35372
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
35245
35373
|
}
|
|
35246
|
-
__name(
|
|
35374
|
+
__name(_ts_decorate10, "_ts_decorate");
|
|
35247
35375
|
function _ts_metadata6(k, v) {
|
|
35248
35376
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
35249
35377
|
}
|
|
@@ -35268,7 +35396,7 @@ var FileService = class {
|
|
|
35268
35396
|
this.httpClient = httpClient;
|
|
35269
35397
|
this.observable = observable;
|
|
35270
35398
|
this.fileServiceCore = new import_file_service.FileService(this.httpClient);
|
|
35271
|
-
this.nestLogger = new
|
|
35399
|
+
this.nestLogger = new import_common10.Logger("file");
|
|
35272
35400
|
}
|
|
35273
35401
|
/**
|
|
35274
35402
|
* 返回一个绑定了指定 bucket 的代理对象
|
|
@@ -35608,10 +35736,10 @@ var FileService = class {
|
|
|
35608
35736
|
}
|
|
35609
35737
|
}
|
|
35610
35738
|
};
|
|
35611
|
-
FileService =
|
|
35612
|
-
(0,
|
|
35613
|
-
_ts_param2(1, (0,
|
|
35614
|
-
_ts_param2(2, (0,
|
|
35739
|
+
FileService = _ts_decorate10([
|
|
35740
|
+
(0, import_common10.Injectable)(),
|
|
35741
|
+
_ts_param2(1, (0, import_common10.Inject)(import_nestjs_common4.PLATFORM_HTTP_CLIENT)),
|
|
35742
|
+
_ts_param2(2, (0, import_common10.Inject)(import_nestjs_common4.OBSERVABLE_SERVICE)),
|
|
35615
35743
|
_ts_metadata6("design:type", Function),
|
|
35616
35744
|
_ts_metadata6("design:paramtypes", [
|
|
35617
35745
|
typeof import_nestjs_common4.RequestContextService === "undefined" ? Object : import_nestjs_common4.RequestContextService,
|
|
@@ -35624,21 +35752,21 @@ FileService = _ts_decorate9([
|
|
|
35624
35752
|
var import_nestjs_authzpaas = require("@lark-apaas/nestjs-authzpaas");
|
|
35625
35753
|
|
|
35626
35754
|
// src/modules/static/static.module.ts
|
|
35627
|
-
var
|
|
35755
|
+
var import_common12 = require("@nestjs/common");
|
|
35628
35756
|
|
|
35629
35757
|
// src/modules/static/static.controller.ts
|
|
35630
|
-
var
|
|
35631
|
-
var
|
|
35758
|
+
var import_common11 = require("@nestjs/common");
|
|
35759
|
+
var import_swagger2 = require("@nestjs/swagger");
|
|
35632
35760
|
var fs = __toESM(require("fs"), 1);
|
|
35633
35761
|
var path = __toESM(require("path"), 1);
|
|
35634
35762
|
var crypto2 = __toESM(require("crypto"), 1);
|
|
35635
|
-
function
|
|
35763
|
+
function _ts_decorate11(decorators, target, key, desc) {
|
|
35636
35764
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
35637
35765
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
35638
35766
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
35639
35767
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
35640
35768
|
}
|
|
35641
|
-
__name(
|
|
35769
|
+
__name(_ts_decorate11, "_ts_decorate");
|
|
35642
35770
|
function _ts_metadata7(k, v) {
|
|
35643
35771
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
35644
35772
|
}
|
|
@@ -35706,7 +35834,7 @@ var StaticController = class _StaticController {
|
|
|
35706
35834
|
static {
|
|
35707
35835
|
__name(this, "StaticController");
|
|
35708
35836
|
}
|
|
35709
|
-
logger = new
|
|
35837
|
+
logger = new import_common11.Logger(_StaticController.name);
|
|
35710
35838
|
staticDir;
|
|
35711
35839
|
constructor() {
|
|
35712
35840
|
this.staticDir = path.resolve(process.cwd(), "shared/static");
|
|
@@ -35727,7 +35855,7 @@ var StaticController = class _StaticController {
|
|
|
35727
35855
|
try {
|
|
35728
35856
|
const relativePath = params["0"] || params["*"] || "";
|
|
35729
35857
|
if (!relativePath) {
|
|
35730
|
-
res.status(
|
|
35858
|
+
res.status(import_common11.HttpStatus.BAD_REQUEST).json({
|
|
35731
35859
|
error: "Bad Request",
|
|
35732
35860
|
message: "File path is required"
|
|
35733
35861
|
});
|
|
@@ -35737,14 +35865,14 @@ var StaticController = class _StaticController {
|
|
|
35737
35865
|
const normalizedPath = path.normalize(filePath);
|
|
35738
35866
|
if (!normalizedPath.startsWith(this.staticDir)) {
|
|
35739
35867
|
this.logger.warn(`Path traversal attempt detected: ${relativePath}`);
|
|
35740
|
-
res.status(
|
|
35868
|
+
res.status(import_common11.HttpStatus.FORBIDDEN).json({
|
|
35741
35869
|
error: "Forbidden",
|
|
35742
35870
|
message: "Access denied"
|
|
35743
35871
|
});
|
|
35744
35872
|
return;
|
|
35745
35873
|
}
|
|
35746
35874
|
if (!fs.existsSync(normalizedPath)) {
|
|
35747
|
-
res.status(
|
|
35875
|
+
res.status(import_common11.HttpStatus.NOT_FOUND).json({
|
|
35748
35876
|
error: "Not Found",
|
|
35749
35877
|
message: "File not found"
|
|
35750
35878
|
});
|
|
@@ -35752,7 +35880,7 @@ var StaticController = class _StaticController {
|
|
|
35752
35880
|
}
|
|
35753
35881
|
const stat = fs.statSync(normalizedPath);
|
|
35754
35882
|
if (stat.isDirectory()) {
|
|
35755
|
-
res.status(
|
|
35883
|
+
res.status(import_common11.HttpStatus.FORBIDDEN).json({
|
|
35756
35884
|
error: "Forbidden",
|
|
35757
35885
|
message: "Directory listing not allowed"
|
|
35758
35886
|
});
|
|
@@ -35762,7 +35890,7 @@ var StaticController = class _StaticController {
|
|
|
35762
35890
|
const etag = generateETag(stat);
|
|
35763
35891
|
const ifNoneMatch = req.headers["if-none-match"];
|
|
35764
35892
|
if (ifNoneMatch === etag) {
|
|
35765
|
-
res.status(
|
|
35893
|
+
res.status(import_common11.HttpStatus.NOT_MODIFIED).end();
|
|
35766
35894
|
return;
|
|
35767
35895
|
}
|
|
35768
35896
|
res.setHeader("Content-Type", mimeType);
|
|
@@ -35773,7 +35901,7 @@ var StaticController = class _StaticController {
|
|
|
35773
35901
|
stream.on("error", (error) => {
|
|
35774
35902
|
this.logger.error(`Error streaming file: ${relativePath}`, error);
|
|
35775
35903
|
if (!res.headersSent) {
|
|
35776
|
-
res.status(
|
|
35904
|
+
res.status(import_common11.HttpStatus.INTERNAL_SERVER_ERROR).json({
|
|
35777
35905
|
error: "Internal Server Error",
|
|
35778
35906
|
message: "Failed to read file"
|
|
35779
35907
|
});
|
|
@@ -35783,7 +35911,7 @@ var StaticController = class _StaticController {
|
|
|
35783
35911
|
} catch (error) {
|
|
35784
35912
|
this.logger.error("Error serving static file", error);
|
|
35785
35913
|
if (!res.headersSent) {
|
|
35786
|
-
res.status(
|
|
35914
|
+
res.status(import_common11.HttpStatus.INTERNAL_SERVER_ERROR).json({
|
|
35787
35915
|
error: "Internal Server Error",
|
|
35788
35916
|
message: "An unexpected error occurred"
|
|
35789
35917
|
});
|
|
@@ -35791,11 +35919,11 @@ var StaticController = class _StaticController {
|
|
|
35791
35919
|
}
|
|
35792
35920
|
}
|
|
35793
35921
|
};
|
|
35794
|
-
|
|
35795
|
-
(0,
|
|
35796
|
-
_ts_param3(0, (0,
|
|
35797
|
-
_ts_param3(1, (0,
|
|
35798
|
-
_ts_param3(2, (0,
|
|
35922
|
+
_ts_decorate11([
|
|
35923
|
+
(0, import_common11.Get)("*"),
|
|
35924
|
+
_ts_param3(0, (0, import_common11.Param)()),
|
|
35925
|
+
_ts_param3(1, (0, import_common11.Req)()),
|
|
35926
|
+
_ts_param3(2, (0, import_common11.Res)()),
|
|
35799
35927
|
_ts_metadata7("design:type", Function),
|
|
35800
35928
|
_ts_metadata7("design:paramtypes", [
|
|
35801
35929
|
typeof Record === "undefined" ? Object : Record,
|
|
@@ -35804,28 +35932,28 @@ _ts_decorate10([
|
|
|
35804
35932
|
]),
|
|
35805
35933
|
_ts_metadata7("design:returntype", void 0)
|
|
35806
35934
|
], StaticController.prototype, "serveFile", null);
|
|
35807
|
-
StaticController =
|
|
35808
|
-
(0,
|
|
35809
|
-
(0,
|
|
35935
|
+
StaticController = _ts_decorate11([
|
|
35936
|
+
(0, import_swagger2.ApiExcludeController)(),
|
|
35937
|
+
(0, import_common11.Controller)("static"),
|
|
35810
35938
|
_ts_metadata7("design:type", Function),
|
|
35811
35939
|
_ts_metadata7("design:paramtypes", [])
|
|
35812
35940
|
], StaticController);
|
|
35813
35941
|
|
|
35814
35942
|
// src/modules/static/static.module.ts
|
|
35815
|
-
function
|
|
35943
|
+
function _ts_decorate12(decorators, target, key, desc) {
|
|
35816
35944
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
35817
35945
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
35818
35946
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
35819
35947
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
35820
35948
|
}
|
|
35821
|
-
__name(
|
|
35949
|
+
__name(_ts_decorate12, "_ts_decorate");
|
|
35822
35950
|
var StaticModule = class {
|
|
35823
35951
|
static {
|
|
35824
35952
|
__name(this, "StaticModule");
|
|
35825
35953
|
}
|
|
35826
35954
|
};
|
|
35827
|
-
StaticModule =
|
|
35828
|
-
(0,
|
|
35955
|
+
StaticModule = _ts_decorate12([
|
|
35956
|
+
(0, import_common12.Module)({
|
|
35829
35957
|
controllers: [
|
|
35830
35958
|
StaticController
|
|
35831
35959
|
]
|
|
@@ -35833,14 +35961,14 @@ StaticModule = _ts_decorate11([
|
|
|
35833
35961
|
], StaticModule);
|
|
35834
35962
|
|
|
35835
35963
|
// src/modules/html-hot-update/html-hot-update.module.ts
|
|
35836
|
-
var
|
|
35964
|
+
var import_common15 = require("@nestjs/common");
|
|
35837
35965
|
|
|
35838
35966
|
// src/modules/html-hot-update/html-hot-update.controller.ts
|
|
35839
|
-
var
|
|
35840
|
-
var
|
|
35967
|
+
var import_common14 = require("@nestjs/common");
|
|
35968
|
+
var import_swagger3 = require("@nestjs/swagger");
|
|
35841
35969
|
|
|
35842
35970
|
// src/modules/html-hot-update/html-hot-update.service.ts
|
|
35843
|
-
var
|
|
35971
|
+
var import_common13 = require("@nestjs/common");
|
|
35844
35972
|
var import_node_fs = require("fs");
|
|
35845
35973
|
var import_node_fs2 = require("fs");
|
|
35846
35974
|
var import_node_crypto = require("crypto");
|
|
@@ -35873,13 +36001,13 @@ function setActiveHtmlVersion(version) {
|
|
|
35873
36001
|
__name(setActiveHtmlVersion, "setActiveHtmlVersion");
|
|
35874
36002
|
|
|
35875
36003
|
// src/modules/html-hot-update/html-hot-update.service.ts
|
|
35876
|
-
function
|
|
36004
|
+
function _ts_decorate13(decorators, target, key, desc) {
|
|
35877
36005
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
35878
36006
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
35879
36007
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
35880
36008
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
35881
36009
|
}
|
|
35882
|
-
__name(
|
|
36010
|
+
__name(_ts_decorate13, "_ts_decorate");
|
|
35883
36011
|
function _ts_metadata8(k, v) {
|
|
35884
36012
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
35885
36013
|
}
|
|
@@ -35922,7 +36050,7 @@ var HtmlHotUpdateService = class _HtmlHotUpdateService {
|
|
|
35922
36050
|
__name(this, "HtmlHotUpdateService");
|
|
35923
36051
|
}
|
|
35924
36052
|
httpClient;
|
|
35925
|
-
logger = new
|
|
36053
|
+
logger = new import_common13.Logger(_HtmlHotUpdateService.name);
|
|
35926
36054
|
fileLock = new Mutex();
|
|
35927
36055
|
hotUpdateDir = getHotUpdateHtmlDir();
|
|
35928
36056
|
hotUpdateVersionsDir = getHotUpdateVersionsDir();
|
|
@@ -36124,9 +36252,9 @@ var HtmlHotUpdateService = class _HtmlHotUpdateService {
|
|
|
36124
36252
|
return "";
|
|
36125
36253
|
}
|
|
36126
36254
|
};
|
|
36127
|
-
HtmlHotUpdateService =
|
|
36128
|
-
(0,
|
|
36129
|
-
_ts_param4(0, (0,
|
|
36255
|
+
HtmlHotUpdateService = _ts_decorate13([
|
|
36256
|
+
(0, import_common13.Injectable)(),
|
|
36257
|
+
_ts_param4(0, (0, import_common13.Inject)(import_nestjs_common5.PLATFORM_HTTP_CLIENT)),
|
|
36130
36258
|
_ts_metadata8("design:type", Function),
|
|
36131
36259
|
_ts_metadata8("design:paramtypes", [
|
|
36132
36260
|
typeof PlatformHttpClient === "undefined" ? Object : PlatformHttpClient
|
|
@@ -36134,13 +36262,13 @@ HtmlHotUpdateService = _ts_decorate12([
|
|
|
36134
36262
|
], HtmlHotUpdateService);
|
|
36135
36263
|
|
|
36136
36264
|
// src/modules/html-hot-update/html-hot-update.controller.ts
|
|
36137
|
-
function
|
|
36265
|
+
function _ts_decorate14(decorators, target, key, desc) {
|
|
36138
36266
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
36139
36267
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
36140
36268
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
36141
36269
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
36142
36270
|
}
|
|
36143
|
-
__name(
|
|
36271
|
+
__name(_ts_decorate14, "_ts_decorate");
|
|
36144
36272
|
function _ts_metadata9(k, v) {
|
|
36145
36273
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
36146
36274
|
}
|
|
@@ -36163,7 +36291,7 @@ var HtmlHotUpdateController = class _HtmlHotUpdateController {
|
|
|
36163
36291
|
__name(this, "HtmlHotUpdateController");
|
|
36164
36292
|
}
|
|
36165
36293
|
htmlHotUpdateService;
|
|
36166
|
-
logger = new
|
|
36294
|
+
logger = new import_common14.Logger(_HtmlHotUpdateController.name);
|
|
36167
36295
|
constructor(htmlHotUpdateService) {
|
|
36168
36296
|
this.htmlHotUpdateService = htmlHotUpdateService;
|
|
36169
36297
|
}
|
|
@@ -36205,19 +36333,19 @@ var HtmlHotUpdateController = class _HtmlHotUpdateController {
|
|
|
36205
36333
|
}
|
|
36206
36334
|
}
|
|
36207
36335
|
};
|
|
36208
|
-
|
|
36209
|
-
(0,
|
|
36210
|
-
(0,
|
|
36211
|
-
_ts_param5(0, (0,
|
|
36336
|
+
_ts_decorate14([
|
|
36337
|
+
(0, import_common14.Post)("update_html_files"),
|
|
36338
|
+
(0, import_common14.HttpCode)(import_common14.HttpStatus.OK),
|
|
36339
|
+
_ts_param5(0, (0, import_common14.Body)()),
|
|
36212
36340
|
_ts_metadata9("design:type", Function),
|
|
36213
36341
|
_ts_metadata9("design:paramtypes", [
|
|
36214
36342
|
typeof UpdateHtmlFilesDto === "undefined" ? Object : UpdateHtmlFilesDto
|
|
36215
36343
|
]),
|
|
36216
36344
|
_ts_metadata9("design:returntype", Promise)
|
|
36217
36345
|
], HtmlHotUpdateController.prototype, "updateHtmlFiles", null);
|
|
36218
|
-
HtmlHotUpdateController =
|
|
36219
|
-
(0,
|
|
36220
|
-
(0,
|
|
36346
|
+
HtmlHotUpdateController = _ts_decorate14([
|
|
36347
|
+
(0, import_swagger3.ApiExcludeController)(),
|
|
36348
|
+
(0, import_common14.Controller)("__innerapi__"),
|
|
36221
36349
|
_ts_metadata9("design:type", Function),
|
|
36222
36350
|
_ts_metadata9("design:paramtypes", [
|
|
36223
36351
|
typeof HtmlHotUpdateService === "undefined" ? Object : HtmlHotUpdateService
|
|
@@ -36225,20 +36353,20 @@ HtmlHotUpdateController = _ts_decorate13([
|
|
|
36225
36353
|
], HtmlHotUpdateController);
|
|
36226
36354
|
|
|
36227
36355
|
// src/modules/html-hot-update/html-hot-update.module.ts
|
|
36228
|
-
function
|
|
36356
|
+
function _ts_decorate15(decorators, target, key, desc) {
|
|
36229
36357
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
36230
36358
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
36231
36359
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
36232
36360
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
36233
36361
|
}
|
|
36234
|
-
__name(
|
|
36362
|
+
__name(_ts_decorate15, "_ts_decorate");
|
|
36235
36363
|
var HtmlHotUpdateModule = class {
|
|
36236
36364
|
static {
|
|
36237
36365
|
__name(this, "HtmlHotUpdateModule");
|
|
36238
36366
|
}
|
|
36239
36367
|
};
|
|
36240
|
-
HtmlHotUpdateModule =
|
|
36241
|
-
(0,
|
|
36368
|
+
HtmlHotUpdateModule = _ts_decorate15([
|
|
36369
|
+
(0, import_common15.Module)({
|
|
36242
36370
|
controllers: [
|
|
36243
36371
|
HtmlHotUpdateController
|
|
36244
36372
|
],
|
|
@@ -36252,16 +36380,16 @@ HtmlHotUpdateModule = _ts_decorate14([
|
|
|
36252
36380
|
], HtmlHotUpdateModule);
|
|
36253
36381
|
|
|
36254
36382
|
// src/middlewares/html-hot-update-view/index.ts
|
|
36255
|
-
var
|
|
36383
|
+
var import_common16 = require("@nestjs/common");
|
|
36256
36384
|
var import_node_fs3 = require("fs");
|
|
36257
36385
|
var import_node_path3 = require("path");
|
|
36258
|
-
function
|
|
36386
|
+
function _ts_decorate16(decorators, target, key, desc) {
|
|
36259
36387
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
36260
36388
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
36261
36389
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
36262
36390
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
36263
36391
|
}
|
|
36264
|
-
__name(
|
|
36392
|
+
__name(_ts_decorate16, "_ts_decorate");
|
|
36265
36393
|
var HtmlHotUpdateViewMiddleware = class {
|
|
36266
36394
|
static {
|
|
36267
36395
|
__name(this, "HtmlHotUpdateViewMiddleware");
|
|
@@ -36288,18 +36416,18 @@ var HtmlHotUpdateViewMiddleware = class {
|
|
|
36288
36416
|
next();
|
|
36289
36417
|
}
|
|
36290
36418
|
};
|
|
36291
|
-
HtmlHotUpdateViewMiddleware =
|
|
36292
|
-
(0,
|
|
36419
|
+
HtmlHotUpdateViewMiddleware = _ts_decorate16([
|
|
36420
|
+
(0, import_common16.Injectable)()
|
|
36293
36421
|
], HtmlHotUpdateViewMiddleware);
|
|
36294
36422
|
|
|
36295
36423
|
// src/modules/platform/module.ts
|
|
36296
|
-
function
|
|
36424
|
+
function _ts_decorate17(decorators, target, key, desc) {
|
|
36297
36425
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
36298
36426
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
36299
36427
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
36300
36428
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
36301
36429
|
}
|
|
36302
|
-
__name(
|
|
36430
|
+
__name(_ts_decorate17, "_ts_decorate");
|
|
36303
36431
|
var PLATFORM_MODULE_OPTIONS = /* @__PURE__ */ Symbol("PLATFORM_MODULE_OPTIONS");
|
|
36304
36432
|
var PlatformModule = class _PlatformModule {
|
|
36305
36433
|
static {
|
|
@@ -36387,7 +36515,7 @@ var PlatformModule = class _PlatformModule {
|
|
|
36387
36515
|
},
|
|
36388
36516
|
{
|
|
36389
36517
|
provide: import_core2.APP_PIPE,
|
|
36390
|
-
useValue: new
|
|
36518
|
+
useValue: new import_common17.ValidationPipe({
|
|
36391
36519
|
transform: true,
|
|
36392
36520
|
transformOptions: {
|
|
36393
36521
|
enableImplicitConversion: true
|
|
@@ -36440,16 +36568,21 @@ var PlatformModule = class _PlatformModule {
|
|
|
36440
36568
|
*/
|
|
36441
36569
|
configure(consumer) {
|
|
36442
36570
|
const options = _PlatformModule.moduleOptions;
|
|
36443
|
-
consumer.apply(apiResponseInterceptor).forRoutes("/api/*");
|
|
36571
|
+
consumer.apply(apiResponseInterceptor).forRoutes("/api/*", "/openapi/*");
|
|
36444
36572
|
if (process.env.NODE_ENV === "development") {
|
|
36445
36573
|
consumer.apply(FrameworkDebugMiddleware).forRoutes("/api/__framework__/debug");
|
|
36446
36574
|
}
|
|
36575
|
+
if (process.env.NODE_ENV !== "production") {
|
|
36576
|
+
consumer.apply(OpenApiSpecMiddleware).forRoutes("/api/__framework__/openapi-spec");
|
|
36577
|
+
}
|
|
36447
36578
|
consumer.apply(UserContextMiddleware, RequestContextMiddleware, import_nestjs_logger2.LoggerContextMiddleware, import_nestjs_observable.ObservableTraceMiddleware, ...DISABLE_DATAPASS ? [] : [
|
|
36448
36579
|
import_nestjs_datapaas.SqlExecutionContextMiddleware
|
|
36449
36580
|
]).forRoutes("/*");
|
|
36450
|
-
consumer.apply(CsrfTokenMiddleware, ViewContextMiddleware, HtmlHotUpdateViewMiddleware).exclude("/api/(.*)", "/static/(.*)").forRoutes("*");
|
|
36581
|
+
consumer.apply(CsrfTokenMiddleware, ViewContextMiddleware, HtmlHotUpdateViewMiddleware).exclude("/api/(.*)", "/openapi/(.*)", "/static/(.*)").forRoutes("*");
|
|
36451
36582
|
if (options.enableCsrf !== false) {
|
|
36452
|
-
const csrfRoutes = options.csrfRoutes ||
|
|
36583
|
+
const csrfRoutes = options.csrfRoutes || [
|
|
36584
|
+
"/api/*"
|
|
36585
|
+
];
|
|
36453
36586
|
if (Array.isArray(csrfRoutes)) {
|
|
36454
36587
|
csrfRoutes.forEach((route) => {
|
|
36455
36588
|
consumer.apply(CsrfMiddleware).forRoutes(route);
|
|
@@ -36460,9 +36593,9 @@ var PlatformModule = class _PlatformModule {
|
|
|
36460
36593
|
}
|
|
36461
36594
|
}
|
|
36462
36595
|
};
|
|
36463
|
-
PlatformModule =
|
|
36464
|
-
(0,
|
|
36465
|
-
(0,
|
|
36596
|
+
PlatformModule = _ts_decorate17([
|
|
36597
|
+
(0, import_common17.Global)(),
|
|
36598
|
+
(0, import_common17.Module)({})
|
|
36466
36599
|
], PlatformModule);
|
|
36467
36600
|
|
|
36468
36601
|
// src/setup.ts
|
|
@@ -36538,6 +36671,9 @@ async function configureApp(app, perms = defaultPerms) {
|
|
|
36538
36671
|
console.error("[OpenAPI] OpenAPI \u751F\u6210\u5931\u8D25:", err);
|
|
36539
36672
|
}
|
|
36540
36673
|
}
|
|
36674
|
+
if (process.env.NODE_ENV !== "production") {
|
|
36675
|
+
registerOpenApiSpecEndpoint(app);
|
|
36676
|
+
}
|
|
36541
36677
|
console.log("App Started Successfully.");
|
|
36542
36678
|
}
|
|
36543
36679
|
__name(configureApp, "configureApp");
|
|
@@ -36574,6 +36710,7 @@ var import_nestjs_authzpaas2 = require("@lark-apaas/nestjs-authzpaas");
|
|
|
36574
36710
|
ViewContextMiddleware,
|
|
36575
36711
|
configureApp,
|
|
36576
36712
|
createLegacyPathRedirectMiddleware,
|
|
36713
|
+
registerOpenApiSpecEndpoint,
|
|
36577
36714
|
...require("@lark-apaas/nestjs-authnpaas"),
|
|
36578
36715
|
...require("@lark-apaas/nestjs-capability"),
|
|
36579
36716
|
...require("@lark-apaas/nestjs-datapaas"),
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NestModule, DynamicModule, MiddlewareConsumer, OnModuleInit, NestMiddleware } from '@nestjs/common';
|
|
1
|
+
import { NestModule, DynamicModule, MiddlewareConsumer, OnModuleInit, NestMiddleware, INestApplication } 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
|
|
204
|
+
private getAppInfo;
|
|
205
205
|
use(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
206
206
|
}
|
|
207
207
|
|
|
@@ -221,6 +221,12 @@ declare class ViewContextMiddleware implements NestMiddleware {
|
|
|
221
221
|
*/
|
|
222
222
|
declare function createLegacyPathRedirectMiddleware(): (req: Request, res: Response, next: NextFunction) => void;
|
|
223
223
|
|
|
224
|
+
/**
|
|
225
|
+
* 保存 app 引用,供 OpenApiSpecMiddleware 懒加载生成 spec。
|
|
226
|
+
* 在 configureApp() 中调用(非生产环境)。
|
|
227
|
+
*/
|
|
228
|
+
declare function registerOpenApiSpecEndpoint(app: INestApplication): void;
|
|
229
|
+
|
|
224
230
|
/**
|
|
225
231
|
* API 404 响应格式
|
|
226
232
|
*/
|
|
@@ -401,4 +407,4 @@ declare class PlatformHttpClientService {
|
|
|
401
407
|
private registerInterceptorsForClient;
|
|
402
408
|
}
|
|
403
409
|
|
|
404
|
-
export { type ApiNotFoundResponse, CsrfMiddleware, CsrfTokenMiddleware, FileService, HtmlHotUpdateModule, HtmlHotUpdateService, type PlatformHttpClientOptions, PlatformHttpClientService, PlatformModule, type PlatformModuleOptions, StaticModule, UserContextMiddleware, ViewContextMiddleware, configureApp, createLegacyPathRedirectMiddleware };
|
|
410
|
+
export { type ApiNotFoundResponse, CsrfMiddleware, CsrfTokenMiddleware, FileService, HtmlHotUpdateModule, HtmlHotUpdateService, type PlatformHttpClientOptions, PlatformHttpClientService, PlatformModule, type PlatformModuleOptions, StaticModule, UserContextMiddleware, ViewContextMiddleware, configureApp, createLegacyPathRedirectMiddleware, registerOpenApiSpecEndpoint };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NestModule, DynamicModule, MiddlewareConsumer, OnModuleInit, NestMiddleware } from '@nestjs/common';
|
|
1
|
+
import { NestModule, DynamicModule, MiddlewareConsumer, OnModuleInit, NestMiddleware, INestApplication } 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
|
|
204
|
+
private getAppInfo;
|
|
205
205
|
use(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
206
206
|
}
|
|
207
207
|
|
|
@@ -221,6 +221,12 @@ declare class ViewContextMiddleware implements NestMiddleware {
|
|
|
221
221
|
*/
|
|
222
222
|
declare function createLegacyPathRedirectMiddleware(): (req: Request, res: Response, next: NextFunction) => void;
|
|
223
223
|
|
|
224
|
+
/**
|
|
225
|
+
* 保存 app 引用,供 OpenApiSpecMiddleware 懒加载生成 spec。
|
|
226
|
+
* 在 configureApp() 中调用(非生产环境)。
|
|
227
|
+
*/
|
|
228
|
+
declare function registerOpenApiSpecEndpoint(app: INestApplication): void;
|
|
229
|
+
|
|
224
230
|
/**
|
|
225
231
|
* API 404 响应格式
|
|
226
232
|
*/
|
|
@@ -401,4 +407,4 @@ declare class PlatformHttpClientService {
|
|
|
401
407
|
private registerInterceptorsForClient;
|
|
402
408
|
}
|
|
403
409
|
|
|
404
|
-
export { type ApiNotFoundResponse, CsrfMiddleware, CsrfTokenMiddleware, FileService, HtmlHotUpdateModule, HtmlHotUpdateService, type PlatformHttpClientOptions, PlatformHttpClientService, PlatformModule, type PlatformModuleOptions, StaticModule, UserContextMiddleware, ViewContextMiddleware, configureApp, createLegacyPathRedirectMiddleware };
|
|
410
|
+
export { type ApiNotFoundResponse, CsrfMiddleware, CsrfTokenMiddleware, FileService, HtmlHotUpdateModule, HtmlHotUpdateService, type PlatformHttpClientOptions, PlatformHttpClientService, PlatformModule, type PlatformModuleOptions, StaticModule, UserContextMiddleware, ViewContextMiddleware, configureApp, createLegacyPathRedirectMiddleware, registerOpenApiSpecEndpoint };
|
package/dist/index.js
CHANGED
|
@@ -34600,32 +34600,31 @@ var ViewContextMiddleware = class _ViewContextMiddleware {
|
|
|
34600
34600
|
constructor(client) {
|
|
34601
34601
|
this.client = client;
|
|
34602
34602
|
}
|
|
34603
|
-
async
|
|
34603
|
+
async getAppInfo(appId) {
|
|
34604
34604
|
if (!appId) {
|
|
34605
|
-
this.logger.warn(`appId is empty, skip get app
|
|
34605
|
+
this.logger.warn(`appId is empty, skip get app info`);
|
|
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
|
|
34611
|
+
throw new Error(`Failed to get app info, 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
|
|
34615
|
+
throw new Error(`Failed to get app info, status_code: ${data.status_code}`);
|
|
34616
34616
|
}
|
|
34617
|
-
return data.data ??
|
|
34617
|
+
return data.data.app_info ?? {};
|
|
34618
34618
|
} catch (err) {
|
|
34619
|
-
this.logger.error(err, "Failed to get app
|
|
34619
|
+
this.logger.error(err, "Failed to get app info");
|
|
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);
|
|
34626
34627
|
const environment = mapToWindowEnvironment(process.env.FORCE_FRAMEWORK_ENVIRONMENT);
|
|
34627
|
-
const appPublishedData = await this.getAppPublished(appId);
|
|
34628
|
-
const appInfo = appPublishedData?.app_info ?? null;
|
|
34629
34628
|
req.__platform_data__ = {
|
|
34630
34629
|
csrfToken: csrfToken ?? "",
|
|
34631
34630
|
userId: userId ?? "",
|
|
@@ -34636,9 +34635,7 @@ var ViewContextMiddleware = class _ViewContextMiddleware {
|
|
|
34636
34635
|
loginUrl: loginUrl ?? "",
|
|
34637
34636
|
userType: userType ?? "",
|
|
34638
34637
|
tenantId,
|
|
34639
|
-
environment
|
|
34640
|
-
showBadge: appInfo?.show_badge !== false,
|
|
34641
|
-
appPublished: appPublishedData ?? null
|
|
34638
|
+
environment
|
|
34642
34639
|
};
|
|
34643
34640
|
res.locals = {
|
|
34644
34641
|
...res.locals ?? {},
|
|
@@ -34749,18 +34746,24 @@ function createApiNotFoundResponse(req) {
|
|
|
34749
34746
|
};
|
|
34750
34747
|
}
|
|
34751
34748
|
__name(createApiNotFoundResponse, "createApiNotFoundResponse");
|
|
34752
|
-
function
|
|
34749
|
+
function getApiPathPrefixes() {
|
|
34753
34750
|
const globalPrefix = process.env.CLIENT_BASE_PATH ?? "";
|
|
34754
34751
|
if (!globalPrefix) {
|
|
34755
|
-
return
|
|
34752
|
+
return [
|
|
34753
|
+
"/api/",
|
|
34754
|
+
"/openapi/"
|
|
34755
|
+
];
|
|
34756
34756
|
}
|
|
34757
34757
|
const normalizedPrefix = globalPrefix.replace(/\/+$/, "");
|
|
34758
|
-
return
|
|
34758
|
+
return [
|
|
34759
|
+
`${normalizedPrefix}/api/`,
|
|
34760
|
+
`${normalizedPrefix}/openapi/`
|
|
34761
|
+
];
|
|
34759
34762
|
}
|
|
34760
|
-
__name(
|
|
34763
|
+
__name(getApiPathPrefixes, "getApiPathPrefixes");
|
|
34761
34764
|
function apiResponseInterceptor(req, res, next) {
|
|
34762
|
-
const
|
|
34763
|
-
if (!req.baseUrl.startsWith(
|
|
34765
|
+
const apiPrefixes = getApiPathPrefixes();
|
|
34766
|
+
if (!apiPrefixes.some((prefix) => req.baseUrl.startsWith(prefix))) {
|
|
34764
34767
|
return next();
|
|
34765
34768
|
}
|
|
34766
34769
|
res.render = function() {
|
|
@@ -34990,17 +34993,141 @@ FrameworkDebugMiddleware = _ts_decorate7([
|
|
|
34990
34993
|
])
|
|
34991
34994
|
], FrameworkDebugMiddleware);
|
|
34992
34995
|
|
|
34996
|
+
// src/middlewares/openapi-spec/index.ts
|
|
34997
|
+
import { SwaggerModule, DocumentBuilder } from "@nestjs/swagger";
|
|
34998
|
+
import { Injectable as Injectable8 } from "@nestjs/common";
|
|
34999
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
35000
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
35001
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
35002
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
35003
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
35004
|
+
}
|
|
35005
|
+
__name(_ts_decorate8, "_ts_decorate");
|
|
35006
|
+
var _app = null;
|
|
35007
|
+
var _cachedSpec = null;
|
|
35008
|
+
function registerOpenApiSpecEndpoint(app) {
|
|
35009
|
+
const globalPrefix = (process.env.CLIENT_BASE_PATH ?? "").replace(/\/+$/, "");
|
|
35010
|
+
_app = app;
|
|
35011
|
+
console.log(`[OpenAPI] Registered GET ${globalPrefix}/api/__framework__/openapi-spec`);
|
|
35012
|
+
}
|
|
35013
|
+
__name(registerOpenApiSpecEndpoint, "registerOpenApiSpecEndpoint");
|
|
35014
|
+
var OpenApiSpecMiddleware = class {
|
|
35015
|
+
static {
|
|
35016
|
+
__name(this, "OpenApiSpecMiddleware");
|
|
35017
|
+
}
|
|
35018
|
+
use(_req, res, next) {
|
|
35019
|
+
if (!_app) {
|
|
35020
|
+
next();
|
|
35021
|
+
return;
|
|
35022
|
+
}
|
|
35023
|
+
try {
|
|
35024
|
+
if (!_cachedSpec) {
|
|
35025
|
+
const globalPrefix = (process.env.CLIENT_BASE_PATH ?? "").replace(/\/+$/, "");
|
|
35026
|
+
const config = new DocumentBuilder().setTitle("OpenAPI Spec").setVersion("1.0").build();
|
|
35027
|
+
const spec = SwaggerModule.createDocument(_app, config);
|
|
35028
|
+
_cachedSpec = buildFilteredSpec(spec, globalPrefix);
|
|
35029
|
+
}
|
|
35030
|
+
res.json(_cachedSpec);
|
|
35031
|
+
} catch (err) {
|
|
35032
|
+
console.error("[openapi-spec] Failed to generate spec:", err);
|
|
35033
|
+
res.json({
|
|
35034
|
+
openapi: "3.0.0",
|
|
35035
|
+
paths: {},
|
|
35036
|
+
components: {
|
|
35037
|
+
schemas: {}
|
|
35038
|
+
}
|
|
35039
|
+
});
|
|
35040
|
+
}
|
|
35041
|
+
}
|
|
35042
|
+
};
|
|
35043
|
+
OpenApiSpecMiddleware = _ts_decorate8([
|
|
35044
|
+
Injectable8()
|
|
35045
|
+
], OpenApiSpecMiddleware);
|
|
35046
|
+
function buildFilteredSpec(spec, globalPrefix) {
|
|
35047
|
+
const schemas = spec.components?.schemas ?? {};
|
|
35048
|
+
const paths = spec.paths ?? {};
|
|
35049
|
+
const filteredPaths = {};
|
|
35050
|
+
for (const [pathKey, methods] of Object.entries(paths)) {
|
|
35051
|
+
const cleanPath = stripPrefix(pathKey, globalPrefix);
|
|
35052
|
+
if (!cleanPath.startsWith("/openapi")) continue;
|
|
35053
|
+
filteredPaths[cleanPath] = {};
|
|
35054
|
+
for (const [method, operation] of Object.entries(methods)) {
|
|
35055
|
+
if ([
|
|
35056
|
+
"parameters",
|
|
35057
|
+
"summary",
|
|
35058
|
+
"description",
|
|
35059
|
+
"servers"
|
|
35060
|
+
].includes(method)) continue;
|
|
35061
|
+
filteredPaths[cleanPath][method] = resolveRefsDeep(structuredClone(operation), schemas);
|
|
35062
|
+
}
|
|
35063
|
+
}
|
|
35064
|
+
return {
|
|
35065
|
+
openapi: spec.openapi,
|
|
35066
|
+
paths: filteredPaths,
|
|
35067
|
+
components: {
|
|
35068
|
+
schemas: resolveAllSchemaRefs(structuredClone(schemas))
|
|
35069
|
+
}
|
|
35070
|
+
};
|
|
35071
|
+
}
|
|
35072
|
+
__name(buildFilteredSpec, "buildFilteredSpec");
|
|
35073
|
+
function stripPrefix(path2, prefix) {
|
|
35074
|
+
if (prefix && path2.startsWith(prefix)) {
|
|
35075
|
+
return path2.slice(prefix.length);
|
|
35076
|
+
}
|
|
35077
|
+
return path2;
|
|
35078
|
+
}
|
|
35079
|
+
__name(stripPrefix, "stripPrefix");
|
|
35080
|
+
var MAX_REF_DEPTH = 5;
|
|
35081
|
+
function resolveRefsDeep(obj, schemas, depth = 0) {
|
|
35082
|
+
if (depth > MAX_REF_DEPTH || obj === null || obj === void 0) return obj;
|
|
35083
|
+
if (typeof obj !== "object") return obj;
|
|
35084
|
+
if (Array.isArray(obj)) {
|
|
35085
|
+
return obj.map((item) => resolveRefsDeep(item, schemas, depth));
|
|
35086
|
+
}
|
|
35087
|
+
const record = obj;
|
|
35088
|
+
if (typeof record["$ref"] === "string") {
|
|
35089
|
+
const resolved = resolveRef(record["$ref"], schemas);
|
|
35090
|
+
if (resolved !== void 0) {
|
|
35091
|
+
return resolveRefsDeep(structuredClone(resolved), schemas, depth + 1);
|
|
35092
|
+
}
|
|
35093
|
+
return record;
|
|
35094
|
+
}
|
|
35095
|
+
const result = {};
|
|
35096
|
+
for (const [key, value] of Object.entries(record)) {
|
|
35097
|
+
result[key] = resolveRefsDeep(value, schemas, depth);
|
|
35098
|
+
}
|
|
35099
|
+
return result;
|
|
35100
|
+
}
|
|
35101
|
+
__name(resolveRefsDeep, "resolveRefsDeep");
|
|
35102
|
+
function resolveRef(ref, schemas) {
|
|
35103
|
+
const prefix = "#/components/schemas/";
|
|
35104
|
+
if (ref.startsWith(prefix)) {
|
|
35105
|
+
const name = ref.slice(prefix.length);
|
|
35106
|
+
return schemas[name];
|
|
35107
|
+
}
|
|
35108
|
+
return void 0;
|
|
35109
|
+
}
|
|
35110
|
+
__name(resolveRef, "resolveRef");
|
|
35111
|
+
function resolveAllSchemaRefs(schemas) {
|
|
35112
|
+
const result = {};
|
|
35113
|
+
for (const [name, schema] of Object.entries(schemas)) {
|
|
35114
|
+
result[name] = resolveRefsDeep(schema, schemas);
|
|
35115
|
+
}
|
|
35116
|
+
return result;
|
|
35117
|
+
}
|
|
35118
|
+
__name(resolveAllSchemaRefs, "resolveAllSchemaRefs");
|
|
35119
|
+
|
|
34993
35120
|
// src/services/platform-http-client.service.ts
|
|
34994
|
-
import { Injectable as
|
|
35121
|
+
import { Injectable as Injectable9, Logger as Logger2 } from "@nestjs/common";
|
|
34995
35122
|
import { HttpClient } from "@lark-apaas/http-client";
|
|
34996
35123
|
import { RequestContextService as RequestContextService2 } from "@lark-apaas/nestjs-common";
|
|
34997
|
-
function
|
|
35124
|
+
function _ts_decorate9(decorators, target, key, desc) {
|
|
34998
35125
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
34999
35126
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
35000
35127
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
35001
35128
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
35002
35129
|
}
|
|
35003
|
-
__name(
|
|
35130
|
+
__name(_ts_decorate9, "_ts_decorate");
|
|
35004
35131
|
function _ts_metadata5(k, v) {
|
|
35005
35132
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
35006
35133
|
}
|
|
@@ -35195,8 +35322,8 @@ var PlatformHttpClientService = class _PlatformHttpClientService {
|
|
|
35195
35322
|
});
|
|
35196
35323
|
}
|
|
35197
35324
|
};
|
|
35198
|
-
PlatformHttpClientService =
|
|
35199
|
-
|
|
35325
|
+
PlatformHttpClientService = _ts_decorate9([
|
|
35326
|
+
Injectable9(),
|
|
35200
35327
|
_ts_metadata5("design:type", Function),
|
|
35201
35328
|
_ts_metadata5("design:paramtypes", [
|
|
35202
35329
|
typeof RequestContextService2 === "undefined" ? Object : RequestContextService2
|
|
@@ -35207,16 +35334,16 @@ PlatformHttpClientService = _ts_decorate8([
|
|
|
35207
35334
|
var DISABLE_DATAPASS = process.env.FORCE_FRAMEWORK_DISABLE_DATAPASS === "true";
|
|
35208
35335
|
|
|
35209
35336
|
// src/services/file.service.ts
|
|
35210
|
-
import { Injectable as
|
|
35337
|
+
import { Injectable as Injectable10, Inject as Inject2, Logger as Logger3 } from "@nestjs/common";
|
|
35211
35338
|
import { ObservableService, RequestContextService as RequestContextService3, PLATFORM_HTTP_CLIENT as PLATFORM_HTTP_CLIENT2, OBSERVABLE_SERVICE } from "@lark-apaas/nestjs-common";
|
|
35212
35339
|
import { FileService as FileServiceCore, FileDownloadBuilder } from "@lark-apaas/file-service";
|
|
35213
|
-
function
|
|
35340
|
+
function _ts_decorate10(decorators, target, key, desc) {
|
|
35214
35341
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
35215
35342
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
35216
35343
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
35217
35344
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
35218
35345
|
}
|
|
35219
|
-
__name(
|
|
35346
|
+
__name(_ts_decorate10, "_ts_decorate");
|
|
35220
35347
|
function _ts_metadata6(k, v) {
|
|
35221
35348
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
35222
35349
|
}
|
|
@@ -35581,8 +35708,8 @@ var FileService = class {
|
|
|
35581
35708
|
}
|
|
35582
35709
|
}
|
|
35583
35710
|
};
|
|
35584
|
-
FileService =
|
|
35585
|
-
|
|
35711
|
+
FileService = _ts_decorate10([
|
|
35712
|
+
Injectable10(),
|
|
35586
35713
|
_ts_param2(1, Inject2(PLATFORM_HTTP_CLIENT2)),
|
|
35587
35714
|
_ts_param2(2, Inject2(OBSERVABLE_SERVICE)),
|
|
35588
35715
|
_ts_metadata6("design:type", Function),
|
|
@@ -35605,13 +35732,13 @@ import { ApiExcludeController } from "@nestjs/swagger";
|
|
|
35605
35732
|
import * as fs from "fs";
|
|
35606
35733
|
import * as path from "path";
|
|
35607
35734
|
import * as crypto2 from "crypto";
|
|
35608
|
-
function
|
|
35735
|
+
function _ts_decorate11(decorators, target, key, desc) {
|
|
35609
35736
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
35610
35737
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
35611
35738
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
35612
35739
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
35613
35740
|
}
|
|
35614
|
-
__name(
|
|
35741
|
+
__name(_ts_decorate11, "_ts_decorate");
|
|
35615
35742
|
function _ts_metadata7(k, v) {
|
|
35616
35743
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
35617
35744
|
}
|
|
@@ -35764,7 +35891,7 @@ var StaticController = class _StaticController {
|
|
|
35764
35891
|
}
|
|
35765
35892
|
}
|
|
35766
35893
|
};
|
|
35767
|
-
|
|
35894
|
+
_ts_decorate11([
|
|
35768
35895
|
Get("*"),
|
|
35769
35896
|
_ts_param3(0, Param()),
|
|
35770
35897
|
_ts_param3(1, Req()),
|
|
@@ -35777,7 +35904,7 @@ _ts_decorate10([
|
|
|
35777
35904
|
]),
|
|
35778
35905
|
_ts_metadata7("design:returntype", void 0)
|
|
35779
35906
|
], StaticController.prototype, "serveFile", null);
|
|
35780
|
-
StaticController =
|
|
35907
|
+
StaticController = _ts_decorate11([
|
|
35781
35908
|
ApiExcludeController(),
|
|
35782
35909
|
Controller("static"),
|
|
35783
35910
|
_ts_metadata7("design:type", Function),
|
|
@@ -35785,19 +35912,19 @@ StaticController = _ts_decorate10([
|
|
|
35785
35912
|
], StaticController);
|
|
35786
35913
|
|
|
35787
35914
|
// src/modules/static/static.module.ts
|
|
35788
|
-
function
|
|
35915
|
+
function _ts_decorate12(decorators, target, key, desc) {
|
|
35789
35916
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
35790
35917
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
35791
35918
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
35792
35919
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
35793
35920
|
}
|
|
35794
|
-
__name(
|
|
35921
|
+
__name(_ts_decorate12, "_ts_decorate");
|
|
35795
35922
|
var StaticModule = class {
|
|
35796
35923
|
static {
|
|
35797
35924
|
__name(this, "StaticModule");
|
|
35798
35925
|
}
|
|
35799
35926
|
};
|
|
35800
|
-
StaticModule =
|
|
35927
|
+
StaticModule = _ts_decorate12([
|
|
35801
35928
|
Module({
|
|
35802
35929
|
controllers: [
|
|
35803
35930
|
StaticController
|
|
@@ -35813,7 +35940,7 @@ import { Controller as Controller2, Post, Body, HttpCode, HttpStatus as HttpStat
|
|
|
35813
35940
|
import { ApiExcludeController as ApiExcludeController2 } from "@nestjs/swagger";
|
|
35814
35941
|
|
|
35815
35942
|
// src/modules/html-hot-update/html-hot-update.service.ts
|
|
35816
|
-
import { Injectable as
|
|
35943
|
+
import { Injectable as Injectable11, Logger as Logger5, Inject as Inject3 } from "@nestjs/common";
|
|
35817
35944
|
import { promises as fs2 } from "fs";
|
|
35818
35945
|
import { existsSync as existsSync2 } from "fs";
|
|
35819
35946
|
import { createHash as createHash2 } from "crypto";
|
|
@@ -35846,13 +35973,13 @@ function setActiveHtmlVersion(version) {
|
|
|
35846
35973
|
__name(setActiveHtmlVersion, "setActiveHtmlVersion");
|
|
35847
35974
|
|
|
35848
35975
|
// src/modules/html-hot-update/html-hot-update.service.ts
|
|
35849
|
-
function
|
|
35976
|
+
function _ts_decorate13(decorators, target, key, desc) {
|
|
35850
35977
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
35851
35978
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
35852
35979
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
35853
35980
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
35854
35981
|
}
|
|
35855
|
-
__name(
|
|
35982
|
+
__name(_ts_decorate13, "_ts_decorate");
|
|
35856
35983
|
function _ts_metadata8(k, v) {
|
|
35857
35984
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
35858
35985
|
}
|
|
@@ -36097,8 +36224,8 @@ var HtmlHotUpdateService = class _HtmlHotUpdateService {
|
|
|
36097
36224
|
return "";
|
|
36098
36225
|
}
|
|
36099
36226
|
};
|
|
36100
|
-
HtmlHotUpdateService =
|
|
36101
|
-
|
|
36227
|
+
HtmlHotUpdateService = _ts_decorate13([
|
|
36228
|
+
Injectable11(),
|
|
36102
36229
|
_ts_param4(0, Inject3(PLATFORM_HTTP_CLIENT3)),
|
|
36103
36230
|
_ts_metadata8("design:type", Function),
|
|
36104
36231
|
_ts_metadata8("design:paramtypes", [
|
|
@@ -36107,13 +36234,13 @@ HtmlHotUpdateService = _ts_decorate12([
|
|
|
36107
36234
|
], HtmlHotUpdateService);
|
|
36108
36235
|
|
|
36109
36236
|
// src/modules/html-hot-update/html-hot-update.controller.ts
|
|
36110
|
-
function
|
|
36237
|
+
function _ts_decorate14(decorators, target, key, desc) {
|
|
36111
36238
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
36112
36239
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
36113
36240
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
36114
36241
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
36115
36242
|
}
|
|
36116
|
-
__name(
|
|
36243
|
+
__name(_ts_decorate14, "_ts_decorate");
|
|
36117
36244
|
function _ts_metadata9(k, v) {
|
|
36118
36245
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
36119
36246
|
}
|
|
@@ -36178,7 +36305,7 @@ var HtmlHotUpdateController = class _HtmlHotUpdateController {
|
|
|
36178
36305
|
}
|
|
36179
36306
|
}
|
|
36180
36307
|
};
|
|
36181
|
-
|
|
36308
|
+
_ts_decorate14([
|
|
36182
36309
|
Post("update_html_files"),
|
|
36183
36310
|
HttpCode(HttpStatus2.OK),
|
|
36184
36311
|
_ts_param5(0, Body()),
|
|
@@ -36188,7 +36315,7 @@ _ts_decorate13([
|
|
|
36188
36315
|
]),
|
|
36189
36316
|
_ts_metadata9("design:returntype", Promise)
|
|
36190
36317
|
], HtmlHotUpdateController.prototype, "updateHtmlFiles", null);
|
|
36191
|
-
HtmlHotUpdateController =
|
|
36318
|
+
HtmlHotUpdateController = _ts_decorate14([
|
|
36192
36319
|
ApiExcludeController2(),
|
|
36193
36320
|
Controller2("__innerapi__"),
|
|
36194
36321
|
_ts_metadata9("design:type", Function),
|
|
@@ -36198,19 +36325,19 @@ HtmlHotUpdateController = _ts_decorate13([
|
|
|
36198
36325
|
], HtmlHotUpdateController);
|
|
36199
36326
|
|
|
36200
36327
|
// src/modules/html-hot-update/html-hot-update.module.ts
|
|
36201
|
-
function
|
|
36328
|
+
function _ts_decorate15(decorators, target, key, desc) {
|
|
36202
36329
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
36203
36330
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
36204
36331
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
36205
36332
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
36206
36333
|
}
|
|
36207
|
-
__name(
|
|
36334
|
+
__name(_ts_decorate15, "_ts_decorate");
|
|
36208
36335
|
var HtmlHotUpdateModule = class {
|
|
36209
36336
|
static {
|
|
36210
36337
|
__name(this, "HtmlHotUpdateModule");
|
|
36211
36338
|
}
|
|
36212
36339
|
};
|
|
36213
|
-
HtmlHotUpdateModule =
|
|
36340
|
+
HtmlHotUpdateModule = _ts_decorate15([
|
|
36214
36341
|
Module2({
|
|
36215
36342
|
controllers: [
|
|
36216
36343
|
HtmlHotUpdateController
|
|
@@ -36225,16 +36352,16 @@ HtmlHotUpdateModule = _ts_decorate14([
|
|
|
36225
36352
|
], HtmlHotUpdateModule);
|
|
36226
36353
|
|
|
36227
36354
|
// src/middlewares/html-hot-update-view/index.ts
|
|
36228
|
-
import { Injectable as
|
|
36355
|
+
import { Injectable as Injectable12 } from "@nestjs/common";
|
|
36229
36356
|
import { existsSync as existsSync3 } from "fs";
|
|
36230
36357
|
import { join as join4 } from "path";
|
|
36231
|
-
function
|
|
36358
|
+
function _ts_decorate16(decorators, target, key, desc) {
|
|
36232
36359
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
36233
36360
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
36234
36361
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
36235
36362
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
36236
36363
|
}
|
|
36237
|
-
__name(
|
|
36364
|
+
__name(_ts_decorate16, "_ts_decorate");
|
|
36238
36365
|
var HtmlHotUpdateViewMiddleware = class {
|
|
36239
36366
|
static {
|
|
36240
36367
|
__name(this, "HtmlHotUpdateViewMiddleware");
|
|
@@ -36261,18 +36388,18 @@ var HtmlHotUpdateViewMiddleware = class {
|
|
|
36261
36388
|
next();
|
|
36262
36389
|
}
|
|
36263
36390
|
};
|
|
36264
|
-
HtmlHotUpdateViewMiddleware =
|
|
36265
|
-
|
|
36391
|
+
HtmlHotUpdateViewMiddleware = _ts_decorate16([
|
|
36392
|
+
Injectable12()
|
|
36266
36393
|
], HtmlHotUpdateViewMiddleware);
|
|
36267
36394
|
|
|
36268
36395
|
// src/modules/platform/module.ts
|
|
36269
|
-
function
|
|
36396
|
+
function _ts_decorate17(decorators, target, key, desc) {
|
|
36270
36397
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
36271
36398
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
36272
36399
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
36273
36400
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
36274
36401
|
}
|
|
36275
|
-
__name(
|
|
36402
|
+
__name(_ts_decorate17, "_ts_decorate");
|
|
36276
36403
|
var PLATFORM_MODULE_OPTIONS = /* @__PURE__ */ Symbol("PLATFORM_MODULE_OPTIONS");
|
|
36277
36404
|
var PlatformModule = class _PlatformModule {
|
|
36278
36405
|
static {
|
|
@@ -36413,16 +36540,21 @@ var PlatformModule = class _PlatformModule {
|
|
|
36413
36540
|
*/
|
|
36414
36541
|
configure(consumer) {
|
|
36415
36542
|
const options = _PlatformModule.moduleOptions;
|
|
36416
|
-
consumer.apply(apiResponseInterceptor).forRoutes("/api/*");
|
|
36543
|
+
consumer.apply(apiResponseInterceptor).forRoutes("/api/*", "/openapi/*");
|
|
36417
36544
|
if (process.env.NODE_ENV === "development") {
|
|
36418
36545
|
consumer.apply(FrameworkDebugMiddleware).forRoutes("/api/__framework__/debug");
|
|
36419
36546
|
}
|
|
36547
|
+
if (process.env.NODE_ENV !== "production") {
|
|
36548
|
+
consumer.apply(OpenApiSpecMiddleware).forRoutes("/api/__framework__/openapi-spec");
|
|
36549
|
+
}
|
|
36420
36550
|
consumer.apply(UserContextMiddleware, RequestContextMiddleware, LoggerContextMiddleware, ObservableTraceMiddleware, ...DISABLE_DATAPASS ? [] : [
|
|
36421
36551
|
SqlExecutionContextMiddleware
|
|
36422
36552
|
]).forRoutes("/*");
|
|
36423
|
-
consumer.apply(CsrfTokenMiddleware, ViewContextMiddleware, HtmlHotUpdateViewMiddleware).exclude("/api/(.*)", "/static/(.*)").forRoutes("*");
|
|
36553
|
+
consumer.apply(CsrfTokenMiddleware, ViewContextMiddleware, HtmlHotUpdateViewMiddleware).exclude("/api/(.*)", "/openapi/(.*)", "/static/(.*)").forRoutes("*");
|
|
36424
36554
|
if (options.enableCsrf !== false) {
|
|
36425
|
-
const csrfRoutes = options.csrfRoutes ||
|
|
36555
|
+
const csrfRoutes = options.csrfRoutes || [
|
|
36556
|
+
"/api/*"
|
|
36557
|
+
];
|
|
36426
36558
|
if (Array.isArray(csrfRoutes)) {
|
|
36427
36559
|
csrfRoutes.forEach((route) => {
|
|
36428
36560
|
consumer.apply(CsrfMiddleware).forRoutes(route);
|
|
@@ -36433,7 +36565,7 @@ var PlatformModule = class _PlatformModule {
|
|
|
36433
36565
|
}
|
|
36434
36566
|
}
|
|
36435
36567
|
};
|
|
36436
|
-
PlatformModule =
|
|
36568
|
+
PlatformModule = _ts_decorate17([
|
|
36437
36569
|
Global(),
|
|
36438
36570
|
Module3({})
|
|
36439
36571
|
], PlatformModule);
|
|
@@ -36511,6 +36643,9 @@ async function configureApp(app, perms = defaultPerms) {
|
|
|
36511
36643
|
console.error("[OpenAPI] OpenAPI \u751F\u6210\u5931\u8D25:", err);
|
|
36512
36644
|
}
|
|
36513
36645
|
}
|
|
36646
|
+
if (process.env.NODE_ENV !== "production") {
|
|
36647
|
+
registerOpenApiSpecEndpoint(app);
|
|
36648
|
+
}
|
|
36514
36649
|
console.log("App Started Successfully.");
|
|
36515
36650
|
}
|
|
36516
36651
|
__name(configureApp, "configureApp");
|
|
@@ -36545,7 +36680,8 @@ export {
|
|
|
36545
36680
|
UserContextMiddleware,
|
|
36546
36681
|
ViewContextMiddleware,
|
|
36547
36682
|
configureApp,
|
|
36548
|
-
createLegacyPathRedirectMiddleware
|
|
36683
|
+
createLegacyPathRedirectMiddleware,
|
|
36684
|
+
registerOpenApiSpecEndpoint
|
|
36549
36685
|
};
|
|
36550
36686
|
/*! Bundled license information:
|
|
36551
36687
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lark-apaas/fullstack-nestjs-core",
|
|
3
|
-
"version": "1.1.34-alpha.
|
|
3
|
+
"version": "1.1.34-alpha.66",
|
|
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.
|
|
48
|
+
"@lark-apaas/nestjs-datapaas": "^1.0.18",
|
|
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",
|