jcc-express-mvc 1.9.2 → 1.9.3
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/lib/Auth/AuthMiddleware.d.ts.map +1 -1
- package/lib/Auth/AuthMiddleware.js +13 -6
- package/lib/Cache/index.d.ts +2 -0
- package/lib/Cache/index.d.ts.map +1 -1
- package/lib/Cache/index.js +101 -6
- package/lib/Command-Line/NodeArtisanCommand.d.ts +5 -0
- package/lib/Command-Line/NodeArtisanCommand.d.ts.map +1 -1
- package/lib/Command-Line/NodeArtisanCommand.js +52 -1
- package/lib/Command-Line/WatchCommand.d.ts +12 -2
- package/lib/Command-Line/WatchCommand.d.ts.map +1 -1
- package/lib/Command-Line/WatchCommand.js +186 -45
- package/lib/Error/AppErrorHandler.d.ts.map +1 -1
- package/lib/Error/AppErrorHandler.js +4 -0
- package/lib/Error/ModelExceptions/ModelTokenError.d.ts +4 -0
- package/lib/Error/ModelExceptions/ModelTokenError.d.ts.map +1 -0
- package/lib/Error/ModelExceptions/ModelTokenError.js +10 -0
- package/lib/Http/index.d.ts +3 -0
- package/lib/Http/index.d.ts.map +1 -1
- package/lib/Http/index.js +46 -10
- package/lib/Jcc-eloquent/lib/Model.d.ts +2 -0
- package/lib/Jcc-eloquent/lib/Model.d.ts.map +1 -1
- package/lib/Jcc-eloquent/lib/Model.js +13 -1
- package/lib/Mail/Manager.d.ts +2 -0
- package/lib/Mail/Manager.d.ts.map +1 -1
- package/lib/Mail/Manager.js +39 -2
- package/lib/Monitor/Collectors/CacheCollector.d.ts +2 -4
- package/lib/Monitor/Collectors/CacheCollector.d.ts.map +1 -1
- package/lib/Monitor/Collectors/CacheCollector.js +4 -63
- package/lib/Monitor/Collectors/CommandCollector.d.ts +3 -4
- package/lib/Monitor/Collectors/CommandCollector.d.ts.map +1 -1
- package/lib/Monitor/Collectors/CommandCollector.js +3 -4
- package/lib/Monitor/Collectors/DatabaseCollector.d.ts +2 -0
- package/lib/Monitor/Collectors/DatabaseCollector.d.ts.map +1 -1
- package/lib/Monitor/Collectors/DatabaseCollector.js +8 -1
- package/lib/Monitor/Collectors/MailCollector.d.ts +2 -4
- package/lib/Monitor/Collectors/MailCollector.d.ts.map +1 -1
- package/lib/Monitor/Collectors/MailCollector.js +5 -58
- package/lib/Monitor/Collectors/OutgoingRequestCollector.d.ts +3 -4
- package/lib/Monitor/Collectors/OutgoingRequestCollector.d.ts.map +1 -1
- package/lib/Monitor/Collectors/OutgoingRequestCollector.js +6 -8
- package/lib/Monitor/Collectors/ScheduleCollector.d.ts +2 -3
- package/lib/Monitor/Collectors/ScheduleCollector.d.ts.map +1 -1
- package/lib/Monitor/Collectors/ScheduleCollector.js +2 -3
- package/lib/Monitor/Controllers/MonitorController.d.ts +1 -0
- package/lib/Monitor/Controllers/MonitorController.d.ts.map +1 -1
- package/lib/Monitor/Controllers/MonitorController.js +15 -8
- package/lib/Monitor/MonitorManager.d.ts +10 -1
- package/lib/Monitor/MonitorManager.d.ts.map +1 -1
- package/lib/Monitor/MonitorManager.js +39 -1
- package/lib/Monitor/MonitorServiceProvider.d.ts.map +1 -1
- package/lib/Monitor/MonitorServiceProvider.js +3 -1
- package/lib/Monitor/index.d.ts +1 -0
- package/lib/Monitor/index.d.ts.map +1 -1
- package/lib/Monitor/index.js +1 -0
- package/lib/Monitor/types.d.ts +3 -1
- package/lib/Monitor/types.d.ts.map +1 -1
- package/lib/Monitor/types.js +13 -2
- package/lib/Queue/Queue.d.ts +4 -0
- package/lib/Queue/Queue.d.ts.map +1 -1
- package/lib/Queue/Queue.js +55 -0
- package/lib/Schedule/Scheduler.d.ts +2 -0
- package/lib/Schedule/Scheduler.d.ts.map +1 -1
- package/lib/Schedule/Scheduler.js +28 -1
- package/lib/Server/index.d.ts +2 -0
- package/lib/Server/index.d.ts.map +1 -1
- package/lib/Server/index.js +12 -1
- package/lib/Templating-engine/engineHelper.d.ts +2 -2
- package/lib/Templating-engine/engineHelper.d.ts.map +1 -1
- package/lib/Templating-engine/engineHelper.js +5 -2
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthMiddleware.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Auth/AuthMiddleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAUhE,cAAM,cAAc;IAClB,qCAAqC;IACxB,OAAO,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO;
|
|
1
|
+
{"version":3,"file":"AuthMiddleware.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Auth/AuthMiddleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAUhE,cAAM,cAAc;IAClB,qCAAqC;IACxB,OAAO,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO;IAkCxD,IAAI,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO;IAmC3D,KAAK,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO;CAgB9D;AAED,eAAO,MAAM,cAAc,gBAAuB,CAAC"}
|
|
@@ -15,15 +15,22 @@ class AuthMiddleware {
|
|
|
15
15
|
if (!(0, util_1.checkJwtAccessTokenPayload)(payload).ok) {
|
|
16
16
|
return res.status(401).json({ message: "Not authorized" });
|
|
17
17
|
}
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
const { exp, iat, typ, ...data } = payload;
|
|
19
|
+
const orm = Config_1.config.get("DB_ORM");
|
|
20
|
+
let user;
|
|
21
|
+
if (orm === "mongodb" || orm === "mongoose") {
|
|
22
|
+
user = await User.findOne({ ...data });
|
|
23
|
+
}
|
|
24
|
+
else if (orm === "sequelize") {
|
|
25
|
+
user = await User.findOne({ where: { ...data } });
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
user = await User.where({ ...data }).first();
|
|
29
|
+
}
|
|
23
30
|
if (!user)
|
|
24
31
|
return res.status(401).json({ message: "Not authorized" });
|
|
25
32
|
req.user = user;
|
|
26
|
-
req.id = String(id);
|
|
33
|
+
req.id = String(data?.id);
|
|
27
34
|
next();
|
|
28
35
|
}
|
|
29
36
|
catch (err) {
|
package/lib/Cache/index.d.ts
CHANGED
|
@@ -23,6 +23,8 @@ export declare class Cache {
|
|
|
23
23
|
pull<T = any>(key: string, fallback?: T | (() => T) | (() => Promise<T>)): Promise<T | null>;
|
|
24
24
|
add<T = any>(key: string, value: T, seconds?: number): Promise<boolean>;
|
|
25
25
|
tags(tags: string[]): TaggedCache;
|
|
26
|
+
private monitorCacheEnabled;
|
|
27
|
+
private recordCacheOp;
|
|
26
28
|
}
|
|
27
29
|
export { Cache as CacheManager };
|
|
28
30
|
export { CacheFacade, CacheFacde } from "./CacheFacade";
|
package/lib/Cache/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Cache/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Cache/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAMxD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAmB5C,qBAAa,KAAK;IAChB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAQ;IAC/B,OAAO,CAAC,OAAO,CAAuC;IACtD,OAAO,CAAC,MA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AG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIlC,QAAQ,CAAC,CAAC,EACd,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GAC7B,OAAO,CAAC,CAAC,CAAC;IAoCP,eAAe,CAAC,CAAC,GAAG,GAAG,EAC3B,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GAC7B,OAAO,CAAC,CAAC,CAAC;IAgCP,IAAI,CAAC,CAAC,GAAG,GAAG,EAChB,GAAG,EAAE,MAAM,EACX,QAAQ,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC,GAC5C,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IASd,GAAG,CAAC,CAAC,GAAG,GAAG,EACf,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,CAAC,EACR,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,OAAO,CAAC;IASnB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,WAAW;IAIjC,OAAO,CAAC,mBAAmB;IAK3B,OAAO,CAAC,aAAa;CAUtB;AACD,OAAO,EAAE,KAAK,IAAI,YAAY,EAAE,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC"}
|
package/lib/Cache/index.js
CHANGED
|
@@ -34,11 +34,14 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.CacheFacde = exports.CacheFacade = exports.CacheManager = exports.Cache = void 0;
|
|
37
|
+
const Monitor_1 = require("../Monitor");
|
|
38
|
+
const MonitorManager_1 = require("../Monitor/MonitorManager");
|
|
37
39
|
const MemoryDriver_1 = require("./MemoryDriver");
|
|
38
40
|
const RedisDriver_1 = require("./RedisDriver");
|
|
39
41
|
const FileCacheDriver_1 = require("./FileCacheDriver");
|
|
40
42
|
const TaggedCache_1 = require("./TaggedCache");
|
|
41
43
|
const path = __importStar(require("path"));
|
|
44
|
+
const perf_hooks_1 = require("perf_hooks");
|
|
42
45
|
// CacheDriver is imported from ../Interface
|
|
43
46
|
const fallbackCacheConfig = {
|
|
44
47
|
default: "memory",
|
|
@@ -106,10 +109,24 @@ class Cache {
|
|
|
106
109
|
if (!key) {
|
|
107
110
|
throw new Error("Cache key must be provided");
|
|
108
111
|
}
|
|
112
|
+
const startedAt = perf_hooks_1.performance.now();
|
|
113
|
+
const storeName = this.config.default;
|
|
109
114
|
const value = await this.store().get(key);
|
|
110
115
|
if (value !== null && value !== undefined) {
|
|
116
|
+
this.recordCacheOp({
|
|
117
|
+
op: "hit",
|
|
118
|
+
key,
|
|
119
|
+
store: storeName,
|
|
120
|
+
durationMs: Number((perf_hooks_1.performance.now() - startedAt).toFixed(2)),
|
|
121
|
+
});
|
|
111
122
|
return value;
|
|
112
123
|
}
|
|
124
|
+
this.recordCacheOp({
|
|
125
|
+
op: "miss",
|
|
126
|
+
key,
|
|
127
|
+
store: storeName,
|
|
128
|
+
durationMs: Number((perf_hooks_1.performance.now() - startedAt).toFixed(2)),
|
|
129
|
+
});
|
|
113
130
|
if (fallback !== undefined) {
|
|
114
131
|
return typeof fallback === "function"
|
|
115
132
|
? await fallback()
|
|
@@ -127,16 +144,46 @@ class Cache {
|
|
|
127
144
|
if (seconds !== undefined && (isNaN(seconds) || seconds < 0)) {
|
|
128
145
|
throw new Error("Cache TTL must be a positive number");
|
|
129
146
|
}
|
|
130
|
-
|
|
147
|
+
const startedAt = perf_hooks_1.performance.now();
|
|
148
|
+
await this.store().put(key, value, seconds);
|
|
149
|
+
this.recordCacheOp({
|
|
150
|
+
op: "write",
|
|
151
|
+
key,
|
|
152
|
+
store: this.config.default,
|
|
153
|
+
ttl: seconds,
|
|
154
|
+
durationMs: Number((perf_hooks_1.performance.now() - startedAt).toFixed(2)),
|
|
155
|
+
});
|
|
131
156
|
}
|
|
132
157
|
async forget(key) {
|
|
133
|
-
|
|
158
|
+
const startedAt = perf_hooks_1.performance.now();
|
|
159
|
+
const result = await this.store().forget(key);
|
|
160
|
+
this.recordCacheOp({
|
|
161
|
+
op: "forget",
|
|
162
|
+
key,
|
|
163
|
+
store: this.config.default,
|
|
164
|
+
durationMs: Number((perf_hooks_1.performance.now() - startedAt).toFixed(2)),
|
|
165
|
+
});
|
|
166
|
+
return result;
|
|
134
167
|
}
|
|
135
168
|
async flush() {
|
|
136
|
-
|
|
169
|
+
const startedAt = perf_hooks_1.performance.now();
|
|
170
|
+
await this.store().flush();
|
|
171
|
+
this.recordCacheOp({
|
|
172
|
+
op: "forget",
|
|
173
|
+
key: "*",
|
|
174
|
+
store: this.config.default,
|
|
175
|
+
durationMs: Number((perf_hooks_1.performance.now() - startedAt).toFixed(2)),
|
|
176
|
+
});
|
|
137
177
|
}
|
|
138
178
|
async forever(key, value) {
|
|
139
|
-
|
|
179
|
+
const startedAt = perf_hooks_1.performance.now();
|
|
180
|
+
await this.store().forever(key, value);
|
|
181
|
+
this.recordCacheOp({
|
|
182
|
+
op: "write",
|
|
183
|
+
key,
|
|
184
|
+
store: this.config.default,
|
|
185
|
+
durationMs: Number((perf_hooks_1.performance.now() - startedAt).toFixed(2)),
|
|
186
|
+
});
|
|
140
187
|
}
|
|
141
188
|
async increment(key, value) {
|
|
142
189
|
return this.store().increment(key, value);
|
|
@@ -166,7 +213,27 @@ class Cache {
|
|
|
166
213
|
if (typeof callback !== "function") {
|
|
167
214
|
throw new Error("Callback must be a function");
|
|
168
215
|
}
|
|
169
|
-
|
|
216
|
+
const startedAt = perf_hooks_1.performance.now();
|
|
217
|
+
const storeName = this.config.default;
|
|
218
|
+
const cached = await this.store().get(key);
|
|
219
|
+
if (cached !== null && cached !== undefined) {
|
|
220
|
+
this.recordCacheOp({
|
|
221
|
+
op: "hit",
|
|
222
|
+
key,
|
|
223
|
+
store: storeName,
|
|
224
|
+
durationMs: Number((perf_hooks_1.performance.now() - startedAt).toFixed(2)),
|
|
225
|
+
});
|
|
226
|
+
return cached;
|
|
227
|
+
}
|
|
228
|
+
const result = await this.store().remember(key, seconds, callback);
|
|
229
|
+
this.recordCacheOp({
|
|
230
|
+
op: "write",
|
|
231
|
+
key,
|
|
232
|
+
store: storeName,
|
|
233
|
+
ttl: seconds,
|
|
234
|
+
durationMs: Number((perf_hooks_1.performance.now() - startedAt).toFixed(2)),
|
|
235
|
+
});
|
|
236
|
+
return result;
|
|
170
237
|
}
|
|
171
238
|
// Laravel-like rememberForever method
|
|
172
239
|
async rememberForever(key, callback) {
|
|
@@ -176,7 +243,26 @@ class Cache {
|
|
|
176
243
|
if (typeof callback !== "function") {
|
|
177
244
|
throw new Error("Callback must be a function");
|
|
178
245
|
}
|
|
179
|
-
|
|
246
|
+
const startedAt = perf_hooks_1.performance.now();
|
|
247
|
+
const storeName = this.config.default;
|
|
248
|
+
const cached = await this.store().get(key);
|
|
249
|
+
if (cached !== null && cached !== undefined) {
|
|
250
|
+
this.recordCacheOp({
|
|
251
|
+
op: "hit",
|
|
252
|
+
key,
|
|
253
|
+
store: storeName,
|
|
254
|
+
durationMs: Number((perf_hooks_1.performance.now() - startedAt).toFixed(2)),
|
|
255
|
+
});
|
|
256
|
+
return cached;
|
|
257
|
+
}
|
|
258
|
+
const result = await this.store().rememberForever(key, callback);
|
|
259
|
+
this.recordCacheOp({
|
|
260
|
+
op: "write",
|
|
261
|
+
key,
|
|
262
|
+
store: storeName,
|
|
263
|
+
durationMs: Number((perf_hooks_1.performance.now() - startedAt).toFixed(2)),
|
|
264
|
+
});
|
|
265
|
+
return result;
|
|
180
266
|
}
|
|
181
267
|
// Laravel-like pull method (get and forget)
|
|
182
268
|
async pull(key, fallback) {
|
|
@@ -198,6 +284,15 @@ class Cache {
|
|
|
198
284
|
tags(tags) {
|
|
199
285
|
return new TaggedCache_1.TaggedCache(this, tags);
|
|
200
286
|
}
|
|
287
|
+
monitorCacheEnabled() {
|
|
288
|
+
const mgr = MonitorManager_1.MonitorManager.getInstance();
|
|
289
|
+
return mgr.config.enabled && mgr.config.collectors.cache.enabled;
|
|
290
|
+
}
|
|
291
|
+
recordCacheOp(payload) {
|
|
292
|
+
if (!this.monitorCacheEnabled())
|
|
293
|
+
return;
|
|
294
|
+
Monitor_1.Monitor.recordCacheOp({ ...payload, timestamp: Date.now() });
|
|
295
|
+
}
|
|
201
296
|
}
|
|
202
297
|
exports.Cache = Cache;
|
|
203
298
|
exports.CacheManager = Cache;
|
|
@@ -25,6 +25,11 @@ export declare class ConsoleKernel {
|
|
|
25
25
|
private loadCustomCommands;
|
|
26
26
|
private defineCommand;
|
|
27
27
|
/** Wrap action with error handling; call process.exit when done (unless longRunning) */
|
|
28
|
+
/** Boot Monitor in CLI processes so file/redis/database persistence is active. */
|
|
29
|
+
private ensureMonitorForCli;
|
|
30
|
+
private monitorCommandsEnabled;
|
|
31
|
+
private recordCommandRun;
|
|
32
|
+
private finishCommandRun;
|
|
28
33
|
private runAction;
|
|
29
34
|
private defineActions;
|
|
30
35
|
private showHelp;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeArtisanCommand.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Command-Line/NodeArtisanCommand.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"NodeArtisanCommand.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Command-Line/NodeArtisanCommand.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA4CpC,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiB;IACzC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAK1B;IACF,OAAO,CAAC,cAAc,CAA0B;IAChD,OAAO,CAAC,QAAQ,CAAwB;IACxC,OAAO,CAAC,GAAG,CAA0B;IACrC,OAAO,CAAC,KAAK,CAA4B;IACzC,OAAO,CAAC,MAAM,CAA6B;IAC3C,OAAO,CAAC,SAAS,CAAgC;IACjD,OAAO,CAAC,MAAM,CAA6B;IAC3C,OAAO,CAAC,IAAI,CAAc;IAC1B,OAAO,CAAC,MAAM,CAA6B;IAE3C,OAAO,KAAK,OAAO,GAElB;IAED,OAAO,KAAK,EAAE,GAEb;IAED,OAAO,KAAK,IAAI,GAEf;IAED,OAAO,KAAK,KAAK,GAEhB;IAED,OAAO,KAAK,QAAQ,GAEnB;IAED,OAAO,KAAK,KAAK,GAEhB;IAED,OAAO,KAAK,KAAK,GAEhB;IAED,OAAO,CAAC,GAAG;;IAWX,0FAA0F;IAC1F,OAAO,CAAC,kBAAkB;IA0B1B,OAAO,CAAC,aAAa;IAQrB,wFAAwF;IACxF,kFAAkF;YACpE,mBAAmB;IAQjC,OAAO,CAAC,sBAAsB;IAK9B,OAAO,CAAC,gBAAgB;YAWV,gBAAgB;IAW9B,OAAO,CAAC,SAAS;IAkDjB,OAAO,CAAC,aAAa;IAkQrB,OAAO,CAAC,QAAQ;IA+JhB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;CA4BpD"}
|
|
@@ -22,6 +22,9 @@ const KeyGenerateCommand_1 = require("./KeyGenerateCommand");
|
|
|
22
22
|
const Tinker_1 = require("./NodeTinker/Tinker");
|
|
23
23
|
const WatchCommand_1 = require("./WatchCommand");
|
|
24
24
|
const util_1 = require("../util");
|
|
25
|
+
const perf_hooks_1 = require("perf_hooks");
|
|
26
|
+
const Monitor_1 = require("../Monitor");
|
|
27
|
+
const MonitorManager_1 = require("../Monitor/MonitorManager");
|
|
25
28
|
const CacheCommand_1 = require("./CacheCommand");
|
|
26
29
|
const PublishCommand_1 = require("./PublishCommand");
|
|
27
30
|
/** Parse key=value from secondArg (e.g. steps=2, class=UserSeeder) */
|
|
@@ -108,14 +111,62 @@ class ConsoleKernel {
|
|
|
108
111
|
.argument("[thirdArg]");
|
|
109
112
|
}
|
|
110
113
|
/** Wrap action with error handling; call process.exit when done (unless longRunning) */
|
|
114
|
+
/** Boot Monitor in CLI processes so file/redis/database persistence is active. */
|
|
115
|
+
async ensureMonitorForCli() {
|
|
116
|
+
this._app.boot();
|
|
117
|
+
const manager = MonitorManager_1.MonitorManager.getInstance();
|
|
118
|
+
if (!manager.isStarted) {
|
|
119
|
+
await manager.start();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
monitorCommandsEnabled() {
|
|
123
|
+
const mgr = MonitorManager_1.MonitorManager.getInstance();
|
|
124
|
+
return mgr.config.enabled && mgr.config.collectors.commands.enabled;
|
|
125
|
+
}
|
|
126
|
+
recordCommandRun(payload) {
|
|
127
|
+
if (!this.monitorCommandsEnabled())
|
|
128
|
+
return;
|
|
129
|
+
Monitor_1.Monitor.recordCommand({ ...payload, timestamp: Date.now() });
|
|
130
|
+
}
|
|
131
|
+
async finishCommandRun(payload) {
|
|
132
|
+
this.recordCommandRun(payload);
|
|
133
|
+
await MonitorManager_1.MonitorManager.getInstance().flush();
|
|
134
|
+
}
|
|
111
135
|
runAction(handler, options = { exit: true }) {
|
|
112
136
|
return async (firstArg, secondArg, thirdArg) => {
|
|
137
|
+
const command = process.argv[2] ?? "unknown";
|
|
138
|
+
const args = [firstArg, secondArg, thirdArg].filter(Boolean);
|
|
139
|
+
const startedAt = perf_hooks_1.performance.now();
|
|
113
140
|
try {
|
|
141
|
+
await this.ensureMonitorForCli();
|
|
142
|
+
if (options.exit === false) {
|
|
143
|
+
await this.finishCommandRun({
|
|
144
|
+
command,
|
|
145
|
+
args,
|
|
146
|
+
status: "running",
|
|
147
|
+
durationMs: 0,
|
|
148
|
+
});
|
|
149
|
+
}
|
|
114
150
|
await handler(firstArg ?? "", secondArg ?? "", thirdArg ?? "");
|
|
115
|
-
if (options.exit !== false)
|
|
151
|
+
if (options.exit !== false) {
|
|
152
|
+
await this.finishCommandRun({
|
|
153
|
+
command,
|
|
154
|
+
args,
|
|
155
|
+
status: "success",
|
|
156
|
+
durationMs: Number((perf_hooks_1.performance.now() - startedAt).toFixed(2)),
|
|
157
|
+
exitCode: 0,
|
|
158
|
+
});
|
|
116
159
|
process.exit(0);
|
|
160
|
+
}
|
|
117
161
|
}
|
|
118
162
|
catch (err) {
|
|
163
|
+
await this.finishCommandRun({
|
|
164
|
+
command,
|
|
165
|
+
args,
|
|
166
|
+
status: "failed",
|
|
167
|
+
durationMs: Number((perf_hooks_1.performance.now() - startedAt).toFixed(2)),
|
|
168
|
+
exitCode: 1,
|
|
169
|
+
});
|
|
119
170
|
console.error(colors_1.default.red("\n❌ Error:"), err instanceof Error ? err.message : err);
|
|
120
171
|
process.exit(1);
|
|
121
172
|
}
|
|
@@ -6,6 +6,9 @@ export declare class WatchCommand {
|
|
|
6
6
|
private watchers;
|
|
7
7
|
private child;
|
|
8
8
|
private restartTimer;
|
|
9
|
+
private hotPollTimer;
|
|
10
|
+
private hotFileActive;
|
|
11
|
+
private hotWasPresent;
|
|
9
12
|
private isRestarting;
|
|
10
13
|
private suppressNextExitLog;
|
|
11
14
|
private pendingChanges;
|
|
@@ -14,16 +17,23 @@ export declare class WatchCommand {
|
|
|
14
17
|
private entryFile;
|
|
15
18
|
run(entryFile?: string): Promise<void>;
|
|
16
19
|
private refreshWatchers;
|
|
20
|
+
/** Vite writes public/hot when the dev server starts — watch it reliably. */
|
|
21
|
+
private watchPublicHot;
|
|
22
|
+
private syncHotFileWatcher;
|
|
23
|
+
private onPublicHotChanged;
|
|
17
24
|
private collectWatchDirectories;
|
|
18
25
|
private walkDirectories;
|
|
19
26
|
private onFileChanged;
|
|
20
27
|
private shouldIgnore;
|
|
21
28
|
private startServer;
|
|
22
29
|
private restartServer;
|
|
30
|
+
private getConfiguredPort;
|
|
31
|
+
private isPortFree;
|
|
32
|
+
private waitForPortFree;
|
|
23
33
|
private stopServer;
|
|
24
34
|
private closeWatchers;
|
|
35
|
+
private teardownHotWatcher;
|
|
25
36
|
private installSignalHandlers;
|
|
26
|
-
private
|
|
27
|
-
private clearTerminal;
|
|
37
|
+
private renderInitialHeader;
|
|
28
38
|
}
|
|
29
39
|
//# sourceMappingURL=WatchCommand.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WatchCommand.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Command-Line/WatchCommand.ts"],"names":[],"mappings":"AAOA,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAoB;IAC7C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAWzB;IACH,OAAO,CAAC,QAAQ,CAAC,mBAAmB,
|
|
1
|
+
{"version":3,"file":"WatchCommand.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Command-Line/WatchCommand.ts"],"names":[],"mappings":"AAOA,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAoB;IAC7C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAWzB;IACH,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAWlC;IACF,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAqB;IAEtD,OAAO,CAAC,QAAQ,CAAsB;IACtC,OAAO,CAAC,KAAK,CAA6B;IAC1C,OAAO,CAAC,YAAY,CAA+B;IACnD,OAAO,CAAC,YAAY,CAA+B;IACnD,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,mBAAmB,CAAS;IACpC,OAAO,CAAC,cAAc,CAAqB;IAC3C,OAAO,CAAC,aAAa,CAAK;IAC1B,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAO;IACvC,OAAO,CAAC,SAAS,C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