@pb33f/cowboy-components 0.7.4 → 0.7.6
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/dist/components/auth/login-button.d.ts +2 -0
- package/dist/components/auth/login-button.js +15 -3
- package/dist/components/auth/login-panel.js +1 -1
- package/dist/components/auth/oauth-login.d.ts +1 -0
- package/dist/components/auth/oauth-login.js +11 -5
- package/dist/components/editor/editor-breadcrumb.css.js +1 -1
- package/dist/components/model-renderer/rendered-node.d.ts +2 -0
- package/dist/components/model-renderer/rendered-node.js +18 -0
- package/dist/components/model-renderer/responses.d.ts +11 -0
- package/dist/components/model-renderer/responses.js +46 -0
- package/dist/components/model-tree/tree.js +1 -1
- package/dist/components/rodeo/rodeo.js +1 -1
- package/dist/components/the-doctor/the-doctor.css.js +1 -1
- package/dist/components/the-doctor/the-doctor.d.ts +112 -120
- package/dist/components/the-doctor/the-doctor.js +134 -1735
- package/dist/components/the-doctor/upload-archive.d.ts +1 -0
- package/dist/components/the-doctor/upload-archive.js +36 -13
- package/dist/controllers/auth-controller.d.ts +25 -0
- package/dist/controllers/auth-controller.js +154 -0
- package/dist/controllers/broker-controller.d.ts +22 -0
- package/dist/controllers/broker-controller.js +107 -0
- package/dist/controllers/diagnostic-controller.d.ts +6 -0
- package/dist/controllers/diagnostic-controller.js +262 -0
- package/dist/controllers/docs-controller.d.ts +8 -0
- package/dist/controllers/docs-controller.js +143 -0
- package/dist/controllers/model-controller.d.ts +8 -0
- package/dist/controllers/model-controller.js +87 -0
- package/dist/controllers/node-clicker-controller.d.ts +11 -0
- package/dist/controllers/node-clicker-controller.js +362 -0
- package/dist/controllers/problem-controller.d.ts +7 -0
- package/dist/controllers/problem-controller.js +46 -0
- package/dist/controllers/rolodex-controller.d.ts +10 -0
- package/dist/controllers/rolodex-controller.js +126 -0
- package/dist/controllers/rule-controller.d.ts +19 -0
- package/dist/controllers/rule-controller.js +264 -0
- package/dist/controllers/spec-controller.d.ts +8 -0
- package/dist/controllers/spec-controller.js +78 -0
- package/dist/controllers/state-controller.d.ts +9 -0
- package/dist/controllers/state-controller.js +279 -0
- package/dist/cowboy-components.umd.cjs +1152 -1121
- package/dist/css/shared.css.js +5 -0
- package/dist/events/doctor.d.ts +10 -0
- package/dist/events/doctor.js +2 -0
- package/dist/model/api-response.d.ts +7 -0
- package/dist/model/api-response.js +2 -0
- package/dist/services/auth-service.d.ts +1 -0
- package/dist/services/auth-service.js +28 -0
- package/dist/services/linting-service.js +11 -2
- package/dist/services/model-service.d.ts +2 -1
- package/dist/services/model-service.js +31 -5
- package/package.json +1 -1
- package/dist/controllers/auth.d.ts +0 -20
- package/dist/controllers/auth.js +0 -101
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
import { RolodexFilesBag, RolodexStateBag } from "../components/the-doctor/the-doctor.js";
|
|
2
|
+
import { RolodexTreeNodeClicked } from "../events/doctor.js";
|
|
3
|
+
import { ToastType } from "../model/toast.js";
|
|
4
|
+
import { NodeType } from "../model/node_type.js";
|
|
5
|
+
import { ModelService } from "../services/model-service.js";
|
|
6
|
+
export class NodeClickerController extends EventTarget {
|
|
7
|
+
constructor(doc) {
|
|
8
|
+
super();
|
|
9
|
+
this.doc = doc;
|
|
10
|
+
}
|
|
11
|
+
rolodexTreeNodeClicked(evt) {
|
|
12
|
+
const fileBag = this.doc.rolodexFilesBag?.get(RolodexFilesBag);
|
|
13
|
+
const handleRolodexResponse = (result) => {
|
|
14
|
+
this.doc.rolodexActivePath = evt.detail.path;
|
|
15
|
+
this.doc.rolodexActiveHash = evt.detail.nodeHashId;
|
|
16
|
+
this.doc.editor.setValue(result.instance, true);
|
|
17
|
+
this.doc.editor.setCurrentPath(this.doc.rolodexActivePath);
|
|
18
|
+
this.doc.modelController.fetchRefMap(this.doc.rolodexActivePath);
|
|
19
|
+
const probs = this.doc.rolodexProblemMap.get(this.doc.rolodexActivePath);
|
|
20
|
+
if (probs) {
|
|
21
|
+
this.doc.editor.setMarkers(probs);
|
|
22
|
+
}
|
|
23
|
+
// set the editor file type
|
|
24
|
+
let language = 'yaml';
|
|
25
|
+
const ext = evt.detail?.path?.split('.').pop();
|
|
26
|
+
if (ext) {
|
|
27
|
+
switch (ext) {
|
|
28
|
+
case NodeType.JSON:
|
|
29
|
+
language = NodeType.JSON;
|
|
30
|
+
break;
|
|
31
|
+
case NodeType.GO:
|
|
32
|
+
language = NodeType.GO;
|
|
33
|
+
break;
|
|
34
|
+
case NodeType.PY:
|
|
35
|
+
language = 'python';
|
|
36
|
+
break;
|
|
37
|
+
case NodeType.JS:
|
|
38
|
+
language = 'javascript';
|
|
39
|
+
break;
|
|
40
|
+
case NodeType.TS:
|
|
41
|
+
language = 'typescript';
|
|
42
|
+
break;
|
|
43
|
+
case NodeType.PHP:
|
|
44
|
+
language = NodeType.PHP;
|
|
45
|
+
break;
|
|
46
|
+
case NodeType.XML:
|
|
47
|
+
language = NodeType.XML;
|
|
48
|
+
break;
|
|
49
|
+
case NodeType.JAVA:
|
|
50
|
+
language = NodeType.JAVA;
|
|
51
|
+
break;
|
|
52
|
+
case NodeType.RB:
|
|
53
|
+
language = 'ruby';
|
|
54
|
+
break;
|
|
55
|
+
case NodeType.RS:
|
|
56
|
+
language = 'rust';
|
|
57
|
+
break;
|
|
58
|
+
case NodeType.C:
|
|
59
|
+
language = NodeType.C;
|
|
60
|
+
break;
|
|
61
|
+
case NodeType.CPP:
|
|
62
|
+
language = NodeType.CPP;
|
|
63
|
+
break;
|
|
64
|
+
case NodeType.CS:
|
|
65
|
+
language = 'csharp';
|
|
66
|
+
break;
|
|
67
|
+
case NodeType.MD:
|
|
68
|
+
language = 'markdown';
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const existingState = this.doc.rolodexStateBag?.get(RolodexStateBag);
|
|
73
|
+
if (existingState) {
|
|
74
|
+
existingState.activePath = evt.detail.path;
|
|
75
|
+
existingState.activeHash = evt.detail.nodeHashId;
|
|
76
|
+
existingState.activeLanguage = language;
|
|
77
|
+
existingState.activeNode = result;
|
|
78
|
+
existingState.rootPath = this.doc.rolodexRootPath;
|
|
79
|
+
this.doc.rolodexStateBag?.set(RolodexStateBag, existingState);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
const existingState = {
|
|
83
|
+
activePath: evt.detail.path,
|
|
84
|
+
activeHash: evt.detail.nodeHashId,
|
|
85
|
+
activeLanguage: language,
|
|
86
|
+
activeNode: result,
|
|
87
|
+
rootHash: this.doc.rolodexRootHash,
|
|
88
|
+
rootPath: this.doc.rolodexRootPath
|
|
89
|
+
};
|
|
90
|
+
this.doc.rolodexStateBag?.set(RolodexStateBag, existingState);
|
|
91
|
+
}
|
|
92
|
+
this.doc.editor.switchLanguage(language);
|
|
93
|
+
let line = 1;
|
|
94
|
+
let col = 0;
|
|
95
|
+
if (evt.detail.line) {
|
|
96
|
+
line = evt.detail.line;
|
|
97
|
+
}
|
|
98
|
+
if (evt.detail.column) {
|
|
99
|
+
col = evt.detail.column;
|
|
100
|
+
}
|
|
101
|
+
this.doc.editor.editor?.setPosition({ lineNumber: line, column: col });
|
|
102
|
+
this.doc.editor.editor?.revealLineInCenter(line, col);
|
|
103
|
+
//this.lintSpec(result.instance);
|
|
104
|
+
if (evt.detail.path) {
|
|
105
|
+
this.doc.rolodexTree.openNodeByPath(evt.detail.path);
|
|
106
|
+
}
|
|
107
|
+
return language;
|
|
108
|
+
};
|
|
109
|
+
ModelService.queryRolodex(evt.detail.nodeHashId, evt.detail.path).then((result) => {
|
|
110
|
+
this.doc.editor.showBreadcrumb = true;
|
|
111
|
+
// clear all references
|
|
112
|
+
this.doc.referenceMapBag?.reset();
|
|
113
|
+
handleRolodexResponse(result.rolodexRoot);
|
|
114
|
+
if (evt.detail.path) {
|
|
115
|
+
if (fileBag && !fileBag.files[evt.detail.path]) {
|
|
116
|
+
fileBag.files[evt.detail.path] = result.rolodexRoot;
|
|
117
|
+
this.doc.rolodexFilesBag?.set(RolodexFilesBag, fileBag);
|
|
118
|
+
}
|
|
119
|
+
if (!fileBag) {
|
|
120
|
+
const rf = {
|
|
121
|
+
files: { [evt.detail.path]: result.rolodexRoot }
|
|
122
|
+
};
|
|
123
|
+
this.doc.rolodexFilesBag?.set(RolodexFilesBag, rf);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
explorerNodeClicked(evt, replaceRenderedNode = true) {
|
|
129
|
+
let found = false;
|
|
130
|
+
let foundRenderedNode;
|
|
131
|
+
this.doc.explorer.nodeComponents.forEach((node) => {
|
|
132
|
+
if (node.id === evt.detail.nodeId) {
|
|
133
|
+
let renderedNode;
|
|
134
|
+
if (replaceRenderedNode) {
|
|
135
|
+
renderedNode = this.doc.renderedNodeMap.get(node.id);
|
|
136
|
+
if (renderedNode && !this.doc.firstRun) {
|
|
137
|
+
this.doc.renderedNode.node = renderedNode;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
this.doc.selectedNodeHashId = node.body.node.idHash;
|
|
141
|
+
node.body.active = true;
|
|
142
|
+
this.doc.activeNode = node.body.node;
|
|
143
|
+
this.doc.explorer.activeNode = node.body.node;
|
|
144
|
+
found = true;
|
|
145
|
+
if (replaceRenderedNode) {
|
|
146
|
+
foundRenderedNode = renderedNode;
|
|
147
|
+
}
|
|
148
|
+
if (!evt.detail.noState) {
|
|
149
|
+
this.doc.addClickTrack(node.body.node);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
node.body.active = false;
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
if (!found) {
|
|
157
|
+
// might be filtered, check the filtered nodes
|
|
158
|
+
const node = this.doc.nodeIdMap.get(evt.detail.nodeId);
|
|
159
|
+
if (node) {
|
|
160
|
+
this.doc.selectedNodeHashId = node.idHash;
|
|
161
|
+
this.doc.activeNode = node;
|
|
162
|
+
this.doc.explorer.activeNode = node;
|
|
163
|
+
this.doc.explorer.equalizer.activeNode = node;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (foundRenderedNode) {
|
|
167
|
+
// when jumping back to the spec view, we need to set the line
|
|
168
|
+
this.doc.pendingLine = foundRenderedNode.keyLine;
|
|
169
|
+
}
|
|
170
|
+
this.doc.modelTree.explorerClicked(evt.detail.nodeId);
|
|
171
|
+
if (!this.doc.firstRun) {
|
|
172
|
+
this.doc.viewerPanel.click();
|
|
173
|
+
}
|
|
174
|
+
this.doc.explorer.requestUpdate();
|
|
175
|
+
}
|
|
176
|
+
modelTreeNodeClicked(evt) {
|
|
177
|
+
let node = this.doc.nodeIdMap.get(evt.detail.nodeId);
|
|
178
|
+
if (!node) {
|
|
179
|
+
node = this.doc.nodeIdHashMap.get(evt.detail.nodeId);
|
|
180
|
+
}
|
|
181
|
+
if (node) {
|
|
182
|
+
if (node.origin && node.origin != this.doc.rolodexActivePath && (node.origin != '/root.yaml' && node.origin != 'root.yaml')) {
|
|
183
|
+
// extract the rolodex id using the path
|
|
184
|
+
let hashId = '';
|
|
185
|
+
let path = '';
|
|
186
|
+
const fb = this.doc.rolodexFilesBag?.get(RolodexFilesBag);
|
|
187
|
+
if (fb) {
|
|
188
|
+
if (node.origin && fb.files[node.origin]) {
|
|
189
|
+
hashId = fb.files[node.origin].idHash;
|
|
190
|
+
path = node.origin;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
this.explorerNodeClicked(evt, true);
|
|
194
|
+
// we need to fire a rolodex tree node change event.
|
|
195
|
+
this.rolodexTreeNodeClicked(new CustomEvent(RolodexTreeNodeClicked, {
|
|
196
|
+
detail: {
|
|
197
|
+
nodeHashId: hashId,
|
|
198
|
+
path: path
|
|
199
|
+
}
|
|
200
|
+
}));
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
// don't jump to the root in the editor if the root is selected
|
|
204
|
+
if (node.idHash !== 'root') {
|
|
205
|
+
this.doc.editor.editor?.setPosition({ lineNumber: node.keyLine, column: 0 });
|
|
206
|
+
this.doc.editor.editor?.revealLineInCenter(node.keyLine);
|
|
207
|
+
}
|
|
208
|
+
if (this.doc.explorerVisible) {
|
|
209
|
+
this.doc.explorer.moveToNode(node, evt.detail.first);
|
|
210
|
+
}
|
|
211
|
+
this.doc.activeNode = node;
|
|
212
|
+
// add changes to active node.
|
|
213
|
+
if (evt.detail.changes) {
|
|
214
|
+
node.timeline = evt.detail.changes;
|
|
215
|
+
}
|
|
216
|
+
this.doc.explorer.activeNode = node;
|
|
217
|
+
this.doc.explorer.equalizer.activeNode = node;
|
|
218
|
+
const renderedNode = structuredClone(this.doc.renderedNodeMap.get(node.id));
|
|
219
|
+
if (renderedNode) {
|
|
220
|
+
if (evt.detail.changes) {
|
|
221
|
+
renderedNode.timeline = evt.detail.changes;
|
|
222
|
+
}
|
|
223
|
+
this.doc.renderedNode.node = renderedNode;
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
alert('no id found');
|
|
227
|
+
}
|
|
228
|
+
if (!evt.detail.noState) {
|
|
229
|
+
this.doc.addClickTrack(node);
|
|
230
|
+
evt.detail.noState = true;
|
|
231
|
+
}
|
|
232
|
+
this.explorerNodeClicked(evt, true);
|
|
233
|
+
if (this.doc.firstRun) {
|
|
234
|
+
this.doc.firstRun = false;
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
this.doc.viewerPanel.click();
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
this.doc.sendToast({
|
|
242
|
+
id: crypto.randomUUID(),
|
|
243
|
+
title: 'Unable to load change model',
|
|
244
|
+
type: ToastType.WARNING,
|
|
245
|
+
body: 'There is no-longer a model with the path `' + evt.detail.nodeId + '` in the document',
|
|
246
|
+
});
|
|
247
|
+
console.error('cannot navigate to node, path not found', evt.detail.nodeId);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
explorerReferenceClicked(evt) {
|
|
251
|
+
let nodeId = '';
|
|
252
|
+
this.doc.explorer.nodeComponents.forEach((node) => {
|
|
253
|
+
if (node.body.node.nodePath === evt.detail.nodePath) {
|
|
254
|
+
const renderedNode = this.doc.renderedNodeMap.get(node.body.node.id);
|
|
255
|
+
if (renderedNode) {
|
|
256
|
+
this.doc.editor.editor?.setPosition({ lineNumber: renderedNode.keyLine, column: 0 });
|
|
257
|
+
this.doc.editor.editor?.revealLineInCenter(renderedNode.keyLine);
|
|
258
|
+
this.doc.renderedNode.node = renderedNode;
|
|
259
|
+
nodeId = node.body.node.id;
|
|
260
|
+
this.doc.explorer.moveToNode(node.body.node);
|
|
261
|
+
this.doc.activeNode = node.body.node;
|
|
262
|
+
this.doc.explorer.activeNode = node.body.node;
|
|
263
|
+
this.doc.explorer.equalizer.activeNode = node.body.node;
|
|
264
|
+
}
|
|
265
|
+
node.body.active = true;
|
|
266
|
+
}
|
|
267
|
+
else {
|
|
268
|
+
node.body.active = false;
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
if (nodeId) {
|
|
272
|
+
this.doc.modelTree.explorerClicked(nodeId);
|
|
273
|
+
this.doc.explorer.requestUpdate();
|
|
274
|
+
this.doc.viewerPanel.click();
|
|
275
|
+
}
|
|
276
|
+
if (evt.detail.nodePath) {
|
|
277
|
+
let p = evt.detail.nodePath;
|
|
278
|
+
if (!p.startsWith('/') && !p.includes('#')) {
|
|
279
|
+
const dir = this.doc.rolodexRootPath.substring(0, this.doc.rolodexRootPath.lastIndexOf('/') + 1);
|
|
280
|
+
p = dir + p;
|
|
281
|
+
}
|
|
282
|
+
if (!p.startsWith('#/')) {
|
|
283
|
+
this.rolodexTreeNodeClicked(new CustomEvent(RolodexTreeNodeClicked, {
|
|
284
|
+
detail: {
|
|
285
|
+
path: p,
|
|
286
|
+
}
|
|
287
|
+
}));
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
documentReferenceClicked(evt) {
|
|
292
|
+
let location = '';
|
|
293
|
+
let line, col = 1;
|
|
294
|
+
let path = evt.detail.jsonPath;
|
|
295
|
+
let fullPath = '';
|
|
296
|
+
let file = '';
|
|
297
|
+
let rolodexId = '';
|
|
298
|
+
if (evt.detail.jsonPath.includes('||')) {
|
|
299
|
+
location = evt.detail.jsonPath.split('||')[1];
|
|
300
|
+
path = evt.detail.jsonPath.split('||')[0];
|
|
301
|
+
// location is formatted line:col-endCol
|
|
302
|
+
line = parseInt(location.split(':')[0]);
|
|
303
|
+
col = parseInt(location.split(':')[1]);
|
|
304
|
+
fullPath = evt.detail.jsonPath.split('||')[2];
|
|
305
|
+
if (fullPath != '') {
|
|
306
|
+
file = fullPath.split('#')[0];
|
|
307
|
+
}
|
|
308
|
+
rolodexId = evt.detail.jsonPath.split('||')[3];
|
|
309
|
+
}
|
|
310
|
+
this.doc.editor.editor?.setPosition({ lineNumber: line, column: col });
|
|
311
|
+
this.doc.editor.editor?.revealLineInCenter(line);
|
|
312
|
+
if (this.doc.nodeIdMap.has(path)) {
|
|
313
|
+
const node = this.doc.nodeIdMap.get(path);
|
|
314
|
+
if (node) {
|
|
315
|
+
if (this.doc.nodeIdHashMap.has(node.idHash)) {
|
|
316
|
+
const renderedNode = this.doc.renderedNodeMap.get(node.id);
|
|
317
|
+
if (renderedNode) {
|
|
318
|
+
this.doc.renderedNode.node = renderedNode;
|
|
319
|
+
this.doc.modelTree.explorerClicked(node.id);
|
|
320
|
+
// add a ref click
|
|
321
|
+
if (!evt.detail.noState) {
|
|
322
|
+
this.doc.addRefTrack(evt.detail.jsonPath);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
else {
|
|
328
|
+
this.doc.toastManager.addToastManually({
|
|
329
|
+
id: crypto.randomUUID(),
|
|
330
|
+
type: ToastType.INFO,
|
|
331
|
+
title: "Reference not found",
|
|
332
|
+
body: `Something went wrong, '${path}' not found`
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
else {
|
|
337
|
+
if (this.doc.rolodexActivePath != undefined && this.doc.rolodexActivePath != file) {
|
|
338
|
+
ModelService.queryRolodex(rolodexId, file).then((result) => {
|
|
339
|
+
this.doc.editor.showBreadcrumb = true;
|
|
340
|
+
this.doc.rolodexActivePath = file;
|
|
341
|
+
this.doc.editor.clearDecorations();
|
|
342
|
+
this.doc.editor.setValue(result.rolodexRoot.instance, true);
|
|
343
|
+
this.doc.editor.editor?.setPosition({ lineNumber: line, column: 1 });
|
|
344
|
+
this.doc.editor.editor?.revealLineInCenter(line);
|
|
345
|
+
this.doc.rolodexTree.explorerClicked(rolodexId);
|
|
346
|
+
this.doc.editor.setCurrentPath(file);
|
|
347
|
+
this.doc.modelController.fetchRefMap(file);
|
|
348
|
+
//this.lintSpec(result.rolodexRoot.instance);
|
|
349
|
+
// apply problems
|
|
350
|
+
if (this.doc.rolodexProblemMap.has(this.doc.rolodexActivePath)) {
|
|
351
|
+
const probs = this.doc.rolodexProblemMap.get(this.doc.rolodexActivePath);
|
|
352
|
+
if (probs) {
|
|
353
|
+
this.doc.editor.setMarkers(probs);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}).catch((e) => {
|
|
357
|
+
console.error('rolodex query failed', e);
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TheDoctor } from "../components/the-doctor/the-doctor";
|
|
2
|
+
import { ProblemClickedEvent } from "../events/doctor";
|
|
3
|
+
export declare class ProblemController extends EventTarget {
|
|
4
|
+
doc: TheDoctor;
|
|
5
|
+
constructor(doc: TheDoctor);
|
|
6
|
+
problemClicked(event: CustomEvent<ProblemClickedEvent>): void;
|
|
7
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ActiveView, RolodexTreeNodeClicked } from "../events/doctor";
|
|
2
|
+
import { SearchNodeTreeForPath } from "../model/graph";
|
|
3
|
+
export class ProblemController extends EventTarget {
|
|
4
|
+
constructor(doc) {
|
|
5
|
+
super();
|
|
6
|
+
this.doc = doc;
|
|
7
|
+
}
|
|
8
|
+
problemClicked(event) {
|
|
9
|
+
if (this.doc.selectedEditorTab != "spec") {
|
|
10
|
+
this.doc.editorTabGroup.show("spec");
|
|
11
|
+
this.doc.selectedEditorTab = "spec";
|
|
12
|
+
}
|
|
13
|
+
let sourceLocation = event.detail.problem.problemObject.sourceLocation;
|
|
14
|
+
// no source? use root
|
|
15
|
+
if (sourceLocation == '' || sourceLocation == undefined || sourceLocation == 'root') {
|
|
16
|
+
sourceLocation = this.doc.rolodexRootPath;
|
|
17
|
+
}
|
|
18
|
+
// locate the node in rolodex root
|
|
19
|
+
const node = SearchNodeTreeForPath(this.doc.rolodexRoot, sourceLocation);
|
|
20
|
+
if (node) {
|
|
21
|
+
// trigger a rolodex load
|
|
22
|
+
this.doc.nodeClickerController.rolodexTreeNodeClicked(new CustomEvent(RolodexTreeNodeClicked, {
|
|
23
|
+
detail: {
|
|
24
|
+
nodeHashId: node.idHash,
|
|
25
|
+
path: sourceLocation,
|
|
26
|
+
line: event.detail.problem.problemObject.startLineNumber,
|
|
27
|
+
column: event.detail.problem.problemObject.startColumn
|
|
28
|
+
}
|
|
29
|
+
}));
|
|
30
|
+
this.doc.detailsDrawer.close();
|
|
31
|
+
// make sure we select the file in the rolodex
|
|
32
|
+
this.doc.rolodexTree.openNodeByPath(sourceLocation);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
this.doc.controlTabGroup.show(ActiveView.Problems);
|
|
36
|
+
this.doc.editor.editor?.revealLineInCenter(event.detail.problem.line);
|
|
37
|
+
this.doc.editor.editor?.setPosition({
|
|
38
|
+
lineNumber: event.detail.problem.line,
|
|
39
|
+
column: event.detail.problem.column
|
|
40
|
+
});
|
|
41
|
+
this.doc.detailsDrawer.close();
|
|
42
|
+
if (!event.detail.launchedFromProblems) {
|
|
43
|
+
this.doc.problemList.lineClicked(event.detail.problem.problemObject.startLineNumber);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TheDoctor } from "../components/the-doctor/the-doctor.js";
|
|
2
|
+
import { NodeClickedEvent } from "../events/doctor.js";
|
|
3
|
+
import { Problem } from "../model/problem";
|
|
4
|
+
export declare class RolodexController extends EventTarget {
|
|
5
|
+
doc: TheDoctor;
|
|
6
|
+
constructor(doc: TheDoctor);
|
|
7
|
+
rolodexRootFileSelected(evt: CustomEvent<NodeClickedEvent>): void;
|
|
8
|
+
buildRolodexResultMap(results: Problem[]): Map<string, Problem[]>;
|
|
9
|
+
queryRolodex(currentPath?: string): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { RolodexResponseBag, RolodexStateBag } from "../components/the-doctor/the-doctor.js";
|
|
2
|
+
import { ModelService } from "../services/model-service";
|
|
3
|
+
export class RolodexController extends EventTarget {
|
|
4
|
+
constructor(doc) {
|
|
5
|
+
super();
|
|
6
|
+
this.doc = doc;
|
|
7
|
+
}
|
|
8
|
+
rolodexRootFileSelected(evt) {
|
|
9
|
+
this.doc.rolodexActivePath = evt.detail.path;
|
|
10
|
+
this.doc.rolodexActiveHash = evt.detail.nodeHashId;
|
|
11
|
+
this.doc.rolodexRootPath = evt.detail.path;
|
|
12
|
+
this.doc.importDisabled = true;
|
|
13
|
+
const existingState = this.doc.rolodexStateBag?.get(RolodexStateBag);
|
|
14
|
+
if (existingState) {
|
|
15
|
+
existingState.activePath = evt.detail.path;
|
|
16
|
+
existingState.activeHash = evt.detail.nodeHashId;
|
|
17
|
+
existingState.rootPath = evt.detail.path;
|
|
18
|
+
existingState.rootHash = evt.detail.nodeHashId;
|
|
19
|
+
this.doc.rolodexStateBag?.set(RolodexStateBag, existingState);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
const existingState = {
|
|
23
|
+
activePath: evt.detail.path,
|
|
24
|
+
activeHash: evt.detail.nodeHashId,
|
|
25
|
+
rootPath: evt.detail.path,
|
|
26
|
+
rootHash: evt.detail.nodeHashId
|
|
27
|
+
};
|
|
28
|
+
this.doc.rolodexStateBag?.set(RolodexStateBag, existingState);
|
|
29
|
+
}
|
|
30
|
+
if (evt.detail.nodeHashId) {
|
|
31
|
+
this.doc.rolodexRootHash = evt.detail.nodeHashId;
|
|
32
|
+
}
|
|
33
|
+
if (evt.detail.content) {
|
|
34
|
+
this.doc.rolodexNeedsReset = true;
|
|
35
|
+
this.doc.editor.setValue(evt.detail.content, true);
|
|
36
|
+
this.doc.diagnosticController.lintSpec(evt.detail.content);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
buildRolodexResultMap(results) {
|
|
40
|
+
// TODO: optimize this, it's a bit slow.
|
|
41
|
+
this.doc.rolodexProblemMap.clear();
|
|
42
|
+
results.forEach((problem) => {
|
|
43
|
+
// check if the source location is '/root.yaml'
|
|
44
|
+
if (problem.sourceLocation === '/root.yaml' || problem.sourceLocation === 'root.yaml') {
|
|
45
|
+
problem.sourceLocation = "root";
|
|
46
|
+
}
|
|
47
|
+
if (this.doc.rolodexProblemMap.has(problem.sourceLocation)) {
|
|
48
|
+
const problems = this.doc.rolodexProblemMap.get(problem.sourceLocation);
|
|
49
|
+
if (problems) {
|
|
50
|
+
problems.push(problem);
|
|
51
|
+
if (problem.sourceLocation) {
|
|
52
|
+
this.doc.rolodexProblemMap.set(problem.sourceLocation, problems);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
if (!this.doc.rolodexRootPath) {
|
|
56
|
+
this.doc.rolodexProblemMap.set("root", problems);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
this.doc.rolodexProblemMap.set(this.doc.rolodexRootPath, problems);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
if (problem.sourceLocation) {
|
|
66
|
+
this.doc.rolodexProblemMap.set(problem.sourceLocation, [problem]);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
if (!this.doc.rolodexRootPath) {
|
|
70
|
+
const currProblems = this.doc.rolodexProblemMap.get("root");
|
|
71
|
+
if (currProblems) {
|
|
72
|
+
currProblems.push(problem);
|
|
73
|
+
this.doc.rolodexProblemMap.set("root", currProblems);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
this.doc.rolodexProblemMap.set("root", [problem]);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
const currProblems = this.doc.rolodexProblemMap.get(this.doc.rolodexRootPath);
|
|
81
|
+
if (currProblems) {
|
|
82
|
+
currProblems.push(problem);
|
|
83
|
+
this.doc.rolodexProblemMap.set(this.doc.rolodexRootPath, currProblems);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
this.doc.rolodexProblemMap.set(this.doc.rolodexRootPath, [problem]);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
return this.doc.rolodexProblemMap;
|
|
93
|
+
}
|
|
94
|
+
queryRolodex(currentPath) {
|
|
95
|
+
ModelService.queryRolodex().then((result) => {
|
|
96
|
+
this.doc.modelController.fetchRefMap(currentPath);
|
|
97
|
+
this.doc.editor.showBreadcrumb = true;
|
|
98
|
+
this.doc.rolodexNeedsReset = false;
|
|
99
|
+
result.rolodexRoot.treeExpanded = true;
|
|
100
|
+
this.doc.rolodexTree.isRolodex = true;
|
|
101
|
+
this.doc.rolodexTree.node = result.rolodexRoot;
|
|
102
|
+
this.doc.rolodexRoot = result.rolodexRoot;
|
|
103
|
+
if (this.doc.rolodexActiveHash) {
|
|
104
|
+
this.doc.rolodexTree.pendingNavigationHash = this.doc.rolodexActiveHash;
|
|
105
|
+
}
|
|
106
|
+
if (this.doc.rolodexActivePath) {
|
|
107
|
+
this.doc.rolodexTree.pendingNavigationPath = this.doc.rolodexActivePath;
|
|
108
|
+
}
|
|
109
|
+
if (result.rolodexRoot.nodes?.length > 0) {
|
|
110
|
+
this.doc.importDisabled = true;
|
|
111
|
+
}
|
|
112
|
+
this.doc.rolodexResponseBag?.set(RolodexResponseBag, result);
|
|
113
|
+
const existingState = this.doc.rolodexStateBag?.get(RolodexStateBag);
|
|
114
|
+
if (!existingState) {
|
|
115
|
+
const existingState = {
|
|
116
|
+
activePath: this.doc.rolodexActivePath,
|
|
117
|
+
rootPath: this.doc.rolodexRootPath,
|
|
118
|
+
};
|
|
119
|
+
this.doc.rolodexStateBag?.set(RolodexStateBag, existingState);
|
|
120
|
+
}
|
|
121
|
+
this.doc.requestUpdate();
|
|
122
|
+
}).catch((e) => {
|
|
123
|
+
console.info("rolodex returned and error:", e.detail);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { TheDoctor } from "../components/the-doctor/the-doctor";
|
|
2
|
+
import { CustomRulesetEnabledEvent, ProblemRuleFilterChangedEvent, RuleClickedEvent, RulesetSavedEvent } from "../events/doctor";
|
|
3
|
+
import { RuleSet } from "../model/vacuum_rule";
|
|
4
|
+
export declare class RuleController extends EventTarget {
|
|
5
|
+
doc: TheDoctor;
|
|
6
|
+
constructor(doc: TheDoctor);
|
|
7
|
+
ruleClicked(evt: CustomEvent<RuleClickedEvent>): void;
|
|
8
|
+
rulesetSaved(evt: CustomEvent<RulesetSavedEvent>): void;
|
|
9
|
+
customRulesetEnabled(event: CustomEvent<CustomRulesetEnabledEvent>): void;
|
|
10
|
+
ruleGroupClicked(event: CustomEvent<ProblemRuleFilterChangedEvent>): void;
|
|
11
|
+
rulesetManuallyChanged(): void;
|
|
12
|
+
fetchRulesetMap(): void;
|
|
13
|
+
exportJSON(): void;
|
|
14
|
+
exportYAML(): void;
|
|
15
|
+
fetchSessionRulesetAsYaml(): Promise<string>;
|
|
16
|
+
fetchAllRuleset(): Promise<RuleSet>;
|
|
17
|
+
fetchDefaultRuleset(): Promise<RuleSet>;
|
|
18
|
+
fetchOWASPRuleset(): Promise<RuleSet>;
|
|
19
|
+
}
|