@pb33f/cowboy-components 0.6.7 → 0.7.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.
Files changed (186) hide show
  1. package/dist/assets/equalizer.worker-DyLD5JTU.js +1 -0
  2. package/dist/assets/search-problems.worker-BAF8L2rX.js +1 -0
  3. package/dist/components/changelog/changelog.js +1 -1
  4. package/dist/components/charts/beefy-chart.d.ts +21 -0
  5. package/dist/components/charts/beefy-chart.js +159 -0
  6. package/dist/components/charts/chart-colors.d.ts +27 -0
  7. package/dist/components/charts/chart-colors.js +76 -0
  8. package/dist/components/charts/config.d.ts +15 -0
  9. package/dist/components/charts/config.js +35 -0
  10. package/dist/components/charts/doughnut-chart.d.ts +22 -0
  11. package/dist/components/charts/doughnut-chart.js +128 -0
  12. package/dist/components/editor/editor.d.ts +9 -3
  13. package/dist/components/editor/editor.js +115 -60
  14. package/dist/components/editor/init.d.ts +0 -0
  15. package/dist/components/editor/init.js +28 -0
  16. package/dist/components/editor/schemas/openapi3.json +1651 -0
  17. package/dist/components/editor/schemas/openapi31.json +1449 -0
  18. package/dist/components/model-icon/model-icon.js +3 -0
  19. package/dist/components/model-renderer/callback.js +2 -1
  20. package/dist/components/model-renderer/change.css.d.ts +2 -0
  21. package/dist/components/model-renderer/change.css.js +254 -0
  22. package/dist/components/model-renderer/changes.d.ts +19 -0
  23. package/dist/components/model-renderer/changes.js +306 -0
  24. package/dist/components/model-renderer/clickable-ref.d.ts +10 -6
  25. package/dist/components/model-renderer/clickable-ref.js +9 -0
  26. package/dist/components/model-renderer/components.js +1 -0
  27. package/dist/components/model-renderer/contact.js +2 -1
  28. package/dist/components/model-renderer/document.js +11 -9
  29. package/dist/components/model-renderer/encoding.js +1 -0
  30. package/dist/components/model-renderer/example.js +1 -0
  31. package/dist/components/model-renderer/external-docs.js +1 -0
  32. package/dist/components/model-renderer/has-changes.d.ts +8 -0
  33. package/dist/components/model-renderer/has-changes.js +50 -0
  34. package/dist/components/model-renderer/header.js +1 -0
  35. package/dist/components/model-renderer/info.js +3 -1
  36. package/dist/components/model-renderer/license.js +3 -3
  37. package/dist/components/model-renderer/link.js +1 -1
  38. package/dist/components/model-renderer/media-type.js +1 -1
  39. package/dist/components/model-renderer/oauth-flows.js +2 -1
  40. package/dist/components/model-renderer/operation.js +2 -1
  41. package/dist/components/model-renderer/parameter.js +1 -0
  42. package/dist/components/model-renderer/path-item.js +1 -0
  43. package/dist/components/model-renderer/paths.js +1 -0
  44. package/dist/components/model-renderer/rendered-node.js +20 -20
  45. package/dist/components/model-renderer/rendered-property.css.js +4 -0
  46. package/dist/components/model-renderer/rendered-property.js +5 -2
  47. package/dist/components/model-renderer/request-body.js +1 -1
  48. package/dist/components/model-renderer/response.js +1 -1
  49. package/dist/components/model-renderer/schema.js +57 -54
  50. package/dist/components/model-renderer/security-scheme.js +1 -1
  51. package/dist/components/model-renderer/server.js +1 -0
  52. package/dist/components/model-renderer/tag.js +3 -1
  53. package/dist/components/model-tree/tree.d.ts +7 -4
  54. package/dist/components/model-tree/tree.js +54 -25
  55. package/dist/components/paginator/paginator.css.js +5 -2
  56. package/dist/components/problem-list/problem-mainview.js +8 -1
  57. package/dist/components/rodeo/npm/download-statistic.d.ts +41 -0
  58. package/dist/components/rodeo/npm/download-statistic.js +634 -0
  59. package/dist/components/rodeo/rodeo-nav.js +1 -0
  60. package/dist/components/rodeo/rodeo.d.ts +1 -0
  61. package/dist/components/rodeo/rodeo.js +9 -2
  62. package/dist/components/rodeo/statistic.css.js +17 -0
  63. package/dist/components/rodeo/statistic.d.ts +4 -2
  64. package/dist/components/rodeo/statistic.js +15 -4
  65. package/dist/components/the-doctor/settings.css.d.ts +2 -0
  66. package/dist/components/the-doctor/settings.css.js +28 -0
  67. package/dist/components/the-doctor/settings.d.ts +13 -0
  68. package/dist/components/the-doctor/settings.js +83 -2
  69. package/dist/components/the-doctor/the-doctor.css.js +80 -47
  70. package/dist/components/the-doctor/the-doctor.d.ts +24 -6
  71. package/dist/components/the-doctor/the-doctor.js +345 -110
  72. package/dist/components/the-doctor/upload-archive.js +1 -1
  73. package/dist/components/theme-switcher/theme-switcher.d.ts +1 -1
  74. package/dist/components/theme-switcher/theme-switcher.js +5 -2
  75. package/dist/components/time-vortex/change-list-item.css.d.ts +2 -0
  76. package/dist/components/time-vortex/change-list-item.css.js +96 -0
  77. package/dist/components/time-vortex/change-list-item.d.ts +10 -0
  78. package/dist/components/time-vortex/change-list-item.js +58 -0
  79. package/dist/components/time-vortex/history-picker.css.d.ts +2 -0
  80. package/dist/components/time-vortex/history-picker.css.js +90 -0
  81. package/dist/components/time-vortex/history-picker.d.ts +18 -0
  82. package/dist/components/time-vortex/history-picker.js +143 -0
  83. package/dist/components/time-vortex/spec-summary-timeline-item.css.d.ts +2 -0
  84. package/dist/components/time-vortex/spec-summary-timeline-item.css.js +144 -0
  85. package/dist/components/time-vortex/spec-summary-timeline-item.d.ts +11 -0
  86. package/dist/components/time-vortex/spec-summary-timeline-item.js +153 -0
  87. package/dist/components/time-vortex/tardis-control.css.d.ts +2 -0
  88. package/dist/components/time-vortex/tardis-control.css.js +103 -0
  89. package/dist/components/time-vortex/tardis-control.d.ts +31 -0
  90. package/dist/components/time-vortex/tardis-control.js +286 -0
  91. package/dist/components/time-vortex/time-vortex.d.ts +17 -0
  92. package/dist/components/time-vortex/time-vortex.js +75 -0
  93. package/dist/components/time-vortex/timeline-view.css.d.ts +2 -0
  94. package/dist/components/time-vortex/timeline-view.css.js +28 -0
  95. package/dist/components/time-vortex/timeline-view.d.ts +32 -0
  96. package/dist/components/time-vortex/timeline-view.js +233 -0
  97. package/dist/components/timeline/timeline-item.css.js +95 -48
  98. package/dist/components/timeline/timeline-item.d.ts +1 -0
  99. package/dist/components/timeline/timeline-item.js +20 -1
  100. package/dist/components/timeline/timeline.css.js +46 -40
  101. package/dist/components/timeline/timeline.d.ts +1 -0
  102. package/dist/components/timeline/timeline.js +9 -5
  103. package/dist/components/toast/toast-component.css.js +4 -0
  104. package/dist/components/visualizer/equalizer.d.ts +2 -0
  105. package/dist/components/visualizer/equalizer.js +13 -5
  106. package/dist/components/visualizer/explorer.d.ts +5 -0
  107. package/dist/components/visualizer/explorer.js +41 -37
  108. package/dist/components/visualizer/foreign-object.js +3 -0
  109. package/dist/components/visualizer/nodes/callback.js +3 -1
  110. package/dist/components/visualizer/nodes/changes.css.d.ts +2 -0
  111. package/dist/components/visualizer/nodes/changes.css.js +33 -0
  112. package/dist/components/visualizer/nodes/components.js +3 -1
  113. package/dist/components/visualizer/nodes/contact.js +3 -1
  114. package/dist/components/visualizer/nodes/document.js +1 -0
  115. package/dist/components/visualizer/nodes/graph-node.d.ts +8 -7
  116. package/dist/components/visualizer/nodes/graph-node.js +55 -1
  117. package/dist/components/visualizer/nodes/header.js +3 -1
  118. package/dist/components/visualizer/nodes/info.js +3 -1
  119. package/dist/components/visualizer/nodes/license.js +8 -1
  120. package/dist/components/visualizer/nodes/link.js +3 -1
  121. package/dist/components/visualizer/nodes/media-type.js +3 -1
  122. package/dist/components/visualizer/nodes/operation.js +4 -1
  123. package/dist/components/visualizer/nodes/parameter.js +3 -1
  124. package/dist/components/visualizer/nodes/path-item.js +3 -1
  125. package/dist/components/visualizer/nodes/request-body.js +3 -1
  126. package/dist/components/visualizer/nodes/response.js +3 -1
  127. package/dist/components/visualizer/nodes/schema.js +3 -1
  128. package/dist/components/visualizer/nodes/security-scheme.js +3 -1
  129. package/dist/components/visualizer/nodes/server.js +3 -1
  130. package/dist/components/visualizer/nodes/tag.js +3 -1
  131. package/dist/components/visualizer/nodes/xml.js +3 -1
  132. package/dist/components/visualizer/orientation-controls.d.ts +1 -0
  133. package/dist/components/visualizer/orientation-controls.js +31 -16
  134. package/dist/components/visualizer/search.js +4 -3
  135. package/dist/components/warning-stripe/warning-stripe.d.ts +20 -0
  136. package/dist/components/warning-stripe/warning-stripe.js +124 -0
  137. package/dist/cowboy-components.umd.cjs +3840 -2216
  138. package/dist/css/panels.css.d.ts +2 -0
  139. package/dist/css/panels.css.js +44 -0
  140. package/dist/css/pb33f-theme.css +8 -1
  141. package/dist/css/scrollbar.css.d.ts +2 -0
  142. package/dist/css/scrollbar.css.js +16 -0
  143. package/dist/css/tabs.css.js +1 -1
  144. package/dist/events/doctor.d.ts +15 -1
  145. package/dist/events/doctor.js +5 -0
  146. package/dist/model/api-response.d.ts +6 -0
  147. package/dist/model/api-response.js +2 -0
  148. package/dist/model/chart-data.d.ts +15 -0
  149. package/dist/model/chart-data.js +1 -0
  150. package/dist/model/diagnostic-report.d.ts +5 -0
  151. package/dist/model/diagnostic-report.js +3 -0
  152. package/dist/model/document.d.ts +1 -0
  153. package/dist/model/graph.d.ts +26 -0
  154. package/dist/model/media-type.d.ts +2 -0
  155. package/dist/model/media-type.js +7 -0
  156. package/dist/model/node_type.d.ts +2 -0
  157. package/dist/model/node_type.js +2 -0
  158. package/dist/model/settings.d.ts +5 -0
  159. package/dist/model/settings.js +1 -0
  160. package/dist/model/timeline.d.ts +33 -0
  161. package/dist/model/timeline.js +1 -0
  162. package/dist/monacoeditorwork/css.worker.bundle.js +53460 -0
  163. package/dist/monacoeditorwork/editor.worker.bundle.js +13517 -0
  164. package/dist/monacoeditorwork/html.worker.bundle.js +29660 -0
  165. package/dist/monacoeditorwork/json.worker.bundle.js +21318 -0
  166. package/dist/monacoeditorwork/yaml.worker..bundle.js +37321 -0
  167. package/dist/services/color-service.d.ts +1 -0
  168. package/dist/services/color-service.js +13 -0
  169. package/dist/services/linting-service.d.ts +1 -3
  170. package/dist/services/linting-service.js +21 -29
  171. package/dist/services/model-service.d.ts +1 -1
  172. package/dist/services/model-service.js +35 -8
  173. package/dist/services/rodeo-service.d.ts +6 -0
  174. package/dist/services/rodeo-service.js +134 -0
  175. package/dist/services/timeline-service.d.ts +8 -0
  176. package/dist/services/timeline-service.js +85 -0
  177. package/dist/style.css +1 -1
  178. package/dist/workers/equalizer.worker.js +1 -1
  179. package/dist/workers/search-problems.worker.js +1 -1
  180. package/package.json +6 -1
  181. package/dist/assets/css.worker-Byh--afc.js +0 -84
  182. package/dist/assets/editor.worker-CYC0jP-p.js +0 -12
  183. package/dist/assets/equalizer.worker-CdIiiqfH.js +0 -1
  184. package/dist/assets/html.worker-DArWg-Dy.js +0 -461
  185. package/dist/assets/json.worker-heCfXoJw.js +0 -49
  186. package/dist/assets/search-problems.worker-VJi4P9Gj.js +0 -1
@@ -0,0 +1 @@
1
+ export declare function rgbaToHex(rgba: string): string;
@@ -0,0 +1,13 @@
1
+ export function rgbaToHex(rgba) {
2
+ const parts = rgba.match(/\d+(\.\d+)?/g)?.map(Number);
3
+ if (!parts || parts.length < 3)
4
+ return '#000000';
5
+ const [r, g, b, a = 1] = parts;
6
+ const toHex = (x) => x.toString(16).padStart(2, '0');
7
+ const hex = `#${toHex(r)}${toHex(g)}${toHex(b)}`;
8
+ if (a < 1) {
9
+ const alphaHex = toHex(Math.round(a * 255));
10
+ return `${hex}${alphaHex}`;
11
+ }
12
+ return hex;
13
+ }
@@ -1,13 +1,11 @@
1
1
  import { Problem } from "../model/problem.js";
2
2
  import { HowToFix } from "../model/how_to_fix.js";
3
3
  import { DrDiagnostics } from "../model/document-statistics.js";
4
- import { Session } from "../model/session.js";
5
4
  export declare class LintingService {
6
5
  static doctorEndpoint: string;
7
6
  static compareProblems(a: Problem, b: Problem): number;
8
- static lintFile(file: string, brokerId?: string, url?: string, currentPath?: string): Promise<Problem[]>;
7
+ static lintFile(file: string, brokerId?: string, url?: string, currentPath?: string, skipTimeline?: boolean): Promise<Problem[]>;
9
8
  static fetchAllHowToFix(): Promise<HowToFix[]>;
10
9
  static fetchStatistics(): Promise<DrDiagnostics>;
11
- static startSession(): Promise<Session>;
12
10
  static bootstrapEditor(): Promise<string>;
13
11
  }
@@ -19,14 +19,15 @@ export class LintingService {
19
19
  }
20
20
  return 0;
21
21
  }
22
- static async lintFile(file, brokerId, url, currentPath) {
22
+ static async lintFile(file, brokerId, url, currentPath, skipTimeline) {
23
23
  return new Promise(async (resolve, reject) => {
24
24
  try {
25
25
  const headers = HeaderService.buildDefaultHeaders(brokerId);
26
26
  let lintResults;
27
+ let skipTimelineParam = skipTimeline ? 'skipTimeline=true' : '';
27
28
  if (!url) {
28
29
  if (currentPath) {
29
- lintResults = await fetch(LintingService.doctorEndpoint + '/lint-lsp?currentPath=' + encodeURIComponent(currentPath), {
30
+ lintResults = await fetch(LintingService.doctorEndpoint + '/diagnose?currentPath=' + encodeURIComponent(currentPath) + '&' + skipTimelineParam, {
30
31
  method: 'POST',
31
32
  credentials: 'include',
32
33
  headers: headers,
@@ -34,7 +35,7 @@ export class LintingService {
34
35
  });
35
36
  }
36
37
  else {
37
- lintResults = await fetch(LintingService.doctorEndpoint + '/lint-lsp', {
38
+ lintResults = await fetch(LintingService.doctorEndpoint + '/diagnose' + (skipTimelineParam ? '?' + skipTimelineParam : ''), {
38
39
  method: 'POST',
39
40
  credentials: 'include',
40
41
  headers: headers,
@@ -43,7 +44,7 @@ export class LintingService {
43
44
  }
44
45
  }
45
46
  else {
46
- lintResults = await fetch(LintingService.doctorEndpoint + '/lint-lsp?url=' + encodeURIComponent(url), {
47
+ lintResults = await fetch(LintingService.doctorEndpoint + '/diagnose?url=' + encodeURIComponent(url) + '&' + skipTimelineParam, {
47
48
  method: 'GET',
48
49
  credentials: 'include',
49
50
  headers: headers,
@@ -60,13 +61,23 @@ export class LintingService {
60
61
  }
61
62
  const lintData = apiResult;
62
63
  const constructedProblems = [];
63
- if (lintData && Array.isArray(lintData)) {
64
- for (let i = 0; i < lintData.length; i++) {
65
- const problem = lintData[i];
64
+ if (lintData && !lintData.response && !lintData.message) {
65
+ resolve([]);
66
+ return;
67
+ }
68
+ if (lintData && !lintData.response && lintData.message) {
69
+ const problem = lintData;
70
+ constructedProblems.push(new Problem(problem.category, problem.jsonPath, problem.endColumn, problem.endLineNumber, problem.message, problem.severity, problem.startColumn, problem.startLineNumber, problem.source, problem.id, problem.sourceLocation));
71
+ resolve(constructedProblems);
72
+ return;
73
+ }
74
+ if (lintData && Array.isArray(lintData.response)) {
75
+ for (let i = 0; i < lintData.response.length; i++) {
76
+ const problem = lintData.response[i];
66
77
  constructedProblems.push(new Problem(problem.category, problem.jsonPath, problem.endColumn, problem.endLineNumber, problem.message, problem.severity, problem.startColumn, problem.startLineNumber, problem.source, problem.id, problem.sourceLocation));
67
78
  }
68
79
  }
69
- if (lintData && !Array.isArray(lintData)) {
80
+ if (lintData && !Array.isArray(lintData.response)) {
70
81
  const problem = lintData;
71
82
  constructedProblems.push(new Problem(problem.category, problem.jsonPath, problem.endColumn, problem.endLineNumber, problem.message, problem.severity, problem.startColumn, problem.startLineNumber, problem.source, problem.id, problem.sourceLocation));
72
83
  }
@@ -74,7 +85,7 @@ export class LintingService {
74
85
  resolve(constructedProblems);
75
86
  }
76
87
  catch (e) {
77
- reject({ detail: "the pb33f platform is unresponsive" });
88
+ reject({ detail: "the pb33f platform is unresponsive", "error": e });
78
89
  }
79
90
  });
80
91
  }
@@ -102,7 +113,7 @@ export class LintingService {
102
113
  static async fetchStatistics() {
103
114
  return new Promise(async (resolve, reject) => {
104
115
  try {
105
- const lintStatsJSON = await fetch(LintingService.doctorEndpoint + '/lint-statistics', {
116
+ const lintStatsJSON = await fetch(LintingService.doctorEndpoint + '/diagnosis-statistics', {
106
117
  method: 'GET',
107
118
  credentials: 'include',
108
119
  });
@@ -117,25 +128,6 @@ export class LintingService {
117
128
  }
118
129
  });
119
130
  }
120
- // TODO: this needs to be moved out of here.
121
- static async startSession() {
122
- return new Promise(async (resolve, reject) => {
123
- try {
124
- const sessionJSON = await fetch(LintingService.doctorEndpoint + '/start-session', {
125
- method: 'GET',
126
- credentials: 'include',
127
- });
128
- const session = await sessionJSON.json();
129
- if (session.type && session.title && session.status) {
130
- reject(session);
131
- }
132
- resolve(session);
133
- }
134
- catch (e) {
135
- reject({ detail: "the pb33f platform is unresponsive" });
136
- }
137
- });
138
- }
139
131
  static async bootstrapEditor() {
140
132
  return new Promise(async (resolve, reject) => {
141
133
  try {
@@ -4,7 +4,7 @@ import { Node } from "../model/graph";
4
4
  import { ArchiveFileResponse, RolodexResponse } from "../model/rolodex";
5
5
  export declare class ModelService {
6
6
  static doctorEndpoint: string;
7
- static createGraph(spec?: string): Promise<GraphResponse>;
7
+ static fetchLatestGraph(): Promise<GraphResponse>;
8
8
  static fetchReferenceMap(): Promise<Reference[]>;
9
9
  static uploadArchive(formData: FormData): Promise<ArchiveFileResponse>;
10
10
  static selectRootPath(path: string): Promise<Node>;
@@ -1,14 +1,13 @@
1
1
  export class ModelService {
2
- static async createGraph(spec = '') {
2
+ static async fetchLatestGraph() {
3
3
  return new Promise(async (resolve, reject) => {
4
4
  try {
5
5
  const graph = await fetch(ModelService.doctorEndpoint + '/model/graph', {
6
- method: 'POST',
6
+ method: 'GET',
7
7
  credentials: 'include',
8
8
  headers: {
9
9
  'Content-Type': 'application/json'
10
10
  },
11
- body: spec,
12
11
  });
13
12
  const graphData = await graph.json();
14
13
  if (!graphData) {
@@ -19,7 +18,29 @@ export class ModelService {
19
18
  reject(graphData);
20
19
  return;
21
20
  }
22
- resolve(graphData);
21
+ const graphRevisions = graphData;
22
+ if (graphRevisions) {
23
+ // first is latest, grab the id
24
+ const gId = graphRevisions[0].graphId;
25
+ const graphFile = await fetch(ModelService.doctorEndpoint + '/model/graph/' + gId, {
26
+ method: 'GET',
27
+ credentials: 'include',
28
+ headers: {
29
+ 'Content-Type': 'application/json'
30
+ },
31
+ });
32
+ const graphFileData = await graphFile.json();
33
+ if (!graphFileData) {
34
+ reject({ detail: 'unable to fetch model graph file' });
35
+ return;
36
+ }
37
+ if (graphFileData?.type && graphFileData?.title && graphFileData?.status) {
38
+ reject(graphFileData);
39
+ return;
40
+ }
41
+ resolve(graphFileData);
42
+ }
43
+ reject({ detail: 'no graph data could be extracted' });
23
44
  }
24
45
  catch (e) {
25
46
  reject({ detail: 'unable fetch model graph: ' + e });
@@ -29,14 +50,14 @@ export class ModelService {
29
50
  static async fetchReferenceMap() {
30
51
  return new Promise(async (resolve, reject) => {
31
52
  try {
32
- const graph = await fetch(ModelService.doctorEndpoint + '/model/reference-map', {
53
+ const refs = await fetch(ModelService.doctorEndpoint + '/model/reference-map', {
33
54
  method: 'GET',
34
55
  credentials: 'include',
35
56
  headers: {
36
57
  'Content-Type': 'application/json'
37
58
  },
38
59
  });
39
- const referenceMap = await graph.json();
60
+ const referenceMap = await refs.json();
40
61
  if (!referenceMap) {
41
62
  reject({ detail: 'unable to fetch reference map' });
42
63
  return;
@@ -45,10 +66,16 @@ export class ModelService {
45
66
  reject(referenceMap);
46
67
  return;
47
68
  }
48
- resolve(referenceMap);
69
+ const apiResponse = referenceMap;
70
+ if (apiResponse.response) {
71
+ resolve(apiResponse.response);
72
+ }
73
+ else {
74
+ reject({ detail: 'unable to fetch reference map' });
75
+ }
49
76
  }
50
77
  catch (e) {
51
- reject({ detail: 'unable fetch model graph: ' + e });
78
+ reject({ detail: 'unable fetch refernce map ' + e });
52
79
  }
53
80
  });
54
81
  }
@@ -1,5 +1,11 @@
1
1
  import { RoundupStats } from "../model/roundup-stats.js";
2
+ import { ChartResultData } from "../model/chart-data";
2
3
  export declare class RodeoService {
3
4
  static doctorEndpoint: string;
4
5
  static getRoundup(): Promise<RoundupStats>;
6
+ static getNpmStatistics(project: string): Promise<ChartResultData>;
7
+ static getGithubStatistics(project: string, showPatches?: boolean): Promise<ChartResultData>;
8
+ static getGithubCloneStatistics(project: string): Promise<ChartResultData>;
9
+ static getGithubStars(project: string): Promise<ChartResultData>;
10
+ static getDockerPulls(project: string): Promise<ChartResultData>;
5
11
  }
@@ -25,5 +25,139 @@ export class RodeoService {
25
25
  }
26
26
  });
27
27
  }
28
+ static async getNpmStatistics(project) {
29
+ return new Promise(async (resolve, reject) => {
30
+ try {
31
+ const npmStats = await fetch(RodeoService.doctorEndpoint + '/rodeo/statistics/npm/' + project, {
32
+ method: 'GET',
33
+ credentials: 'include',
34
+ headers: {
35
+ 'Content-Type': 'application/json'
36
+ },
37
+ });
38
+ const apiResult = await npmStats.json();
39
+ if (!apiResult) {
40
+ reject({ details: 'unable to send feedback' });
41
+ return;
42
+ }
43
+ if (apiResult?.type && apiResult?.title && apiResult?.status) {
44
+ reject(apiResult);
45
+ return;
46
+ }
47
+ resolve(apiResult);
48
+ }
49
+ catch (e) {
50
+ reject({ details: `unable to get npm statistics for project ${project}: ` + e });
51
+ }
52
+ });
53
+ }
54
+ static async getGithubStatistics(project, showPatches = false) {
55
+ return new Promise(async (resolve, reject) => {
56
+ try {
57
+ let patches = '';
58
+ if (showPatches) {
59
+ patches = '?showPatches=true';
60
+ }
61
+ const githubResult = await fetch(RodeoService.doctorEndpoint + '/rodeo/statistics/github/' + project + patches, {
62
+ method: 'GET',
63
+ credentials: 'include',
64
+ headers: {
65
+ 'Content-Type': 'application/json'
66
+ },
67
+ });
68
+ const apiResult = await githubResult.json();
69
+ if (!apiResult) {
70
+ reject({ details: 'unable to send feedback' });
71
+ return;
72
+ }
73
+ if (apiResult?.type && apiResult?.title && apiResult?.status) {
74
+ reject(apiResult);
75
+ return;
76
+ }
77
+ resolve(apiResult);
78
+ }
79
+ catch (e) {
80
+ reject({ details: `unable to get github statistics for project ${project}: ` + e });
81
+ }
82
+ });
83
+ }
84
+ static async getGithubCloneStatistics(project) {
85
+ return new Promise(async (resolve, reject) => {
86
+ try {
87
+ const githubResult = await fetch(RodeoService.doctorEndpoint + '/rodeo/statistics/github-clones/' + project, {
88
+ method: 'GET',
89
+ credentials: 'include',
90
+ headers: {
91
+ 'Content-Type': 'application/json'
92
+ },
93
+ });
94
+ const apiResult = await githubResult.json();
95
+ if (!apiResult) {
96
+ reject({ details: 'unable to send feedback' });
97
+ return;
98
+ }
99
+ if (apiResult?.type && apiResult?.title && apiResult?.status) {
100
+ reject(apiResult);
101
+ return;
102
+ }
103
+ resolve(apiResult);
104
+ }
105
+ catch (e) {
106
+ reject({ details: `unable to get github clone statistics for project ${project}: ` + e });
107
+ }
108
+ });
109
+ }
110
+ static async getGithubStars(project) {
111
+ return new Promise(async (resolve, reject) => {
112
+ try {
113
+ const githubResult = await fetch(RodeoService.doctorEndpoint + '/rodeo/statistics/github-stars/' + project, {
114
+ method: 'GET',
115
+ credentials: 'include',
116
+ headers: {
117
+ 'Content-Type': 'application/json'
118
+ },
119
+ });
120
+ const apiResult = await githubResult.json();
121
+ if (!apiResult) {
122
+ reject({ details: 'unable to send feedback' });
123
+ return;
124
+ }
125
+ if (apiResult?.type && apiResult?.title && apiResult?.status) {
126
+ reject(apiResult);
127
+ return;
128
+ }
129
+ resolve(apiResult);
130
+ }
131
+ catch (e) {
132
+ reject({ details: `unable to get github stars statistics for project ${project}: ` + e });
133
+ }
134
+ });
135
+ }
136
+ static async getDockerPulls(project) {
137
+ return new Promise(async (resolve, reject) => {
138
+ try {
139
+ const githubResult = await fetch(RodeoService.doctorEndpoint + '/rodeo/statistics/docker-pulls/' + project, {
140
+ method: 'GET',
141
+ credentials: 'include',
142
+ headers: {
143
+ 'Content-Type': 'application/json'
144
+ },
145
+ });
146
+ const apiResult = await githubResult.json();
147
+ if (!apiResult) {
148
+ reject({ details: 'unable to send feedback' });
149
+ return;
150
+ }
151
+ if (apiResult?.type && apiResult?.title && apiResult?.status) {
152
+ reject(apiResult);
153
+ return;
154
+ }
155
+ resolve(apiResult);
156
+ }
157
+ catch (e) {
158
+ reject({ details: `unable to get docker pull statistics for project ${project}: ` + e });
159
+ }
160
+ });
161
+ }
28
162
  }
29
163
  RodeoService.doctorEndpoint = 'https://doctor.pb33f.io';
@@ -0,0 +1,8 @@
1
+ import { ChangeHistory, SpecSummary } from "../model/timeline";
2
+ import { GraphResponse } from "../model/graph";
3
+ export declare class TimelineService {
4
+ static doctorEndpoint: string;
5
+ static getSummary(): Promise<SpecSummary[]>;
6
+ static fetchChange(changeId: string, report?: boolean): Promise<GraphResponse>;
7
+ static fetchHistory(): Promise<ChangeHistory>;
8
+ }
@@ -0,0 +1,85 @@
1
+ export class TimelineService {
2
+ static async getSummary() {
3
+ return new Promise(async (resolve, reject) => {
4
+ try {
5
+ const summary = await fetch(TimelineService.doctorEndpoint + '/timeline/summary', {
6
+ method: 'GET',
7
+ credentials: 'include',
8
+ headers: {
9
+ 'Content-Type': 'application/json'
10
+ },
11
+ });
12
+ const summaryData = await summary.json();
13
+ if (!summaryData) {
14
+ reject({ detail: 'unable to fetch model graph' });
15
+ return;
16
+ }
17
+ if (summaryData?.type && summaryData?.title && summaryData?.status) {
18
+ reject(summaryData);
19
+ return;
20
+ }
21
+ resolve(summaryData);
22
+ }
23
+ catch (e) {
24
+ reject({ detail: 'unable fetch timeline summary: ' + e });
25
+ }
26
+ });
27
+ }
28
+ static async fetchChange(changeId, report = true) {
29
+ return new Promise(async (resolve, reject) => {
30
+ try {
31
+ let command = 'change';
32
+ if (!report) {
33
+ command = 'graph';
34
+ }
35
+ const summary = await fetch(TimelineService.doctorEndpoint + '/timeline/' + command + '/' + changeId, {
36
+ method: 'GET',
37
+ credentials: 'include',
38
+ headers: {
39
+ 'Content-Type': 'application/json'
40
+ },
41
+ });
42
+ const change = await summary.json();
43
+ if (!change) {
44
+ reject({ detail: 'unable to fetch model graph' });
45
+ return;
46
+ }
47
+ if (change?.type && change?.title && change?.status) {
48
+ reject(change);
49
+ return;
50
+ }
51
+ resolve(change);
52
+ }
53
+ catch (e) {
54
+ reject({ detail: 'unable fetch timeline change ' + e });
55
+ }
56
+ });
57
+ }
58
+ static async fetchHistory() {
59
+ return new Promise(async (resolve, reject) => {
60
+ try {
61
+ const summary = await fetch(TimelineService.doctorEndpoint + '/timeline/history', {
62
+ method: 'GET',
63
+ credentials: 'include',
64
+ headers: {
65
+ 'Content-Type': 'application/json'
66
+ },
67
+ });
68
+ const history = await summary.json();
69
+ if (!history) {
70
+ reject({ detail: 'unable to fetch timeline history' });
71
+ return;
72
+ }
73
+ if (history?.type && history?.title && history?.status) {
74
+ reject(history);
75
+ return;
76
+ }
77
+ resolve(history);
78
+ }
79
+ catch (e) {
80
+ reject({ detail: 'unable fetch timeline change ' + e });
81
+ }
82
+ });
83
+ }
84
+ }
85
+ TimelineService.doctorEndpoint = 'https://doctor.pb33f.io';