@usebruno/filestore 0.4.0 → 0.6.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.
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/workers/worker-script.js +1 -1
- package/dist/cjs/workers/worker-script.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/workers/worker-script.js +1 -1
- package/dist/esm/workers/worker-script.js.map +1 -1
- package/dist/formats/bru/index.d.ts +20 -0
- package/dist/formats/bru/index.d.ts.map +1 -0
- package/dist/formats/bru/tests/fixtures/oauth2-additional-params.d.ts +57 -0
- package/dist/formats/bru/tests/fixtures/oauth2-additional-params.d.ts.map +1 -0
- package/dist/formats/bru/tests/oauth2-additional-params.spec.d.ts +2 -0
- package/dist/formats/bru/tests/oauth2-additional-params.spec.d.ts.map +1 -0
- package/dist/formats/bru/tests/request-parse-and-redact-body-data.spec.d.ts +2 -0
- package/dist/formats/bru/tests/request-parse-and-redact-body-data.spec.d.ts.map +1 -0
- package/dist/{esm/formats → formats}/bru/utils/oauth2-additional-params.d.ts +1 -0
- package/dist/formats/bru/utils/oauth2-additional-params.d.ts.map +1 -0
- package/dist/{cjs/workers/formats → formats}/bru/utils/request-parse-and-redact-body-data.d.ts +1 -0
- package/dist/formats/bru/utils/request-parse-and-redact-body-data.d.ts.map +1 -0
- package/dist/formats/yml/common/actions.d.ts +14 -0
- package/dist/formats/yml/common/actions.d.ts.map +1 -0
- package/dist/formats/yml/common/assertions.d.ts +5 -0
- package/dist/formats/yml/common/assertions.d.ts.map +1 -0
- package/dist/formats/yml/common/auth-oauth2.d.ts +5 -0
- package/dist/formats/yml/common/auth-oauth2.d.ts.map +1 -0
- package/dist/formats/yml/common/auth.d.ts +5 -0
- package/dist/formats/yml/common/auth.d.ts.map +1 -0
- package/dist/formats/yml/common/body.d.ts +5 -0
- package/dist/formats/yml/common/body.d.ts.map +1 -0
- package/dist/formats/yml/common/headers.d.ts +7 -0
- package/dist/formats/yml/common/headers.d.ts.map +1 -0
- package/dist/formats/yml/common/params.d.ts +5 -0
- package/dist/formats/yml/common/params.d.ts.map +1 -0
- package/dist/formats/yml/common/scripts.d.ts +14 -0
- package/dist/formats/yml/common/scripts.d.ts.map +1 -0
- package/dist/formats/yml/common/variables.d.ts +17 -0
- package/dist/formats/yml/common/variables.d.ts.map +1 -0
- package/dist/formats/yml/index.d.ts +10 -0
- package/dist/formats/yml/index.d.ts.map +1 -0
- package/dist/formats/yml/items/parseGraphQLRequest.d.ts +5 -0
- package/dist/formats/yml/items/parseGraphQLRequest.d.ts.map +1 -0
- package/dist/formats/yml/items/parseGrpcRequest.d.ts +5 -0
- package/dist/formats/yml/items/parseGrpcRequest.d.ts.map +1 -0
- package/dist/formats/yml/items/parseHttpRequest.d.ts +5 -0
- package/dist/formats/yml/items/parseHttpRequest.d.ts.map +1 -0
- package/dist/formats/yml/items/parseScript.d.ts +5 -0
- package/dist/formats/yml/items/parseScript.d.ts.map +1 -0
- package/dist/formats/yml/items/parseWebsocketRequest.d.ts +5 -0
- package/dist/formats/yml/items/parseWebsocketRequest.d.ts.map +1 -0
- package/dist/formats/yml/items/stringifyGraphQLRequest.d.ts +4 -0
- package/dist/formats/yml/items/stringifyGraphQLRequest.d.ts.map +1 -0
- package/dist/formats/yml/items/stringifyGrpcRequest.d.ts +4 -0
- package/dist/formats/yml/items/stringifyGrpcRequest.d.ts.map +1 -0
- package/dist/formats/yml/items/stringifyHttpRequest.d.ts +4 -0
- package/dist/formats/yml/items/stringifyHttpRequest.d.ts.map +1 -0
- package/dist/formats/yml/items/stringifyScript.d.ts +4 -0
- package/dist/formats/yml/items/stringifyScript.d.ts.map +1 -0
- package/dist/formats/yml/items/stringifyWebsocketRequest.d.ts +4 -0
- package/dist/formats/yml/items/stringifyWebsocketRequest.d.ts.map +1 -0
- package/dist/formats/yml/parseCollection.d.ts +8 -0
- package/dist/formats/yml/parseCollection.d.ts.map +1 -0
- package/dist/formats/yml/parseEnvironment.d.ts +4 -0
- package/dist/formats/yml/parseEnvironment.d.ts.map +1 -0
- package/dist/formats/yml/parseFolder.d.ts +4 -0
- package/dist/formats/yml/parseFolder.d.ts.map +1 -0
- package/dist/formats/yml/parseItem.d.ts +4 -0
- package/dist/formats/yml/parseItem.d.ts.map +1 -0
- package/dist/formats/yml/stringifyCollection.d.ts +3 -0
- package/dist/formats/yml/stringifyCollection.d.ts.map +1 -0
- package/dist/formats/yml/stringifyEnvironment.d.ts +4 -0
- package/dist/formats/yml/stringifyEnvironment.d.ts.map +1 -0
- package/dist/formats/yml/stringifyFolder.d.ts +4 -0
- package/dist/formats/yml/stringifyFolder.d.ts.map +1 -0
- package/dist/formats/yml/stringifyItem.d.ts +4 -0
- package/dist/formats/yml/stringifyItem.d.ts.map +1 -0
- package/dist/formats/yml/utils.d.ts +3 -0
- package/dist/formats/yml/utils.d.ts.map +1 -0
- package/dist/{cjs/workers/index.d.ts → index.d.ts} +13 -6
- package/dist/index.d.ts.map +1 -0
- package/dist/types.d.ts +19 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/{esm/workers → workers}/WorkerQueue/index.d.ts +1 -0
- package/dist/workers/WorkerQueue/index.d.ts.map +1 -0
- package/dist/workers/index.d.ts +12 -0
- package/dist/workers/index.d.ts.map +1 -0
- package/dist/workers/worker-script.d.ts +2 -0
- package/dist/workers/worker-script.d.ts.map +1 -0
- package/package.json +12 -6
- package/src/formats/bru/index.ts +103 -11
- package/src/formats/bru/tests/oauth2-additional-params.spec.js +1 -1
- package/src/formats/bru/utils/oauth2-additional-params.ts +17 -18
- package/src/formats/bru/utils/request-parse-and-redact-body-data.ts +13 -13
- package/src/formats/yml/common/actions.ts +78 -0
- package/src/formats/yml/common/assertions.ts +146 -0
- package/src/formats/yml/common/auth-oauth2.ts +555 -0
- package/src/formats/yml/common/auth.ts +245 -0
- package/src/formats/yml/common/body.ts +238 -0
- package/src/formats/yml/common/headers.ts +58 -0
- package/src/formats/yml/common/params.ts +57 -0
- package/src/formats/yml/common/scripts.ts +64 -0
- package/src/formats/yml/common/variables.ts +68 -0
- package/src/formats/yml/index.ts +20 -0
- package/src/formats/yml/items/parseGraphQLRequest.ts +137 -0
- package/src/formats/yml/items/parseGrpcRequest.ts +116 -0
- package/src/formats/yml/items/parseHttpRequest.ts +195 -0
- package/src/formats/yml/items/parseScript.ts +25 -0
- package/src/formats/yml/items/parseWebsocketRequest.ts +106 -0
- package/src/formats/yml/items/stringifyGraphQLRequest.ts +168 -0
- package/src/formats/yml/items/stringifyGrpcRequest.ts +137 -0
- package/src/formats/yml/items/stringifyHttpRequest.ts +221 -0
- package/src/formats/yml/items/stringifyScript.ts +22 -0
- package/src/formats/yml/items/stringifyWebsocketRequest.ts +114 -0
- package/src/formats/yml/parseCollection.ts +198 -0
- package/src/formats/yml/parseEnvironment.ts +56 -0
- package/src/formats/yml/parseFolder.ts +88 -0
- package/src/formats/yml/parseItem.ts +102 -0
- package/src/formats/yml/stringifyCollection.ts +230 -0
- package/src/formats/yml/stringifyEnvironment.ts +64 -0
- package/src/formats/yml/stringifyFolder.ts +96 -0
- package/src/formats/yml/stringifyItem.ts +37 -0
- package/src/formats/yml/utils.ts +38 -0
- package/src/index.ts +57 -27
- package/src/types/bruno-lang.d.ts +1 -1
- package/src/types.ts +5 -124
- package/src/utils/index.ts +15 -0
- package/src/workers/WorkerQueue/index.ts +10 -10
- package/src/workers/index.ts +20 -20
- package/src/workers/worker-script.ts +20 -6
- package/dist/cjs/formats/bru/index.d.ts +0 -6
- package/dist/cjs/formats/bru/utils/oauth2-additional-params.d.ts +0 -38
- package/dist/cjs/formats/bru/utils/request-parse-and-redact-body-data.d.ts +0 -9
- package/dist/cjs/index.d.ts +0 -16
- package/dist/cjs/types.d.ts +0 -142
- package/dist/cjs/workers/WorkerQueue/index.d.ts +0 -26
- package/dist/cjs/workers/formats/bru/index.d.ts +0 -6
- package/dist/cjs/workers/formats/bru/utils/oauth2-additional-params.d.ts +0 -38
- package/dist/cjs/workers/types.d.ts +0 -142
- package/dist/cjs/workers/worker-script.d.ts +0 -1
- package/dist/cjs/workers/workers/WorkerQueue/index.d.ts +0 -26
- package/dist/cjs/workers/workers/index.d.ts +0 -10
- package/dist/cjs/workers/workers/worker-script.d.ts +0 -1
- package/dist/esm/formats/bru/index.d.ts +0 -6
- package/dist/esm/formats/bru/utils/request-parse-and-redact-body-data.d.ts +0 -9
- package/dist/esm/index.d.ts +0 -16
- package/dist/esm/types.d.ts +0 -142
- package/dist/esm/workers/formats/bru/index.d.ts +0 -6
- package/dist/esm/workers/formats/bru/utils/oauth2-additional-params.d.ts +0 -38
- package/dist/esm/workers/formats/bru/utils/request-parse-and-redact-body-data.d.ts +0 -9
- package/dist/esm/workers/index.d.ts +0 -16
- package/dist/esm/workers/types.d.ts +0 -142
- package/dist/esm/workers/worker-script.d.ts +0 -1
- package/dist/esm/workers/workers/WorkerQueue/index.d.ts +0 -26
- package/dist/esm/workers/workers/index.d.ts +0 -10
- package/dist/esm/workers/workers/worker-script.d.ts +0 -1
package/src/workers/index.ts
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
import WorkerQueue from './WorkerQueue';
|
|
2
|
-
import { Lane } from '../types';
|
|
2
|
+
import { Lane, CollectionFormat } from '../types';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
|
|
5
5
|
const sizeInMB = (size: number): number => {
|
|
6
6
|
return size / (1024 * 1024);
|
|
7
|
-
}
|
|
7
|
+
};
|
|
8
8
|
|
|
9
9
|
const getSize = (data: any): number => {
|
|
10
10
|
return sizeInMB(typeof data === 'string' ? Buffer.byteLength(data, 'utf8') : Buffer.byteLength(JSON.stringify(data), 'utf8'));
|
|
11
|
-
}
|
|
11
|
+
};
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Lanes are used to determine which worker queue to use based on the size of the data.
|
|
15
|
-
*
|
|
15
|
+
*
|
|
16
16
|
* The first lane is for smaller files (<0.1MB), the second lane is for larger files (>=0.1MB).
|
|
17
17
|
* This helps with parsing performance.
|
|
18
18
|
*/
|
|
19
19
|
const LANES: Lane[] = [{
|
|
20
20
|
maxSize: 0.005
|
|
21
|
-
},{
|
|
21
|
+
}, {
|
|
22
22
|
maxSize: 0.1
|
|
23
|
-
},{
|
|
23
|
+
}, {
|
|
24
24
|
maxSize: 1
|
|
25
|
-
},{
|
|
25
|
+
}, {
|
|
26
26
|
maxSize: 10
|
|
27
|
-
},{
|
|
27
|
+
}, {
|
|
28
28
|
maxSize: 100
|
|
29
29
|
}];
|
|
30
30
|
|
|
@@ -38,7 +38,7 @@ class BruParserWorker {
|
|
|
38
38
|
private workerQueues: WorkerQueueWithSize[];
|
|
39
39
|
|
|
40
40
|
constructor() {
|
|
41
|
-
this.workerQueues = LANES?.map(lane => ({
|
|
41
|
+
this.workerQueues = LANES?.map((lane) => ({
|
|
42
42
|
maxSize: lane?.maxSize,
|
|
43
43
|
workerQueue: new WorkerQueue()
|
|
44
44
|
}));
|
|
@@ -47,40 +47,40 @@ class BruParserWorker {
|
|
|
47
47
|
private getWorkerQueue(size: number): WorkerQueue {
|
|
48
48
|
// Find the first queue that can handle the given size
|
|
49
49
|
// or fallback to the last queue for largest files
|
|
50
|
-
const queueForSize = this.workerQueues.find((queue) =>
|
|
50
|
+
const queueForSize = this.workerQueues.find((queue) =>
|
|
51
51
|
queue.maxSize >= size
|
|
52
52
|
);
|
|
53
53
|
|
|
54
54
|
return queueForSize?.workerQueue ?? this.workerQueues[this.workerQueues.length - 1].workerQueue;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
private async enqueueTask({ data, taskType }: { data: any; taskType: 'parse' | 'stringify' }): Promise<any> {
|
|
57
|
+
private async enqueueTask({ data, taskType, format = 'bru' }: { data: any; taskType: 'parse' | 'stringify'; format?: CollectionFormat }): Promise<any> {
|
|
58
58
|
const size = getSize(data);
|
|
59
59
|
const workerQueue = this.getWorkerQueue(size);
|
|
60
60
|
const workerScriptPath = path.join(__dirname, './workers/worker-script.js');
|
|
61
|
-
|
|
61
|
+
|
|
62
62
|
return workerQueue.enqueue({
|
|
63
|
-
data,
|
|
63
|
+
data: { data, format },
|
|
64
64
|
priority: size,
|
|
65
65
|
scriptPath: workerScriptPath,
|
|
66
|
-
taskType
|
|
66
|
+
taskType
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
async parseRequest(data: any): Promise<any> {
|
|
71
|
-
return this.enqueueTask({ data, taskType: 'parse' });
|
|
70
|
+
async parseRequest(data: any, format: CollectionFormat = 'bru'): Promise<any> {
|
|
71
|
+
return this.enqueueTask({ data, taskType: 'parse', format });
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
async stringifyRequest(data: any): Promise<any> {
|
|
75
|
-
return this.enqueueTask({ data, taskType: 'stringify' });
|
|
74
|
+
async stringifyRequest(data: any, format: CollectionFormat = 'bru'): Promise<any> {
|
|
75
|
+
return this.enqueueTask({ data, taskType: 'stringify', format });
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
async cleanup(): Promise<void> {
|
|
79
|
-
const cleanupPromises = this.workerQueues.map(({ workerQueue }) =>
|
|
79
|
+
const cleanupPromises = this.workerQueues.map(({ workerQueue }) =>
|
|
80
80
|
workerQueue.cleanup()
|
|
81
81
|
);
|
|
82
82
|
await Promise.allSettled(cleanupPromises);
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
export default BruParserWorker;
|
|
86
|
+
export default BruParserWorker;
|
|
@@ -1,20 +1,34 @@
|
|
|
1
1
|
import { parentPort } from 'node:worker_threads';
|
|
2
|
-
import {
|
|
2
|
+
import { parseBruRequest, stringifyBruRequest } from '../formats/bru';
|
|
3
|
+
import { parseYmlItem, stringifyYmlItem } from '../formats/yml';
|
|
4
|
+
import { CollectionFormat } from '../types';
|
|
3
5
|
|
|
4
6
|
interface WorkerMessage {
|
|
5
7
|
taskType: 'parse' | 'stringify';
|
|
6
|
-
data:
|
|
8
|
+
data: {
|
|
9
|
+
data: any;
|
|
10
|
+
format?: CollectionFormat;
|
|
11
|
+
};
|
|
7
12
|
}
|
|
8
13
|
|
|
9
14
|
parentPort?.on('message', async (message: WorkerMessage) => {
|
|
10
15
|
try {
|
|
11
|
-
const { taskType, data } = message;
|
|
16
|
+
const { taskType, data: messageData } = message;
|
|
17
|
+
const { data, format = 'bru' } = messageData;
|
|
12
18
|
let result: any;
|
|
13
19
|
|
|
14
20
|
if (taskType === 'parse') {
|
|
15
|
-
|
|
21
|
+
if (format === 'yml') {
|
|
22
|
+
result = parseYmlItem(data);
|
|
23
|
+
} else {
|
|
24
|
+
result = parseBruRequest(data);
|
|
25
|
+
}
|
|
16
26
|
} else if (taskType === 'stringify') {
|
|
17
|
-
|
|
27
|
+
if (format === 'yml') {
|
|
28
|
+
result = stringifyYmlItem(data);
|
|
29
|
+
} else {
|
|
30
|
+
result = stringifyBruRequest(data);
|
|
31
|
+
}
|
|
18
32
|
} else {
|
|
19
33
|
throw new Error(`Unknown task type: ${taskType}`);
|
|
20
34
|
}
|
|
@@ -24,4 +38,4 @@ parentPort?.on('message', async (message: WorkerMessage) => {
|
|
|
24
38
|
console.error('Worker error:', error);
|
|
25
39
|
parentPort?.postMessage({ error: error?.message });
|
|
26
40
|
}
|
|
27
|
-
});
|
|
41
|
+
});
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export declare const bruRequestToJson: (data: string | any, parsed?: boolean) => any;
|
|
2
|
-
export declare const jsonRequestToBru: (json: any) => string;
|
|
3
|
-
export declare const bruCollectionToJson: (data: string | any, parsed?: boolean) => any;
|
|
4
|
-
export declare const jsonCollectionToBru: (json: any, isFolder?: boolean) => string;
|
|
5
|
-
export declare const bruEnvironmentToJson: (bru: string) => any;
|
|
6
|
-
export declare const jsonEnvironmentToBru: (json: any) => string;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
type T_Oauth2ParameterSendInType = 'headers' | 'queryparams' | 'body';
|
|
2
|
-
export interface T_OAuth2AdditionalParam {
|
|
3
|
-
name: string;
|
|
4
|
-
value: string;
|
|
5
|
-
enabled: boolean;
|
|
6
|
-
sendIn: T_Oauth2ParameterSendInType;
|
|
7
|
-
}
|
|
8
|
-
export interface T_OAuth2AdditionalParameters {
|
|
9
|
-
authorization?: T_OAuth2AdditionalParam[];
|
|
10
|
-
token?: T_OAuth2AdditionalParam[];
|
|
11
|
-
refresh?: T_OAuth2AdditionalParam[];
|
|
12
|
-
}
|
|
13
|
-
export interface T_Oauth2Auth {
|
|
14
|
-
grantType: string;
|
|
15
|
-
additionalParameters?: T_OAuth2AdditionalParameters;
|
|
16
|
-
}
|
|
17
|
-
export interface T_BruJson {
|
|
18
|
-
auth: {
|
|
19
|
-
oauth2: T_Oauth2Auth;
|
|
20
|
-
};
|
|
21
|
-
oauth2_additional_parameters_auth_req_headers?: any[];
|
|
22
|
-
oauth2_additional_parameters_auth_req_queryparams?: any[];
|
|
23
|
-
oauth2_additional_parameters_access_token_req_headers?: any[];
|
|
24
|
-
oauth2_additional_parameters_access_token_req_queryparams?: any[];
|
|
25
|
-
oauth2_additional_parameters_access_token_req_bodyvalues?: any[];
|
|
26
|
-
oauth2_additional_parameters_refresh_token_req_headers?: any[];
|
|
27
|
-
oauth2_additional_parameters_refresh_token_req_queryparams?: any[];
|
|
28
|
-
oauth2_additional_parameters_refresh_token_req_bodyvalues?: any[];
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* This function extracts OAuth2 additional parameters from various sources in the bru json data and organizes
|
|
32
|
-
* them into a structured format based on their usage context (authorization, token, refresh).
|
|
33
|
-
*
|
|
34
|
-
* @param json - json object containing OAuth2 configuration and additional parameters
|
|
35
|
-
* @returns OAuth2 additional parameters
|
|
36
|
-
*/
|
|
37
|
-
export declare const getOauth2AdditionalParameters: (json: T_BruJson) => T_OAuth2AdditionalParameters;
|
|
38
|
-
export {};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Parses a .bru file and extracts body content while redacting it from the main content
|
|
3
|
-
* @param {string} bruFileContent - The raw content of the .bru file
|
|
4
|
-
* @returns {Object} Object containing redacted file content and extracted body data
|
|
5
|
-
*/
|
|
6
|
-
export declare const bruRequestParseAndRedactBodyData: (bruFileContent: string) => {
|
|
7
|
-
bruFileStringWithRedactedBody: string;
|
|
8
|
-
extractedBodyContent: Record<string, string>;
|
|
9
|
-
};
|
package/dist/cjs/index.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import BruParserWorker from './workers';
|
|
2
|
-
import { ParseOptions, StringifyOptions, ParsedRequest, ParsedCollection, ParsedEnvironment } from './types';
|
|
3
|
-
export declare const parseRequest: (content: string, options?: ParseOptions) => any;
|
|
4
|
-
export declare const parseRequestAndRedactBody: (content: string, options?: ParseOptions) => any;
|
|
5
|
-
export declare const stringifyRequest: (requestObj: ParsedRequest, options?: StringifyOptions) => string;
|
|
6
|
-
export declare const parseRequestViaWorker: (content: string) => Promise<any>;
|
|
7
|
-
export declare const stringifyRequestViaWorker: (requestObj: any) => Promise<string>;
|
|
8
|
-
export declare const parseCollection: (content: string, options?: ParseOptions) => any;
|
|
9
|
-
export declare const stringifyCollection: (collectionObj: ParsedCollection, options?: StringifyOptions) => string;
|
|
10
|
-
export declare const parseFolder: (content: string, options?: ParseOptions) => any;
|
|
11
|
-
export declare const stringifyFolder: (folderObj: any, options?: StringifyOptions) => string;
|
|
12
|
-
export declare const parseEnvironment: (content: string, options?: ParseOptions) => any;
|
|
13
|
-
export declare const stringifyEnvironment: (envObj: ParsedEnvironment, options?: StringifyOptions) => string;
|
|
14
|
-
export declare const parseDotEnv: (content: string) => Record<string, string>;
|
|
15
|
-
export { BruParserWorker };
|
|
16
|
-
export * from './types';
|
package/dist/cjs/types.d.ts
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
export interface ParseOptions {
|
|
2
|
-
format?: 'bru' | 'yaml';
|
|
3
|
-
}
|
|
4
|
-
export interface StringifyOptions {
|
|
5
|
-
format?: 'bru' | 'yaml';
|
|
6
|
-
}
|
|
7
|
-
export interface RequestBody {
|
|
8
|
-
mode?: string;
|
|
9
|
-
raw?: string;
|
|
10
|
-
formUrlEncoded?: Array<{
|
|
11
|
-
name: string;
|
|
12
|
-
value: string;
|
|
13
|
-
enabled: boolean;
|
|
14
|
-
}>;
|
|
15
|
-
multipartForm?: Array<{
|
|
16
|
-
name: string;
|
|
17
|
-
value: string;
|
|
18
|
-
type: string;
|
|
19
|
-
enabled: boolean;
|
|
20
|
-
}>;
|
|
21
|
-
json?: string;
|
|
22
|
-
xml?: string;
|
|
23
|
-
sparql?: string;
|
|
24
|
-
graphql?: {
|
|
25
|
-
query?: string;
|
|
26
|
-
variables?: string;
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
export interface AuthConfig {
|
|
30
|
-
mode?: string;
|
|
31
|
-
basic?: {
|
|
32
|
-
username?: string;
|
|
33
|
-
password?: string;
|
|
34
|
-
};
|
|
35
|
-
bearer?: {
|
|
36
|
-
token?: string;
|
|
37
|
-
};
|
|
38
|
-
apikey?: {
|
|
39
|
-
key?: string;
|
|
40
|
-
value?: string;
|
|
41
|
-
placement?: string;
|
|
42
|
-
};
|
|
43
|
-
awsv4?: {
|
|
44
|
-
accessKeyId?: string;
|
|
45
|
-
secretAccessKey?: string;
|
|
46
|
-
sessionToken?: string;
|
|
47
|
-
service?: string;
|
|
48
|
-
region?: string;
|
|
49
|
-
profileName?: string;
|
|
50
|
-
};
|
|
51
|
-
oauth2?: {
|
|
52
|
-
grantType?: string;
|
|
53
|
-
callbackUrl?: string;
|
|
54
|
-
authorizationUrl?: string;
|
|
55
|
-
accessTokenUrl?: string;
|
|
56
|
-
clientId?: string;
|
|
57
|
-
clientSecret?: string;
|
|
58
|
-
scope?: string;
|
|
59
|
-
state?: string;
|
|
60
|
-
pkce?: boolean;
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
export interface RequestParam {
|
|
64
|
-
name: string;
|
|
65
|
-
value: string;
|
|
66
|
-
enabled: boolean;
|
|
67
|
-
}
|
|
68
|
-
export interface RequestHeader {
|
|
69
|
-
name: string;
|
|
70
|
-
value: string;
|
|
71
|
-
enabled: boolean;
|
|
72
|
-
}
|
|
73
|
-
export interface RequestAssertion {
|
|
74
|
-
name: string;
|
|
75
|
-
value: string;
|
|
76
|
-
enabled: boolean;
|
|
77
|
-
}
|
|
78
|
-
export interface RequestVars {
|
|
79
|
-
req?: Array<{
|
|
80
|
-
name: string;
|
|
81
|
-
value: string;
|
|
82
|
-
enabled: boolean;
|
|
83
|
-
}>;
|
|
84
|
-
res?: Array<{
|
|
85
|
-
name: string;
|
|
86
|
-
value: string;
|
|
87
|
-
enabled: boolean;
|
|
88
|
-
}>;
|
|
89
|
-
}
|
|
90
|
-
export interface RequestScript {
|
|
91
|
-
req?: string;
|
|
92
|
-
res?: string;
|
|
93
|
-
}
|
|
94
|
-
export interface RequestSettings {
|
|
95
|
-
[key: string]: any;
|
|
96
|
-
}
|
|
97
|
-
export interface RequestData {
|
|
98
|
-
method: string;
|
|
99
|
-
url: string;
|
|
100
|
-
params: RequestParam[];
|
|
101
|
-
headers: RequestHeader[];
|
|
102
|
-
auth: AuthConfig;
|
|
103
|
-
body: RequestBody;
|
|
104
|
-
script: RequestScript;
|
|
105
|
-
vars: RequestVars;
|
|
106
|
-
assertions: RequestAssertion[];
|
|
107
|
-
tests: string;
|
|
108
|
-
docs: string;
|
|
109
|
-
}
|
|
110
|
-
export interface ParsedRequest {
|
|
111
|
-
type: 'http-request' | 'graphql-request';
|
|
112
|
-
name: string;
|
|
113
|
-
seq: number;
|
|
114
|
-
settings: RequestSettings;
|
|
115
|
-
tags: string[];
|
|
116
|
-
request: RequestData;
|
|
117
|
-
}
|
|
118
|
-
export interface ParsedCollection {
|
|
119
|
-
name: string;
|
|
120
|
-
type?: string;
|
|
121
|
-
version?: string;
|
|
122
|
-
[key: string]: any;
|
|
123
|
-
}
|
|
124
|
-
export interface EnvironmentVariable {
|
|
125
|
-
name: string;
|
|
126
|
-
value: string;
|
|
127
|
-
enabled: boolean;
|
|
128
|
-
}
|
|
129
|
-
export interface ParsedEnvironment {
|
|
130
|
-
variables: EnvironmentVariable[];
|
|
131
|
-
}
|
|
132
|
-
export interface WorkerTask {
|
|
133
|
-
data: any;
|
|
134
|
-
priority: number;
|
|
135
|
-
scriptPath: string;
|
|
136
|
-
taskType?: 'parse' | 'stringify';
|
|
137
|
-
resolve?: (value: any) => void;
|
|
138
|
-
reject?: (reason?: any) => void;
|
|
139
|
-
}
|
|
140
|
-
export interface Lane {
|
|
141
|
-
maxSize: number;
|
|
142
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { Worker } from 'node:worker_threads';
|
|
3
|
-
interface QueuedTask {
|
|
4
|
-
priority: number;
|
|
5
|
-
scriptPath: string;
|
|
6
|
-
data: any;
|
|
7
|
-
taskType: 'parse' | 'stringify';
|
|
8
|
-
resolve?: (value: any) => void;
|
|
9
|
-
reject?: (reason?: any) => void;
|
|
10
|
-
}
|
|
11
|
-
declare class WorkerQueue {
|
|
12
|
-
private queue;
|
|
13
|
-
private isProcessing;
|
|
14
|
-
private workers;
|
|
15
|
-
constructor();
|
|
16
|
-
getWorkerForScriptPath(scriptPath: string): Promise<Worker>;
|
|
17
|
-
enqueue(task: QueuedTask): Promise<unknown>;
|
|
18
|
-
processQueue(): Promise<void>;
|
|
19
|
-
runWorker({ scriptPath, data, taskType }: {
|
|
20
|
-
scriptPath: string;
|
|
21
|
-
data: any;
|
|
22
|
-
taskType: 'parse' | 'stringify';
|
|
23
|
-
}): Promise<unknown>;
|
|
24
|
-
cleanup(): Promise<void>;
|
|
25
|
-
}
|
|
26
|
-
export default WorkerQueue;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export declare const bruRequestToJson: (data: string | any, parsed?: boolean) => any;
|
|
2
|
-
export declare const jsonRequestToBru: (json: any) => string;
|
|
3
|
-
export declare const bruCollectionToJson: (data: string | any, parsed?: boolean) => any;
|
|
4
|
-
export declare const jsonCollectionToBru: (json: any, isFolder?: boolean) => string;
|
|
5
|
-
export declare const bruEnvironmentToJson: (bru: string) => any;
|
|
6
|
-
export declare const jsonEnvironmentToBru: (json: any) => string;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
type T_Oauth2ParameterSendInType = 'headers' | 'queryparams' | 'body';
|
|
2
|
-
export interface T_OAuth2AdditionalParam {
|
|
3
|
-
name: string;
|
|
4
|
-
value: string;
|
|
5
|
-
enabled: boolean;
|
|
6
|
-
sendIn: T_Oauth2ParameterSendInType;
|
|
7
|
-
}
|
|
8
|
-
export interface T_OAuth2AdditionalParameters {
|
|
9
|
-
authorization?: T_OAuth2AdditionalParam[];
|
|
10
|
-
token?: T_OAuth2AdditionalParam[];
|
|
11
|
-
refresh?: T_OAuth2AdditionalParam[];
|
|
12
|
-
}
|
|
13
|
-
export interface T_Oauth2Auth {
|
|
14
|
-
grantType: string;
|
|
15
|
-
additionalParameters?: T_OAuth2AdditionalParameters;
|
|
16
|
-
}
|
|
17
|
-
export interface T_BruJson {
|
|
18
|
-
auth: {
|
|
19
|
-
oauth2: T_Oauth2Auth;
|
|
20
|
-
};
|
|
21
|
-
oauth2_additional_parameters_auth_req_headers?: any[];
|
|
22
|
-
oauth2_additional_parameters_auth_req_queryparams?: any[];
|
|
23
|
-
oauth2_additional_parameters_access_token_req_headers?: any[];
|
|
24
|
-
oauth2_additional_parameters_access_token_req_queryparams?: any[];
|
|
25
|
-
oauth2_additional_parameters_access_token_req_bodyvalues?: any[];
|
|
26
|
-
oauth2_additional_parameters_refresh_token_req_headers?: any[];
|
|
27
|
-
oauth2_additional_parameters_refresh_token_req_queryparams?: any[];
|
|
28
|
-
oauth2_additional_parameters_refresh_token_req_bodyvalues?: any[];
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* This function extracts OAuth2 additional parameters from various sources in the bru json data and organizes
|
|
32
|
-
* them into a structured format based on their usage context (authorization, token, refresh).
|
|
33
|
-
*
|
|
34
|
-
* @param json - json object containing OAuth2 configuration and additional parameters
|
|
35
|
-
* @returns OAuth2 additional parameters
|
|
36
|
-
*/
|
|
37
|
-
export declare const getOauth2AdditionalParameters: (json: T_BruJson) => T_OAuth2AdditionalParameters;
|
|
38
|
-
export {};
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
export interface ParseOptions {
|
|
2
|
-
format?: 'bru' | 'yaml';
|
|
3
|
-
}
|
|
4
|
-
export interface StringifyOptions {
|
|
5
|
-
format?: 'bru' | 'yaml';
|
|
6
|
-
}
|
|
7
|
-
export interface RequestBody {
|
|
8
|
-
mode?: string;
|
|
9
|
-
raw?: string;
|
|
10
|
-
formUrlEncoded?: Array<{
|
|
11
|
-
name: string;
|
|
12
|
-
value: string;
|
|
13
|
-
enabled: boolean;
|
|
14
|
-
}>;
|
|
15
|
-
multipartForm?: Array<{
|
|
16
|
-
name: string;
|
|
17
|
-
value: string;
|
|
18
|
-
type: string;
|
|
19
|
-
enabled: boolean;
|
|
20
|
-
}>;
|
|
21
|
-
json?: string;
|
|
22
|
-
xml?: string;
|
|
23
|
-
sparql?: string;
|
|
24
|
-
graphql?: {
|
|
25
|
-
query?: string;
|
|
26
|
-
variables?: string;
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
export interface AuthConfig {
|
|
30
|
-
mode?: string;
|
|
31
|
-
basic?: {
|
|
32
|
-
username?: string;
|
|
33
|
-
password?: string;
|
|
34
|
-
};
|
|
35
|
-
bearer?: {
|
|
36
|
-
token?: string;
|
|
37
|
-
};
|
|
38
|
-
apikey?: {
|
|
39
|
-
key?: string;
|
|
40
|
-
value?: string;
|
|
41
|
-
placement?: string;
|
|
42
|
-
};
|
|
43
|
-
awsv4?: {
|
|
44
|
-
accessKeyId?: string;
|
|
45
|
-
secretAccessKey?: string;
|
|
46
|
-
sessionToken?: string;
|
|
47
|
-
service?: string;
|
|
48
|
-
region?: string;
|
|
49
|
-
profileName?: string;
|
|
50
|
-
};
|
|
51
|
-
oauth2?: {
|
|
52
|
-
grantType?: string;
|
|
53
|
-
callbackUrl?: string;
|
|
54
|
-
authorizationUrl?: string;
|
|
55
|
-
accessTokenUrl?: string;
|
|
56
|
-
clientId?: string;
|
|
57
|
-
clientSecret?: string;
|
|
58
|
-
scope?: string;
|
|
59
|
-
state?: string;
|
|
60
|
-
pkce?: boolean;
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
export interface RequestParam {
|
|
64
|
-
name: string;
|
|
65
|
-
value: string;
|
|
66
|
-
enabled: boolean;
|
|
67
|
-
}
|
|
68
|
-
export interface RequestHeader {
|
|
69
|
-
name: string;
|
|
70
|
-
value: string;
|
|
71
|
-
enabled: boolean;
|
|
72
|
-
}
|
|
73
|
-
export interface RequestAssertion {
|
|
74
|
-
name: string;
|
|
75
|
-
value: string;
|
|
76
|
-
enabled: boolean;
|
|
77
|
-
}
|
|
78
|
-
export interface RequestVars {
|
|
79
|
-
req?: Array<{
|
|
80
|
-
name: string;
|
|
81
|
-
value: string;
|
|
82
|
-
enabled: boolean;
|
|
83
|
-
}>;
|
|
84
|
-
res?: Array<{
|
|
85
|
-
name: string;
|
|
86
|
-
value: string;
|
|
87
|
-
enabled: boolean;
|
|
88
|
-
}>;
|
|
89
|
-
}
|
|
90
|
-
export interface RequestScript {
|
|
91
|
-
req?: string;
|
|
92
|
-
res?: string;
|
|
93
|
-
}
|
|
94
|
-
export interface RequestSettings {
|
|
95
|
-
[key: string]: any;
|
|
96
|
-
}
|
|
97
|
-
export interface RequestData {
|
|
98
|
-
method: string;
|
|
99
|
-
url: string;
|
|
100
|
-
params: RequestParam[];
|
|
101
|
-
headers: RequestHeader[];
|
|
102
|
-
auth: AuthConfig;
|
|
103
|
-
body: RequestBody;
|
|
104
|
-
script: RequestScript;
|
|
105
|
-
vars: RequestVars;
|
|
106
|
-
assertions: RequestAssertion[];
|
|
107
|
-
tests: string;
|
|
108
|
-
docs: string;
|
|
109
|
-
}
|
|
110
|
-
export interface ParsedRequest {
|
|
111
|
-
type: 'http-request' | 'graphql-request';
|
|
112
|
-
name: string;
|
|
113
|
-
seq: number;
|
|
114
|
-
settings: RequestSettings;
|
|
115
|
-
tags: string[];
|
|
116
|
-
request: RequestData;
|
|
117
|
-
}
|
|
118
|
-
export interface ParsedCollection {
|
|
119
|
-
name: string;
|
|
120
|
-
type?: string;
|
|
121
|
-
version?: string;
|
|
122
|
-
[key: string]: any;
|
|
123
|
-
}
|
|
124
|
-
export interface EnvironmentVariable {
|
|
125
|
-
name: string;
|
|
126
|
-
value: string;
|
|
127
|
-
enabled: boolean;
|
|
128
|
-
}
|
|
129
|
-
export interface ParsedEnvironment {
|
|
130
|
-
variables: EnvironmentVariable[];
|
|
131
|
-
}
|
|
132
|
-
export interface WorkerTask {
|
|
133
|
-
data: any;
|
|
134
|
-
priority: number;
|
|
135
|
-
scriptPath: string;
|
|
136
|
-
taskType?: 'parse' | 'stringify';
|
|
137
|
-
resolve?: (value: any) => void;
|
|
138
|
-
reject?: (reason?: any) => void;
|
|
139
|
-
}
|
|
140
|
-
export interface Lane {
|
|
141
|
-
maxSize: number;
|
|
142
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { Worker } from 'node:worker_threads';
|
|
3
|
-
interface QueuedTask {
|
|
4
|
-
priority: number;
|
|
5
|
-
scriptPath: string;
|
|
6
|
-
data: any;
|
|
7
|
-
taskType: 'parse' | 'stringify';
|
|
8
|
-
resolve?: (value: any) => void;
|
|
9
|
-
reject?: (reason?: any) => void;
|
|
10
|
-
}
|
|
11
|
-
declare class WorkerQueue {
|
|
12
|
-
private queue;
|
|
13
|
-
private isProcessing;
|
|
14
|
-
private workers;
|
|
15
|
-
constructor();
|
|
16
|
-
getWorkerForScriptPath(scriptPath: string): Promise<Worker>;
|
|
17
|
-
enqueue(task: QueuedTask): Promise<unknown>;
|
|
18
|
-
processQueue(): Promise<void>;
|
|
19
|
-
runWorker({ scriptPath, data, taskType }: {
|
|
20
|
-
scriptPath: string;
|
|
21
|
-
data: any;
|
|
22
|
-
taskType: 'parse' | 'stringify';
|
|
23
|
-
}): Promise<unknown>;
|
|
24
|
-
cleanup(): Promise<void>;
|
|
25
|
-
}
|
|
26
|
-
export default WorkerQueue;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
declare class BruParserWorker {
|
|
2
|
-
private workerQueues;
|
|
3
|
-
constructor();
|
|
4
|
-
private getWorkerQueue;
|
|
5
|
-
private enqueueTask;
|
|
6
|
-
parseRequest(data: any): Promise<any>;
|
|
7
|
-
stringifyRequest(data: any): Promise<any>;
|
|
8
|
-
cleanup(): Promise<void>;
|
|
9
|
-
}
|
|
10
|
-
export default BruParserWorker;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export declare const bruRequestToJson: (data: string | any, parsed?: boolean) => any;
|
|
2
|
-
export declare const jsonRequestToBru: (json: any) => string;
|
|
3
|
-
export declare const bruCollectionToJson: (data: string | any, parsed?: boolean) => any;
|
|
4
|
-
export declare const jsonCollectionToBru: (json: any, isFolder?: boolean) => string;
|
|
5
|
-
export declare const bruEnvironmentToJson: (bru: string) => any;
|
|
6
|
-
export declare const jsonEnvironmentToBru: (json: any) => string;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Parses a .bru file and extracts body content while redacting it from the main content
|
|
3
|
-
* @param {string} bruFileContent - The raw content of the .bru file
|
|
4
|
-
* @returns {Object} Object containing redacted file content and extracted body data
|
|
5
|
-
*/
|
|
6
|
-
export declare const bruRequestParseAndRedactBodyData: (bruFileContent: string) => {
|
|
7
|
-
bruFileStringWithRedactedBody: string;
|
|
8
|
-
extractedBodyContent: Record<string, string>;
|
|
9
|
-
};
|
package/dist/esm/index.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import BruParserWorker from './workers';
|
|
2
|
-
import { ParseOptions, StringifyOptions, ParsedRequest, ParsedCollection, ParsedEnvironment } from './types';
|
|
3
|
-
export declare const parseRequest: (content: string, options?: ParseOptions) => any;
|
|
4
|
-
export declare const parseRequestAndRedactBody: (content: string, options?: ParseOptions) => any;
|
|
5
|
-
export declare const stringifyRequest: (requestObj: ParsedRequest, options?: StringifyOptions) => string;
|
|
6
|
-
export declare const parseRequestViaWorker: (content: string) => Promise<any>;
|
|
7
|
-
export declare const stringifyRequestViaWorker: (requestObj: any) => Promise<string>;
|
|
8
|
-
export declare const parseCollection: (content: string, options?: ParseOptions) => any;
|
|
9
|
-
export declare const stringifyCollection: (collectionObj: ParsedCollection, options?: StringifyOptions) => string;
|
|
10
|
-
export declare const parseFolder: (content: string, options?: ParseOptions) => any;
|
|
11
|
-
export declare const stringifyFolder: (folderObj: any, options?: StringifyOptions) => string;
|
|
12
|
-
export declare const parseEnvironment: (content: string, options?: ParseOptions) => any;
|
|
13
|
-
export declare const stringifyEnvironment: (envObj: ParsedEnvironment, options?: StringifyOptions) => string;
|
|
14
|
-
export declare const parseDotEnv: (content: string) => Record<string, string>;
|
|
15
|
-
export { BruParserWorker };
|
|
16
|
-
export * from './types';
|