Socket
Socket
Sign inDemoInstall

postman-collection

Package Overview
Dependencies
Maintainers
2
Versions
180
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postman-collection - npm Package Compare versions

Comparing version 0.0.8 to 0.0.9

lib/schema/auth.json

12

lib/collection/collection.js

@@ -98,3 +98,3 @@ var _ = require('../util').lodash,

*/
variables: new VariableList(this, definition.variable, environments)
variables: new VariableList(this, definition && definition.variable, environments)
});

@@ -119,4 +119,14 @@ }), ItemGroup);

_.extend(Collection, /** @lends Collection */ {
/**
* Defines the name of this property for internal use.
* @private
* @readOnly
* @type {String}
*/
_postman_propertyName: 'Collection'
});
module.exports = {
Collection: Collection
};

@@ -138,3 +138,12 @@ var _ = require('../util').lodash,

_.extend(Cookie, /** @lends Cookie */ {
/**
* Defines the name of this property for internal use.
* @private
* @readOnly
* @type {String}
*/
_postman_propertyName: 'Cookie',
/**
* Cookie header parser

@@ -141,0 +150,0 @@ *

14

lib/collection/description.js

@@ -138,2 +138,9 @@ var _ = require('../util').lodash,

/**
* Defines the name of this property for internal use.
* @private
* @readOnly
* @type {String}
*/
_postman_propertyName: 'Description',
/**
* The default and supported description format handlers.

@@ -178,7 +185,8 @@ * @readOnly

*
* @param {*} prop
* @param {*} obj
* @returns {Boolean}
*/
isDescription: function (prop) {
return prop instanceof Description;
isDescription: function (obj) {
return obj && ((obj instanceof Description) ||
_.inSuperChain(obj.constructor, '_postman_propertyName', Description._postman_propertyName));
}

@@ -185,0 +193,0 @@ });

@@ -63,4 +63,10 @@ var _ = require('../util').lodash,

_.extend(EventList, /** @lends EventList */ {
/**
* Defines the name of this property for internal use.
* @private
* @readOnly
* @type {String}
*/
_postman_propertyName: 'EventList',
/**
* Checks if the given object is an EventList.

@@ -72,3 +78,4 @@ *

isEventList: function (obj) {
return obj instanceof EventList;
return obj && ((obj instanceof EventList) ||
_.inSuperChain(obj.constructor, '_postman_propertyName', EventList._postman_propertyName));
}

@@ -75,0 +82,0 @@ });

@@ -44,4 +44,15 @@ var _ = require('../util').lodash,

_.extend(Event, /** @lends Event */ {
/**
* Defines the name of this property for internal use.
* @private
* @readOnly
* @type {String}
*/
_postman_propertyName: 'Event'
});
module.exports = {
Event: Event
};

@@ -15,4 +15,4 @@ var _ = require('../util').lodash,

FormParam = function PostmanFormParam (options) {
this.key = options.key || '';
this.value = options.value || '';
this.key = _.get(options, 'key') || '';
this.value = _.get(options, 'value') || '';
}), Property);

@@ -33,2 +33,10 @@

/**
* Defines the name of this property for internal use.
* @private
* @readOnly
* @type {String}
*/
_postman_propertyName: 'FormParam',
/**
* Parse a form data string into an array of objects, where each object contains a key and a value.

@@ -35,0 +43,0 @@ *

@@ -23,4 +23,4 @@ var _ = require('../util').lodash,

this.key = options.key || '';
this.value = options.value || '';
this.key = _.get(options, 'key') || '';
this.value = _.get(options, 'value') || '';
}), PropertyBase);

@@ -39,3 +39,12 @@

_.extend(Header, /** @lends Header */ {
/**
* Defines the name of this property for internal use.
* @private
* @readOnly
* @type {String}
*/
_postman_propertyName: 'Header',
/**
* Parses a multi line header string into individual header key-value pairs.

@@ -42,0 +51,0 @@ *

@@ -133,2 +133,9 @@ var _ = require('../util').lodash,

/**
* Defines the name of this property for internal use.
* @private
* @readOnly
* @type {String}
*/
_postman_propertyName: 'ItemGroup',
/**
* Iterator function to update an itemgroup's item array with appropriate objects from definition

@@ -154,3 +161,4 @@ * @private

isItemGroup: function (obj) {
return obj && (obj instanceof ItemGroup);
return obj && ((obj instanceof ItemGroup) ||
_.inSuperChain(obj.constructor, '_postman_propertyName', ItemGroup._postman_propertyName));
}

@@ -157,0 +165,0 @@ });

@@ -43,2 +43,8 @@ var _ = require('../util').lodash,

_.extend(Item.prototype, /** @lends Item.prototype */ {
/**
* Defines whether this property instances requires an id
* @private
* @readOnly
* @type {String}
*/
_postman_requiresId: true,

@@ -68,2 +74,10 @@

/**
* Defines the name of this property for internal use.
* @private
* @readOnly
* @type {String}
*/
_postman_propertyName: 'Item',
/**
* Check whether an object is an instance of PostmanItem.

@@ -75,3 +89,4 @@ *

isItem: function (obj) {
return obj && (obj instanceof Item);
return obj && ((obj instanceof Item) ||
_.inSuperChain(obj.constructor, '_postman_propertyName', Item._postman_propertyName));
}

@@ -78,0 +93,0 @@ });

@@ -43,5 +43,2 @@ var _ = require('../util').lodash,

* You can use this method to get the instantaneous representation of any property, including a {@link Collection}.
*
* @example
*
*/

@@ -80,3 +77,12 @@ toJSON: function () {

_.extend(PropertyBase, /** @lends Base */ {
/**
* Defines the name of this property for internal use.
* @private
* @readOnly
* @type {String}
*/
_postman_propertyName: 'PropertyBase',
/**
* Filter funcion to check whether a key starts with underscore or not. These usually are the meta properties. It

@@ -83,0 +89,0 @@ * returns `true` if the criteria is matched.

var _ = require('../util').lodash,
PropertyBase = require('./property-base').PropertyBase,

@@ -8,38 +9,39 @@ __PARENT = '__parent',

/**
* @constructor
*
* @todo
* - document stuff
*/
PropertyList = function PostmanPropertyList (type, parent, populate, options) {
_.assignLocked(this, __PARENT, parent); // save reference to parent
_.extend(this, /** @lends PropertyList.prototype */ {
/**
* @private
* @type {Array}
*/
members: this.members || [],
/**
* @private
* @type {Object}
*/
reference: this.reference || {},
/**
* @private
* @type {function}
*/
Type: type,
/**
* Holds holds the attribute to index this PropertyList by. Default: 'id'
*
* @private
* @type {function}
*/
indexBy: (options && options.indexBy) || DEFAULT_INDEX_ATTR
});
_.inherit((
/**
* @constructor
*
* @todo
* - document stuff
*/
PropertyList = function PostmanPropertyList (type, parent, populate, options) {
_.assignLocked(this, __PARENT, parent); // save reference to parent
_.extend(this, /** @lends PropertyList.prototype */ {
/**
* @private
* @type {Array}
*/
members: this.members || [],
/**
* @private
* @type {Object}
*/
reference: this.reference || {},
/**
* @private
* @type {function}
*/
Type: type,
/**
* Holds holds the attribute to index this PropertyList by. Default: 'id'
*
* @private
* @type {function}
*/
indexBy: (options && options.indexBy) || DEFAULT_INDEX_ATTR
});
// prepopulate
populate && this.populate(populate);
};
// prepopulate
populate && this.populate(populate);
}), PropertyBase);

@@ -50,2 +52,3 @@ _.extend(PropertyList.prototype, /** @lends PropertyList.prototype */ {

* Indicates that this element contains a number of other elements.
* @private
*/

@@ -86,3 +89,3 @@ _postman_isGroup: true,

* @param {PropertyList.Type} item
* @param {PropertyList.Type|String} [ater]
* @param {PropertyList.Type|String} [after]
*/

@@ -325,2 +328,9 @@ insertAfter: function (item, after) {

/**
* Defines the name of this property for internal use.
* @private
* @readOnly
* @type {String}
*/
_postman_propertyName: 'PropertyList',
/**
* Checks whether an object is a PropertyList

@@ -332,3 +342,4 @@ *

isPropertyList: function (obj) {
return (obj instanceof PropertyList);
return obj && ((obj instanceof PropertyList) ||
_.inSuperChain(obj.constructor, '_postman_propertyName', PropertyList._postman_propertyName));
}

@@ -335,0 +346,0 @@ });

@@ -102,4 +102,14 @@ var _ = require('../util').lodash,

_.extend(Property, /** @lends Property */ {
/**
* Defines the name of this property for internal use.
* @private
* @readOnly
* @type {String}
*/
_postman_propertyName: 'Property'
});
module.exports = {
Property: Property
};

@@ -20,4 +20,4 @@ var _ = require('../util').lodash,

this.key = options.key || '';
this.value = options.value || '';
this.key = _.get(options, 'key') || '';
this.value = _.get(options, 'value') || '';
}), Property);

@@ -38,2 +38,10 @@

/**
* Defines the name of this property for internal use.
* @private
* @readOnly
* @type {String}
*/
_postman_propertyName: 'QueryParam',
/**
* Parse a query string into an array of objects, where each object contains a key and a value.

@@ -40,0 +48,0 @@ *

@@ -108,2 +108,10 @@ var _ = require('../util').lodash,

/**
* Defines the name of this property for internal use.
* @private
* @readOnly
* @type {String}
*/
_postman_propertyName: 'RequestAuth',
addType: function (handler, name) {

@@ -110,0 +118,0 @@ // validate definition

@@ -107,2 +107,10 @@ var _ = require('../util').lodash,

/**
* Defines the name of this property for internal use.
* @private
* @readOnly
* @type {String}
*/
_postman_propertyName: 'RequestBody',
/**
* @enum {string} MODES

@@ -109,0 +117,0 @@ */

@@ -181,4 +181,14 @@ var _ = require('../util').lodash,

_.extend(Request, /** @lends Request */ {
/**
* Defines the name of this property for internal use.
* @private
* @readOnly
* @type {String}
*/
_postman_propertyName: 'Request'
});
module.exports = {
Request: Request
};

@@ -71,4 +71,14 @@ var _ = require('../util').lodash,

_.extend(Response, /** @lends Response */ {
/**
* Defines the name of this property for internal use.
* @private
* @readOnly
* @type {String}
*/
_postman_propertyName: 'Response'
});
module.exports = {
Response: Response
};

@@ -54,4 +54,14 @@ var _ = require('../util').lodash,

_.extend(Script, /** @lends Script */ {
/**
* Defines the name of this property for internal use.
* @private
* @readOnly
* @type {String}
*/
_postman_propertyName: 'Script'
});
module.exports = {
Script: Script
};

@@ -251,3 +251,12 @@ var _ = require('../util').lodash,

_.extend(Url, /** @lends Url */ {
/**
* Defines the name of this property for internal use.
* @private
* @readOnly
* @type {String}
*/
_postman_propertyName: 'Url',
/**
* Parses a string to a PostmanUrl, decomposing the URL into it's constitutent parts, such as

@@ -266,40 +275,43 @@ * path, host, port, etc.

// extract the protocol
p.protocol = url.match(/^([^:]+):\/\/([^\?#\/:]+|$)/);
p.protocol = _.get(p.protocol, '[1]');
// remove that damn protocol from url
_.isString(p.protocol) && (url = url.substr(p.protocol.length + 3));
p.protocol = _.get(url.match(/^([^:]+):\/\/([^\?#\/:]+|$)/), '[1]');
_.isString(p.protocol) && (url = url.substr(p.protocol.length + 3)); // remove that damn protocol from url
// extract authentication information
p.auth = url.match(/^(([^:]+):?([^@]*))@([^\?#\/:]+|$)/);
// remove the auth part from url
_.isString(_.get(p.auth, '[1]')) && (url = url.substr(_.get(p.auth, '[1]').length + 1));
p.auth = {
user: _.get(p.auth, '[2]'),
password: _.get(p.auth, '[3]')
};
// extract the host
p.host = url.match(/^([^\?#\/:]+)/);
p.host = _.get(p.host, '[1]');
_.isString(p.host) && ((url = url.substr(p.host.length)), (p.host = _.trim(p.host, '.').split('.')));
p.host = _.get(url.match(/^([^\?#\/]+)/), '[1]');
// get the port
p.port = url.match(/^:(\d+|{{.+}})(\/|\?|^)/);
p.port = _.get(p.port, '[1]');
_.isString(p.port) && (url = url.substr(p.port.length + 1));
// if host exists there are a lot you can extract from it
if (_.isString(p.host)) {
url = url.substr(p.host.length); // remove host from url
if (p.auth = _.get(p.host.match(/^([^@]+)@/), '[1]')) {
p.host = p.host.substr(p.auth.length + 1); // remove auth from host
p.auth = p.auth.split(':');
p.auth = {
user: p.auth[0],
password: p.auth[1]
};
}
// extract the port from the host
p.port = _.get(p.host.match(/:([^:]*)$/), '[1]');
p.port && (p.host = p.host.substring(0, p.host.length - p.port.length - 1)); // remove port from url
p.host = _.trim(p.host, '.').split('.'); // split host by subdomains
}
// extract the path
p.path = url.match(/.*?(?=\?|#|$)/);
p.path = _.get(p.path, '[0]');
_.isString(p.path) && ((url = url.substr(p.path.length)), (p.path = p.path.split('/')));
p.path = _.get(url.match(/.*?(?=\?|#|$)/), '[0]');
if (_.isString(p.path)) {
url = url.substr(p.path.length);
p.path && (p.path = p.path.replace(/^\/((.+))$/, '$1')); // remove leading slash for valid path
// if path is blank string, we set it to undefined, if '/' then single blank string array
p.path = !p.path ? undefined : (p.path === '/' ? [''] : p.path.split('/'));
}
// extract the query string
p.query = url.match(/^\?([^#$]+)/);
p.query = _.get(p.query, '[1]');
p.query = _.get(url.match(/^\?([^#$]+)/), '[1]');
_.isString(p.query) && ((url = url.substr(p.query.length + 1)), (p.query = QueryParam.parse(p.query)));
// extract the hash
p.hash = url.match(/#(.+)$/);
p.hash = _.get(p.hash, '[1]');
p.hash = _.get(url.match(/#(.+)$/), '[1]');
return p;

@@ -306,0 +318,0 @@ }

var _ = require('../util').lodash,
PropertyList = require('./property-list').PropertyList,
PropertyBase = require('./property-base').PropertyBase,
Variable = require('./variable').Variable,
/**
* Convert object to JSON using the base converter
* @private
* @param {Object} obj
* @returns {Object}
*/
toJSON = function (obj) {
return PropertyBase.prototype.toJSON.call(obj);
},
/**
* Maintain a list of types that are native

@@ -33,7 +44,7 @@ * @private

*/
this.environments = [];
this._environments = [];
// we process the environments here only if it is defined as an array and has at least one environment
if (_.isArray(environments) && environments.length) {
var proxies = this.environments;
var proxies = this._environments;
environments.reduce(function (parent, child) {

@@ -78,2 +89,54 @@ return (proxies.push(VariableList.proxy(parent, VariableList.objectify(child))), _.last(proxies));

}, this) : obj;
},
/**
* This function allows to manipulate the environment chain in this variable list.
* @private
*
* @param {Number} [index] If an index value is provided, this function returns the JSON representation of the
* particular environment. In its absence, all environments are returned within an array.
* @param {(Object|(Array<Variable>)|Null)=} [assign] A list of variables can be passed on for replacement in the
* environment. If a replacement is sent, then the function does not return any JSON.
* @param {Boolean=} [clear=false] If set to true, then the environment is cleared before new set of assignments are
* done. The assignment can be sent a `null` if environment is needed to be cleared alone.
*
* @returns {Object|undefined}
*
* @example
* myCollection.variables.env(); // gets all environments as array
* myCollection.variables.env(1); // gets the second environment as Object
* myCollection.variables.env(0, null, true); // cleares the first environment (does not delete the layer though)
* myCollection.variables.env(0, {
* var1: "variable-value"
* }); // assigns `var1` variable to the first environment layer
* myCollection.variables.env(1, {
* var2: "variable-value-2"
* }); // clears the 2nd layer and then assigns `var2` variable to it
* myCollection.variables.env(0, [
* new Variable({ id: "var3", value: "value-3"}),
* new Variable({ id: "var4", value: "value-4"})
* ]); // accepts array of variables property ass assignment
*
* @todo
* - convert this to an environment instance (coded within this module) and then add an easy API on it
*/
env: function (index, assign, clear) {
// keep a reference to the select environment for future use
var env = this._environments[index];
// we check whether a replacement was instructed then we perform replacement
if (arguments.length && (assign || (assign === null)) && env) {
// first we clear (if needed) all the variables stored within the particular environment
clear && Object.keys(this._environments[index]).forEach(function (prop) {
delete env[prop];
});
// then we merge the new assignment variables
_.merge(env, VariableList.objectify(assign));
return;
}
// if we request a particular environment, we get the one, else we convert all environments to JSON
return arguments.length ? (env && toJSON(env)) : _.map(this._environments, function (environment) {
return toJSON(environment);
});
}

@@ -83,4 +146,13 @@ });

_.extend(VariableList, /** @lends VariableList */ {
/**
* Defines the name of this property for internal use.
* @private
* @readOnly
* @type {String}
*/
_postman_propertyName: 'VariableList',
/**
* @private
*

@@ -87,0 +159,0 @@ * @type {RegExp}

@@ -113,2 +113,9 @@ var _ = require('../util').lodash,

/**
* Defines the name of this property for internal use.
* @private
* @readOnly
* @type {String}
*/
_postman_propertyName: 'Variable',
/**
* Types of variables

@@ -131,3 +138,4 @@ * @enum {Function}

isVariable: function (obj) {
return (obj instanceof Variable);
return obj && ((obj instanceof Variable) ||
_.inSuperChain(obj.constructor, '_postman_propertyName', Variable._postman_propertyName));
}

@@ -134,0 +142,0 @@ });

var _ = require('../util').lodash,
semver = require('semver'),
PropertyBase = require('./property-base'),
PropertyBase = require('./property-base').PropertyBase,

@@ -76,4 +76,14 @@ Version;

_.extend(Version, /** @lends Version */ {
/**
* Defines the name of this property for internal use.
* @private
* @readOnly
* @type {String}
*/
_postman_propertyName: 'Version'
});
module.exports = {
Version: Version
};

@@ -8,2 +8,3 @@ module.exports = {

EventList: require('./collection/event-list').EventList,
FormParam: require('./collection/form-param').FormParam,
Header: require('./collection/header').Header,

@@ -10,0 +11,0 @@ Item: require('./collection/item').Item,

@@ -115,2 +115,15 @@ var _ = require('lodash');

});
},
/**
* Returns the match of a value of a property by traversing the prototype
*
* @param {Object} obj
* @param {String} key
* @param {*} value
*
* @returns {Boolean}
*/
inSuperChain: function (obj, key, value) {
return obj ? ((obj[key] === value) || _.inSuperChain(obj.super_, key, value)) : false;
}

@@ -117,0 +130,0 @@ });

@@ -5,3 +5,3 @@ {

"author": "Postman Labs <help@getpostman.com>",
"version": "0.0.8",
"version": "0.0.9",
"keywords": [

@@ -22,3 +22,4 @@ "postman"

"scripts": {
"docs": "scripts/docs/docs.sh",
"build-docs": "scripts/build/build-docs.sh",
"build-schema": "scripts/build/build-schema.sh",
"test": "scripts/test/test.sh",

@@ -42,2 +43,3 @@ "test-unit": "scripts/test/test-unit.sh",

"sanitize-html": "^1.11.2",
"schema-compiler": "^0.0.3",
"semver": "^5.1.0"

@@ -60,4 +62,7 @@ },

"mocha": "^2.3.4",
"mustache": "^2.2.1",
"packity": "0.0.0-beta.3",
"strip-json-comments": "^2.0.0",
"require-all": "^2.0.0",
"strip-json-comments": "^2.0.1",
"tv4": "^1.2.7",
"watchify": "^3.7.0"

@@ -64,0 +69,0 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc