@igoruehara/canvas-flow 0.1.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/LICENSE +21 -0
- package/README.md +152 -0
- package/bin/canvas-flow.js +1132 -0
- package/package.json +68 -0
- package/public/assets/index-PCQkqMUe.css +1 -0
- package/public/assets/index-qV8twxcq.js +767 -0
- package/public/index.html +13 -0
- package/server/api-key/api-key-connect-provider.d.ts +104 -0
- package/server/api-key/api-key-connect-provider.js +14 -0
- package/server/api-key/api-key-connect-provider.js.map +1 -0
- package/server/api-key/api-key-constants-model.d.ts +2 -0
- package/server/api-key/api-key-constants-model.js +6 -0
- package/server/api-key/api-key-constants-model.js.map +1 -0
- package/server/api-key/api-key-controller.d.ts +12 -0
- package/server/api-key/api-key-controller.js +86 -0
- package/server/api-key/api-key-controller.js.map +1 -0
- package/server/api-key/api-key-module.d.ts +2 -0
- package/server/api-key/api-key-module.js +27 -0
- package/server/api-key/api-key-module.js.map +1 -0
- package/server/api-key/api-key-schema.d.ts +72 -0
- package/server/api-key/api-key-schema.js +98 -0
- package/server/api-key/api-key-schema.js.map +1 -0
- package/server/api-key/api-key-service.d.ts +45 -0
- package/server/api-key/api-key-service.js +151 -0
- package/server/api-key/api-key-service.js.map +1 -0
- package/server/api-key/dto/create-api-key.dto.d.ts +8 -0
- package/server/api-key/dto/create-api-key.dto.js +7 -0
- package/server/api-key/dto/create-api-key.dto.js.map +1 -0
- package/server/app.module.d.ts +2 -0
- package/server/app.module.js +53 -0
- package/server/app.module.js.map +1 -0
- package/server/auth/auth-connect-provider.d.ts +140 -0
- package/server/auth/auth-connect-provider.js +20 -0
- package/server/auth/auth-connect-provider.js.map +1 -0
- package/server/auth/auth-constants-model.d.ts +4 -0
- package/server/auth/auth-constants-model.js +8 -0
- package/server/auth/auth-constants-model.js.map +1 -0
- package/server/auth/auth-controller.d.ts +25 -0
- package/server/auth/auth-controller.js +96 -0
- package/server/auth/auth-controller.js.map +1 -0
- package/server/auth/auth-module.d.ts +2 -0
- package/server/auth/auth-module.js +26 -0
- package/server/auth/auth-module.js.map +1 -0
- package/server/auth/auth-organization-schema.d.ts +44 -0
- package/server/auth/auth-organization-schema.js +62 -0
- package/server/auth/auth-organization-schema.js.map +1 -0
- package/server/auth/auth-schema.d.ts +56 -0
- package/server/auth/auth-schema.js +77 -0
- package/server/auth/auth-schema.js.map +1 -0
- package/server/auth/auth-service.d.ts +64 -0
- package/server/auth/auth-service.js +343 -0
- package/server/auth/auth-service.js.map +1 -0
- package/server/canvas-flow/canvas-flow-connect-provider.d.ts +278 -0
- package/server/canvas-flow/canvas-flow-connect-provider.js +24 -0
- package/server/canvas-flow/canvas-flow-connect-provider.js.map +1 -0
- package/server/canvas-flow/canvas-flow-constants-model.d.ts +6 -0
- package/server/canvas-flow/canvas-flow-constants-model.js +10 -0
- package/server/canvas-flow/canvas-flow-constants-model.js.map +1 -0
- package/server/canvas-flow/canvas-flow-controller.d.ts +98 -0
- package/server/canvas-flow/canvas-flow-controller.js +423 -0
- package/server/canvas-flow/canvas-flow-controller.js.map +1 -0
- package/server/canvas-flow/canvas-flow-module.d.ts +2 -0
- package/server/canvas-flow/canvas-flow-module.js +27 -0
- package/server/canvas-flow/canvas-flow-module.js.map +1 -0
- package/server/canvas-flow/canvas-flow-schema.d.ts +192 -0
- package/server/canvas-flow/canvas-flow-schema.js +239 -0
- package/server/canvas-flow/canvas-flow-schema.js.map +1 -0
- package/server/canvas-flow/canvas-flow-service.d.ts +250 -0
- package/server/canvas-flow/canvas-flow-service.js +1681 -0
- package/server/canvas-flow/canvas-flow-service.js.map +1 -0
- package/server/canvas-flow/dto/create-canvas-flow.dto.d.ts +11 -0
- package/server/canvas-flow/dto/create-canvas-flow.dto.js +61 -0
- package/server/canvas-flow/dto/create-canvas-flow.dto.js.map +1 -0
- package/server/canvas-flow/dto/update-canvas-flow.dto.d.ts +10 -0
- package/server/canvas-flow/dto/update-canvas-flow.dto.js +56 -0
- package/server/canvas-flow/dto/update-canvas-flow.dto.js.map +1 -0
- package/server/constants-global.d.ts +1 -0
- package/server/constants-global.js +5 -0
- package/server/constants-global.js.map +1 -0
- package/server/database/database.module.d.ts +2 -0
- package/server/database/database.module.js +23 -0
- package/server/database/database.module.js.map +1 -0
- package/server/database/database.providers.d.ts +7 -0
- package/server/database/database.providers.js +26 -0
- package/server/database/database.providers.js.map +1 -0
- package/server/documents/documents-connect-provider.d.ts +140 -0
- package/server/documents/documents-connect-provider.js +14 -0
- package/server/documents/documents-connect-provider.js.map +1 -0
- package/server/documents/documents-constants-model.d.ts +2 -0
- package/server/documents/documents-constants-model.js +6 -0
- package/server/documents/documents-constants-model.js.map +1 -0
- package/server/documents/documents-controller.d.ts +16 -0
- package/server/documents/documents-controller.js +117 -0
- package/server/documents/documents-controller.js.map +1 -0
- package/server/documents/documents-module.d.ts +2 -0
- package/server/documents/documents-module.js +27 -0
- package/server/documents/documents-module.js.map +1 -0
- package/server/documents/documents-schema.d.ts +96 -0
- package/server/documents/documents-schema.js +38 -0
- package/server/documents/documents-schema.js.map +1 -0
- package/server/documents/documents-service.d.ts +164 -0
- package/server/documents/documents-service.js +1417 -0
- package/server/documents/documents-service.js.map +1 -0
- package/server/flow-tag/flow-tag-connect-provider.d.ts +146 -0
- package/server/flow-tag/flow-tag-connect-provider.js +14 -0
- package/server/flow-tag/flow-tag-connect-provider.js.map +1 -0
- package/server/flow-tag/flow-tag-constants-model.d.ts +2 -0
- package/server/flow-tag/flow-tag-constants-model.js +6 -0
- package/server/flow-tag/flow-tag-constants-model.js.map +1 -0
- package/server/flow-tag/flow-tag-module.d.ts +2 -0
- package/server/flow-tag/flow-tag-module.js +24 -0
- package/server/flow-tag/flow-tag-module.js.map +1 -0
- package/server/flow-tag/flow-tag-schema.d.ts +100 -0
- package/server/flow-tag/flow-tag-schema.js +131 -0
- package/server/flow-tag/flow-tag-schema.js.map +1 -0
- package/server/flow-tag/flow-tag-service.d.ts +77 -0
- package/server/flow-tag/flow-tag-service.js +156 -0
- package/server/flow-tag/flow-tag-service.js.map +1 -0
- package/server/health.controller.d.ts +7 -0
- package/server/health.controller.js +33 -0
- package/server/health.controller.js.map +1 -0
- package/server/http-batch/http-batch-controller.d.ts +345 -0
- package/server/http-batch/http-batch-controller.js +40 -0
- package/server/http-batch/http-batch-controller.js.map +1 -0
- package/server/http-batch/http-batch-module.d.ts +2 -0
- package/server/http-batch/http-batch-module.js +25 -0
- package/server/http-batch/http-batch-module.js.map +1 -0
- package/server/http-batch/http-batch-service.d.ts +381 -0
- package/server/http-batch/http-batch-service.js +268 -0
- package/server/http-batch/http-batch-service.js.map +1 -0
- package/server/lambda.d.ts +2 -0
- package/server/lambda.js +115 -0
- package/server/lambda.js.map +1 -0
- package/server/llm/openai-provider.d.ts +8 -0
- package/server/llm/openai-provider.js +256 -0
- package/server/llm/openai-provider.js.map +1 -0
- package/server/main.d.ts +1 -0
- package/server/main.js +80 -0
- package/server/main.js.map +1 -0
- package/server/mcp-oauth/mcp-oauth-connect-provider.d.ts +164 -0
- package/server/mcp-oauth/mcp-oauth-connect-provider.js +14 -0
- package/server/mcp-oauth/mcp-oauth-connect-provider.js.map +1 -0
- package/server/mcp-oauth/mcp-oauth-constants-model.d.ts +2 -0
- package/server/mcp-oauth/mcp-oauth-constants-model.js +6 -0
- package/server/mcp-oauth/mcp-oauth-constants-model.js.map +1 -0
- package/server/mcp-oauth/mcp-oauth-controller.d.ts +66 -0
- package/server/mcp-oauth/mcp-oauth-controller.js +166 -0
- package/server/mcp-oauth/mcp-oauth-controller.js.map +1 -0
- package/server/mcp-oauth/mcp-oauth-module.d.ts +2 -0
- package/server/mcp-oauth/mcp-oauth-module.js +27 -0
- package/server/mcp-oauth/mcp-oauth-module.js.map +1 -0
- package/server/mcp-oauth/mcp-oauth-schema.d.ts +112 -0
- package/server/mcp-oauth/mcp-oauth-schema.js +148 -0
- package/server/mcp-oauth/mcp-oauth-schema.js.map +1 -0
- package/server/mcp-oauth/mcp-oauth-service.d.ts +189 -0
- package/server/mcp-oauth/mcp-oauth-service.js +545 -0
- package/server/mcp-oauth/mcp-oauth-service.js.map +1 -0
- package/server/memory/memory-connect-provider.d.ts +200 -0
- package/server/memory/memory-connect-provider.js +26 -0
- package/server/memory/memory-connect-provider.js.map +1 -0
- package/server/memory/memory-constants-model.d.ts +6 -0
- package/server/memory/memory-constants-model.js +10 -0
- package/server/memory/memory-constants-model.js.map +1 -0
- package/server/memory/memory-controller.d.ts +15 -0
- package/server/memory/memory-controller.js +53 -0
- package/server/memory/memory-controller.js.map +1 -0
- package/server/memory/memory-history-schema.d.ts +48 -0
- package/server/memory/memory-history-schema.js +62 -0
- package/server/memory/memory-history-schema.js.map +1 -0
- package/server/memory/memory-module.d.ts +2 -0
- package/server/memory/memory-module.js +26 -0
- package/server/memory/memory-module.js.map +1 -0
- package/server/memory/memory-schema.d.ts +48 -0
- package/server/memory/memory-schema.js +62 -0
- package/server/memory/memory-schema.js.map +1 -0
- package/server/memory/memory-service.d.ts +134 -0
- package/server/memory/memory-service.js +317 -0
- package/server/memory/memory-service.js.map +1 -0
- package/server/memory/memory-trace-history-schema.d.ts +48 -0
- package/server/memory/memory-trace-history-schema.js +62 -0
- package/server/memory/memory-trace-history-schema.js.map +1 -0
- package/server/observability/observability.d.ts +3 -0
- package/server/observability/observability.js +62 -0
- package/server/observability/observability.js.map +1 -0
- package/server/production-guard.d.ts +9 -0
- package/server/production-guard.js +105 -0
- package/server/production-guard.js.map +1 -0
- package/server/provider-config/provider-config-connect-provider.d.ts +44 -0
- package/server/provider-config/provider-config-connect-provider.js +14 -0
- package/server/provider-config/provider-config-connect-provider.js.map +1 -0
- package/server/provider-config/provider-config-constants-model.d.ts +3 -0
- package/server/provider-config/provider-config-constants-model.js +7 -0
- package/server/provider-config/provider-config-constants-model.js.map +1 -0
- package/server/provider-config/provider-config-controller.d.ts +23 -0
- package/server/provider-config/provider-config-controller.js +80 -0
- package/server/provider-config/provider-config-controller.js.map +1 -0
- package/server/provider-config/provider-config-module.d.ts +2 -0
- package/server/provider-config/provider-config-module.js +27 -0
- package/server/provider-config/provider-config-module.js.map +1 -0
- package/server/provider-config/provider-config-schema.d.ts +32 -0
- package/server/provider-config/provider-config-schema.js +46 -0
- package/server/provider-config/provider-config-schema.js.map +1 -0
- package/server/provider-config/provider-config-service.d.ts +178 -0
- package/server/provider-config/provider-config-service.js +689 -0
- package/server/provider-config/provider-config-service.js.map +1 -0
- package/server/queue/queue-job-connect-provider.d.ts +128 -0
- package/server/queue/queue-job-connect-provider.js +14 -0
- package/server/queue/queue-job-connect-provider.js.map +1 -0
- package/server/queue/queue-job-constants-model.d.ts +2 -0
- package/server/queue/queue-job-constants-model.js +6 -0
- package/server/queue/queue-job-constants-model.js.map +1 -0
- package/server/queue/queue-job-schema.d.ts +88 -0
- package/server/queue/queue-job-schema.js +119 -0
- package/server/queue/queue-job-schema.js.map +1 -0
- package/server/queue/queue-lock-connect-provider.d.ts +44 -0
- package/server/queue/queue-lock-connect-provider.js +14 -0
- package/server/queue/queue-lock-connect-provider.js.map +1 -0
- package/server/queue/queue-lock-constants-model.d.ts +2 -0
- package/server/queue/queue-lock-constants-model.js +6 -0
- package/server/queue/queue-lock-constants-model.js.map +1 -0
- package/server/queue/queue-lock-schema.d.ts +32 -0
- package/server/queue/queue-lock-schema.js +47 -0
- package/server/queue/queue-lock-schema.js.map +1 -0
- package/server/queue/queue-message-dedupe-connect-provider.d.ts +116 -0
- package/server/queue/queue-message-dedupe-connect-provider.js +14 -0
- package/server/queue/queue-message-dedupe-connect-provider.js.map +1 -0
- package/server/queue/queue-message-dedupe-constants-model.d.ts +2 -0
- package/server/queue/queue-message-dedupe-constants-model.js +6 -0
- package/server/queue/queue-message-dedupe-constants-model.js.map +1 -0
- package/server/queue/queue-message-dedupe-schema.d.ts +80 -0
- package/server/queue/queue-message-dedupe-schema.js +108 -0
- package/server/queue/queue-message-dedupe-schema.js.map +1 -0
- package/server/queue/queue-module.d.ts +2 -0
- package/server/queue/queue-module.js +33 -0
- package/server/queue/queue-module.js.map +1 -0
- package/server/queue/queue-rate-limit-connect-provider.d.ts +56 -0
- package/server/queue/queue-rate-limit-connect-provider.js +14 -0
- package/server/queue/queue-rate-limit-connect-provider.js.map +1 -0
- package/server/queue/queue-rate-limit-constants-model.d.ts +2 -0
- package/server/queue/queue-rate-limit-constants-model.js +6 -0
- package/server/queue/queue-rate-limit-constants-model.js.map +1 -0
- package/server/queue/queue-rate-limit-schema.d.ts +40 -0
- package/server/queue/queue-rate-limit-schema.js +57 -0
- package/server/queue/queue-rate-limit-schema.js.map +1 -0
- package/server/queue/sqs-transition-service.d.ts +123 -0
- package/server/queue/sqs-transition-service.js +442 -0
- package/server/queue/sqs-transition-service.js.map +1 -0
- package/server/rag/rag-controller.d.ts +167 -0
- package/server/rag/rag-controller.js +232 -0
- package/server/rag/rag-controller.js.map +1 -0
- package/server/rag/rag-module.d.ts +2 -0
- package/server/rag/rag-module.js +30 -0
- package/server/rag/rag-module.js.map +1 -0
- package/server/rag/rag-service.d.ts +361 -0
- package/server/rag/rag-service.js +2864 -0
- package/server/rag/rag-service.js.map +1 -0
- package/server/runner/flow-templates.d.ts +55 -0
- package/server/runner/flow-templates.js +388 -0
- package/server/runner/flow-templates.js.map +1 -0
- package/server/runner/langgraph-runtime.service.d.ts +77 -0
- package/server/runner/langgraph-runtime.service.js +221 -0
- package/server/runner/langgraph-runtime.service.js.map +1 -0
- package/server/runner/runner-controller.d.ts +1044 -0
- package/server/runner/runner-controller.js +751 -0
- package/server/runner/runner-controller.js.map +1 -0
- package/server/runner/runner-module.d.ts +2 -0
- package/server/runner/runner-module.js +37 -0
- package/server/runner/runner-module.js.map +1 -0
- package/server/runner/runner-queue-processor.d.ts +29 -0
- package/server/runner/runner-queue-processor.js +259 -0
- package/server/runner/runner-queue-processor.js.map +1 -0
- package/server/runner/runner-service.d.ts +1761 -0
- package/server/runner/runner-service.js +14256 -0
- package/server/runner/runner-service.js.map +1 -0
- package/server/scripts/migrate-canvas-flow-versions.d.ts +1 -0
- package/server/scripts/migrate-canvas-flow-versions.js +72 -0
- package/server/scripts/migrate-canvas-flow-versions.js.map +1 -0
- package/server/scripts/migrate-mcp-oauth-user-scope.d.ts +1 -0
- package/server/scripts/migrate-mcp-oauth-user-scope.js +95 -0
- package/server/scripts/migrate-mcp-oauth-user-scope.js.map +1 -0
- package/templates/config.example.json +204 -0
- package/templates/config.production.example.json +206 -0
- package/templates/docker-compose.yml +60 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type FindingLevel = 'warn' | 'fail';
|
|
2
|
+
export type ProductionSafetyFinding = {
|
|
3
|
+
level: FindingLevel;
|
|
4
|
+
code: string;
|
|
5
|
+
message: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function getProductionSafetyFindings(env?: NodeJS.ProcessEnv): ProductionSafetyFinding[];
|
|
8
|
+
export declare function assertProductionSafety(env?: NodeJS.ProcessEnv): void;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getProductionSafetyFindings = getProductionSafetyFindings;
|
|
4
|
+
exports.assertProductionSafety = assertProductionSafety;
|
|
5
|
+
const observability_1 = require("./observability/observability");
|
|
6
|
+
function asBool(value) {
|
|
7
|
+
return ['true', '1', 'yes', 'sim'].includes(String(value || '').trim().toLowerCase());
|
|
8
|
+
}
|
|
9
|
+
function isProduction(env) {
|
|
10
|
+
return String(env.NODE_ENV || '').trim().toLowerCase() === 'production';
|
|
11
|
+
}
|
|
12
|
+
function isStrongSecret(value) {
|
|
13
|
+
const text = String(value || '');
|
|
14
|
+
return text.length >= 32 && !/^(changeme|change-me|secret|password|token|123456|canvas-flow)$/i.test(text);
|
|
15
|
+
}
|
|
16
|
+
function parseOrigins(env) {
|
|
17
|
+
return String(env.CORS_ORIGINS || env.CORS_ALLOWED_ORIGINS || '')
|
|
18
|
+
.split(',')
|
|
19
|
+
.map((origin) => origin.trim())
|
|
20
|
+
.filter(Boolean);
|
|
21
|
+
}
|
|
22
|
+
function parseBodyLimitBytes(value) {
|
|
23
|
+
const raw = String(value || '').trim().toLowerCase();
|
|
24
|
+
const match = raw.match(/^(\d+(?:\.\d+)?)(b|kb|mb|gb)?$/);
|
|
25
|
+
if (!match)
|
|
26
|
+
return 0;
|
|
27
|
+
const amount = Number(match[1]);
|
|
28
|
+
const unit = match[2] || 'b';
|
|
29
|
+
const multiplier = unit === 'gb' ? 1024 * 1024 * 1024 : unit === 'mb' ? 1024 * 1024 : unit === 'kb' ? 1024 : 1;
|
|
30
|
+
return Math.floor(amount * multiplier);
|
|
31
|
+
}
|
|
32
|
+
function getProductionSafetyFindings(env = process.env) {
|
|
33
|
+
if (!isProduction(env))
|
|
34
|
+
return [];
|
|
35
|
+
const findings = [];
|
|
36
|
+
const loginEnabled = asBool(env.CANVAS_FLOW_LOGIN);
|
|
37
|
+
const origins = parseOrigins(env);
|
|
38
|
+
if (!isStrongSecret(env.CANVAS_FLOW_API_TOKEN)) {
|
|
39
|
+
findings.push({
|
|
40
|
+
level: 'fail',
|
|
41
|
+
code: 'missing_api_token',
|
|
42
|
+
message: 'CANVAS_FLOW_API_TOKEN must be set to a strong value in production.',
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
if (loginEnabled && !isStrongSecret(env.CANVAS_FLOW_JWT_SECRET)) {
|
|
46
|
+
findings.push({
|
|
47
|
+
level: 'fail',
|
|
48
|
+
code: 'missing_jwt_secret',
|
|
49
|
+
message: 'CANVAS_FLOW_JWT_SECRET must be set to a strong value when production login is enabled.',
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
if (!loginEnabled) {
|
|
53
|
+
findings.push({
|
|
54
|
+
level: 'warn',
|
|
55
|
+
code: 'login_disabled',
|
|
56
|
+
message: 'CANVAS_FLOW_LOGIN is disabled in production; expose the admin UI only behind a trusted private boundary.',
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
if (asBool(env.ENABLE_SWAGGER)) {
|
|
60
|
+
findings.push({
|
|
61
|
+
level: 'warn',
|
|
62
|
+
code: 'swagger_enabled',
|
|
63
|
+
message: 'ENABLE_SWAGGER is true in production.',
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
if (origins.some((origin) => origin === '*')) {
|
|
67
|
+
findings.push({
|
|
68
|
+
level: 'fail',
|
|
69
|
+
code: 'cors_wildcard',
|
|
70
|
+
message: 'CORS_ORIGINS must not contain * in production.',
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
const bodyLimit = parseBodyLimitBytes(env.REQUEST_BODY_LIMIT || '2mb');
|
|
74
|
+
if (bodyLimit > 10 * 1024 * 1024) {
|
|
75
|
+
findings.push({
|
|
76
|
+
level: 'warn',
|
|
77
|
+
code: 'large_body_limit',
|
|
78
|
+
message: 'REQUEST_BODY_LIMIT is above 10mb in production.',
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
if (String(env.CANVAS_FLOW_FILES_STORAGE || '').trim().toLowerCase() === 's3' && !String(env.CANVAS_FLOW_FILES_S3_BUCKET || '').trim()) {
|
|
82
|
+
findings.push({
|
|
83
|
+
level: 'fail',
|
|
84
|
+
code: 'missing_files_s3_bucket',
|
|
85
|
+
message: 'CANVAS_FLOW_FILES_S3_BUCKET must be configured when CANVAS_FLOW_FILES_STORAGE=s3.',
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
return findings;
|
|
89
|
+
}
|
|
90
|
+
function assertProductionSafety(env = process.env) {
|
|
91
|
+
const findings = getProductionSafetyFindings(env);
|
|
92
|
+
if (!findings.length)
|
|
93
|
+
return;
|
|
94
|
+
findings.forEach((finding) => {
|
|
95
|
+
(0, observability_1.logEvent)(finding.level === 'fail' ? 'error' : 'warn', `production_guard.${finding.code}`, {
|
|
96
|
+
message: finding.message,
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
const strict = asBool(env.CANVAS_FLOW_STRICT_PRODUCTION);
|
|
100
|
+
const blocking = findings.filter((finding) => finding.level === 'fail' || strict);
|
|
101
|
+
if (blocking.length) {
|
|
102
|
+
throw new Error(`Unsafe production configuration: ${blocking.map((finding) => finding.code).join(', ')}`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=production-guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"production-guard.js","sourceRoot":"","sources":["../src/production-guard.ts"],"names":[],"mappings":";;AAwCA,kEAiEC;AAED,wDAeC;AA1HD,iEAAyD;AAUzD,SAAS,MAAM,CAAC,KAAc;IAC5B,OAAO,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;AACxF,CAAC;AAED,SAAS,YAAY,CAAC,GAAsB;IAC1C,OAAO,MAAM,CAAC,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,YAAY,CAAC;AAC1E,CAAC;AAED,SAAS,cAAc,CAAC,KAAc;IACpC,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;IACjC,OAAO,IAAI,CAAC,MAAM,IAAI,EAAE,IAAI,CAAC,kEAAkE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC7G,CAAC;AAED,SAAS,YAAY,CAAC,GAAsB;IAC1C,OAAO,MAAM,CAAC,GAAG,CAAC,YAAY,IAAI,GAAG,CAAC,oBAAoB,IAAI,EAAE,CAAC;SAC9D,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;SAC9B,MAAM,CAAC,OAAO,CAAC,CAAC;AACrB,CAAC;AAED,SAAS,mBAAmB,CAAC,K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AAC,IAAI,EAAE,EAAE,CAAC;QACvI,QAAQ,CAAC,IAAI,CAAC;YACZ,KAAK,EAAE,MAAM;YACb,IAAI,EAAE,yBAAyB;YAC/B,OAAO,EAAE,mFAAmF;SAC7F,CAAC,CAAC;IACL,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAgB,sBAAsB,CAAC,MAAyB,OAAO,CAAC,GAAG;IACzE,MAAM,QAAQ,GAAG,2BAA2B,CAAC,GAAG,CAAC,CAAC;IAClD,IAAI,CAAC,QAAQ,CAAC,MAAM;QAAE,OAAO;IAE7B,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC3B,IAAA,wBAAQ,EAAC,OAAO,CAAC,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE,oBAAoB,OAAO,CAAC,IAAI,EAAE,EAAE;YACxF,OAAO,EAAE,OAAO,CAAC,OAAO;SACzB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;IACzD,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,KAAK,MAAM,IAAI,MAAM,CAAC,CAAC;IAClF,IAAI,QAAQ,CAAC,MAAM,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,oCAAoC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC5G,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Connection } from 'mongoose';
|
|
2
|
+
export declare const connectProviders: {
|
|
3
|
+
provide: string;
|
|
4
|
+
useFactory: (connection: Connection) => import("mongoose").Model<{
|
|
5
|
+
key: string;
|
|
6
|
+
settings: any;
|
|
7
|
+
updatedBy?: string;
|
|
8
|
+
} & import("mongoose").DefaultTimestampProps, {}, {}, {}, import("mongoose").Document<unknown, {}, {
|
|
9
|
+
key: string;
|
|
10
|
+
settings: any;
|
|
11
|
+
updatedBy?: string;
|
|
12
|
+
} & import("mongoose").DefaultTimestampProps, {}, {}> & {
|
|
13
|
+
key: string;
|
|
14
|
+
settings: any;
|
|
15
|
+
updatedBy?: string;
|
|
16
|
+
} & import("mongoose").DefaultTimestampProps & {
|
|
17
|
+
_id: import("mongoose").Types.ObjectId;
|
|
18
|
+
} & {
|
|
19
|
+
__v: number;
|
|
20
|
+
}, import("mongoose").Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
21
|
+
collection: string;
|
|
22
|
+
timestamps: true;
|
|
23
|
+
}, {
|
|
24
|
+
key: string;
|
|
25
|
+
settings: any;
|
|
26
|
+
updatedBy?: string;
|
|
27
|
+
} & import("mongoose").DefaultTimestampProps, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
|
|
28
|
+
key: string;
|
|
29
|
+
settings: any;
|
|
30
|
+
updatedBy?: string;
|
|
31
|
+
} & import("mongoose").DefaultTimestampProps>, {}, import("mongoose").MergeType<import("mongoose").DefaultSchemaOptions, {
|
|
32
|
+
collection: string;
|
|
33
|
+
timestamps: true;
|
|
34
|
+
}>> & import("mongoose").FlatRecord<{
|
|
35
|
+
key: string;
|
|
36
|
+
settings: any;
|
|
37
|
+
updatedBy?: string;
|
|
38
|
+
} & import("mongoose").DefaultTimestampProps> & {
|
|
39
|
+
_id: import("mongoose").Types.ObjectId;
|
|
40
|
+
} & {
|
|
41
|
+
__v: number;
|
|
42
|
+
}>>;
|
|
43
|
+
inject: string[];
|
|
44
|
+
}[];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.connectProviders = void 0;
|
|
4
|
+
const constants_global_1 = require("./../constants-global");
|
|
5
|
+
const provider_config_constants_model_1 = require("./provider-config-constants-model");
|
|
6
|
+
const provider_config_schema_1 = require("./provider-config-schema");
|
|
7
|
+
exports.connectProviders = [
|
|
8
|
+
{
|
|
9
|
+
provide: provider_config_constants_model_1.MODEL_NAME,
|
|
10
|
+
useFactory: (connection) => connection.model(provider_config_constants_model_1.COLLECTION_NAME, provider_config_schema_1.EntitySchema),
|
|
11
|
+
inject: [constants_global_1.STRING_URL_DATABASE_CONNECTION],
|
|
12
|
+
},
|
|
13
|
+
];
|
|
14
|
+
//# sourceMappingURL=provider-config-connect-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-config-connect-provider.js","sourceRoot":"","sources":["../../src/provider-config/provider-config-connect-provider.ts"],"names":[],"mappings":";;;AACA,4DAAuE;AACvE,uFAAgF;AAChF,qEAAwD;AAE3C,QAAA,gBAAgB,GAAG;IAC9B;QACE,OAAO,EAAE,4CAAU;QACnB,UAAU,EAAE,CAAC,UAAsB,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,iDAAe,EAAE,qCAAY,CAAC;QACvF,MAAM,EAAE,CAAC,iDAA8B,CAAC;KACzC;CACF,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GLOBAL_CONFIG_KEY = exports.COLLECTION_NAME = exports.MODEL_NAME = void 0;
|
|
4
|
+
exports.MODEL_NAME = 'CANVAS_FLOW_PROVIDER_CONFIG_MODEL';
|
|
5
|
+
exports.COLLECTION_NAME = 'canvas_flow_provider_configs';
|
|
6
|
+
exports.GLOBAL_CONFIG_KEY = 'global';
|
|
7
|
+
//# sourceMappingURL=provider-config-constants-model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-config-constants-model.js","sourceRoot":"","sources":["../../src/provider-config/provider-config-constants-model.ts"],"names":[],"mappings":";;;AAAa,QAAA,UAAU,GAAG,mCAAmC,CAAC;AACjD,QAAA,eAAe,GAAG,8BAA8B,CAAC;AACjD,QAAA,iBAAiB,GAAG,QAAQ,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AuthService } from '../auth/auth-service';
|
|
2
|
+
import { ProviderConfigService } from './provider-config-service';
|
|
3
|
+
export declare class ProviderConfigController {
|
|
4
|
+
private readonly service;
|
|
5
|
+
private readonly authService;
|
|
6
|
+
constructor(service: ProviderConfigService, authService: AuthService);
|
|
7
|
+
private assertAuth;
|
|
8
|
+
getConfig(agentId?: string, authorization?: string, headerToken?: string, xApiKey?: string): Promise<{
|
|
9
|
+
providerStatus?: Record<import("./provider-config-service").ProviderConfigSection, any>;
|
|
10
|
+
settings: any;
|
|
11
|
+
secretStatus: Record<string, boolean>;
|
|
12
|
+
}>;
|
|
13
|
+
updateConfig(body: any, agentId?: string, authorization?: string, headerToken?: string, xApiKey?: string): Promise<{
|
|
14
|
+
providerStatus?: Record<import("./provider-config-service").ProviderConfigSection, any>;
|
|
15
|
+
settings: any;
|
|
16
|
+
secretStatus: Record<string, boolean>;
|
|
17
|
+
}>;
|
|
18
|
+
clearConfigSection(section: string, agentId?: string, authorization?: string, headerToken?: string, xApiKey?: string): Promise<{
|
|
19
|
+
providerStatus?: Record<import("./provider-config-service").ProviderConfigSection, any>;
|
|
20
|
+
settings: any;
|
|
21
|
+
secretStatus: Record<string, boolean>;
|
|
22
|
+
}>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.ProviderConfigController = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
18
|
+
const auth_service_1 = require("../auth/auth-service");
|
|
19
|
+
const provider_config_service_1 = require("./provider-config-service");
|
|
20
|
+
let ProviderConfigController = class ProviderConfigController {
|
|
21
|
+
constructor(service, authService) {
|
|
22
|
+
this.service = service;
|
|
23
|
+
this.authService = authService;
|
|
24
|
+
}
|
|
25
|
+
async assertAuth(authorization, headerToken, xApiKey) {
|
|
26
|
+
return await this.authService.assertUiAuth(authorization, headerToken, xApiKey);
|
|
27
|
+
}
|
|
28
|
+
async getConfig(agentId, authorization, headerToken, xApiKey) {
|
|
29
|
+
await this.assertAuth(authorization, headerToken, xApiKey);
|
|
30
|
+
return await this.service.getSafeSettings(agentId);
|
|
31
|
+
}
|
|
32
|
+
async updateConfig(body, agentId, authorization, headerToken, xApiKey) {
|
|
33
|
+
const user = await this.assertAuth(authorization, headerToken, xApiKey);
|
|
34
|
+
return await this.service.updateSettings(body?.settings || body || {}, user?.id, body?.agentId || agentId);
|
|
35
|
+
}
|
|
36
|
+
async clearConfigSection(section, agentId, authorization, headerToken, xApiKey) {
|
|
37
|
+
const user = await this.assertAuth(authorization, headerToken, xApiKey);
|
|
38
|
+
return await this.service.clearSection(section, user?.id, agentId);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
exports.ProviderConfigController = ProviderConfigController;
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, common_1.Get)(),
|
|
44
|
+
__param(0, (0, common_1.Query)('agentId')),
|
|
45
|
+
__param(1, (0, common_1.Headers)('authorization')),
|
|
46
|
+
__param(2, (0, common_1.Headers)('x-canvas-flow-token')),
|
|
47
|
+
__param(3, (0, common_1.Headers)('x-api-key')),
|
|
48
|
+
__metadata("design:type", Function),
|
|
49
|
+
__metadata("design:paramtypes", [String, String, String, String]),
|
|
50
|
+
__metadata("design:returntype", Promise)
|
|
51
|
+
], ProviderConfigController.prototype, "getConfig", null);
|
|
52
|
+
__decorate([
|
|
53
|
+
(0, common_1.Put)(),
|
|
54
|
+
__param(0, (0, common_1.Body)()),
|
|
55
|
+
__param(1, (0, common_1.Query)('agentId')),
|
|
56
|
+
__param(2, (0, common_1.Headers)('authorization')),
|
|
57
|
+
__param(3, (0, common_1.Headers)('x-canvas-flow-token')),
|
|
58
|
+
__param(4, (0, common_1.Headers)('x-api-key')),
|
|
59
|
+
__metadata("design:type", Function),
|
|
60
|
+
__metadata("design:paramtypes", [Object, String, String, String, String]),
|
|
61
|
+
__metadata("design:returntype", Promise)
|
|
62
|
+
], ProviderConfigController.prototype, "updateConfig", null);
|
|
63
|
+
__decorate([
|
|
64
|
+
(0, common_1.Delete)(':section'),
|
|
65
|
+
__param(0, (0, common_1.Param)('section')),
|
|
66
|
+
__param(1, (0, common_1.Query)('agentId')),
|
|
67
|
+
__param(2, (0, common_1.Headers)('authorization')),
|
|
68
|
+
__param(3, (0, common_1.Headers)('x-canvas-flow-token')),
|
|
69
|
+
__param(4, (0, common_1.Headers)('x-api-key')),
|
|
70
|
+
__metadata("design:type", Function),
|
|
71
|
+
__metadata("design:paramtypes", [String, String, String, String, String]),
|
|
72
|
+
__metadata("design:returntype", Promise)
|
|
73
|
+
], ProviderConfigController.prototype, "clearConfigSection", null);
|
|
74
|
+
exports.ProviderConfigController = ProviderConfigController = __decorate([
|
|
75
|
+
(0, swagger_1.ApiTags)('provider-config'),
|
|
76
|
+
(0, common_1.Controller)('api/provider-config'),
|
|
77
|
+
__metadata("design:paramtypes", [provider_config_service_1.ProviderConfigService,
|
|
78
|
+
auth_service_1.AuthService])
|
|
79
|
+
], ProviderConfigController);
|
|
80
|
+
//# sourceMappingURL=provider-config-controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-config-controller.js","sourceRoot":"","sources":["../../src/provider-config/provider-config-controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA2F;AAC3F,6CAA0C;AAC1C,uDAAmD;AACnD,uEAAkE;AAI3D,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IACnC,YACmB,OAA8B,EAC9B,WAAwB;QADxB,YAAO,GAAP,OAAO,CAAuB;QAC9B,gBAAW,GAAX,WAAW,CAAa;IACxC,CAAC;IAEI,KAAK,CAAC,UAAU,CAAC,aAAsB,EAAE,WAAoB,EAAE,OAAgB;QACrF,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,aAAa,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;IAClF,CAAC;IAGK,AAAN,KAAK,CAAC,SAAS,CACK,OAAgB,EACR,aAAsB,EAChB,WAAoB,EAC9B,OAAgB;QAEtC,MAAM,IAAI,CAAC,UAAU,CAAC,aAAa,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;QAC3D,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IACrD,CAAC;IAGK,AAAN,KAAK,CAAC,YAAY,CACR,IAAS,EACC,OAAgB,EACR,aAAsB,EAChB,WAAoB,EAC9B,OAAgB;QAEtC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,aAAa,EAAE,WAAW,EAAE,OAAO,CAAC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;IACxB,WAAA,IAAA,gBAAO,EAAC,qBAAqB,CAAC,CAAA;IAC9B,WAAA,IAAA,gBAAO,EAAC,WAAW,CAAC,CAAA;;;;kEAItB;mCA3CU,wBAAwB;IAFpC,IAAA,iBAAO,EAAC,iBAAiB,CAAC;IAC1B,IAAA,mBAAU,EAAC,qBAAqB,CAAC;qCAGJ,+CAAqB;QACjB,0BAAW;GAHhC,wBAAwB,CA4CpC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.ProviderConfigModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const auth_module_1 = require("../auth/auth-module");
|
|
12
|
+
const database_module_1 = require("../database/database.module");
|
|
13
|
+
const provider_config_controller_1 = require("./provider-config-controller");
|
|
14
|
+
const provider_config_service_1 = require("./provider-config-service");
|
|
15
|
+
const provider_config_connect_provider_1 = require("./provider-config-connect-provider");
|
|
16
|
+
let ProviderConfigModule = class ProviderConfigModule {
|
|
17
|
+
};
|
|
18
|
+
exports.ProviderConfigModule = ProviderConfigModule;
|
|
19
|
+
exports.ProviderConfigModule = ProviderConfigModule = __decorate([
|
|
20
|
+
(0, common_1.Module)({
|
|
21
|
+
imports: [database_module_1.DatabaseModule, auth_module_1.AuthModule],
|
|
22
|
+
controllers: [provider_config_controller_1.ProviderConfigController],
|
|
23
|
+
providers: [provider_config_service_1.ProviderConfigService, ...provider_config_connect_provider_1.connectProviders],
|
|
24
|
+
exports: [provider_config_service_1.ProviderConfigService],
|
|
25
|
+
})
|
|
26
|
+
], ProviderConfigModule);
|
|
27
|
+
//# sourceMappingURL=provider-config-module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-config-module.js","sourceRoot":"","sources":["../../src/provider-config/provider-config-module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,qDAAiD;AACjD,iEAA6D;AAC7D,6EAAwE;AACxE,uEAAkE;AAClE,yFAAsE;AAQ/D,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;CAAG,CAAA;AAAvB,oDAAoB;+BAApB,oBAAoB;IANhC,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,gCAAc,EAAE,wBAAU,CAAC;QACrC,WAAW,EAAE,CAAC,qDAAwB,CAAC;QACvC,SAAS,EAAE,CAAC,+CAAqB,EAAE,GAAG,mDAAgB,CAAC;QACvD,OAAO,EAAE,CAAC,+CAAqB,CAAC;KACjC,CAAC;GACW,oBAAoB,CAAG"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as mongoose from 'mongoose';
|
|
2
|
+
import { Document } from 'mongoose';
|
|
3
|
+
export declare const EntitySchema: mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
4
|
+
collection: string;
|
|
5
|
+
timestamps: true;
|
|
6
|
+
}, {
|
|
7
|
+
key: string;
|
|
8
|
+
settings: any;
|
|
9
|
+
updatedBy?: string;
|
|
10
|
+
} & mongoose.DefaultTimestampProps, mongoose.Document<unknown, {}, mongoose.FlatRecord<{
|
|
11
|
+
key: string;
|
|
12
|
+
settings: any;
|
|
13
|
+
updatedBy?: string;
|
|
14
|
+
} & mongoose.DefaultTimestampProps>, {}, mongoose.MergeType<mongoose.DefaultSchemaOptions, {
|
|
15
|
+
collection: string;
|
|
16
|
+
timestamps: true;
|
|
17
|
+
}>> & mongoose.FlatRecord<{
|
|
18
|
+
key: string;
|
|
19
|
+
settings: any;
|
|
20
|
+
updatedBy?: string;
|
|
21
|
+
} & mongoose.DefaultTimestampProps> & {
|
|
22
|
+
_id: mongoose.Types.ObjectId;
|
|
23
|
+
} & {
|
|
24
|
+
__v: number;
|
|
25
|
+
}>;
|
|
26
|
+
export declare class ProviderConfigEntity extends Document {
|
|
27
|
+
key: string;
|
|
28
|
+
settings: Record<string, any>;
|
|
29
|
+
updatedBy?: string;
|
|
30
|
+
createdAt: Date;
|
|
31
|
+
updatedAt: Date;
|
|
32
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ProviderConfigEntity = exports.EntitySchema = void 0;
|
|
13
|
+
const mongoose_1 = require("@nestjs/mongoose");
|
|
14
|
+
const mongoose = require("mongoose");
|
|
15
|
+
const mongoose_2 = require("mongoose");
|
|
16
|
+
const provider_config_constants_model_1 = require("./provider-config-constants-model");
|
|
17
|
+
exports.EntitySchema = new mongoose.Schema({
|
|
18
|
+
key: { type: String, required: true, unique: true, index: true },
|
|
19
|
+
settings: { type: Object, default: {} },
|
|
20
|
+
updatedBy: String,
|
|
21
|
+
}, {
|
|
22
|
+
collection: provider_config_constants_model_1.COLLECTION_NAME,
|
|
23
|
+
timestamps: true,
|
|
24
|
+
});
|
|
25
|
+
let ProviderConfigEntity = class ProviderConfigEntity extends mongoose_2.Document {
|
|
26
|
+
};
|
|
27
|
+
exports.ProviderConfigEntity = ProviderConfigEntity;
|
|
28
|
+
__decorate([
|
|
29
|
+
(0, mongoose_1.Prop)({ required: true, unique: true }),
|
|
30
|
+
__metadata("design:type", String)
|
|
31
|
+
], ProviderConfigEntity.prototype, "key", void 0);
|
|
32
|
+
__decorate([
|
|
33
|
+
(0, mongoose_1.Prop)({ type: Object, default: {} }),
|
|
34
|
+
__metadata("design:type", Object)
|
|
35
|
+
], ProviderConfigEntity.prototype, "settings", void 0);
|
|
36
|
+
__decorate([
|
|
37
|
+
(0, mongoose_1.Prop)(),
|
|
38
|
+
__metadata("design:type", String)
|
|
39
|
+
], ProviderConfigEntity.prototype, "updatedBy", void 0);
|
|
40
|
+
exports.ProviderConfigEntity = ProviderConfigEntity = __decorate([
|
|
41
|
+
(0, mongoose_1.Schema)({
|
|
42
|
+
collection: provider_config_constants_model_1.COLLECTION_NAME,
|
|
43
|
+
timestamps: true,
|
|
44
|
+
})
|
|
45
|
+
], ProviderConfigEntity);
|
|
46
|
+
//# sourceMappingURL=provider-config-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-config-schema.js","sourceRoot":"","sources":["../../src/provider-config/provider-config-schema.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAAgD;AAChD,qCAAqC;AACrC,uCAAoC;AACpC,uFAAoE;AAEvD,QAAA,YAAY,GAAG,IAAI,QAAQ,CAAC,MAAM,CAC7C;IACE,GAAG,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE;IAChE,QAAQ,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE;IACvC,SAAS,EAAE,MAAM;CAClB,EACD;IACE,UAAU,EAAE,iDAAe;IAC3B,UAAU,EAAE,IAAI;CACjB,CACF,CAAC;AAMK,IAAM,oBAAoB,GAA1B,MAAM,oBAAqB,SAAQ,mBAAQ;CAYjD,CAAA;AAZY,oDAAoB;AAE/B;IADC,IAAA,eAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;;iDAC3B;AAGZ;IADC,IAAA,eAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;;sDACN;AAG9B;IADC,IAAA,eAAI,GAAE;;uDACY;+BARR,oBAAoB;IAJhC,IAAA,iBAAM,EAAC;QACN,UAAU,EAAE,iDAAe;QAC3B,UAAU,EAAE,IAAI;KACjB,CAAC;GACW,oBAAoB,CAYhC"}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { ConfigService } from '@nestjs/config';
|
|
2
|
+
import { Model } from 'mongoose';
|
|
3
|
+
import { ProviderConfigEntity } from './provider-config-schema';
|
|
4
|
+
export interface OpenAIRuntimeConfig {
|
|
5
|
+
openaiProvider?: string;
|
|
6
|
+
openaiApiKey?: string;
|
|
7
|
+
openaiChatModel?: string;
|
|
8
|
+
openaiEmbeddingModel?: string;
|
|
9
|
+
openaiOcrModel?: string;
|
|
10
|
+
azureOpenAIEnabled?: boolean;
|
|
11
|
+
azureOpenAIApiKey?: string;
|
|
12
|
+
azureOpenAIApiVersion?: string;
|
|
13
|
+
azureOpenAIEndpoint?: string;
|
|
14
|
+
azureOpenAIChatDeployment?: string;
|
|
15
|
+
azureOpenAIEmbeddingDeployment?: string;
|
|
16
|
+
azureOpenAIOcrDeployment?: string;
|
|
17
|
+
geminiApiKey?: string;
|
|
18
|
+
geminiChatModel?: string;
|
|
19
|
+
claudeApiKey?: string;
|
|
20
|
+
claudeChatModel?: string;
|
|
21
|
+
grokApiKey?: string;
|
|
22
|
+
grokBaseUrl?: string;
|
|
23
|
+
grokChatModel?: string;
|
|
24
|
+
bedrockApiKey?: string;
|
|
25
|
+
bedrockBaseUrl?: string;
|
|
26
|
+
bedrockRegion?: string;
|
|
27
|
+
bedrockChatModel?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface ProviderSettings {
|
|
30
|
+
llmProvider: 'openai' | 'azure' | 'azure_openai' | 'gemini' | 'claude' | 'grok' | 'bedrock';
|
|
31
|
+
openai: {
|
|
32
|
+
enabled: boolean;
|
|
33
|
+
apiKey: string;
|
|
34
|
+
chatModel: string;
|
|
35
|
+
embeddingModel: string;
|
|
36
|
+
ocrModel: string;
|
|
37
|
+
};
|
|
38
|
+
azureOpenai: {
|
|
39
|
+
enabled: boolean;
|
|
40
|
+
apiKey: string;
|
|
41
|
+
endpoint: string;
|
|
42
|
+
apiVersion: string;
|
|
43
|
+
chatDeploymentName: string;
|
|
44
|
+
embeddingDeploymentName: string;
|
|
45
|
+
ocrDeploymentName: string;
|
|
46
|
+
embeddingDimensions: number;
|
|
47
|
+
};
|
|
48
|
+
gemini: {
|
|
49
|
+
enabled: boolean;
|
|
50
|
+
apiKey: string;
|
|
51
|
+
chatModel: string;
|
|
52
|
+
};
|
|
53
|
+
claude: {
|
|
54
|
+
enabled: boolean;
|
|
55
|
+
apiKey: string;
|
|
56
|
+
chatModel: string;
|
|
57
|
+
};
|
|
58
|
+
grok: {
|
|
59
|
+
enabled: boolean;
|
|
60
|
+
apiKey: string;
|
|
61
|
+
baseUrl: string;
|
|
62
|
+
chatModel: string;
|
|
63
|
+
};
|
|
64
|
+
bedrock: {
|
|
65
|
+
enabled: boolean;
|
|
66
|
+
apiKey: string;
|
|
67
|
+
baseUrl: string;
|
|
68
|
+
region: string;
|
|
69
|
+
chatModel: string;
|
|
70
|
+
};
|
|
71
|
+
milvus: {
|
|
72
|
+
address: string;
|
|
73
|
+
token: string;
|
|
74
|
+
username: string;
|
|
75
|
+
password: string;
|
|
76
|
+
collectionName: string;
|
|
77
|
+
};
|
|
78
|
+
azureBlob: {
|
|
79
|
+
connectionString: string;
|
|
80
|
+
containerName: string;
|
|
81
|
+
};
|
|
82
|
+
azureSearch: {
|
|
83
|
+
endpoint: string;
|
|
84
|
+
apiKey: string;
|
|
85
|
+
indexName: string;
|
|
86
|
+
apiVersion: string;
|
|
87
|
+
};
|
|
88
|
+
mongodb: {
|
|
89
|
+
connectionString: string;
|
|
90
|
+
databaseName: string;
|
|
91
|
+
};
|
|
92
|
+
webWidget: {
|
|
93
|
+
primaryColor: string;
|
|
94
|
+
accentColor: string;
|
|
95
|
+
assistantName: string;
|
|
96
|
+
subtitle: string;
|
|
97
|
+
welcomeMessage: string;
|
|
98
|
+
placeholder: string;
|
|
99
|
+
bubbleLabel: string;
|
|
100
|
+
avatarText: string;
|
|
101
|
+
openByDefault: boolean;
|
|
102
|
+
position: 'right' | 'left';
|
|
103
|
+
};
|
|
104
|
+
whatsapp: {
|
|
105
|
+
provider: 'meta' | 'blip' | 'sinch';
|
|
106
|
+
deliveryMode: 'provider' | 'apiResponse';
|
|
107
|
+
autoReply: boolean;
|
|
108
|
+
verifyToken: string;
|
|
109
|
+
businessAccountId: string;
|
|
110
|
+
phoneNumberId: string;
|
|
111
|
+
accessToken: string;
|
|
112
|
+
graphApiVersion: string;
|
|
113
|
+
blipContractId: string;
|
|
114
|
+
blipAuthorizationKey: string;
|
|
115
|
+
sinchProjectId: string;
|
|
116
|
+
sinchAppId: string;
|
|
117
|
+
sinchRegion: string;
|
|
118
|
+
sinchAccessToken: string;
|
|
119
|
+
sinchChannel: string;
|
|
120
|
+
sinchApiMode: 'conversation' | 'relay';
|
|
121
|
+
sinchServiceNumber: string;
|
|
122
|
+
sinchServiceUsername: string;
|
|
123
|
+
sinchServiceToken: string;
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
export type ProviderConfigSection = 'openai' | 'azureOpenai' | 'gemini' | 'claude' | 'grok' | 'bedrock' | 'milvus' | 'azureBlob' | 'azureSearch' | 'mongodb' | 'webWidget' | 'whatsapp';
|
|
127
|
+
export declare class ProviderConfigService {
|
|
128
|
+
private model;
|
|
129
|
+
private readonly configService;
|
|
130
|
+
private effectiveSettingsCache;
|
|
131
|
+
constructor(model: Model<ProviderConfigEntity>, configService: ConfigService);
|
|
132
|
+
private clearEffectiveSettingsCache;
|
|
133
|
+
private configKey;
|
|
134
|
+
private envFlag;
|
|
135
|
+
private encryptSecret;
|
|
136
|
+
private decryptSecret;
|
|
137
|
+
private secretKey;
|
|
138
|
+
getEnvSettings(): ProviderSettings;
|
|
139
|
+
private deepMerge;
|
|
140
|
+
private deepMergeFallback;
|
|
141
|
+
private walkSecrets;
|
|
142
|
+
private decryptStoredSettings;
|
|
143
|
+
private buildEffectiveSettings;
|
|
144
|
+
private decryptSettings;
|
|
145
|
+
private encryptSettings;
|
|
146
|
+
private sanitizeSettingsPatch;
|
|
147
|
+
private mergePatchPreservingSecrets;
|
|
148
|
+
private maskSafe;
|
|
149
|
+
private hasOpenAIConfig;
|
|
150
|
+
private hasAzureOpenAIConfig;
|
|
151
|
+
private hasGeminiConfig;
|
|
152
|
+
private hasClaudeConfig;
|
|
153
|
+
private hasGrokConfig;
|
|
154
|
+
private hasBedrockConfig;
|
|
155
|
+
private hasSectionConfig;
|
|
156
|
+
private buildProviderStatus;
|
|
157
|
+
private hasEnvWebWidgetConfig;
|
|
158
|
+
private normalizeEffectiveSettings;
|
|
159
|
+
private blankSection;
|
|
160
|
+
private getStoredSettings;
|
|
161
|
+
getEffectiveSettings(agentId?: string): Promise<ProviderSettings>;
|
|
162
|
+
getSafeSettings(agentId?: string): Promise<{
|
|
163
|
+
providerStatus?: Record<ProviderConfigSection, any>;
|
|
164
|
+
settings: any;
|
|
165
|
+
secretStatus: Record<string, boolean>;
|
|
166
|
+
}>;
|
|
167
|
+
updateSettings(patch: any, updatedBy?: string, agentId?: string): Promise<{
|
|
168
|
+
providerStatus?: Record<ProviderConfigSection, any>;
|
|
169
|
+
settings: any;
|
|
170
|
+
secretStatus: Record<string, boolean>;
|
|
171
|
+
}>;
|
|
172
|
+
clearSection(section: string, updatedBy?: string, agentId?: string): Promise<{
|
|
173
|
+
providerStatus?: Record<ProviderConfigSection, any>;
|
|
174
|
+
settings: any;
|
|
175
|
+
secretStatus: Record<string, boolean>;
|
|
176
|
+
}>;
|
|
177
|
+
toOpenAIRuntimeConfig(settings: ProviderSettings, provider?: string): OpenAIRuntimeConfig;
|
|
178
|
+
}
|