postman-runtime 7.53.0 → 7.54.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.
@@ -24,6 +24,7 @@ var _ = require('lodash'),
24
24
  EXECUTION_SKIP_REQUEST_EVENT_BASE = 'execution.skipRequest.',
25
25
 
26
26
  EXECUTION_VAULT_BASE = 'execution.vault.',
27
+ EXECUTION_DATASETS_BASE = 'execution.datasets.',
27
28
 
28
29
  COOKIES_EVENT_STORE_ACTION = 'store',
29
30
  COOKIE_STORE_PUT_METHOD = 'putCookie',
@@ -487,6 +488,40 @@ module.exports = {
487
488
  dispatch(null, vaultSecrets[cmd](...args));
488
489
  }.bind(this));
489
490
 
491
+ this.host.on(EXECUTION_DATASETS_BASE + executionId, function (id, cmd, datasetId, ...args) {
492
+ const datasetsResolver = _.get(this, 'options.script.datasetsResolver'),
493
+
494
+ // Ensure error is string
495
+ // TODO identify why error objects are not being serialized correctly
496
+ dispatch = (e, r) => {
497
+ this.host.dispatch(EXECUTION_DATASETS_BASE + executionId, id, e, r);
498
+ };
499
+
500
+ if (!datasetsResolver) {
501
+ return dispatch('Datasets API is not available');
502
+ }
503
+
504
+ if (!['executeView', 'executeQuery'].includes(cmd)) {
505
+ return dispatch(`Invalid datasets command: ${cmd}`);
506
+ }
507
+
508
+ try {
509
+ datasetsResolver(cmd, datasetId, args, function (err, result) {
510
+ if (err) {
511
+ return dispatch(err instanceof Error ? err.message :
512
+ (typeof err === 'string' ? err : String(err && err.message || err)));
513
+ }
514
+
515
+ dispatch(null, result);
516
+ });
517
+ }
518
+ catch (error) {
519
+ const detail = error && error.message ? `: ${error.message}` : '';
520
+
521
+ dispatch(`Datasets: error executing "${cmd}"${detail}`);
522
+ }
523
+ }.bind(this));
524
+
490
525
  this.host.on(EXECUTION_REQUEST_EVENT_BASE + executionId,
491
526
  function (scriptCursor, id, requestId, request) {
492
527
  // remove files in request body if any
@@ -570,8 +605,12 @@ module.exports = {
570
605
  context: contextToUse,
571
606
  resolvedPackages: resolvedPackages,
572
607
 
573
- disabledAPIs: !_.get(this, 'options.script.requestResolver') ?
574
- ['execution.runRequest'] : [],
608
+ disabledAPIs: [
609
+ ...(!_.get(this, 'options.script.requestResolver') ?
610
+ ['execution.runRequest'] : []),
611
+ ...(!_.get(this, 'options.script.datasetsResolver') ?
612
+ ['datasets'] : [])
613
+ ],
575
614
 
576
615
  // legacy options
577
616
  legacy: {
@@ -589,6 +628,7 @@ module.exports = {
589
628
  this.host.removeAllListeners(EXECUTION_ERROR_EVENT_BASE + executionId);
590
629
  this.host.removeAllListeners(EXECUTION_SKIP_REQUEST_EVENT_BASE + executionId);
591
630
  this.host.removeAllListeners(EXECUTION_VAULT_BASE + executionId);
631
+ this.host.removeAllListeners(EXECUTION_DATASETS_BASE + executionId);
592
632
 
593
633
  // Handle async errors as well.
594
634
  // If there was an error running the script itself, that takes precedence
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postman-runtime",
3
- "version": "7.53.0",
3
+ "version": "7.54.0",
4
4
  "description": "Underlying library of executing Postman Collections",
5
5
  "author": "Postman Inc.",
6
6
  "license": "Apache-2.0",
@@ -56,7 +56,7 @@
56
56
  "performance-now": "2.1.0",
57
57
  "postman-collection": "5.3.0",
58
58
  "postman-request": "2.88.1-postman.48",
59
- "postman-sandbox": "6.6.1",
59
+ "postman-sandbox": "6.7.0",
60
60
  "postman-url-encoder": "3.0.8",
61
61
  "serialised-error": "1.1.3",
62
62
  "strip-json-comments": "3.1.1",