@skyramp/skyramp 2025.8.11 → 2025.12.19
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 +3 -2
- package/scripts/download-binary.js +0 -5
- package/src/classes/MockV2.d.ts +93 -0
- package/src/classes/MockV2.js +62 -0
- package/src/classes/ResponseV2.d.ts +2 -1
- package/src/classes/ResponseV2.js +5 -1
- package/src/classes/SkyrampClient.d.ts +123 -36
- package/src/classes/SkyrampClient.js +93 -4
- package/src/classes/SmartPlaywright.d.ts +5 -0
- package/src/classes/SmartPlaywright.js +992 -0
- package/src/function.d.ts +20 -0
- package/src/index.d.ts +21 -19
- package/src/index.js +7 -1
- package/src/utils.d.ts +82 -0
- package/src/utils.js +27 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ResponseV2 } from "./classes/ResponseV2";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Checks if the response's status code matches the expected status code (with support for wildcards).
|
|
5
|
+
*
|
|
6
|
+
* The expected status can include 'x' as a wildcard for a single digit.
|
|
7
|
+
* Examples:
|
|
8
|
+
* - "200" matches exactly 200
|
|
9
|
+
* - "20x" matches any status code in the range 200 to 209
|
|
10
|
+
* - "2xx" matches any status code in the range 200 to 299
|
|
11
|
+
*
|
|
12
|
+
* @param response - The response object containing a `status_code` attribute.
|
|
13
|
+
* @param expectedStatus - The expected status code as a string with optional 'x' wildcards.
|
|
14
|
+
* @returns True if the status code matches, false otherwise.
|
|
15
|
+
* @throws Error if the response object lacks a 'status_code' attribute.
|
|
16
|
+
*/
|
|
17
|
+
export function checkStatusCode(
|
|
18
|
+
response: ResponseV2,
|
|
19
|
+
expectedStatus: string
|
|
20
|
+
): boolean;
|
package/src/index.d.ts
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
11
|
-
export * from
|
|
12
|
-
export * from
|
|
13
|
-
export * from
|
|
14
|
-
export * from
|
|
15
|
-
export * from
|
|
16
|
-
export * from
|
|
17
|
-
export * from
|
|
18
|
-
export * from
|
|
19
|
-
export * from
|
|
1
|
+
export * from "./classes/Endpoint";
|
|
2
|
+
export * from "./classes/GrpcEndpoint";
|
|
3
|
+
export * from "./classes/RestEndpoint";
|
|
4
|
+
export * from "./classes/Scenario";
|
|
5
|
+
export * from "./classes/SkyrampClient";
|
|
6
|
+
export * from "./classes/RequestValue";
|
|
7
|
+
export * from "./classes/ResponseValue";
|
|
8
|
+
export * from "./classes/RestParam";
|
|
9
|
+
export * from "./classes/MultipartParam";
|
|
10
|
+
export * from "./classes/TrafficConfig";
|
|
11
|
+
export * from "./classes/DelayConfig";
|
|
12
|
+
export * from "./classes/Protocol";
|
|
13
|
+
export * from "./classes/RequestV2";
|
|
14
|
+
export * from "./classes/ResponseV2";
|
|
15
|
+
export * from "./classes/MockV2";
|
|
16
|
+
export * from "./classes/AsyncScenario";
|
|
17
|
+
export * from "./classes/LoadTestConfig";
|
|
18
|
+
export * from "./classes/AsyncTestStatus";
|
|
19
|
+
export * from "./utils";
|
|
20
|
+
export * from "./function";
|
|
21
|
+
export * from "./classes/SmartPlaywright";
|
package/src/index.js
CHANGED
|
@@ -16,13 +16,16 @@ const ResponseV2 = require('./classes/ResponseV2');
|
|
|
16
16
|
const { AsyncScenario, AsyncRequest } = require('./classes/AsyncScenario');
|
|
17
17
|
const { LoadTestConfig } = require('./classes/LoadTestConfig');
|
|
18
18
|
const AsyncTestStatus = require('./classes/AsyncTestStatus');
|
|
19
|
-
const
|
|
19
|
+
const MockV2 = require('./classes/MockV2');
|
|
20
|
+
const { getValue, checkSchema, iterate, pushToolEvent } = require('./utils');
|
|
20
21
|
const { checkStatusCode } = require('./function');
|
|
22
|
+
const { newSkyrampPlaywrightPage, expect } = require('./classes/SmartPlaywright');
|
|
21
23
|
|
|
22
24
|
module.exports = {
|
|
23
25
|
SkyrampClient,
|
|
24
26
|
RequestV2,
|
|
25
27
|
ResponseV2,
|
|
28
|
+
MockV2,
|
|
26
29
|
GrpcEndpoint,
|
|
27
30
|
RestEndpoint,
|
|
28
31
|
Scenario,
|
|
@@ -43,4 +46,7 @@ module.exports = {
|
|
|
43
46
|
checkStatusCode,
|
|
44
47
|
checkSchema,
|
|
45
48
|
iterate,
|
|
49
|
+
pushToolEvent,
|
|
50
|
+
newSkyrampPlaywrightPage,
|
|
51
|
+
expect,
|
|
46
52
|
}
|
package/src/utils.d.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the given value is a JSON string.
|
|
3
|
+
* @param value - The value to check
|
|
4
|
+
* @returns True if the value is a JSON string, false otherwise
|
|
5
|
+
*/
|
|
6
|
+
export function isJSONString(value: string): boolean;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Safely converts a value to a JSON string.
|
|
10
|
+
* @param value - The value to stringify
|
|
11
|
+
* @returns The JSON string representation
|
|
12
|
+
*/
|
|
13
|
+
export function safeStringify(value: string): string;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Creates a test description from a scenario.
|
|
17
|
+
* @param scenario - The scenario object
|
|
18
|
+
* @returns The test description
|
|
19
|
+
*/
|
|
20
|
+
export function createTestDescriptionFromScenario(scenario: object): object;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Gets YAML bytes from a configuration.
|
|
24
|
+
* @param config - The configuration object
|
|
25
|
+
* @returns The YAML bytes
|
|
26
|
+
*/
|
|
27
|
+
export function getYamlBytes(config: object): string;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Reads data from a file.
|
|
31
|
+
* @param filePath - The path to the file
|
|
32
|
+
* @returns The file data
|
|
33
|
+
*/
|
|
34
|
+
export function readDataFromFile(
|
|
35
|
+
filename: string
|
|
36
|
+
): [string, false] | [string, true];
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Extracts a value from JSON using JSONPath syntax.
|
|
40
|
+
* @param jsonInput - The JSON object or string to extract from
|
|
41
|
+
* @param path - The JSONPath expression (e.g., "$.value", "$.data[0].name")
|
|
42
|
+
* @returns The extracted value or null if not found
|
|
43
|
+
*/
|
|
44
|
+
export function getValue(
|
|
45
|
+
jsonInput: object,
|
|
46
|
+
path: string
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
48
|
+
): any;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Validates JSON against a schema.
|
|
52
|
+
* @param jsonInput - The JSON to validate
|
|
53
|
+
* @param schema - The schema to validate against
|
|
54
|
+
* @returns The validation result
|
|
55
|
+
*/
|
|
56
|
+
export function checkSchema(jsonInput: object, schema: object): boolean;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Iterates over JSON data structure.
|
|
60
|
+
* @param jsonInput - The JSON data to iterate
|
|
61
|
+
* @returns The iteration result
|
|
62
|
+
*/
|
|
63
|
+
export function iterate(jsonInput: object): object;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Send telemetry of tool event
|
|
67
|
+
* @param {string} entryPoint - entrypoint of event, either MCP or vscode
|
|
68
|
+
* @param {string} toolName - name of the tool
|
|
69
|
+
* @param {string} error - error message if it failed
|
|
70
|
+
* @param {Object} params - any parameters associated with the tool call. Disctionary
|
|
71
|
+
*/
|
|
72
|
+
export function pushToolEvent(entryPoint: string, toolName: string, err: string, params: object): void;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* check for update
|
|
76
|
+
*/
|
|
77
|
+
export function checkForUpdate(component: string): void;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The Skyramp YAML version constant.
|
|
81
|
+
*/
|
|
82
|
+
export const SKYRAMP_YAML_VERSION: string;
|
package/src/utils.js
CHANGED
|
@@ -13,6 +13,8 @@ const responseType = koffi.struct({
|
|
|
13
13
|
const getJSONValueWrapper = lib.func('getJSONValueWrapper', responseType, ['string', 'string']);
|
|
14
14
|
const checkSchemaWrapper = lib.func('checkSchemaWrapper', responseType, ['string', 'string']);
|
|
15
15
|
const iterateWrapper = lib.func('generateJsonTreePathsFromBlob', 'string', ['string']);
|
|
16
|
+
const pushToolEventWrapper = lib.func('pushToolEvent', 'void', ['string', 'string', 'string', 'string']);
|
|
17
|
+
const checkForUpdateWrapper = lib.func('checkForUpdateWrapper', 'void', ['string']);
|
|
16
18
|
|
|
17
19
|
function isJSONString(value) {
|
|
18
20
|
if (typeof value !== "string") {
|
|
@@ -196,6 +198,29 @@ function iterate(fuzz_body) {
|
|
|
196
198
|
return parsed
|
|
197
199
|
}
|
|
198
200
|
|
|
201
|
+
/**
|
|
202
|
+
* Send telemetry of tool event
|
|
203
|
+
*
|
|
204
|
+
* @param {string} entryPoint - entrypoint of event, either MCP or vscode
|
|
205
|
+
* @param {string} toolName - name of the tool
|
|
206
|
+
* @param {string} error - error message if it failed
|
|
207
|
+
* @param {Object} params - any parameters associated with the tool call. Disctionary
|
|
208
|
+
*/
|
|
209
|
+
function pushToolEvent(entryPoint, toolName, err, params) {
|
|
210
|
+
const paramsStr = JSON.stringify(params);
|
|
211
|
+
|
|
212
|
+
pushToolEventWrapper(entryPoint, toolName, err, paramsStr);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* check if new library is available
|
|
217
|
+
*
|
|
218
|
+
* @param {string} component - NAme of component
|
|
219
|
+
*/
|
|
220
|
+
function checkForUpdate(component) {
|
|
221
|
+
checkForUpdateWrapper(component)
|
|
222
|
+
}
|
|
223
|
+
|
|
199
224
|
module.exports = {
|
|
200
225
|
createTestDescriptionFromScenario,
|
|
201
226
|
getYamlBytes,
|
|
@@ -203,5 +228,7 @@ module.exports = {
|
|
|
203
228
|
getValue,
|
|
204
229
|
checkSchema,
|
|
205
230
|
iterate,
|
|
231
|
+
pushToolEvent,
|
|
232
|
+
checkForUpdate,
|
|
206
233
|
SKYRAMP_YAML_VERSION
|
|
207
234
|
}
|