@usebruno/js 0.24.0 → 0.25.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usebruno/js",
3
- "version": "0.24.0",
3
+ "version": "0.25.0",
4
4
  "license": "MIT",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -21,10 +21,11 @@
21
21
  "ajv": "^8.12.0",
22
22
  "ajv-formats": "^2.1.1",
23
23
  "atob": "^2.1.2",
24
- "axios": "1.7.5",
24
+ "axios": "1.7.7",
25
25
  "btoa": "^1.2.1",
26
26
  "chai": "^4.3.7",
27
27
  "chai-string": "^1.5.0",
28
+ "cheerio": "^1.0.0",
28
29
  "crypto-js": "^4.1.1",
29
30
  "json-query": "^2.2.2",
30
31
  "lodash": "^4.17.21",
@@ -34,7 +35,8 @@
34
35
  "node-vault": "^0.10.2",
35
36
  "path": "^0.12.7",
36
37
  "quickjs-emscripten": "^0.29.2",
37
- "uuid": "^9.0.0"
38
+ "uuid": "^9.0.0",
39
+ "xml2js": "^0.6.2"
38
40
  },
39
41
  "devDependencies": {
40
42
  "@rollup/plugin-commonjs": "^23.0.2",
@@ -1,3 +1,5 @@
1
+ const { get } = require('@usebruno/query');
2
+
1
3
  class BrunoResponse {
2
4
  constructor(res) {
3
5
  this.res = res;
@@ -6,6 +8,13 @@ class BrunoResponse {
6
8
  this.headers = res ? res.headers : null;
7
9
  this.body = res ? res.data : null;
8
10
  this.responseTime = res ? res.responseTime : null;
11
+
12
+ // Make the instance callable
13
+ const callable = (...args) => get(this.body, ...args);
14
+ Object.setPrototypeOf(callable, this.constructor.prototype);
15
+ Object.assign(callable, this);
16
+
17
+ return callable;
9
18
  }
10
19
 
11
20
  getStatus() {
@@ -28,6 +28,8 @@ const fetch = require('node-fetch');
28
28
  const chai = require('chai');
29
29
  const CryptoJS = require('crypto-js');
30
30
  const NodeVault = require('node-vault');
31
+ const xml2js = require('xml2js');
32
+ const cheerio = require('cheerio');
31
33
  const { executeQuickJsVmAsync } = require('../sandbox/quickjs');
32
34
 
33
35
  class ScriptRuntime {
@@ -152,6 +154,8 @@ class ScriptRuntime {
152
154
  chai,
153
155
  'node-fetch': fetch,
154
156
  'crypto-js': CryptoJS,
157
+ 'xml2js': xml2js,
158
+ cheerio,
155
159
  ...whitelistedModules,
156
160
  fs: allowScriptFilesystemAccess ? fs : undefined,
157
161
  'node-vault': NodeVault
@@ -30,6 +30,8 @@ const axios = require('axios');
30
30
  const fetch = require('node-fetch');
31
31
  const CryptoJS = require('crypto-js');
32
32
  const NodeVault = require('node-vault');
33
+ const xml2js = require('xml2js');
34
+ const cheerio = require('cheerio');
33
35
  const { executeQuickJsVmAsync } = require('../sandbox/quickjs');
34
36
 
35
37
  const getResultsSummary = (results) => {
@@ -207,6 +209,8 @@ class TestRuntime {
207
209
  chai,
208
210
  'node-fetch': fetch,
209
211
  'crypto-js': CryptoJS,
212
+ 'xml2js': xml2js,
213
+ cheerio,
210
214
  ...whitelistedModules,
211
215
  fs: allowScriptFilesystemAccess ? fs : undefined,
212
216
  'node-vault': NodeVault
@@ -22,12 +22,6 @@ const toNumber = (value) => {
22
22
  return Number.isInteger(num) ? parseInt(value, 10) : parseFloat(value);
23
23
  };
24
24
 
25
- const removeQuotes = (str) => {
26
- if ((str.startsWith('"') && str.endsWith('"')) || (str.startsWith("'") && str.endsWith("'"))) {
27
- return str.slice(1, -1);
28
- }
29
- return str;
30
- };
31
25
 
32
26
  const executeQuickJsVm = ({ script: externalScript, context: externalContext, scriptType = 'template-literal' }) => {
33
27
  if (!externalScript?.length || typeof externalScript !== 'string') {
@@ -44,7 +38,6 @@ const executeQuickJsVm = ({ script: externalScript, context: externalContext, sc
44
38
  if (externalScript === 'null') return null;
45
39
  if (externalScript === 'undefined') return undefined;
46
40
 
47
- externalScript = removeQuotes(externalScript);
48
41
 
49
42
  const vm = QuickJSSyncContext;
50
43
 
@@ -94,7 +87,6 @@ const executeQuickJsVmAsync = async ({ script: externalScript, context: external
94
87
  if (externalScript === 'null') return null;
95
88
  if (externalScript === 'undefined') return undefined;
96
89
 
97
- externalScript = removeQuotes(externalScript);
98
90
 
99
91
  try {
100
92
  const module = await newQuickJSWASMModule();
package/src/utils.js CHANGED
@@ -86,14 +86,6 @@ const evaluateJsTemplateLiteral = (templateLiteral, context) => {
86
86
  return undefined;
87
87
  }
88
88
 
89
- if (templateLiteral.startsWith('"') && templateLiteral.endsWith('"')) {
90
- return templateLiteral.slice(1, -1);
91
- }
92
-
93
- if (templateLiteral.startsWith("'") && templateLiteral.endsWith("'")) {
94
- return templateLiteral.slice(1, -1);
95
- }
96
-
97
89
  if (!isNaN(templateLiteral)) {
98
90
  const number = Number(templateLiteral);
99
91
  // Check if the number is too high. Too high number might get altered, see #1000