@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.
Files changed (82) hide show
  1. package/README.md +9 -0
  2. package/dist/components/attention-box/attention-box.css.js +73 -0
  3. package/dist/components/attention-box/attention-box.d.ts +16 -0
  4. package/dist/components/attention-box/attention-box.js +65 -0
  5. package/dist/components/changelog/changelog.css.js +95 -0
  6. package/dist/components/changelog/changelog.d.ts +12 -0
  7. package/dist/components/changelog/changelog.js +125 -0
  8. package/dist/components/changelog/model.d.ts +68 -0
  9. package/dist/components/changelog/model.js +1 -0
  10. package/dist/components/changelog/release.css.d.ts +2 -0
  11. package/dist/components/changelog/release.css.js +66 -0
  12. package/dist/components/changelog/release.d.ts +16 -0
  13. package/dist/components/changelog/release.js +96 -0
  14. package/dist/components/header/header.css.js +102 -0
  15. package/dist/components/header/header.d.ts +1 -0
  16. package/dist/components/header/header.js +39 -0
  17. package/dist/components/http-method/http-method.css.d.ts +2 -0
  18. package/dist/components/http-method/http-method.css.js +22 -0
  19. package/dist/components/http-method/http-method.d.ts +8 -0
  20. package/dist/components/http-method/http-method.js +34 -0
  21. package/dist/components/http-property-view/http-property-view.css.d.ts +2 -0
  22. package/dist/components/http-property-view/http-property-view.css.js +108 -0
  23. package/dist/components/http-property-view/http-property-view.d.ts +19 -0
  24. package/dist/components/http-property-view/http-property-view.js +102 -0
  25. package/dist/components/kv-view/kv-view.css.js +81 -0
  26. package/dist/components/kv-view/kv-view.js +98 -0
  27. package/dist/components/mailing-list/mailing-list.css.d.ts +2 -0
  28. package/dist/components/mailing-list/mailing-list.css.js +100 -0
  29. package/dist/components/mailing-list/mailing-list.d.ts +24 -0
  30. package/dist/components/mailing-list/mailing-list.js +138 -0
  31. package/dist/components/terminal/terminal-example.css.js +43 -0
  32. package/dist/components/terminal/terminal-example.js +34 -0
  33. package/dist/components/theme-switcher/theme-switcher.css.js +9 -0
  34. package/dist/components/theme-switcher/theme-switcher.js +76 -0
  35. package/dist/components/timeline/timeline-item.css.d.ts +2 -0
  36. package/dist/components/timeline/timeline-item.css.js +63 -0
  37. package/dist/components/timeline/timeline-item.d.ts +6 -0
  38. package/dist/components/timeline/timeline-item.js +32 -0
  39. package/dist/components/timeline/timeline.css.d.ts +2 -0
  40. package/dist/components/timeline/timeline.css.js +53 -0
  41. package/dist/components/timeline/timeline.d.ts +6 -0
  42. package/dist/components/timeline/timeline.js +30 -0
  43. package/dist/cowboy-components.d.ts +14 -0
  44. package/dist/cowboy-components.js +18 -4240
  45. package/dist/cowboy-components.umd.cjs +1146 -1213
  46. package/dist/css/alerts.css.d.ts +2 -0
  47. package/dist/css/alerts.css.js +89 -0
  48. package/dist/css/prism.css.d.ts +2 -0
  49. package/dist/css/prism.css.js +114 -0
  50. package/dist/css/shared.css.d.ts +2 -0
  51. package/dist/css/shared.css.js +116 -0
  52. package/dist/model/constants.d.ts +23 -0
  53. package/dist/model/constants.js +23 -0
  54. package/dist/model/controls.d.ts +30 -0
  55. package/dist/model/controls.js +25 -0
  56. package/dist/model/errors.d.ts +7 -0
  57. package/dist/model/errors.js +1 -0
  58. package/dist/model/exchange_method.d.ts +1 -0
  59. package/dist/model/exchange_method.js +16 -0
  60. package/dist/model/extract_content_type.d.ts +34 -0
  61. package/dist/model/extract_content_type.js +78 -0
  62. package/dist/model/extract_query.d.ts +1 -0
  63. package/dist/model/extract_query.js +11 -0
  64. package/dist/model/http_transaction.d.ts +78 -0
  65. package/dist/model/http_transaction.js +109 -0
  66. package/dist/style.css +1 -1
  67. package/package.json +18 -7
  68. package/demo/index.ts +0 -1
  69. package/demo/kv-view.ts +0 -18
  70. package/dist/fonts/BerkeleyMono-Bold.woff +0 -0
  71. package/dist/fonts/BerkeleyMono-Bold.woff2 +0 -0
  72. package/dist/fonts/BerkeleyMono-BoldItalic.woff +0 -0
  73. package/dist/fonts/BerkeleyMono-BoldItalic.woff2 +0 -0
  74. package/dist/fonts/BerkeleyMono-Italic.woff +0 -0
  75. package/dist/fonts/BerkeleyMono-Italic.woff2 +0 -0
  76. package/dist/fonts/BerkeleyMono-Regular.woff +0 -0
  77. package/dist/fonts/BerkeleyMono-Regular.woff2 +0 -0
  78. package/dist/index.d.ts +0 -9
  79. package/dist/vite.svg +0 -1
  80. package/index.html +0 -66
  81. /package/dist/components/{prism.css.d.ts → attention-box/attention-box.css.d.ts} +0 -0
  82. /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
+ }