@skyramp/skyramp 1.3.10 → 1.3.12
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/package.json +7 -5
- package/scripts/build-pdf-bundle.js +141 -0
- package/scripts/pdf-execution-helpers.js +340 -0
- package/src/classes/MockV2.d.ts +26 -22
- package/src/classes/MockV2.js +51 -20
- package/src/classes/SkyrampClient.d.ts +10 -9
- package/src/classes/SkyrampClient.js +122 -20
- package/src/classes/SmartPlaywright.js +418 -2
- package/src/function.d.ts +14 -0
- package/src/function.js +146 -1
- package/src/index.js +4 -2
- package/src/pdfViewer/bundle.d.ts +11 -0
- package/src/pdfViewer/bundle.js +1349 -0
- package/src/pdfViewer/index.d.ts +8 -0
- package/src/pdfViewer/index.js +14 -0
- package/src/pdfViewer/validator.d.ts +25 -0
- package/src/pdfViewer/validator.js +119 -0
- package/src/utils.d.ts +8 -0
- package/src/utils.js +5 -0
package/src/classes/MockV2.js
CHANGED
|
@@ -5,24 +5,52 @@
|
|
|
5
5
|
class MockV2 {
|
|
6
6
|
/**
|
|
7
7
|
* Represents a mock object configuration for API endpoint mocking.
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* @
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
8
|
+
* Supports both positional arguments and options object patterns.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* // Positional arguments
|
|
12
|
+
* new MockV2("http://localhost:8080", "/api/v1/products", 8080, "POST", 201, "{}")
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* // Options object (preferred)
|
|
16
|
+
* new MockV2({
|
|
17
|
+
* url: "http://localhost:8080",
|
|
18
|
+
* path: "/api/v1/products",
|
|
19
|
+
* method: "POST",
|
|
20
|
+
* responseStatusCode: 201
|
|
21
|
+
* })
|
|
22
|
+
*
|
|
23
|
+
* @param {string|Object} URLOrOptions - URL string or options object
|
|
24
|
+
* @param {string} [path] - The endpoint path (positional only)
|
|
25
|
+
* @param {string} [method] - The HTTP method (positional only)
|
|
26
|
+
* @param {number} [statusCode] - The status code (positional only)
|
|
27
|
+
* @param {string} [responseBody] - The response body (positional only)
|
|
14
28
|
* @param {string} [requestBody] - Optional request body to match
|
|
15
29
|
* @param {Object} [dataOverride] - Optional data override object
|
|
16
30
|
*/
|
|
17
|
-
constructor(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
31
|
+
constructor(URLOrOptions, path, method, statusCode, responseBody, requestBody = null, dataOverride = null) {
|
|
32
|
+
// Handle options object pattern
|
|
33
|
+
if (typeof URLOrOptions === 'object' && URLOrOptions !== null) {
|
|
34
|
+
const options = URLOrOptions;
|
|
35
|
+
this.url = options.url || '';
|
|
36
|
+
this.path = options.path || '';
|
|
37
|
+
this.method = options.method || '';
|
|
38
|
+
this.statusCode = options.statusCode || 201;
|
|
39
|
+
this.responseBody = (options.body !== undefined ? options.body : options.responseBody) || '';
|
|
40
|
+
this.requestBody = options.requestBody || null;
|
|
41
|
+
this.dataOverride = options.dataOverride || null;
|
|
42
|
+
this.clientID = options.clientID || null;
|
|
43
|
+
} else {
|
|
44
|
+
// Handle positional arguments pattern
|
|
45
|
+
this.url = URLOrOptions;
|
|
46
|
+
this.path = path;
|
|
47
|
+
this.method = method;
|
|
48
|
+
this.statusCode = statusCode;
|
|
49
|
+
this.responseBody = responseBody;
|
|
50
|
+
this.requestBody = requestBody;
|
|
51
|
+
this.dataOverride = dataOverride;
|
|
52
|
+
this.clientID = null;
|
|
53
|
+
}
|
|
26
54
|
}
|
|
27
55
|
|
|
28
56
|
/**
|
|
@@ -31,11 +59,10 @@ class MockV2 {
|
|
|
31
59
|
*/
|
|
32
60
|
toDict() {
|
|
33
61
|
const result = {
|
|
34
|
-
url: this.
|
|
35
|
-
|
|
36
|
-
port: this.port,
|
|
62
|
+
url: this.url,
|
|
63
|
+
path: this.path,
|
|
37
64
|
method: this.method,
|
|
38
|
-
status_code: this.
|
|
65
|
+
status_code: this.statusCode,
|
|
39
66
|
response_body: this.responseBody
|
|
40
67
|
};
|
|
41
68
|
|
|
@@ -47,6 +74,10 @@ class MockV2 {
|
|
|
47
74
|
result.data_override = this.dataOverride;
|
|
48
75
|
}
|
|
49
76
|
|
|
77
|
+
if (this.clientID !== null) {
|
|
78
|
+
result.client_id = this.clientID;
|
|
79
|
+
}
|
|
80
|
+
|
|
50
81
|
return result;
|
|
51
82
|
}
|
|
52
83
|
|
|
@@ -59,4 +90,4 @@ class MockV2 {
|
|
|
59
90
|
}
|
|
60
91
|
}
|
|
61
92
|
|
|
62
|
-
module.exports = MockV2;
|
|
93
|
+
module.exports = MockV2;
|
|
@@ -138,6 +138,13 @@ interface GenerateRestTestOptions {
|
|
|
138
138
|
unblock?: boolean;
|
|
139
139
|
entrypoint?: string;
|
|
140
140
|
chainingKey?: string;
|
|
141
|
+
parentRequestData?: Record<string, string> | string;
|
|
142
|
+
parentStatusCode?: Record<string, string> | string;
|
|
143
|
+
requestAware?: boolean;
|
|
144
|
+
providerMode?: boolean;
|
|
145
|
+
consumerMode?: boolean;
|
|
146
|
+
providerOutput?: string;
|
|
147
|
+
consumerOutput?: string;
|
|
141
148
|
}
|
|
142
149
|
|
|
143
150
|
interface GenerateRestMockOptions {
|
|
@@ -157,6 +164,7 @@ interface GenerateRestMockOptions {
|
|
|
157
164
|
responseStatusCode?: string;
|
|
158
165
|
force?: boolean;
|
|
159
166
|
deployDashboard?: boolean;
|
|
167
|
+
requestAware?: boolean;
|
|
160
168
|
formParams?: string;
|
|
161
169
|
pathParams?: string;
|
|
162
170
|
queryParams?: string;
|
|
@@ -174,11 +182,6 @@ interface SendScenarioOptions {
|
|
|
174
182
|
skipCertVerification?: boolean;
|
|
175
183
|
}
|
|
176
184
|
|
|
177
|
-
interface InitAgentOptions {
|
|
178
|
-
version: string;
|
|
179
|
-
entryPoint?: string;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
185
|
export declare class SkyrampClient {
|
|
183
186
|
constructor(
|
|
184
187
|
kubeconfigPath?: string,
|
|
@@ -250,6 +253,7 @@ export declare class SkyrampClient {
|
|
|
250
253
|
mockYamlContent: string
|
|
251
254
|
): Promise<void>;
|
|
252
255
|
applyMock(mock: MockV2 | MockV2[]): Promise<void>;
|
|
256
|
+
removeAllMocks(): Promise<void>;
|
|
253
257
|
testerStart(
|
|
254
258
|
namespace: string,
|
|
255
259
|
kubePath: string,
|
|
@@ -314,10 +318,7 @@ export declare class SkyrampClient {
|
|
|
314
318
|
|
|
315
319
|
/**
|
|
316
320
|
* Initializes the agent by checking and pulling required Docker images (executor and worker).
|
|
317
|
-
* @param {InitAgentOptions} options - The options for initializing the agent.
|
|
318
|
-
* @param {string} options.version - The version of the agent to initialize.
|
|
319
|
-
* @param {string} [options.entryPoint='vscode'] - The entry point identifier (e.g., 'vscode').
|
|
320
321
|
* @returns {Promise<string>} A promise that resolves with the initialization output message.
|
|
321
322
|
*/
|
|
322
|
-
initAgent(
|
|
323
|
+
initAgent(): Promise<string>;
|
|
323
324
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const { promisify } = require('util');
|
|
1
2
|
const lib = require('../lib');
|
|
2
3
|
const koffi = require('koffi');
|
|
3
4
|
const TrafficConfig = require('./TrafficConfig');
|
|
@@ -46,16 +47,98 @@ const runTesterStartWrapper = lib.func('runTesterStartWrapper', testerInfoType,
|
|
|
46
47
|
const runTesterStartWrapperv1 = lib.func('runTesterStartWrapperWithGlobalHeaders', testerInfoType, ['string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'bool', 'bool', 'string', 'string', 'string']);
|
|
47
48
|
const applyMockDescriptionWrapper = lib.func('applyMockDescriptionWrapper', 'string', ['string', 'string', 'string', 'string', 'string', 'string', 'string', 'string']);
|
|
48
49
|
const applyMockObjectWrapper = lib.func('applyMockObjectWrapper', 'string', ['string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'bool']);
|
|
50
|
+
const removeMocksObjectWrapper = lib.func('removeMocksObjectWrapper', 'string', []);
|
|
49
51
|
// NPM only: for VS code extension use
|
|
50
52
|
const initTargetWrapper = lib.func('initTargetWrapper', 'string', ['string']);
|
|
51
53
|
const deployTargetWrapper = lib.func('deployTargetWrapper', 'string', ['string', 'string', 'string', 'string', 'string', 'string', 'bool']);
|
|
52
54
|
const deleteTargetWrapper = lib.func('deleteTargetWrapper', 'string', ['string', 'string', 'string', 'string', 'string']);
|
|
53
55
|
|
|
54
|
-
const generateRestTestWrapper = lib.func('generateRestTestWrapper', 'string', [
|
|
55
|
-
|
|
56
|
+
const generateRestTestWrapper = lib.func('generateRestTestWrapper', 'string', [
|
|
57
|
+
'string', // test
|
|
58
|
+
'string', // uri
|
|
59
|
+
'string', // methodX
|
|
60
|
+
'string', // language
|
|
61
|
+
'string', // framework
|
|
62
|
+
'string', // output
|
|
63
|
+
'string', // outputDir
|
|
64
|
+
'string', // runtime
|
|
65
|
+
'string', // dockerNetwork
|
|
66
|
+
'string', // dockerWorkerPort
|
|
67
|
+
'string', // k8sNamespace
|
|
68
|
+
'string', // k8sConfig
|
|
69
|
+
'string', // k8sContxt
|
|
70
|
+
'string', // authHeader
|
|
71
|
+
'string', // authType
|
|
72
|
+
'string', // requestData
|
|
73
|
+
'string', // responseData
|
|
74
|
+
'string', // responseStatusCode
|
|
75
|
+
'bool', // force
|
|
76
|
+
'bool', // deployDashboard
|
|
77
|
+
'string', // formParams
|
|
78
|
+
'string', // pathParams
|
|
79
|
+
'string', // queryParams
|
|
80
|
+
'string', // apiSchema
|
|
81
|
+
'string', // trafeFilePath
|
|
82
|
+
'string', // generateInclude
|
|
83
|
+
'string', // generateExclude
|
|
84
|
+
'string', // generateNoProxy
|
|
85
|
+
'bool', // generateInsecure
|
|
86
|
+
'string', // assertOption
|
|
87
|
+
'bool', // playwright
|
|
88
|
+
'string', // playwrightOutput
|
|
89
|
+
'string', // playwrightInput
|
|
90
|
+
'string', // playwrightViewportSize
|
|
91
|
+
'string', // playwrightStoragePath
|
|
92
|
+
'string', // playwrightSaveStoragePath
|
|
93
|
+
'string', // browser
|
|
94
|
+
'string', // device
|
|
95
|
+
'string', // loadCount
|
|
96
|
+
'string', // loadDuration
|
|
97
|
+
'string', // loadNumThreads
|
|
98
|
+
'string', // loadRampupDuration
|
|
99
|
+
'string', // loadRampupInterval
|
|
100
|
+
'string', // loadTargetRPS
|
|
101
|
+
'string', // rawTrace
|
|
102
|
+
'bool', // unblock
|
|
103
|
+
'string', // entrypoint
|
|
104
|
+
'string', // chainingKey
|
|
105
|
+
'string', // parentRequestData
|
|
106
|
+
'string', // parentStatusCode
|
|
107
|
+
'bool', // requestAware
|
|
108
|
+
'bool', // providerMode
|
|
109
|
+
'bool', // consumerMode
|
|
110
|
+
'string', // providerOutput (contract test)
|
|
111
|
+
'string', // consumerOutput (contract test)
|
|
112
|
+
'bool' // skipProvisionParents
|
|
113
|
+
]);
|
|
114
|
+
const generateRestMockWrapper = lib.func('generateRestMockWrapper', 'string', [
|
|
115
|
+
'string', // uri
|
|
116
|
+
'string', // methodX
|
|
117
|
+
'string', // language
|
|
118
|
+
'string', // framework
|
|
119
|
+
'string', // output
|
|
120
|
+
'string', // outputDir
|
|
121
|
+
'string', // runtime
|
|
122
|
+
'string', // dockerNetwork
|
|
123
|
+
'string', // dockerWorkerPort
|
|
124
|
+
'string', // k8sNamespace
|
|
125
|
+
'string', // k8sConfig
|
|
126
|
+
'string', // k8sContext
|
|
127
|
+
'string', // responseData
|
|
128
|
+
'string', // responseStatusCode
|
|
129
|
+
'bool', // force
|
|
130
|
+
'bool', // deployDashboard
|
|
131
|
+
'bool', // requestAware
|
|
132
|
+
'string', // formParams
|
|
133
|
+
'string', // pathParams
|
|
134
|
+
'string', // queryParams
|
|
135
|
+
'string', // apiSchema
|
|
136
|
+
'string', // traceFilePath
|
|
137
|
+
'string' // entryPoint
|
|
138
|
+
]);
|
|
56
139
|
const traceCollectWrapper = lib.func('traceCollectWrapper', 'string', ['string', 'string', 'bool', 'string', 'string']);
|
|
57
140
|
const analyzeOpenapiWrapper = lib.func('analyzeOpenapiWrapper', 'string', ['string', 'string']);
|
|
58
|
-
const initAgentWrapper = lib.func('initAgent', 'string', [
|
|
141
|
+
const initAgentWrapper = lib.func('initAgent', 'string', []);
|
|
59
142
|
|
|
60
143
|
// Load test scenario support
|
|
61
144
|
const sendScenarioWrapper = lib.func('sendScenarioWrapper', contractResponseType, ['string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'bool', 'bool', 'bool']);
|
|
@@ -471,6 +554,24 @@ class SkyrampClient {
|
|
|
471
554
|
});
|
|
472
555
|
}
|
|
473
556
|
|
|
557
|
+
/**
|
|
558
|
+
* Removes all mock configurations from the worker.
|
|
559
|
+
* @returns {Promise} A promise that resolves when all mocks are removed successfully
|
|
560
|
+
*/
|
|
561
|
+
async removeAllMocks() {
|
|
562
|
+
return new Promise((resolve, reject) => {
|
|
563
|
+
removeMocksObjectWrapper.async((err, res) => {
|
|
564
|
+
if (err) {
|
|
565
|
+
reject(err);
|
|
566
|
+
} else if (res) {
|
|
567
|
+
reject(new Error(res));
|
|
568
|
+
} else {
|
|
569
|
+
resolve();
|
|
570
|
+
}
|
|
571
|
+
});
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
|
|
474
575
|
async testerStart(namespace, kubePath, kubeContext, clusterName, address, scenario) {
|
|
475
576
|
const preparedScenario = scenario.prepareTestDescription();
|
|
476
577
|
const testDescription = createTestDescriptionFromScenario({ scenario: preparedScenario });
|
|
@@ -788,6 +889,13 @@ class SkyrampClient {
|
|
|
788
889
|
|
|
789
890
|
async generateRestTest(options) {
|
|
790
891
|
return new Promise((resolve, reject) => {
|
|
892
|
+
const parentRequestData = typeof options.parentRequestData === 'string'
|
|
893
|
+
? options.parentRequestData
|
|
894
|
+
: JSON.stringify(options.parentRequestData || {});
|
|
895
|
+
const parentStatusCode = typeof options.parentStatusCode === 'string'
|
|
896
|
+
? options.parentStatusCode
|
|
897
|
+
: JSON.stringify(options.parentStatusCode || {});
|
|
898
|
+
|
|
791
899
|
generateRestTestWrapper.async(
|
|
792
900
|
options.testType || "",
|
|
793
901
|
options.uri || "",
|
|
@@ -837,6 +945,14 @@ class SkyrampClient {
|
|
|
837
945
|
options.unblock || false,
|
|
838
946
|
options.entrypoint || "",
|
|
839
947
|
options.chainingKey || "",
|
|
948
|
+
parentRequestData || "",
|
|
949
|
+
parentStatusCode || "",
|
|
950
|
+
options.requestAware || false,
|
|
951
|
+
options.providerMode || true,
|
|
952
|
+
options.consumerMode || false,
|
|
953
|
+
options.providerOutput || "",
|
|
954
|
+
options.consumerOutput || "",
|
|
955
|
+
options.skipProvisionParents || true,
|
|
840
956
|
(err, res) => {
|
|
841
957
|
if (err) {
|
|
842
958
|
reject(err);
|
|
@@ -867,6 +983,7 @@ class SkyrampClient {
|
|
|
867
983
|
options.responseStatusCode || "",
|
|
868
984
|
options.force || false,
|
|
869
985
|
options.deployDashboard || false,
|
|
986
|
+
options.requestAware || false,
|
|
870
987
|
options.formParams || "",
|
|
871
988
|
options.pathParams || "",
|
|
872
989
|
options.queryParams || "",
|
|
@@ -1007,26 +1124,11 @@ class SkyrampClient {
|
|
|
1007
1124
|
|
|
1008
1125
|
/**
|
|
1009
1126
|
* Initializes the agent by checking and pulling required Docker images (executor and worker).
|
|
1010
|
-
* @param {Object} options - The options for initializing the agent.
|
|
1011
|
-
* @param {string} options.version - The version of the agent to initialize.
|
|
1012
|
-
* @param {string} [options.entryPoint='vscode'] - The entry point identifier (e.g., 'vscode').
|
|
1013
1127
|
* @returns {Promise<string>} A promise that resolves with the initialization output message.
|
|
1014
1128
|
*/
|
|
1015
|
-
async initAgent(
|
|
1129
|
+
async initAgent() {
|
|
1016
1130
|
await checkForUpdate("npm");
|
|
1017
|
-
return
|
|
1018
|
-
initAgentWrapper.async(
|
|
1019
|
-
options.version || "",
|
|
1020
|
-
options.entryPoint || "vscode",
|
|
1021
|
-
(err, res) => {
|
|
1022
|
-
if (err) {
|
|
1023
|
-
reject(err);
|
|
1024
|
-
} else {
|
|
1025
|
-
resolve(res);
|
|
1026
|
-
}
|
|
1027
|
-
}
|
|
1028
|
-
);
|
|
1029
|
-
});
|
|
1131
|
+
return promisify(initAgentWrapper.async)();
|
|
1030
1132
|
}
|
|
1031
1133
|
}
|
|
1032
1134
|
|