@lark-apaas/fullstack-nestjs-core 1.1.34-alpha.70 → 1.1.34-alpha.72
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 +300 -505
- package/dist/index.d.cts +3 -13
- package/dist/index.d.ts +3 -13
- package/dist/index.js +256 -460
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -1371,8 +1371,8 @@ var require_node = __commonJS({
|
|
|
1371
1371
|
}
|
|
1372
1372
|
break;
|
|
1373
1373
|
case "FILE":
|
|
1374
|
-
var
|
|
1375
|
-
stream2 = new
|
|
1374
|
+
var fs3 = require("fs");
|
|
1375
|
+
stream2 = new fs3.SyncWriteStream(fd2, {
|
|
1376
1376
|
autoClose: false
|
|
1377
1377
|
});
|
|
1378
1378
|
stream2._type = "fs";
|
|
@@ -14215,11 +14215,11 @@ var require_mime_types = __commonJS({
|
|
|
14215
14215
|
return exts[0];
|
|
14216
14216
|
}
|
|
14217
14217
|
__name(extension, "extension");
|
|
14218
|
-
function lookup(
|
|
14219
|
-
if (!
|
|
14218
|
+
function lookup(path2) {
|
|
14219
|
+
if (!path2 || typeof path2 !== "string") {
|
|
14220
14220
|
return false;
|
|
14221
14221
|
}
|
|
14222
|
-
var extension2 = extname2("x." +
|
|
14222
|
+
var extension2 = extname2("x." + path2).toLowerCase().substr(1);
|
|
14223
14223
|
if (!extension2) {
|
|
14224
14224
|
return false;
|
|
14225
14225
|
}
|
|
@@ -18069,8 +18069,8 @@ var require_node2 = __commonJS({
|
|
|
18069
18069
|
}
|
|
18070
18070
|
break;
|
|
18071
18071
|
case "FILE":
|
|
18072
|
-
var
|
|
18073
|
-
stream2 = new
|
|
18072
|
+
var fs3 = require("fs");
|
|
18073
|
+
stream2 = new fs3.SyncWriteStream(fd2, {
|
|
18074
18074
|
autoClose: false
|
|
18075
18075
|
});
|
|
18076
18076
|
stream2._type = "fs";
|
|
@@ -18839,8 +18839,8 @@ var require_node3 = __commonJS({
|
|
|
18839
18839
|
}
|
|
18840
18840
|
break;
|
|
18841
18841
|
case "FILE":
|
|
18842
|
-
var
|
|
18843
|
-
stream2 = new
|
|
18842
|
+
var fs3 = require("fs");
|
|
18843
|
+
stream2 = new fs3.SyncWriteStream(fd2, {
|
|
18844
18844
|
autoClose: false
|
|
18845
18845
|
});
|
|
18846
18846
|
stream2._type = "fs";
|
|
@@ -18937,7 +18937,7 @@ var require_path_to_regexp = __commonJS({
|
|
|
18937
18937
|
"use strict";
|
|
18938
18938
|
module2.exports = pathToRegexp;
|
|
18939
18939
|
var MATCHING_GROUP_REGEXP = /\\.|\((?:\?<(.*?)>)?(?!\?)/g;
|
|
18940
|
-
function pathToRegexp(
|
|
18940
|
+
function pathToRegexp(path2, keys, options) {
|
|
18941
18941
|
options = options || {};
|
|
18942
18942
|
keys = keys || [];
|
|
18943
18943
|
var strict = options.strict;
|
|
@@ -18951,8 +18951,8 @@ var require_path_to_regexp = __commonJS({
|
|
|
18951
18951
|
var pos = 0;
|
|
18952
18952
|
var backtrack = "";
|
|
18953
18953
|
var m;
|
|
18954
|
-
if (
|
|
18955
|
-
while (m = MATCHING_GROUP_REGEXP.exec(
|
|
18954
|
+
if (path2 instanceof RegExp) {
|
|
18955
|
+
while (m = MATCHING_GROUP_REGEXP.exec(path2.source)) {
|
|
18956
18956
|
if (m[0][0] === "\\") continue;
|
|
18957
18957
|
keys.push({
|
|
18958
18958
|
name: m[1] || name++,
|
|
@@ -18960,18 +18960,18 @@ var require_path_to_regexp = __commonJS({
|
|
|
18960
18960
|
offset: m.index
|
|
18961
18961
|
});
|
|
18962
18962
|
}
|
|
18963
|
-
return
|
|
18963
|
+
return path2;
|
|
18964
18964
|
}
|
|
18965
|
-
if (Array.isArray(
|
|
18966
|
-
|
|
18965
|
+
if (Array.isArray(path2)) {
|
|
18966
|
+
path2 = path2.map(function(value) {
|
|
18967
18967
|
return pathToRegexp(value, keys, options).source;
|
|
18968
18968
|
});
|
|
18969
|
-
return new RegExp(
|
|
18969
|
+
return new RegExp(path2.join("|"), flags);
|
|
18970
18970
|
}
|
|
18971
|
-
if (typeof
|
|
18971
|
+
if (typeof path2 !== "string") {
|
|
18972
18972
|
throw new TypeError("path must be a string, array of strings, or regular expression");
|
|
18973
18973
|
}
|
|
18974
|
-
|
|
18974
|
+
path2 = path2.replace(/\\.|(\/)?(\.)?:(\w+)(\(.*?\))?(\*)?(\?)?|[.*]|\/\(/g, function(match, slash, format, key, capture, star, optional, offset) {
|
|
18975
18975
|
if (match[0] === "\\") {
|
|
18976
18976
|
backtrack += match;
|
|
18977
18977
|
pos += 2;
|
|
@@ -18986,7 +18986,7 @@ var require_path_to_regexp = __commonJS({
|
|
|
18986
18986
|
if (slash || format) {
|
|
18987
18987
|
backtrack = "";
|
|
18988
18988
|
} else {
|
|
18989
|
-
backtrack +=
|
|
18989
|
+
backtrack += path2.slice(pos, offset);
|
|
18990
18990
|
}
|
|
18991
18991
|
pos = offset + match.length;
|
|
18992
18992
|
if (match === "*") {
|
|
@@ -19013,7 +19013,7 @@ var require_path_to_regexp = __commonJS({
|
|
|
19013
19013
|
extraOffset += result.length - match.length;
|
|
19014
19014
|
return result;
|
|
19015
19015
|
});
|
|
19016
|
-
while (m = MATCHING_GROUP_REGEXP.exec(
|
|
19016
|
+
while (m = MATCHING_GROUP_REGEXP.exec(path2)) {
|
|
19017
19017
|
if (m[0][0] === "\\") continue;
|
|
19018
19018
|
if (keysOffset + i === keys.length || keys[keysOffset + i].offset > m.index) {
|
|
19019
19019
|
keys.splice(keysOffset + i, 0, {
|
|
@@ -19024,13 +19024,13 @@ var require_path_to_regexp = __commonJS({
|
|
|
19024
19024
|
}
|
|
19025
19025
|
i++;
|
|
19026
19026
|
}
|
|
19027
|
-
|
|
19027
|
+
path2 += strict ? "" : path2[path2.length - 1] === "/" ? "?" : "/?";
|
|
19028
19028
|
if (end) {
|
|
19029
|
-
|
|
19030
|
-
} else if (
|
|
19031
|
-
|
|
19029
|
+
path2 += "$";
|
|
19030
|
+
} else if (path2[path2.length - 1] !== "/") {
|
|
19031
|
+
path2 += lookahead ? "(?=/|$)" : "(?:/|$)";
|
|
19032
19032
|
}
|
|
19033
|
-
return new RegExp("^" +
|
|
19033
|
+
return new RegExp("^" + path2, flags);
|
|
19034
19034
|
}
|
|
19035
19035
|
__name(pathToRegexp, "pathToRegexp");
|
|
19036
19036
|
}
|
|
@@ -19044,19 +19044,19 @@ var require_layer = __commonJS({
|
|
|
19044
19044
|
var debug = require_src3()("express:router:layer");
|
|
19045
19045
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
19046
19046
|
module2.exports = Layer;
|
|
19047
|
-
function Layer(
|
|
19047
|
+
function Layer(path2, options, fn) {
|
|
19048
19048
|
if (!(this instanceof Layer)) {
|
|
19049
|
-
return new Layer(
|
|
19049
|
+
return new Layer(path2, options, fn);
|
|
19050
19050
|
}
|
|
19051
|
-
debug("new %o",
|
|
19051
|
+
debug("new %o", path2);
|
|
19052
19052
|
var opts = options || {};
|
|
19053
19053
|
this.handle = fn;
|
|
19054
19054
|
this.name = fn.name || "<anonymous>";
|
|
19055
19055
|
this.params = void 0;
|
|
19056
19056
|
this.path = void 0;
|
|
19057
|
-
this.regexp = pathRegexp(
|
|
19058
|
-
this.regexp.fast_star =
|
|
19059
|
-
this.regexp.fast_slash =
|
|
19057
|
+
this.regexp = pathRegexp(path2, this.keys = [], opts);
|
|
19058
|
+
this.regexp.fast_star = path2 === "*";
|
|
19059
|
+
this.regexp.fast_slash = path2 === "/" && opts.end === false;
|
|
19060
19060
|
}
|
|
19061
19061
|
__name(Layer, "Layer");
|
|
19062
19062
|
Layer.prototype.handle_error = /* @__PURE__ */ __name(function handle_error(error, req, res, next) {
|
|
@@ -19081,9 +19081,9 @@ var require_layer = __commonJS({
|
|
|
19081
19081
|
next(err);
|
|
19082
19082
|
}
|
|
19083
19083
|
}, "handle");
|
|
19084
|
-
Layer.prototype.match = /* @__PURE__ */ __name(function match(
|
|
19084
|
+
Layer.prototype.match = /* @__PURE__ */ __name(function match(path2) {
|
|
19085
19085
|
var match2;
|
|
19086
|
-
if (
|
|
19086
|
+
if (path2 != null) {
|
|
19087
19087
|
if (this.regexp.fast_slash) {
|
|
19088
19088
|
this.params = {};
|
|
19089
19089
|
this.path = "";
|
|
@@ -19091,12 +19091,12 @@ var require_layer = __commonJS({
|
|
|
19091
19091
|
}
|
|
19092
19092
|
if (this.regexp.fast_star) {
|
|
19093
19093
|
this.params = {
|
|
19094
|
-
"0": decode_param(
|
|
19094
|
+
"0": decode_param(path2)
|
|
19095
19095
|
};
|
|
19096
|
-
this.path =
|
|
19096
|
+
this.path = path2;
|
|
19097
19097
|
return true;
|
|
19098
19098
|
}
|
|
19099
|
-
match2 = this.regexp.exec(
|
|
19099
|
+
match2 = this.regexp.exec(path2);
|
|
19100
19100
|
}
|
|
19101
19101
|
if (!match2) {
|
|
19102
19102
|
this.params = void 0;
|
|
@@ -19192,10 +19192,10 @@ var require_route = __commonJS({
|
|
|
19192
19192
|
var slice = Array.prototype.slice;
|
|
19193
19193
|
var toString = Object.prototype.toString;
|
|
19194
19194
|
module2.exports = Route;
|
|
19195
|
-
function Route(
|
|
19196
|
-
this.path =
|
|
19195
|
+
function Route(path2) {
|
|
19196
|
+
this.path = path2;
|
|
19197
19197
|
this.stack = [];
|
|
19198
|
-
debug("new %o",
|
|
19198
|
+
debug("new %o", path2);
|
|
19199
19199
|
this.methods = {};
|
|
19200
19200
|
}
|
|
19201
19201
|
__name(Route, "Route");
|
|
@@ -19411,8 +19411,8 @@ var require_router = __commonJS({
|
|
|
19411
19411
|
if (++sync > 100) {
|
|
19412
19412
|
return setImmediate(next, err);
|
|
19413
19413
|
}
|
|
19414
|
-
var
|
|
19415
|
-
if (
|
|
19414
|
+
var path2 = getPathname(req);
|
|
19415
|
+
if (path2 == null) {
|
|
19416
19416
|
return done(layerError);
|
|
19417
19417
|
}
|
|
19418
19418
|
var layer;
|
|
@@ -19420,7 +19420,7 @@ var require_router = __commonJS({
|
|
|
19420
19420
|
var route;
|
|
19421
19421
|
while (match !== true && idx < stack.length) {
|
|
19422
19422
|
layer = stack[idx++];
|
|
19423
|
-
match = matchLayer(layer,
|
|
19423
|
+
match = matchLayer(layer, path2);
|
|
19424
19424
|
route = layer.route;
|
|
19425
19425
|
if (typeof match !== "boolean") {
|
|
19426
19426
|
layerError = layerError || match;
|
|
@@ -19458,19 +19458,19 @@ var require_router = __commonJS({
|
|
|
19458
19458
|
} else if (route) {
|
|
19459
19459
|
layer.handle_request(req, res, next);
|
|
19460
19460
|
} else {
|
|
19461
|
-
trim_prefix(layer, layerError, layerPath,
|
|
19461
|
+
trim_prefix(layer, layerError, layerPath, path2);
|
|
19462
19462
|
}
|
|
19463
19463
|
sync = 0;
|
|
19464
19464
|
});
|
|
19465
19465
|
}
|
|
19466
19466
|
__name(next, "next");
|
|
19467
|
-
function trim_prefix(layer, layerError, layerPath,
|
|
19467
|
+
function trim_prefix(layer, layerError, layerPath, path2) {
|
|
19468
19468
|
if (layerPath.length !== 0) {
|
|
19469
|
-
if (layerPath !==
|
|
19469
|
+
if (layerPath !== path2.slice(0, layerPath.length)) {
|
|
19470
19470
|
next(layerError);
|
|
19471
19471
|
return;
|
|
19472
19472
|
}
|
|
19473
|
-
var c =
|
|
19473
|
+
var c = path2[layerPath.length];
|
|
19474
19474
|
if (c && c !== "/" && c !== ".") return next(layerError);
|
|
19475
19475
|
debug("trim prefix (%s) from url %s", layerPath, req.url);
|
|
19476
19476
|
removed = layerPath;
|
|
@@ -19551,7 +19551,7 @@ var require_router = __commonJS({
|
|
|
19551
19551
|
}, "process_params");
|
|
19552
19552
|
proto.use = /* @__PURE__ */ __name(function use(fn) {
|
|
19553
19553
|
var offset = 0;
|
|
19554
|
-
var
|
|
19554
|
+
var path2 = "/";
|
|
19555
19555
|
if (typeof fn !== "function") {
|
|
19556
19556
|
var arg = fn;
|
|
19557
19557
|
while (Array.isArray(arg) && arg.length !== 0) {
|
|
@@ -19559,7 +19559,7 @@ var require_router = __commonJS({
|
|
|
19559
19559
|
}
|
|
19560
19560
|
if (typeof arg !== "function") {
|
|
19561
19561
|
offset = 1;
|
|
19562
|
-
|
|
19562
|
+
path2 = fn;
|
|
19563
19563
|
}
|
|
19564
19564
|
}
|
|
19565
19565
|
var callbacks = flatten(slice.call(arguments, offset));
|
|
@@ -19571,8 +19571,8 @@ var require_router = __commonJS({
|
|
|
19571
19571
|
if (typeof fn !== "function") {
|
|
19572
19572
|
throw new TypeError("Router.use() requires a middleware function but got a " + gettype(fn));
|
|
19573
19573
|
}
|
|
19574
|
-
debug("use %o %s",
|
|
19575
|
-
var layer = new Layer(
|
|
19574
|
+
debug("use %o %s", path2, fn.name || "<anonymous>");
|
|
19575
|
+
var layer = new Layer(path2, {
|
|
19576
19576
|
sensitive: this.caseSensitive,
|
|
19577
19577
|
strict: false,
|
|
19578
19578
|
end: false
|
|
@@ -19582,9 +19582,9 @@ var require_router = __commonJS({
|
|
|
19582
19582
|
}
|
|
19583
19583
|
return this;
|
|
19584
19584
|
}, "use");
|
|
19585
|
-
proto.route = /* @__PURE__ */ __name(function route(
|
|
19586
|
-
var route2 = new Route(
|
|
19587
|
-
var layer = new Layer(
|
|
19585
|
+
proto.route = /* @__PURE__ */ __name(function route(path2) {
|
|
19586
|
+
var route2 = new Route(path2);
|
|
19587
|
+
var layer = new Layer(path2, {
|
|
19588
19588
|
sensitive: this.caseSensitive,
|
|
19589
19589
|
strict: this.strict,
|
|
19590
19590
|
end: true
|
|
@@ -19594,8 +19594,8 @@ var require_router = __commonJS({
|
|
|
19594
19594
|
return route2;
|
|
19595
19595
|
}, "route");
|
|
19596
19596
|
methods.concat("all").forEach(function(method) {
|
|
19597
|
-
proto[method] = function(
|
|
19598
|
-
var route = this.route(
|
|
19597
|
+
proto[method] = function(path2) {
|
|
19598
|
+
var route = this.route(path2);
|
|
19599
19599
|
route[method].apply(route, slice.call(arguments, 1));
|
|
19600
19600
|
return this;
|
|
19601
19601
|
};
|
|
@@ -19635,9 +19635,9 @@ var require_router = __commonJS({
|
|
|
19635
19635
|
return toString.call(obj).replace(objectRegExp, "$1");
|
|
19636
19636
|
}
|
|
19637
19637
|
__name(gettype, "gettype");
|
|
19638
|
-
function matchLayer(layer,
|
|
19638
|
+
function matchLayer(layer, path2) {
|
|
19639
19639
|
try {
|
|
19640
|
-
return layer.match(
|
|
19640
|
+
return layer.match(path2);
|
|
19641
19641
|
} catch (err) {
|
|
19642
19642
|
return err;
|
|
19643
19643
|
}
|
|
@@ -20633,13 +20633,13 @@ var require_view = __commonJS({
|
|
|
20633
20633
|
"../../../node_modules/express/lib/view.js"(exports2, module2) {
|
|
20634
20634
|
"use strict";
|
|
20635
20635
|
var debug = require_src3()("express:view");
|
|
20636
|
-
var
|
|
20637
|
-
var
|
|
20638
|
-
var dirname2 =
|
|
20639
|
-
var basename =
|
|
20640
|
-
var extname2 =
|
|
20641
|
-
var join5 =
|
|
20642
|
-
var resolve2 =
|
|
20636
|
+
var path2 = require("path");
|
|
20637
|
+
var fs3 = require("fs");
|
|
20638
|
+
var dirname2 = path2.dirname;
|
|
20639
|
+
var basename = path2.basename;
|
|
20640
|
+
var extname2 = path2.extname;
|
|
20641
|
+
var join5 = path2.join;
|
|
20642
|
+
var resolve2 = path2.resolve;
|
|
20643
20643
|
module2.exports = View;
|
|
20644
20644
|
function View(name, options) {
|
|
20645
20645
|
var opts = options || {};
|
|
@@ -20669,17 +20669,17 @@ var require_view = __commonJS({
|
|
|
20669
20669
|
}
|
|
20670
20670
|
__name(View, "View");
|
|
20671
20671
|
View.prototype.lookup = /* @__PURE__ */ __name(function lookup(name) {
|
|
20672
|
-
var
|
|
20672
|
+
var path3;
|
|
20673
20673
|
var roots = [].concat(this.root);
|
|
20674
20674
|
debug('lookup "%s"', name);
|
|
20675
|
-
for (var i = 0; i < roots.length && !
|
|
20675
|
+
for (var i = 0; i < roots.length && !path3; i++) {
|
|
20676
20676
|
var root = roots[i];
|
|
20677
20677
|
var loc = resolve2(root, name);
|
|
20678
20678
|
var dir = dirname2(loc);
|
|
20679
20679
|
var file = basename(loc);
|
|
20680
|
-
|
|
20680
|
+
path3 = this.resolve(dir, file);
|
|
20681
20681
|
}
|
|
20682
|
-
return
|
|
20682
|
+
return path3;
|
|
20683
20683
|
}, "lookup");
|
|
20684
20684
|
View.prototype.render = /* @__PURE__ */ __name(function render(options, callback) {
|
|
20685
20685
|
debug('render "%s"', this.path);
|
|
@@ -20687,21 +20687,21 @@ var require_view = __commonJS({
|
|
|
20687
20687
|
}, "render");
|
|
20688
20688
|
View.prototype.resolve = /* @__PURE__ */ __name(function resolve3(dir, file) {
|
|
20689
20689
|
var ext = this.ext;
|
|
20690
|
-
var
|
|
20691
|
-
var stat = tryStat(
|
|
20690
|
+
var path3 = join5(dir, file);
|
|
20691
|
+
var stat = tryStat(path3);
|
|
20692
20692
|
if (stat && stat.isFile()) {
|
|
20693
|
-
return
|
|
20693
|
+
return path3;
|
|
20694
20694
|
}
|
|
20695
|
-
|
|
20696
|
-
stat = tryStat(
|
|
20695
|
+
path3 = join5(dir, basename(file, ext), "index" + ext);
|
|
20696
|
+
stat = tryStat(path3);
|
|
20697
20697
|
if (stat && stat.isFile()) {
|
|
20698
|
-
return
|
|
20698
|
+
return path3;
|
|
20699
20699
|
}
|
|
20700
20700
|
}, "resolve");
|
|
20701
|
-
function tryStat(
|
|
20702
|
-
debug('stat "%s"',
|
|
20701
|
+
function tryStat(path3) {
|
|
20702
|
+
debug('stat "%s"', path3);
|
|
20703
20703
|
try {
|
|
20704
|
-
return
|
|
20704
|
+
return fs3.statSync(path3);
|
|
20705
20705
|
} catch (e) {
|
|
20706
20706
|
return void 0;
|
|
20707
20707
|
}
|
|
@@ -21350,8 +21350,8 @@ var require_node4 = __commonJS({
|
|
|
21350
21350
|
}
|
|
21351
21351
|
break;
|
|
21352
21352
|
case "FILE":
|
|
21353
|
-
var
|
|
21354
|
-
stream2 = new
|
|
21353
|
+
var fs3 = require("fs");
|
|
21354
|
+
stream2 = new fs3.SyncWriteStream(fd2, {
|
|
21355
21355
|
autoClose: false
|
|
21356
21356
|
});
|
|
21357
21357
|
stream2._type = "fs";
|
|
@@ -21536,8 +21536,8 @@ var require_types = __commonJS({
|
|
|
21536
21536
|
var require_mime = __commonJS({
|
|
21537
21537
|
"../../../node_modules/mime/mime.js"(exports2, module2) {
|
|
21538
21538
|
"use strict";
|
|
21539
|
-
var
|
|
21540
|
-
var
|
|
21539
|
+
var path2 = require("path");
|
|
21540
|
+
var fs3 = require("fs");
|
|
21541
21541
|
function Mime() {
|
|
21542
21542
|
this.types = /* @__PURE__ */ Object.create(null);
|
|
21543
21543
|
this.extensions = /* @__PURE__ */ Object.create(null);
|
|
@@ -21559,7 +21559,7 @@ var require_mime = __commonJS({
|
|
|
21559
21559
|
};
|
|
21560
21560
|
Mime.prototype.load = function(file) {
|
|
21561
21561
|
this._loading = file;
|
|
21562
|
-
var map = {}, content =
|
|
21562
|
+
var map = {}, content = fs3.readFileSync(file, "ascii"), lines = content.split(/[\r\n]+/);
|
|
21563
21563
|
lines.forEach(function(line) {
|
|
21564
21564
|
var fields = line.replace(/\s*#.*|^\s*|\s*$/g, "").split(/\s+/);
|
|
21565
21565
|
map[fields.shift()] = fields;
|
|
@@ -21567,8 +21567,8 @@ var require_mime = __commonJS({
|
|
|
21567
21567
|
this.define(map);
|
|
21568
21568
|
this._loading = null;
|
|
21569
21569
|
};
|
|
21570
|
-
Mime.prototype.lookup = function(
|
|
21571
|
-
var ext =
|
|
21570
|
+
Mime.prototype.lookup = function(path3, fallback) {
|
|
21571
|
+
var ext = path3.replace(/^.*[\.\/\\]/, "").toLowerCase();
|
|
21572
21572
|
return this.types[ext] || fallback || this.default_type;
|
|
21573
21573
|
};
|
|
21574
21574
|
Mime.prototype.extension = function(mimeType) {
|
|
@@ -21804,34 +21804,34 @@ var require_send = __commonJS({
|
|
|
21804
21804
|
var escapeHtml = require_escape_html();
|
|
21805
21805
|
var etag = require_etag();
|
|
21806
21806
|
var fresh = require_fresh();
|
|
21807
|
-
var
|
|
21807
|
+
var fs3 = require("fs");
|
|
21808
21808
|
var mime = require_mime();
|
|
21809
21809
|
var ms = require_ms5();
|
|
21810
21810
|
var onFinished = require_on_finished();
|
|
21811
21811
|
var parseRange = require_range_parser();
|
|
21812
|
-
var
|
|
21812
|
+
var path2 = require("path");
|
|
21813
21813
|
var statuses = require_statuses();
|
|
21814
21814
|
var Stream = require("stream");
|
|
21815
21815
|
var util = require("util");
|
|
21816
|
-
var extname2 =
|
|
21817
|
-
var join5 =
|
|
21818
|
-
var normalize2 =
|
|
21819
|
-
var resolve2 =
|
|
21820
|
-
var sep =
|
|
21816
|
+
var extname2 = path2.extname;
|
|
21817
|
+
var join5 = path2.join;
|
|
21818
|
+
var normalize2 = path2.normalize;
|
|
21819
|
+
var resolve2 = path2.resolve;
|
|
21820
|
+
var sep = path2.sep;
|
|
21821
21821
|
var BYTES_RANGE_REGEXP = /^ *bytes=/;
|
|
21822
21822
|
var MAX_MAXAGE = 60 * 60 * 24 * 365 * 1e3;
|
|
21823
21823
|
var UP_PATH_REGEXP = /(?:^|[\\/])\.\.(?:[\\/]|$)/;
|
|
21824
21824
|
module2.exports = send;
|
|
21825
21825
|
module2.exports.mime = mime;
|
|
21826
|
-
function send(req,
|
|
21827
|
-
return new SendStream(req,
|
|
21826
|
+
function send(req, path3, options) {
|
|
21827
|
+
return new SendStream(req, path3, options);
|
|
21828
21828
|
}
|
|
21829
21829
|
__name(send, "send");
|
|
21830
|
-
function SendStream(req,
|
|
21830
|
+
function SendStream(req, path3, options) {
|
|
21831
21831
|
Stream.call(this);
|
|
21832
21832
|
var opts = options || {};
|
|
21833
21833
|
this.options = opts;
|
|
21834
|
-
this.path =
|
|
21834
|
+
this.path = path3;
|
|
21835
21835
|
this.req = req;
|
|
21836
21836
|
this._acceptRanges = opts.acceptRanges !== void 0 ? Boolean(opts.acceptRanges) : true;
|
|
21837
21837
|
this._cacheControl = opts.cacheControl !== void 0 ? Boolean(opts.cacheControl) : true;
|
|
@@ -21880,8 +21880,8 @@ var require_send = __commonJS({
|
|
|
21880
21880
|
this._index = index2;
|
|
21881
21881
|
return this;
|
|
21882
21882
|
}, "index"), "send.index: pass index as option");
|
|
21883
|
-
SendStream.prototype.root = /* @__PURE__ */ __name(function root(
|
|
21884
|
-
this._root = resolve2(String(
|
|
21883
|
+
SendStream.prototype.root = /* @__PURE__ */ __name(function root(path3) {
|
|
21884
|
+
this._root = resolve2(String(path3));
|
|
21885
21885
|
debug("root %s", this._root);
|
|
21886
21886
|
return this;
|
|
21887
21887
|
}, "root");
|
|
@@ -21988,10 +21988,10 @@ var require_send = __commonJS({
|
|
|
21988
21988
|
var lastModified = this.res.getHeader("Last-Modified");
|
|
21989
21989
|
return parseHttpDate(lastModified) <= parseHttpDate(ifRange);
|
|
21990
21990
|
}, "isRangeFresh");
|
|
21991
|
-
SendStream.prototype.redirect = /* @__PURE__ */ __name(function redirect(
|
|
21991
|
+
SendStream.prototype.redirect = /* @__PURE__ */ __name(function redirect(path3) {
|
|
21992
21992
|
var res = this.res;
|
|
21993
21993
|
if (hasListeners(this, "directory")) {
|
|
21994
|
-
this.emit("directory", res,
|
|
21994
|
+
this.emit("directory", res, path3);
|
|
21995
21995
|
return;
|
|
21996
21996
|
}
|
|
21997
21997
|
if (this.hasTrailingSlash()) {
|
|
@@ -22011,42 +22011,42 @@ var require_send = __commonJS({
|
|
|
22011
22011
|
SendStream.prototype.pipe = /* @__PURE__ */ __name(function pipe(res) {
|
|
22012
22012
|
var root = this._root;
|
|
22013
22013
|
this.res = res;
|
|
22014
|
-
var
|
|
22015
|
-
if (
|
|
22014
|
+
var path3 = decode(this.path);
|
|
22015
|
+
if (path3 === -1) {
|
|
22016
22016
|
this.error(400);
|
|
22017
22017
|
return res;
|
|
22018
22018
|
}
|
|
22019
|
-
if (~
|
|
22019
|
+
if (~path3.indexOf("\0")) {
|
|
22020
22020
|
this.error(400);
|
|
22021
22021
|
return res;
|
|
22022
22022
|
}
|
|
22023
22023
|
var parts;
|
|
22024
22024
|
if (root !== null) {
|
|
22025
|
-
if (
|
|
22026
|
-
|
|
22025
|
+
if (path3) {
|
|
22026
|
+
path3 = normalize2("." + sep + path3);
|
|
22027
22027
|
}
|
|
22028
|
-
if (UP_PATH_REGEXP.test(
|
|
22029
|
-
debug('malicious path "%s"',
|
|
22028
|
+
if (UP_PATH_REGEXP.test(path3)) {
|
|
22029
|
+
debug('malicious path "%s"', path3);
|
|
22030
22030
|
this.error(403);
|
|
22031
22031
|
return res;
|
|
22032
22032
|
}
|
|
22033
|
-
parts =
|
|
22034
|
-
|
|
22033
|
+
parts = path3.split(sep);
|
|
22034
|
+
path3 = normalize2(join5(root, path3));
|
|
22035
22035
|
} else {
|
|
22036
|
-
if (UP_PATH_REGEXP.test(
|
|
22037
|
-
debug('malicious path "%s"',
|
|
22036
|
+
if (UP_PATH_REGEXP.test(path3)) {
|
|
22037
|
+
debug('malicious path "%s"', path3);
|
|
22038
22038
|
this.error(403);
|
|
22039
22039
|
return res;
|
|
22040
22040
|
}
|
|
22041
|
-
parts = normalize2(
|
|
22042
|
-
|
|
22041
|
+
parts = normalize2(path3).split(sep);
|
|
22042
|
+
path3 = resolve2(path3);
|
|
22043
22043
|
}
|
|
22044
22044
|
if (containsDotFile(parts)) {
|
|
22045
22045
|
var access = this._dotfiles;
|
|
22046
22046
|
if (access === void 0) {
|
|
22047
22047
|
access = parts[parts.length - 1][0] === "." ? this._hidden ? "allow" : "ignore" : "allow";
|
|
22048
22048
|
}
|
|
22049
|
-
debug('%s dotfile "%s"', access,
|
|
22049
|
+
debug('%s dotfile "%s"', access, path3);
|
|
22050
22050
|
switch (access) {
|
|
22051
22051
|
case "allow":
|
|
22052
22052
|
break;
|
|
@@ -22060,13 +22060,13 @@ var require_send = __commonJS({
|
|
|
22060
22060
|
}
|
|
22061
22061
|
}
|
|
22062
22062
|
if (this._index.length && this.hasTrailingSlash()) {
|
|
22063
|
-
this.sendIndex(
|
|
22063
|
+
this.sendIndex(path3);
|
|
22064
22064
|
return res;
|
|
22065
22065
|
}
|
|
22066
|
-
this.sendFile(
|
|
22066
|
+
this.sendFile(path3);
|
|
22067
22067
|
return res;
|
|
22068
22068
|
}, "pipe");
|
|
22069
|
-
SendStream.prototype.send = /* @__PURE__ */ __name(function send2(
|
|
22069
|
+
SendStream.prototype.send = /* @__PURE__ */ __name(function send2(path3, stat) {
|
|
22070
22070
|
var len = stat.size;
|
|
22071
22071
|
var options = this.options;
|
|
22072
22072
|
var opts = {};
|
|
@@ -22078,9 +22078,9 @@ var require_send = __commonJS({
|
|
|
22078
22078
|
this.headersAlreadySent();
|
|
22079
22079
|
return;
|
|
22080
22080
|
}
|
|
22081
|
-
debug('pipe "%s"',
|
|
22082
|
-
this.setHeader(
|
|
22083
|
-
this.type(
|
|
22081
|
+
debug('pipe "%s"', path3);
|
|
22082
|
+
this.setHeader(path3, stat);
|
|
22083
|
+
this.type(path3);
|
|
22084
22084
|
if (this.isConditionalGET()) {
|
|
22085
22085
|
if (this.isPreconditionFailure()) {
|
|
22086
22086
|
this.error(412);
|
|
@@ -22131,28 +22131,28 @@ var require_send = __commonJS({
|
|
|
22131
22131
|
res.end();
|
|
22132
22132
|
return;
|
|
22133
22133
|
}
|
|
22134
|
-
this.stream(
|
|
22134
|
+
this.stream(path3, opts);
|
|
22135
22135
|
}, "send");
|
|
22136
|
-
SendStream.prototype.sendFile = /* @__PURE__ */ __name(function sendFile(
|
|
22136
|
+
SendStream.prototype.sendFile = /* @__PURE__ */ __name(function sendFile(path3) {
|
|
22137
22137
|
var i = 0;
|
|
22138
22138
|
var self = this;
|
|
22139
|
-
debug('stat "%s"',
|
|
22140
|
-
|
|
22141
|
-
if (err && err.code === "ENOENT" && !extname2(
|
|
22139
|
+
debug('stat "%s"', path3);
|
|
22140
|
+
fs3.stat(path3, /* @__PURE__ */ __name(function onstat(err, stat) {
|
|
22141
|
+
if (err && err.code === "ENOENT" && !extname2(path3) && path3[path3.length - 1] !== sep) {
|
|
22142
22142
|
return next(err);
|
|
22143
22143
|
}
|
|
22144
22144
|
if (err) return self.onStatError(err);
|
|
22145
|
-
if (stat.isDirectory()) return self.redirect(
|
|
22146
|
-
self.emit("file",
|
|
22147
|
-
self.send(
|
|
22145
|
+
if (stat.isDirectory()) return self.redirect(path3);
|
|
22146
|
+
self.emit("file", path3, stat);
|
|
22147
|
+
self.send(path3, stat);
|
|
22148
22148
|
}, "onstat"));
|
|
22149
22149
|
function next(err) {
|
|
22150
22150
|
if (self._extensions.length <= i) {
|
|
22151
22151
|
return err ? self.onStatError(err) : self.error(404);
|
|
22152
22152
|
}
|
|
22153
|
-
var p =
|
|
22153
|
+
var p = path3 + "." + self._extensions[i++];
|
|
22154
22154
|
debug('stat "%s"', p);
|
|
22155
|
-
|
|
22155
|
+
fs3.stat(p, function(err2, stat) {
|
|
22156
22156
|
if (err2) return next(err2);
|
|
22157
22157
|
if (stat.isDirectory()) return next();
|
|
22158
22158
|
self.emit("file", p, stat);
|
|
@@ -22161,7 +22161,7 @@ var require_send = __commonJS({
|
|
|
22161
22161
|
}
|
|
22162
22162
|
__name(next, "next");
|
|
22163
22163
|
}, "sendFile");
|
|
22164
|
-
SendStream.prototype.sendIndex = /* @__PURE__ */ __name(function sendIndex(
|
|
22164
|
+
SendStream.prototype.sendIndex = /* @__PURE__ */ __name(function sendIndex(path3) {
|
|
22165
22165
|
var i = -1;
|
|
22166
22166
|
var self = this;
|
|
22167
22167
|
function next(err) {
|
|
@@ -22169,9 +22169,9 @@ var require_send = __commonJS({
|
|
|
22169
22169
|
if (err) return self.onStatError(err);
|
|
22170
22170
|
return self.error(404);
|
|
22171
22171
|
}
|
|
22172
|
-
var p = join5(
|
|
22172
|
+
var p = join5(path3, self._index[i]);
|
|
22173
22173
|
debug('stat "%s"', p);
|
|
22174
|
-
|
|
22174
|
+
fs3.stat(p, function(err2, stat) {
|
|
22175
22175
|
if (err2) return next(err2);
|
|
22176
22176
|
if (stat.isDirectory()) return next();
|
|
22177
22177
|
self.emit("file", p, stat);
|
|
@@ -22181,10 +22181,10 @@ var require_send = __commonJS({
|
|
|
22181
22181
|
__name(next, "next");
|
|
22182
22182
|
next();
|
|
22183
22183
|
}, "sendIndex");
|
|
22184
|
-
SendStream.prototype.stream = /* @__PURE__ */ __name(function stream(
|
|
22184
|
+
SendStream.prototype.stream = /* @__PURE__ */ __name(function stream(path3, options) {
|
|
22185
22185
|
var self = this;
|
|
22186
22186
|
var res = this.res;
|
|
22187
|
-
var stream2 =
|
|
22187
|
+
var stream2 = fs3.createReadStream(path3, options);
|
|
22188
22188
|
this.emit("stream", stream2);
|
|
22189
22189
|
stream2.pipe(res);
|
|
22190
22190
|
function cleanup() {
|
|
@@ -22200,10 +22200,10 @@ var require_send = __commonJS({
|
|
|
22200
22200
|
self.emit("end");
|
|
22201
22201
|
}, "onend"));
|
|
22202
22202
|
}, "stream");
|
|
22203
|
-
SendStream.prototype.type = /* @__PURE__ */ __name(function type(
|
|
22203
|
+
SendStream.prototype.type = /* @__PURE__ */ __name(function type(path3) {
|
|
22204
22204
|
var res = this.res;
|
|
22205
22205
|
if (res.getHeader("Content-Type")) return;
|
|
22206
|
-
var type2 = mime.lookup(
|
|
22206
|
+
var type2 = mime.lookup(path3);
|
|
22207
22207
|
if (!type2) {
|
|
22208
22208
|
debug("no content-type");
|
|
22209
22209
|
return;
|
|
@@ -22212,9 +22212,9 @@ var require_send = __commonJS({
|
|
|
22212
22212
|
debug("content-type %s", type2);
|
|
22213
22213
|
res.setHeader("Content-Type", type2 + (charset ? "; charset=" + charset : ""));
|
|
22214
22214
|
}, "type");
|
|
22215
|
-
SendStream.prototype.setHeader = /* @__PURE__ */ __name(function setHeader(
|
|
22215
|
+
SendStream.prototype.setHeader = /* @__PURE__ */ __name(function setHeader(path3, stat) {
|
|
22216
22216
|
var res = this.res;
|
|
22217
|
-
this.emit("headers", res,
|
|
22217
|
+
this.emit("headers", res, path3, stat);
|
|
22218
22218
|
if (this._acceptRanges && !res.getHeader("Accept-Ranges")) {
|
|
22219
22219
|
debug("accept ranges");
|
|
22220
22220
|
res.setHeader("Accept-Ranges", "bytes");
|
|
@@ -22281,9 +22281,9 @@ var require_send = __commonJS({
|
|
|
22281
22281
|
}) : createError(status, err);
|
|
22282
22282
|
}
|
|
22283
22283
|
__name(createHttpError, "createHttpError");
|
|
22284
|
-
function decode(
|
|
22284
|
+
function decode(path3) {
|
|
22285
22285
|
try {
|
|
22286
|
-
return decodeURIComponent(
|
|
22286
|
+
return decodeURIComponent(path3);
|
|
22287
22287
|
} catch (err) {
|
|
22288
22288
|
return -1;
|
|
22289
22289
|
}
|
|
@@ -23541,10 +23541,10 @@ var require_utils3 = __commonJS({
|
|
|
23541
23541
|
exports2.wetag = createETagGenerator({
|
|
23542
23542
|
weak: true
|
|
23543
23543
|
});
|
|
23544
|
-
exports2.isAbsolute = function(
|
|
23545
|
-
if ("/" ===
|
|
23546
|
-
if (":" ===
|
|
23547
|
-
if ("\\\\" ===
|
|
23544
|
+
exports2.isAbsolute = function(path2) {
|
|
23545
|
+
if ("/" === path2[0]) return true;
|
|
23546
|
+
if (":" === path2[1] && ("\\" === path2[2] || "/" === path2[2])) return true;
|
|
23547
|
+
if ("\\\\" === path2.substring(0, 2)) return true;
|
|
23548
23548
|
};
|
|
23549
23549
|
exports2.flatten = deprecate.function(flatten, "utils.flatten: use array-flatten npm module instead");
|
|
23550
23550
|
exports2.normalizeType = function(type) {
|
|
@@ -23760,7 +23760,7 @@ var require_application = __commonJS({
|
|
|
23760
23760
|
}, "handle");
|
|
23761
23761
|
app.use = /* @__PURE__ */ __name(function use(fn) {
|
|
23762
23762
|
var offset = 0;
|
|
23763
|
-
var
|
|
23763
|
+
var path2 = "/";
|
|
23764
23764
|
if (typeof fn !== "function") {
|
|
23765
23765
|
var arg = fn;
|
|
23766
23766
|
while (Array.isArray(arg) && arg.length !== 0) {
|
|
@@ -23768,7 +23768,7 @@ var require_application = __commonJS({
|
|
|
23768
23768
|
}
|
|
23769
23769
|
if (typeof arg !== "function") {
|
|
23770
23770
|
offset = 1;
|
|
23771
|
-
|
|
23771
|
+
path2 = fn;
|
|
23772
23772
|
}
|
|
23773
23773
|
}
|
|
23774
23774
|
var fns = flatten(slice.call(arguments, offset));
|
|
@@ -23779,12 +23779,12 @@ var require_application = __commonJS({
|
|
|
23779
23779
|
var router = this._router;
|
|
23780
23780
|
fns.forEach(function(fn2) {
|
|
23781
23781
|
if (!fn2 || !fn2.handle || !fn2.set) {
|
|
23782
|
-
return router.use(
|
|
23782
|
+
return router.use(path2, fn2);
|
|
23783
23783
|
}
|
|
23784
|
-
debug(".use app under %s",
|
|
23785
|
-
fn2.mountpath =
|
|
23784
|
+
debug(".use app under %s", path2);
|
|
23785
|
+
fn2.mountpath = path2;
|
|
23786
23786
|
fn2.parent = this;
|
|
23787
|
-
router.use(
|
|
23787
|
+
router.use(path2, /* @__PURE__ */ __name(function mounted_app(req, res, next) {
|
|
23788
23788
|
var orig = req.app;
|
|
23789
23789
|
fn2.handle(req, res, function(err) {
|
|
23790
23790
|
setPrototypeOf(req, orig.request);
|
|
@@ -23796,9 +23796,9 @@ var require_application = __commonJS({
|
|
|
23796
23796
|
}, this);
|
|
23797
23797
|
return this;
|
|
23798
23798
|
}, "use");
|
|
23799
|
-
app.route = /* @__PURE__ */ __name(function route(
|
|
23799
|
+
app.route = /* @__PURE__ */ __name(function route(path2) {
|
|
23800
23800
|
this.lazyrouter();
|
|
23801
|
-
return this._router.route(
|
|
23801
|
+
return this._router.route(path2);
|
|
23802
23802
|
}, "route");
|
|
23803
23803
|
app.engine = /* @__PURE__ */ __name(function engine(ext, fn) {
|
|
23804
23804
|
if (typeof fn !== "function") {
|
|
@@ -23849,7 +23849,7 @@ var require_application = __commonJS({
|
|
|
23849
23849
|
}
|
|
23850
23850
|
return this;
|
|
23851
23851
|
}, "set");
|
|
23852
|
-
app.path = /* @__PURE__ */ __name(function
|
|
23852
|
+
app.path = /* @__PURE__ */ __name(function path2() {
|
|
23853
23853
|
return this.parent ? this.parent.path() + this.mountpath : "";
|
|
23854
23854
|
}, "path");
|
|
23855
23855
|
app.enabled = /* @__PURE__ */ __name(function enabled(setting) {
|
|
@@ -23865,19 +23865,19 @@ var require_application = __commonJS({
|
|
|
23865
23865
|
return this.set(setting, false);
|
|
23866
23866
|
}, "disable");
|
|
23867
23867
|
methods.forEach(function(method) {
|
|
23868
|
-
app[method] = function(
|
|
23868
|
+
app[method] = function(path2) {
|
|
23869
23869
|
if (method === "get" && arguments.length === 1) {
|
|
23870
|
-
return this.set(
|
|
23870
|
+
return this.set(path2);
|
|
23871
23871
|
}
|
|
23872
23872
|
this.lazyrouter();
|
|
23873
|
-
var route = this._router.route(
|
|
23873
|
+
var route = this._router.route(path2);
|
|
23874
23874
|
route[method].apply(route, slice.call(arguments, 1));
|
|
23875
23875
|
return this;
|
|
23876
23876
|
};
|
|
23877
23877
|
});
|
|
23878
|
-
app.all = /* @__PURE__ */ __name(function all(
|
|
23878
|
+
app.all = /* @__PURE__ */ __name(function all(path2) {
|
|
23879
23879
|
this.lazyrouter();
|
|
23880
|
-
var route = this._router.route(
|
|
23880
|
+
var route = this._router.route(path2);
|
|
23881
23881
|
var args = slice.call(arguments, 1);
|
|
23882
23882
|
for (var i = 0; i < methods.length; i++) {
|
|
23883
23883
|
route[methods[i]].apply(route, args);
|
|
@@ -33091,11 +33091,11 @@ var require_mime_types2 = __commonJS({
|
|
|
33091
33091
|
return exts[0];
|
|
33092
33092
|
}
|
|
33093
33093
|
__name(extension, "extension");
|
|
33094
|
-
function lookup(
|
|
33095
|
-
if (!
|
|
33094
|
+
function lookup(path2) {
|
|
33095
|
+
if (!path2 || typeof path2 !== "string") {
|
|
33096
33096
|
return false;
|
|
33097
33097
|
}
|
|
33098
|
-
var extension2 = extname2("x." +
|
|
33098
|
+
var extension2 = extname2("x." + path2).toLowerCase().substr(1);
|
|
33099
33099
|
if (!extension2) {
|
|
33100
33100
|
return false;
|
|
33101
33101
|
}
|
|
@@ -33325,7 +33325,7 @@ var require_request = __commonJS({
|
|
|
33325
33325
|
];
|
|
33326
33326
|
return subdomains2.slice(offset);
|
|
33327
33327
|
}, "subdomains"));
|
|
33328
|
-
defineGetter(req, "path", /* @__PURE__ */ __name(function
|
|
33328
|
+
defineGetter(req, "path", /* @__PURE__ */ __name(function path2() {
|
|
33329
33329
|
return parse(this).pathname;
|
|
33330
33330
|
}, "path"));
|
|
33331
33331
|
defineGetter(req, "hostname", /* @__PURE__ */ __name(function hostname() {
|
|
@@ -33660,7 +33660,7 @@ var require_response = __commonJS({
|
|
|
33660
33660
|
var http = require("http");
|
|
33661
33661
|
var isAbsolute = require_utils3().isAbsolute;
|
|
33662
33662
|
var onFinished = require_on_finished();
|
|
33663
|
-
var
|
|
33663
|
+
var path2 = require("path");
|
|
33664
33664
|
var statuses = require_statuses();
|
|
33665
33665
|
var merge = require_utils_merge();
|
|
33666
33666
|
var sign = require_cookie_signature().sign;
|
|
@@ -33669,9 +33669,9 @@ var require_response = __commonJS({
|
|
|
33669
33669
|
var setCharset = require_utils3().setCharset;
|
|
33670
33670
|
var cookie = require_cookie();
|
|
33671
33671
|
var send = require_send();
|
|
33672
|
-
var extname2 =
|
|
33672
|
+
var extname2 = path2.extname;
|
|
33673
33673
|
var mime = send.mime;
|
|
33674
|
-
var resolve2 =
|
|
33674
|
+
var resolve2 = path2.resolve;
|
|
33675
33675
|
var vary = require_vary();
|
|
33676
33676
|
var res = Object.create(http.ServerResponse.prototype);
|
|
33677
33677
|
module2.exports = res;
|
|
@@ -33848,26 +33848,26 @@ var require_response = __commonJS({
|
|
|
33848
33848
|
this.type("txt");
|
|
33849
33849
|
return this.send(body);
|
|
33850
33850
|
}, "sendStatus");
|
|
33851
|
-
res.sendFile = /* @__PURE__ */ __name(function sendFile(
|
|
33851
|
+
res.sendFile = /* @__PURE__ */ __name(function sendFile(path3, options, callback) {
|
|
33852
33852
|
var done = callback;
|
|
33853
33853
|
var req = this.req;
|
|
33854
33854
|
var res2 = this;
|
|
33855
33855
|
var next = req.next;
|
|
33856
33856
|
var opts = options || {};
|
|
33857
|
-
if (!
|
|
33857
|
+
if (!path3) {
|
|
33858
33858
|
throw new TypeError("path argument is required to res.sendFile");
|
|
33859
33859
|
}
|
|
33860
|
-
if (typeof
|
|
33860
|
+
if (typeof path3 !== "string") {
|
|
33861
33861
|
throw new TypeError("path must be a string to res.sendFile");
|
|
33862
33862
|
}
|
|
33863
33863
|
if (typeof options === "function") {
|
|
33864
33864
|
done = options;
|
|
33865
33865
|
opts = {};
|
|
33866
33866
|
}
|
|
33867
|
-
if (!opts.root && !isAbsolute(
|
|
33867
|
+
if (!opts.root && !isAbsolute(path3)) {
|
|
33868
33868
|
throw new TypeError("path must be absolute or specify root to res.sendFile");
|
|
33869
33869
|
}
|
|
33870
|
-
var pathname = encodeURI(
|
|
33870
|
+
var pathname = encodeURI(path3);
|
|
33871
33871
|
var file = send(req, pathname, opts);
|
|
33872
33872
|
sendfile(res2, file, opts, function(err) {
|
|
33873
33873
|
if (done) return done(err);
|
|
@@ -33877,7 +33877,7 @@ var require_response = __commonJS({
|
|
|
33877
33877
|
}
|
|
33878
33878
|
});
|
|
33879
33879
|
}, "sendFile");
|
|
33880
|
-
res.sendfile = function(
|
|
33880
|
+
res.sendfile = function(path3, options, callback) {
|
|
33881
33881
|
var done = callback;
|
|
33882
33882
|
var req = this.req;
|
|
33883
33883
|
var res2 = this;
|
|
@@ -33887,7 +33887,7 @@ var require_response = __commonJS({
|
|
|
33887
33887
|
done = options;
|
|
33888
33888
|
opts = {};
|
|
33889
33889
|
}
|
|
33890
|
-
var file = send(req,
|
|
33890
|
+
var file = send(req, path3, opts);
|
|
33891
33891
|
sendfile(res2, file, opts, function(err) {
|
|
33892
33892
|
if (done) return done(err);
|
|
33893
33893
|
if (err && err.code === "EISDIR") return next();
|
|
@@ -33897,7 +33897,7 @@ var require_response = __commonJS({
|
|
|
33897
33897
|
});
|
|
33898
33898
|
};
|
|
33899
33899
|
res.sendfile = deprecate.function(res.sendfile, "res.sendfile: Use res.sendFile instead");
|
|
33900
|
-
res.download = /* @__PURE__ */ __name(function download(
|
|
33900
|
+
res.download = /* @__PURE__ */ __name(function download(path3, filename, options, callback) {
|
|
33901
33901
|
var done = callback;
|
|
33902
33902
|
var name = filename;
|
|
33903
33903
|
var opts = options || null;
|
|
@@ -33914,7 +33914,7 @@ var require_response = __commonJS({
|
|
|
33914
33914
|
opts = filename;
|
|
33915
33915
|
}
|
|
33916
33916
|
var headers = {
|
|
33917
|
-
"Content-Disposition": contentDisposition(name ||
|
|
33917
|
+
"Content-Disposition": contentDisposition(name || path3)
|
|
33918
33918
|
};
|
|
33919
33919
|
if (opts && opts.headers) {
|
|
33920
33920
|
var keys = Object.keys(opts.headers);
|
|
@@ -33927,7 +33927,7 @@ var require_response = __commonJS({
|
|
|
33927
33927
|
}
|
|
33928
33928
|
opts = Object.create(opts);
|
|
33929
33929
|
opts.headers = headers;
|
|
33930
|
-
var fullPath = !opts.root ? resolve2(
|
|
33930
|
+
var fullPath = !opts.root ? resolve2(path3) : path3;
|
|
33931
33931
|
return this.sendFile(fullPath, opts, done);
|
|
33932
33932
|
}, "download");
|
|
33933
33933
|
res.contentType = res.type = /* @__PURE__ */ __name(function contentType(type) {
|
|
@@ -34245,11 +34245,11 @@ var require_serve_static = __commonJS({
|
|
|
34245
34245
|
}
|
|
34246
34246
|
var forwardError = !fallthrough;
|
|
34247
34247
|
var originalUrl = parseUrl.original(req);
|
|
34248
|
-
var
|
|
34249
|
-
if (
|
|
34250
|
-
|
|
34248
|
+
var path2 = parseUrl(req).pathname;
|
|
34249
|
+
if (path2 === "/" && originalUrl.pathname.substr(-1) !== "/") {
|
|
34250
|
+
path2 = "";
|
|
34251
34251
|
}
|
|
34252
|
-
var stream = send(req,
|
|
34252
|
+
var stream = send(req, path2, opts);
|
|
34253
34253
|
stream.on("directory", onDirectory);
|
|
34254
34254
|
if (setHeaders) {
|
|
34255
34255
|
stream.on("headers", setHeaders);
|
|
@@ -34423,13 +34423,12 @@ __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
|
|
|
34431
34430
|
// src/modules/platform/module.ts
|
|
34432
|
-
var
|
|
34431
|
+
var import_common16 = require("@nestjs/common");
|
|
34433
34432
|
var import_core2 = require("@nestjs/core");
|
|
34434
34433
|
var import_nestjs_common6 = require("@lark-apaas/nestjs-common");
|
|
34435
34434
|
var import_config2 = require("@nestjs/config");
|
|
@@ -34628,31 +34627,32 @@ var ViewContextMiddleware = class _ViewContextMiddleware {
|
|
|
34628
34627
|
constructor(client) {
|
|
34629
34628
|
this.client = client;
|
|
34630
34629
|
}
|
|
34631
|
-
async
|
|
34630
|
+
async getAppPublished(appId) {
|
|
34632
34631
|
if (!appId) {
|
|
34633
|
-
this.logger.warn(`appId is empty, skip get app
|
|
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
|
|
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
|
|
34642
|
+
throw new Error(`Failed to get app published, status_code: ${data.status_code}`);
|
|
34644
34643
|
}
|
|
34645
|
-
return data.data
|
|
34644
|
+
return data.data ?? null;
|
|
34646
34645
|
} catch (err) {
|
|
34647
|
-
this.logger.error(err, "Failed to get app
|
|
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 ?? {},
|
|
@@ -34824,7 +34826,7 @@ var RequestContextMiddleware = class {
|
|
|
34824
34826
|
this.requestContext = requestContext;
|
|
34825
34827
|
}
|
|
34826
34828
|
use(req, _res, next) {
|
|
34827
|
-
const
|
|
34829
|
+
const path2 = req.originalUrl ?? req.url;
|
|
34828
34830
|
const userContext = req.userContext ?? {};
|
|
34829
34831
|
const ttEnv = req.headers["x-tt-env"];
|
|
34830
34832
|
const rawPageRoute = req.get("X-Page-Route");
|
|
@@ -34832,7 +34834,7 @@ var RequestContextMiddleware = class {
|
|
|
34832
34834
|
const refererPath = req.headers["rpc-persist-apaas-observability-referer-path"];
|
|
34833
34835
|
const observabilityApi = req.headers["rpc-persist-apaas-observability-api"];
|
|
34834
34836
|
this.requestContext.run({
|
|
34835
|
-
path:
|
|
34837
|
+
path: path2,
|
|
34836
34838
|
method: req.method,
|
|
34837
34839
|
userId: userContext.userId,
|
|
34838
34840
|
tenantId: userContext.tenantId,
|
|
@@ -35021,214 +35023,17 @@ FrameworkDebugMiddleware = _ts_decorate7([
|
|
|
35021
35023
|
])
|
|
35022
35024
|
], FrameworkDebugMiddleware);
|
|
35023
35025
|
|
|
35024
|
-
// src/middlewares/openapi-spec/index.ts
|
|
35025
|
-
var import_node_fs = __toESM(require("fs"), 1);
|
|
35026
|
-
var import_swagger = require("@nestjs/swagger");
|
|
35027
|
-
var import_common8 = require("@nestjs/common");
|
|
35028
|
-
function _ts_decorate8(decorators, target, key, desc) {
|
|
35029
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
35030
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
35031
|
-
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;
|
|
35032
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
35033
|
-
}
|
|
35034
|
-
__name(_ts_decorate8, "_ts_decorate");
|
|
35035
|
-
var _app = null;
|
|
35036
|
-
var _openapiFile = null;
|
|
35037
|
-
var _specCache = null;
|
|
35038
|
-
var _fallbackCache = null;
|
|
35039
|
-
function registerOpenApiSpecEndpoint(app, options) {
|
|
35040
|
-
const globalPrefix = (process.env.CLIENT_BASE_PATH ?? "").replace(/\/+$/, "");
|
|
35041
|
-
_app = app;
|
|
35042
|
-
_openapiFile = options.openapiFile;
|
|
35043
|
-
console.log(`[OpenAPI] Registered GET ${globalPrefix}/api/__framework__/openapi-spec (source: ${_openapiFile})`);
|
|
35044
|
-
}
|
|
35045
|
-
__name(registerOpenApiSpecEndpoint, "registerOpenApiSpecEndpoint");
|
|
35046
|
-
var OpenApiSpecMiddleware = class {
|
|
35047
|
-
static {
|
|
35048
|
-
__name(this, "OpenApiSpecMiddleware");
|
|
35049
|
-
}
|
|
35050
|
-
use(_req, res, next) {
|
|
35051
|
-
if (!_app) {
|
|
35052
|
-
next();
|
|
35053
|
-
return;
|
|
35054
|
-
}
|
|
35055
|
-
try {
|
|
35056
|
-
const fromFile = loadSpecFromFile(_openapiFile);
|
|
35057
|
-
if (fromFile) {
|
|
35058
|
-
res.json(fromFile);
|
|
35059
|
-
return;
|
|
35060
|
-
}
|
|
35061
|
-
const fallback = loadFallbackSpec(_app);
|
|
35062
|
-
res.json(fallback);
|
|
35063
|
-
} catch (err) {
|
|
35064
|
-
console.error("[openapi-spec] Failed to generate spec:", err);
|
|
35065
|
-
res.json({
|
|
35066
|
-
openapi: "3.0.0",
|
|
35067
|
-
paths: {},
|
|
35068
|
-
components: {
|
|
35069
|
-
schemas: {}
|
|
35070
|
-
}
|
|
35071
|
-
});
|
|
35072
|
-
}
|
|
35073
|
-
}
|
|
35074
|
-
};
|
|
35075
|
-
OpenApiSpecMiddleware = _ts_decorate8([
|
|
35076
|
-
(0, import_common8.Injectable)()
|
|
35077
|
-
], OpenApiSpecMiddleware);
|
|
35078
|
-
function loadSpecFromFile(file) {
|
|
35079
|
-
if (!file) return null;
|
|
35080
|
-
let statBefore;
|
|
35081
|
-
try {
|
|
35082
|
-
statBefore = import_node_fs.default.statSync(file);
|
|
35083
|
-
} catch {
|
|
35084
|
-
return null;
|
|
35085
|
-
}
|
|
35086
|
-
const sig = `${file}:${statBefore.mtimeMs}:${statBefore.size}`;
|
|
35087
|
-
if (_specCache && _specCache.sig === sig) {
|
|
35088
|
-
return _specCache.spec;
|
|
35089
|
-
}
|
|
35090
|
-
let raw;
|
|
35091
|
-
try {
|
|
35092
|
-
raw = import_node_fs.default.readFileSync(file, "utf8");
|
|
35093
|
-
} catch (err) {
|
|
35094
|
-
console.warn(`[openapi-spec] ${file} read failed: ${err.message}, falling back`);
|
|
35095
|
-
return null;
|
|
35096
|
-
}
|
|
35097
|
-
let statAfter;
|
|
35098
|
-
try {
|
|
35099
|
-
statAfter = import_node_fs.default.statSync(file);
|
|
35100
|
-
} catch {
|
|
35101
|
-
return null;
|
|
35102
|
-
}
|
|
35103
|
-
const raced = statAfter.mtimeMs !== statBefore.mtimeMs || statAfter.size !== statBefore.size;
|
|
35104
|
-
const spec = parseOpenApiSpec(file, raw);
|
|
35105
|
-
if (!spec) return null;
|
|
35106
|
-
if (!raced) {
|
|
35107
|
-
_specCache = {
|
|
35108
|
-
spec,
|
|
35109
|
-
sig
|
|
35110
|
-
};
|
|
35111
|
-
}
|
|
35112
|
-
return spec;
|
|
35113
|
-
}
|
|
35114
|
-
__name(loadSpecFromFile, "loadSpecFromFile");
|
|
35115
|
-
function parseOpenApiSpec(file, raw) {
|
|
35116
|
-
let parsed;
|
|
35117
|
-
try {
|
|
35118
|
-
parsed = JSON.parse(raw);
|
|
35119
|
-
} catch (err) {
|
|
35120
|
-
console.warn(`[openapi-spec] ${file} invalid: ${err.message}, falling back`);
|
|
35121
|
-
return null;
|
|
35122
|
-
}
|
|
35123
|
-
if (!parsed || typeof parsed !== "object" || !parsed.paths || typeof parsed.paths !== "object") {
|
|
35124
|
-
console.warn(`[openapi-spec] ${file} missing "paths", falling back`);
|
|
35125
|
-
return null;
|
|
35126
|
-
}
|
|
35127
|
-
return {
|
|
35128
|
-
openapi: "3.0.0",
|
|
35129
|
-
info: {
|
|
35130
|
-
title: "OpenAPI Spec",
|
|
35131
|
-
version: "1.0.0"
|
|
35132
|
-
},
|
|
35133
|
-
paths: parsed.paths
|
|
35134
|
-
};
|
|
35135
|
-
}
|
|
35136
|
-
__name(parseOpenApiSpec, "parseOpenApiSpec");
|
|
35137
|
-
function loadFallbackSpec(app) {
|
|
35138
|
-
if (_fallbackCache) return _fallbackCache;
|
|
35139
|
-
const globalPrefix = (process.env.CLIENT_BASE_PATH ?? "").replace(/\/+$/, "");
|
|
35140
|
-
const config = new import_swagger.DocumentBuilder().setTitle("OpenAPI Spec").setVersion("1.0").build();
|
|
35141
|
-
const spec = import_swagger.SwaggerModule.createDocument(app, config);
|
|
35142
|
-
console.warn("[openapi-spec] docs/openapi.json not available, falling back to SwaggerModule.createDocument(). Populate docs/openapi.json to use the static-first path.");
|
|
35143
|
-
_fallbackCache = buildFilteredSpec(spec, globalPrefix);
|
|
35144
|
-
return _fallbackCache;
|
|
35145
|
-
}
|
|
35146
|
-
__name(loadFallbackSpec, "loadFallbackSpec");
|
|
35147
|
-
function buildFilteredSpec(spec, globalPrefix) {
|
|
35148
|
-
const schemas = spec.components?.schemas ?? {};
|
|
35149
|
-
const paths = spec.paths ?? {};
|
|
35150
|
-
const filteredPaths = {};
|
|
35151
|
-
for (const [pathKey, methods] of Object.entries(paths)) {
|
|
35152
|
-
const cleanPath = stripPrefix(pathKey, globalPrefix);
|
|
35153
|
-
if (!cleanPath.startsWith("/openapi")) continue;
|
|
35154
|
-
filteredPaths[cleanPath] = {};
|
|
35155
|
-
for (const [method, operation] of Object.entries(methods)) {
|
|
35156
|
-
if ([
|
|
35157
|
-
"parameters",
|
|
35158
|
-
"summary",
|
|
35159
|
-
"description",
|
|
35160
|
-
"servers"
|
|
35161
|
-
].includes(method)) continue;
|
|
35162
|
-
filteredPaths[cleanPath][method] = resolveRefsDeep(structuredClone(operation), schemas);
|
|
35163
|
-
}
|
|
35164
|
-
}
|
|
35165
|
-
return {
|
|
35166
|
-
openapi: spec.openapi,
|
|
35167
|
-
paths: filteredPaths,
|
|
35168
|
-
components: {
|
|
35169
|
-
schemas: resolveAllSchemaRefs(structuredClone(schemas))
|
|
35170
|
-
}
|
|
35171
|
-
};
|
|
35172
|
-
}
|
|
35173
|
-
__name(buildFilteredSpec, "buildFilteredSpec");
|
|
35174
|
-
function stripPrefix(pathStr, prefix) {
|
|
35175
|
-
if (prefix && pathStr.startsWith(prefix)) {
|
|
35176
|
-
return pathStr.slice(prefix.length);
|
|
35177
|
-
}
|
|
35178
|
-
return pathStr;
|
|
35179
|
-
}
|
|
35180
|
-
__name(stripPrefix, "stripPrefix");
|
|
35181
|
-
var MAX_REF_DEPTH = 5;
|
|
35182
|
-
function resolveRefsDeep(obj, schemas, depth = 0) {
|
|
35183
|
-
if (depth > MAX_REF_DEPTH || obj === null || obj === void 0) return obj;
|
|
35184
|
-
if (typeof obj !== "object") return obj;
|
|
35185
|
-
if (Array.isArray(obj)) {
|
|
35186
|
-
return obj.map((item) => resolveRefsDeep(item, schemas, depth));
|
|
35187
|
-
}
|
|
35188
|
-
const record = obj;
|
|
35189
|
-
if (typeof record["$ref"] === "string") {
|
|
35190
|
-
const resolved = resolveRef(record["$ref"], schemas);
|
|
35191
|
-
if (resolved !== void 0) {
|
|
35192
|
-
return resolveRefsDeep(structuredClone(resolved), schemas, depth + 1);
|
|
35193
|
-
}
|
|
35194
|
-
return record;
|
|
35195
|
-
}
|
|
35196
|
-
const result = {};
|
|
35197
|
-
for (const [key, value] of Object.entries(record)) {
|
|
35198
|
-
result[key] = resolveRefsDeep(value, schemas, depth);
|
|
35199
|
-
}
|
|
35200
|
-
return result;
|
|
35201
|
-
}
|
|
35202
|
-
__name(resolveRefsDeep, "resolveRefsDeep");
|
|
35203
|
-
function resolveRef(ref, schemas) {
|
|
35204
|
-
const prefix = "#/components/schemas/";
|
|
35205
|
-
if (ref.startsWith(prefix)) {
|
|
35206
|
-
const name = ref.slice(prefix.length);
|
|
35207
|
-
return schemas[name];
|
|
35208
|
-
}
|
|
35209
|
-
return void 0;
|
|
35210
|
-
}
|
|
35211
|
-
__name(resolveRef, "resolveRef");
|
|
35212
|
-
function resolveAllSchemaRefs(schemas) {
|
|
35213
|
-
const result = {};
|
|
35214
|
-
for (const [name, schema] of Object.entries(schemas)) {
|
|
35215
|
-
result[name] = resolveRefsDeep(schema, schemas);
|
|
35216
|
-
}
|
|
35217
|
-
return result;
|
|
35218
|
-
}
|
|
35219
|
-
__name(resolveAllSchemaRefs, "resolveAllSchemaRefs");
|
|
35220
|
-
|
|
35221
35026
|
// src/services/platform-http-client.service.ts
|
|
35222
|
-
var
|
|
35027
|
+
var import_common8 = require("@nestjs/common");
|
|
35223
35028
|
var import_http_client = require("@lark-apaas/http-client");
|
|
35224
35029
|
var import_nestjs_common3 = require("@lark-apaas/nestjs-common");
|
|
35225
|
-
function
|
|
35030
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
35226
35031
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
35227
35032
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
35228
35033
|
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;
|
|
35229
35034
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
35230
35035
|
}
|
|
35231
|
-
__name(
|
|
35036
|
+
__name(_ts_decorate8, "_ts_decorate");
|
|
35232
35037
|
function _ts_metadata5(k, v) {
|
|
35233
35038
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
35234
35039
|
}
|
|
@@ -35267,7 +35072,7 @@ var PlatformHttpClientService = class _PlatformHttpClientService {
|
|
|
35267
35072
|
requestContext;
|
|
35268
35073
|
client;
|
|
35269
35074
|
protectedClient;
|
|
35270
|
-
logger = new
|
|
35075
|
+
logger = new import_common8.Logger(_PlatformHttpClientService.name);
|
|
35271
35076
|
constructor(requestContext) {
|
|
35272
35077
|
this.requestContext = requestContext;
|
|
35273
35078
|
const baseConfig = {
|
|
@@ -35423,8 +35228,8 @@ var PlatformHttpClientService = class _PlatformHttpClientService {
|
|
|
35423
35228
|
});
|
|
35424
35229
|
}
|
|
35425
35230
|
};
|
|
35426
|
-
PlatformHttpClientService =
|
|
35427
|
-
(0,
|
|
35231
|
+
PlatformHttpClientService = _ts_decorate8([
|
|
35232
|
+
(0, import_common8.Injectable)(),
|
|
35428
35233
|
_ts_metadata5("design:type", Function),
|
|
35429
35234
|
_ts_metadata5("design:paramtypes", [
|
|
35430
35235
|
typeof import_nestjs_common3.RequestContextService === "undefined" ? Object : import_nestjs_common3.RequestContextService
|
|
@@ -35435,16 +35240,16 @@ PlatformHttpClientService = _ts_decorate9([
|
|
|
35435
35240
|
var DISABLE_DATAPASS = process.env.FORCE_FRAMEWORK_DISABLE_DATAPASS === "true";
|
|
35436
35241
|
|
|
35437
35242
|
// src/services/file.service.ts
|
|
35438
|
-
var
|
|
35243
|
+
var import_common9 = require("@nestjs/common");
|
|
35439
35244
|
var import_nestjs_common4 = require("@lark-apaas/nestjs-common");
|
|
35440
35245
|
var import_file_service = require("@lark-apaas/file-service");
|
|
35441
|
-
function
|
|
35246
|
+
function _ts_decorate9(decorators, target, key, desc) {
|
|
35442
35247
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
35443
35248
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
35444
35249
|
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;
|
|
35445
35250
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
35446
35251
|
}
|
|
35447
|
-
__name(
|
|
35252
|
+
__name(_ts_decorate9, "_ts_decorate");
|
|
35448
35253
|
function _ts_metadata6(k, v) {
|
|
35449
35254
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
35450
35255
|
}
|
|
@@ -35469,7 +35274,7 @@ var FileService = class {
|
|
|
35469
35274
|
this.httpClient = httpClient;
|
|
35470
35275
|
this.observable = observable;
|
|
35471
35276
|
this.fileServiceCore = new import_file_service.FileService(this.httpClient);
|
|
35472
|
-
this.nestLogger = new
|
|
35277
|
+
this.nestLogger = new import_common9.Logger("file");
|
|
35473
35278
|
}
|
|
35474
35279
|
/**
|
|
35475
35280
|
* 返回一个绑定了指定 bucket 的代理对象
|
|
@@ -35478,10 +35283,10 @@ var FileService = class {
|
|
|
35478
35283
|
from(bucket) {
|
|
35479
35284
|
return {
|
|
35480
35285
|
upload: /* @__PURE__ */ __name((file, options) => this._upload(bucket, file, options), "upload"),
|
|
35481
|
-
download: /* @__PURE__ */ __name((
|
|
35286
|
+
download: /* @__PURE__ */ __name((path2) => this._download(bucket, path2), "download"),
|
|
35482
35287
|
list: /* @__PURE__ */ __name((prefix, searchOptions) => this._list(bucket, prefix, searchOptions), "list"),
|
|
35483
35288
|
remove: /* @__PURE__ */ __name((filePaths) => this._remove(bucket, filePaths), "remove"),
|
|
35484
|
-
createSignedUrl: /* @__PURE__ */ __name((
|
|
35289
|
+
createSignedUrl: /* @__PURE__ */ __name((path2, expiresIn) => this._createSignedUrl(bucket, path2, expiresIn), "createSignedUrl"),
|
|
35485
35290
|
getFileMetadata: /* @__PURE__ */ __name((filePath) => this._getFileMetadata(bucket, filePath), "getFileMetadata")
|
|
35486
35291
|
};
|
|
35487
35292
|
}
|
|
@@ -35489,9 +35294,9 @@ var FileService = class {
|
|
|
35489
35294
|
async upload(file, options) {
|
|
35490
35295
|
return this._upload(await this.getDefaultBucket(), file, options);
|
|
35491
35296
|
}
|
|
35492
|
-
download(
|
|
35297
|
+
download(path2) {
|
|
35493
35298
|
const capturedBucketPromise = this.getDefaultBucket();
|
|
35494
|
-
return this._download(capturedBucketPromise,
|
|
35299
|
+
return this._download(capturedBucketPromise, path2);
|
|
35495
35300
|
}
|
|
35496
35301
|
async list(prefix, searchOptions) {
|
|
35497
35302
|
return this._list(await this.getDefaultBucket(), prefix, searchOptions);
|
|
@@ -35499,8 +35304,8 @@ var FileService = class {
|
|
|
35499
35304
|
async remove(filePaths) {
|
|
35500
35305
|
return this._remove(await this.getDefaultBucket(), filePaths);
|
|
35501
35306
|
}
|
|
35502
|
-
async createSignedUrl(
|
|
35503
|
-
return this._createSignedUrl(await this.getDefaultBucket(),
|
|
35307
|
+
async createSignedUrl(path2, expiresIn) {
|
|
35308
|
+
return this._createSignedUrl(await this.getDefaultBucket(), path2, expiresIn);
|
|
35504
35309
|
}
|
|
35505
35310
|
async getFileMetadata(filePath) {
|
|
35506
35311
|
return this._getFileMetadata(await this.getDefaultBucket(), filePath);
|
|
@@ -35567,7 +35372,7 @@ var FileService = class {
|
|
|
35567
35372
|
span.end();
|
|
35568
35373
|
}
|
|
35569
35374
|
}
|
|
35570
|
-
_download(bucket,
|
|
35375
|
+
_download(bucket, path2) {
|
|
35571
35376
|
const capturedAppId = this.getAppId();
|
|
35572
35377
|
const capturedRootSpan = this.requestContextService.getContext()?.requestRootSpan;
|
|
35573
35378
|
const downloadFn = /* @__PURE__ */ __name(async () => {
|
|
@@ -35587,7 +35392,7 @@ var FileService = class {
|
|
|
35587
35392
|
method: "download",
|
|
35588
35393
|
source_type: "server",
|
|
35589
35394
|
request: {
|
|
35590
|
-
path:
|
|
35395
|
+
path: path2
|
|
35591
35396
|
}
|
|
35592
35397
|
};
|
|
35593
35398
|
const startTime = Date.now();
|
|
@@ -35595,7 +35400,7 @@ var FileService = class {
|
|
|
35595
35400
|
const res = await this.fileServiceCore.downloadInner({
|
|
35596
35401
|
appId: capturedAppId,
|
|
35597
35402
|
bucketId: await bucket,
|
|
35598
|
-
filePath:
|
|
35403
|
+
filePath: path2
|
|
35599
35404
|
});
|
|
35600
35405
|
this.nestLogger.log(JSON.stringify({
|
|
35601
35406
|
...baseParams,
|
|
@@ -35714,7 +35519,7 @@ var FileService = class {
|
|
|
35714
35519
|
span.end();
|
|
35715
35520
|
}
|
|
35716
35521
|
}
|
|
35717
|
-
async _createSignedUrl(bucket,
|
|
35522
|
+
async _createSignedUrl(bucket, path2, expiresIn) {
|
|
35718
35523
|
const span = this.observable.startTrace("\u6587\u4EF6: createSignedUrl", this.requestContextService.getContext()?.requestRootSpan);
|
|
35719
35524
|
span.setAttribute("module", "file");
|
|
35720
35525
|
span.setAttribute("source_type", "platform");
|
|
@@ -35731,7 +35536,7 @@ var FileService = class {
|
|
|
35731
35536
|
method: "createSignedUrl",
|
|
35732
35537
|
source_type: "server",
|
|
35733
35538
|
request: {
|
|
35734
|
-
path:
|
|
35539
|
+
path: path2,
|
|
35735
35540
|
expiresIn
|
|
35736
35541
|
}
|
|
35737
35542
|
};
|
|
@@ -35740,7 +35545,7 @@ var FileService = class {
|
|
|
35740
35545
|
const res = await this.fileServiceCore.createSignedUrl({
|
|
35741
35546
|
appId: this.getAppId(),
|
|
35742
35547
|
bucketId: await bucket,
|
|
35743
|
-
filePath:
|
|
35548
|
+
filePath: path2,
|
|
35744
35549
|
expiresIn
|
|
35745
35550
|
});
|
|
35746
35551
|
this.nestLogger.log(JSON.stringify({
|
|
@@ -35809,10 +35614,10 @@ var FileService = class {
|
|
|
35809
35614
|
}
|
|
35810
35615
|
}
|
|
35811
35616
|
};
|
|
35812
|
-
FileService =
|
|
35813
|
-
(0,
|
|
35814
|
-
_ts_param2(1, (0,
|
|
35815
|
-
_ts_param2(2, (0,
|
|
35617
|
+
FileService = _ts_decorate9([
|
|
35618
|
+
(0, import_common9.Injectable)(),
|
|
35619
|
+
_ts_param2(1, (0, import_common9.Inject)(import_nestjs_common4.PLATFORM_HTTP_CLIENT)),
|
|
35620
|
+
_ts_param2(2, (0, import_common9.Inject)(import_nestjs_common4.OBSERVABLE_SERVICE)),
|
|
35816
35621
|
_ts_metadata6("design:type", Function),
|
|
35817
35622
|
_ts_metadata6("design:paramtypes", [
|
|
35818
35623
|
typeof import_nestjs_common4.RequestContextService === "undefined" ? Object : import_nestjs_common4.RequestContextService,
|
|
@@ -35825,21 +35630,21 @@ FileService = _ts_decorate10([
|
|
|
35825
35630
|
var import_nestjs_authzpaas = require("@lark-apaas/nestjs-authzpaas");
|
|
35826
35631
|
|
|
35827
35632
|
// src/modules/static/static.module.ts
|
|
35828
|
-
var
|
|
35633
|
+
var import_common11 = require("@nestjs/common");
|
|
35829
35634
|
|
|
35830
35635
|
// src/modules/static/static.controller.ts
|
|
35831
|
-
var
|
|
35832
|
-
var
|
|
35833
|
-
var
|
|
35636
|
+
var import_common10 = require("@nestjs/common");
|
|
35637
|
+
var import_swagger = require("@nestjs/swagger");
|
|
35638
|
+
var fs = __toESM(require("fs"), 1);
|
|
35834
35639
|
var path = __toESM(require("path"), 1);
|
|
35835
35640
|
var crypto2 = __toESM(require("crypto"), 1);
|
|
35836
|
-
function
|
|
35641
|
+
function _ts_decorate10(decorators, target, key, desc) {
|
|
35837
35642
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
35838
35643
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
35839
35644
|
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;
|
|
35840
35645
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
35841
35646
|
}
|
|
35842
|
-
__name(
|
|
35647
|
+
__name(_ts_decorate10, "_ts_decorate");
|
|
35843
35648
|
function _ts_metadata7(k, v) {
|
|
35844
35649
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
35845
35650
|
}
|
|
@@ -35907,7 +35712,7 @@ var StaticController = class _StaticController {
|
|
|
35907
35712
|
static {
|
|
35908
35713
|
__name(this, "StaticController");
|
|
35909
35714
|
}
|
|
35910
|
-
logger = new
|
|
35715
|
+
logger = new import_common10.Logger(_StaticController.name);
|
|
35911
35716
|
staticDir;
|
|
35912
35717
|
constructor() {
|
|
35913
35718
|
this.staticDir = path.resolve(process.cwd(), "shared/static");
|
|
@@ -35928,7 +35733,7 @@ var StaticController = class _StaticController {
|
|
|
35928
35733
|
try {
|
|
35929
35734
|
const relativePath = params["0"] || params["*"] || "";
|
|
35930
35735
|
if (!relativePath) {
|
|
35931
|
-
res.status(
|
|
35736
|
+
res.status(import_common10.HttpStatus.BAD_REQUEST).json({
|
|
35932
35737
|
error: "Bad Request",
|
|
35933
35738
|
message: "File path is required"
|
|
35934
35739
|
});
|
|
@@ -35938,22 +35743,22 @@ var StaticController = class _StaticController {
|
|
|
35938
35743
|
const normalizedPath = path.normalize(filePath);
|
|
35939
35744
|
if (!normalizedPath.startsWith(this.staticDir)) {
|
|
35940
35745
|
this.logger.warn(`Path traversal attempt detected: ${relativePath}`);
|
|
35941
|
-
res.status(
|
|
35746
|
+
res.status(import_common10.HttpStatus.FORBIDDEN).json({
|
|
35942
35747
|
error: "Forbidden",
|
|
35943
35748
|
message: "Access denied"
|
|
35944
35749
|
});
|
|
35945
35750
|
return;
|
|
35946
35751
|
}
|
|
35947
|
-
if (!
|
|
35948
|
-
res.status(
|
|
35752
|
+
if (!fs.existsSync(normalizedPath)) {
|
|
35753
|
+
res.status(import_common10.HttpStatus.NOT_FOUND).json({
|
|
35949
35754
|
error: "Not Found",
|
|
35950
35755
|
message: "File not found"
|
|
35951
35756
|
});
|
|
35952
35757
|
return;
|
|
35953
35758
|
}
|
|
35954
|
-
const stat =
|
|
35759
|
+
const stat = fs.statSync(normalizedPath);
|
|
35955
35760
|
if (stat.isDirectory()) {
|
|
35956
|
-
res.status(
|
|
35761
|
+
res.status(import_common10.HttpStatus.FORBIDDEN).json({
|
|
35957
35762
|
error: "Forbidden",
|
|
35958
35763
|
message: "Directory listing not allowed"
|
|
35959
35764
|
});
|
|
@@ -35963,18 +35768,18 @@ var StaticController = class _StaticController {
|
|
|
35963
35768
|
const etag = generateETag(stat);
|
|
35964
35769
|
const ifNoneMatch = req.headers["if-none-match"];
|
|
35965
35770
|
if (ifNoneMatch === etag) {
|
|
35966
|
-
res.status(
|
|
35771
|
+
res.status(import_common10.HttpStatus.NOT_MODIFIED).end();
|
|
35967
35772
|
return;
|
|
35968
35773
|
}
|
|
35969
35774
|
res.setHeader("Content-Type", mimeType);
|
|
35970
35775
|
res.setHeader("Content-Length", stat.size);
|
|
35971
35776
|
res.setHeader("ETag", etag);
|
|
35972
35777
|
res.setHeader("Cache-Control", "public, max-age=0, must-revalidate");
|
|
35973
|
-
const stream =
|
|
35778
|
+
const stream = fs.createReadStream(normalizedPath);
|
|
35974
35779
|
stream.on("error", (error) => {
|
|
35975
35780
|
this.logger.error(`Error streaming file: ${relativePath}`, error);
|
|
35976
35781
|
if (!res.headersSent) {
|
|
35977
|
-
res.status(
|
|
35782
|
+
res.status(import_common10.HttpStatus.INTERNAL_SERVER_ERROR).json({
|
|
35978
35783
|
error: "Internal Server Error",
|
|
35979
35784
|
message: "Failed to read file"
|
|
35980
35785
|
});
|
|
@@ -35984,7 +35789,7 @@ var StaticController = class _StaticController {
|
|
|
35984
35789
|
} catch (error) {
|
|
35985
35790
|
this.logger.error("Error serving static file", error);
|
|
35986
35791
|
if (!res.headersSent) {
|
|
35987
|
-
res.status(
|
|
35792
|
+
res.status(import_common10.HttpStatus.INTERNAL_SERVER_ERROR).json({
|
|
35988
35793
|
error: "Internal Server Error",
|
|
35989
35794
|
message: "An unexpected error occurred"
|
|
35990
35795
|
});
|
|
@@ -35992,11 +35797,11 @@ var StaticController = class _StaticController {
|
|
|
35992
35797
|
}
|
|
35993
35798
|
}
|
|
35994
35799
|
};
|
|
35995
|
-
|
|
35996
|
-
(0,
|
|
35997
|
-
_ts_param3(0, (0,
|
|
35998
|
-
_ts_param3(1, (0,
|
|
35999
|
-
_ts_param3(2, (0,
|
|
35800
|
+
_ts_decorate10([
|
|
35801
|
+
(0, import_common10.Get)("*"),
|
|
35802
|
+
_ts_param3(0, (0, import_common10.Param)()),
|
|
35803
|
+
_ts_param3(1, (0, import_common10.Req)()),
|
|
35804
|
+
_ts_param3(2, (0, import_common10.Res)()),
|
|
36000
35805
|
_ts_metadata7("design:type", Function),
|
|
36001
35806
|
_ts_metadata7("design:paramtypes", [
|
|
36002
35807
|
typeof Record === "undefined" ? Object : Record,
|
|
@@ -36005,28 +35810,28 @@ _ts_decorate11([
|
|
|
36005
35810
|
]),
|
|
36006
35811
|
_ts_metadata7("design:returntype", void 0)
|
|
36007
35812
|
], StaticController.prototype, "serveFile", null);
|
|
36008
|
-
StaticController =
|
|
36009
|
-
(0,
|
|
36010
|
-
(0,
|
|
35813
|
+
StaticController = _ts_decorate10([
|
|
35814
|
+
(0, import_swagger.ApiExcludeController)(),
|
|
35815
|
+
(0, import_common10.Controller)("static"),
|
|
36011
35816
|
_ts_metadata7("design:type", Function),
|
|
36012
35817
|
_ts_metadata7("design:paramtypes", [])
|
|
36013
35818
|
], StaticController);
|
|
36014
35819
|
|
|
36015
35820
|
// src/modules/static/static.module.ts
|
|
36016
|
-
function
|
|
35821
|
+
function _ts_decorate11(decorators, target, key, desc) {
|
|
36017
35822
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
36018
35823
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
36019
35824
|
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;
|
|
36020
35825
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
36021
35826
|
}
|
|
36022
|
-
__name(
|
|
35827
|
+
__name(_ts_decorate11, "_ts_decorate");
|
|
36023
35828
|
var StaticModule = class {
|
|
36024
35829
|
static {
|
|
36025
35830
|
__name(this, "StaticModule");
|
|
36026
35831
|
}
|
|
36027
35832
|
};
|
|
36028
|
-
StaticModule =
|
|
36029
|
-
(0,
|
|
35833
|
+
StaticModule = _ts_decorate11([
|
|
35834
|
+
(0, import_common11.Module)({
|
|
36030
35835
|
controllers: [
|
|
36031
35836
|
StaticController
|
|
36032
35837
|
]
|
|
@@ -36034,16 +35839,16 @@ StaticModule = _ts_decorate12([
|
|
|
36034
35839
|
], StaticModule);
|
|
36035
35840
|
|
|
36036
35841
|
// src/modules/html-hot-update/html-hot-update.module.ts
|
|
36037
|
-
var
|
|
35842
|
+
var import_common14 = require("@nestjs/common");
|
|
36038
35843
|
|
|
36039
35844
|
// src/modules/html-hot-update/html-hot-update.controller.ts
|
|
36040
|
-
var
|
|
36041
|
-
var
|
|
35845
|
+
var import_common13 = require("@nestjs/common");
|
|
35846
|
+
var import_swagger2 = require("@nestjs/swagger");
|
|
36042
35847
|
|
|
36043
35848
|
// src/modules/html-hot-update/html-hot-update.service.ts
|
|
36044
|
-
var
|
|
35849
|
+
var import_common12 = require("@nestjs/common");
|
|
35850
|
+
var import_node_fs = require("fs");
|
|
36045
35851
|
var import_node_fs2 = require("fs");
|
|
36046
|
-
var import_node_fs3 = require("fs");
|
|
36047
35852
|
var import_node_crypto = require("crypto");
|
|
36048
35853
|
var import_node_path2 = require("path");
|
|
36049
35854
|
var import_nestjs_common5 = require("@lark-apaas/nestjs-common");
|
|
@@ -36074,13 +35879,13 @@ function setActiveHtmlVersion(version) {
|
|
|
36074
35879
|
__name(setActiveHtmlVersion, "setActiveHtmlVersion");
|
|
36075
35880
|
|
|
36076
35881
|
// src/modules/html-hot-update/html-hot-update.service.ts
|
|
36077
|
-
function
|
|
35882
|
+
function _ts_decorate12(decorators, target, key, desc) {
|
|
36078
35883
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
36079
35884
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
36080
35885
|
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;
|
|
36081
35886
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
36082
35887
|
}
|
|
36083
|
-
__name(
|
|
35888
|
+
__name(_ts_decorate12, "_ts_decorate");
|
|
36084
35889
|
function _ts_metadata8(k, v) {
|
|
36085
35890
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
36086
35891
|
}
|
|
@@ -36123,7 +35928,7 @@ var HtmlHotUpdateService = class _HtmlHotUpdateService {
|
|
|
36123
35928
|
__name(this, "HtmlHotUpdateService");
|
|
36124
35929
|
}
|
|
36125
35930
|
httpClient;
|
|
36126
|
-
logger = new
|
|
35931
|
+
logger = new import_common12.Logger(_HtmlHotUpdateService.name);
|
|
36127
35932
|
fileLock = new Mutex();
|
|
36128
35933
|
hotUpdateDir = getHotUpdateHtmlDir();
|
|
36129
35934
|
hotUpdateVersionsDir = getHotUpdateVersionsDir();
|
|
@@ -36148,7 +35953,7 @@ var HtmlHotUpdateService = class _HtmlHotUpdateService {
|
|
|
36148
35953
|
const activeVersion = getActiveHtmlVersion();
|
|
36149
35954
|
if (activeVersion) {
|
|
36150
35955
|
const hotPath = (0, import_node_path2.join)(getHotUpdateVersionDir(activeVersion), fileName);
|
|
36151
|
-
if ((0,
|
|
35956
|
+
if ((0, import_node_fs2.existsSync)(hotPath)) {
|
|
36152
35957
|
return hotPath;
|
|
36153
35958
|
}
|
|
36154
35959
|
}
|
|
@@ -36162,7 +35967,7 @@ var HtmlHotUpdateService = class _HtmlHotUpdateService {
|
|
|
36162
35967
|
];
|
|
36163
35968
|
}
|
|
36164
35969
|
const activeVersionDir = getHotUpdateVersionDir(activeVersion);
|
|
36165
|
-
return (0,
|
|
35970
|
+
return (0, import_node_fs2.existsSync)(activeVersionDir) ? [
|
|
36166
35971
|
activeVersionDir,
|
|
36167
35972
|
this.originalHtmlDir
|
|
36168
35973
|
] : [
|
|
@@ -36205,28 +36010,28 @@ var HtmlHotUpdateService = class _HtmlHotUpdateService {
|
|
|
36205
36010
|
const version = this.computeVersion(fileMap);
|
|
36206
36011
|
const versionDir = getHotUpdateVersionDir(version);
|
|
36207
36012
|
const currentVersion = getActiveHtmlVersion();
|
|
36208
|
-
if (currentVersion === version && (0,
|
|
36013
|
+
if (currentVersion === version && (0, import_node_fs2.existsSync)(versionDir)) {
|
|
36209
36014
|
this.logger.log(`HTML hot update skipped: version ${version} already active`);
|
|
36210
36015
|
return result;
|
|
36211
36016
|
}
|
|
36212
36017
|
const stagingDir = (0, import_node_path2.join)(this.hotUpdateDir, "staging", `${version}-${process.pid}-${Date.now()}`);
|
|
36213
36018
|
await this.fileLock.acquire();
|
|
36214
36019
|
try {
|
|
36215
|
-
if (getActiveHtmlVersion() === version && (0,
|
|
36020
|
+
if (getActiveHtmlVersion() === version && (0, import_node_fs2.existsSync)(versionDir)) {
|
|
36216
36021
|
this.logger.log(`HTML hot update skipped after lock: version ${version} already active`);
|
|
36217
36022
|
return result;
|
|
36218
36023
|
}
|
|
36219
|
-
await
|
|
36024
|
+
await import_node_fs.promises.mkdir(stagingDir, {
|
|
36220
36025
|
recursive: true
|
|
36221
36026
|
});
|
|
36222
36027
|
for (const [rawFilePath, content] of entries) {
|
|
36223
36028
|
try {
|
|
36224
36029
|
const filePath = this.normalizeFilePath(rawFilePath);
|
|
36225
36030
|
const localPath = (0, import_node_path2.join)(stagingDir, filePath);
|
|
36226
|
-
await
|
|
36031
|
+
await import_node_fs.promises.mkdir((0, import_node_path2.dirname)(localPath), {
|
|
36227
36032
|
recursive: true
|
|
36228
36033
|
});
|
|
36229
|
-
await
|
|
36034
|
+
await import_node_fs.promises.writeFile(localPath, content, "utf-8");
|
|
36230
36035
|
result.updatedFiles.push(filePath);
|
|
36231
36036
|
} catch (error) {
|
|
36232
36037
|
const reason = error instanceof Error ? error.message : String(error);
|
|
@@ -36238,7 +36043,7 @@ var HtmlHotUpdateService = class _HtmlHotUpdateService {
|
|
|
36238
36043
|
}
|
|
36239
36044
|
}
|
|
36240
36045
|
if (result.updatedFiles.length === 0) {
|
|
36241
|
-
await
|
|
36046
|
+
await import_node_fs.promises.rm(stagingDir, {
|
|
36242
36047
|
recursive: true,
|
|
36243
36048
|
force: true
|
|
36244
36049
|
});
|
|
@@ -36249,7 +36054,7 @@ var HtmlHotUpdateService = class _HtmlHotUpdateService {
|
|
|
36249
36054
|
await this.cleanupOldVersions(version);
|
|
36250
36055
|
this.logger.log(`HTML hot update activated: version=${version}, files=${result.updatedFiles.length}`);
|
|
36251
36056
|
} finally {
|
|
36252
|
-
await
|
|
36057
|
+
await import_node_fs.promises.rm(stagingDir, {
|
|
36253
36058
|
recursive: true,
|
|
36254
36059
|
force: true
|
|
36255
36060
|
}).catch(() => void 0);
|
|
@@ -36258,11 +36063,11 @@ var HtmlHotUpdateService = class _HtmlHotUpdateService {
|
|
|
36258
36063
|
return result;
|
|
36259
36064
|
}
|
|
36260
36065
|
async promoteVersionDirectory(stagingDir, versionDir) {
|
|
36261
|
-
await
|
|
36066
|
+
await import_node_fs.promises.mkdir(this.hotUpdateVersionsDir, {
|
|
36262
36067
|
recursive: true
|
|
36263
36068
|
});
|
|
36264
36069
|
try {
|
|
36265
|
-
await
|
|
36070
|
+
await import_node_fs.promises.rename(stagingDir, versionDir);
|
|
36266
36071
|
} catch (error) {
|
|
36267
36072
|
const err = error;
|
|
36268
36073
|
if (err.code !== "EEXIST") {
|
|
@@ -36273,11 +36078,11 @@ var HtmlHotUpdateService = class _HtmlHotUpdateService {
|
|
|
36273
36078
|
async cleanupOldVersions(activeVersion) {
|
|
36274
36079
|
let versions = [];
|
|
36275
36080
|
try {
|
|
36276
|
-
versions = await
|
|
36081
|
+
versions = await import_node_fs.promises.readdir(this.hotUpdateVersionsDir);
|
|
36277
36082
|
} catch {
|
|
36278
36083
|
return;
|
|
36279
36084
|
}
|
|
36280
|
-
await Promise.all(versions.filter((version) => version !== activeVersion).map((version) =>
|
|
36085
|
+
await Promise.all(versions.filter((version) => version !== activeVersion).map((version) => import_node_fs.promises.rm(getHotUpdateVersionDir(version), {
|
|
36281
36086
|
recursive: true,
|
|
36282
36087
|
force: true
|
|
36283
36088
|
})));
|
|
@@ -36325,9 +36130,9 @@ var HtmlHotUpdateService = class _HtmlHotUpdateService {
|
|
|
36325
36130
|
return "";
|
|
36326
36131
|
}
|
|
36327
36132
|
};
|
|
36328
|
-
HtmlHotUpdateService =
|
|
36329
|
-
(0,
|
|
36330
|
-
_ts_param4(0, (0,
|
|
36133
|
+
HtmlHotUpdateService = _ts_decorate12([
|
|
36134
|
+
(0, import_common12.Injectable)(),
|
|
36135
|
+
_ts_param4(0, (0, import_common12.Inject)(import_nestjs_common5.PLATFORM_HTTP_CLIENT)),
|
|
36331
36136
|
_ts_metadata8("design:type", Function),
|
|
36332
36137
|
_ts_metadata8("design:paramtypes", [
|
|
36333
36138
|
typeof PlatformHttpClient === "undefined" ? Object : PlatformHttpClient
|
|
@@ -36335,13 +36140,13 @@ HtmlHotUpdateService = _ts_decorate13([
|
|
|
36335
36140
|
], HtmlHotUpdateService);
|
|
36336
36141
|
|
|
36337
36142
|
// src/modules/html-hot-update/html-hot-update.controller.ts
|
|
36338
|
-
function
|
|
36143
|
+
function _ts_decorate13(decorators, target, key, desc) {
|
|
36339
36144
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
36340
36145
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
36341
36146
|
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;
|
|
36342
36147
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
36343
36148
|
}
|
|
36344
|
-
__name(
|
|
36149
|
+
__name(_ts_decorate13, "_ts_decorate");
|
|
36345
36150
|
function _ts_metadata9(k, v) {
|
|
36346
36151
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
36347
36152
|
}
|
|
@@ -36364,7 +36169,7 @@ var HtmlHotUpdateController = class _HtmlHotUpdateController {
|
|
|
36364
36169
|
__name(this, "HtmlHotUpdateController");
|
|
36365
36170
|
}
|
|
36366
36171
|
htmlHotUpdateService;
|
|
36367
|
-
logger = new
|
|
36172
|
+
logger = new import_common13.Logger(_HtmlHotUpdateController.name);
|
|
36368
36173
|
constructor(htmlHotUpdateService) {
|
|
36369
36174
|
this.htmlHotUpdateService = htmlHotUpdateService;
|
|
36370
36175
|
}
|
|
@@ -36406,19 +36211,19 @@ var HtmlHotUpdateController = class _HtmlHotUpdateController {
|
|
|
36406
36211
|
}
|
|
36407
36212
|
}
|
|
36408
36213
|
};
|
|
36409
|
-
|
|
36410
|
-
(0,
|
|
36411
|
-
(0,
|
|
36412
|
-
_ts_param5(0, (0,
|
|
36214
|
+
_ts_decorate13([
|
|
36215
|
+
(0, import_common13.Post)("update_html_files"),
|
|
36216
|
+
(0, import_common13.HttpCode)(import_common13.HttpStatus.OK),
|
|
36217
|
+
_ts_param5(0, (0, import_common13.Body)()),
|
|
36413
36218
|
_ts_metadata9("design:type", Function),
|
|
36414
36219
|
_ts_metadata9("design:paramtypes", [
|
|
36415
36220
|
typeof UpdateHtmlFilesDto === "undefined" ? Object : UpdateHtmlFilesDto
|
|
36416
36221
|
]),
|
|
36417
36222
|
_ts_metadata9("design:returntype", Promise)
|
|
36418
36223
|
], HtmlHotUpdateController.prototype, "updateHtmlFiles", null);
|
|
36419
|
-
HtmlHotUpdateController =
|
|
36420
|
-
(0,
|
|
36421
|
-
(0,
|
|
36224
|
+
HtmlHotUpdateController = _ts_decorate13([
|
|
36225
|
+
(0, import_swagger2.ApiExcludeController)(),
|
|
36226
|
+
(0, import_common13.Controller)("__innerapi__"),
|
|
36422
36227
|
_ts_metadata9("design:type", Function),
|
|
36423
36228
|
_ts_metadata9("design:paramtypes", [
|
|
36424
36229
|
typeof HtmlHotUpdateService === "undefined" ? Object : HtmlHotUpdateService
|
|
@@ -36426,20 +36231,20 @@ HtmlHotUpdateController = _ts_decorate14([
|
|
|
36426
36231
|
], HtmlHotUpdateController);
|
|
36427
36232
|
|
|
36428
36233
|
// src/modules/html-hot-update/html-hot-update.module.ts
|
|
36429
|
-
function
|
|
36234
|
+
function _ts_decorate14(decorators, target, key, desc) {
|
|
36430
36235
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
36431
36236
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
36432
36237
|
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;
|
|
36433
36238
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
36434
36239
|
}
|
|
36435
|
-
__name(
|
|
36240
|
+
__name(_ts_decorate14, "_ts_decorate");
|
|
36436
36241
|
var HtmlHotUpdateModule = class {
|
|
36437
36242
|
static {
|
|
36438
36243
|
__name(this, "HtmlHotUpdateModule");
|
|
36439
36244
|
}
|
|
36440
36245
|
};
|
|
36441
|
-
HtmlHotUpdateModule =
|
|
36442
|
-
(0,
|
|
36246
|
+
HtmlHotUpdateModule = _ts_decorate14([
|
|
36247
|
+
(0, import_common14.Module)({
|
|
36443
36248
|
controllers: [
|
|
36444
36249
|
HtmlHotUpdateController
|
|
36445
36250
|
],
|
|
@@ -36453,16 +36258,16 @@ HtmlHotUpdateModule = _ts_decorate15([
|
|
|
36453
36258
|
], HtmlHotUpdateModule);
|
|
36454
36259
|
|
|
36455
36260
|
// src/middlewares/html-hot-update-view/index.ts
|
|
36456
|
-
var
|
|
36457
|
-
var
|
|
36261
|
+
var import_common15 = require("@nestjs/common");
|
|
36262
|
+
var import_node_fs3 = require("fs");
|
|
36458
36263
|
var import_node_path3 = require("path");
|
|
36459
|
-
function
|
|
36264
|
+
function _ts_decorate15(decorators, target, key, desc) {
|
|
36460
36265
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
36461
36266
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
36462
36267
|
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;
|
|
36463
36268
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
36464
36269
|
}
|
|
36465
|
-
__name(
|
|
36270
|
+
__name(_ts_decorate15, "_ts_decorate");
|
|
36466
36271
|
var HtmlHotUpdateViewMiddleware = class {
|
|
36467
36272
|
static {
|
|
36468
36273
|
__name(this, "HtmlHotUpdateViewMiddleware");
|
|
@@ -36481,7 +36286,7 @@ var HtmlHotUpdateViewMiddleware = class {
|
|
|
36481
36286
|
}
|
|
36482
36287
|
const activeVersion = getActiveHtmlVersion();
|
|
36483
36288
|
const hotPath = activeVersion ? (0, import_node_path3.join)(getHotUpdateVersionDir(activeVersion), `${view}.html`) : "";
|
|
36484
|
-
if (hotPath && (0,
|
|
36289
|
+
if (hotPath && (0, import_node_fs3.existsSync)(hotPath)) {
|
|
36485
36290
|
return originalRender(hotPath, renderOptions, renderCallback);
|
|
36486
36291
|
}
|
|
36487
36292
|
return originalRender(view, renderOptions, renderCallback);
|
|
@@ -36489,18 +36294,18 @@ var HtmlHotUpdateViewMiddleware = class {
|
|
|
36489
36294
|
next();
|
|
36490
36295
|
}
|
|
36491
36296
|
};
|
|
36492
|
-
HtmlHotUpdateViewMiddleware =
|
|
36493
|
-
(0,
|
|
36297
|
+
HtmlHotUpdateViewMiddleware = _ts_decorate15([
|
|
36298
|
+
(0, import_common15.Injectable)()
|
|
36494
36299
|
], HtmlHotUpdateViewMiddleware);
|
|
36495
36300
|
|
|
36496
36301
|
// src/modules/platform/module.ts
|
|
36497
|
-
function
|
|
36302
|
+
function _ts_decorate16(decorators, target, key, desc) {
|
|
36498
36303
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
36499
36304
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
36500
36305
|
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;
|
|
36501
36306
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
36502
36307
|
}
|
|
36503
|
-
__name(
|
|
36308
|
+
__name(_ts_decorate16, "_ts_decorate");
|
|
36504
36309
|
var PLATFORM_MODULE_OPTIONS = /* @__PURE__ */ Symbol("PLATFORM_MODULE_OPTIONS");
|
|
36505
36310
|
var PlatformModule = class _PlatformModule {
|
|
36506
36311
|
static {
|
|
@@ -36588,7 +36393,7 @@ var PlatformModule = class _PlatformModule {
|
|
|
36588
36393
|
},
|
|
36589
36394
|
{
|
|
36590
36395
|
provide: import_core2.APP_PIPE,
|
|
36591
|
-
useValue: new
|
|
36396
|
+
useValue: new import_common16.ValidationPipe({
|
|
36592
36397
|
transform: true,
|
|
36593
36398
|
transformOptions: {
|
|
36594
36399
|
enableImplicitConversion: true
|
|
@@ -36645,9 +36450,6 @@ var PlatformModule = class _PlatformModule {
|
|
|
36645
36450
|
if (process.env.NODE_ENV === "development") {
|
|
36646
36451
|
consumer.apply(FrameworkDebugMiddleware).forRoutes("/api/__framework__/debug");
|
|
36647
36452
|
}
|
|
36648
|
-
if (process.env.NODE_ENV !== "production") {
|
|
36649
|
-
consumer.apply(OpenApiSpecMiddleware).forRoutes("/api/__framework__/openapi-spec");
|
|
36650
|
-
}
|
|
36651
36453
|
consumer.apply(UserContextMiddleware, RequestContextMiddleware, import_nestjs_logger2.LoggerContextMiddleware, import_nestjs_observable.ObservableTraceMiddleware, ...DISABLE_DATAPASS ? [] : [
|
|
36652
36454
|
import_nestjs_datapaas.SqlExecutionContextMiddleware
|
|
36653
36455
|
]).forRoutes("/*");
|
|
@@ -36666,13 +36468,12 @@ var PlatformModule = class _PlatformModule {
|
|
|
36666
36468
|
}
|
|
36667
36469
|
}
|
|
36668
36470
|
};
|
|
36669
|
-
PlatformModule =
|
|
36670
|
-
(0,
|
|
36671
|
-
(0,
|
|
36471
|
+
PlatformModule = _ts_decorate16([
|
|
36472
|
+
(0, import_common16.Global)(),
|
|
36473
|
+
(0, import_common16.Module)({})
|
|
36672
36474
|
], PlatformModule);
|
|
36673
36475
|
|
|
36674
36476
|
// src/setup.ts
|
|
36675
|
-
var import_node_path4 = __toESM(require("path"), 1);
|
|
36676
36477
|
var import_nestjs_logger3 = require("@lark-apaas/nestjs-logger");
|
|
36677
36478
|
var import_cookie_parser = __toESM(require("cookie-parser"), 1);
|
|
36678
36479
|
var import_express = __toESM(require_express2(), 1);
|
|
@@ -36745,11 +36546,6 @@ async function configureApp(app, perms = defaultPerms) {
|
|
|
36745
36546
|
console.error("[OpenAPI] OpenAPI \u751F\u6210\u5931\u8D25:", err);
|
|
36746
36547
|
}
|
|
36747
36548
|
}
|
|
36748
|
-
if (process.env.NODE_ENV !== "production") {
|
|
36749
|
-
registerOpenApiSpecEndpoint(app, {
|
|
36750
|
-
openapiFile: import_node_path4.default.resolve(process.cwd(), "docs/openapi.json")
|
|
36751
|
-
});
|
|
36752
|
-
}
|
|
36753
36549
|
console.log("App Started Successfully.");
|
|
36754
36550
|
}
|
|
36755
36551
|
__name(configureApp, "configureApp");
|
|
@@ -36786,7 +36582,6 @@ var import_nestjs_authzpaas2 = require("@lark-apaas/nestjs-authzpaas");
|
|
|
36786
36582
|
ViewContextMiddleware,
|
|
36787
36583
|
configureApp,
|
|
36788
36584
|
createLegacyPathRedirectMiddleware,
|
|
36789
|
-
registerOpenApiSpecEndpoint,
|
|
36790
36585
|
...require("@lark-apaas/nestjs-authnpaas"),
|
|
36791
36586
|
...require("@lark-apaas/nestjs-capability"),
|
|
36792
36587
|
...require("@lark-apaas/nestjs-datapaas"),
|