@pb33f/cowboy-components 0.1.16 → 0.2.0

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 (74) hide show
  1. package/dist/assets/rule-documentation.worker-D39NS8Lx.js +1 -0
  2. package/dist/components/editor/editor.d.ts +2 -0
  3. package/dist/components/editor/editor.js +6 -4
  4. package/dist/components/error-banner/error-banner.css.js +1 -1
  5. package/dist/components/manage-ruleset/function-option.css.d.ts +2 -0
  6. package/dist/components/manage-ruleset/function-option.css.js +38 -0
  7. package/dist/components/manage-ruleset/function-option.d.ts +19 -0
  8. package/dist/components/manage-ruleset/function-option.js +117 -0
  9. package/dist/components/manage-ruleset/manage-ruleset.css.d.ts +2 -0
  10. package/dist/components/manage-ruleset/manage-ruleset.css.js +75 -0
  11. package/dist/components/manage-ruleset/manage-ruleset.d.ts +62 -0
  12. package/dist/components/manage-ruleset/manage-ruleset.js +575 -0
  13. package/dist/components/manage-ruleset/rule-action.css.d.ts +2 -0
  14. package/dist/components/manage-ruleset/rule-action.css.js +56 -0
  15. package/dist/components/manage-ruleset/rule-action.d.ts +37 -0
  16. package/dist/components/manage-ruleset/rule-action.js +351 -0
  17. package/dist/components/manage-ruleset/rule-input.d.ts +38 -0
  18. package/dist/components/manage-ruleset/rule-input.js +296 -0
  19. package/dist/components/manage-ruleset/rule.css.d.ts +2 -0
  20. package/dist/components/manage-ruleset/rule.css.js +117 -0
  21. package/dist/components/manage-ruleset/rule.d.ts +31 -0
  22. package/dist/components/manage-ruleset/rule.js +153 -0
  23. package/dist/components/problem-list/details-drawer.d.ts +2 -1
  24. package/dist/components/problem-list/details-drawer.js +7 -0
  25. package/dist/components/problem-list/filter.css.js +2 -3
  26. package/dist/components/problem-list/problem-item.css.js +1 -3
  27. package/dist/components/problem-list/problem-item.js +1 -1
  28. package/dist/components/problem-list/problem-list.css.js +0 -10
  29. package/dist/components/problem-list/problem-list.js +0 -1
  30. package/dist/components/problems-overview/document-statistic.css.js +0 -1
  31. package/dist/components/problems-overview/problem-overview-group.css.js +1 -3
  32. package/dist/components/problems-overview/problem-overview-group.js +2 -2
  33. package/dist/components/problems-overview/problem-statistics.css.js +0 -5
  34. package/dist/components/problems-overview/problems-overview.css.js +0 -4
  35. package/dist/components/the-doctor/the-doctor.css.js +99 -27
  36. package/dist/components/the-doctor/the-doctor.d.ts +65 -8
  37. package/dist/components/the-doctor/the-doctor.js +663 -63
  38. package/dist/components/toast/toast-component.css.d.ts +2 -0
  39. package/dist/components/toast/toast-component.css.js +151 -0
  40. package/dist/components/toast/toast-component.d.ts +19 -0
  41. package/dist/components/toast/toast-component.js +116 -0
  42. package/dist/components/toast/toast-manager.d.ts +13 -0
  43. package/dist/components/toast/toast-manager.js +54 -0
  44. package/dist/cowboy-components.umd.cjs +1375 -372
  45. package/dist/css/button.css.js +46 -0
  46. package/dist/css/dialog.css.d.ts +2 -0
  47. package/dist/css/dialog.css.js +11 -0
  48. package/dist/css/forms.css.d.ts +2 -0
  49. package/dist/css/forms.css.js +123 -0
  50. package/dist/css/modal.css.d.ts +2 -0
  51. package/dist/css/modal.css.js +15 -0
  52. package/dist/css/pb33f-theme.css +1 -0
  53. package/dist/css/radiogroups.css.d.ts +2 -0
  54. package/dist/css/radiogroups.css.js +26 -0
  55. package/dist/css/spinner.css.d.ts +2 -0
  56. package/dist/css/spinner.css.js +42 -0
  57. package/dist/events/doctor.d.ts +57 -3
  58. package/dist/events/doctor.js +13 -1
  59. package/dist/model/errors.d.ts +10 -0
  60. package/dist/model/rule_documentation.d.ts +8 -2
  61. package/dist/model/rule_documentation.js +5 -1
  62. package/dist/model/toast.d.ts +15 -0
  63. package/dist/model/toast.js +9 -0
  64. package/dist/model/vacuum_rule.d.ts +58 -0
  65. package/dist/model/vacuum_rule.js +1 -0
  66. package/dist/services/linting-service.d.ts +1 -1
  67. package/dist/services/linting-service.js +2 -6
  68. package/dist/services/ruleset-service.d.ts +17 -0
  69. package/dist/services/ruleset-service.js +316 -0
  70. package/dist/style.css +1 -1
  71. package/dist/workers/rule-documentation.worker.d.ts +7 -4
  72. package/dist/workers/rule-documentation.worker.js +93 -2
  73. package/package.json +1 -1
  74. package/dist/assets/rule-documentation.worker-BFIxMBU8.js +0 -1
@@ -1,6 +1,9 @@
1
- import { RuleDocumentation } from "../model/rule_documentation.js";
1
+ import { DoctorDocumentation } from "../model/rule_documentation.js";
2
2
  declare const _default: (this: Window, e: MessageEvent<any>) => void;
3
3
  export default _default;
4
- export declare function buildRuleDocs(endpoint: string): Promise<RuleDocumentation[]>;
5
- export declare function fetchAllRuleDocumentation(endpoint: string): Promise<RuleDocumentation[]>;
6
- export declare function fetchRuleDocumentation(ruleId: string, endpoint: string): Promise<RuleDocumentation>;
4
+ export declare function buildRuleDocs(endpoint: string): Promise<DoctorDocumentation[]>;
5
+ export declare function buildFunctionDocs(endpoint: string): Promise<DoctorDocumentation[]>;
6
+ export declare function fetchAllRuleDocumentation(endpoint: string): Promise<DoctorDocumentation[]>;
7
+ export declare function fetchAllFunctionDocumentation(endpoint: string): Promise<DoctorDocumentation[]>;
8
+ export declare function fetchRuleDocumentation(ruleId: string, endpoint: string): Promise<DoctorDocumentation>;
9
+ export declare function fetchFunctionDocumentation(functionId: string, endpoint: string): Promise<DoctorDocumentation>;
@@ -1,7 +1,9 @@
1
+ import { DocumentationType } from "../model/rule_documentation.js";
1
2
  export default onmessage = function (e) {
2
3
  if (e.data.start) {
3
- buildRuleDocs(e.data.endpoint).then((docs) => {
4
- postMessage(docs);
4
+ const promises = [buildRuleDocs(e.data.endpoint), buildFunctionDocs(e.data.endpoint)];
5
+ Promise.all(promises).then((docs) => {
6
+ postMessage(docs.flat());
5
7
  }).catch(() => {
6
8
  console.error('documentation cannot be fetched');
7
9
  });
@@ -15,6 +17,27 @@ export async function buildRuleDocs(endpoint) {
15
17
  if (fullDoc.body) {
16
18
  doc.body = fullDoc.body;
17
19
  }
20
+ doc.type = DocumentationType.RULE;
21
+ return doc;
22
+ }));
23
+ const updatedDocs = await Promise.all(fetchPromises);
24
+ resolve(updatedDocs);
25
+ }
26
+ catch (e) {
27
+ console.error('documentation service is down');
28
+ reject(e);
29
+ }
30
+ });
31
+ }
32
+ export async function buildFunctionDocs(endpoint) {
33
+ return new Promise(async (resolve, reject) => {
34
+ try {
35
+ const docs = await fetchAllFunctionDocumentation(endpoint);
36
+ const fetchPromises = docs.map(doc => fetchFunctionDocumentation(doc.functionId, endpoint).then(fullDoc => {
37
+ if (fullDoc.body) {
38
+ doc.body = fullDoc.body;
39
+ }
40
+ doc.type = DocumentationType.FUNCTION;
18
41
  return doc;
19
42
  }));
20
43
  const updatedDocs = await Promise.all(fetchPromises);
@@ -31,6 +54,40 @@ export async function fetchAllRuleDocumentation(endpoint) {
31
54
  const response = await fetch(endpoint + '/rules/documentation', {
32
55
  method: 'GET',
33
56
  credentials: 'include',
57
+ headers: {
58
+ 'Content-Type': 'application/json'
59
+ },
60
+ });
61
+ const apiResult = await response.json();
62
+ if (!apiResult) {
63
+ // @ts-ignore
64
+ return new Promise(async (resolve, reject) => {
65
+ reject("nothing returned");
66
+ });
67
+ }
68
+ if (apiResult?.error) {
69
+ // @ts-ignore
70
+ return new Promise(async (resolve, reject) => {
71
+ reject(apiResult.error);
72
+ });
73
+ }
74
+ return apiResult;
75
+ }
76
+ catch (e) {
77
+ // @ts-ignore
78
+ return new Promise(async (resolve, reject) => {
79
+ reject(e);
80
+ });
81
+ }
82
+ }
83
+ export async function fetchAllFunctionDocumentation(endpoint) {
84
+ try {
85
+ const response = await fetch(endpoint + '/functions/documentation', {
86
+ method: 'GET',
87
+ credentials: 'include',
88
+ headers: {
89
+ 'Content-Type': 'application/json'
90
+ },
34
91
  });
35
92
  const apiResult = await response.json();
36
93
  if (!apiResult) {
@@ -59,6 +116,40 @@ export async function fetchRuleDocumentation(ruleId, endpoint) {
59
116
  const response = await fetch(endpoint + `/rules/documentation/${ruleId}`, {
60
117
  method: 'GET',
61
118
  credentials: 'include',
119
+ headers: {
120
+ 'Content-Type': 'application/json'
121
+ },
122
+ });
123
+ const apiResult = await response.json();
124
+ if (!apiResult) {
125
+ // @ts-ignore
126
+ return new Promise(async (accept, reject) => {
127
+ reject("nothing returned");
128
+ });
129
+ }
130
+ if (apiResult?.error) {
131
+ // @ts-ignore
132
+ return new Promise(async (accept, reject) => {
133
+ reject(apiResult.error);
134
+ });
135
+ }
136
+ return apiResult;
137
+ }
138
+ catch (e) {
139
+ // @ts-ignore
140
+ return new Promise(async (accept, reject) => {
141
+ reject(e);
142
+ });
143
+ }
144
+ }
145
+ export async function fetchFunctionDocumentation(functionId, endpoint) {
146
+ try {
147
+ const response = await fetch(endpoint + `/functions/documentation/${functionId}`, {
148
+ method: 'GET',
149
+ credentials: 'include',
150
+ headers: {
151
+ 'Content-Type': 'application/json'
152
+ },
62
153
  });
63
154
  const apiResult = await response.json();
64
155
  if (!apiResult) {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Princess Beef Heavy Industries Cowboy Components",
4
4
  "private": false,
5
5
  "license": "BUSL-1.1",
6
- "version": "0.1.16",
6
+ "version": "0.2.0",
7
7
  "type": "module",
8
8
  "main": "./dist/cowboy-components.umd.cjs",
9
9
  "module": "./dist/cowboy-components.js",
@@ -1 +0,0 @@
1
- (function(){"use strict";onmessage=function(t){t.data.start&&i(t.data.endpoint).then(o=>{postMessage(o)}).catch(()=>{console.error("documentation cannot be fetched")})};async function i(t){return new Promise(async(o,n)=>{try{const r=(await u(t)).map(s=>d(s.ruleId,t).then(a=>(a.body&&(s.body=a.body),s))),c=await Promise.all(r);o(c)}catch(e){console.error("documentation service is down"),n(e)}})}async function u(t){try{const n=await(await fetch(t+"/rules/documentation",{method:"GET",credentials:"include"})).json();return n?n!=null&&n.error?new Promise(async(e,r)=>{r(n.error)}):n:new Promise(async(e,r)=>{r("nothing returned")})}catch(o){return new Promise(async(n,e)=>{e(o)})}}async function d(t,o){try{const e=await(await fetch(o+`/rules/documentation/${t}`,{method:"GET",credentials:"include"})).json();return e?e!=null&&e.error?new Promise(async(r,c)=>{c(e.error)}):e:new Promise(async(r,c)=>{c("nothing returned")})}catch(n){return new Promise(async(e,r)=>{r(n)})}}})();