@pb33f/cowboy-components 0.3.3 → 0.3.4

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.
@@ -0,0 +1,11 @@
1
+ export declare const DoctorServiceChannel = "doctor-service";
2
+ export declare const SpecStreamChannel = "spec-stream";
3
+ export declare const TopicPrefix = "/t/";
4
+ export declare const QueuePrefix = "/q/";
5
+ export declare function isBrokerResponse(obj: any): obj is BrokerResponse;
6
+ export interface BrokerResponse {
7
+ broker: string;
8
+ }
9
+ export declare enum Command {
10
+ WhoAmI = "whoami"
11
+ }
@@ -0,0 +1,11 @@
1
+ export const DoctorServiceChannel = "doctor-service";
2
+ export const SpecStreamChannel = "spec-stream";
3
+ export const TopicPrefix = "/t/";
4
+ export const QueuePrefix = "/q/";
5
+ export function isBrokerResponse(obj) {
6
+ return typeof obj === 'object' && obj !== null && typeof obj.broker === 'string';
7
+ }
8
+ export var Command;
9
+ (function (Command) {
10
+ Command["WhoAmI"] = "whoami";
11
+ })(Command || (Command = {}));
@@ -1,7 +1,7 @@
1
1
  export interface PlatformError {
2
2
  detail: string;
3
3
  instance: string;
4
- statusL: number;
4
+ status: number;
5
5
  title: string;
6
6
  type: string;
7
7
  body: any;
@@ -0,0 +1,5 @@
1
+ export declare class HeaderService {
2
+ static buildDefaultHeaders(broker?: any): any;
3
+ static addBrokerHeader(headers: any, broker?: string): any;
4
+ static addJSONHeader(headers: any): any;
5
+ }
@@ -0,0 +1,16 @@
1
+ export class HeaderService {
2
+ static buildDefaultHeaders(broker) {
3
+ const headers = {};
4
+ HeaderService.addBrokerHeader(headers, broker);
5
+ HeaderService.addJSONHeader(headers);
6
+ return headers;
7
+ }
8
+ static addBrokerHeader(headers, broker) {
9
+ if (broker) {
10
+ headers['x-pb33f-broker'] = broker;
11
+ }
12
+ }
13
+ static addJSONHeader(headers) {
14
+ headers['Content-Type'] = 'application/json';
15
+ }
16
+ }
@@ -5,7 +5,7 @@ import { Session } from "../model/session.js";
5
5
  export declare class LintingService {
6
6
  static doctorEndpoint: string;
7
7
  static compareProblems(a: Problem, b: Problem): number;
8
- static lintFile(file: string): Promise<Problem[]>;
8
+ static lintFile(file: string, brokerId?: string, url?: string): Promise<Problem[]>;
9
9
  static fetchAllHowToFix(): Promise<HowToFix[]>;
10
10
  static fetchStatistics(): Promise<DrDiagnostics>;
11
11
  static startSession(): Promise<Session>;
@@ -1,4 +1,5 @@
1
1
  import { Problem } from "../model/problem.js";
2
+ import { HeaderService } from "./header-service";
2
3
  export class LintingService {
3
4
  static compareProblems(a, b) {
4
5
  if (a.startLineNumber < b.startLineNumber) {
@@ -18,17 +19,26 @@ export class LintingService {
18
19
  }
19
20
  return 0;
20
21
  }
21
- static async lintFile(file) {
22
+ static async lintFile(file, brokerId, url) {
22
23
  return new Promise(async (resolve, reject) => {
23
24
  try {
24
- const lintResults = await fetch(LintingService.doctorEndpoint + '/lint-lsp', {
25
- method: 'POST',
26
- credentials: 'include',
27
- headers: {
28
- 'Content-Type': 'application/json'
29
- },
30
- body: file
31
- });
25
+ const headers = HeaderService.buildDefaultHeaders(brokerId);
26
+ let lintResults;
27
+ if (!url) {
28
+ lintResults = await fetch(LintingService.doctorEndpoint + '/lint-lsp', {
29
+ method: 'POST',
30
+ credentials: 'include',
31
+ headers: headers,
32
+ body: file
33
+ });
34
+ }
35
+ else {
36
+ lintResults = await fetch(LintingService.doctorEndpoint + '/lint-lsp?url=' + encodeURIComponent(url), {
37
+ method: 'GET',
38
+ credentials: 'include',
39
+ headers: headers,
40
+ });
41
+ }
32
42
  const apiResult = await lintResults.json();
33
43
  if (!apiResult) {
34
44
  reject([]);
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.3.3",
6
+ "version": "0.3.4",
7
7
  "type": "module",
8
8
  "main": "./dist/cowboy-components.umd.cjs",
9
9
  "module": "./dist/cowboy-components.js",