@loopstack/api 0.12.2 → 0.13.0
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/CHANGELOG.md +13 -0
- package/dist/controllers/config.controller.js +2 -1
- package/dist/controllers/config.controller.js.map +1 -1
- package/dist/controllers/sse.controller.d.ts +15 -0
- package/dist/controllers/sse.controller.js +82 -0
- package/dist/controllers/sse.controller.js.map +1 -0
- package/dist/loopstack-api.module.js +7 -16
- package/dist/loopstack-api.module.js.map +1 -1
- package/dist/services/dashboard.service.d.ts +3 -6
- package/dist/services/dashboard.service.js +8 -19
- package/dist/services/dashboard.service.js.map +1 -1
- package/dist/services/pipeline-api.service.js +2 -2
- package/dist/services/pipeline-api.service.js.map +1 -1
- package/dist/services/processor-api.service.js +2 -1
- package/dist/services/processor-api.service.js.map +1 -1
- package/dist/services/sse-event.service.d.ts +13 -0
- package/dist/services/sse-event.service.js +85 -0
- package/dist/services/sse-event.service.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @loopstack/api
|
|
2
2
|
|
|
3
|
+
## 0.13.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 41aabbf: Use local frontend without authentication
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [41aabbf]
|
|
12
|
+
- @loopstack/auth@0.13.0
|
|
13
|
+
- @loopstack/core@0.13.0
|
|
14
|
+
- @loopstack/shared@0.13.0
|
|
15
|
+
|
|
3
16
|
## 0.12.2
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -11,6 +11,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
12
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
13
|
};
|
|
14
|
+
var _a;
|
|
14
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
16
|
exports.ConfigController = void 0;
|
|
16
17
|
const swagger_1 = require("@nestjs/swagger");
|
|
@@ -93,6 +94,6 @@ exports.ConfigController = ConfigController = __decorate([
|
|
|
93
94
|
(0, swagger_1.ApiExtraModels)(workspace_config_dto_1.WorkspaceConfigDto, pipeline_config_dto_1.PipelineConfigDto),
|
|
94
95
|
(0, common_1.UsePipes)(new common_1.ValidationPipe({ transform: true, whitelist: true })),
|
|
95
96
|
(0, common_1.Controller)('api/v1/config'),
|
|
96
|
-
__metadata("design:paramtypes", [core_1.BlockRegistryService])
|
|
97
|
+
__metadata("design:paramtypes", [typeof (_a = typeof core_1.BlockRegistryService !== "undefined" && core_1.BlockRegistryService) === "function" ? _a : Object])
|
|
97
98
|
], ConfigController);
|
|
98
99
|
//# sourceMappingURL=config.controller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.controller.js","sourceRoot":"","sources":["../../src/controllers/config.controller.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.controller.js","sourceRoot":"","sources":["../../src/controllers/config.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAOyB;AACzB,2CAOwB;AAKxB,0CAAqF;AACrF,yDAAoD;AACpD,qEAAgE;AAChE,uEAAkE;AAClE,mCAAgC;AAMzB,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAER;IADnB,YACmB,oBAA0C;QAA1C,yBAAoB,GAApB,oBAAoB,CAAsB;IAC1D,CAAC;IAMJ,iBAAiB;QAEf,MAAM,MAAM,GAAG,IAAI,CAAC,oBAAoB,CAAC,eAAe,CAAC,gBAAS,CAAC,CAAC;QAEpE,MAAM,eAAe,GAAG,MAAM;aAC3B,GAAG,CAAC,CAAC,KAAwB,EAAE,EAAE;YAChC,MAAM,MAAM,GAAG,KAAK,CAAC,MAAuB,CAAC;YAC7C,OA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AY,EAAC,EAAE,OAAO,EAAE,6CAA6C,EAAE,CAAC;IACxE,IAAA,uBAAa,EAAC,EAAE,IAAI,EAAE,yCAAkB,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC1D,IAAA,iCAAuB,GAAE;;;;yDAiBzB;AAaD;IAXC,IAAA,YAAG,EAAC,0CAA0C,CAAC;IAC/C,IAAA,sBAAY,EAAC;QACZ,OAAO,EAAE,qDAAqD;KAC/D,CAAC;IACD,IAAA,kBAAQ,EAAC;QACR,IAAI,EAAE,oBAAoB;QAC1B,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE,sCAAsC;KACpD,CAAC;IACD,IAAA,uBAAa,EAAC,EAAE,IAAI,EAAE,uCAAiB,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IACzD,IAAA,iCAAuB,GAAE;IAEvB,WAAA,IAAA,cAAK,EAAC,oBAAoB,CAAC,CAAA;;;;mEAyB7B;2BAhEU,gBAAgB;IAJ5B,IAAA,iBAAO,EAAC,eAAe,CAAC;IACxB,IAAA,wBAAc,EAAC,yCAAkB,EAAE,uCAAiB,CAAC;IACrD,IAAA,iBAAQ,EAAC,IAAI,uBAAc,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAClE,IAAA,mBAAU,EAAC,eAAe,CAAC;yDAGe,2BAAoB,oBAApB,2BAAoB;GAFlD,gBAAgB,CAiE5B"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { MessageEvent } from '@nestjs/common';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { SseEventService } from '../services/sse-event.service';
|
|
4
|
+
import { CurrentUserInterface } from '@loopstack/shared';
|
|
5
|
+
import { Request } from 'express';
|
|
6
|
+
export declare class SseController {
|
|
7
|
+
private readonly sseEventService;
|
|
8
|
+
private readonly logger;
|
|
9
|
+
constructor(sseEventService: SseEventService);
|
|
10
|
+
stream(user: CurrentUserInterface, request: Request): Observable<MessageEvent>;
|
|
11
|
+
health(): {
|
|
12
|
+
active_connections: number;
|
|
13
|
+
connections: string[];
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var SseController_1;
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.SseController = void 0;
|
|
17
|
+
const common_1 = require("@nestjs/common");
|
|
18
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
19
|
+
const rxjs_1 = require("rxjs");
|
|
20
|
+
const operators_1 = require("rxjs/operators");
|
|
21
|
+
const sse_event_service_1 = require("../services/sse-event.service");
|
|
22
|
+
const shared_1 = require("@loopstack/shared");
|
|
23
|
+
let SseController = SseController_1 = class SseController {
|
|
24
|
+
sseEventService;
|
|
25
|
+
logger = new common_1.Logger(SseController_1.name);
|
|
26
|
+
constructor(sseEventService) {
|
|
27
|
+
this.sseEventService = sseEventService;
|
|
28
|
+
}
|
|
29
|
+
stream(user, request) {
|
|
30
|
+
const workerId = user.workerId;
|
|
31
|
+
const userId = user.userId;
|
|
32
|
+
const messageSubject = this.sseEventService.registerConnection(workerId, userId);
|
|
33
|
+
request.on('close', () => {
|
|
34
|
+
this.sseEventService.unregisterConnection(workerId, userId);
|
|
35
|
+
});
|
|
36
|
+
return messageSubject.pipe((0, operators_1.map)((message) => ({
|
|
37
|
+
data: message,
|
|
38
|
+
type: message.type,
|
|
39
|
+
})));
|
|
40
|
+
}
|
|
41
|
+
health() {
|
|
42
|
+
return {
|
|
43
|
+
active_connections: this.sseEventService.getConnectionCount(),
|
|
44
|
+
connections: this.sseEventService.getActiveConnections(),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
exports.SseController = SseController;
|
|
49
|
+
__decorate([
|
|
50
|
+
(0, common_1.Sse)('stream'),
|
|
51
|
+
(0, swagger_1.ApiOperation)({
|
|
52
|
+
summary: 'Server-Sent Events stream',
|
|
53
|
+
description: 'Establishes a Server-Sent Events connection to receive real-time updates',
|
|
54
|
+
}),
|
|
55
|
+
(0, swagger_1.ApiOkResponse)({
|
|
56
|
+
description: 'SSE stream established successfully',
|
|
57
|
+
}),
|
|
58
|
+
__param(0, (0, shared_1.CurrentUser)()),
|
|
59
|
+
__param(1, (0, common_1.Req)()),
|
|
60
|
+
__metadata("design:type", Function),
|
|
61
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
62
|
+
__metadata("design:returntype", rxjs_1.Observable)
|
|
63
|
+
], SseController.prototype, "stream", null);
|
|
64
|
+
__decorate([
|
|
65
|
+
(0, common_1.Get)('health'),
|
|
66
|
+
(0, swagger_1.ApiOperation)({
|
|
67
|
+
summary: 'SSE health check',
|
|
68
|
+
description: 'Returns the number of active SSE connections',
|
|
69
|
+
}),
|
|
70
|
+
(0, swagger_1.ApiOkResponse)({
|
|
71
|
+
description: 'Health check response',
|
|
72
|
+
}),
|
|
73
|
+
__metadata("design:type", Function),
|
|
74
|
+
__metadata("design:paramtypes", []),
|
|
75
|
+
__metadata("design:returntype", Object)
|
|
76
|
+
], SseController.prototype, "health", null);
|
|
77
|
+
exports.SseController = SseController = SseController_1 = __decorate([
|
|
78
|
+
(0, swagger_1.ApiTags)('api/v1/sse'),
|
|
79
|
+
(0, common_1.Controller)('api/v1/sse'),
|
|
80
|
+
__metadata("design:paramtypes", [sse_event_service_1.SseEventService])
|
|
81
|
+
], SseController);
|
|
82
|
+
//# sourceMappingURL=sse.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sse.controller.js","sourceRoot":"","sources":["../../src/controllers/sse.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAOwB;AACxB,6CAAuE;AACvE,+BAAkC;AAClC,8CAAqC;AACrC,qEAAgE;AAChE,8CAAsE;AAK/D,IAAM,aAAa,qBAAnB,MAAM,aAAa;IAGK;IAFZ,MAAM,GAAG,IAAI,eAAM,CAAC,eAAa,CAAC,IAAI,CAAC,CAAC;IAEzD,YAA6B,eAAgC;QAAhC,oBAAe,GAAf,eAAe,CAAiB;IAAG,CAAC;IAWjE,MAAM,CACW,IAA0B,EAClC,OAAgB;QAEvB,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC/B,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAE3B,MAAM,cAAc,GAAG,IAAI,CAAC,eAAe,CAAC,kBAAkB,CAC5D,QAAQ,EACR,MAAM,CACP,CAAC;QAEF,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;YACvB,IAAI,CAAC,eAAe,CAAC,oBAAoB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC9D,CAAC,CAAC,CAAC;QAEH,OAAO,cAAc,CAAC,IAAI,CACxB,IAAA,eAAG,EAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;YAChB,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,OAAO,CAAC,IAAI;SACnB,CAAC,CAAC,CACJ,CAAC;IACJ,CAAC;IAUD,MAAM;QAIJ,OAAO;YACL,kBAAkB,EAAE,IAAI,CAAC,eAAe,CAAC,kBAAkB,EAAE;YAC7D,WAAW,EAAE,IAAI,CAAC,eAAe,CAAC,oBAAoB,EAAE;SACzD,CAAC;IACJ,CAAC;CACF,CAAA;AAvDY,sCAAa;AAcxB;IATC,IAAA,YAAG,EAAC,QAAQ,CAAC;IACb,IAAA,sBAAY,EAAC;QACZ,OAAO,EAAE,2BAA2B;QACpC,WAAW,EACT,0EAA0E;KAC7E,CAAC;IACD,IAAA,uBAAa,EAAC;QACb,WAAW,EAAE,qCAAqC;KACnD,CAAC;IAEC,WAAA,IAAA,oBAAW,GAAE,CAAA;IACb,WAAA,IAAA,YAAG,GAAE,CAAA;;;oCACL,iBAAU;2CAmBZ;AAUD;IARC,IAAA,YAAG,EAAC,QAAQ,CAAC;IACb,IAAA,sBAAY,EAAC;QACZ,OAAO,EAAE,kBAAkB;QAC3B,WAAW,EAAE,8CAA8C;KAC5D,CAAC;IACD,IAAA,uBAAa,EAAC;QACb,WAAW,EAAE,uBAAuB;KACrC,CAAC;;;;2CASD;wBAtDU,aAAa;IAFzB,IAAA,iBAAO,EAAC,YAAY,CAAC;IACrB,IAAA,mBAAU,EAAC,YAAY,CAAC;qCAIuB,mCAAe;GAHlD,aAAa,CAuDzB"}
|
|
@@ -30,16 +30,16 @@ const jwt_1 = require("@nestjs/jwt");
|
|
|
30
30
|
const null_strategy_1 = require("./strategies/null.strategy");
|
|
31
31
|
const jwt_strategy_1 = require("./strategies/jwt.strategy");
|
|
32
32
|
const auth_service_1 = require("./services/auth.service");
|
|
33
|
-
const
|
|
33
|
+
const sse_event_service_1 = require("./services/sse-event.service");
|
|
34
34
|
const event_emitter_1 = require("@nestjs/event-emitter");
|
|
35
|
-
const microservices_1 = require("@nestjs/microservices");
|
|
36
35
|
const config_controller_1 = require("./controllers/config.controller");
|
|
37
36
|
const dashboard_controller_1 = require("./controllers/dashboard.controller");
|
|
38
37
|
const dashboard_service_1 = require("./services/dashboard.service");
|
|
39
38
|
const auth_1 = require("@loopstack/auth");
|
|
40
39
|
const core_2 = require("@nestjs/core");
|
|
41
40
|
const services_1 = require("./services");
|
|
42
|
-
|
|
41
|
+
const sse_controller_1 = require("./controllers/sse.controller");
|
|
42
|
+
const cookieParser = require('cookie-parser');
|
|
43
43
|
let LoopstackApiModule = class LoopstackApiModule extends loop_api_module_definition_1.ConfigurableModuleClass {
|
|
44
44
|
static setup(app, options = {}) {
|
|
45
45
|
const corsEnabled = options.cors?.enabled ?? true;
|
|
@@ -79,17 +79,6 @@ exports.LoopstackApiModule = LoopstackApiModule = __decorate([
|
|
|
79
79
|
shared_1.DocumentEntity,
|
|
80
80
|
shared_1.NamespaceEntity,
|
|
81
81
|
]),
|
|
82
|
-
microservices_1.ClientsModule.register([
|
|
83
|
-
{
|
|
84
|
-
name: 'REDIS_PUB_SUB',
|
|
85
|
-
transport: microservices_1.Transport.REDIS,
|
|
86
|
-
options: {
|
|
87
|
-
host: process.env.REDIS_HOST ?? 'localhost',
|
|
88
|
-
port: process.env.REDIS_PORT ? parseInt(process.env.REDIS_PORT ?? '6379', 0) : 6379,
|
|
89
|
-
family: 0
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
]),
|
|
93
82
|
event_emitter_1.EventEmitterModule.forRoot(),
|
|
94
83
|
core_1.LoopCoreModule,
|
|
95
84
|
auth_1.AuthModule.forRoot(),
|
|
@@ -107,16 +96,17 @@ exports.LoopstackApiModule = LoopstackApiModule = __decorate([
|
|
|
107
96
|
namespace_controller_1.NamespaceController,
|
|
108
97
|
config_controller_1.ConfigController,
|
|
109
98
|
dashboard_controller_1.DashboardController,
|
|
99
|
+
sse_controller_1.SseController,
|
|
110
100
|
],
|
|
111
101
|
providers: [
|
|
112
102
|
{
|
|
113
103
|
provide: core_2.APP_GUARD,
|
|
114
|
-
useClass: auth_1.
|
|
104
|
+
useClass: auth_1.JwtAuthGuard,
|
|
115
105
|
},
|
|
116
106
|
auth_service_1.AuthService,
|
|
117
107
|
jwt_strategy_1.JwtStrategy,
|
|
118
108
|
null_strategy_1.NullStrategy,
|
|
119
|
-
|
|
109
|
+
sse_event_service_1.SseEventService,
|
|
120
110
|
pipeline_api_service_1.PipelineApiService,
|
|
121
111
|
workspace_api_service_1.WorkspaceApiService,
|
|
122
112
|
processor_api_service_1.ProcessorApiService,
|
|
@@ -132,6 +122,7 @@ exports.LoopstackApiModule = LoopstackApiModule = __decorate([
|
|
|
132
122
|
processor_api_service_1.ProcessorApiService,
|
|
133
123
|
dashboard_service_1.DashboardService,
|
|
134
124
|
services_1.UserService,
|
|
125
|
+
sse_event_service_1.SseEventService,
|
|
135
126
|
],
|
|
136
127
|
})
|
|
137
128
|
], LoopstackApiModule);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loopstack-api.module.js","sourceRoot":"","sources":["../src/loopstack-api.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA0E;AAC1E,6EAAuE;AACvE,2EAAuE;AACvE,0EAAqE;AACrE,6CAAgD;AAChD,6EAAyE;AACzE,4EAAuE;AACvE,4EAAuE;AACvE,8CAM2B;AAC3B,6EAAyE;AACzE,6CAAiE;AAEjE,2EAAuE;AACvE,2EAAuE;AACvE,0EAAqE;AACrE,0EAAqE;AACrE,6EAAyE;AACzE,4EAAuE;AACvE,0CAAiD;AACjD,+CAAkD;AAClD,qCAAwC;AACxC,8DAA0D;AAC1D,4DAAwD;AACxD,0DAAsD;AAEtD,
|
|
1
|
+
{"version":3,"file":"loopstack-api.module.js","sourceRoot":"","sources":["../src/loopstack-api.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA0E;AAC1E,6EAAuE;AACvE,2EAAuE;AACvE,0EAAqE;AACrE,6CAAgD;AAChD,6EAAyE;AACzE,4EAAuE;AACvE,4EAAuE;AACvE,8CAM2B;AAC3B,6EAAyE;AACzE,6CAAiE;AAEjE,2EAAuE;AACvE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IAAI,uBAAc,CAAC;YACjB,SAAS,EAAE,IAAI;YACf,SAAS,EAAE,IAAI;SAChB,CAAC,CACH,CAAC;QAEF,GAAG,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC,CAAC;IAC1B,CAAC;CACF,CAAA;AAxCY,gDAAkB;6BAAlB,kBAAkB;IAvD9B,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,uBAAa,CAAC,UAAU,CAAC;gBACvB,uBAAc;gBACd,wBAAe;gBACf,uBAAc;gBACd,uBAAc;gBACd,wBAAe;aAChB,CAAC;YACF,kCAAkB,CAAC,OAAO,EAAE;YAC5B,qBAAc;YACd,iBAAU,CAAC,OAAO,EAAE;YACpB,yBAAc;YACd,eAAS,CAAC,QAAQ,CAAC;gBACjB,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,WAAW;aAC9C,CAAC;SACH;QACD,WAAW,EAAE;YACX,wCAAkB;YAClB,0CAAmB;YACnB,0CAAmB;YACnB,wCAAkB;YAClB,wCAAkB;YAClB,0CAAmB;YACnB,oCAAgB;YAChB,0CAAmB;YACnB,8BAAa;SACd;QACD,SAAS,EAAE;YACT;gBACE,OAAO,EAAE,gBAAS;gBAClB,QAAQ,EAAE,mBAAY;aACvB;YACD,0BAAW;YACX,0BAAW;YACX,4BAAY;YACZ,mCAAe;YACf,yCAAkB;YAClB,2CAAmB;YACnB,2CAAmB;YACnB,yCAAkB;YAClB,yCAAkB;YAClB,2CAAmB;YACnB,oCAAgB;YAChB,sBAAW;SACZ;QACD,OAAO,EAAE;YACP,yCAAkB;YAClB,2CAAmB;YACnB,2CAAmB;YACnB,oCAAgB;YAChB,sBAAW;YACX,mCAAe;SAChB;KACF,CAAC;GACW,kBAAkB,CAwC9B"}
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import { Repository } from 'typeorm';
|
|
2
|
-
import { PipelineEntity
|
|
2
|
+
import { PipelineEntity } from '@loopstack/shared';
|
|
3
3
|
export interface DashboardStats {
|
|
4
|
-
workspaceCount: number;
|
|
5
|
-
totalAutomations: number;
|
|
6
4
|
totalAutomationRuns: number;
|
|
7
5
|
completedRuns: number;
|
|
8
6
|
errorRuns: number;
|
|
9
7
|
inProgressRuns: number;
|
|
10
|
-
recentErrors:
|
|
8
|
+
recentErrors: PipelineEntity[];
|
|
11
9
|
recentRuns: PipelineEntity[];
|
|
12
10
|
}
|
|
13
11
|
export declare class DashboardService {
|
|
14
12
|
private readonly pipelineRepository;
|
|
15
|
-
|
|
16
|
-
constructor(pipelineRepository: Repository<PipelineEntity>, workflowRepository: Repository<WorkflowEntity>);
|
|
13
|
+
constructor(pipelineRepository: Repository<PipelineEntity>);
|
|
17
14
|
getDashboardStats(user: string): Promise<DashboardStats>;
|
|
18
15
|
}
|
|
@@ -19,14 +19,10 @@ const typeorm_2 = require("@nestjs/typeorm");
|
|
|
19
19
|
const shared_1 = require("@loopstack/shared");
|
|
20
20
|
let DashboardService = class DashboardService {
|
|
21
21
|
pipelineRepository;
|
|
22
|
-
|
|
23
|
-
constructor(pipelineRepository, workflowRepository) {
|
|
22
|
+
constructor(pipelineRepository) {
|
|
24
23
|
this.pipelineRepository = pipelineRepository;
|
|
25
|
-
this.workflowRepository = workflowRepository;
|
|
26
24
|
}
|
|
27
25
|
async getDashboardStats(user) {
|
|
28
|
-
const workspaceCount = 0;
|
|
29
|
-
const automations = 0;
|
|
30
26
|
const baseQuery = this.pipelineRepository
|
|
31
27
|
.createQueryBuilder('pipeline')
|
|
32
28
|
.where({
|
|
@@ -50,22 +46,17 @@ let DashboardService = class DashboardService {
|
|
|
50
46
|
.getCount(),
|
|
51
47
|
baseQuery
|
|
52
48
|
.clone()
|
|
53
|
-
.orderBy('pipeline.
|
|
54
|
-
.
|
|
49
|
+
.orderBy('pipeline.updatedAt', 'DESC')
|
|
50
|
+
.limit(3)
|
|
55
51
|
.getMany(),
|
|
56
|
-
|
|
57
|
-
.
|
|
58
|
-
.where({
|
|
59
|
-
createdBy: user,
|
|
60
|
-
})
|
|
52
|
+
baseQuery
|
|
53
|
+
.clone()
|
|
61
54
|
.andWhere({ status: shared_1.WorkflowState.Failed })
|
|
62
|
-
.orderBy('
|
|
63
|
-
.
|
|
55
|
+
.orderBy('pipeline.updatedAt', 'DESC')
|
|
56
|
+
.limit(3)
|
|
64
57
|
.getMany(),
|
|
65
58
|
]);
|
|
66
59
|
return {
|
|
67
|
-
workspaceCount,
|
|
68
|
-
totalAutomations: automations,
|
|
69
60
|
totalAutomationRuns: total,
|
|
70
61
|
completedRuns: completed,
|
|
71
62
|
errorRuns: failed,
|
|
@@ -79,8 +70,6 @@ exports.DashboardService = DashboardService;
|
|
|
79
70
|
exports.DashboardService = DashboardService = __decorate([
|
|
80
71
|
(0, common_1.Injectable)(),
|
|
81
72
|
__param(0, (0, typeorm_2.InjectRepository)(shared_1.PipelineEntity)),
|
|
82
|
-
|
|
83
|
-
__metadata("design:paramtypes", [typeorm_1.Repository,
|
|
84
|
-
typeorm_1.Repository])
|
|
73
|
+
__metadata("design:paramtypes", [typeorm_1.Repository])
|
|
85
74
|
], DashboardService);
|
|
86
75
|
//# sourceMappingURL=dashboard.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dashboard.service.js","sourceRoot":"","sources":["../../src/services/dashboard.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,
|
|
1
|
+
{"version":3,"file":"dashboard.service.js","sourceRoot":"","sources":["../../src/services/dashboard.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,qCAA+C;AAC/C,6CAAmD;AACnD,8CAI2B;AAYpB,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAGR;IAFnB,YAEmB,kBAA8C;QAA9C,uBAAkB,GAAlB,kBAAkB,CAA4B;IAC9D,CAAC;IAEJ,KAAK,CAAC,iBAAiB,CAAC,IAAY;QAClC,MAAM,SAAS,GAAG,IAAI,CAAC,kBAAkB;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CAAC;iBACR,OAAO,EAAE;SACb,CAAC,CAAC;QAEL,OAAO;YACL,mBAAmB,EAAE,KAAK;YAC1B,aAAa,EAAE,SAAS;YACxB,SAAS,EAAE,MAAM;YACjB,cAAc,EAAE,UAAU;YAC1B,YAAY;YACZ,UAAU;SACX,CAAC;IACJ,CAAC;CACF,CAAA;AAtDY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,0BAAgB,EAAC,uBAAc,CAAC,CAAA;qCACI,oBAAU;GAHtC,gBAAgB,CAsD5B"}
|
|
@@ -11,6 +11,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
12
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
13
|
};
|
|
14
|
+
var _a;
|
|
14
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
16
|
exports.PipelineApiService = void 0;
|
|
16
17
|
const common_1 = require("@nestjs/common");
|
|
@@ -174,7 +175,6 @@ exports.PipelineApiService = PipelineApiService = __decorate([
|
|
|
174
175
|
(0, common_1.Injectable)(),
|
|
175
176
|
__param(0, (0, typeorm_2.InjectRepository)(shared_1.PipelineEntity)),
|
|
176
177
|
__metadata("design:paramtypes", [typeorm_1.Repository,
|
|
177
|
-
config_1.ConfigService,
|
|
178
|
-
core_1.CreatePipelineService])
|
|
178
|
+
config_1.ConfigService, typeof (_a = typeof core_1.CreatePipelineService !== "undefined" && core_1.CreatePipelineService) === "function" ? _a : Object])
|
|
179
179
|
], PipelineApiService);
|
|
180
180
|
//# sourceMappingURL=pipeline-api.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline-api.service.js","sourceRoot":"","sources":["../../src/services/pipeline-api.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pipeline-api.service.js","sourceRoot":"","sources":["../../src/services/pipeline-api.service.ts"],"names":[],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qCACL,oBAAU;QACf,sBAAa,sBACI,4BAAqB,oBAArB,4BAAqB;GALpD,kBAAkB,CAmP9B"}
|
|
@@ -8,6 +8,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
|
+
var _a;
|
|
11
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
13
|
exports.ProcessorApiService = void 0;
|
|
13
14
|
const common_1 = require("@nestjs/common");
|
|
@@ -36,6 +37,6 @@ let ProcessorApiService = class ProcessorApiService {
|
|
|
36
37
|
exports.ProcessorApiService = ProcessorApiService;
|
|
37
38
|
exports.ProcessorApiService = ProcessorApiService = __decorate([
|
|
38
39
|
(0, common_1.Injectable)(),
|
|
39
|
-
__metadata("design:paramtypes", [core_1.TaskSchedulerService])
|
|
40
|
+
__metadata("design:paramtypes", [typeof (_a = typeof core_1.TaskSchedulerService !== "undefined" && core_1.TaskSchedulerService) === "function" ? _a : Object])
|
|
40
41
|
], ProcessorApiService);
|
|
41
42
|
//# sourceMappingURL=processor-api.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processor-api.service.js","sourceRoot":"","sources":["../../src/services/processor-api.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"processor-api.service.js","sourceRoot":"","sources":["../../src/services/processor-api.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAEwB;AAKxB,6CAAyC;AACzC,0CAAuD;AAGhD,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAEpB;IADV,YACU,oBAA0C;QAA1C,yBAAoB,GAApB,oBAAoB,CAAsB;IACjD,CAAC;IAEJ,KAAK,CAAC,eAAe,CACnB,UAAkB,EAClB,IAAY,EACZ,OAA8B;QAE9B,OAAO,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC;YACvC,EAAE,EAAE,4BAA4B,GAAG,IAAA,wBAAU,GAAE;YAC/C,IAAI,EAAE;gBACJ,IAAI,EAAE,kBAAkB;gBACxB,IAAI,EAAE,cAAc;gBACpB,OAAO,EAAE;oBACP,GAAG,OAAO;oBACV,EAAE,EAAE,UAAU;iBACf;gBACD,IAAI,EAAE,IAAI;aACX;SACsB,CAAC,CAAC;IAC7B,CAAC;CACF,CAAA;AAvBY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,mBAAU,GAAE;yDAGqB,2BAAoB,oBAApB,2BAAoB;GAFzC,mBAAmB,CAuB/B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ClientMessageDto } from '@loopstack/shared';
|
|
2
|
+
import { Subject } from 'rxjs';
|
|
3
|
+
export declare class SseEventService {
|
|
4
|
+
private readonly logger;
|
|
5
|
+
private connections;
|
|
6
|
+
private getConnectionKey;
|
|
7
|
+
registerConnection(workerId: string, userId: string): Subject<ClientMessageDto>;
|
|
8
|
+
unregisterConnection(workerId: string, userId: string): void;
|
|
9
|
+
private sendToConnection;
|
|
10
|
+
handleClientMessage(payload: ClientMessageDto): void;
|
|
11
|
+
getConnectionCount(): number;
|
|
12
|
+
getActiveConnections(): string[];
|
|
13
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var SseEventService_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.SseEventService = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const event_emitter_1 = require("@nestjs/event-emitter");
|
|
16
|
+
const shared_1 = require("@loopstack/shared");
|
|
17
|
+
const rxjs_1 = require("rxjs");
|
|
18
|
+
let SseEventService = SseEventService_1 = class SseEventService {
|
|
19
|
+
logger = new common_1.Logger(SseEventService_1.name);
|
|
20
|
+
connections = new Map();
|
|
21
|
+
getConnectionKey(workerId, userId) {
|
|
22
|
+
return `worker:${workerId}-user:${userId}`;
|
|
23
|
+
}
|
|
24
|
+
registerConnection(workerId, userId) {
|
|
25
|
+
const key = this.getConnectionKey(workerId, userId);
|
|
26
|
+
const subject = new rxjs_1.Subject();
|
|
27
|
+
this.logger.debug(`Registering SSE connection for user ${userId} on worker ${workerId}`);
|
|
28
|
+
this.connections.set(key, {
|
|
29
|
+
workerId,
|
|
30
|
+
userId,
|
|
31
|
+
subject,
|
|
32
|
+
});
|
|
33
|
+
return subject;
|
|
34
|
+
}
|
|
35
|
+
unregisterConnection(workerId, userId) {
|
|
36
|
+
const key = this.getConnectionKey(workerId, userId);
|
|
37
|
+
const connection = this.connections.get(key);
|
|
38
|
+
this.logger.debug(`Unregistering SSE connection for user ${userId} on worker ${workerId}`);
|
|
39
|
+
if (connection) {
|
|
40
|
+
connection.subject.complete();
|
|
41
|
+
this.connections.delete(key);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
sendToConnection(workerId, userId, message) {
|
|
45
|
+
const key = this.getConnectionKey(workerId, userId);
|
|
46
|
+
const connection = this.connections.get(key);
|
|
47
|
+
this.logger.debug(`Sending message to user ${userId} on worker ${workerId}: ${JSON.stringify(message)}`);
|
|
48
|
+
if (connection) {
|
|
49
|
+
try {
|
|
50
|
+
connection.subject.next(message);
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
this.logger.error(`Error sending message to user ${userId} on worker ${workerId}:`, error);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
this.logger.debug(`No active SSE connection found for user ${userId} on worker ${workerId}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
handleClientMessage(payload) {
|
|
61
|
+
if (payload.userId && payload.workerId) {
|
|
62
|
+
this.sendToConnection(payload.workerId, payload.userId, payload);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
this.logger.warn(`Client message missing userId or workerId:`, payload);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
getConnectionCount() {
|
|
69
|
+
return this.connections.size;
|
|
70
|
+
}
|
|
71
|
+
getActiveConnections() {
|
|
72
|
+
return Array.from(this.connections.keys());
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
exports.SseEventService = SseEventService;
|
|
76
|
+
__decorate([
|
|
77
|
+
(0, event_emitter_1.OnEvent)('client.message'),
|
|
78
|
+
__metadata("design:type", Function),
|
|
79
|
+
__metadata("design:paramtypes", [shared_1.ClientMessageDto]),
|
|
80
|
+
__metadata("design:returntype", void 0)
|
|
81
|
+
], SseEventService.prototype, "handleClientMessage", null);
|
|
82
|
+
exports.SseEventService = SseEventService = SseEventService_1 = __decorate([
|
|
83
|
+
(0, common_1.Injectable)()
|
|
84
|
+
], SseEventService);
|
|
85
|
+
//# sourceMappingURL=sse-event.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sse-event.service.js","sourceRoot":"","sources":["../../src/services/sse-event.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AACpD,yDAAgD;AAChD,8CAAqD;AACrD,+BAA+B;AASxB,IAAM,eAAe,uBAArB,MAAM,eAAe;IACT,MAAM,GAAG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