mockaton 10.6.4 → 10.6.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/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/Api.js +3 -5
- package/src/ApiCommander.js +14 -4
- package/src/ApiConstants.js +1 -1
- package/src/Dashboard.css +42 -53
- package/src/Dashboard.js +332 -568
- package/src/DashboardDom.js +83 -0
- package/src/DashboardHtml.js +2 -0
- package/src/DashboardStore.js +257 -0
- package/src/MockBroker.js +12 -17
- package/src/MockDispatcher.js +10 -6
- package/src/mockBrokersCollection.js +2 -9
package/index.d.ts
CHANGED
package/package.json
CHANGED
package/src/Api.js
CHANGED
|
@@ -21,7 +21,7 @@ export const apiGetRequests = new Map([
|
|
|
21
21
|
...[
|
|
22
22
|
'Dashboard.css',
|
|
23
23
|
'Dashboard.js',
|
|
24
|
-
'ApiConstants.js', 'ApiCommander.js', 'Filename.js',
|
|
24
|
+
'ApiConstants.js', 'ApiCommander.js', 'Filename.js', 'DashboardStore.js', 'DashboardDom.js',
|
|
25
25
|
'Logo.svg'
|
|
26
26
|
].map(f => [API.dashboard + '/' + f, serveStatic(f)]),
|
|
27
27
|
|
|
@@ -117,7 +117,7 @@ async function selectMock(req, response) {
|
|
|
117
117
|
sendUnprocessableContent(response, `Missing Mock: ${file}`)
|
|
118
118
|
else {
|
|
119
119
|
broker.selectFile(file)
|
|
120
|
-
|
|
120
|
+
sendJSON(response, broker.currentMock)
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
|
|
@@ -130,7 +130,7 @@ async function toggle500(req, response) {
|
|
|
130
130
|
sendUnprocessableContent(response, `Route does not exist: ${body[DF.routeMethod]} ${body[DF.routeUrlMask]}`)
|
|
131
131
|
else {
|
|
132
132
|
broker.toggle500()
|
|
133
|
-
|
|
133
|
+
sendJSON(response, broker.currentMock)
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
|
|
@@ -176,8 +176,6 @@ async function updateProxyFallback(req, response) {
|
|
|
176
176
|
sendUnprocessableContent(response, `Invalid Proxy Fallback URL`)
|
|
177
177
|
return
|
|
178
178
|
}
|
|
179
|
-
if (!fallback)
|
|
180
|
-
mockBrokersCollection.ensureAllRoutesHaveSelectedMock()
|
|
181
179
|
config.proxyFallback = fallback
|
|
182
180
|
sendOK(response)
|
|
183
181
|
}
|
package/src/ApiCommander.js
CHANGED
|
@@ -4,24 +4,34 @@ import { API, DF, LONG_POLL_SERVER_TIMEOUT } from './ApiConstants.js'
|
|
|
4
4
|
/** Client for controlling Mockaton via its HTTP API */
|
|
5
5
|
export class Commander {
|
|
6
6
|
#addr = ''
|
|
7
|
+
#then = a => a
|
|
8
|
+
#catch = e => { throw e }
|
|
9
|
+
|
|
7
10
|
constructor(addr) {
|
|
8
11
|
this.#addr = addr
|
|
9
12
|
}
|
|
10
13
|
|
|
11
|
-
|
|
14
|
+
setupPatchCallbacks(_then = undefined, _catch = undefined) {
|
|
15
|
+
if (_then) this.#then = _then
|
|
16
|
+
if (_catch) this.#catch = _catch
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
#patch = (api, body) => {
|
|
12
20
|
return fetch(this.#addr + api, {
|
|
13
21
|
method: 'PATCH',
|
|
14
22
|
body: JSON.stringify(body)
|
|
15
23
|
})
|
|
24
|
+
.then(this.#then)
|
|
25
|
+
.catch(this.#catch)
|
|
16
26
|
}
|
|
17
27
|
|
|
18
28
|
/** @returns {JsonPromise<State>} */
|
|
19
|
-
getState() {
|
|
29
|
+
getState = () => {
|
|
20
30
|
return fetch(this.#addr + API.state)
|
|
21
31
|
}
|
|
22
32
|
|
|
23
33
|
/** @returns {JsonPromise<number>} */
|
|
24
|
-
getSyncVersion(currentSyncVersion, abortSignal) {
|
|
34
|
+
getSyncVersion = (currentSyncVersion, abortSignal) => {
|
|
25
35
|
return fetch(this.#addr + API.syncVersion, {
|
|
26
36
|
signal: AbortSignal.any([abortSignal, AbortSignal.timeout(LONG_POLL_SERVER_TIMEOUT + 1000)]),
|
|
27
37
|
headers: {
|
|
@@ -42,7 +52,7 @@ export class Commander {
|
|
|
42
52
|
toggle500(routeMethod, routeUrlMask) {
|
|
43
53
|
return this.#patch(API.toggle500, {
|
|
44
54
|
[DF.routeMethod]: routeMethod,
|
|
45
|
-
[DF.routeUrlMask]: routeUrlMask
|
|
55
|
+
[DF.routeUrlMask]: routeUrlMask
|
|
46
56
|
})
|
|
47
57
|
}
|
|
48
58
|
|
package/src/ApiConstants.js
CHANGED
|
@@ -30,7 +30,7 @@ export const DF = { // Dashboard Fields (XHR)
|
|
|
30
30
|
|
|
31
31
|
// TODO @ThinkAbout these affecting partial matches when bulk-selecting
|
|
32
32
|
// e.g. 'ton' would match
|
|
33
|
-
export const
|
|
33
|
+
export const AUTO_500_COMMENT = '(Mockaton 500)'
|
|
34
34
|
export const DEFAULT_MOCK_COMMENT = '(default)'
|
|
35
35
|
|
|
36
36
|
export const EXT_FOR_UNKNOWN_MIME = 'unknown'
|
package/src/Dashboard.css
CHANGED
|
@@ -20,23 +20,14 @@
|
|
|
20
20
|
--colorLightRed: #ffe4ee;
|
|
21
21
|
--colorRed: #da0f00;
|
|
22
22
|
--colorText: #000;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
.syntaxKey, .syntaxTag {
|
|
28
|
-
color: #ed206a
|
|
29
|
-
}
|
|
30
|
-
.syntaxVal, .syntaxAttr {
|
|
31
|
-
color: #9b71e8
|
|
32
|
-
}
|
|
33
|
-
.syntaxStr, .syntaxAttrVal {
|
|
34
|
-
color: #388E3C
|
|
23
|
+
--colorPink: #ed206a;
|
|
24
|
+
--colorPurple: #9b71e8;
|
|
25
|
+
--colorGreen: #388e3c;
|
|
35
26
|
}
|
|
36
27
|
}
|
|
37
28
|
@media (prefers-color-scheme: dark) {
|
|
38
29
|
:root {
|
|
39
|
-
--color4xxBackground: #
|
|
30
|
+
--color4xxBackground: #68554a;
|
|
40
31
|
--colorAccent: #2495ff;
|
|
41
32
|
--colorBackground: #181818;
|
|
42
33
|
--colorHeaderBackground: #111;
|
|
@@ -51,18 +42,9 @@
|
|
|
51
42
|
--colorLightRed: #ffe4ee;
|
|
52
43
|
--colorRed: #f41606;
|
|
53
44
|
--colorText: #fff;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
.syntaxKey, .syntaxTag {
|
|
59
|
-
color: #f92672
|
|
60
|
-
}
|
|
61
|
-
.syntaxVal, .syntaxAttr {
|
|
62
|
-
color: #ae81ff
|
|
63
|
-
}
|
|
64
|
-
.syntaxStr, .syntaxAttrVal {
|
|
65
|
-
color: #a6e22e
|
|
45
|
+
--colorPink: #f92672;
|
|
46
|
+
--colorPurple: #ae81ff;
|
|
47
|
+
--colorGreen: #a6e22e;
|
|
66
48
|
}
|
|
67
49
|
}
|
|
68
50
|
|
|
@@ -95,6 +77,8 @@ body {
|
|
|
95
77
|
}
|
|
96
78
|
|
|
97
79
|
select, a, input, button {
|
|
80
|
+
cursor: pointer;
|
|
81
|
+
|
|
98
82
|
&:focus-visible {
|
|
99
83
|
outline: 2px solid var(--colorAccent);
|
|
100
84
|
}
|
|
@@ -104,15 +88,10 @@ a {
|
|
|
104
88
|
text-decoration: none;
|
|
105
89
|
}
|
|
106
90
|
|
|
107
|
-
a,
|
|
108
|
-
button,
|
|
109
|
-
input[type=checkbox]
|
|
110
|
-
|
|
111
|
-
cursor: pointer;
|
|
112
|
-
|
|
113
|
-
&:active {
|
|
114
|
-
cursor: grabbing;
|
|
115
|
-
}
|
|
91
|
+
a:active,
|
|
92
|
+
button:active,
|
|
93
|
+
input[type=checkbox]:active {
|
|
94
|
+
cursor: grabbing;
|
|
116
95
|
}
|
|
117
96
|
|
|
118
97
|
select {
|
|
@@ -270,8 +249,11 @@ header {
|
|
|
270
249
|
margin-left: 4px;
|
|
271
250
|
outline-offset: 1px;
|
|
272
251
|
background: transparent;
|
|
273
|
-
color: var(--colorRed);
|
|
274
252
|
border-radius: 50px;
|
|
253
|
+
color: var(--colorRed);
|
|
254
|
+
@media (prefers-color-scheme: dark) {
|
|
255
|
+
color: var(--colorLightRed);
|
|
256
|
+
}
|
|
275
257
|
|
|
276
258
|
&:hover {
|
|
277
259
|
background: var(--colorRed);
|
|
@@ -389,10 +371,6 @@ table {
|
|
|
389
371
|
}
|
|
390
372
|
}
|
|
391
373
|
|
|
392
|
-
.empty {
|
|
393
|
-
margin-top: 80px;
|
|
394
|
-
}
|
|
395
|
-
|
|
396
374
|
.Method {
|
|
397
375
|
padding-right: 8px;
|
|
398
376
|
color: var(--colorSecondaryAction);
|
|
@@ -419,6 +397,10 @@ table {
|
|
|
419
397
|
color: white;
|
|
420
398
|
background: var(--colorAccent);
|
|
421
399
|
}
|
|
400
|
+
.dittoDir {
|
|
401
|
+
opacity: 0.9;
|
|
402
|
+
filter: saturate(0.1);
|
|
403
|
+
}
|
|
422
404
|
}
|
|
423
405
|
|
|
424
406
|
|
|
@@ -467,7 +449,6 @@ table {
|
|
|
467
449
|
}
|
|
468
450
|
|
|
469
451
|
> svg {
|
|
470
|
-
vertical-align: bottom;
|
|
471
452
|
fill: none;
|
|
472
453
|
stroke: var(--colorSecondaryAction);
|
|
473
454
|
}
|
|
@@ -579,10 +560,12 @@ table {
|
|
|
579
560
|
border-radius: var(--radius);
|
|
580
561
|
|
|
581
562
|
&:hover {
|
|
582
|
-
border-color: var(--
|
|
583
|
-
background: var(--colorLightRed);
|
|
563
|
+
border-color: var(--colorRed);
|
|
584
564
|
color: var(--colorRed);
|
|
585
565
|
}
|
|
566
|
+
&:active {
|
|
567
|
+
cursor: grabbing;
|
|
568
|
+
}
|
|
586
569
|
}
|
|
587
570
|
}
|
|
588
571
|
|
|
@@ -593,25 +576,38 @@ table {
|
|
|
593
576
|
flex-direction: column;
|
|
594
577
|
padding-top: 16px;
|
|
595
578
|
|
|
596
|
-
h2 {
|
|
579
|
+
> h2 {
|
|
597
580
|
padding-bottom: 4px;
|
|
598
581
|
padding-left: 16px;
|
|
599
582
|
}
|
|
600
583
|
|
|
601
|
-
pre {
|
|
584
|
+
> pre {
|
|
602
585
|
overflow: auto;
|
|
603
586
|
height: 100%;
|
|
604
587
|
padding: 16px;
|
|
605
588
|
padding-top: 12px;
|
|
606
589
|
font-family: monospace;
|
|
607
590
|
|
|
608
|
-
code {
|
|
591
|
+
> code {
|
|
609
592
|
white-space: pre;
|
|
610
593
|
tab-size: 2;
|
|
611
594
|
|
|
612
|
-
.json {
|
|
595
|
+
> .json {
|
|
613
596
|
color: var(--colorSecondaryAction);
|
|
614
597
|
}
|
|
598
|
+
|
|
599
|
+
.syntaxPunc {
|
|
600
|
+
color: var(--colorSecondaryAction);
|
|
601
|
+
}
|
|
602
|
+
.syntaxKey, .syntaxTag {
|
|
603
|
+
color: var(--colorPink);
|
|
604
|
+
}
|
|
605
|
+
.syntaxVal, .syntaxAttr {
|
|
606
|
+
color: var(--colorPurple);
|
|
607
|
+
}
|
|
608
|
+
.syntaxStr, .syntaxAttrVal {
|
|
609
|
+
color: var(--colorGreen);
|
|
610
|
+
}
|
|
615
611
|
}
|
|
616
612
|
}
|
|
617
613
|
}
|
|
@@ -641,13 +637,6 @@ table {
|
|
|
641
637
|
}
|
|
642
638
|
}
|
|
643
639
|
|
|
644
|
-
.red {
|
|
645
|
-
color: var(--colorRed);
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
.dittoDir {
|
|
649
|
-
opacity: 0.6;
|
|
650
|
-
}
|
|
651
640
|
|
|
652
641
|
.ErrorToast {
|
|
653
642
|
position: fixed;
|