noteconnection 1.7.0 → 1.8.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 +674 -21
- package/README.md +242 -62
- package/dist/src/agent_workspace.contract.parity.test.js +475 -0
- package/dist/src/agent_workspace.frontend.test.js +9989 -0
- package/dist/src/agent_workspace.locale.contract.test.js +95 -0
- package/dist/src/agent_workspace.runtime.behavior.test.js +5072 -0
- package/dist/src/copy.assets.contract.test.js +130 -0
- package/dist/src/core/PathBridge.js +28 -3
- package/dist/src/export/WorkspaceExportBundle.js +1130 -0
- package/dist/src/export/WorkspaceExportBundle.test.js +1480 -0
- package/dist/src/export/index.js +18 -0
- package/dist/src/export/types.js +2 -0
- package/dist/src/fixrisk.issue.verifier.contract.test.js +3 -1
- package/dist/src/foundation.ann.runtime.contract.test.js +81 -0
- package/dist/src/foundation.release.evidence.contract.test.js +406 -0
- package/dist/src/foundation.sqlite.runtime.contract.test.js +82 -0
- package/dist/src/frontend/README.md +242 -62
- package/dist/src/frontend/agent_workspace.js +5353 -0
- package/dist/src/frontend/agent_workspace_runtime.js +4434 -0
- package/dist/src/frontend/analysis.js +31 -4
- package/dist/src/frontend/app.js +2178 -62
- package/dist/src/frontend/focus_mode_interactions.js +33 -0
- package/dist/src/frontend/godot_future_path_renderer.js +540 -0
- package/dist/src/frontend/godot_tree_interactions.js +178 -0
- package/dist/src/frontend/graph_state.mjs +105 -0
- package/dist/src/frontend/hosted_future_path_runtime.js +157 -0
- package/dist/src/frontend/i18n.mjs +186 -0
- package/dist/src/frontend/index.html +641 -266
- package/dist/src/frontend/layout_gpu.js +12 -4
- package/dist/src/frontend/locales/en.json +721 -5
- package/dist/src/frontend/locales/zh.json +721 -5
- package/dist/src/frontend/main.mjs +60 -0
- package/dist/src/frontend/markdown_runtime.js +827 -0
- package/dist/src/frontend/notemd.css +49 -0
- package/dist/src/frontend/notemd.html +7 -1
- package/dist/src/frontend/notemd.js +64 -0
- package/dist/src/frontend/path.html +107 -0
- package/dist/src/frontend/path_app.js +2108 -130
- package/dist/src/frontend/path_layout.mjs +143 -0
- package/dist/src/frontend/path_mermaid_utils.mjs +108 -0
- package/dist/src/frontend/path_modules_bridge.js +486 -0
- package/dist/src/frontend/path_state.mjs +118 -0
- package/dist/src/frontend/path_styles.css +146 -0
- package/dist/src/frontend/path_worker_bridge.mjs +85 -0
- package/dist/src/frontend/reader.js +393 -33
- package/dist/src/frontend/runtime_bridge.js +67 -54
- package/dist/src/frontend/runtime_bridge.mjs +279 -0
- package/dist/src/frontend/settings.js +130 -12
- package/dist/src/frontend/source_manager.js +190 -21
- package/dist/src/frontend/styles.css +2720 -72
- package/dist/src/frontend/workbench_state.mjs +101 -0
- package/dist/src/frontend/workspace_panes.js +10168 -0
- package/dist/src/frontend.locale.contract.test.js +62 -0
- package/dist/src/godot.sidecar.bootstrap.contract.test.js +244 -0
- package/dist/src/indexing/IndexLifecycle.js +195 -0
- package/dist/src/indexing/IndexLifecycle.test.js +49 -0
- package/dist/src/indexing/SegmentBuilder.js +64 -0
- package/dist/src/indexing/UnitBuilder.js +48 -0
- package/dist/src/indexing/types.js +2 -0
- package/dist/src/knowledge.api.contract.test.js +170 -0
- package/dist/src/learning/KnowledgeLearningPlatform.js +10386 -0
- package/dist/src/learning/KnowledgeLearningPlatform.persistence.test.js +327 -0
- package/dist/src/learning/KnowledgeLearningPlatform.program-f.test.js +99 -0
- package/dist/src/learning/KnowledgeLearningPlatform.test.js +2971 -0
- package/dist/src/learning/KnowledgeWorkspaceConversationRegression.js +2974 -0
- package/dist/src/learning/KnowledgeWorkspaceConversationRegression.test.js +3928 -0
- package/dist/src/learning/answerReleaseReview.js +4319 -0
- package/dist/src/learning/answerReleaseReview.test.js +2888 -0
- package/dist/src/learning/api.js +2 -0
- package/dist/src/learning/conversationComposer.js +1480 -0
- package/dist/src/learning/conversationComposer.test.js +1817 -0
- package/dist/src/learning/domains/ConversationManager.js +53 -0
- package/dist/src/learning/domains/KnowledgeIngestor.js +238 -0
- package/dist/src/learning/domains/KnowledgeQuerier.js +187 -0
- package/dist/src/learning/domains/MasteryEngine.js +387 -0
- package/dist/src/learning/domains/MemoryPolicyManager.js +408 -0
- package/dist/src/learning/domains/QualityEvaluator.js +307 -0
- package/dist/src/learning/domains/TutorRouter.js +313 -0
- package/dist/src/learning/domains/index.js +33 -0
- package/dist/src/learning/domains/types.js +7 -0
- package/dist/src/learning/errors.js +29 -0
- package/dist/src/learning/evidenceContextAssembler.js +1176 -0
- package/dist/src/learning/evidenceContextAssembler.test.js +6332 -0
- package/dist/src/learning/graphContextAssembler.js +870 -0
- package/dist/src/learning/graphContextAssembler.test.js +1033 -0
- package/dist/src/learning/index.js +28 -0
- package/dist/src/learning/queryBackend.js +1898 -0
- package/dist/src/learning/queryBackend.test.js +955 -0
- package/dist/src/learning/ragContextPack.js +257 -0
- package/dist/src/learning/ragContextPack.test.js +160 -0
- package/dist/src/learning/ragPublicText.js +38 -0
- package/dist/src/learning/ragSufficiencyJudge.js +161 -0
- package/dist/src/learning/ragSufficiencyJudge.test.js +177 -0
- package/dist/src/learning/ragSufficiencyProviderJudge.js +227 -0
- package/dist/src/learning/ragSufficiencyProviderJudge.test.js +156 -0
- package/dist/src/learning/requestNormalization.js +198 -0
- package/dist/src/learning/runtimeCapability.js +4677 -0
- package/dist/src/learning/runtimeCapability.test.js +3635 -0
- package/dist/src/learning/store.js +1240 -0
- package/dist/src/learning/store.test.js +1126 -0
- package/dist/src/learning/tutorAdapter.js +2 -0
- package/dist/src/learning/types.js +2 -0
- package/dist/src/learning/vectorAccelerationAdapter.js +942 -0
- package/dist/src/learning/vectorAccelerationAdapter.test.js +382 -0
- package/dist/src/lfs.asset.policy.contract.test.js +153 -0
- package/dist/src/license.policy.contract.test.js +66 -0
- package/dist/src/memory/MemoryGovernance.js +74 -0
- package/dist/src/memory/MemoryGovernance.test.js +46 -0
- package/dist/src/memory/types.js +2 -0
- package/dist/src/mermaid.frontend.guard.contract.test.js +77 -0
- package/dist/src/middleware/auth.js +17 -0
- package/dist/src/middleware/body-parser.js +45 -0
- package/dist/src/middleware/cors.js +44 -0
- package/dist/src/middleware/index.js +21 -0
- package/dist/src/middleware/request-trace.js +96 -0
- package/dist/src/notemd/AppConfigToml.js +6 -4
- package/dist/src/notemd/MermaidProcessor.js +400 -50
- package/dist/src/notemd/NotemdService.js +498 -13
- package/dist/src/notemd/PromptManager.js +15 -0
- package/dist/src/notemd/cli/commands.js +357 -0
- package/dist/src/notemd/cli/dispatcher.js +225 -0
- package/dist/src/notemd/cli/index.js +169 -0
- package/dist/src/notemd/cli/parser.js +68 -0
- package/dist/src/notemd/cli/types.js +2 -0
- package/dist/src/notemd/constants.js +43 -0
- package/dist/src/notemd/diagram/diagramGenerationService.js +78 -0
- package/dist/src/notemd/diagram/diagramSpec.js +79 -0
- package/dist/src/notemd/diagram/diagramSpecResponseParser.js +131 -0
- package/dist/src/notemd/diagram/intent.js +95 -0
- package/dist/src/notemd/diagram/planner.js +71 -0
- package/dist/src/notemd/diagram/prompts/diagramSpecPrompt.js +42 -0
- package/dist/src/notemd/diagram/types.js +18 -0
- package/dist/src/notemd/index.js +26 -0
- package/dist/src/notemd/operations/capabilityManifest.js +23 -0
- package/dist/src/notemd/operations/cliContracts.js +17 -0
- package/dist/src/notemd/operations/configProfileCommands.js +85 -0
- package/dist/src/notemd/operations/registry.contract.test.js +95 -0
- package/dist/src/notemd/operations/registry.js +991 -0
- package/dist/src/notemd/operations/types.js +2 -0
- package/dist/src/notemd/providerDiagnostics.js +220 -0
- package/dist/src/notemd/providerProfiles.js +42 -0
- package/dist/src/notemd/providerTemplates.js +231 -0
- package/dist/src/notemd/search/DuckDuckGoProvider.js +39 -0
- package/dist/src/notemd/search/SearchManager.js +13 -0
- package/dist/src/notemd/search/SearchProvider.js +2 -0
- package/dist/src/notemd/search/TavilyProvider.js +44 -0
- package/dist/src/notemd.agent.manifest.test.js +85 -0
- package/dist/src/notemd.api.contract.test.js +14 -1
- package/dist/src/notemd.app_config_toml.test.js +2 -1
- package/dist/src/notemd.batch.workflow.test.js +117 -0
- package/dist/src/notemd.cli.e2e.test.js +136 -0
- package/dist/src/notemd.core.test.js +51 -0
- package/dist/src/notemd.diagram.pipeline.test.js +233 -0
- package/dist/src/notemd.providerTemplates.test.js +34 -0
- package/dist/src/notemd.server.integration.test.js +143 -35
- package/dist/src/notemd.workflow.pipeline.test.js +162 -0
- package/dist/src/pathbridge.handshake.contract.test.js +16 -2
- package/dist/src/pathmode.background.contract.test.js +69 -0
- package/dist/src/pathmode.settings.api.contract.test.js +9 -0
- package/dist/src/pkg.sidecar.contract.test.js +9 -3
- package/dist/src/platform/ExportProfile.js +58 -0
- package/dist/src/platform/PlatformCapabilities.js +45 -0
- package/dist/src/platform/PlatformCapabilities.test.js +30 -0
- package/dist/src/platform/RenderMaterializer.js +33 -0
- package/dist/src/platform/RenderMaterializer.test.js +32 -0
- package/dist/src/query_backend.external_http.integration.test.js +410 -0
- package/dist/src/reader_renderer.js +404 -3
- package/dist/src/reader_renderer.test.js +87 -0
- package/dist/src/release.godot.mirror.contract.test.js +73 -0
- package/dist/src/resources/ResourceRegistry.js +223 -0
- package/dist/src/resources/ResourceRegistry.test.js +61 -0
- package/dist/src/resources/types.js +2 -0
- package/dist/src/routes/agentWorkspaceDiagnostics.js +173 -0
- package/dist/src/routes/data.js +267 -0
- package/dist/src/routes/diagnostics.js +51 -0
- package/dist/src/routes/index.js +23 -0
- package/dist/src/routes/knowledge.js +968 -0
- package/dist/src/routes/markdown.js +287 -0
- package/dist/src/routes/notemd.js +565 -0
- package/dist/src/routes/registry.contract.test.js +130 -0
- package/dist/src/routes/render.js +285 -0
- package/dist/src/routes/runtimeRunbookRouteOps.js +149 -0
- package/dist/src/routes/runtimeRunbookRouteOps.test.js +194 -0
- package/dist/src/routes/settings.js +6 -0
- package/dist/src/routes/staticFiles.js +94 -0
- package/dist/src/routes/types.js +2 -0
- package/dist/src/runtime.transport.adapter.contract.test.js +81 -0
- package/dist/src/server.js +11090 -1549
- package/dist/src/server.migration.test.js +193 -21
- package/dist/src/server.port.fallback.contract.test.js +63 -0
- package/dist/src/session/SessionStateStore.js +81 -0
- package/dist/src/session/SessionStateStore.test.js +58 -0
- package/dist/src/session/types.js +2 -0
- package/dist/src/settings.runtime.contract.test.js +50 -0
- package/dist/src/shared/types.contract.test.js +107 -0
- package/dist/src/shared/types.js +22 -0
- package/dist/src/sidecar.replacement.boundary.contract.test.js +128 -0
- package/dist/src/sidecar.supply.readiness.contract.test.js +144 -0
- package/dist/src/source_manager.loadflow.test.js +46 -0
- package/dist/src/startup.layout.snapshot.contract.test.js +57 -0
- package/dist/src/tauri.frontend.build.contract.test.js +60 -0
- package/dist/src/tauri.sidecar.cleanup.contract.test.js +21 -0
- package/dist/src/utils/RuntimePaths.js +4 -13
- package/dist/src/utils/platform.js +153 -0
- package/dist/src/workflows/WorkflowArtifactStore.js +96 -0
- package/dist/src/workflows/WorkflowArtifactStore.test.js +80 -0
- package/dist/src/workflows/types.js +2 -0
- package/dist/src/workspace/WorkspaceRegistry.js +122 -0
- package/dist/src/workspace/WorkspaceRegistry.test.js +29 -0
- package/dist/src/workspace/types.js +2 -0
- package/package.json +53 -10
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.registerRenderRoutes = registerRenderRoutes;
|
|
37
|
+
const CrashLogger_1 = require("../backend/utils/CrashLogger");
|
|
38
|
+
const RenderMaterializer_1 = require("../platform/RenderMaterializer");
|
|
39
|
+
function normalizeMermaidRendererPreference(value) {
|
|
40
|
+
const normalized = typeof value === 'string' ? value.trim().toLowerCase() : '';
|
|
41
|
+
if (normalized === 'local') {
|
|
42
|
+
return 'local';
|
|
43
|
+
}
|
|
44
|
+
if (normalized === 'frontend' || normalized === 'bridge') {
|
|
45
|
+
return 'frontend';
|
|
46
|
+
}
|
|
47
|
+
return 'auto';
|
|
48
|
+
}
|
|
49
|
+
function registerRenderRoutes(ctx) {
|
|
50
|
+
const json = (res, code, data) => {
|
|
51
|
+
res.writeHead(code, { 'Content-Type': 'application/json' });
|
|
52
|
+
res.end(JSON.stringify(data));
|
|
53
|
+
};
|
|
54
|
+
const fail = (res, error, label) => {
|
|
55
|
+
console.error(error);
|
|
56
|
+
CrashLogger_1.CrashLogger.log(error, label);
|
|
57
|
+
json(res, 500, { success: false, error: String(error) });
|
|
58
|
+
};
|
|
59
|
+
const readBody = (req) => new Promise((resolve, reject) => {
|
|
60
|
+
const chunks = [];
|
|
61
|
+
req.on('data', (c) => chunks.push(c));
|
|
62
|
+
req.on('end', () => resolve(Buffer.concat(chunks).toString('utf8')));
|
|
63
|
+
req.on('error', reject);
|
|
64
|
+
});
|
|
65
|
+
const parseOptionalPositiveDimension = (value) => {
|
|
66
|
+
const numeric = Number(value);
|
|
67
|
+
if (!Number.isFinite(numeric) || numeric <= 0) {
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
return Math.floor(numeric);
|
|
71
|
+
};
|
|
72
|
+
const parseOptionalPositiveScale = (value) => {
|
|
73
|
+
const numeric = Number(value);
|
|
74
|
+
if (!Number.isFinite(numeric) || numeric <= 0) {
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
77
|
+
return numeric;
|
|
78
|
+
};
|
|
79
|
+
const renderMermaidWithPreference = async (source, options) => {
|
|
80
|
+
const includeSvg = options.includeStages || options.includeSvg;
|
|
81
|
+
const { normalizeMermaidDefinition } = await Promise.resolve().then(() => __importStar(require('../reader_renderer')));
|
|
82
|
+
const normalizedSource = normalizeMermaidDefinition(source);
|
|
83
|
+
const pathBridge = typeof ctx.getPathBridge === 'function' ? ctx.getPathBridge() : null;
|
|
84
|
+
if (options.rendererPreference !== 'local'
|
|
85
|
+
&& pathBridge
|
|
86
|
+
&& typeof pathBridge.requestFrontendMermaidRender === 'function') {
|
|
87
|
+
try {
|
|
88
|
+
const frontendRendered = await pathBridge.requestFrontendMermaidRender({
|
|
89
|
+
source,
|
|
90
|
+
theme: 'dark',
|
|
91
|
+
maxWidth: options.maxWidth,
|
|
92
|
+
maxHeight: options.maxHeight,
|
|
93
|
+
renderScale: options.renderScale,
|
|
94
|
+
includeStages: options.includeStages,
|
|
95
|
+
includeSvg,
|
|
96
|
+
});
|
|
97
|
+
const frontendResult = {
|
|
98
|
+
pngBase64: frontendRendered.pngBase64,
|
|
99
|
+
width: frontendRendered.width,
|
|
100
|
+
height: frontendRendered.height,
|
|
101
|
+
renderer: frontendRendered.renderer || 'frontend-bridge',
|
|
102
|
+
normalizedSource,
|
|
103
|
+
};
|
|
104
|
+
if (includeSvg && typeof frontendRendered.svg === 'string' && frontendRendered.svg.trim()) {
|
|
105
|
+
frontendResult.svg = frontendRendered.svg;
|
|
106
|
+
}
|
|
107
|
+
if (options.includeStages && Array.isArray(frontendRendered.stages)) {
|
|
108
|
+
frontendResult.stages = frontendRendered.stages;
|
|
109
|
+
}
|
|
110
|
+
return frontendResult;
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
if (options.rendererPreference === 'frontend') {
|
|
114
|
+
throw error;
|
|
115
|
+
}
|
|
116
|
+
console.warn('[Render Route] Frontend Mermaid renderer unavailable, falling back to local resvg.', error);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const { collectMermaidRenderStageSnapshots, renderMermaidPng, } = await Promise.resolve().then(() => __importStar(require('../reader_renderer')));
|
|
120
|
+
const localRendered = await renderMermaidPng(source, {
|
|
121
|
+
theme: 'dark',
|
|
122
|
+
maxWidth: options.maxWidth,
|
|
123
|
+
maxHeight: options.maxHeight,
|
|
124
|
+
renderScale: options.renderScale,
|
|
125
|
+
});
|
|
126
|
+
const localResult = {
|
|
127
|
+
pngBase64: localRendered.pngBase64,
|
|
128
|
+
width: localRendered.width,
|
|
129
|
+
height: localRendered.height,
|
|
130
|
+
renderer: 'local-resvg',
|
|
131
|
+
normalizedSource,
|
|
132
|
+
};
|
|
133
|
+
if (includeSvg && typeof localRendered.svg === 'string' && localRendered.svg.trim()) {
|
|
134
|
+
localResult.svg = localRendered.svg;
|
|
135
|
+
}
|
|
136
|
+
if (options.includeStages) {
|
|
137
|
+
localResult.stages = await collectMermaidRenderStageSnapshots(source, {
|
|
138
|
+
theme: 'dark',
|
|
139
|
+
maxWidth: options.maxWidth,
|
|
140
|
+
maxHeight: options.maxHeight,
|
|
141
|
+
renderScale: options.renderScale,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
return localResult;
|
|
145
|
+
};
|
|
146
|
+
return [
|
|
147
|
+
{
|
|
148
|
+
method: 'POST',
|
|
149
|
+
path: '/api/render/math',
|
|
150
|
+
handler: async (req, res) => {
|
|
151
|
+
try {
|
|
152
|
+
const body = await readBody(req);
|
|
153
|
+
const payload = JSON.parse(body);
|
|
154
|
+
const expression = typeof payload?.expression === 'string'
|
|
155
|
+
? payload.expression
|
|
156
|
+
: (typeof payload?.source === 'string' ? payload.source : '');
|
|
157
|
+
if (!expression.trim()) {
|
|
158
|
+
json(res, 400, { success: false, error: 'Missing expression' });
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const { renderMathPng } = await Promise.resolve().then(() => __importStar(require('../reader_renderer')));
|
|
162
|
+
const result = await renderMathPng(expression, {
|
|
163
|
+
displayMode: payload?.displayMode !== false,
|
|
164
|
+
maxWidth: parseOptionalPositiveDimension(payload?.maxWidth),
|
|
165
|
+
maxHeight: parseOptionalPositiveDimension(payload?.maxHeight),
|
|
166
|
+
renderScale: parseOptionalPositiveScale(payload?.renderScale),
|
|
167
|
+
});
|
|
168
|
+
const materialization = (0, RenderMaterializer_1.resolveRenderMaterializationDecision)({
|
|
169
|
+
exportProfileId: payload?.exportProfileId,
|
|
170
|
+
platformTarget: payload?.platformTarget,
|
|
171
|
+
});
|
|
172
|
+
json(res, 200, {
|
|
173
|
+
success: true,
|
|
174
|
+
pngBase64: result.pngBase64,
|
|
175
|
+
width: result.width,
|
|
176
|
+
height: result.height,
|
|
177
|
+
materialization,
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
catch (e) {
|
|
181
|
+
fail(res, e, 'POST /api/render/math');
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
method: 'POST',
|
|
187
|
+
path: '/api/render/mermaid',
|
|
188
|
+
handler: async (req, res) => {
|
|
189
|
+
let source = '';
|
|
190
|
+
try {
|
|
191
|
+
const body = await readBody(req);
|
|
192
|
+
const payload = JSON.parse(body);
|
|
193
|
+
source = typeof payload?.source === 'string'
|
|
194
|
+
? payload.source
|
|
195
|
+
: (typeof payload?.diagram === 'string' ? payload.diagram : '');
|
|
196
|
+
if (!source.trim()) {
|
|
197
|
+
json(res, 400, { success: false, error: 'Missing source' });
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
const includeStages = payload?.includeStages === true;
|
|
201
|
+
const materialization = (0, RenderMaterializer_1.resolveRenderMaterializationDecision)({
|
|
202
|
+
exportProfileId: payload?.exportProfileId,
|
|
203
|
+
platformTarget: payload?.platformTarget,
|
|
204
|
+
includeSvg: payload?.includeSvg === true,
|
|
205
|
+
includeStages,
|
|
206
|
+
rendererPreference: payload?.renderer,
|
|
207
|
+
});
|
|
208
|
+
const rendererPreference = normalizeMermaidRendererPreference(materialization.rendererPreference);
|
|
209
|
+
const responsePayload = await renderMermaidWithPreference(source, {
|
|
210
|
+
rendererPreference,
|
|
211
|
+
includeStages: materialization.includeStages,
|
|
212
|
+
includeSvg: materialization.includeSvg,
|
|
213
|
+
maxWidth: parseOptionalPositiveDimension(payload?.maxWidth),
|
|
214
|
+
maxHeight: parseOptionalPositiveDimension(payload?.maxHeight),
|
|
215
|
+
renderScale: parseOptionalPositiveScale(payload?.renderScale),
|
|
216
|
+
});
|
|
217
|
+
responsePayload.materialization = materialization;
|
|
218
|
+
json(res, 200, responsePayload);
|
|
219
|
+
}
|
|
220
|
+
catch (e) {
|
|
221
|
+
try {
|
|
222
|
+
const { normalizeMermaidDefinition } = await Promise.resolve().then(() => __importStar(require('../reader_renderer')));
|
|
223
|
+
json(res, 500, {
|
|
224
|
+
success: false,
|
|
225
|
+
error: String(e),
|
|
226
|
+
normalizedSource: normalizeMermaidDefinition(source),
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
catch {
|
|
230
|
+
fail(res, e, 'POST /api/render/mermaid');
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
method: 'POST',
|
|
237
|
+
path: '/api/render/graphviz',
|
|
238
|
+
handler: async (req, res) => {
|
|
239
|
+
try {
|
|
240
|
+
const body = await readBody(req);
|
|
241
|
+
json(res, 200, { success: true, message: 'graphviz render route' });
|
|
242
|
+
}
|
|
243
|
+
catch (e) {
|
|
244
|
+
fail(res, e, 'POST /api/render/graphviz');
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
method: 'POST',
|
|
250
|
+
path: '/api/clipboard/image',
|
|
251
|
+
handler: async (req, res) => {
|
|
252
|
+
try {
|
|
253
|
+
const body = await readBody(req);
|
|
254
|
+
const { pngBase64 } = JSON.parse(body);
|
|
255
|
+
const { copyPngToClipboard } = await Promise.resolve().then(() => __importStar(require('../native_clipboard')));
|
|
256
|
+
await copyPngToClipboard(Buffer.from(pngBase64 || '', 'base64'));
|
|
257
|
+
json(res, 200, { success: true });
|
|
258
|
+
}
|
|
259
|
+
catch (e) {
|
|
260
|
+
fail(res, e, 'POST /api/clipboard/image');
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
method: 'POST',
|
|
266
|
+
path: '/api/clipboard/image-binary',
|
|
267
|
+
handler: async (req, res) => {
|
|
268
|
+
try {
|
|
269
|
+
const chunks = [];
|
|
270
|
+
req.on('data', (c) => chunks.push(c));
|
|
271
|
+
await new Promise((resolve, reject) => {
|
|
272
|
+
req.on('end', resolve);
|
|
273
|
+
req.on('error', reject);
|
|
274
|
+
});
|
|
275
|
+
const { copyPngToClipboard } = await Promise.resolve().then(() => __importStar(require('../native_clipboard')));
|
|
276
|
+
await copyPngToClipboard(Buffer.concat(chunks));
|
|
277
|
+
json(res, 200, { success: true });
|
|
278
|
+
}
|
|
279
|
+
catch (e) {
|
|
280
|
+
fail(res, e, 'POST /api/clipboard/image-binary');
|
|
281
|
+
}
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
];
|
|
285
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.__runtimeRunbookRouteOpsTestUtils = void 0;
|
|
4
|
+
exports.createRuntimeRunbookRouteOps = createRuntimeRunbookRouteOps;
|
|
5
|
+
const learning_1 = require("../learning");
|
|
6
|
+
function normalizeVerificationStatus(value) {
|
|
7
|
+
const normalized = String(value || '').trim().toLowerCase();
|
|
8
|
+
return (normalized === 'pass'
|
|
9
|
+
|| normalized === 'warn'
|
|
10
|
+
|| normalized === 'fail')
|
|
11
|
+
? normalized
|
|
12
|
+
: 'unknown';
|
|
13
|
+
}
|
|
14
|
+
function buildRuntimeRunbookVerifyFallbackResult(input) {
|
|
15
|
+
return {
|
|
16
|
+
generatedAt: input.generatedAt,
|
|
17
|
+
requestedCheckId: input.requestedCheckId,
|
|
18
|
+
selectedCheckId: '',
|
|
19
|
+
effectiveCheckId: '',
|
|
20
|
+
selectedCheckStatus: 'unknown',
|
|
21
|
+
selectedCheckEscalation: 'normal',
|
|
22
|
+
selectedCheckPriorityScore: 0,
|
|
23
|
+
selectedCheckMessage: 'No verification history available yet.',
|
|
24
|
+
verificationTargets: Array.isArray(input.runbook.verificationTargets)
|
|
25
|
+
? input.runbook.verificationTargets
|
|
26
|
+
: [],
|
|
27
|
+
selectedCheckEscalationActions: [],
|
|
28
|
+
traceSummary: {
|
|
29
|
+
returnedRecords: 0,
|
|
30
|
+
errorRequests: 0,
|
|
31
|
+
errorRatioPct: 0,
|
|
32
|
+
p95DurationMs: 0,
|
|
33
|
+
},
|
|
34
|
+
selectedCheckHistory: {
|
|
35
|
+
returnedRecords: 0,
|
|
36
|
+
activeRiskStreak: 0,
|
|
37
|
+
activeFailStreak: 0,
|
|
38
|
+
trendStatus: 'insufficient_data',
|
|
39
|
+
},
|
|
40
|
+
selectedCheckRemediation: {
|
|
41
|
+
latestStatus: '',
|
|
42
|
+
trendStatus: 'insufficient_data',
|
|
43
|
+
riskRatioPct: 0,
|
|
44
|
+
},
|
|
45
|
+
queryVectorAccelerationIndexSyncHealth: input.buildIndexSyncHealthSummary(input.runtimeCapabilityMatrix),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function createRuntimeRunbookRouteOps(deps) {
|
|
49
|
+
return {
|
|
50
|
+
getRunbook: async (request = {}) => {
|
|
51
|
+
const generatedAt = new Date().toISOString();
|
|
52
|
+
const runtimePayload = await deps.buildRuntimePayload(generatedAt);
|
|
53
|
+
return (0, learning_1.buildRuntimeCapabilityRunbook)(runtimePayload.runtimeCapabilityMatrix, String(request.checkId || '').trim());
|
|
54
|
+
},
|
|
55
|
+
verify: async (request = {}) => {
|
|
56
|
+
const requestedCheckId = deps.normalizeCheckId(request.checkId || '');
|
|
57
|
+
const sinceMinutes = Math.max(0, Math.floor(Number(request.sinceMinutes || 1440)));
|
|
58
|
+
const traceLimit = Math.max(1, Math.floor(Number(request.limit || 20)));
|
|
59
|
+
const generatedAt = new Date().toISOString();
|
|
60
|
+
const runtimePayload = await deps.buildRuntimePayload(generatedAt);
|
|
61
|
+
const runbook = (0, learning_1.buildRuntimeCapabilityRunbook)(runtimePayload.runtimeCapabilityMatrix, requestedCheckId);
|
|
62
|
+
const selectedCheckId = deps.normalizeCheckId(String(runbook.selectedCheck?.checkId || requestedCheckId));
|
|
63
|
+
if (selectedCheckId) {
|
|
64
|
+
const replayResult = await deps.replayVerificationForCheck({
|
|
65
|
+
checkId: selectedCheckId,
|
|
66
|
+
sinceMinutes,
|
|
67
|
+
traceLimit,
|
|
68
|
+
});
|
|
69
|
+
if (replayResult) {
|
|
70
|
+
const resolvedCheckId = deps.normalizeCheckId(String(replayResult.resolvedCheckId || selectedCheckId));
|
|
71
|
+
return {
|
|
72
|
+
...replayResult,
|
|
73
|
+
selectedCheckId: resolvedCheckId || selectedCheckId,
|
|
74
|
+
effectiveCheckId: resolvedCheckId || selectedCheckId,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return buildRuntimeRunbookVerifyFallbackResult({
|
|
79
|
+
generatedAt,
|
|
80
|
+
requestedCheckId,
|
|
81
|
+
runbook,
|
|
82
|
+
runtimeCapabilityMatrix: runtimePayload.runtimeCapabilityMatrix,
|
|
83
|
+
buildIndexSyncHealthSummary: deps.buildIndexSyncHealthSummary,
|
|
84
|
+
});
|
|
85
|
+
},
|
|
86
|
+
getHistory: async (request = {}) => deps.queryHistory({
|
|
87
|
+
limit: deps.parseHistoryLimit(request.limit),
|
|
88
|
+
checkId: deps.normalizeCheckId(request.checkId || ''),
|
|
89
|
+
sinceMinutes: deps.parseHistorySinceMinutes(request.sinceMinutes),
|
|
90
|
+
status: deps.normalizeVerificationStatus(request.status || ''),
|
|
91
|
+
}),
|
|
92
|
+
getChecks: async (request = {}) => deps.queryChecks({
|
|
93
|
+
limit: deps.parseChecksLimit(request.limit),
|
|
94
|
+
sinceMinutes: deps.parseHistorySinceMinutes(request.sinceMinutes),
|
|
95
|
+
status: deps.normalizeVerificationStatus(request.status || ''),
|
|
96
|
+
checkQuery: String(request.checkQuery || '').trim(),
|
|
97
|
+
}),
|
|
98
|
+
getActionQueue: async (request = {}) => deps.queryActionQueue({
|
|
99
|
+
checksQuery: {
|
|
100
|
+
limit: deps.parseChecksLimit(request.limit),
|
|
101
|
+
sinceMinutes: deps.parseHistorySinceMinutes(request.sinceMinutes),
|
|
102
|
+
status: deps.normalizeVerificationStatus(request.status || ''),
|
|
103
|
+
checkQuery: String(request.checkQuery || '').trim(),
|
|
104
|
+
},
|
|
105
|
+
queueLimit: deps.parseActionQueueLimit(request.queueLimit),
|
|
106
|
+
priorityFilter: deps.normalizeActionQueuePriorityFilter(request.priority || ''),
|
|
107
|
+
categoryFilter: deps.normalizeActionQueueCategoryFilter(request.category || ''),
|
|
108
|
+
checkIdFilter: deps.normalizeCheckId(request.checkId || ''),
|
|
109
|
+
remediationStatusFilter: deps.normalizeActionQueueRemediationStatusFilter(request.remediationStatus || ''),
|
|
110
|
+
remediationTrendFilter: deps.normalizeActionQueueRemediationTrendFilter(request.remediationTrend || ''),
|
|
111
|
+
}),
|
|
112
|
+
getRemediationHistory: async (request = {}) => deps.queryRemediationHistory({
|
|
113
|
+
limit: deps.parseRemediationLimit(request.limit),
|
|
114
|
+
sinceMinutes: deps.parseHistorySinceMinutes(request.sinceMinutes),
|
|
115
|
+
status: deps.normalizeRemediationStatusQuery(request.status || ''),
|
|
116
|
+
source: deps.normalizeRemediationSource(request.source || ''),
|
|
117
|
+
checkId: deps.normalizeCheckId(request.checkId || ''),
|
|
118
|
+
}),
|
|
119
|
+
getReplaySchedule: async () => deps.getReplaySchedule(),
|
|
120
|
+
recordRemediationEvent: async (payload, requestId = '') => {
|
|
121
|
+
const record = deps.normalizeRemediationEventPayload(payload, requestId);
|
|
122
|
+
deps.appendRemediationEventRecord(record);
|
|
123
|
+
deps.triggerReplayScheduleFromEvent();
|
|
124
|
+
return {
|
|
125
|
+
record,
|
|
126
|
+
summary: {
|
|
127
|
+
totalRecords: Math.max(0, Math.floor(Number(deps.getRemediationEventCount() || 0))),
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
},
|
|
131
|
+
replayRemediationEvent: async (payload) => {
|
|
132
|
+
const replayOptions = deps.normalizeRemediationReplayRequestPayload(payload);
|
|
133
|
+
return deps.replayRemediationEvents(replayOptions);
|
|
134
|
+
},
|
|
135
|
+
updateReplaySchedule: async (payload) => deps.updateReplaySchedule(payload),
|
|
136
|
+
tickReplaySchedule: async (payload = {}) => {
|
|
137
|
+
const tickOptions = deps.normalizeReplayScheduleTickPayload(payload);
|
|
138
|
+
return deps.tickReplaySchedule({
|
|
139
|
+
force: tickOptions.force,
|
|
140
|
+
dryRunOverride: tickOptions.dryRunOverride,
|
|
141
|
+
actor: 'modular_route',
|
|
142
|
+
});
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
exports.__runtimeRunbookRouteOpsTestUtils = {
|
|
147
|
+
buildRuntimeRunbookVerifyFallbackResult,
|
|
148
|
+
normalizeVerificationStatus,
|
|
149
|
+
};
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const runtimeRunbookRouteOps_1 = require("./runtimeRunbookRouteOps");
|
|
4
|
+
function createRuntimeCapabilityMatrix(overrides = {}) {
|
|
5
|
+
return {
|
|
6
|
+
generatedAt: '2026-06-06T10:00:00.000Z',
|
|
7
|
+
overallStatus: 'degraded',
|
|
8
|
+
summary: {
|
|
9
|
+
passCount: 0,
|
|
10
|
+
warnCount: 0,
|
|
11
|
+
failCount: 1,
|
|
12
|
+
},
|
|
13
|
+
checks: [
|
|
14
|
+
{
|
|
15
|
+
checkId: 'alpha_check',
|
|
16
|
+
status: 'fail',
|
|
17
|
+
message: 'alpha failed',
|
|
18
|
+
observed: 'observed',
|
|
19
|
+
priorityScore: 12,
|
|
20
|
+
recommendedActions: ['Inspect alpha'],
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
signals: {
|
|
24
|
+
topRiskCheckId: 'alpha_check',
|
|
25
|
+
},
|
|
26
|
+
...overrides,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function createDependencies(overrides = {}) {
|
|
30
|
+
return {
|
|
31
|
+
buildRuntimePayload: jest.fn(async (generatedAt) => ({
|
|
32
|
+
runtimeCapabilityMatrix: createRuntimeCapabilityMatrix({
|
|
33
|
+
generatedAt,
|
|
34
|
+
}),
|
|
35
|
+
})),
|
|
36
|
+
normalizeCheckId: jest.fn((value) => String(value || '').trim().toLowerCase()),
|
|
37
|
+
replayVerificationForCheck: jest.fn(async () => null),
|
|
38
|
+
buildIndexSyncHealthSummary: jest.fn(() => ({ health: 'index-sync-ok' })),
|
|
39
|
+
queryHistory: jest.fn(async (request) => request),
|
|
40
|
+
parseHistoryLimit: jest.fn((value) => Number(value || 20)),
|
|
41
|
+
parseHistorySinceMinutes: jest.fn((value) => Number(value || 1440)),
|
|
42
|
+
normalizeVerificationStatus: jest.fn((value) => String(value || '').trim().toLowerCase()),
|
|
43
|
+
queryChecks: jest.fn(async (request) => request),
|
|
44
|
+
parseChecksLimit: jest.fn((value) => Number(value || 8)),
|
|
45
|
+
queryActionQueue: jest.fn(async (request) => request),
|
|
46
|
+
parseActionQueueLimit: jest.fn((value) => Number(value || 12)),
|
|
47
|
+
normalizeActionQueuePriorityFilter: jest.fn((value) => String(value || '').trim().toLowerCase()),
|
|
48
|
+
normalizeActionQueueCategoryFilter: jest.fn((value) => String(value || '').trim().toLowerCase()),
|
|
49
|
+
normalizeActionQueueRemediationStatusFilter: jest.fn((value) => String(value || '').trim().toLowerCase()),
|
|
50
|
+
normalizeActionQueueRemediationTrendFilter: jest.fn((value) => String(value || '').trim().toLowerCase()),
|
|
51
|
+
queryRemediationHistory: jest.fn(async (request) => request),
|
|
52
|
+
parseRemediationLimit: jest.fn((value) => Number(value || 20)),
|
|
53
|
+
normalizeRemediationStatusQuery: jest.fn((value) => String(value || '').trim().toLowerCase()),
|
|
54
|
+
normalizeRemediationSource: jest.fn((value) => String(value || '').trim().toLowerCase()),
|
|
55
|
+
getReplaySchedule: jest.fn(async () => ({ enabled: true })),
|
|
56
|
+
normalizeRemediationEventPayload: jest.fn((payload, requestId) => ({
|
|
57
|
+
payload,
|
|
58
|
+
requestId,
|
|
59
|
+
})),
|
|
60
|
+
appendRemediationEventRecord: jest.fn(),
|
|
61
|
+
getRemediationEventCount: jest.fn(() => 3),
|
|
62
|
+
triggerReplayScheduleFromEvent: jest.fn(),
|
|
63
|
+
normalizeRemediationReplayRequestPayload: jest.fn((payload) => ({
|
|
64
|
+
normalizedReplayPayload: payload,
|
|
65
|
+
})),
|
|
66
|
+
replayRemediationEvents: jest.fn(async (payload) => payload),
|
|
67
|
+
updateReplaySchedule: jest.fn(async (payload) => ({
|
|
68
|
+
updated: payload,
|
|
69
|
+
})),
|
|
70
|
+
normalizeReplayScheduleTickPayload: jest.fn((payload) => ({
|
|
71
|
+
force: Boolean(payload?.force),
|
|
72
|
+
dryRunOverride: payload?.dryRunOverride,
|
|
73
|
+
})),
|
|
74
|
+
tickReplaySchedule: jest.fn(async (options) => options),
|
|
75
|
+
...overrides,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
describe('runtimeRunbookRouteOps', () => {
|
|
79
|
+
test('verify reuses replay result and resolves selected/effective check ids', async () => {
|
|
80
|
+
const deps = createDependencies({
|
|
81
|
+
replayVerificationForCheck: jest.fn(async () => ({
|
|
82
|
+
resolvedCheckId: 'alpha_check_resolved',
|
|
83
|
+
replayedAt: '2026-06-06T10:01:00.000Z',
|
|
84
|
+
selectedCheckStatus: 'fail',
|
|
85
|
+
})),
|
|
86
|
+
});
|
|
87
|
+
const ops = (0, runtimeRunbookRouteOps_1.createRuntimeRunbookRouteOps)(deps);
|
|
88
|
+
const result = await ops.verify?.({
|
|
89
|
+
checkId: 'alpha_check',
|
|
90
|
+
sinceMinutes: 60,
|
|
91
|
+
limit: 15,
|
|
92
|
+
});
|
|
93
|
+
expect(deps.replayVerificationForCheck).toHaveBeenCalledWith({
|
|
94
|
+
checkId: 'alpha_check',
|
|
95
|
+
sinceMinutes: 60,
|
|
96
|
+
traceLimit: 15,
|
|
97
|
+
});
|
|
98
|
+
expect(result).toMatchObject({
|
|
99
|
+
resolvedCheckId: 'alpha_check_resolved',
|
|
100
|
+
selectedCheckId: 'alpha_check_resolved',
|
|
101
|
+
effectiveCheckId: 'alpha_check_resolved',
|
|
102
|
+
selectedCheckStatus: 'fail',
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
test('verify returns stable fallback result when no verification history is available', async () => {
|
|
106
|
+
const deps = createDependencies();
|
|
107
|
+
const ops = (0, runtimeRunbookRouteOps_1.createRuntimeRunbookRouteOps)(deps);
|
|
108
|
+
const result = await ops.verify?.({
|
|
109
|
+
checkId: 'alpha_check',
|
|
110
|
+
});
|
|
111
|
+
expect(result).toMatchObject({
|
|
112
|
+
requestedCheckId: 'alpha_check',
|
|
113
|
+
selectedCheckId: '',
|
|
114
|
+
effectiveCheckId: '',
|
|
115
|
+
selectedCheckStatus: 'unknown',
|
|
116
|
+
selectedCheckEscalation: 'normal',
|
|
117
|
+
selectedCheckMessage: 'No verification history available yet.',
|
|
118
|
+
selectedCheckHistory: {
|
|
119
|
+
returnedRecords: 0,
|
|
120
|
+
activeRiskStreak: 0,
|
|
121
|
+
activeFailStreak: 0,
|
|
122
|
+
trendStatus: 'insufficient_data',
|
|
123
|
+
},
|
|
124
|
+
selectedCheckRemediation: {
|
|
125
|
+
latestStatus: '',
|
|
126
|
+
trendStatus: 'insufficient_data',
|
|
127
|
+
riskRatioPct: 0,
|
|
128
|
+
},
|
|
129
|
+
queryVectorAccelerationIndexSyncHealth: {
|
|
130
|
+
health: 'index-sync-ok',
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
expect(Array.isArray(result.verificationTargets)).toBe(true);
|
|
134
|
+
expect(result.verificationTargets.length).toBeGreaterThan(0);
|
|
135
|
+
});
|
|
136
|
+
test('getActionQueue delegates normalized filters to the query owner', async () => {
|
|
137
|
+
const deps = createDependencies();
|
|
138
|
+
const ops = (0, runtimeRunbookRouteOps_1.createRuntimeRunbookRouteOps)(deps);
|
|
139
|
+
await ops.getActionQueue?.({
|
|
140
|
+
limit: 9,
|
|
141
|
+
sinceMinutes: 33,
|
|
142
|
+
status: 'WARN',
|
|
143
|
+
checkQuery: 'alpha',
|
|
144
|
+
queueLimit: 7,
|
|
145
|
+
priority: 'P1',
|
|
146
|
+
category: 'trend',
|
|
147
|
+
checkId: 'ALPHA_CHECK',
|
|
148
|
+
remediationStatus: 'SUCCESS',
|
|
149
|
+
remediationTrend: 'REGRESSING',
|
|
150
|
+
});
|
|
151
|
+
expect(deps.queryActionQueue).toHaveBeenCalledWith({
|
|
152
|
+
checksQuery: {
|
|
153
|
+
limit: 9,
|
|
154
|
+
sinceMinutes: 33,
|
|
155
|
+
status: 'warn',
|
|
156
|
+
checkQuery: 'alpha',
|
|
157
|
+
},
|
|
158
|
+
queueLimit: 7,
|
|
159
|
+
priorityFilter: 'p1',
|
|
160
|
+
categoryFilter: 'trend',
|
|
161
|
+
checkIdFilter: 'alpha_check',
|
|
162
|
+
remediationStatusFilter: 'success',
|
|
163
|
+
remediationTrendFilter: 'regressing',
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
test('recordRemediationEvent appends the normalized record and returns count summary', async () => {
|
|
167
|
+
const deps = createDependencies();
|
|
168
|
+
const ops = (0, runtimeRunbookRouteOps_1.createRuntimeRunbookRouteOps)(deps);
|
|
169
|
+
const result = await ops.recordRemediationEvent?.({
|
|
170
|
+
action: 'retry',
|
|
171
|
+
}, 'req-123');
|
|
172
|
+
expect(deps.normalizeRemediationEventPayload).toHaveBeenCalledWith({
|
|
173
|
+
action: 'retry',
|
|
174
|
+
}, 'req-123');
|
|
175
|
+
expect(deps.appendRemediationEventRecord).toHaveBeenCalledWith({
|
|
176
|
+
payload: {
|
|
177
|
+
action: 'retry',
|
|
178
|
+
},
|
|
179
|
+
requestId: 'req-123',
|
|
180
|
+
});
|
|
181
|
+
expect(deps.triggerReplayScheduleFromEvent).toHaveBeenCalled();
|
|
182
|
+
expect(result).toEqual({
|
|
183
|
+
record: {
|
|
184
|
+
payload: {
|
|
185
|
+
action: 'retry',
|
|
186
|
+
},
|
|
187
|
+
requestId: 'req-123',
|
|
188
|
+
},
|
|
189
|
+
summary: {
|
|
190
|
+
totalRecords: 3,
|
|
191
|
+
},
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
});
|