@skyramp/skyramp 1.3.6 → 1.3.8
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 +1 -1
- package/src/classes/SkyrampClient.d.ts +40 -0
- package/src/classes/SkyrampClient.js +75 -14
- package/src/lib.js +2 -0
package/package.json
CHANGED
|
@@ -138,6 +138,31 @@ interface GenerateRestTestOptions {
|
|
|
138
138
|
chainingKey?: string;
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
+
interface GenerateRestMockOptions {
|
|
142
|
+
uri?: string;
|
|
143
|
+
method?: string;
|
|
144
|
+
language?: string;
|
|
145
|
+
framework?: string;
|
|
146
|
+
output?: string;
|
|
147
|
+
outputDir?: string;
|
|
148
|
+
runtime?: string;
|
|
149
|
+
dockerNetwork?: string;
|
|
150
|
+
dockerWorkerPort?: string;
|
|
151
|
+
k8sNamespace?: string;
|
|
152
|
+
k8sConfig?: string;
|
|
153
|
+
k8sContext?: string;
|
|
154
|
+
responseData?: string;
|
|
155
|
+
responseStatusCode?: string;
|
|
156
|
+
force?: boolean;
|
|
157
|
+
deployDashboard?: boolean;
|
|
158
|
+
formParams?: string;
|
|
159
|
+
pathParams?: string;
|
|
160
|
+
queryParams?: string;
|
|
161
|
+
apiSchema?: string[];
|
|
162
|
+
traceFilePath?: string;
|
|
163
|
+
entrypoint?: string;
|
|
164
|
+
}
|
|
165
|
+
|
|
141
166
|
interface SendScenarioOptions {
|
|
142
167
|
until?: string;
|
|
143
168
|
loadTestConfig?: LoadTestConfig;
|
|
@@ -147,6 +172,11 @@ interface SendScenarioOptions {
|
|
|
147
172
|
skipCertVerification?: boolean;
|
|
148
173
|
}
|
|
149
174
|
|
|
175
|
+
interface InitAgentOptions {
|
|
176
|
+
version: string;
|
|
177
|
+
entryPoint?: string;
|
|
178
|
+
}
|
|
179
|
+
|
|
150
180
|
export declare class SkyrampClient {
|
|
151
181
|
constructor(
|
|
152
182
|
kubeconfigPath?: string,
|
|
@@ -259,6 +289,7 @@ export declare class SkyrampClient {
|
|
|
259
289
|
deployDashboard(network: string): Promise<void>;
|
|
260
290
|
|
|
261
291
|
generateRestTest(options: GenerateRestTestOptions): Promise<string>;
|
|
292
|
+
generateRestMock(options: GenerateRestMockOptions): Promise<string>;
|
|
262
293
|
traceCollect(options: TraceCollectOptions): Promise<string>;
|
|
263
294
|
analyzeOpenapi(options: AnalyzeOpenAPIOptions): Promise<string>;
|
|
264
295
|
|
|
@@ -278,4 +309,13 @@ export declare class SkyrampClient {
|
|
|
278
309
|
fetchLatestOtp(
|
|
279
310
|
email: string
|
|
280
311
|
): string;
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Initializes the agent by checking and pulling required Docker images (executor and worker).
|
|
315
|
+
* @param {InitAgentOptions} options - The options for initializing the agent.
|
|
316
|
+
* @param {string} options.version - The version of the agent to initialize.
|
|
317
|
+
* @param {string} [options.entryPoint='vscode'] - The entry point identifier (e.g., 'vscode').
|
|
318
|
+
* @returns {Promise<string>} A promise that resolves with the initialization output message.
|
|
319
|
+
*/
|
|
320
|
+
initAgent(options: InitAgentOptions): Promise<string>;
|
|
281
321
|
}
|
|
@@ -58,8 +58,10 @@ const deleteTargetWrapper = lib.func('deleteTargetWrapper', 'string', ['string',
|
|
|
58
58
|
const runTesterGenerateRestWrapper = lib.func('runTesterGenerateRestWrapper', testerGenerateType, ['string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'int', 'bool', 'bool', 'bool']);
|
|
59
59
|
|
|
60
60
|
const generateRestTestWrapper = lib.func('generateRestTestWrapper', 'string', ['string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'bool', 'bool', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'bool', 'string', 'bool', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'bool', 'string', 'string']);
|
|
61
|
+
const generateRestMockWrapper = lib.func('generateRestMockWrapper', 'string', ['string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'bool', 'bool', 'string', 'string', 'string', 'string', 'string', 'string']);
|
|
61
62
|
const traceCollectWrapper = lib.func('traceCollectWrapper', 'string', ['string', 'string', 'bool', 'string', 'string']);
|
|
62
63
|
const analyzeOpenapiWrapper = lib.func('analyzeOpenapiWrapper', 'string', ['string', 'string']);
|
|
64
|
+
const initAgentWrapper = lib.func('initAgent', 'string', ['string', 'string']);
|
|
63
65
|
|
|
64
66
|
// Load test scenario support
|
|
65
67
|
const sendScenarioWrapper = lib.func('sendScenarioWrapper', contractResponseType, ['string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'string', 'bool', 'bool', 'bool']);
|
|
@@ -446,13 +448,13 @@ class SkyrampClient {
|
|
|
446
448
|
if (!Array.isArray(mock)) {
|
|
447
449
|
mock = [mock];
|
|
448
450
|
}
|
|
449
|
-
|
|
451
|
+
|
|
450
452
|
// Convert MockV2 objects to dictionary format
|
|
451
453
|
const mockList = mock.map(m => m.toDict());
|
|
452
|
-
|
|
454
|
+
|
|
453
455
|
// Convert to JSON string
|
|
454
456
|
const mockJson = JSON.stringify(mockList);
|
|
455
|
-
|
|
457
|
+
|
|
456
458
|
return new Promise((resolve, reject) => {
|
|
457
459
|
applyMockObjectWrapper.async(
|
|
458
460
|
this.address || '',
|
|
@@ -887,6 +889,42 @@ class SkyrampClient {
|
|
|
887
889
|
});
|
|
888
890
|
}
|
|
889
891
|
|
|
892
|
+
async generateRestMock(options) {
|
|
893
|
+
return new Promise((resolve, reject) => {
|
|
894
|
+
generateRestMockWrapper.async(
|
|
895
|
+
options.uri || "",
|
|
896
|
+
options.method || "",
|
|
897
|
+
options.language || "",
|
|
898
|
+
options.framework || "",
|
|
899
|
+
options.output || "",
|
|
900
|
+
options.outputDir || "",
|
|
901
|
+
options.runtime || "",
|
|
902
|
+
options.dockerNetwork || "",
|
|
903
|
+
options.dockerWorkerPort || "0",
|
|
904
|
+
options.k8sNamespace || "",
|
|
905
|
+
options.k8sConfig || "",
|
|
906
|
+
options.k8sContext || "",
|
|
907
|
+
options.responseData || "",
|
|
908
|
+
options.responseStatusCode || "",
|
|
909
|
+
options.force || false,
|
|
910
|
+
options.deployDashboard || false,
|
|
911
|
+
options.formParams || "",
|
|
912
|
+
options.pathParams || "",
|
|
913
|
+
options.queryParams || "",
|
|
914
|
+
JSON.stringify(options.apiSchema || []),
|
|
915
|
+
options.traceFilePath || "",
|
|
916
|
+
options.entrypoint || "",
|
|
917
|
+
(err, res) => {
|
|
918
|
+
if (err) {
|
|
919
|
+
reject(err);
|
|
920
|
+
} else {
|
|
921
|
+
resolve(res);
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
);
|
|
925
|
+
});
|
|
926
|
+
}
|
|
927
|
+
|
|
890
928
|
/**
|
|
891
929
|
* Sends a scenario for load testing using the V2 API
|
|
892
930
|
* @param {Object|Array} scenario - The scenario object or array of scenarios to run
|
|
@@ -909,10 +947,10 @@ class SkyrampClient {
|
|
|
909
947
|
skipCertVerification = false
|
|
910
948
|
} = options;
|
|
911
949
|
|
|
912
|
-
if (debug) { /* add to api for future use */}
|
|
950
|
+
if (debug) { /* add to api for future use */ }
|
|
913
951
|
let configJson = "";
|
|
914
952
|
if (loadTestConfig) {
|
|
915
|
-
|
|
953
|
+
configJson = loadTestConfig.toJson();
|
|
916
954
|
}
|
|
917
955
|
|
|
918
956
|
// Ensure scenario is an array
|
|
@@ -923,13 +961,13 @@ class SkyrampClient {
|
|
|
923
961
|
// If scenario has toJson method, use it for proper formatting
|
|
924
962
|
if (typeof _scenario.toJson === 'function') {
|
|
925
963
|
const scenarioJson = _scenario.toJson();
|
|
926
|
-
|
|
964
|
+
|
|
927
965
|
return {
|
|
928
966
|
...scenarioJson,
|
|
929
967
|
until: until || scenarioJson.until
|
|
930
968
|
};
|
|
931
969
|
}
|
|
932
|
-
|
|
970
|
+
|
|
933
971
|
// Fallback for scenarios without toJson method
|
|
934
972
|
return {
|
|
935
973
|
name: _scenario.name,
|
|
@@ -982,22 +1020,22 @@ class SkyrampClient {
|
|
|
982
1020
|
let timestamp = this.timestamp;
|
|
983
1021
|
|
|
984
1022
|
if (!email.includes("@otp.skyramp.dev")) {
|
|
985
|
-
|
|
1023
|
+
throw new Error("non-Skyramp email is not supported")
|
|
986
1024
|
}
|
|
987
1025
|
|
|
988
1026
|
const username = email.replace("@otp.skyramp.dev", "")
|
|
989
1027
|
|
|
990
|
-
for (let i = 0; i < 10; i
|
|
1028
|
+
for (let i = 0; i < 10; i++) {
|
|
991
1029
|
// Execute Request
|
|
992
1030
|
latestGetResponse = await this.sendRequest({
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
1031
|
+
url: "https://tokenize.skyramp.dev",
|
|
1032
|
+
path: `/msg/${username}/latest`,
|
|
1033
|
+
method: "GET"
|
|
996
1034
|
});
|
|
997
1035
|
|
|
998
1036
|
if (latestGetResponse.statusCode != 200) {
|
|
999
|
-
|
|
1000
|
-
|
|
1037
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
1038
|
+
continue
|
|
1001
1039
|
}
|
|
1002
1040
|
|
|
1003
1041
|
let codeTime = new Date(utils.getResponseValue(latestGetResponse, "timestamp"));
|
|
@@ -1007,6 +1045,29 @@ class SkyrampClient {
|
|
|
1007
1045
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
1008
1046
|
}
|
|
1009
1047
|
}
|
|
1048
|
+
|
|
1049
|
+
/**
|
|
1050
|
+
* Initializes the agent by checking and pulling required Docker images (executor and worker).
|
|
1051
|
+
* @param {Object} options - The options for initializing the agent.
|
|
1052
|
+
* @param {string} options.version - The version of the agent to initialize.
|
|
1053
|
+
* @param {string} [options.entryPoint='vscode'] - The entry point identifier (e.g., 'vscode').
|
|
1054
|
+
* @returns {Promise<string>} A promise that resolves with the initialization output message.
|
|
1055
|
+
*/
|
|
1056
|
+
async initAgent(options) {
|
|
1057
|
+
return new Promise((resolve, reject) => {
|
|
1058
|
+
initAgentWrapper.async(
|
|
1059
|
+
options.version || "",
|
|
1060
|
+
options.entryPoint || "vscode",
|
|
1061
|
+
(err, res) => {
|
|
1062
|
+
if (err) {
|
|
1063
|
+
reject(err);
|
|
1064
|
+
} else {
|
|
1065
|
+
resolve(res);
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
);
|
|
1069
|
+
});
|
|
1070
|
+
}
|
|
1010
1071
|
}
|
|
1011
1072
|
|
|
1012
1073
|
module.exports = SkyrampClient;
|
package/src/lib.js
CHANGED