@pb33f/cowboy-components 0.0.1 → 0.0.3
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/README.md +9 -0
- package/dist/components/attention-box/attention-box.css.js +73 -0
- package/dist/components/attention-box/attention-box.d.ts +16 -0
- package/dist/components/attention-box/attention-box.js +65 -0
- package/dist/components/changelog/changelog.css.js +95 -0
- package/dist/components/changelog/changelog.d.ts +12 -0
- package/dist/components/changelog/changelog.js +125 -0
- package/dist/components/changelog/model.d.ts +68 -0
- package/dist/components/changelog/model.js +1 -0
- package/dist/components/changelog/release.css.d.ts +2 -0
- package/dist/components/changelog/release.css.js +66 -0
- package/dist/components/changelog/release.d.ts +16 -0
- package/dist/components/changelog/release.js +96 -0
- package/dist/components/header/header.css.js +102 -0
- package/dist/components/header/header.d.ts +1 -0
- package/dist/components/header/header.js +39 -0
- package/dist/components/http-method/http-method.css.d.ts +2 -0
- package/dist/components/http-method/http-method.css.js +22 -0
- package/dist/components/http-method/http-method.d.ts +8 -0
- package/dist/components/http-method/http-method.js +34 -0
- package/dist/components/http-property-view/http-property-view.css.d.ts +2 -0
- package/dist/components/http-property-view/http-property-view.css.js +108 -0
- package/dist/components/http-property-view/http-property-view.d.ts +19 -0
- package/dist/components/http-property-view/http-property-view.js +102 -0
- package/dist/components/kv-view/kv-view.css.js +81 -0
- package/dist/components/kv-view/kv-view.js +98 -0
- package/dist/components/mailing-list/mailing-list.css.d.ts +2 -0
- package/dist/components/mailing-list/mailing-list.css.js +100 -0
- package/dist/components/mailing-list/mailing-list.d.ts +24 -0
- package/dist/components/mailing-list/mailing-list.js +138 -0
- package/dist/components/terminal/terminal-example.css.js +43 -0
- package/dist/components/terminal/terminal-example.js +34 -0
- package/dist/components/theme-switcher/theme-switcher.css.js +9 -0
- package/dist/components/theme-switcher/theme-switcher.js +76 -0
- package/dist/components/timeline/timeline-item.css.d.ts +2 -0
- package/dist/components/timeline/timeline-item.css.js +63 -0
- package/dist/components/timeline/timeline-item.d.ts +6 -0
- package/dist/components/timeline/timeline-item.js +32 -0
- package/dist/components/timeline/timeline.css.d.ts +2 -0
- package/dist/components/timeline/timeline.css.js +53 -0
- package/dist/components/timeline/timeline.d.ts +6 -0
- package/dist/components/timeline/timeline.js +30 -0
- package/dist/cowboy-components.d.ts +14 -0
- package/dist/cowboy-components.js +18 -4240
- package/dist/cowboy-components.umd.cjs +1146 -1213
- package/dist/css/alerts.css.d.ts +2 -0
- package/dist/css/alerts.css.js +89 -0
- package/dist/css/prism.css.d.ts +2 -0
- package/dist/css/prism.css.js +114 -0
- package/dist/css/shared.css.d.ts +2 -0
- package/dist/css/shared.css.js +116 -0
- package/dist/model/constants.d.ts +23 -0
- package/dist/model/constants.js +23 -0
- package/dist/model/controls.d.ts +30 -0
- package/dist/model/controls.js +25 -0
- package/dist/model/errors.d.ts +7 -0
- package/dist/model/errors.js +1 -0
- package/dist/model/exchange_method.d.ts +1 -0
- package/dist/model/exchange_method.js +16 -0
- package/dist/model/extract_content_type.d.ts +34 -0
- package/dist/model/extract_content_type.js +78 -0
- package/dist/model/extract_query.d.ts +1 -0
- package/dist/model/extract_query.js +11 -0
- package/dist/model/http_transaction.d.ts +78 -0
- package/dist/model/http_transaction.js +109 -0
- package/dist/style.css +1 -1
- package/package.json +18 -7
- package/demo/index.ts +0 -1
- package/demo/kv-view.ts +0 -18
- package/dist/fonts/BerkeleyMono-Bold.woff +0 -0
- package/dist/fonts/BerkeleyMono-Bold.woff2 +0 -0
- package/dist/fonts/BerkeleyMono-BoldItalic.woff +0 -0
- package/dist/fonts/BerkeleyMono-BoldItalic.woff2 +0 -0
- package/dist/fonts/BerkeleyMono-Italic.woff +0 -0
- package/dist/fonts/BerkeleyMono-Italic.woff2 +0 -0
- package/dist/fonts/BerkeleyMono-Regular.woff +0 -0
- package/dist/fonts/BerkeleyMono-Regular.woff2 +0 -0
- package/dist/index.d.ts +0 -9
- package/dist/vite.svg +0 -1
- package/index.html +0 -66
- /package/dist/components/{prism.css.d.ts → attention-box/attention-box.css.d.ts} +0 -0
- /package/dist/components/{shared.css.d.ts → changelog/changelog.css.d.ts} +0 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { ExtractQueryString } from "./extract_query";
|
|
2
|
+
export class HttpRequest {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.headers = {};
|
|
5
|
+
this.cookies = {};
|
|
6
|
+
this.droppedHeaders = [];
|
|
7
|
+
}
|
|
8
|
+
extractHeaders() {
|
|
9
|
+
return new Map(Object.entries(this.headers));
|
|
10
|
+
}
|
|
11
|
+
extractQuery() {
|
|
12
|
+
return ExtractQueryString(this.query);
|
|
13
|
+
}
|
|
14
|
+
extractCookies() {
|
|
15
|
+
return new Map(Object.entries(this.cookies));
|
|
16
|
+
}
|
|
17
|
+
checkContentType(contentType) {
|
|
18
|
+
if (this.headers) {
|
|
19
|
+
if (this.headers.has("Content-Type")) {
|
|
20
|
+
const headerContentType = this.headers.get("Content-Type");
|
|
21
|
+
if (headerContentType === contentType) {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export class HttpResponse {
|
|
30
|
+
constructor() {
|
|
31
|
+
this.headers = {};
|
|
32
|
+
this.cookies = {};
|
|
33
|
+
}
|
|
34
|
+
extractHeaders() {
|
|
35
|
+
return new Map(Object.entries(this.headers));
|
|
36
|
+
}
|
|
37
|
+
extractCookies() {
|
|
38
|
+
return new Map(Object.entries(this.cookies));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export class HttpTransactionBase {
|
|
42
|
+
}
|
|
43
|
+
export class HttpTransaction extends HttpTransactionBase {
|
|
44
|
+
constructor(timestamp, delay, httpRequest, httpResponse, id, requestValidation, responseValidation, containsChainLink) {
|
|
45
|
+
super();
|
|
46
|
+
this.timestamp = timestamp;
|
|
47
|
+
this.delay = delay;
|
|
48
|
+
this.httpRequest = httpRequest;
|
|
49
|
+
this.httpResponse = httpResponse;
|
|
50
|
+
this.id = id;
|
|
51
|
+
this.requestValidation = requestValidation;
|
|
52
|
+
this.responseValidation = responseValidation;
|
|
53
|
+
this.containsChainLink = containsChainLink;
|
|
54
|
+
}
|
|
55
|
+
matchesMethodFilter(filter) {
|
|
56
|
+
if (filter?.filterMethod?.keyword?.toLowerCase() === this.httpRequest?.method?.toLowerCase()) {
|
|
57
|
+
return filter.filterMethod;
|
|
58
|
+
}
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
matchesKeywordFilter(filter) {
|
|
62
|
+
if (filter?.filterKeywords?.length > 0) {
|
|
63
|
+
for (let i = 0; i < filter.filterKeywords.length; i++) {
|
|
64
|
+
const keywordFilter = filter.filterKeywords[i];
|
|
65
|
+
// check if the keyword filter is in the url.
|
|
66
|
+
if (this.httpRequest?.url?.toLowerCase().includes(keywordFilter.keyword.toLowerCase())) {
|
|
67
|
+
return keywordFilter;
|
|
68
|
+
}
|
|
69
|
+
// check if the keyword filter is in the query string.
|
|
70
|
+
if (this.httpRequest?.query?.toLowerCase().includes(keywordFilter.keyword.toLowerCase())) {
|
|
71
|
+
return keywordFilter;
|
|
72
|
+
}
|
|
73
|
+
// check if the keyword filter is in the request body.
|
|
74
|
+
if (this.httpRequest?.requestBody?.toLowerCase().includes(keywordFilter.keyword.toLowerCase())) {
|
|
75
|
+
return keywordFilter;
|
|
76
|
+
}
|
|
77
|
+
// check if the keyword filter is in the response body.
|
|
78
|
+
if (this.httpResponse?.responseBody?.toLowerCase().includes(keywordFilter.keyword.toLowerCase())) {
|
|
79
|
+
return keywordFilter;
|
|
80
|
+
}
|
|
81
|
+
// check headers
|
|
82
|
+
const headers = this.httpRequest?.extractHeaders();
|
|
83
|
+
if (headers) {
|
|
84
|
+
headers.forEach((value) => {
|
|
85
|
+
if (value.toLowerCase().includes(keywordFilter.keyword.toLowerCase())) {
|
|
86
|
+
return keywordFilter;
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
containsActiveLink(filter) {
|
|
95
|
+
if (filter?.filterChain?.length > 0) {
|
|
96
|
+
for (let i = 0; i < filter.filterChain.length; i++) {
|
|
97
|
+
const chainFilter = filter.filterChain[i];
|
|
98
|
+
const rex = `(${chainFilter.keyword.toLowerCase()})=([\\w\\d]+)`;
|
|
99
|
+
if (this.httpRequest?.query?.toLowerCase().match(rex)) {
|
|
100
|
+
return chainFilter;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
export function BuildLiveTransactionFromState(httpTransaction) {
|
|
108
|
+
return new HttpTransaction(httpTransaction.timestamp, httpTransaction.delay, Object.assign(new HttpRequest(), httpTransaction.httpRequest), Object.assign(new HttpResponse(), httpTransaction.httpResponse), httpTransaction.id, httpTransaction.requestValidation, httpTransaction.responseValidation, httpTransaction.containsChainLink);
|
|
109
|
+
}
|