@usebruno/filestore 0.11.0 → 0.12.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/constants.d.ts +1 -1
- package/dist/constants.d.ts.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/utils/redact-large-text-blocks.d.ts.map +1 -1
- package/dist/formats/yml/index.d.ts +3 -1
- package/dist/formats/yml/index.d.ts.map +1 -1
- package/dist/formats/yml/items/parseGraphQLRequest.d.ts.map +1 -1
- package/dist/formats/yml/items/parseHttpRequest.d.ts.map +1 -1
- package/dist/formats/yml/items/stringifyGraphQLRequest.d.ts.map +1 -1
- package/dist/formats/yml/items/stringifyHttpRequest.d.ts.map +1 -1
- package/dist/formats/yml/mockServerTypes.d.ts +95 -0
- package/dist/formats/yml/mockServerTypes.d.ts.map +1 -0
- package/dist/formats/yml/parseCollection.d.ts.map +1 -1
- package/dist/formats/yml/parseFolder.d.ts.map +1 -1
- package/dist/formats/yml/parseMockServer.d.ts +4 -0
- package/dist/formats/yml/parseMockServer.d.ts.map +1 -0
- package/dist/formats/yml/stringifyCollection.d.ts.map +1 -1
- package/dist/formats/yml/stringifyFolder.d.ts.map +1 -1
- package/dist/formats/yml/stringifyMockServer.d.ts +4 -0
- package/dist/formats/yml/stringifyMockServer.d.ts.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/workers/WorkerQueue/index.d.ts +3 -2
- package/dist/workers/WorkerQueue/index.d.ts.map +1 -1
- package/dist/workers/index.d.ts +4 -0
- package/dist/workers/index.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/constants.ts +5 -1
- package/src/formats/bru/tests/redact-large-text-blocks.spec.js +160 -1
- package/src/formats/bru/utils/redact-large-text-blocks.ts +42 -1
- package/src/formats/yml/index.ts +5 -1
- package/src/formats/yml/items/parseGraphQLRequest.ts +6 -16
- package/src/formats/yml/items/parseHttpRequest.ts +6 -16
- package/src/formats/yml/items/stringifyGraphQLRequest.ts +4 -6
- package/src/formats/yml/items/stringifyHttpRequest.ts +4 -6
- package/src/formats/yml/mockServerTypes.ts +95 -0
- package/src/formats/yml/parseCollection.spec.ts +123 -0
- package/src/formats/yml/parseCollection.ts +18 -5
- package/src/formats/yml/parseFolder.spec.ts +18 -0
- package/src/formats/yml/parseFolder.ts +5 -1
- package/src/formats/yml/parseMockServer.spec.ts +180 -0
- package/src/formats/yml/parseMockServer.ts +113 -0
- package/src/formats/yml/stringifyCollection.spec.ts +146 -0
- package/src/formats/yml/stringifyCollection.ts +22 -9
- package/src/formats/yml/stringifyFolder.spec.ts +23 -0
- package/src/formats/yml/stringifyFolder.ts +7 -2
- package/src/formats/yml/stringifyMockServer.spec.ts +177 -0
- package/src/formats/yml/stringifyMockServer.ts +129 -0
- package/src/formats/yml/tests/defaultEnvironment.spec.js +50 -0
- package/src/formats/yml/tests/stringifyEnvironment.spec.ts +26 -0
- package/src/formats/yml/utils.ts +1 -1
- package/src/index.ts +34 -1
- package/src/types.ts +1 -0
- package/src/workers/WorkerQueue/index.ts +10 -2
- package/src/workers/index.ts +25 -1
- package/src/workers/worker-script.ts +45 -21
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redact-large-text-blocks.d.ts","sourceRoot":"","sources":["../../../../src/formats/bru/utils/redact-large-text-blocks.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,aAAa,EAAE,CAAC;CACzB;
|
|
1
|
+
{"version":3,"file":"redact-large-text-blocks.d.ts","sourceRoot":"","sources":["../../../../src/formats/bru/utils/redact-large-text-blocks.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,aAAa,EAAE,CAAC;CACzB;AAyED,eAAO,MAAM,wBAAwB,YAAa,MAAM,KAAG,eAoC1D,CAAC;AAEF,eAAO,MAAM,qBAAqB,yBAA0B,aAAa,EAAE,MAoB1E,CAAC"}
|
|
@@ -2,9 +2,11 @@ import parseYmlItem from './parseItem';
|
|
|
2
2
|
import parseYmlFolder from './parseFolder';
|
|
3
3
|
import parseYmlCollection from './parseCollection';
|
|
4
4
|
import parseYmlEnvironment from './parseEnvironment';
|
|
5
|
+
import parseYmlMockServer from './parseMockServer';
|
|
5
6
|
import stringifyYmlItem from './stringifyItem';
|
|
6
7
|
import stringifyYmlFolder from './stringifyFolder';
|
|
7
8
|
import stringifyYmlCollection from './stringifyCollection';
|
|
8
9
|
import stringifyYmlEnvironment from './stringifyEnvironment';
|
|
9
|
-
|
|
10
|
+
import stringifyYmlMockServer from './stringifyMockServer';
|
|
11
|
+
export { parseYmlItem, parseYmlFolder, parseYmlCollection, parseYmlEnvironment, parseYmlMockServer, stringifyYmlItem, stringifyYmlFolder, stringifyYmlCollection, stringifyYmlEnvironment, stringifyYmlMockServer };
|
|
10
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/formats/yml/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,aAAa,CAAC;AACvC,OAAO,cAAc,MAAM,eAAe,CAAC;AAC3C,OAAO,kBAAkB,MAAM,mBAAmB,CAAC;AACnD,OAAO,mBAAmB,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/formats/yml/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,aAAa,CAAC;AACvC,OAAO,cAAc,MAAM,eAAe,CAAC;AAC3C,OAAO,kBAAkB,MAAM,mBAAmB,CAAC;AACnD,OAAO,mBAAmB,MAAM,oBAAoB,CAAC;AACrD,OAAO,kBAAkB,MAAM,mBAAmB,CAAC;AAEnD,OAAO,gBAAgB,MAAM,iBAAiB,CAAC;AAC/C,OAAO,kBAAkB,MAAM,mBAAmB,CAAC;AACnD,OAAO,sBAAsB,MAAM,uBAAuB,CAAC;AAC3D,OAAO,uBAAuB,MAAM,wBAAwB,CAAC;AAC7D,OAAO,sBAAsB,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EACL,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACvB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseGraphQLRequest.d.ts","sourceRoot":"","sources":["../../../../src/formats/yml/items/parseGraphQLRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,IAAI,SAAS,EAA6C,MAAM,wCAAwC,CAAC;AAE3H,OAAO,KAAK,EAAE,cAAc,EAAuC,MAAM,wCAAwC,CAAC;
|
|
1
|
+
{"version":3,"file":"parseGraphQLRequest.d.ts","sourceRoot":"","sources":["../../../../src/formats/yml/items/parseGraphQLRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,IAAI,SAAS,EAA6C,MAAM,wCAAwC,CAAC;AAE3H,OAAO,KAAK,EAAE,cAAc,EAAuC,MAAM,wCAAwC,CAAC;AAYlH,QAAA,MAAM,mBAAmB,cAAe,cAAc,KAAG,SAsHxD,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseHttpRequest.d.ts","sourceRoot":"","sources":["../../../../src/formats/yml/items/parseHttpRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,IAAI,SAAS,EAA6C,MAAM,wCAAwC,CAAC;AAE3H,OAAO,KAAK,EAAE,WAAW,EAAmB,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"parseHttpRequest.d.ts","sourceRoot":"","sources":["../../../../src/formats/yml/items/parseHttpRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,IAAI,SAAS,EAA6C,MAAM,wCAAwC,CAAC;AAE3H,OAAO,KAAK,EAAE,WAAW,EAAmB,MAAM,qCAAqC,CAAC;AAcxF,QAAA,MAAM,gBAAgB,cAAe,WAAW,KAAG,SAoLlD,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stringifyGraphQLRequest.d.ts","sourceRoot":"","sources":["../../../../src/formats/yml/items/stringifyGraphQLRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,IAAI,SAAS,EAA6C,MAAM,wCAAwC,CAAC;
|
|
1
|
+
{"version":3,"file":"stringifyGraphQLRequest.d.ts","sourceRoot":"","sources":["../../../../src/formats/yml/items/stringifyGraphQLRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,IAAI,SAAS,EAA6C,MAAM,wCAAwC,CAAC;AAoB3H,QAAA,MAAM,uBAAuB,SAAU,SAAS,KAAG,MAkJlD,CAAC;AAEF,eAAe,uBAAuB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stringifyHttpRequest.d.ts","sourceRoot":"","sources":["../../../../src/formats/yml/items/stringifyHttpRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,IAAI,SAAS,EAA6C,MAAM,wCAAwC,CAAC;
|
|
1
|
+
{"version":3,"file":"stringifyHttpRequest.d.ts","sourceRoot":"","sources":["../../../../src/formats/yml/items/stringifyHttpRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,IAAI,SAAS,EAA6C,MAAM,wCAAwC,CAAC;AAsB3H,QAAA,MAAM,oBAAoB,SAAU,SAAS,KAAG,MA6M/C,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { HttpRequestHeader, HttpResponseHeader, HttpRequestParam, HttpRequestBody } from '@opencollection/types/requests/http';
|
|
2
|
+
export interface MockRuleCondition {
|
|
3
|
+
target?: string;
|
|
4
|
+
key?: string;
|
|
5
|
+
operator?: string;
|
|
6
|
+
value?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface MockRouteRules {
|
|
9
|
+
operator?: 'AND' | 'OR';
|
|
10
|
+
conditions?: MockRuleCondition[];
|
|
11
|
+
}
|
|
12
|
+
export interface MockRouteEntry {
|
|
13
|
+
name?: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
request?: {
|
|
16
|
+
method?: string;
|
|
17
|
+
url?: string;
|
|
18
|
+
headers?: HttpRequestHeader[];
|
|
19
|
+
params?: HttpRequestParam[];
|
|
20
|
+
body?: HttpRequestBody;
|
|
21
|
+
};
|
|
22
|
+
response?: {
|
|
23
|
+
status?: number;
|
|
24
|
+
statusText?: string;
|
|
25
|
+
headers?: HttpResponseHeader[];
|
|
26
|
+
body?: {
|
|
27
|
+
type?: string;
|
|
28
|
+
data?: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
rules?: MockRouteRules;
|
|
32
|
+
copiedFrom?: {
|
|
33
|
+
example?: string | null;
|
|
34
|
+
requestPath?: string | null;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export interface MockServerFile {
|
|
38
|
+
info?: {
|
|
39
|
+
name?: string;
|
|
40
|
+
type?: 'mock';
|
|
41
|
+
};
|
|
42
|
+
mock?: {
|
|
43
|
+
port?: number;
|
|
44
|
+
delay?: number;
|
|
45
|
+
source?: {
|
|
46
|
+
type?: 'collection' | 'spec';
|
|
47
|
+
path?: string;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
routes?: MockRouteEntry[];
|
|
51
|
+
}
|
|
52
|
+
export interface BrunoMockRoute {
|
|
53
|
+
name: string;
|
|
54
|
+
description: string;
|
|
55
|
+
request: {
|
|
56
|
+
url: string;
|
|
57
|
+
method: string;
|
|
58
|
+
headers: any[];
|
|
59
|
+
params: any[];
|
|
60
|
+
body: any;
|
|
61
|
+
};
|
|
62
|
+
response: {
|
|
63
|
+
status: number;
|
|
64
|
+
statusText: string;
|
|
65
|
+
headers: any[];
|
|
66
|
+
body: {
|
|
67
|
+
type: string;
|
|
68
|
+
content: string;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
rules: {
|
|
72
|
+
operator: 'AND' | 'OR';
|
|
73
|
+
conditions: Array<{
|
|
74
|
+
target: string;
|
|
75
|
+
key: string;
|
|
76
|
+
operator: string;
|
|
77
|
+
value: string;
|
|
78
|
+
}>;
|
|
79
|
+
};
|
|
80
|
+
copiedFrom?: {
|
|
81
|
+
exampleName: string | null;
|
|
82
|
+
requestPathname: string | null;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
export interface BrunoMockServer {
|
|
86
|
+
name: string;
|
|
87
|
+
port: number | null;
|
|
88
|
+
delay: number;
|
|
89
|
+
source: {
|
|
90
|
+
type: 'collection' | 'spec';
|
|
91
|
+
path: string;
|
|
92
|
+
} | null;
|
|
93
|
+
routes: BrunoMockRoute[];
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=mockServerTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mockServerTypes.d.ts","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AAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE;QACN,IAAI,EAAE,YAAY,GAAG,MAAM,CAAC;QAC5B,IAAI,EAAE,MAAM,CAAC;KACd,GAAG,IAAI,CAAC;IACT,MAAM,EAAE,cAAc,EAAE,CAAC;CAC1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseCollection.d.ts","sourceRoot":"","sources":["../../../src/formats/yml/parseCollection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAU3E,UAAU,gBAAgB;IACxB,cAAc,EAAE,UAAU,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAClC;AAED,QAAA,MAAM,eAAe,cAAe,MAAM,KAAG,
|
|
1
|
+
{"version":3,"file":"parseCollection.d.ts","sourceRoot":"","sources":["../../../src/formats/yml/parseCollection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAU3E,UAAU,gBAAgB;IACxB,cAAc,EAAE,UAAU,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAClC;AAED,QAAA,MAAM,eAAe,cAAe,MAAM,KAAG,gBAqO5C,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseFolder.d.ts","sourceRoot":"","sources":["../../../src/formats/yml/parseFolder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAU3E,QAAA,MAAM,WAAW,cAAe,MAAM,KAAG,
|
|
1
|
+
{"version":3,"file":"parseFolder.d.ts","sourceRoot":"","sources":["../../../src/formats/yml/parseFolder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAU3E,QAAA,MAAM,WAAW,cAAe,MAAM,KAAG,UA6ExC,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseMockServer.d.ts","sourceRoot":"","sources":["../../../src/formats/yml/parseMockServer.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAGV,eAAe,EAGhB,MAAM,mBAAmB,CAAC;AAuE3B,QAAA,MAAM,eAAe,YAAa,MAAM,KAAG,eA4B1C,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stringifyCollection.d.ts","sourceRoot":"","sources":["../../../src/formats/yml/stringifyCollection.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"stringifyCollection.d.ts","sourceRoot":"","sources":["../../../src/formats/yml/stringifyCollection.ts"],"names":[],"mappings":"AAmEA,QAAA,MAAM,mBAAmB,mBAAoB,GAAG,eAAe,GAAG,KAAG,MA0OpE,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stringifyFolder.d.ts","sourceRoot":"","sources":["../../../src/formats/yml/stringifyFolder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAmC3E,QAAA,MAAM,eAAe,eAAgB,UAAU,KAAG,
|
|
1
|
+
{"version":3,"file":"stringifyFolder.d.ts","sourceRoot":"","sources":["../../../src/formats/yml/stringifyFolder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAmC3E,QAAA,MAAM,eAAe,eAAgB,UAAU,KAAG,MA2EjD,CAAC;AACF,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stringifyMockServer.d.ts","sourceRoot":"","sources":["../../../src/formats/yml/stringifyMockServer.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAGV,eAAe,EAEhB,MAAM,mBAAmB,CAAC;AAkF3B,QAAA,MAAM,mBAAmB,eAAgB,eAAe,KAAG,MAkC1D,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -12,12 +12,26 @@ export declare const parseRequestViaWorker: (content: string, options: {
|
|
|
12
12
|
export declare const stringifyRequestViaWorker: (requestObj: any, options: {
|
|
13
13
|
format: CollectionFormat;
|
|
14
14
|
}) => Promise<string>;
|
|
15
|
+
export declare const parseFolderViaWorker: (content: string, options: {
|
|
16
|
+
format: CollectionFormat;
|
|
17
|
+
}) => Promise<any>;
|
|
18
|
+
export declare const stringifyFolderViaWorker: (folderObj: any, options: {
|
|
19
|
+
format: CollectionFormat;
|
|
20
|
+
}) => Promise<string>;
|
|
21
|
+
export declare const parseEnvironmentViaWorker: (content: string, options: {
|
|
22
|
+
format: CollectionFormat;
|
|
23
|
+
}) => Promise<any>;
|
|
24
|
+
export declare const stringifyEnvironmentViaWorker: (envObj: any, options: {
|
|
25
|
+
format: CollectionFormat;
|
|
26
|
+
}) => Promise<string>;
|
|
15
27
|
export declare const parseCollection: (content: string, options?: ParseOptions) => any;
|
|
16
28
|
export declare const stringifyCollection: (collectionObj: BrunoCollection, brunoConfig: any, options?: StringifyOptions) => string;
|
|
17
29
|
export declare const parseFolder: (content: string, options?: ParseOptions) => any;
|
|
18
30
|
export declare const stringifyFolder: (folderObj: any, options?: StringifyOptions) => string;
|
|
19
31
|
export declare const parseEnvironment: (content: string, options?: ParseOptions) => any;
|
|
20
32
|
export declare const stringifyEnvironment: (envObj: BrunoEnvironment, options?: StringifyOptions) => string;
|
|
33
|
+
export declare const parseMockServer: (content: string, options?: ParseOptions) => any;
|
|
34
|
+
export declare const stringifyMockServer: (mockServerObj: any, options?: StringifyOptions) => string;
|
|
21
35
|
export declare const parseDotEnv: (content: string) => Record<string, string>;
|
|
22
36
|
export { redactLargeBruTextBlocks, restoreRedactedBlocks };
|
|
23
37
|
export type { RedactedBlock, RedactionResult } from './formats/bru/utils/redact-large-text-blocks';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAuB3F,OAAO,eAAe,MAAM,WAAW,CAAC;AACxC,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAG/G,eAAO,MAAM,YAAY,YAAa,MAAM,YAAW,YAAY,KAA2C,GAO7G,CAAC;AAEF,eAAO,MAAM,yBAAyB,YAAa,MAAM,YAAW,YAAY,KAAuB,GAKtG,CAAC;AAEF,eAAO,MAAM,gBAAgB,eAAgB,SAAS,YAAW,gBAAgB,KAA2C,MAO3H,CAAC;AAWF,eAAO,MAAM,qBAAqB,YAAmB,MAAM,WAAW;IAAE,MAAM,EAAE,gBAAgB,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,KAAG,QAAQ,GAAG,CAIlI,CAAC;AAEF,eAAO,MAAM,yBAAyB,eAAsB,GAAG,WAAW;IAAE,MAAM,EAAE,gBAAgB,CAAA;CAAE,KAAG,QAAQ,MAAM,CAGtH,CAAC;AAEF,eAAO,MAAM,oBAAoB,YAAmB,MAA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CAAgC,EAAE,MAAM,mCAAmC,CAAC;AAErF,OAAO,EAAE,eAAe,EAAE,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
|
package/dist/types.d.ts
CHANGED
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,KAAK,CAAC;AAE7C,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,EAAE,gBAAgB,CAAC;CAC3B;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,gBAAgB,CAAC;CAC3B;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,GAAG,CAAC;IACV,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,GAAG,WAAW,CAAC;IACjC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;IAC/B,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;CACjC;AAED,MAAM,WAAW,IAAI;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,CAAC,EAAE;QACR,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,GAAG,CAAC,EAAE,MAAM,CAAC;KACd,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,KAAK,CAAC;AAE7C,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,EAAE,gBAAgB,CAAC;CAC3B;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,gBAAgB,CAAC;CAC3B;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,GAAG,CAAC;IACV,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,GAAG,WAAW,CAAC;IACjC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;IAC/B,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;CACjC;AAED,MAAM,WAAW,IAAI;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,CAAC,EAAE;QACR,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,GAAG,CAAC,EAAE,MAAM,CAAC;KACd,CAAC;IACF,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Worker } from 'node:worker_threads';
|
|
3
|
+
type WorkerTaskType = 'parse' | 'stringify' | 'parseFolder' | 'stringifyFolder' | 'parseEnvironment' | 'stringifyEnvironment';
|
|
3
4
|
interface QueuedTask {
|
|
4
5
|
priority: number;
|
|
5
6
|
scriptPath: string;
|
|
6
7
|
data: any;
|
|
7
|
-
taskType:
|
|
8
|
+
taskType: WorkerTaskType;
|
|
8
9
|
resolve?: (value: any) => void;
|
|
9
10
|
reject?: (reason?: any) => void;
|
|
10
11
|
}
|
|
@@ -19,7 +20,7 @@ declare class WorkerQueue {
|
|
|
19
20
|
runWorker({ scriptPath, data, taskType }: {
|
|
20
21
|
scriptPath: string;
|
|
21
22
|
data: any;
|
|
22
|
-
taskType:
|
|
23
|
+
taskType: WorkerTaskType;
|
|
23
24
|
}): Promise<unknown>;
|
|
24
25
|
cleanup(): Promise<void>;
|
|
25
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/workers/WorkerQueue/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,UAAU,UAAU;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,GAAG,CAAC;IACV,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/workers/WorkerQueue/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,KAAK,cAAc,GACb,OAAO,GACP,WAAW,GACX,aAAa,GACb,iBAAiB,GACjB,kBAAkB,GAClB,sBAAsB,CAAC;AAE7B,UAAU,UAAU;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,GAAG,CAAC;IACV,QAAQ,EAAE,cAAc,CAAC;IACzB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;IAC/B,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;CACjC;AAED,cAAM,WAAW;IACf,OAAO,CAAC,KAAK,CAAe;IAC5B,OAAO,CAAC,YAAY,CAAU;IAC9B,OAAO,CAAC,OAAO,CAAyB;;IAQlC,sBAAsB,CAAC,UAAU,EAAE,MAAM;IASzC,OAAO,CAAC,IAAI,EAAE,UAAU;IAUxB,YAAY;IAmBZ,SAAS,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,GAAG,CAAC;QAAC,QAAQ,EAAE,cAAc,CAAA;KAAE;IAwCrG,OAAO;CAWd;AAED,eAAe,WAAW,CAAC"}
|
package/dist/workers/index.d.ts
CHANGED
|
@@ -6,6 +6,10 @@ declare class BruParserWorker {
|
|
|
6
6
|
private enqueueTask;
|
|
7
7
|
parseRequest(data: any, format?: CollectionFormat): Promise<any>;
|
|
8
8
|
stringifyRequest(data: any, format?: CollectionFormat): Promise<any>;
|
|
9
|
+
parseFolder(data: any, format?: CollectionFormat): Promise<any>;
|
|
10
|
+
stringifyFolder(data: any, format?: CollectionFormat): Promise<any>;
|
|
11
|
+
parseEnvironment(data: any, format?: CollectionFormat): Promise<any>;
|
|
12
|
+
stringifyEnvironment(data: any, format?: CollectionFormat): Promise<any>;
|
|
9
13
|
cleanup(): Promise<void>;
|
|
10
14
|
}
|
|
11
15
|
export default BruParserWorker;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/workers/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAQ,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAoClD,cAAM,eAAe;IACnB,OAAO,CAAC,YAAY,CAAwB;;IAS5C,OAAO,CAAC,cAAc;YAUR,WAAW;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/workers/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAQ,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAoClD,cAAM,eAAe;IACnB,OAAO,CAAC,YAAY,CAAwB;;IAS5C,OAAO,CAAC,cAAc;YAUR,WAAW;IAqBnB,YAAY,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,GAAE,gBAA4C,GAAG,OAAO,CAAC,GAAG,CAAC;IAI3F,gBAAgB,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,GAAE,gBAA4C,GAAG,OAAO,CAAC,GAAG,CAAC;IAI/F,WAAW,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,GAAE,gBAA4C,GAAG,OAAO,CAAC,GAAG,CAAC;IAI1F,eAAe,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,GAAE,gBAA4C,GAAG,OAAO,CAAC,GAAG,CAAC;IAI9F,gBAAgB,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,GAAE,gBAA4C,GAAG,OAAO,CAAC,GAAG,CAAC;IAI/F,oBAAoB,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,GAAE,gBAA4C,GAAG,OAAO,CAAC,GAAG,CAAC;IAInG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAM/B;AAED,eAAe,eAAe,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usebruno/filestore",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"@types/jest": "^29.5.11",
|
|
30
30
|
"@types/lodash": "^4.14.191",
|
|
31
31
|
"@types/node": "^24.1.0",
|
|
32
|
-
"@opencollection/types": "0.
|
|
33
|
-
"@usebruno/schema-types": "0.
|
|
32
|
+
"@opencollection/types": "0.12.0",
|
|
33
|
+
"@usebruno/schema-types": "0.8.0",
|
|
34
34
|
"babel-jest": "^29.7.0",
|
|
35
35
|
"jest": "^29.2.0",
|
|
36
36
|
"nanoid": "3.3.8",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@types/nanoid": "^2.1.0",
|
|
49
|
-
"@usebruno/common": "0.
|
|
50
|
-
"@usebruno/lang": "0.
|
|
49
|
+
"@usebruno/common": "0.25.0",
|
|
50
|
+
"@usebruno/lang": "0.39.0",
|
|
51
51
|
"ajv": "^8.17.1",
|
|
52
52
|
"lodash": "4.18.1",
|
|
53
53
|
"yaml": "^2.3.4"
|
package/src/constants.ts
CHANGED
|
@@ -4,9 +4,13 @@ import type { ExternalSecretProviderType } from '@usebruno/schema-types/collecti
|
|
|
4
4
|
export const DEFAULT_COLLECTION_FORMAT: CollectionFormat = 'yml';
|
|
5
5
|
|
|
6
6
|
// Each provider type stores its secret reference under a different key.
|
|
7
|
-
export const SECRET_PROVIDER_IDENTIFIER_FIELDS: Record<
|
|
7
|
+
export const SECRET_PROVIDER_IDENTIFIER_FIELDS: Record<
|
|
8
|
+
ExternalSecretProviderType,
|
|
9
|
+
'path' | 'secretName' | 'vaultName' | 'projectId'
|
|
10
|
+
> = {
|
|
8
11
|
'aws-secrets-manager': 'secretName',
|
|
9
12
|
'azure-key-vault': 'vaultName',
|
|
13
|
+
'gcp-secrets-manager': 'projectId',
|
|
10
14
|
'hashicorp-vault-cloud': 'path',
|
|
11
15
|
'hashicorp-vault-server': 'path'
|
|
12
16
|
};
|
|
@@ -169,6 +169,127 @@ body:json {
|
|
|
169
169
|
}
|
|
170
170
|
`;
|
|
171
171
|
|
|
172
|
+
const appBru = `meta {
|
|
173
|
+
name: App Request
|
|
174
|
+
type: http
|
|
175
|
+
seq: 1
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
get {
|
|
179
|
+
url: https://example.com
|
|
180
|
+
body: none
|
|
181
|
+
auth: none
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
app {
|
|
185
|
+
enabled: true
|
|
186
|
+
code: '''
|
|
187
|
+
<div id="x">hi</div>
|
|
188
|
+
<style>
|
|
189
|
+
body {
|
|
190
|
+
color: red;
|
|
191
|
+
}
|
|
192
|
+
</style>
|
|
193
|
+
<script>
|
|
194
|
+
function go() {
|
|
195
|
+
return { ok: 1 };
|
|
196
|
+
}
|
|
197
|
+
</script>
|
|
198
|
+
'''
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
docs {
|
|
202
|
+
# Docs after the app block
|
|
203
|
+
}
|
|
204
|
+
`;
|
|
205
|
+
|
|
206
|
+
const standaloneAppBru = `meta {
|
|
207
|
+
name: Dashboard
|
|
208
|
+
type: app
|
|
209
|
+
seq: 2
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
app {
|
|
213
|
+
code: '''
|
|
214
|
+
<div id="app">standalone</div>
|
|
215
|
+
'''
|
|
216
|
+
}
|
|
217
|
+
`;
|
|
218
|
+
|
|
219
|
+
const appWithoutCodeBru = `meta {
|
|
220
|
+
name: No Code
|
|
221
|
+
type: http
|
|
222
|
+
seq: 1
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
get {
|
|
226
|
+
url: https://example.com
|
|
227
|
+
body: none
|
|
228
|
+
auth: none
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
app {
|
|
232
|
+
enabled: true
|
|
233
|
+
}
|
|
234
|
+
`;
|
|
235
|
+
|
|
236
|
+
const appEmptyCodeBru = `meta {
|
|
237
|
+
name: Empty Code
|
|
238
|
+
type: http
|
|
239
|
+
seq: 1
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
app {
|
|
243
|
+
enabled: true
|
|
244
|
+
code: '''
|
|
245
|
+
'''
|
|
246
|
+
}
|
|
247
|
+
`;
|
|
248
|
+
|
|
249
|
+
const docsAboutAppCodeBru = `meta {
|
|
250
|
+
name: Docs About App Code
|
|
251
|
+
type: http
|
|
252
|
+
seq: 1
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
get {
|
|
256
|
+
url: https://example.com
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
docs {
|
|
260
|
+
# How the app block works
|
|
261
|
+
|
|
262
|
+
app {
|
|
263
|
+
code: '''
|
|
264
|
+
<div>hi</div>
|
|
265
|
+
'''
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
`;
|
|
269
|
+
|
|
270
|
+
const appWithoutCodeThenDocsBru = `meta {
|
|
271
|
+
name: No Code Then Docs
|
|
272
|
+
type: http
|
|
273
|
+
seq: 1
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
get {
|
|
277
|
+
url: https://example.com
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
app {
|
|
281
|
+
enabled: true
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
docs {
|
|
285
|
+
Set the code like this:
|
|
286
|
+
|
|
287
|
+
code: '''
|
|
288
|
+
<div>hi</div>
|
|
289
|
+
'''
|
|
290
|
+
}
|
|
291
|
+
`;
|
|
292
|
+
|
|
172
293
|
describe('redactLargeBruTextBlocks', () => {
|
|
173
294
|
describe('matches a normal parse (ohm oracle)', () => {
|
|
174
295
|
const requestCases = [
|
|
@@ -177,7 +298,14 @@ describe('redactLargeBruTextBlocks', () => {
|
|
|
177
298
|
['xml + sparql bodies', xmlSparqlBru],
|
|
178
299
|
['CRLF request', toCRLF(requestBru)],
|
|
179
300
|
['leading + trailing blank lines in body', blankLinesBru],
|
|
180
|
-
['CRLF leading + trailing blank lines', toCRLF(blankLinesBru)]
|
|
301
|
+
['CRLF leading + trailing blank lines', toCRLF(blankLinesBru)],
|
|
302
|
+
['request-level app code', appBru],
|
|
303
|
+
['CRLF request-level app code', toCRLF(appBru)],
|
|
304
|
+
['standalone app item', standaloneAppBru],
|
|
305
|
+
['app block without code', appWithoutCodeBru],
|
|
306
|
+
['app block with an empty code value', appEmptyCodeBru],
|
|
307
|
+
['docs documenting an app code block', docsAboutAppCodeBru],
|
|
308
|
+
['app block without code followed by docs holding a code pair', appWithoutCodeThenDocsBru]
|
|
181
309
|
];
|
|
182
310
|
|
|
183
311
|
it.each(requestCases)('%s', (_name, content) => {
|
|
@@ -228,6 +356,37 @@ body:json {
|
|
|
228
356
|
expect(blocks[0].value).toContain(blob);
|
|
229
357
|
});
|
|
230
358
|
|
|
359
|
+
it('keeps huge app code out of the skeleton, pair and delimiters intact', () => {
|
|
360
|
+
const blob = 'x'.repeat(4 * 1024 * 1024);
|
|
361
|
+
const bru = appBru.replace('<div id="x">hi</div>', `<div>${blob}</div>`);
|
|
362
|
+
|
|
363
|
+
const { skeleton, blocks } = redactLargeBruTextBlocks(bru);
|
|
364
|
+
expect(skeleton.length).toBeLessThan(1024);
|
|
365
|
+
expect(skeleton).toMatch(/code: '''\n\s+__BRU_REDACTED_TEXT_BLOCK_\w+__\n\s+'''/);
|
|
366
|
+
expect(skeleton).toContain('enabled: true');
|
|
367
|
+
expect(blocks.some((block) => block.value.includes(blob))).toBe(true);
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
it('leaves an app block whose code has no value untouched', () => {
|
|
371
|
+
const { blocks } = redactLargeBruTextBlocks(appEmptyCodeBru);
|
|
372
|
+
expect(blocks).toEqual([]);
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
it('leaves a code pair outside the app block untouched', () => {
|
|
376
|
+
const { blocks } = redactLargeBruTextBlocks(docsAboutAppCodeBru);
|
|
377
|
+
expect(blocks.length).toBe(1);
|
|
378
|
+
expect(blocks[0].value).toContain("code: '''");
|
|
379
|
+
expect(blocks[0].value).toContain('<div>hi</div>');
|
|
380
|
+
expect(blocks[0].value).not.toContain('__BRU_REDACTED_TEXT_BLOCK_');
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
it('leaves a code pair after an app block that has no code untouched', () => {
|
|
384
|
+
const { blocks } = redactLargeBruTextBlocks(appWithoutCodeThenDocsBru);
|
|
385
|
+
expect(blocks.length).toBe(1);
|
|
386
|
+
expect(blocks[0].value).toContain("code: '''");
|
|
387
|
+
expect(blocks[0].value).not.toContain('__BRU_REDACTED_TEXT_BLOCK_');
|
|
388
|
+
});
|
|
389
|
+
|
|
231
390
|
it('leaves dictionary body blocks untouched', () => {
|
|
232
391
|
const multipart = `meta {
|
|
233
392
|
name: Multipart
|
|
@@ -41,6 +41,47 @@ const tokenFor = (content: string): string => {
|
|
|
41
41
|
const blockValue = (content: string[]): string =>
|
|
42
42
|
outdentString(content.join('\n').replace(/^(?:\r?\n)+/, '').replace(/\r$/, ''));
|
|
43
43
|
|
|
44
|
+
const APP_BLOCK_OPENING = /^app[ \t]*\{\r?$/;
|
|
45
|
+
const MULTILINE_DELIMITER = '\'\'\'';
|
|
46
|
+
const APP_CODE_PAIR = `code: ${MULTILINE_DELIMITER}`;
|
|
47
|
+
|
|
48
|
+
const appCodeValue = (code: string[]): string =>
|
|
49
|
+
code.map((line) => line.slice(4)).join('\n').trim();
|
|
50
|
+
|
|
51
|
+
const redactAppCode = (source: string, blocks: RedactedBlock[]): string => {
|
|
52
|
+
const lines = source.split('\n');
|
|
53
|
+
|
|
54
|
+
const start = lines.findIndex((line) => APP_BLOCK_OPENING.test(line));
|
|
55
|
+
if (start === -1) {
|
|
56
|
+
return source;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const closingBrace = lines.findIndex((line, index) => index > start && isClosing(line));
|
|
60
|
+
const end = closingBrace === -1 ? lines.length : closingBrace;
|
|
61
|
+
|
|
62
|
+
const opening = lines.findIndex((line, index) => index > start && index < end && line.trim() === APP_CODE_PAIR);
|
|
63
|
+
if (opening === -1) {
|
|
64
|
+
return source;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const closing = lines.findIndex(
|
|
68
|
+
(line, index) => index > opening && index < end && line.trim() === MULTILINE_DELIMITER
|
|
69
|
+
);
|
|
70
|
+
if (closing === -1) {
|
|
71
|
+
return source;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const code = lines.slice(opening + 1, closing);
|
|
75
|
+
const value = appCodeValue(code);
|
|
76
|
+
if (!value.length) {
|
|
77
|
+
return source;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const token = tokenFor(code.join('\n'));
|
|
81
|
+
blocks.push({ token, value });
|
|
82
|
+
return [...lines.slice(0, opening + 1), ` ${token}`, ...lines.slice(closing)].join('\n');
|
|
83
|
+
};
|
|
84
|
+
|
|
44
85
|
export const redactLargeBruTextBlocks = (content: string): RedactionResult => {
|
|
45
86
|
const source = content || '';
|
|
46
87
|
const skeleton: string[] = [];
|
|
@@ -49,7 +90,7 @@ export const redactLargeBruTextBlocks = (content: string): RedactionResult => {
|
|
|
49
90
|
let openTag: string | null = null;
|
|
50
91
|
let openContent: string[] = [];
|
|
51
92
|
|
|
52
|
-
for (const line of source.split('\n')) {
|
|
93
|
+
for (const line of redactAppCode(source, blocks).split('\n')) {
|
|
53
94
|
if (openTag === null && isOpening(line)) {
|
|
54
95
|
openTag = line;
|
|
55
96
|
openContent = [];
|
package/src/formats/yml/index.ts
CHANGED
|
@@ -2,19 +2,23 @@ import parseYmlItem from './parseItem';
|
|
|
2
2
|
import parseYmlFolder from './parseFolder';
|
|
3
3
|
import parseYmlCollection from './parseCollection';
|
|
4
4
|
import parseYmlEnvironment from './parseEnvironment';
|
|
5
|
+
import parseYmlMockServer from './parseMockServer';
|
|
5
6
|
|
|
6
7
|
import stringifyYmlItem from './stringifyItem';
|
|
7
8
|
import stringifyYmlFolder from './stringifyFolder';
|
|
8
9
|
import stringifyYmlCollection from './stringifyCollection';
|
|
9
10
|
import stringifyYmlEnvironment from './stringifyEnvironment';
|
|
11
|
+
import stringifyYmlMockServer from './stringifyMockServer';
|
|
10
12
|
|
|
11
13
|
export {
|
|
12
14
|
parseYmlItem,
|
|
13
15
|
parseYmlFolder,
|
|
14
16
|
parseYmlCollection,
|
|
15
17
|
parseYmlEnvironment,
|
|
18
|
+
parseYmlMockServer,
|
|
16
19
|
stringifyYmlItem,
|
|
17
20
|
stringifyYmlFolder,
|
|
18
21
|
stringifyYmlCollection,
|
|
19
|
-
stringifyYmlEnvironment
|
|
22
|
+
stringifyYmlEnvironment,
|
|
23
|
+
stringifyYmlMockServer
|
|
20
24
|
};
|
|
@@ -9,6 +9,8 @@ import { toBrunoPostResponseVariables } from '../common/actions';
|
|
|
9
9
|
import { toBrunoScripts } from '../common/scripts';
|
|
10
10
|
import { toBrunoAssertions } from '../common/assertions';
|
|
11
11
|
import { uuid, ensureString } from '../../../utils';
|
|
12
|
+
import { utils } from '@usebruno/common';
|
|
13
|
+
const { toBool, toNumber } = utils;
|
|
12
14
|
|
|
13
15
|
const parseGraphQLRequest = (ocRequest: GraphQLRequest): BrunoItem => {
|
|
14
16
|
const info = ocRequest.info;
|
|
@@ -110,11 +112,7 @@ const parseGraphQLRequest = (ocRequest: GraphQLRequest): BrunoItem => {
|
|
|
110
112
|
if (ocRequest.settings) {
|
|
111
113
|
const settings: BrunoHttpItemSettings = {};
|
|
112
114
|
|
|
113
|
-
|
|
114
|
-
settings.encodeUrl = ocRequest.settings.encodeUrl;
|
|
115
|
-
} else {
|
|
116
|
-
settings.encodeUrl = true;
|
|
117
|
-
}
|
|
115
|
+
settings.encodeUrl = toBool(ocRequest.settings.encodeUrl, true);
|
|
118
116
|
|
|
119
117
|
if (typeof ocRequest.settings.timeout === 'number') {
|
|
120
118
|
settings.timeout = ocRequest.settings.timeout;
|
|
@@ -124,17 +122,9 @@ const parseGraphQLRequest = (ocRequest: GraphQLRequest): BrunoItem => {
|
|
|
124
122
|
settings.timeout = 0;
|
|
125
123
|
}
|
|
126
124
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
settings.followRedirects = true;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
if (typeof ocRequest.settings.maxRedirects === 'number') {
|
|
134
|
-
settings.maxRedirects = ocRequest.settings.maxRedirects;
|
|
135
|
-
} else {
|
|
136
|
-
settings.maxRedirects = 5;
|
|
137
|
-
}
|
|
125
|
+
settings.followRedirects = toBool(ocRequest.settings.followRedirects, true);
|
|
126
|
+
settings.maxRedirects = toNumber(ocRequest.settings.maxRedirects, 5);
|
|
127
|
+
settings.forwardAuthorizationHeader = toBool(ocRequest.settings.forwardAuthorizationHeader, true);
|
|
138
128
|
|
|
139
129
|
brunoItem.settings = settings;
|
|
140
130
|
}
|