@lark-apaas/fullstack-nestjs-core 1.1.12-alpha.12 → 1.1.12-alpha.14
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 +32 -84
- package/dist/index.js +32 -84
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -171,51 +171,6 @@ CsrfMiddleware = _ts_decorate2([
|
|
|
171
171
|
// src/middlewares/view-context/index.ts
|
|
172
172
|
var import_common3 = require("@nestjs/common");
|
|
173
173
|
var import_nestjs_common = require("@lark-apaas/nestjs-common");
|
|
174
|
-
|
|
175
|
-
// src/utils/safe-stringify.ts
|
|
176
|
-
function safeEscape(s) {
|
|
177
|
-
return s.replace(/[<>&='"\n\r\u2028\u2029]/g, function(c) {
|
|
178
|
-
switch (c.charCodeAt(0)) {
|
|
179
|
-
case 60:
|
|
180
|
-
return "\\u003c";
|
|
181
|
-
// <
|
|
182
|
-
case 62:
|
|
183
|
-
return "\\u003e";
|
|
184
|
-
// >
|
|
185
|
-
case 38:
|
|
186
|
-
return "\\u0026";
|
|
187
|
-
// &
|
|
188
|
-
case 61:
|
|
189
|
-
return "\\u003d";
|
|
190
|
-
// =
|
|
191
|
-
case 39:
|
|
192
|
-
return "\\u0027";
|
|
193
|
-
// '
|
|
194
|
-
case 34:
|
|
195
|
-
return "\\u0022";
|
|
196
|
-
// "
|
|
197
|
-
case 10:
|
|
198
|
-
return "\\u000a";
|
|
199
|
-
// \n
|
|
200
|
-
case 13:
|
|
201
|
-
return "\\u000d";
|
|
202
|
-
// \r
|
|
203
|
-
// 正常来说用户无法输入这几个字符, 现代浏览器也修复了这个问题
|
|
204
|
-
// https://zhuanlan.zhihu.com/p/29958439
|
|
205
|
-
case 8232:
|
|
206
|
-
return "\\u2028";
|
|
207
|
-
// 行分隔符
|
|
208
|
-
case 8233:
|
|
209
|
-
return "\\u2029";
|
|
210
|
-
// 段落分隔符
|
|
211
|
-
default:
|
|
212
|
-
return c;
|
|
213
|
-
}
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
__name(safeEscape, "safeEscape");
|
|
217
|
-
|
|
218
|
-
// src/middlewares/view-context/index.ts
|
|
219
174
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
220
175
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
221
176
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -266,13 +221,14 @@ var ViewContextMiddleware = class _ViewContextMiddleware {
|
|
|
266
221
|
const { userId, tenantId, appId } = req.userContext;
|
|
267
222
|
const csrfToken = req.csrfToken;
|
|
268
223
|
const appInfo = await this.getAppInfo(appId);
|
|
224
|
+
this.logger.debug(`appInfo: ${JSON.stringify(appInfo)}`);
|
|
269
225
|
req.__platform_data__ = {
|
|
270
226
|
csrfToken: csrfToken ?? "",
|
|
271
227
|
userId: userId ?? "",
|
|
272
228
|
appId: appId ?? "",
|
|
273
|
-
appName:
|
|
229
|
+
appName: appInfo?.app_name ?? "",
|
|
274
230
|
appAvatar: appInfo?.app_avatar ?? "",
|
|
275
|
-
appDescription:
|
|
231
|
+
appDescription: appInfo?.app_description ?? "",
|
|
276
232
|
tenantId
|
|
277
233
|
};
|
|
278
234
|
res.locals = {
|
|
@@ -281,9 +237,9 @@ var ViewContextMiddleware = class _ViewContextMiddleware {
|
|
|
281
237
|
userId: userId ?? "",
|
|
282
238
|
tenantId: tenantId ?? "",
|
|
283
239
|
appId: appId ?? "",
|
|
284
|
-
appName:
|
|
240
|
+
appName: appInfo?.app_name ?? "\u5999\u642D\u5E94\u7528",
|
|
285
241
|
appAvatar: appInfo?.app_avatar ?? "",
|
|
286
|
-
appDescription:
|
|
242
|
+
appDescription: appInfo?.app_description ?? ""
|
|
287
243
|
};
|
|
288
244
|
next();
|
|
289
245
|
}
|
|
@@ -765,9 +721,6 @@ PlatformHttpClientService = _ts_decorate8([
|
|
|
765
721
|
_ts_metadata5("design:paramtypes", [])
|
|
766
722
|
], PlatformHttpClientService);
|
|
767
723
|
|
|
768
|
-
// src/modules/platform/config/feature-switch.ts
|
|
769
|
-
var DISABLE_DATAPASS = process.env.FORCE_FRAMEWORK_DISABLE_DATAPASS === "true";
|
|
770
|
-
|
|
771
724
|
// src/modules/platform/module.ts
|
|
772
725
|
function _ts_decorate9(decorators, target, key, desc) {
|
|
773
726
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -804,37 +757,34 @@ var PlatformModule = class _PlatformModule {
|
|
|
804
757
|
timeout: 5e3,
|
|
805
758
|
maxRedirects: 5
|
|
806
759
|
}),
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
]
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
params
|
|
827
|
-
}), "Database");
|
|
828
|
-
}
|
|
760
|
+
import_nestjs_datapaas.DataPaasModule.forRootAsync({
|
|
761
|
+
imports: [
|
|
762
|
+
import_config2.ConfigModule,
|
|
763
|
+
import_nestjs_logger2.LoggerModule
|
|
764
|
+
],
|
|
765
|
+
inject: [
|
|
766
|
+
import_config2.ConfigService,
|
|
767
|
+
import_nestjs_logger2.AppLogger
|
|
768
|
+
],
|
|
769
|
+
useFactory: /* @__PURE__ */ __name(async (...args) => {
|
|
770
|
+
const configService = args[0];
|
|
771
|
+
const appLogger = args[1];
|
|
772
|
+
const drizzleLogger = {
|
|
773
|
+
logQuery(query, params) {
|
|
774
|
+
if (process.env.NODE_ENV === "development") {
|
|
775
|
+
appLogger.log?.("SQL Query " + JSON.stringify({
|
|
776
|
+
query,
|
|
777
|
+
params
|
|
778
|
+
}), "Database");
|
|
829
779
|
}
|
|
830
|
-
}
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
}
|
|
836
|
-
})
|
|
837
|
-
|
|
780
|
+
}
|
|
781
|
+
};
|
|
782
|
+
return {
|
|
783
|
+
connectionString: configService.get("app.databaseUrl") ?? "",
|
|
784
|
+
logger: drizzleLogger
|
|
785
|
+
};
|
|
786
|
+
}, "useFactory")
|
|
787
|
+
}),
|
|
838
788
|
import_nestjs_authnpaas.AuthNPaasModule.forRoot(),
|
|
839
789
|
import_nestjs_trigger.AutomationModule.forRoot()
|
|
840
790
|
],
|
|
@@ -920,7 +870,6 @@ async function configureApp(app, perms = defaultPerms) {
|
|
|
920
870
|
app.use((0, import_cookie_parser.default)());
|
|
921
871
|
const globalPrefix = process.env.CLIENT_BASE_PATH ?? "";
|
|
922
872
|
app.setGlobalPrefix(globalPrefix);
|
|
923
|
-
app.set("trust proxy", true);
|
|
924
873
|
if (process.env.NODE_ENV !== "production" && perms.disableSwagger !== true) {
|
|
925
874
|
try {
|
|
926
875
|
await import_nestjs_openapi_devtools.DevToolsV2Module.mount(app, {
|
|
@@ -932,7 +881,6 @@ async function configureApp(app, perms = defaultPerms) {
|
|
|
932
881
|
console.error("[OpenAPI] OpenAPI \u751F\u6210\u5931\u8D25:", err);
|
|
933
882
|
}
|
|
934
883
|
}
|
|
935
|
-
console.log("App Started Successfully.");
|
|
936
884
|
}
|
|
937
885
|
__name(configureApp, "configureApp");
|
|
938
886
|
|
package/dist/index.js
CHANGED
|
@@ -128,51 +128,6 @@ CsrfMiddleware = _ts_decorate2([
|
|
|
128
128
|
// src/middlewares/view-context/index.ts
|
|
129
129
|
import { Inject, Injectable as Injectable3, Logger } from "@nestjs/common";
|
|
130
130
|
import { PLATFORM_HTTP_CLIENT } from "@lark-apaas/nestjs-common";
|
|
131
|
-
|
|
132
|
-
// src/utils/safe-stringify.ts
|
|
133
|
-
function safeEscape(s) {
|
|
134
|
-
return s.replace(/[<>&='"\n\r\u2028\u2029]/g, function(c) {
|
|
135
|
-
switch (c.charCodeAt(0)) {
|
|
136
|
-
case 60:
|
|
137
|
-
return "\\u003c";
|
|
138
|
-
// <
|
|
139
|
-
case 62:
|
|
140
|
-
return "\\u003e";
|
|
141
|
-
// >
|
|
142
|
-
case 38:
|
|
143
|
-
return "\\u0026";
|
|
144
|
-
// &
|
|
145
|
-
case 61:
|
|
146
|
-
return "\\u003d";
|
|
147
|
-
// =
|
|
148
|
-
case 39:
|
|
149
|
-
return "\\u0027";
|
|
150
|
-
// '
|
|
151
|
-
case 34:
|
|
152
|
-
return "\\u0022";
|
|
153
|
-
// "
|
|
154
|
-
case 10:
|
|
155
|
-
return "\\u000a";
|
|
156
|
-
// \n
|
|
157
|
-
case 13:
|
|
158
|
-
return "\\u000d";
|
|
159
|
-
// \r
|
|
160
|
-
// 正常来说用户无法输入这几个字符, 现代浏览器也修复了这个问题
|
|
161
|
-
// https://zhuanlan.zhihu.com/p/29958439
|
|
162
|
-
case 8232:
|
|
163
|
-
return "\\u2028";
|
|
164
|
-
// 行分隔符
|
|
165
|
-
case 8233:
|
|
166
|
-
return "\\u2029";
|
|
167
|
-
// 段落分隔符
|
|
168
|
-
default:
|
|
169
|
-
return c;
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
__name(safeEscape, "safeEscape");
|
|
174
|
-
|
|
175
|
-
// src/middlewares/view-context/index.ts
|
|
176
131
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
177
132
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
178
133
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -223,13 +178,14 @@ var ViewContextMiddleware = class _ViewContextMiddleware {
|
|
|
223
178
|
const { userId, tenantId, appId } = req.userContext;
|
|
224
179
|
const csrfToken = req.csrfToken;
|
|
225
180
|
const appInfo = await this.getAppInfo(appId);
|
|
181
|
+
this.logger.debug(`appInfo: ${JSON.stringify(appInfo)}`);
|
|
226
182
|
req.__platform_data__ = {
|
|
227
183
|
csrfToken: csrfToken ?? "",
|
|
228
184
|
userId: userId ?? "",
|
|
229
185
|
appId: appId ?? "",
|
|
230
|
-
appName:
|
|
186
|
+
appName: appInfo?.app_name ?? "",
|
|
231
187
|
appAvatar: appInfo?.app_avatar ?? "",
|
|
232
|
-
appDescription:
|
|
188
|
+
appDescription: appInfo?.app_description ?? "",
|
|
233
189
|
tenantId
|
|
234
190
|
};
|
|
235
191
|
res.locals = {
|
|
@@ -238,9 +194,9 @@ var ViewContextMiddleware = class _ViewContextMiddleware {
|
|
|
238
194
|
userId: userId ?? "",
|
|
239
195
|
tenantId: tenantId ?? "",
|
|
240
196
|
appId: appId ?? "",
|
|
241
|
-
appName:
|
|
197
|
+
appName: appInfo?.app_name ?? "\u5999\u642D\u5E94\u7528",
|
|
242
198
|
appAvatar: appInfo?.app_avatar ?? "",
|
|
243
|
-
appDescription:
|
|
199
|
+
appDescription: appInfo?.app_description ?? ""
|
|
244
200
|
};
|
|
245
201
|
next();
|
|
246
202
|
}
|
|
@@ -722,9 +678,6 @@ PlatformHttpClientService = _ts_decorate8([
|
|
|
722
678
|
_ts_metadata5("design:paramtypes", [])
|
|
723
679
|
], PlatformHttpClientService);
|
|
724
680
|
|
|
725
|
-
// src/modules/platform/config/feature-switch.ts
|
|
726
|
-
var DISABLE_DATAPASS = process.env.FORCE_FRAMEWORK_DISABLE_DATAPASS === "true";
|
|
727
|
-
|
|
728
681
|
// src/modules/platform/module.ts
|
|
729
682
|
function _ts_decorate9(decorators, target, key, desc) {
|
|
730
683
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -761,37 +714,34 @@ var PlatformModule = class _PlatformModule {
|
|
|
761
714
|
timeout: 5e3,
|
|
762
715
|
maxRedirects: 5
|
|
763
716
|
}),
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
]
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
params
|
|
784
|
-
}), "Database");
|
|
785
|
-
}
|
|
717
|
+
DataPaasModule.forRootAsync({
|
|
718
|
+
imports: [
|
|
719
|
+
ConfigModule,
|
|
720
|
+
LoggerModule
|
|
721
|
+
],
|
|
722
|
+
inject: [
|
|
723
|
+
ConfigService,
|
|
724
|
+
AppLogger2
|
|
725
|
+
],
|
|
726
|
+
useFactory: /* @__PURE__ */ __name(async (...args) => {
|
|
727
|
+
const configService = args[0];
|
|
728
|
+
const appLogger = args[1];
|
|
729
|
+
const drizzleLogger = {
|
|
730
|
+
logQuery(query, params) {
|
|
731
|
+
if (process.env.NODE_ENV === "development") {
|
|
732
|
+
appLogger.log?.("SQL Query " + JSON.stringify({
|
|
733
|
+
query,
|
|
734
|
+
params
|
|
735
|
+
}), "Database");
|
|
786
736
|
}
|
|
787
|
-
}
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
}
|
|
793
|
-
})
|
|
794
|
-
|
|
737
|
+
}
|
|
738
|
+
};
|
|
739
|
+
return {
|
|
740
|
+
connectionString: configService.get("app.databaseUrl") ?? "",
|
|
741
|
+
logger: drizzleLogger
|
|
742
|
+
};
|
|
743
|
+
}, "useFactory")
|
|
744
|
+
}),
|
|
795
745
|
AuthNPaasModule.forRoot(),
|
|
796
746
|
AutomationModule.forRoot()
|
|
797
747
|
],
|
|
@@ -877,7 +827,6 @@ async function configureApp(app, perms = defaultPerms) {
|
|
|
877
827
|
app.use(cookieParser());
|
|
878
828
|
const globalPrefix = process.env.CLIENT_BASE_PATH ?? "";
|
|
879
829
|
app.setGlobalPrefix(globalPrefix);
|
|
880
|
-
app.set("trust proxy", true);
|
|
881
830
|
if (process.env.NODE_ENV !== "production" && perms.disableSwagger !== true) {
|
|
882
831
|
try {
|
|
883
832
|
await DevToolsV2Module.mount(app, {
|
|
@@ -889,7 +838,6 @@ async function configureApp(app, perms = defaultPerms) {
|
|
|
889
838
|
console.error("[OpenAPI] OpenAPI \u751F\u6210\u5931\u8D25:", err);
|
|
890
839
|
}
|
|
891
840
|
}
|
|
892
|
-
console.log("App Started Successfully.");
|
|
893
841
|
}
|
|
894
842
|
__name(configureApp, "configureApp");
|
|
895
843
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lark-apaas/fullstack-nestjs-core",
|
|
3
|
-
"version": "1.1.12-alpha.
|
|
3
|
+
"version": "1.1.12-alpha.14",
|
|
4
4
|
"description": "FullStack Nestjs Core",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -39,12 +39,12 @@
|
|
|
39
39
|
"prepublishOnly": "npm run build"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@lark-apaas/http-client": "0.1.2",
|
|
42
|
+
"@lark-apaas/http-client": "^0.1.2",
|
|
43
43
|
"@lark-apaas/nestjs-authnpaas": "^1.0.2",
|
|
44
|
-
"@lark-apaas/nestjs-common": "0.1.
|
|
44
|
+
"@lark-apaas/nestjs-common": "^0.1.1",
|
|
45
45
|
"@lark-apaas/nestjs-datapaas": "^1.0.7",
|
|
46
|
-
"@lark-apaas/nestjs-logger": "1.0.
|
|
47
|
-
"@lark-apaas/nestjs-observable": "0.0.
|
|
46
|
+
"@lark-apaas/nestjs-logger": "1.0.6-alpha.0",
|
|
47
|
+
"@lark-apaas/nestjs-observable": "^0.0.2",
|
|
48
48
|
"@lark-apaas/nestjs-openapi-devtools": "^1.0.9",
|
|
49
49
|
"@lark-apaas/nestjs-trigger": "^0.0.1",
|
|
50
50
|
"@nestjs/axios": "^4.0.1",
|
|
@@ -72,4 +72,4 @@
|
|
|
72
72
|
"class-validator": "^0.14.2",
|
|
73
73
|
"drizzle-orm": "0.44.6"
|
|
74
74
|
}
|
|
75
|
-
}
|
|
75
|
+
}
|