postman-collection
Advanced tools
Comparing version 3.1.0-beta.1 to 3.1.0
# Postman Collection SDK Changelog | ||
#### v3.1.0-beta.1 (June 6, 2018) | ||
* Added support for tracking changes on a `VariableScope`. To use this you can enable tracking on variable scopes at the time of construction like | ||
### v3.1.0 (June 28, 2018) | ||
* Added support for tracking changes on a `VariableScope`. To use this enable tracking on your variable scope | ||
```js | ||
var variableScope = new VariableScope(definition, layers, { enableTracking: true }); | ||
``` | ||
var variableScope = new VariableScope(); | ||
or at any point later using | ||
```js | ||
variableScope.enableTracking(); | ||
``` | ||
* If you are only interested in the last change for any key, you can use the `compressed` mode. This is available when you enable compression during construction as well as later. | ||
* If you are only interested in the last change for any key, you can use the `autoCompact` option. | ||
```js | ||
var variableScope = new VariableScope(definition, layers, { | ||
enableTracking: true, | ||
changeTracker: { compressed: true } | ||
}); | ||
var variableScope = new VariableScope(); | ||
// which would be the same as | ||
variableScope.enableTracking({ compressed: true }); | ||
variableScope.enableTracking({ autoCompact: true }); | ||
``` | ||
* This makes sure that you are only provided with the most minimal set of changes. Use this when you are conscious about memory usage and performance while applying the changes back. | ||
* The diff object allows you to then apply the same changes on a different `VariableScope`. | ||
* This makes sure that you are only provided with the most minimal set of changes. Use this when you want to optimize memory usage or improve performance when applying the changes back. | ||
* The `mutations` object allows you to then apply the same changes on a different `VariableScope`. | ||
```js | ||
var scope1 = new VariableScope(definition, layers, { enableTracking: true }), | ||
scope2 = new VariableScope(); | ||
var scope1 = new VariableScope(), | ||
scope2 = new VariableScope(); | ||
// enable tracking | ||
scope1.enableTracking(); | ||
// this change is captured in scope1.changes | ||
@@ -40,8 +35,9 @@ scope1.set('foo', 'bar'); | ||
// this applies the captured changes on scope2 | ||
scope2.patch(scope1.changes); | ||
// which is the same as | ||
scope1.changes.apply(scope2); | ||
scope1.mutations.applyOn(scope2); | ||
``` | ||
* **Warning:** These public API are still being worked upon. Expect some breaking changes before the final stable release. | ||
* Added `MutationTracker` for tracking mutations. | ||
* Fixed documentation for `Description~definition` | ||
* Added `Response~contentInfo` to extract mime info and filename from response. | ||
* Deprecated `Response~mime` and `Response~mimeInfo` | ||
* Updated dependencies | ||
@@ -48,0 +44,0 @@ #### v3.0.10 (May 22, 2018) |
@@ -38,3 +38,3 @@ var _ = require('../util').lodash, | ||
* @property {String} content | ||
* @property {String} format | ||
* @property {String} type | ||
*/ | ||
@@ -51,3 +51,3 @@ /** | ||
* is in `text/plain` format or otherwise be sent as part of an object adhering to the {@link Description~definition} | ||
* structure having `content` and `format`. | ||
* structure having `content` and `type`. | ||
* | ||
@@ -54,0 +54,0 @@ * @example <caption>Add a description to an instance of Collection</caption> |
@@ -14,2 +14,3 @@ var util = require('../util'), | ||
HeaderList = require('./header-list').HeaderList, | ||
contentInfo = require('../content-info').contentInfo, | ||
@@ -297,2 +298,12 @@ /** | ||
/** | ||
* Extracts mime type, format, charset, extension and filename of the response content | ||
* A fallback of default filename is given, if filename is not present in content-disposition header | ||
* | ||
* @returns {Response~ResponseContentInfo} - contentInfo for the response | ||
*/ | ||
contentInfo: function () { | ||
return contentInfo(this); | ||
}, | ||
/** | ||
* @private | ||
@@ -312,3 +323,3 @@ * | ||
* format: normalised.format, // format specific to the type returned | ||
* name: DEFAULT_RESPONSE_FILENAME, // @todo - get from disposition | ||
* name: DEFAULT_RESPONSE_FILENAME, | ||
* ext: mimeType.extension(normalised.source) || E, // file extension from sanitised content type | ||
@@ -322,4 +333,3 @@ * filename: name + ext, | ||
* } | ||
* | ||
* @todo write unit tests | ||
* @deprecated To be removed in 4.0. Use {@link Response#contentInfo} contentInfo instead. | ||
*/ | ||
@@ -509,3 +519,3 @@ mime: function (contentType, contentDisposition) { | ||
* | ||
* @todo write unit tests | ||
* @deprecated To be removed in 4.0. Use {@link Response#contentInfo} contentInfo instead. | ||
*/ | ||
@@ -525,3 +535,3 @@ mimeInfo: function (type, disposition) { | ||
format: normalised.format, // format specific to the type returned | ||
name: DEFAULT_RESPONSE_FILENAME, // @todo - get from disposition | ||
name: DEFAULT_RESPONSE_FILENAME, | ||
ext: mimeType.extension(normalised.source) || E, // file extension from sanitised content type | ||
@@ -528,0 +538,0 @@ charset: normalised.charset || UTF8, |
@@ -5,5 +5,15 @@ var _ = require('../util').lodash, | ||
VariableList = require('./variable-list').VariableList, | ||
VariableScopeDiff = require('./variable-scope-diff').VariableScopeDiff, | ||
MutationTracker = require('./mutation-tracker').MutationTracker, | ||
COMPRESSED = 'compressed', | ||
/** | ||
* Known variable mutation types. | ||
* | ||
* @private | ||
* @constant | ||
* @type {Object} | ||
*/ | ||
MUTATIONS = { | ||
SET: 'set', | ||
UNSET: 'unset' | ||
}, | ||
@@ -64,3 +74,3 @@ VariableScope; | ||
*/ | ||
VariableScope = function PostmanVariableScope (definition, layers, options) { | ||
VariableScope = function PostmanVariableScope (definition, layers) { | ||
// in case the definition is an array (legacy format) or existing as list, we convert to actual format | ||
@@ -79,5 +89,9 @@ if (_.isArray(definition) || VariableList.isVariableList(definition)) { | ||
var values = definition && definition.values, // access the values (need this var to reuse access) | ||
i, | ||
ii; | ||
// enable mutation tracking if `mutations` are in definition (restore the state) | ||
// or is enabled through options | ||
mutations = definition && definition.mutations, | ||
ii, | ||
i; | ||
/** | ||
@@ -99,11 +113,6 @@ * @memberOf VariableScope.prototype | ||
// recreate the diff if present in the definition | ||
if (definition && definition.changes) { | ||
this.diff = new VariableScopeDiff(definition.changes); | ||
// restore previously tracked mutations | ||
if (mutations) { | ||
this.mutations = new MutationTracker(mutations); | ||
} | ||
// enable tracking only if configured | ||
if (options && options.enableTracking) { | ||
this.enableTracking(options.changeTracker); | ||
} | ||
}), Property); | ||
@@ -232,3 +241,4 @@ | ||
this._postman_enableTracking && this.changes.track('set', key, value); | ||
// track the change if mutation tracking is enabled | ||
this._postman_enableTracking && this.mutations.track(MUTATIONS.SET, key, value); | ||
}, | ||
@@ -242,11 +252,6 @@ | ||
unset: function (key) { | ||
if (!(key && this.values.has(key))) { | ||
return; | ||
} | ||
this.values.remove(key); | ||
if (this._postman_enableTracking) { | ||
this.changes.track('unset', key); | ||
} | ||
// track the change if mutation tracking is enabled | ||
this._postman_enableTracking && this.mutations.track(MUTATIONS.UNSET, key); | ||
}, | ||
@@ -258,7 +263,10 @@ | ||
clear: function () { | ||
var mutations = this.mutations; | ||
// track the change if mutation tracking is enabled | ||
// do this before deleting the keys | ||
if (this._postman_enableTracking) { | ||
// track clear as delete for each key | ||
this.values.each(function (variable) { | ||
this.changes.track('unset', variable.key); | ||
}.bind(this)); | ||
mutations.track(MUTATIONS.UNSET, variable.key); | ||
}); | ||
} | ||
@@ -270,22 +278,58 @@ | ||
/** | ||
* Enables change tracking on the variable scope. Changes are tracked on the `changes` attribute. | ||
* Enable mutation tracking. | ||
* | ||
* @note: Would do nothing if already enabled. | ||
* @note: Any previously tracked mutations would be reset when starting a new tracking session. | ||
* | ||
* @param {MutationTracker~definition} [options] Options for Mutation Tracker. See {@link MutationTracker} | ||
*/ | ||
enableTracking: function (options) { | ||
// enabled already, do nothing | ||
if (this._postman_enableTracking) { | ||
return; | ||
} | ||
/** | ||
* Controls if mutation tracking is enabled | ||
* | ||
* @memberof VariableScope.prototype | ||
* | ||
* @private | ||
* @property {Boolean} | ||
*/ | ||
this._postman_enableTracking = true; | ||
var compress = options && options.compressed, | ||
diffDefinition; | ||
// we don't want to add more mutations to existing mutations | ||
// that will lead to mutations not capturing the correct state | ||
// so we reset this with the new instance, and warn | ||
if (this.mutations) { | ||
console.warn('VariableScope~enableTracking: Dropping existing mutations to enable fresh tracking.'); | ||
} | ||
// if there are changes already wipe them | ||
if (this.changes) { | ||
this.changes.reset(); | ||
this.mutations = new MutationTracker(options); | ||
}, | ||
// adjust mode based on options | ||
compress && this.changes.compress(); | ||
} | ||
/** | ||
* Disable mutation tracking. | ||
*/ | ||
disableTracking: function () { | ||
// disable further tracking but keep the tracked mutations | ||
this._postman_enableTracking = false; | ||
}, | ||
compress && (diffDefinition = { mode: COMPRESSED }); | ||
/** | ||
* Apply a mutation instruction on this variable scope. | ||
* | ||
* @private | ||
* | ||
* @param {String} instruction Instruction identifying the type of the mutation, e.g. `set`, `unset` | ||
*/ | ||
applyMutation: function (instruction, key, value) { | ||
// we know that `set` and `unset` are the only supported instructions | ||
// and we know the parameter signature of both is the same as the items in a mutation | ||
if (this[instruction]) { | ||
// otherwise instantiate a new change tracker | ||
this.changes = new VariableScopeDiff(diffDefinition); | ||
// @todo: use argument spread here, once node v4 support is dropped | ||
this[instruction](key, value); | ||
} | ||
}, | ||
@@ -337,2 +381,8 @@ | ||
// ensure that tracking flag is not serialized | ||
// otherwise, it is very easy to let tracking trickle to many instances leading to a snowball effect | ||
if (obj._postman_enableTracking) { | ||
delete obj._postman_enableTracking; | ||
} | ||
return obj; | ||
@@ -355,16 +405,2 @@ }, | ||
this._layers.push(list); | ||
}, | ||
/** | ||
* Applies a set of variable diff on the scope. | ||
* | ||
* @param {VariableScopeDiff} diff | ||
*/ | ||
patch (diff) { | ||
if (!diff) { | ||
return; | ||
} | ||
// @todo: add isVariableScopeDiff check here | ||
diff.apply(this); | ||
} | ||
@@ -371,0 +407,0 @@ }); |
@@ -16,2 +16,3 @@ module.exports = { | ||
ItemGroup: require('./collection/item-group').ItemGroup, | ||
MutationTracker: require('./collection/mutation-tracker').MutationTracker, | ||
PropertyList: require('./collection/property-list').PropertyList, | ||
@@ -29,6 +30,4 @@ Property: require('./collection/property').Property, | ||
Variable: require('./collection/variable').Variable, | ||
VariableChangeset: require('./collection/variable-changeset').VariableChangeset, | ||
VariableList: require('./collection/variable-list').VariableList, | ||
VariableScope: require('./collection/variable-scope').VariableScope, | ||
VariableScopeDiff: require('./collection/variable-scope-diff').VariableScopeDiff, | ||
ProxyConfig: require('./collection/proxy-config').ProxyConfig, | ||
@@ -35,0 +34,0 @@ ProxyConfigList: require('./collection/proxy-config-list').ProxyConfigList, |
@@ -5,3 +5,3 @@ { | ||
"author": "Postman Labs <help@getpostman.com>", | ||
"version": "3.1.0-beta.1", | ||
"version": "3.1.0", | ||
"keywords": [ | ||
@@ -46,3 +46,3 @@ "postman" | ||
"semver": "5.5.0", | ||
"uuid": "3.2.1", | ||
"uuid": "3.3.0", | ||
"postman-url-encoder": "1.0.1" | ||
@@ -66,4 +66,4 @@ }, | ||
"jsdoc-to-markdown": "4.0.1", | ||
"karma": "2.0.2", | ||
"karma-browserify": "5.2.0", | ||
"karma": "2.0.4", | ||
"karma-browserify": "5.3.0", | ||
"karma-chrome-launcher": "2.2.0", | ||
@@ -76,3 +76,3 @@ "karma-mocha": "1.3.0", | ||
"packity": "0.3.2", | ||
"parse-gitignore": "0.4.0", | ||
"parse-gitignore": "0.5.1", | ||
"postman-jsdoc-theme": "0.0.3", | ||
@@ -79,0 +79,0 @@ "postman-request": "2.86.1-postman.1", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
454980
9868
0
+ Addeduuid@3.3.0(transitive)
- Removeduuid@3.2.1(transitive)
Updateduuid@3.3.0