@pb33f/cowboy-components 0.5.8 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/kv-view/kv-view.css.js +6 -0
- package/dist/components/kv-view/kv-view.d.ts +3 -0
- package/dist/components/kv-view/kv-view.js +23 -9
- package/dist/components/rodeo/rodeo.css.js +1 -0
- package/dist/components/rodeo/rodeo.d.ts +20 -0
- package/dist/components/rodeo/rodeo.js +124 -4
- package/dist/components/rodeo/roundup.css.d.ts +2 -0
- package/dist/components/rodeo/roundup.css.js +16 -0
- package/dist/components/rodeo/roundup.d.ts +17 -1
- package/dist/components/rodeo/roundup.js +83 -5
- package/dist/components/rodeo/statistic.css.d.ts +2 -0
- package/dist/components/rodeo/statistic.css.js +69 -0
- package/dist/components/rodeo/statistic.d.ts +10 -0
- package/dist/components/rodeo/statistic.js +59 -0
- package/dist/components/terminal-emulator/terminal-emulator.css.d.ts +2 -0
- package/dist/components/terminal-emulator/terminal-emulator.css.js +197 -0
- package/dist/components/terminal-emulator/terminal-emulator.d.ts +21 -0
- package/dist/components/terminal-emulator/terminal-emulator.js +95 -0
- package/dist/components/the-doctor/the-doctor.d.ts +1 -2
- package/dist/components/the-doctor/the-doctor.js +99 -94
- package/dist/controllers/auth.d.ts +8 -2
- package/dist/controllers/auth.js +55 -4
- package/dist/cowboy-components.umd.cjs +344 -338
- package/dist/model/channels.d.ts +3 -0
- package/dist/model/channels.js +4 -0
- package/dist/model/platform-events.d.ts +13 -0
- package/dist/model/platform-events.js +7 -0
- package/dist/model/roundup-stats.d.ts +10 -0
- package/dist/model/roundup-stats.js +1 -0
- package/dist/services/linting-service.js +1 -0
- package/dist/services/rodeo-service.d.ts +5 -0
- package/dist/services/rodeo-service.js +29 -0
- package/package.json +2 -2
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
export default css `
|
|
3
|
+
|
|
4
|
+
.render-stream {
|
|
5
|
+
font-family: var(--font-stack), monospace;
|
|
6
|
+
color: var(--font-color-sub3);
|
|
7
|
+
margin-left: 10px;
|
|
8
|
+
height: 250px;
|
|
9
|
+
overflow-y: auto;
|
|
10
|
+
content-visibility: auto;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.render-stream::-webkit-scrollbar {
|
|
14
|
+
width: 8px;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.render-stream::-webkit-scrollbar-track {
|
|
18
|
+
background-color: black;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.render-stream::-webkit-scrollbar-thumb {
|
|
22
|
+
box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
|
|
23
|
+
background: var(--secondary-color-lowalpha);
|
|
24
|
+
padding: var(--global-padding);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
.message {
|
|
29
|
+
display: flex;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.chevron {
|
|
33
|
+
display: block;
|
|
34
|
+
content: ">";
|
|
35
|
+
color: var(--background-color);
|
|
36
|
+
min-width: 20px;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.active_message .chevron {
|
|
40
|
+
color: var(--terminal-text);
|
|
41
|
+
font-family: var(--font-stack-bold), monospace;
|
|
42
|
+
animation-delay: 2s;
|
|
43
|
+
animation-name: cursor;
|
|
44
|
+
animation-duration: 1s;
|
|
45
|
+
animation-iteration-count: infinite;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.error .chevron {
|
|
49
|
+
color: var(--error-color);
|
|
50
|
+
font-size: 10px;
|
|
51
|
+
padding-top: 4px;
|
|
52
|
+
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.message-body {
|
|
56
|
+
display: block;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.active_message {
|
|
60
|
+
color: var(--terminal-text);
|
|
61
|
+
text-shadow: 0 0 10px var(--terminal-text);
|
|
62
|
+
font-family: var(--font-stack-bold), monospace;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.render-stream .message.active_message::before {
|
|
66
|
+
//content: "> ";
|
|
67
|
+
//color: var(--terminal-green);
|
|
68
|
+
//font-weight: bold;
|
|
69
|
+
//animation-delay: 2s;
|
|
70
|
+
////-webkit-animation: cursor .8s infinite;
|
|
71
|
+
////animation: cursor 3s infinite;
|
|
72
|
+
//animation-name: cursor;
|
|
73
|
+
//animation-duration: 1s;
|
|
74
|
+
//animation-iteration-count: infinite;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
._1 {
|
|
78
|
+
color: var(--font-color-sub1);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
._2 {
|
|
82
|
+
color: var(--font-color-sub2);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
._3 {
|
|
86
|
+
color: var(--font-color-sub3);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
._4 {
|
|
90
|
+
color: var(--font-color-sub3);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
.error {
|
|
95
|
+
color: var(--error-font-color);
|
|
96
|
+
text-shadow: none;
|
|
97
|
+
font-weight: normal;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.error::before {
|
|
101
|
+
font-family: var(--font-stack-bold), monospace;
|
|
102
|
+
color: var(--error-font-color) !important;
|
|
103
|
+
text-shadow: none;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
@-webkit-keyframes cursor {
|
|
107
|
+
0% {
|
|
108
|
+
opacity: 0;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
50% {
|
|
112
|
+
opacity: 1;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
to {
|
|
116
|
+
opacity: 0;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
@keyframes cursor {
|
|
121
|
+
0% {
|
|
122
|
+
opacity: 1;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
50% {
|
|
126
|
+
opacity: 0;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
to {
|
|
130
|
+
opacity: 1;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
.date {
|
|
136
|
+
padding-right: 5px;
|
|
137
|
+
color: var(--font-color-sub1);
|
|
138
|
+
text-shadow: 0 0 10px var(--font-color-sub1);
|
|
139
|
+
font-family: var(--font-stack), monospace;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
#terminal-drawer {
|
|
143
|
+
--size: 300px;
|
|
144
|
+
--body-spacing: 0;
|
|
145
|
+
--header-spacing: 0;
|
|
146
|
+
--footer-spacing: 0;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.connect-error {
|
|
150
|
+
color: var(--error-font-color);
|
|
151
|
+
font-weight: bold;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.connection-error-icon {
|
|
155
|
+
font-size: 10em;
|
|
156
|
+
color: var(--error-font-color);
|
|
157
|
+
margin-bottom: 20px
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
#terminal-drawer::part(header) {
|
|
161
|
+
border-top: 1px dashed var(--secondary-color);
|
|
162
|
+
font-family: var(--font-stack), monospace;
|
|
163
|
+
padding-left: 10px;
|
|
164
|
+
padding-right: 10px;
|
|
165
|
+
height: 30px;
|
|
166
|
+
border-bottom: 1px dashed var(--secondary-color-lowalpha);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
#terminal-drawer::part(title) {
|
|
170
|
+
font-size: 16px;
|
|
171
|
+
line-height: inherit;
|
|
172
|
+
padding-top: 3px;
|
|
173
|
+
color: var(--primary-color);
|
|
174
|
+
text-shadow: 0 0 10px var(--primary-color-lowalpha);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.loading {
|
|
178
|
+
text-align: center;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.loading sl-spinner {
|
|
182
|
+
margin-top: 40px;
|
|
183
|
+
margin-bottom: 40px;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
@keyframes fadeInAnimation {
|
|
188
|
+
0% {
|
|
189
|
+
opacity: 0;
|
|
190
|
+
}
|
|
191
|
+
100% {
|
|
192
|
+
opacity: 1;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
`;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import '@shoelace-style/shoelace/dist/components/drawer/drawer.js';
|
|
3
|
+
import '@shoelace-style/shoelace/dist/components/format-date/format-date.js';
|
|
4
|
+
export type TerminalMessage = {
|
|
5
|
+
type: 'info' | 'error' | 'warning' | 'success';
|
|
6
|
+
message: string;
|
|
7
|
+
metadata?: Record<string, any>;
|
|
8
|
+
timestamp: string;
|
|
9
|
+
};
|
|
10
|
+
export declare class TerminalEmulator extends LitElement {
|
|
11
|
+
static styles: import("lit").CSSResult[];
|
|
12
|
+
messages: TerminalMessage[];
|
|
13
|
+
label: string;
|
|
14
|
+
renderStream: HTMLDivElement;
|
|
15
|
+
maxRows: number;
|
|
16
|
+
constructor();
|
|
17
|
+
reset(): void;
|
|
18
|
+
addMessage(msg: TerminalMessage): void;
|
|
19
|
+
updated(): void;
|
|
20
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { html, LitElement } from 'lit';
|
|
8
|
+
import { customElement, property, query, state } from 'lit/decorators.js';
|
|
9
|
+
import renderStreamCss from "./terminal-emulator.css.js";
|
|
10
|
+
import '@shoelace-style/shoelace/dist/components/drawer/drawer.js';
|
|
11
|
+
import '@shoelace-style/shoelace/dist/components/format-date/format-date.js';
|
|
12
|
+
import { KVViewComponent } from "../kv-view/kv-view.js";
|
|
13
|
+
let TerminalEmulator = class TerminalEmulator extends LitElement {
|
|
14
|
+
constructor() {
|
|
15
|
+
super();
|
|
16
|
+
this.label = 'console output';
|
|
17
|
+
this.maxRows = 100;
|
|
18
|
+
this.reset();
|
|
19
|
+
}
|
|
20
|
+
reset() {
|
|
21
|
+
this.messages = [];
|
|
22
|
+
}
|
|
23
|
+
addMessage(msg) {
|
|
24
|
+
this.messages = [...this.messages, msg].slice(-this.maxRows);
|
|
25
|
+
}
|
|
26
|
+
updated() {
|
|
27
|
+
requestAnimationFrame(() => {
|
|
28
|
+
if (this.renderStream) {
|
|
29
|
+
this.renderStream.scrollTop = this.renderStream.scrollHeight;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
render() {
|
|
34
|
+
let c = 0;
|
|
35
|
+
let chevron = html `<span class="chevron">></span>`;
|
|
36
|
+
let errorChevron = html `<span class="chevron">🔴</span>`;
|
|
37
|
+
let fish = html `${this.messages.map((msg) => {
|
|
38
|
+
c++;
|
|
39
|
+
const isError = msg.type === 'error';
|
|
40
|
+
let chev = chevron;
|
|
41
|
+
let className = msg.type;
|
|
42
|
+
if (isError) {
|
|
43
|
+
className = 'error';
|
|
44
|
+
chev = errorChevron;
|
|
45
|
+
}
|
|
46
|
+
const time = html `<span class="date">[<sl-format-date date='${msg.timestamp}' hour="numeric" minute="numeric"></sl-format-date>]</span>`;
|
|
47
|
+
let meta = html ``;
|
|
48
|
+
if (msg.metadata && c == this.messages.length) {
|
|
49
|
+
const kvView = new KVViewComponent();
|
|
50
|
+
kvView.showHeader = false;
|
|
51
|
+
kvView.tiny = true;
|
|
52
|
+
kvView.data = new Map(Object.entries(msg.metadata));
|
|
53
|
+
meta = html `${kvView}`;
|
|
54
|
+
}
|
|
55
|
+
if (c == this.messages.length) {
|
|
56
|
+
return html `<span class="message active_message ${className}">${chev} ${time} <span class="message-body">${msg.message}</span></span>${meta}`;
|
|
57
|
+
}
|
|
58
|
+
else if (c == this.messages.length - 1) {
|
|
59
|
+
return html `<span class="message _1 ${className}">${chev} ${time} <span class="message-body">${msg.message}</span></span>${meta}`;
|
|
60
|
+
}
|
|
61
|
+
else if (c == this.messages.length - 2) {
|
|
62
|
+
return html `<span class="message _2 ${className}">${chev} ${time} <span class="message-body">${msg.message}</span></span>${meta}`;
|
|
63
|
+
}
|
|
64
|
+
else if (c == this.messages.length - 3) {
|
|
65
|
+
return html `<span class="message _3 ${className}">${chev} ${time} <span class="message-body">${msg.message}</span></span>${meta}`;
|
|
66
|
+
}
|
|
67
|
+
else if (c == this.messages.length - 4) {
|
|
68
|
+
return html `<span class="message _4 ${className}">${chev} ${time} <span class="message-body">${msg.message}</span></span>${meta}`;
|
|
69
|
+
}
|
|
70
|
+
return html `<span class="message ${className}">${chev} ${time} <span class="message-body">${msg.message}</span></span>${meta}`;
|
|
71
|
+
})}`;
|
|
72
|
+
return html `
|
|
73
|
+
<sl-drawer contained id="terminal-drawer" label="${this.label}" placement="bottom" open>
|
|
74
|
+
<div class="render-stream">${fish}</div>
|
|
75
|
+
</sl-drawer>
|
|
76
|
+
`;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
TerminalEmulator.styles = [renderStreamCss];
|
|
80
|
+
__decorate([
|
|
81
|
+
state()
|
|
82
|
+
], TerminalEmulator.prototype, "messages", void 0);
|
|
83
|
+
__decorate([
|
|
84
|
+
property()
|
|
85
|
+
], TerminalEmulator.prototype, "label", void 0);
|
|
86
|
+
__decorate([
|
|
87
|
+
query('.render-stream')
|
|
88
|
+
], TerminalEmulator.prototype, "renderStream", void 0);
|
|
89
|
+
__decorate([
|
|
90
|
+
property({ type: Number })
|
|
91
|
+
], TerminalEmulator.prototype, "maxRows", void 0);
|
|
92
|
+
TerminalEmulator = __decorate([
|
|
93
|
+
customElement('pb33f-terminal-emulator')
|
|
94
|
+
], TerminalEmulator);
|
|
95
|
+
export { TerminalEmulator };
|
|
@@ -121,7 +121,6 @@ export declare class TheDoctor extends LitElement {
|
|
|
121
121
|
private bounceId;
|
|
122
122
|
private problems;
|
|
123
123
|
private readonly statusBar;
|
|
124
|
-
private session;
|
|
125
124
|
private readonly feedback;
|
|
126
125
|
private readonly activitySpinner;
|
|
127
126
|
private readonly manageRuleset;
|
|
@@ -158,7 +157,7 @@ export declare class TheDoctor extends LitElement {
|
|
|
158
157
|
private readonly busPort;
|
|
159
158
|
private readonly busHost;
|
|
160
159
|
private readonly busVersion;
|
|
161
|
-
private useTLS;
|
|
160
|
+
private readonly useTLS;
|
|
162
161
|
readonly nodeLimit: number;
|
|
163
162
|
private pendingLine;
|
|
164
163
|
private rolodexDividerPosition;
|
|
@@ -46,7 +46,7 @@ import { ExplorerComponent } from "../visualizer/explorer.js";
|
|
|
46
46
|
import { RenderedNodeComponent } from "../model-renderer/rendered-node.js";
|
|
47
47
|
import tabsCss from "../../css/tabs.css.js";
|
|
48
48
|
import { CreateBus } from "@pb33f/ranch";
|
|
49
|
-
import { Command, CreditStreamChannel, DoctorServiceChannel, isBrokerResponse, QueuePrefix, SpecStreamChannel
|
|
49
|
+
import { Command, CreditStreamChannel, DoctorServiceChannel, isBrokerResponse, QueuePrefix, SpecStreamChannel } from "../../model/channels";
|
|
50
50
|
import formsCss from "../../css/forms.css";
|
|
51
51
|
import spinnerCss from "../../css/spinner.css";
|
|
52
52
|
import { UploadArchiveComponent } from "./upload-archive";
|
|
@@ -54,6 +54,7 @@ import { NodeType } from "../../model/node_type";
|
|
|
54
54
|
import tooltipCss from "../../css/tooltip.css";
|
|
55
55
|
import { NukeWorkspaceComponent } from "./nuke-workspace";
|
|
56
56
|
import { CreditTicker } from "../credit-ticker/credit-ticker";
|
|
57
|
+
import { AuthController } from "../../controllers/auth";
|
|
57
58
|
import { AuthService } from "../../services/auth-service";
|
|
58
59
|
export const GraphBag = "pb33f-doctor-graph";
|
|
59
60
|
export const PanelStateBag = "pb33f-doctor-panel-state";
|
|
@@ -95,11 +96,11 @@ let TheDoctor = class TheDoctor extends LitElement {
|
|
|
95
96
|
this.specStreamChannel = this.bus.createChannel(SpecStreamChannel);
|
|
96
97
|
this.creditStreamChannel = this.bus.createChannel(CreditStreamChannel);
|
|
97
98
|
this.bus.mapChannelToBrokerDestination(QueuePrefix + DoctorServiceChannel, DoctorServiceChannel);
|
|
98
|
-
this.bus.mapChannelToBrokerDestination(QueuePrefix + SpecStreamChannel, SpecStreamChannel);
|
|
99
|
-
this.bus.mapChannelToBrokerDestination(QueuePrefix + CreditStreamChannel, CreditStreamChannel);
|
|
99
|
+
// this.bus.mapChannelToBrokerDestination(QueuePrefix + SpecStreamChannel, SpecStreamChannel);
|
|
100
|
+
// this.bus.mapChannelToBrokerDestination(QueuePrefix + CreditStreamChannel, CreditStreamChannel);
|
|
100
101
|
this.doctorChannelSubscription = this.doctorServiceChannel.subscribe(this.doctorServiceHandler());
|
|
101
|
-
this.specChannelSubscription = this.specStreamChannel.subscribe(this.specStreamHandler());
|
|
102
|
-
this.creditChannelSubscription = this.creditStreamChannel.subscribe(this.creditStreamHandler());
|
|
102
|
+
// this.specChannelSubscription = this.specStreamChannel.subscribe(this.specStreamHandler());
|
|
103
|
+
// this.creditChannelSubscription = this.creditStreamChannel.subscribe(this.creditStreamHandler());
|
|
103
104
|
// create a stateful bag manager
|
|
104
105
|
this.bagManager = CreateBagManager(true);
|
|
105
106
|
this.bagManager.loadStatefulBags().then(this.loadState.bind(this));
|
|
@@ -155,8 +156,24 @@ let TheDoctor = class TheDoctor extends LitElement {
|
|
|
155
156
|
else {
|
|
156
157
|
this.doctorEndpoint = doctorEndpoint;
|
|
157
158
|
}
|
|
158
|
-
|
|
159
|
-
|
|
159
|
+
LintingService.doctorEndpoint = this.doctorEndpoint;
|
|
160
|
+
FeedbackService.doctorEndpoint = this.doctorEndpoint;
|
|
161
|
+
RulesetService.doctorEndpoint = this.doctorEndpoint;
|
|
162
|
+
ModelService.doctorEndpoint = this.doctorEndpoint;
|
|
163
|
+
AuthService.doctorEndpoint = this.doctorEndpoint;
|
|
164
|
+
// session call back for when we're online.
|
|
165
|
+
const sessionCallback = (session) => {
|
|
166
|
+
if (session.creditsRemaining) {
|
|
167
|
+
this.creditTicker.credits = session.creditsRemaining;
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
this.creditTicker.credits = session.creditsRemaining;
|
|
171
|
+
}
|
|
172
|
+
this.creditTicker.visible = true;
|
|
173
|
+
this.connectToBroker();
|
|
174
|
+
};
|
|
175
|
+
// create auth controller
|
|
176
|
+
this.authController = new AuthController(this, sessionCallback, true);
|
|
160
177
|
//@ts-ignore
|
|
161
178
|
this.addEventListener(EditorUpdated, this.specChanged);
|
|
162
179
|
//@ts-ignore
|
|
@@ -270,6 +287,7 @@ let TheDoctor = class TheDoctor extends LitElement {
|
|
|
270
287
|
heartbeatOutgoing: 0,
|
|
271
288
|
onConnect: () => {
|
|
272
289
|
console.log("💊 Connected to the %cOpenAPI Doctor%c, we are ready to communicate.", 'background: #0d1117; color: #62C4FFFF; font-weight: bold', 'color: default');
|
|
290
|
+
this.bus.mapChannels();
|
|
273
291
|
this.whoAmI();
|
|
274
292
|
}
|
|
275
293
|
};
|
|
@@ -286,13 +304,20 @@ let TheDoctor = class TheDoctor extends LitElement {
|
|
|
286
304
|
if (msg.payload?.payload != null) {
|
|
287
305
|
if (isBrokerResponse(msg.payload.payload)) {
|
|
288
306
|
this.brokerConnectionId = msg.payload.payload.broker;
|
|
289
|
-
|
|
290
|
-
|
|
307
|
+
this.authController.associateBroker(this.brokerConnectionId).then(() => {
|
|
308
|
+
console.log('broker connection', this.brokerConnectionId);
|
|
309
|
+
console.log("💊 Welcome to the clinic, the %cdoctor %cis ready to see you.", 'color: #62C4FFFF; font-weight: bold', 'color: default');
|
|
310
|
+
this.startTheDoctor();
|
|
311
|
+
});
|
|
291
312
|
}
|
|
292
313
|
}
|
|
293
314
|
};
|
|
294
315
|
}
|
|
295
316
|
startTheDoctor() {
|
|
317
|
+
this.specChannelSubscription = this.specStreamChannel.subscribe(this.specStreamHandler());
|
|
318
|
+
this.creditChannelSubscription = this.creditStreamChannel.subscribe(this.creditStreamHandler());
|
|
319
|
+
this.bus.mapChannelToBrokerDestination(QueuePrefix + SpecStreamChannel, SpecStreamChannel);
|
|
320
|
+
this.bus.mapChannelToBrokerDestination(QueuePrefix + CreditStreamChannel, CreditStreamChannel);
|
|
296
321
|
this.boostrap();
|
|
297
322
|
this.loadingOverlay.hide();
|
|
298
323
|
}
|
|
@@ -1260,12 +1285,6 @@ let TheDoctor = class TheDoctor extends LitElement {
|
|
|
1260
1285
|
}
|
|
1261
1286
|
}
|
|
1262
1287
|
loadState() {
|
|
1263
|
-
LintingService.doctorEndpoint = this.doctorEndpoint;
|
|
1264
|
-
FeedbackService.doctorEndpoint = this.doctorEndpoint;
|
|
1265
|
-
RulesetService.doctorEndpoint = this.doctorEndpoint;
|
|
1266
|
-
ModelService.doctorEndpoint = this.doctorEndpoint;
|
|
1267
|
-
AuthService.doctorEndpoint = this.doctorEndpoint;
|
|
1268
|
-
this.connectToBroker();
|
|
1269
1288
|
this.graphBag = this.bagManager.getBag(GraphBag);
|
|
1270
1289
|
this.docBag = this.bagManager.getBag(DoctorDocumentBag);
|
|
1271
1290
|
this.rolodexResponseBag = this.bagManager.getBag(RolodexResponseBag);
|
|
@@ -1560,7 +1579,7 @@ let TheDoctor = class TheDoctor extends LitElement {
|
|
|
1560
1579
|
customRulesetEnabled(event) {
|
|
1561
1580
|
const customRS = { rules: new Map() };
|
|
1562
1581
|
customRS.id = crypto.randomUUID();
|
|
1563
|
-
customRS.owner = this.session.sessionId;
|
|
1582
|
+
customRS.owner = this.authController.session.sessionId;
|
|
1564
1583
|
event.detail.rules.forEach((rule) => {
|
|
1565
1584
|
if (rule.rule.id != rule.ruleId) {
|
|
1566
1585
|
rule.rule.id = rule.ruleId;
|
|
@@ -1671,92 +1690,78 @@ let TheDoctor = class TheDoctor extends LitElement {
|
|
|
1671
1690
|
}
|
|
1672
1691
|
fetchDocs() {
|
|
1673
1692
|
this.activitySpinner.show();
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
const urlParam = url.searchParams.get('url');
|
|
1686
|
-
if (urlParam) {
|
|
1687
|
-
//this.urlInput.value = urlParam;
|
|
1688
|
-
this.activeURL = urlParam;
|
|
1689
|
-
this.lintSpec('', urlParam);
|
|
1690
|
-
}
|
|
1691
|
-
LintingService.fetchAllHowToFix().then((result) => {
|
|
1692
|
-
if (result) {
|
|
1693
|
-
result.forEach((howToFix) => {
|
|
1694
|
-
this.howToFixBag?.set(howToFix.ruleId, howToFix);
|
|
1695
|
-
});
|
|
1696
|
-
}
|
|
1697
|
-
}).catch((e) => {
|
|
1698
|
-
this.platformUnavailable(e);
|
|
1699
|
-
console.error("documentation service is down");
|
|
1700
|
-
});
|
|
1701
|
-
this.ruleDocsBag = this.bagManager.getBag(RuleDocumentationBag);
|
|
1702
|
-
this.functionDocsBag = this.bagManager.getBag(FunctionDocumentationBag);
|
|
1703
|
-
// populate docs via worker.
|
|
1704
|
-
this.ruleDocsWorker.addEventListener("message", (event) => {
|
|
1705
|
-
const data = event.data;
|
|
1706
|
-
if (data) {
|
|
1707
|
-
this.docExpirationBag?.set(DocumentationExpirationBag, new Date().toISOString());
|
|
1708
|
-
data.forEach((doc) => {
|
|
1709
|
-
if (doc.ruleId) {
|
|
1710
|
-
this.ruleDocsBag?.set(doc.ruleId, doc);
|
|
1711
|
-
}
|
|
1712
|
-
if (doc.functionId) {
|
|
1713
|
-
this.functionDocsBag?.set(doc.functionId, doc);
|
|
1714
|
-
}
|
|
1715
|
-
});
|
|
1716
|
-
this.activitySpinner.hide();
|
|
1717
|
-
}
|
|
1718
|
-
});
|
|
1719
|
-
let ruleDocs = [];
|
|
1720
|
-
let functionDocs = [];
|
|
1721
|
-
if (this.ruleDocsBag) {
|
|
1722
|
-
ruleDocs = Array.from(this.ruleDocsBag.export().keys());
|
|
1723
|
-
}
|
|
1724
|
-
if (this.functionDocsBag) {
|
|
1725
|
-
functionDocs = Array.from(this.functionDocsBag.export().keys());
|
|
1726
|
-
}
|
|
1727
|
-
const fetchDocs = () => {
|
|
1728
|
-
this.ruleDocsWorker.postMessage({
|
|
1729
|
-
start: true,
|
|
1730
|
-
endpoint: this.doctorEndpoint,
|
|
1731
|
-
existingRules: ruleDocs,
|
|
1732
|
-
existingFunctions: functionDocs
|
|
1693
|
+
const url = new URL(window.location.href);
|
|
1694
|
+
const urlParam = url.searchParams.get('url');
|
|
1695
|
+
if (urlParam) {
|
|
1696
|
+
//this.urlInput.value = urlParam;
|
|
1697
|
+
this.activeURL = urlParam;
|
|
1698
|
+
this.lintSpec('', urlParam);
|
|
1699
|
+
}
|
|
1700
|
+
LintingService.fetchAllHowToFix().then((result) => {
|
|
1701
|
+
if (result) {
|
|
1702
|
+
result.forEach((howToFix) => {
|
|
1703
|
+
this.howToFixBag?.set(howToFix.ruleId, howToFix);
|
|
1733
1704
|
});
|
|
1734
|
-
}
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1705
|
+
}
|
|
1706
|
+
}).catch((e) => {
|
|
1707
|
+
this.platformUnavailable(e);
|
|
1708
|
+
console.error("documentation service is down");
|
|
1709
|
+
});
|
|
1710
|
+
this.ruleDocsBag = this.bagManager.getBag(RuleDocumentationBag);
|
|
1711
|
+
this.functionDocsBag = this.bagManager.getBag(FunctionDocumentationBag);
|
|
1712
|
+
// populate docs via worker.
|
|
1713
|
+
this.ruleDocsWorker.addEventListener("message", (event) => {
|
|
1714
|
+
const data = event.data;
|
|
1715
|
+
if (data) {
|
|
1716
|
+
this.docExpirationBag?.set(DocumentationExpirationBag, new Date().toISOString());
|
|
1717
|
+
data.forEach((doc) => {
|
|
1718
|
+
if (doc.ruleId) {
|
|
1719
|
+
this.ruleDocsBag?.set(doc.ruleId, doc);
|
|
1744
1720
|
}
|
|
1745
|
-
|
|
1746
|
-
this.
|
|
1721
|
+
if (doc.functionId) {
|
|
1722
|
+
this.functionDocsBag?.set(doc.functionId, doc);
|
|
1747
1723
|
}
|
|
1724
|
+
});
|
|
1725
|
+
this.activitySpinner.hide();
|
|
1726
|
+
}
|
|
1727
|
+
});
|
|
1728
|
+
let ruleDocs = [];
|
|
1729
|
+
let functionDocs = [];
|
|
1730
|
+
if (this.ruleDocsBag) {
|
|
1731
|
+
ruleDocs = Array.from(this.ruleDocsBag.export().keys());
|
|
1732
|
+
}
|
|
1733
|
+
if (this.functionDocsBag) {
|
|
1734
|
+
functionDocs = Array.from(this.functionDocsBag.export().keys());
|
|
1735
|
+
}
|
|
1736
|
+
const fetchDocs = () => {
|
|
1737
|
+
this.ruleDocsWorker.postMessage({
|
|
1738
|
+
start: true,
|
|
1739
|
+
endpoint: this.doctorEndpoint,
|
|
1740
|
+
existingRules: ruleDocs,
|
|
1741
|
+
existingFunctions: functionDocs
|
|
1742
|
+
});
|
|
1743
|
+
};
|
|
1744
|
+
// check expiration
|
|
1745
|
+
if (this.docExpirationBag) {
|
|
1746
|
+
const expiration = this.docExpirationBag.get(DocumentationExpirationBag);
|
|
1747
|
+
// if the docs are older than 15 days, refresh them.
|
|
1748
|
+
if (expiration) {
|
|
1749
|
+
const now = new Date().getTime();
|
|
1750
|
+
const then = new Date(expiration).getTime();
|
|
1751
|
+
if (now - then > 1296000000) {
|
|
1752
|
+
fetchDocs();
|
|
1748
1753
|
}
|
|
1749
1754
|
else {
|
|
1750
|
-
|
|
1755
|
+
this.activitySpinner.hide();
|
|
1751
1756
|
}
|
|
1752
1757
|
}
|
|
1753
1758
|
else {
|
|
1754
1759
|
fetchDocs();
|
|
1755
1760
|
}
|
|
1756
|
-
}
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
}
|
|
1761
|
+
}
|
|
1762
|
+
else {
|
|
1763
|
+
fetchDocs();
|
|
1764
|
+
}
|
|
1760
1765
|
}
|
|
1761
1766
|
fetchRulesetMap() {
|
|
1762
1767
|
RulesetService.getSessionRulesetMap().then((result) => {
|
|
@@ -1797,7 +1802,7 @@ let TheDoctor = class TheDoctor extends LitElement {
|
|
|
1797
1802
|
// create a new custom ruleset with a map of rules
|
|
1798
1803
|
let customRS = { rules: new Map() };
|
|
1799
1804
|
customRS.id = crypto.randomUUID();
|
|
1800
|
-
customRS.owner = this.session.sessionId;
|
|
1805
|
+
customRS.owner = this.authController.session.sessionId;
|
|
1801
1806
|
customRS.rules = new Map(Object.entries(result.rules));
|
|
1802
1807
|
customRS.rules.forEach((rule, id) => {
|
|
1803
1808
|
rule.id = id; // set the id to the key
|
|
@@ -1839,7 +1844,7 @@ let TheDoctor = class TheDoctor extends LitElement {
|
|
|
1839
1844
|
// create a new custom ruleset with a map of rules
|
|
1840
1845
|
let customRS = { rules: new Map() };
|
|
1841
1846
|
customRS.id = crypto.randomUUID();
|
|
1842
|
-
customRS.owner = this.session.sessionId;
|
|
1847
|
+
customRS.owner = this.authController.session.sessionId;
|
|
1843
1848
|
customRS.rules = new Map(Object.entries(json.rules));
|
|
1844
1849
|
customRS.rules.forEach((rule, id) => {
|
|
1845
1850
|
if (rule.id != id)
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import { ReactiveControllerHost } from 'lit';
|
|
2
|
-
import { AuthenticationState } from "../model/auth";
|
|
2
|
+
import { AuthenticationState } from "../model/auth.js";
|
|
3
|
+
import { Session } from "../model/session.js";
|
|
3
4
|
export declare class AuthController {
|
|
4
5
|
host: ReactiveControllerHost;
|
|
5
6
|
doctorEndpoint: string;
|
|
6
7
|
state: AuthenticationState | null;
|
|
7
8
|
authenticated: boolean;
|
|
8
9
|
urlCapture: string | null;
|
|
9
|
-
|
|
10
|
+
session: Session;
|
|
11
|
+
sessionCallback: Function;
|
|
12
|
+
startSessionAutomatically: boolean;
|
|
13
|
+
constructor(host: ReactiveControllerHost, sessionCallback?: Function, autoStart?: boolean);
|
|
10
14
|
hostConnected(): void;
|
|
15
|
+
private startSession;
|
|
16
|
+
associateBroker(brokerId: string): Promise<boolean>;
|
|
11
17
|
authGithub(): void;
|
|
12
18
|
logout(): void;
|
|
13
19
|
checkState(): Promise<AuthenticationState>;
|