Skip to content

Commit

Permalink
Added seperate class for CollectionVariableScope
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-sharma-08 committed Sep 29, 2023
1 parent 4f9f722 commit 3ae5b34
Show file tree
Hide file tree
Showing 7 changed files with 136 additions and 20 deletions.
2 changes: 1 addition & 1 deletion lib/sandbox/pmapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function Postman (execution, onRequest, onAssertion, cookieStore, options = {})
environment: execution.environment,

/**
* @type {VariableScope}
* @type {CollectionVariableScope}
*/
collectionVariables: execution.collectionVariables,

Expand Down
2 changes: 1 addition & 1 deletion npm/build-sandbox-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ module.exports = function (exit) {

// Since we are referencing some types from Postman Collection lib, those types needs to imported.
// See https://stackoverflow.com/a/51114250
collectionSDKTypes = ['CookieList', 'Request', 'Response', 'VariableScope'];
collectionSDKTypes = ['CookieList', 'Request', 'Response', 'VariableScope', 'CollectionVariableScope'];

node.forEachChild((child) => {
child.members && child.members.forEach((c) => {
Expand Down
68 changes: 61 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "postman-sandbox-secret-variable-type-only",
"version": "1.0.1",
"version": "1.0.2",
"description": "Sandbox for Postman Scripts to run in Node.js or browser",
"author": "Postman Inc.",
"license": "Apache-2.0",
Expand Down Expand Up @@ -43,7 +43,7 @@
},
"dependencies": {
"lodash": "4.17.21",
"postman-collection": "npm:postman-collection-secret-variable-type-only@1.0.1",
"postman-collection": "npm:postman-collection-secret-variable-type-only@1.0.2",
"teleport-javascript": "1.0.0",
"uvm": "2.1.1"
},
Expand Down
2 changes: 1 addition & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ declare class Postman {
info: Info;
globals: VariableScope;
environment: VariableScope;
collectionVariables: VariableScope;
collectionVariables: CollectionVariableScope;
variables: VariableScope;
/**
* The iterationData object contains data from the data file provided during a collection run.
Expand Down
39 changes: 35 additions & 4 deletions types/sandbox/prerequest.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Type definitions for postman-sandbox 3.5.7
// Type definitions for postman-sandbox 1.0.2
// Project: https://github.com/postmanlabs/postman-sandbox
// Definitions by: PostmanLabs
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
Expand All @@ -14,8 +14,18 @@ declare interface PostmanLegacy {
setNextRequest(requestName: string): void;
}

/**
* @param execution - -
* @param onRequest - -
* @param onAssertion - -
* @param cookieStore - -
* @param [options] - -
* @param [options.disabledAPIs] - -
*/
declare class Postman {
constructor(bridge: EventEmitter, execution: Execution, onRequest: (...params: any[]) => any, cookieStore: any);
constructor(execution: Execution, onRequest: (...params: any[]) => any, onAssertion: (...params: any[]) => any, cookieStore: any, options?: {
disabledAPIs?: string[];
});
/**
* The pm.info object contains information pertaining to the script being executed.
* Useful information such as the request name, request Id, and iteration count are
Expand All @@ -24,7 +34,7 @@ declare class Postman {
info: Info;
globals: import("postman-collection").VariableScope;
environment: import("postman-collection").VariableScope;
collectionVariables: import("postman-collection").VariableScope;
collectionVariables: import("postman-collection").CollectionVariableScope;
variables: import("postman-collection").VariableScope;
/**
* The iterationData object contains data from the data file provided during a collection run.
Expand All @@ -44,6 +54,8 @@ declare class Postman {
visualizer: Visualizer;
/**
* Allows one to send request from script asynchronously.
* @param req - -
* @param callback - -
*/
sendRequest(req: import("postman-collection").Request | string, callback: (...params: any[]) => any): void;
expect: Chai.ExpectStatic;
Expand Down Expand Up @@ -96,25 +108,44 @@ declare interface Visualizer {
*/
declare var pm: Postman;

declare interface PostmanCookieJar {
/**
* @param cookieStore - -
*/
declare class PostmanCookieJar {
constructor(cookieStore: any);
/**
* Get the cookie value with the given name.
* @param url - -
* @param name - -
* @param callback - -
*/
get(url: string, name: string, callback: (...params: any[]) => any): void;
/**
* Get all the cookies for the given URL.
* @param url - -
* @param [options] - -
* @param callback - -
*/
getAll(url: string, options?: any, callback: (...params: any[]) => any): void;
/**
* Set or update a cookie.
* @param url - -
* @param name - -
* @param [value] - -
* @param [callback] - -
*/
set(url: string, name: string | any, value?: string | ((...params: any[]) => any), callback?: (...params: any[]) => any): void;
/**
* Remove single cookie with the given name.
* @param url - -
* @param name - -
* @param [callback] - -
*/
unset(url: string, name: string, callback?: (...params: any[]) => any): void;
/**
* Remove all the cookies for the given URL.
* @param url - -
* @param [callback] - -
*/
clear(url: string, callback?: (...params: any[]) => any): void;
}
Expand Down
39 changes: 35 additions & 4 deletions types/sandbox/test.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Type definitions for postman-sandbox 3.5.7
// Type definitions for postman-sandbox 1.0.2
// Project: https://github.com/postmanlabs/postman-sandbox
// Definitions by: PostmanLabs
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
Expand All @@ -14,8 +14,18 @@ declare interface PostmanLegacy {
setNextRequest(requestName: string): void;
}

/**
* @param execution - -
* @param onRequest - -
* @param onAssertion - -
* @param cookieStore - -
* @param [options] - -
* @param [options.disabledAPIs] - -
*/
declare class Postman {
constructor(bridge: EventEmitter, execution: Execution, onRequest: (...params: any[]) => any, cookieStore: any);
constructor(execution: Execution, onRequest: (...params: any[]) => any, onAssertion: (...params: any[]) => any, cookieStore: any, options?: {
disabledAPIs?: string[];
});
/**
* The pm.info object contains information pertaining to the script being executed.
* Useful information such as the request name, request Id, and iteration count are
Expand All @@ -24,7 +34,7 @@ declare class Postman {
info: Info;
globals: import("postman-collection").VariableScope;
environment: import("postman-collection").VariableScope;
collectionVariables: import("postman-collection").VariableScope;
collectionVariables: import("postman-collection").CollectionVariableScope;
variables: import("postman-collection").VariableScope;
/**
* The iterationData object contains data from the data file provided during a collection run.
Expand All @@ -49,6 +59,8 @@ declare class Postman {
visualizer: Visualizer;
/**
* Allows one to send request from script asynchronously.
* @param req - -
* @param callback - -
*/
sendRequest(req: import("postman-collection").Request | string, callback: (...params: any[]) => any): void;
expect: Chai.ExpectStatic;
Expand Down Expand Up @@ -101,25 +113,44 @@ declare interface Visualizer {
*/
declare var pm: Postman;

declare interface PostmanCookieJar {
/**
* @param cookieStore - -
*/
declare class PostmanCookieJar {
constructor(cookieStore: any);
/**
* Get the cookie value with the given name.
* @param url - -
* @param name - -
* @param callback - -
*/
get(url: string, name: string, callback: (...params: any[]) => any): void;
/**
* Get all the cookies for the given URL.
* @param url - -
* @param [options] - -
* @param callback - -
*/
getAll(url: string, options?: any, callback: (...params: any[]) => any): void;
/**
* Set or update a cookie.
* @param url - -
* @param name - -
* @param [value] - -
* @param [callback] - -
*/
set(url: string, name: string | any, value?: string | ((...params: any[]) => any), callback?: (...params: any[]) => any): void;
/**
* Remove single cookie with the given name.
* @param url - -
* @param name - -
* @param [callback] - -
*/
unset(url: string, name: string, callback?: (...params: any[]) => any): void;
/**
* Remove all the cookies for the given URL.
* @param url - -
* @param [callback] - -
*/
clear(url: string, callback?: (...params: any[]) => any): void;
}
Expand Down

0 comments on commit 3ae5b34

Please sign in to comment.