@invect/nestjs 0.0.1

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.
@@ -0,0 +1,1191 @@
1
+ const require_decorateMetadata = require("./_virtual/_@oxc-project_runtime@0.115.0/helpers/decorateMetadata.cjs");
2
+ const require_decorateParam = require("./_virtual/_@oxc-project_runtime@0.115.0/helpers/decorateParam.cjs");
3
+ const require_decorate = require("./_virtual/_@oxc-project_runtime@0.115.0/helpers/decorate.cjs");
4
+ let _nestjs_common = require("@nestjs/common");
5
+ let _invect_core = require("@invect/core");
6
+ let _invect_core_types = require("@invect/core/types");
7
+ //#region src/invect-nestjs.controller.ts
8
+ var _ref, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9, _ref10, _ref11, _ref12, _ref13, _ref14;
9
+ function parseParamsFromQuery(value) {
10
+ if (!value) return {};
11
+ if (typeof value === "string") try {
12
+ return JSON.parse(value);
13
+ } catch {
14
+ return {};
15
+ }
16
+ if (Array.isArray(value)) {
17
+ const last = value[value.length - 1];
18
+ if (typeof last === "string") try {
19
+ return JSON.parse(last);
20
+ } catch {
21
+ return {};
22
+ }
23
+ return {};
24
+ }
25
+ if (typeof value === "object") return Object.entries(value).reduce((acc, [key, entry]) => {
26
+ acc[key] = Array.isArray(entry) ? entry[entry.length - 1] : entry;
27
+ return acc;
28
+ }, {});
29
+ return {};
30
+ }
31
+ function createPluginDatabaseApi(invect) {
32
+ const connection = invect.getDatabaseConnection();
33
+ const normalizeSql = (statement) => {
34
+ if (connection.type !== "postgresql") return statement;
35
+ let index = 0;
36
+ return statement.replace(/\?/g, () => `$${++index}`);
37
+ };
38
+ const query = async (statement, params = []) => {
39
+ switch (connection.type) {
40
+ case "postgresql": return await connection.db.$client.unsafe(normalizeSql(statement), params);
41
+ case "sqlite": return connection.db.$client.prepare(statement).all(...params);
42
+ case "mysql": {
43
+ const [rows] = await connection.db.$client.execute(statement, params);
44
+ return Array.isArray(rows) ? rows : [];
45
+ }
46
+ }
47
+ throw new Error(`Unsupported database type: ${String(connection.type)}`);
48
+ };
49
+ return {
50
+ type: connection.type,
51
+ query,
52
+ async execute(statement, params = []) {
53
+ await query(statement, params);
54
+ }
55
+ };
56
+ }
57
+ function coerceQueryValue(value) {
58
+ if (Array.isArray(value)) return value[value.length - 1];
59
+ return value ?? void 0;
60
+ }
61
+ let InvectController = class InvectController {
62
+ constructor(invect) {
63
+ this.invect = invect;
64
+ }
65
+ /**
66
+ * GET /flows - List flows with optional filtering and pagination
67
+ * Core method: ✅ listFlows(options?: QueryOptions<Flow>)
68
+ */
69
+ async listFlows(query) {
70
+ return await this.invect.listFlows(query);
71
+ }
72
+ /**
73
+ * GET /flows/list - List flows (Express-compatible alias)
74
+ * POST /flows/list - List flows with body filters (Express-compatible alias)
75
+ */
76
+ async listFlowsGetAlias(query) {
77
+ return await this.invect.listFlows(query);
78
+ }
79
+ async listFlowsPostAlias(body) {
80
+ return await this.invect.listFlows(body);
81
+ }
82
+ /**
83
+ * POST /flows - Create a new flow
84
+ * Core method: ✅ createFlow(flowData: CreateFlowRequest)
85
+ */
86
+ async createFlow(body) {
87
+ return await this.invect.createFlow(body);
88
+ }
89
+ /**
90
+ * GET /flows/:id - Get flow by ID
91
+ * Core method: ✅ getFlow(flowId: string)
92
+ */
93
+ async getFlow(id) {
94
+ return await this.invect.getFlow(id);
95
+ }
96
+ /**
97
+ * PUT /flows/:id - Update flow
98
+ * Core method: ✅ updateFlow(flowId: string, updateData: UpdateFlowInput)
99
+ */
100
+ async updateFlow(id, body) {
101
+ return await this.invect.updateFlow(id, body);
102
+ }
103
+ /**
104
+ * DELETE /flows/:id - Delete flow
105
+ * Core method: ✅ deleteFlow(flowId: string)
106
+ */
107
+ async deleteFlow(id) {
108
+ await this.invect.deleteFlow(id);
109
+ }
110
+ /**
111
+ * POST /validate-flow - Validate flow definition
112
+ * Core method: ✅ validateFlowDefinition(flowId: string, flowDefinition: InvectDefinition)
113
+ */
114
+ async validateFlow(body) {
115
+ const { flowId, flowDefinition } = body;
116
+ return await this.invect.validateFlowDefinition(flowId, flowDefinition);
117
+ }
118
+ /**
119
+ * GET /flows/:flowId/react-flow - Get flow data in React Flow format
120
+ * Core method: ✅ renderToReactFlow(flowId, options)
121
+ */
122
+ async renderToReactFlow(flowId, version, flowRunId) {
123
+ const options = {};
124
+ if (version) options.version = version;
125
+ if (flowRunId) options.flowRunId = flowRunId;
126
+ return await this.invect.renderToReactFlow(flowId, options);
127
+ }
128
+ /**
129
+ * POST /flows/:id/versions/list - Get flow versions with optional filtering and pagination
130
+ * Core method: ✅ listFlowVersions(flowId, options)
131
+ */
132
+ async listFlowVersionsPost(id, body) {
133
+ return await this.invect.listFlowVersions(id, body);
134
+ }
135
+ /**
136
+ * GET /flows/:id/versions - Get flow versions with optional filtering and pagination
137
+ * Core method: ✅ listFlowVersions(flowId: string, options?: QueryOptions<FlowVersion>)
138
+ */
139
+ async getFlowVersions(id, query) {
140
+ return await this.invect.listFlowVersions(id, query);
141
+ }
142
+ /**
143
+ * POST /flows/:id/versions - Create flow version
144
+ * Core method: ✅ createFlowVersion(flowId: string, versionData: CreateFlowVersionRequest)
145
+ */
146
+ async createFlowVersion(id, body) {
147
+ return await this.invect.createFlowVersion(id, body);
148
+ }
149
+ /**
150
+ * GET /flows/:id/versions/:version - Get specific flow version (supports 'latest')
151
+ * Core method: ✅ getFlowVersion(flowId, version)
152
+ */
153
+ async getFlowVersion(id, version) {
154
+ const result = await this.invect.getFlowVersion(id, version);
155
+ if (!result) throw new _nestjs_common.NotFoundException(`Version ${version} not found for flow ${id}`);
156
+ return result;
157
+ }
158
+ /**
159
+ * POST /flows/:flowId/run - Start flow execution
160
+ * Core method: ✅ startFlowRunAsync(flowId, inputs, options)
161
+ */
162
+ async startFlowRun(flowId, body) {
163
+ const { inputs = {}, options } = body;
164
+ return await this.invect.startFlowRunAsync(flowId, inputs, options);
165
+ }
166
+ /**
167
+ * POST /flows/:flowId/run-to-node/:nodeId - Execute flow up to a specific node
168
+ * Core method: ✅ executeFlowToNode(flowId, targetNodeId, inputs, options)
169
+ */
170
+ async executeFlowToNode(flowId, nodeId, body) {
171
+ const { inputs = {}, options } = body;
172
+ return await this.invect.executeFlowToNode(flowId, nodeId, inputs, options);
173
+ }
174
+ /**
175
+ * POST /flow-runs/list - List flow runs with optional filtering and pagination
176
+ * Core method: ✅ listFlowRuns(options)
177
+ */
178
+ async listFlowRunsPost(body) {
179
+ return await this.invect.listFlowRuns(body);
180
+ }
181
+ /**
182
+ * GET /flow-runs - Get all flow runs with optional filtering and pagination
183
+ * Core method: ✅ listFlowRuns(options?: QueryOptions<FlowRun>)
184
+ */
185
+ async listFlowRuns(query) {
186
+ return await this.invect.listFlowRuns(query);
187
+ }
188
+ /**
189
+ * GET /flow-runs/:flowRunId - Get specific flow run by ID
190
+ * Core method: ✅ getFlowRunById(flowRunId: string)
191
+ */
192
+ async getFlowRun(flowRunId) {
193
+ return await this.invect.getFlowRunById(flowRunId);
194
+ }
195
+ /**
196
+ * GET /flows/:flowId/flow-runs - Get flow runs for a specific flow
197
+ * Core method: ✅ listFlowRunsByFlowId(flowId: string)
198
+ */
199
+ async getFlowRunsByFlowId(flowId) {
200
+ return await this.invect.listFlowRunsByFlowId(flowId);
201
+ }
202
+ /**
203
+ * POST /flow-runs/:flowRunId/resume - Resume paused flow execution
204
+ * Core method: ✅ resumeExecution(executionId: string)
205
+ */
206
+ async resumeFlowRun(flowRunId) {
207
+ return await this.invect.resumeExecution(flowRunId);
208
+ }
209
+ /**
210
+ * POST /flow-runs/:flowRunId/cancel - Cancel flow execution
211
+ * Core method: ✅ cancelFlowRun(flowRunId: string)
212
+ */
213
+ async cancelFlowRun(flowRunId) {
214
+ return await this.invect.cancelFlowRun(flowRunId);
215
+ }
216
+ /**
217
+ * POST /flow-runs/:flowRunId/pause - Pause flow execution
218
+ * Core method: ✅ pauseFlowRun(flowRunId: string, reason?: string)
219
+ */
220
+ async pauseFlowRun(flowRunId, body) {
221
+ const reason = body?.reason;
222
+ return await this.invect.pauseFlowRun(flowRunId, reason);
223
+ }
224
+ /**
225
+ * GET /flow-runs/:flowRunId/node-executions - Get node executions for a flow run
226
+ * Core method: ✅ getNodeExecutionsByRunId(flowRunId: string)
227
+ */
228
+ async getNodeExecutionsByRunId(flowRunId) {
229
+ return await this.invect.getNodeExecutionsByRunId(flowRunId);
230
+ }
231
+ /**
232
+ * GET /flow-runs/:flowRunId/stream - SSE stream of execution events
233
+ * Core method: ✅ createFlowRunEventStream(flowRunId: string)
234
+ */
235
+ async streamFlowRun(flowRunId, res) {
236
+ res.setHeader("Content-Type", "text/event-stream");
237
+ res.setHeader("Cache-Control", "no-cache");
238
+ res.setHeader("Connection", "keep-alive");
239
+ res.setHeader("X-Accel-Buffering", "no");
240
+ res.flushHeaders();
241
+ try {
242
+ const stream = this.invect.createFlowRunEventStream(flowRunId);
243
+ for await (const event of stream) {
244
+ if (res.destroyed) break;
245
+ const data = JSON.stringify(event);
246
+ res.write(`event: ${event.type}\ndata: ${data}\n\n`);
247
+ }
248
+ } catch (error) {
249
+ const message = error instanceof Error ? error.message : "Stream failed";
250
+ if (res.headersSent) res.write(`event: error\ndata: ${JSON.stringify({
251
+ type: "error",
252
+ message
253
+ })}\n\n`);
254
+ else return res.status(500).json({
255
+ error: "Internal Server Error",
256
+ message
257
+ });
258
+ } finally {
259
+ res.end();
260
+ }
261
+ }
262
+ /**
263
+ * GET /node-executions - Get all node executions with optional filtering and pagination
264
+ * Core method: ✅ listNodeExecutions(options?: QueryOptions<NodeExecution>)
265
+ */
266
+ async listNodeExecutions(query) {
267
+ return await this.invect.listNodeExecutions(query);
268
+ }
269
+ /**
270
+ * POST /node-executions/list - List node executions with body filters
271
+ * Core method: ✅ listNodeExecutions(options)
272
+ */
273
+ async listNodeExecutionsPost(body) {
274
+ return await this.invect.listNodeExecutions(body);
275
+ }
276
+ /**
277
+ * POST /node-data/sql-query - Execute SQL query for testing
278
+ * Core method: ✅ executeSqlQuery(request: SubmitSQLQueryRequest)
279
+ */
280
+ async executeSqlQuery(body) {
281
+ return await this.invect.executeSqlQuery(body);
282
+ }
283
+ /**
284
+ * POST /node-data/test-expression - Test a JS expression in the QuickJS sandbox
285
+ * Core method: ✅ testJsExpression({ expression, context })
286
+ */
287
+ async testJsExpression(body) {
288
+ return await this.invect.testJsExpression(body);
289
+ }
290
+ /**
291
+ * POST /node-data/test-mapper - Test a mapper expression with mode semantics
292
+ * Core method: ✅ testMapper({ expression, incomingData, mode? })
293
+ */
294
+ async testMapper(body) {
295
+ return await this.invect.testMapper(body);
296
+ }
297
+ /**
298
+ * POST /node-data/model-query - Test model prompt
299
+ * Core method: ✅ testModelPrompt(request: SubmitPromptRequest)
300
+ */
301
+ async testModelPrompt(body) {
302
+ return await this.invect.testModelPrompt(body);
303
+ }
304
+ /**
305
+ * GET /node-data/models - Get available AI models
306
+ * Core method: ✅ getAvailableModels()
307
+ */
308
+ async getAvailableModels(credentialId, provider) {
309
+ if (credentialId) return await this.invect.getModelsForCredential(credentialId);
310
+ if (provider) {
311
+ const normalized = provider.trim().toUpperCase();
312
+ if (!Object.values(_invect_core.BatchProvider).includes(normalized)) throw new _nestjs_common.BadRequestException(`Unsupported provider '${provider}'. Expected one of: ${Object.values(_invect_core.BatchProvider).join(", ")}`);
313
+ return await this.invect.getModelsForProvider(normalized);
314
+ }
315
+ return await this.invect.getAvailableModels();
316
+ }
317
+ /**
318
+ * GET /node-data/databases - Get available databases
319
+ * Core method: ✅ getAvailableDatabases()
320
+ */
321
+ async getAvailableDatabases() {
322
+ return this.invect.getAvailableDatabases();
323
+ }
324
+ /**
325
+ * POST /node-config/update - Generic node configuration updates
326
+ * Core method: ✅ handleNodeConfigUpdate(event)
327
+ */
328
+ async handleNodeConfigUpdate(body) {
329
+ return await this.invect.handleNodeConfigUpdate(body);
330
+ }
331
+ async resolveNodeDefinition(rawNodeType, query) {
332
+ const nodeTypeParam = rawNodeType.includes(".") ? rawNodeType : rawNodeType.toUpperCase();
333
+ const isLegacyEnum = !rawNodeType.includes(".") && nodeTypeParam in _invect_core_types.GraphNodeType;
334
+ const isActionId = rawNodeType.includes(".");
335
+ if (!isLegacyEnum && !isActionId) throw new _nestjs_common.BadRequestException(`Unknown node type '${rawNodeType}'`);
336
+ const params = parseParamsFromQuery(query.params);
337
+ const changeField = typeof query.changeField === "string" ? query.changeField : void 0;
338
+ const changeValue = coerceQueryValue(query.changeValue);
339
+ const nodeId = typeof query.nodeId === "string" ? query.nodeId : `definition-${nodeTypeParam.toLowerCase()}`;
340
+ const flowId = typeof query.flowId === "string" ? query.flowId : void 0;
341
+ return await this.invect.handleNodeConfigUpdate({
342
+ nodeType: nodeTypeParam,
343
+ nodeId,
344
+ flowId,
345
+ params,
346
+ change: changeField ? {
347
+ field: changeField,
348
+ value: changeValue
349
+ } : void 0
350
+ });
351
+ }
352
+ /**
353
+ * GET /nodes - Get available node definitions
354
+ * Core method: ✅ getAvailableNodes()
355
+ */
356
+ getAvailableNodes() {
357
+ return this.invect.getAvailableNodes();
358
+ }
359
+ /**
360
+ * GET /actions/:actionId/fields/:fieldName/options - Load dynamic field options
361
+ * Core method: ✅ resolveFieldOptions(actionId, fieldName, deps)
362
+ */
363
+ async resolveFieldOptions(actionId, fieldName, deps) {
364
+ let dependencyValues = {};
365
+ if (deps) try {
366
+ dependencyValues = JSON.parse(deps);
367
+ } catch {
368
+ throw new _nestjs_common.BadRequestException("Invalid deps JSON");
369
+ }
370
+ return await this.invect.resolveFieldOptions(actionId, fieldName, dependencyValues);
371
+ }
372
+ /**
373
+ * POST /nodes/test - Test/execute a single node in isolation
374
+ * Core method: ✅ testNode(nodeType, params, inputData)
375
+ */
376
+ async testNode(body) {
377
+ const { nodeType, params, inputData } = body;
378
+ if (!nodeType || typeof nodeType !== "string") throw new _nestjs_common.BadRequestException("nodeType is required and must be a string");
379
+ if (!params || typeof params !== "object") throw new _nestjs_common.BadRequestException("params is required and must be an object");
380
+ return await this.invect.testNode(nodeType, params, inputData || {});
381
+ }
382
+ /**
383
+ * POST /credentials - Create a new credential
384
+ */
385
+ async createCredential(body) {
386
+ return await this.invect.createCredential(body);
387
+ }
388
+ /**
389
+ * GET /credentials - List credentials
390
+ */
391
+ async listCredentials(type, authType, isActive) {
392
+ const filters = {};
393
+ if (type) filters.type = type;
394
+ if (authType) filters.authType = authType;
395
+ if (isActive !== void 0) filters.isActive = isActive === "true";
396
+ return await this.invect.listCredentials(filters);
397
+ }
398
+ /**
399
+ * GET /credentials/:id - Get a credential
400
+ */
401
+ async getCredential(id) {
402
+ return await this.invect.getCredential(id);
403
+ }
404
+ /**
405
+ * PUT /credentials/:id - Update a credential
406
+ */
407
+ async updateCredential(id, body) {
408
+ return await this.invect.updateCredential(id, body);
409
+ }
410
+ /**
411
+ * DELETE /credentials/:id - Delete a credential
412
+ */
413
+ async deleteCredential(id) {
414
+ await this.invect.deleteCredential(id);
415
+ }
416
+ /**
417
+ * POST /credentials/:id/test - Test a credential
418
+ */
419
+ async testCredential(id) {
420
+ return await this.invect.testCredential(id);
421
+ }
422
+ /**
423
+ * POST /credentials/:id/track-usage - Update credential last used timestamp
424
+ * Core method: ✅ updateCredentialLastUsed(id)
425
+ */
426
+ async trackCredentialUsage(id) {
427
+ await this.invect.updateCredentialLastUsed(id);
428
+ }
429
+ /**
430
+ * GET /credentials/expiring - Get credentials expiring soon
431
+ * Core method: ✅ getExpiringCredentials(daysUntilExpiry?)
432
+ */
433
+ async getExpiringCredentials(daysUntilExpiry) {
434
+ const days = daysUntilExpiry ? parseInt(daysUntilExpiry) : 7;
435
+ return await this.invect.getExpiringCredentials(days);
436
+ }
437
+ /**
438
+ * POST /credentials/test-request - Proxy HTTP request to test a credential
439
+ */
440
+ async testCredentialRequest(body) {
441
+ const { url, method = "GET", headers = {}, body: reqBody } = body;
442
+ if (!url) throw new _nestjs_common.BadRequestException("URL is required");
443
+ const fetchOptions = {
444
+ method,
445
+ headers
446
+ };
447
+ if (reqBody && [
448
+ "POST",
449
+ "PUT",
450
+ "PATCH"
451
+ ].includes(method)) fetchOptions.body = typeof reqBody === "string" ? reqBody : JSON.stringify(reqBody);
452
+ const response = await fetch(url, fetchOptions);
453
+ const responseText = await response.text();
454
+ let responseBody;
455
+ try {
456
+ responseBody = JSON.parse(responseText);
457
+ } catch {
458
+ responseBody = responseText;
459
+ }
460
+ return {
461
+ status: response.status,
462
+ statusText: response.statusText,
463
+ ok: response.ok,
464
+ body: responseBody
465
+ };
466
+ }
467
+ getOAuth2Providers() {
468
+ return this.invect.getOAuth2Providers();
469
+ }
470
+ getOAuth2Provider(providerId) {
471
+ const provider = this.invect.getOAuth2Provider(providerId);
472
+ if (!provider) throw new _nestjs_common.NotFoundException("OAuth2 provider not found");
473
+ return provider;
474
+ }
475
+ startOAuth2Flow(body) {
476
+ const { providerId, clientId, clientSecret, redirectUri, scopes, returnUrl, credentialName } = body;
477
+ if (!providerId || !clientId || !clientSecret || !redirectUri) throw new _nestjs_common.BadRequestException("Missing required fields: providerId, clientId, clientSecret, redirectUri");
478
+ return this.invect.startOAuth2Flow(providerId, {
479
+ clientId,
480
+ clientSecret,
481
+ redirectUri
482
+ }, {
483
+ scopes,
484
+ returnUrl,
485
+ credentialName
486
+ });
487
+ }
488
+ async handleOAuth2Callback(body) {
489
+ const { code, state, clientId, clientSecret, redirectUri } = body;
490
+ if (!code || !state || !clientId || !clientSecret || !redirectUri) throw new _nestjs_common.BadRequestException("Missing required fields: code, state, clientId, clientSecret, redirectUri");
491
+ return await this.invect.handleOAuth2Callback(code, state, {
492
+ clientId,
493
+ clientSecret,
494
+ redirectUri
495
+ });
496
+ }
497
+ async refreshOAuth2Credential(id) {
498
+ return await this.invect.refreshOAuth2Credential(id);
499
+ }
500
+ async getDashboardStats() {
501
+ return await this.invect.getDashboardStats();
502
+ }
503
+ /**
504
+ * GET /flows/:flowId/triggers - List triggers for a flow
505
+ */
506
+ async listTriggersForFlow(flowId) {
507
+ return await this.invect.listTriggersForFlow(flowId);
508
+ }
509
+ /**
510
+ * POST /flows/:flowId/triggers - Create a trigger
511
+ */
512
+ async createTrigger(flowId, body) {
513
+ return await this.invect.createTrigger({
514
+ ...body,
515
+ flowId
516
+ });
517
+ }
518
+ /**
519
+ * POST /flows/:flowId/triggers/sync - Sync triggers from definition
520
+ */
521
+ async syncTriggersForFlow(flowId, body) {
522
+ return await this.invect.syncTriggersForFlow(flowId, body.definition);
523
+ }
524
+ /**
525
+ * GET /triggers/:triggerId - Get a trigger
526
+ */
527
+ async getTrigger(triggerId) {
528
+ const trigger = await this.invect.getTrigger(triggerId);
529
+ if (!trigger) throw new _nestjs_common.NotFoundException(`Trigger ${triggerId} not found`);
530
+ return trigger;
531
+ }
532
+ /**
533
+ * PUT /triggers/:triggerId - Update a trigger
534
+ */
535
+ async updateTrigger(triggerId, body) {
536
+ const trigger = await this.invect.updateTrigger(triggerId, body);
537
+ if (!trigger) throw new _nestjs_common.NotFoundException(`Trigger ${triggerId} not found`);
538
+ return trigger;
539
+ }
540
+ /**
541
+ * DELETE /triggers/:triggerId - Delete a trigger
542
+ */
543
+ async deleteTrigger(triggerId) {
544
+ await this.invect.deleteTrigger(triggerId);
545
+ }
546
+ /**
547
+ * GET /agent/tools - List all available agent tools
548
+ */
549
+ getAgentTools() {
550
+ return this.invect.getAgentTools();
551
+ }
552
+ getChatStatus() {
553
+ return { enabled: this.invect.isChatEnabled() };
554
+ }
555
+ async streamChat(body, req, res) {
556
+ const { messages, context } = body;
557
+ if (!messages || !Array.isArray(messages)) return res.status(400).json({
558
+ error: "Validation Error",
559
+ message: "\"messages\" must be an array of chat messages"
560
+ });
561
+ res.setHeader("Content-Type", "text/event-stream");
562
+ res.setHeader("Cache-Control", "no-cache");
563
+ res.setHeader("Connection", "keep-alive");
564
+ res.setHeader("X-Accel-Buffering", "no");
565
+ res.flushHeaders();
566
+ try {
567
+ const stream = await this.invect.createChatStream({
568
+ messages,
569
+ context: context || {}
570
+ });
571
+ for await (const event of stream) {
572
+ if (res.destroyed) break;
573
+ const data = JSON.stringify(event);
574
+ res.write(`event: ${event.type}\ndata: ${data}\n\n`);
575
+ }
576
+ } catch (error) {
577
+ const message = error instanceof Error ? error.message : "Chat stream failed";
578
+ if (res.headersSent) res.write(`event: error\ndata: ${JSON.stringify({
579
+ type: "error",
580
+ message,
581
+ recoverable: false
582
+ })}\n\n`);
583
+ else return res.status(500).json({
584
+ error: "Internal Server Error",
585
+ message
586
+ });
587
+ } finally {
588
+ res.end();
589
+ }
590
+ }
591
+ async getChatMessages(flowId) {
592
+ return await this.invect.getChatMessages(flowId);
593
+ }
594
+ async saveChatMessages(flowId, body) {
595
+ if (!body.messages || !Array.isArray(body.messages)) throw new _nestjs_common.BadRequestException("\"messages\" must be an array");
596
+ return await this.invect.saveChatMessages(flowId, body.messages);
597
+ }
598
+ async deleteChatMessages(flowId) {
599
+ await this.invect.deleteChatMessages(flowId);
600
+ return { success: true };
601
+ }
602
+ async handlePluginEndpoint(req, res) {
603
+ const endpoints = this.invect.getPluginEndpoints();
604
+ const pluginPath = req.path.replace(/^.*\/plugins/, "") || "/";
605
+ const method = req.method.toUpperCase();
606
+ const matchedEndpoint = endpoints.find((ep) => {
607
+ if (ep.method !== method) return false;
608
+ const pattern = ep.path.replace(/:([^/]+)/g, "([^/]+)");
609
+ return new RegExp(`^${pattern}$`).test(pluginPath);
610
+ });
611
+ if (!matchedEndpoint) return res.status(404).json({
612
+ error: "Not Found",
613
+ message: `Plugin route ${method} ${pluginPath} not found`
614
+ });
615
+ const paramNames = [];
616
+ const paramPattern = matchedEndpoint.path.replace(/:([^/]+)/g, (_m, name) => {
617
+ paramNames.push(name);
618
+ return "([^/]+)";
619
+ });
620
+ const paramMatch = new RegExp(`^${paramPattern}$`).exec(pluginPath);
621
+ const params = {};
622
+ if (paramMatch) paramNames.forEach((name, i) => {
623
+ params[name] = paramMatch[i + 1] || "";
624
+ });
625
+ if (!matchedEndpoint.isPublic && matchedEndpoint.permission) {
626
+ const identity = req.invectIdentity ?? null;
627
+ if (!this.invect.hasPermission(identity, matchedEndpoint.permission)) return res.status(403).json({
628
+ error: "Forbidden",
629
+ message: `Missing permission: ${matchedEndpoint.permission}`
630
+ });
631
+ }
632
+ const result = await matchedEndpoint.handler({
633
+ body: req.body || {},
634
+ params,
635
+ query: req.query || {},
636
+ headers: req.headers,
637
+ identity: req.invectIdentity ?? null,
638
+ database: createPluginDatabaseApi(this.invect),
639
+ request: req,
640
+ core: {
641
+ getPermissions: (identity) => this.invect.getPermissions(identity),
642
+ getAvailableRoles: () => this.invect.getAvailableRoles(),
643
+ getResolvedRole: (identity) => this.invect.getAuthService().getResolvedRole(identity),
644
+ isFlowAccessTableEnabled: () => this.invect.isFlowAccessTableEnabled(),
645
+ listFlowAccess: (flowId) => this.invect.listFlowAccess(flowId),
646
+ grantFlowAccess: (input) => this.invect.grantFlowAccess(input),
647
+ revokeFlowAccess: (accessId) => this.invect.revokeFlowAccess(accessId),
648
+ getAccessibleFlowIds: (userId, teamIds) => this.invect.getAccessibleFlowIds(userId, teamIds),
649
+ getFlowPermission: (flowId, userId, teamIds) => this.invect.getFlowPermission(flowId, userId, teamIds),
650
+ authorize: (context) => this.invect.authorize(context)
651
+ }
652
+ });
653
+ if (result instanceof Response) {
654
+ const arrayBuf = await result.arrayBuffer();
655
+ res.status(result.status);
656
+ result.headers.forEach((value, key) => res.setHeader(key, value));
657
+ res.send(Buffer.from(arrayBuf));
658
+ return;
659
+ }
660
+ if ("stream" in result && result.stream) {
661
+ res.status(result.status || 200);
662
+ res.setHeader("Content-Type", "text/event-stream");
663
+ const reader = result.stream.getReader();
664
+ const pump = async () => {
665
+ const { done, value } = await reader.read();
666
+ if (done) {
667
+ res.end();
668
+ return;
669
+ }
670
+ res.write(value);
671
+ await pump();
672
+ };
673
+ await pump();
674
+ return;
675
+ }
676
+ const jsonResult = result;
677
+ return res.status(jsonResult.status || 200).json(jsonResult.body);
678
+ }
679
+ };
680
+ require_decorate.__decorate([
681
+ (0, _nestjs_common.Get)("flows"),
682
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Query)()),
683
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
684
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [typeof (_ref2 = typeof Record !== "undefined" && Record) === "function" ? _ref2 : Object]),
685
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
686
+ ], InvectController.prototype, "listFlows", null);
687
+ require_decorate.__decorate([
688
+ (0, _nestjs_common.Get)("flows/list"),
689
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Query)()),
690
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
691
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [typeof (_ref3 = typeof Record !== "undefined" && Record) === "function" ? _ref3 : Object]),
692
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
693
+ ], InvectController.prototype, "listFlowsGetAlias", null);
694
+ require_decorate.__decorate([
695
+ (0, _nestjs_common.Post)("flows/list"),
696
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Body)()),
697
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
698
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [typeof (_ref4 = typeof Record !== "undefined" && Record) === "function" ? _ref4 : Object]),
699
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
700
+ ], InvectController.prototype, "listFlowsPostAlias", null);
701
+ require_decorate.__decorate([
702
+ (0, _nestjs_common.Post)("flows"),
703
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Body)()),
704
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
705
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [Object]),
706
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
707
+ ], InvectController.prototype, "createFlow", null);
708
+ require_decorate.__decorate([
709
+ (0, _nestjs_common.Get)("flows/:id"),
710
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Param)("id")),
711
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
712
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [String]),
713
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
714
+ ], InvectController.prototype, "getFlow", null);
715
+ require_decorate.__decorate([
716
+ (0, _nestjs_common.Put)("flows/:id"),
717
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Param)("id")),
718
+ require_decorateParam.__decorateParam(1, (0, _nestjs_common.Body)()),
719
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
720
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [String, Object]),
721
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
722
+ ], InvectController.prototype, "updateFlow", null);
723
+ require_decorate.__decorate([
724
+ (0, _nestjs_common.Delete)("flows/:id"),
725
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Param)("id")),
726
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
727
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [String]),
728
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
729
+ ], InvectController.prototype, "deleteFlow", null);
730
+ require_decorate.__decorate([
731
+ (0, _nestjs_common.Post)("validate-flow"),
732
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Body)()),
733
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
734
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [Object]),
735
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
736
+ ], InvectController.prototype, "validateFlow", null);
737
+ require_decorate.__decorate([
738
+ (0, _nestjs_common.Get)("flows/:flowId/react-flow"),
739
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Param)("flowId")),
740
+ require_decorateParam.__decorateParam(1, (0, _nestjs_common.Query)("version")),
741
+ require_decorateParam.__decorateParam(2, (0, _nestjs_common.Query)("flowRunId")),
742
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
743
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [
744
+ String,
745
+ String,
746
+ String
747
+ ]),
748
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
749
+ ], InvectController.prototype, "renderToReactFlow", null);
750
+ require_decorate.__decorate([
751
+ (0, _nestjs_common.Post)("flows/:id/versions/list"),
752
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Param)("id")),
753
+ require_decorateParam.__decorateParam(1, (0, _nestjs_common.Body)()),
754
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
755
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [String, typeof (_ref5 = typeof Record !== "undefined" && Record) === "function" ? _ref5 : Object]),
756
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
757
+ ], InvectController.prototype, "listFlowVersionsPost", null);
758
+ require_decorate.__decorate([
759
+ (0, _nestjs_common.Get)("flows/:id/versions"),
760
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Param)("id")),
761
+ require_decorateParam.__decorateParam(1, (0, _nestjs_common.Query)()),
762
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
763
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [String, typeof (_ref6 = typeof Record !== "undefined" && Record) === "function" ? _ref6 : Object]),
764
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
765
+ ], InvectController.prototype, "getFlowVersions", null);
766
+ require_decorate.__decorate([
767
+ (0, _nestjs_common.Post)("flows/:id/versions"),
768
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Param)("id")),
769
+ require_decorateParam.__decorateParam(1, (0, _nestjs_common.Body)()),
770
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
771
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [String, Object]),
772
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
773
+ ], InvectController.prototype, "createFlowVersion", null);
774
+ require_decorate.__decorate([
775
+ (0, _nestjs_common.Get)("flows/:id/versions/:version"),
776
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Param)("id")),
777
+ require_decorateParam.__decorateParam(1, (0, _nestjs_common.Param)("version")),
778
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
779
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [String, String]),
780
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
781
+ ], InvectController.prototype, "getFlowVersion", null);
782
+ require_decorate.__decorate([
783
+ (0, _nestjs_common.Post)("flows/:flowId/run"),
784
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Param)("flowId")),
785
+ require_decorateParam.__decorateParam(1, (0, _nestjs_common.Body)()),
786
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
787
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [String, Object]),
788
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
789
+ ], InvectController.prototype, "startFlowRun", null);
790
+ require_decorate.__decorate([
791
+ (0, _nestjs_common.Post)("flows/:flowId/run-to-node/:nodeId"),
792
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Param)("flowId")),
793
+ require_decorateParam.__decorateParam(1, (0, _nestjs_common.Param)("nodeId")),
794
+ require_decorateParam.__decorateParam(2, (0, _nestjs_common.Body)()),
795
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
796
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [
797
+ String,
798
+ String,
799
+ Object
800
+ ]),
801
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
802
+ ], InvectController.prototype, "executeFlowToNode", null);
803
+ require_decorate.__decorate([
804
+ (0, _nestjs_common.Post)("flow-runs/list"),
805
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Body)()),
806
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
807
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [typeof (_ref7 = typeof Record !== "undefined" && Record) === "function" ? _ref7 : Object]),
808
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
809
+ ], InvectController.prototype, "listFlowRunsPost", null);
810
+ require_decorate.__decorate([
811
+ (0, _nestjs_common.Get)("flow-runs"),
812
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Query)()),
813
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
814
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [typeof (_ref8 = typeof Record !== "undefined" && Record) === "function" ? _ref8 : Object]),
815
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
816
+ ], InvectController.prototype, "listFlowRuns", null);
817
+ require_decorate.__decorate([
818
+ (0, _nestjs_common.Get)("flow-runs/:flowRunId"),
819
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Param)("flowRunId")),
820
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
821
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [String]),
822
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
823
+ ], InvectController.prototype, "getFlowRun", null);
824
+ require_decorate.__decorate([
825
+ (0, _nestjs_common.Get)("flows/:flowId/flow-runs"),
826
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Param)("flowId")),
827
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
828
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [String]),
829
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
830
+ ], InvectController.prototype, "getFlowRunsByFlowId", null);
831
+ require_decorate.__decorate([
832
+ (0, _nestjs_common.Post)("flow-runs/:flowRunId/resume"),
833
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Param)("flowRunId")),
834
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
835
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [String]),
836
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
837
+ ], InvectController.prototype, "resumeFlowRun", null);
838
+ require_decorate.__decorate([
839
+ (0, _nestjs_common.Post)("flow-runs/:flowRunId/cancel"),
840
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Param)("flowRunId")),
841
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
842
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [String]),
843
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
844
+ ], InvectController.prototype, "cancelFlowRun", null);
845
+ require_decorate.__decorate([
846
+ (0, _nestjs_common.Post)("flow-runs/:flowRunId/pause"),
847
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Param)("flowRunId")),
848
+ require_decorateParam.__decorateParam(1, (0, _nestjs_common.Body)()),
849
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
850
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [String, Object]),
851
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
852
+ ], InvectController.prototype, "pauseFlowRun", null);
853
+ require_decorate.__decorate([
854
+ (0, _nestjs_common.Get)("flow-runs/:flowRunId/node-executions"),
855
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Param)("flowRunId")),
856
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
857
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [String]),
858
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
859
+ ], InvectController.prototype, "getNodeExecutionsByRunId", null);
860
+ require_decorate.__decorate([
861
+ (0, _nestjs_common.Get)("flow-runs/:flowRunId/stream"),
862
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Param)("flowRunId")),
863
+ require_decorateParam.__decorateParam(1, (0, _nestjs_common.Res)()),
864
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
865
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [String, Object]),
866
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
867
+ ], InvectController.prototype, "streamFlowRun", null);
868
+ require_decorate.__decorate([
869
+ (0, _nestjs_common.Get)("node-executions"),
870
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Query)()),
871
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
872
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [typeof (_ref9 = typeof Record !== "undefined" && Record) === "function" ? _ref9 : Object]),
873
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
874
+ ], InvectController.prototype, "listNodeExecutions", null);
875
+ require_decorate.__decorate([
876
+ (0, _nestjs_common.Post)("node-executions/list"),
877
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Body)()),
878
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
879
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [typeof (_ref10 = typeof Record !== "undefined" && Record) === "function" ? _ref10 : Object]),
880
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
881
+ ], InvectController.prototype, "listNodeExecutionsPost", null);
882
+ require_decorate.__decorate([
883
+ (0, _nestjs_common.Post)("node-data/sql-query"),
884
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Body)()),
885
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
886
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [Object]),
887
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
888
+ ], InvectController.prototype, "executeSqlQuery", null);
889
+ require_decorate.__decorate([
890
+ (0, _nestjs_common.Post)("node-data/test-expression"),
891
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Body)()),
892
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
893
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [Object]),
894
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
895
+ ], InvectController.prototype, "testJsExpression", null);
896
+ require_decorate.__decorate([
897
+ (0, _nestjs_common.Post)("node-data/test-mapper"),
898
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Body)()),
899
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
900
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [Object]),
901
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
902
+ ], InvectController.prototype, "testMapper", null);
903
+ require_decorate.__decorate([
904
+ (0, _nestjs_common.Post)("node-data/model-query"),
905
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Body)()),
906
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
907
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [Object]),
908
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
909
+ ], InvectController.prototype, "testModelPrompt", null);
910
+ require_decorate.__decorate([
911
+ (0, _nestjs_common.Get)("node-data/models"),
912
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Query)("credentialId")),
913
+ require_decorateParam.__decorateParam(1, (0, _nestjs_common.Query)("provider")),
914
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
915
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [String, String]),
916
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
917
+ ], InvectController.prototype, "getAvailableModels", null);
918
+ require_decorate.__decorate([
919
+ (0, _nestjs_common.Get)("node-data/databases"),
920
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
921
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", []),
922
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
923
+ ], InvectController.prototype, "getAvailableDatabases", null);
924
+ require_decorate.__decorate([
925
+ (0, _nestjs_common.Post)("node-config/update"),
926
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Body)()),
927
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
928
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [Object]),
929
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
930
+ ], InvectController.prototype, "handleNodeConfigUpdate", null);
931
+ require_decorate.__decorate([
932
+ (0, _nestjs_common.Get)("node-definition/:nodeType"),
933
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Param)("nodeType")),
934
+ require_decorateParam.__decorateParam(1, (0, _nestjs_common.Query)()),
935
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
936
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [String, typeof (_ref11 = typeof Record !== "undefined" && Record) === "function" ? _ref11 : Object]),
937
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
938
+ ], InvectController.prototype, "resolveNodeDefinition", null);
939
+ require_decorate.__decorate([
940
+ (0, _nestjs_common.Get)("nodes"),
941
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
942
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", []),
943
+ require_decorateMetadata.__decorateMetadata("design:returntype", void 0)
944
+ ], InvectController.prototype, "getAvailableNodes", null);
945
+ require_decorate.__decorate([
946
+ (0, _nestjs_common.Get)("actions/:actionId/fields/:fieldName/options"),
947
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Param)("actionId")),
948
+ require_decorateParam.__decorateParam(1, (0, _nestjs_common.Param)("fieldName")),
949
+ require_decorateParam.__decorateParam(2, (0, _nestjs_common.Query)("deps")),
950
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
951
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [
952
+ String,
953
+ String,
954
+ String
955
+ ]),
956
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
957
+ ], InvectController.prototype, "resolveFieldOptions", null);
958
+ require_decorate.__decorate([
959
+ (0, _nestjs_common.Post)("nodes/test"),
960
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Body)()),
961
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
962
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [Object]),
963
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
964
+ ], InvectController.prototype, "testNode", null);
965
+ require_decorate.__decorate([
966
+ (0, _nestjs_common.Post)("credentials"),
967
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Body)()),
968
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
969
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [Object]),
970
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
971
+ ], InvectController.prototype, "createCredential", null);
972
+ require_decorate.__decorate([
973
+ (0, _nestjs_common.Get)("credentials"),
974
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Query)("type")),
975
+ require_decorateParam.__decorateParam(1, (0, _nestjs_common.Query)("authType")),
976
+ require_decorateParam.__decorateParam(2, (0, _nestjs_common.Query)("isActive")),
977
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
978
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [
979
+ String,
980
+ String,
981
+ String
982
+ ]),
983
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
984
+ ], InvectController.prototype, "listCredentials", null);
985
+ require_decorate.__decorate([
986
+ (0, _nestjs_common.Get)("credentials/:id"),
987
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Param)("id")),
988
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
989
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [String]),
990
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
991
+ ], InvectController.prototype, "getCredential", null);
992
+ require_decorate.__decorate([
993
+ (0, _nestjs_common.Put)("credentials/:id"),
994
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Param)("id")),
995
+ require_decorateParam.__decorateParam(1, (0, _nestjs_common.Body)()),
996
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
997
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [String, typeof (_ref12 = typeof Record !== "undefined" && Record) === "function" ? _ref12 : Object]),
998
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
999
+ ], InvectController.prototype, "updateCredential", null);
1000
+ require_decorate.__decorate([
1001
+ (0, _nestjs_common.Delete)("credentials/:id"),
1002
+ (0, _nestjs_common.HttpCode)(204),
1003
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Param)("id")),
1004
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
1005
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [String]),
1006
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
1007
+ ], InvectController.prototype, "deleteCredential", null);
1008
+ require_decorate.__decorate([
1009
+ (0, _nestjs_common.Post)("credentials/:id/test"),
1010
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Param)("id")),
1011
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
1012
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [String]),
1013
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
1014
+ ], InvectController.prototype, "testCredential", null);
1015
+ require_decorate.__decorate([
1016
+ (0, _nestjs_common.Post)("credentials/:id/track-usage"),
1017
+ (0, _nestjs_common.HttpCode)(204),
1018
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Param)("id")),
1019
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
1020
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [String]),
1021
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
1022
+ ], InvectController.prototype, "trackCredentialUsage", null);
1023
+ require_decorate.__decorate([
1024
+ (0, _nestjs_common.Get)("credentials/expiring"),
1025
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Query)("daysUntilExpiry")),
1026
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
1027
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [String]),
1028
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
1029
+ ], InvectController.prototype, "getExpiringCredentials", null);
1030
+ require_decorate.__decorate([
1031
+ (0, _nestjs_common.Post)("credentials/test-request"),
1032
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Body)()),
1033
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
1034
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [Object]),
1035
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
1036
+ ], InvectController.prototype, "testCredentialRequest", null);
1037
+ require_decorate.__decorate([
1038
+ (0, _nestjs_common.Get)("credentials/oauth2/providers"),
1039
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
1040
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", []),
1041
+ require_decorateMetadata.__decorateMetadata("design:returntype", void 0)
1042
+ ], InvectController.prototype, "getOAuth2Providers", null);
1043
+ require_decorate.__decorate([
1044
+ (0, _nestjs_common.Get)("credentials/oauth2/providers/:providerId"),
1045
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Param)("providerId")),
1046
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
1047
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [String]),
1048
+ require_decorateMetadata.__decorateMetadata("design:returntype", void 0)
1049
+ ], InvectController.prototype, "getOAuth2Provider", null);
1050
+ require_decorate.__decorate([
1051
+ (0, _nestjs_common.Post)("credentials/oauth2/start"),
1052
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Body)()),
1053
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
1054
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [Object]),
1055
+ require_decorateMetadata.__decorateMetadata("design:returntype", void 0)
1056
+ ], InvectController.prototype, "startOAuth2Flow", null);
1057
+ require_decorate.__decorate([
1058
+ (0, _nestjs_common.Post)("credentials/oauth2/callback"),
1059
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Body)()),
1060
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
1061
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [Object]),
1062
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
1063
+ ], InvectController.prototype, "handleOAuth2Callback", null);
1064
+ require_decorate.__decorate([
1065
+ (0, _nestjs_common.Post)("credentials/:id/refresh"),
1066
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Param)("id")),
1067
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
1068
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [String]),
1069
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
1070
+ ], InvectController.prototype, "refreshOAuth2Credential", null);
1071
+ require_decorate.__decorate([
1072
+ (0, _nestjs_common.Get)("dashboard/stats"),
1073
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
1074
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", []),
1075
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
1076
+ ], InvectController.prototype, "getDashboardStats", null);
1077
+ require_decorate.__decorate([
1078
+ (0, _nestjs_common.Get)("flows/:flowId/triggers"),
1079
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Param)("flowId")),
1080
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
1081
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [String]),
1082
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
1083
+ ], InvectController.prototype, "listTriggersForFlow", null);
1084
+ require_decorate.__decorate([
1085
+ (0, _nestjs_common.Post)("flows/:flowId/triggers"),
1086
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Param)("flowId")),
1087
+ require_decorateParam.__decorateParam(1, (0, _nestjs_common.Body)()),
1088
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
1089
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [String, typeof (_ref13 = typeof Record !== "undefined" && Record) === "function" ? _ref13 : Object]),
1090
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
1091
+ ], InvectController.prototype, "createTrigger", null);
1092
+ require_decorate.__decorate([
1093
+ (0, _nestjs_common.Post)("flows/:flowId/triggers/sync"),
1094
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Param)("flowId")),
1095
+ require_decorateParam.__decorateParam(1, (0, _nestjs_common.Body)()),
1096
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
1097
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [String, Object]),
1098
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
1099
+ ], InvectController.prototype, "syncTriggersForFlow", null);
1100
+ require_decorate.__decorate([
1101
+ (0, _nestjs_common.Get)("triggers/:triggerId"),
1102
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Param)("triggerId")),
1103
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
1104
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [String]),
1105
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
1106
+ ], InvectController.prototype, "getTrigger", null);
1107
+ require_decorate.__decorate([
1108
+ (0, _nestjs_common.Put)("triggers/:triggerId"),
1109
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Param)("triggerId")),
1110
+ require_decorateParam.__decorateParam(1, (0, _nestjs_common.Body)()),
1111
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
1112
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [String, typeof (_ref14 = typeof Record !== "undefined" && Record) === "function" ? _ref14 : Object]),
1113
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
1114
+ ], InvectController.prototype, "updateTrigger", null);
1115
+ require_decorate.__decorate([
1116
+ (0, _nestjs_common.Delete)("triggers/:triggerId"),
1117
+ (0, _nestjs_common.HttpCode)(204),
1118
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Param)("triggerId")),
1119
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
1120
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [String]),
1121
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
1122
+ ], InvectController.prototype, "deleteTrigger", null);
1123
+ require_decorate.__decorate([
1124
+ (0, _nestjs_common.Get)("agent/tools"),
1125
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
1126
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", []),
1127
+ require_decorateMetadata.__decorateMetadata("design:returntype", void 0)
1128
+ ], InvectController.prototype, "getAgentTools", null);
1129
+ require_decorate.__decorate([
1130
+ (0, _nestjs_common.Get)("chat/status"),
1131
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
1132
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", []),
1133
+ require_decorateMetadata.__decorateMetadata("design:returntype", void 0)
1134
+ ], InvectController.prototype, "getChatStatus", null);
1135
+ require_decorate.__decorate([
1136
+ (0, _nestjs_common.Post)("chat"),
1137
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Body)()),
1138
+ require_decorateParam.__decorateParam(1, (0, _nestjs_common.Req)()),
1139
+ require_decorateParam.__decorateParam(2, (0, _nestjs_common.Res)()),
1140
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
1141
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [
1142
+ Object,
1143
+ Object,
1144
+ Object
1145
+ ]),
1146
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
1147
+ ], InvectController.prototype, "streamChat", null);
1148
+ require_decorate.__decorate([
1149
+ (0, _nestjs_common.Get)("chat/messages/:flowId"),
1150
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Param)("flowId")),
1151
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
1152
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [String]),
1153
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
1154
+ ], InvectController.prototype, "getChatMessages", null);
1155
+ require_decorate.__decorate([
1156
+ (0, _nestjs_common.Put)("chat/messages/:flowId"),
1157
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Param)("flowId")),
1158
+ require_decorateParam.__decorateParam(1, (0, _nestjs_common.Body)()),
1159
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
1160
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [String, Object]),
1161
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
1162
+ ], InvectController.prototype, "saveChatMessages", null);
1163
+ require_decorate.__decorate([
1164
+ (0, _nestjs_common.Delete)("chat/messages/:flowId"),
1165
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Param)("flowId")),
1166
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
1167
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [String]),
1168
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
1169
+ ], InvectController.prototype, "deleteChatMessages", null);
1170
+ require_decorate.__decorate([
1171
+ (0, _nestjs_common.All)("plugins/*"),
1172
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Req)()),
1173
+ require_decorateParam.__decorateParam(1, (0, _nestjs_common.Res)()),
1174
+ require_decorateMetadata.__decorateMetadata("design:type", Function),
1175
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [Object, Object]),
1176
+ require_decorateMetadata.__decorateMetadata("design:returntype", Promise)
1177
+ ], InvectController.prototype, "handlePluginEndpoint", null);
1178
+ InvectController = require_decorate.__decorate([
1179
+ (0, _nestjs_common.Controller)(),
1180
+ require_decorateParam.__decorateParam(0, (0, _nestjs_common.Inject)("INVECT_CORE")),
1181
+ require_decorateMetadata.__decorateMetadata("design:paramtypes", [typeof (_ref = typeof _invect_core.Invect !== "undefined" && _invect_core.Invect) === "function" ? _ref : Object])
1182
+ ], InvectController);
1183
+ //#endregion
1184
+ Object.defineProperty(exports, "InvectController", {
1185
+ enumerable: true,
1186
+ get: function() {
1187
+ return InvectController;
1188
+ }
1189
+ });
1190
+
1191
+ //# sourceMappingURL=invect-nestjs.controller.cjs.map