@skyramp/skyramp 1.2.38 → 1.2.40

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyramp/skyramp",
3
- "version": "1.2.38",
3
+ "version": "1.2.40",
4
4
  "description": "module for leveraging skyramp cli functionality",
5
5
  "scripts": {
6
6
  "lint": "eslint 'src/**/*.js' 'src/**/*.ts' --fix",
@@ -33,8 +33,8 @@ const CONTAINER_PORT = 35142;
33
33
  const loginWrapper = lib.func('loginWrapper', 'string', []);
34
34
  const logoutWrapper = lib.func('logoutWrapper', 'string', []);
35
35
 
36
+ const { createTestDescriptionFromScenario, getYamlBytes, readDataFromFile, checkForUpdate, SKYRAMP_YAML_VERSION } = require('../utils');
36
37
  // k8s related
37
- const { createTestDescriptionFromScenario, getYamlBytes, readDataFromFile, SKYRAMP_YAML_VERSION } = require('../utils');
38
38
  const applyLocalWrapper = lib.func('applyLocalWrapper', 'string', []);
39
39
  const addKubeconfigWrapper = lib.func('addKubeconfigWrapper', 'string', ['string', 'string', 'string']);
40
40
  const deleteSkyrampWorkerWrapper = lib.func('deleteSkyrampWorkerWrapper', 'string', ['string', 'string', 'string', 'string'])
@@ -101,6 +101,9 @@ class SkyrampClient {
101
101
  constructor(kubeconfigPathOrOptions, clusterName, context, userToken, directory = process.cwd()) {
102
102
  this.local_image = false;
103
103
  this.timestamp = Date.now();
104
+
105
+ checkForUpdate("npm")
106
+
104
107
  if (typeof kubeconfigPathOrOptions === 'object') {
105
108
  const options = kubeconfigPathOrOptions;
106
109
  this.workerNamespaces = [];
@@ -9,6 +9,7 @@ const responseType = koffi.struct({
9
9
  error: 'char*',
10
10
  });
11
11
 
12
+ const { checkForUpdate } = require('../utils');
12
13
  const improvePlaywrightSelectorWrapper = lib.func('improvePlywrightSelectorWrapper', responseType, ['string']);
13
14
  const hasJavascriptWrapper = lib.func('hasJavascript', 'bool', ['string']);
14
15
 
@@ -271,6 +272,13 @@ class SkyrampPlaywrightLocator {
271
272
  newMsg += this.generateLLMErrors();
272
273
  }
273
274
 
275
+ // Ensure error is an Error object, not a string
276
+ if (typeof error === 'string') {
277
+ error = new Error(error);
278
+ } else if (!(error instanceof Error)) {
279
+ error = new Error(String(error));
280
+ }
281
+
274
282
  error.message = error.message + "\n" + newMsg
275
283
 
276
284
  return error
@@ -278,7 +286,7 @@ class SkyrampPlaywrightLocator {
278
286
 
279
287
  hydrationErrorMsg = "Potentially a hydration issue. Please add enough waitForTimeout()"
280
288
 
281
- newPrevHyrdationErrorMsg() {
289
+ newPrevHydrationErrorMsg() {
282
290
  return `Cannot find locator ${this._locator} and likely a hydration issue on ${this._previousLocator._locator}.\n` +
283
291
  `Please add enough waitForTimeout() on ${this._previoousLocator._locator}`;
284
292
  }
@@ -658,6 +666,8 @@ class SkyrampPlaywrightLocator {
658
666
 
659
667
  class SkyrampPlaywrightPage {
660
668
  constructor(page, testInfo) {
669
+ checkForUpdate("npm")
670
+
661
671
  this._page = page;
662
672
  this._testInfo = testInfo; // Store testInfo for screenshot auto-baseline
663
673
  return new Proxy(this, {
package/src/index.js CHANGED
@@ -17,7 +17,7 @@ const { AsyncScenario, AsyncRequest } = require('./classes/AsyncScenario');
17
17
  const { LoadTestConfig } = require('./classes/LoadTestConfig');
18
18
  const AsyncTestStatus = require('./classes/AsyncTestStatus');
19
19
  const MockV2 = require('./classes/MockV2');
20
- const { getValue, checkSchema, iterate } = require('./utils');
20
+ const { getValue, checkSchema, iterate, pushToolEvent } = require('./utils');
21
21
  const { checkStatusCode } = require('./function');
22
22
  const { newSkyrampPlaywrightPage, expect } = require('./classes/SmartPlaywright');
23
23
 
@@ -46,6 +46,7 @@ module.exports = {
46
46
  checkStatusCode,
47
47
  checkSchema,
48
48
  iterate,
49
+ pushToolEvent,
49
50
  newSkyrampPlaywrightPage,
50
51
  expect,
51
52
  }
package/src/utils.d.ts CHANGED
@@ -62,6 +62,20 @@ export function checkSchema(jsonInput: object, schema: object): boolean;
62
62
  */
63
63
  export function iterate(jsonInput: object): object;
64
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
+
65
79
  /**
66
80
  * The Skyramp YAML version constant.
67
81
  */
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
  }