Skip to content

Commit

Permalink
v0.2.2 release
Browse files Browse the repository at this point in the history
  • Loading branch information
mittsh committed Nov 2, 2017
1 parent 71c8658 commit 3f4170e
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 22 deletions.
53 changes: 33 additions & 20 deletions PostmanCollectionV2Importer.js
Expand Up @@ -9996,11 +9996,11 @@ methods.resolve = function (options, uri) {

var uriToLoad = (0, _url.resolve)(uri, $ref);
var protocol = (0, _url.parse)(uriToLoad).protocol;
if (protocol === 'file:' || protocol === 'file') {
return options.fsResolver.resolve(uriToLoad.split('#')[0]);
if (protocol && protocol.substr(0, 4) === 'http') {
return options.httpResolver.resolve(uriToLoad.split('#')[0]);
}

return options.httpResolver.resolve(uriToLoad.split('#')[0]);
return options.fsResolver.resolve(uriToLoad.split('#')[0]);
};

methods.normalizeRequestItem = function (item) {
Expand Down Expand Up @@ -13468,7 +13468,7 @@ methods.addHostEntryToHostMap = function (hostMap, _ref) {
var hostname = key.get('hostname') ? key.get('hostname').generate((0, _immutable.List)(['{{', '}}'])) : '';
var port = key.get('port') ? ':' + key.get('port').generate((0, _immutable.List)(['{{', '}}'])) : '';
var host = hostname + port;
var pathname = key.get('pathname').generate((0, _immutable.List)(['{{', '}}']));
var pathname = key.get('pathname') ? key.get('pathname').generate((0, _immutable.List)(['{{', '}}'])) : '';

if (!hostMap[host]) {
hostMap[host] = { entries: [], lcPathname: pathname.split('/') };
Expand Down Expand Up @@ -14535,15 +14535,15 @@ methods.convertAuthIntoDynamicValue = function (auth) {
* @param {Environment} environment: the environment in which this auth value is applicable.
* @param {Auth} auth: the auth to add to the domain
* @param {string} key: the name of the auth
* @returns {EnvironmentVariable} the newly created environment variable.
* @returns {{ variable: EnvironmentVariable, auth: Auth }} the newly created environment variable.
*/
methods.addAuthToDomain = function (domain, environment, auth, key) {
var variable = domain.createEnvironmentVariable(key);
var dv = methods.convertAuthIntoDynamicValue(auth);
var ds = methods.wrapDV(dv);
variable.setValue(ds, environment);

return variable;
return { variable: variable, auth: auth };
};

/**
Expand Down Expand Up @@ -15122,38 +15122,51 @@ methods.getContainerFromRequest = function (request) {
* converts an auth into a DynamicString from a reference.
* @param {Store} store: the store to use to resolve the reference
* @param {Reference} reference: the reference to an EnvironmentVariable representing an Auth.
* @returns {DynamicString} the corresponding DynamicString
* @returns {{ variable: DynamicString, auth: Auth }} the corresponding DynamicString
*/
methods.convertAuthFromReference = function (store, reference) {
var variable = store.getIn(['auth', reference.get('uuid')]);
var _store$getIn = store.getIn(['auth', reference.get('uuid')]),
variable = _store$getIn.variable,
auth = _store$getIn.auth;

var ds = variable.createDynamicString();
return ds;
return { variable: ds, auth: auth };
};

/**
* converts a reference or an auth into a DynamicString Entry.
* @param {Store} store: the store used to resolve references
* @param {Auth|Reference} authOrReference: the record to convert into a DynamicString
* @returns {DynamicString} the corresponding DynamicString
* @returns {{ variable: DynamicString, auth: Auth }} the corresponding DynamicString
*/
methods.convertReferenceOrAuthToDsEntry = function (store, authOrReference) {
if (authOrReference instanceof _Reference2.default) {
return methods.convertAuthFromReference(store, authOrReference);
}

var dv = methods.convertAuthIntoDynamicValue(authOrReference);
return methods.wrapDV(dv);
return { variable: methods.wrapDV(dv), auth: authOrReference };
};

// TODO create Variable DS that has enum with all auth possible
/**
* sets the Auth DynamicString as am Authorization Header.
* @param {PawRequest} pawRequest: the paw request to update
* @param {DynamicString} auth: the DynamicString representing an auth
* @param {Objecti} authData: the object containing the auth representation as a DynamicString and
* the original auth Record.
* @param {DynamicString} variable: the DynamicString representing an auth
* @param {Auth} auth: the original auth
* @returns {PawRequest} the update paw request
*/
methods.addAuthToRequest = function (pawRequest, auth) {
pawRequest.setHeader('Authorization', auth);
methods.addAuthToRequest = function (pawRequest, _ref7) {
var variable = _ref7.variable,
auth = _ref7.auth;

var authName = 'Authorization';
if (auth instanceof _Auth2.default.ApiKey) {
authName = auth.get('name');
}
pawRequest.setHeader(authName, variable);
return pawRequest;
};

Expand Down Expand Up @@ -15298,13 +15311,13 @@ methods.createGroups = function (context, resources, group, groupName) {
* @returns {boolean} whether the import was successful or not
*/
methods.serialize = function () {
var _ref7 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
_ref7$options = _ref7.options;
var _ref8 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
_ref8$options = _ref8.options;

_ref7$options = _ref7$options === undefined ? {} : _ref7$options;
var context = _ref7$options.context,
_ref7$api = _ref7.api,
api = _ref7$api === undefined ? new _Api2.default() : _ref7$api;
_ref8$options = _ref8$options === undefined ? {} : _ref8$options;
var context = _ref8$options.context,
_ref8$api = _ref8.api,
api = _ref8$api === undefined ? new _Api2.default() : _ref8$api;

var store = methods.createEnvironments(context, api);
var resources = methods.createRequests(context, store, api);
Expand Down
46 changes: 44 additions & 2 deletions README.md
@@ -1,3 +1,45 @@
# Paw-PostmanCollectionV2Importer
An empty repository to host the build of the Postman Collection v2 format Importer produced by [API-Flow](https://github.com/luckymarmot/API-Flow).
# Postman Collection 2.0 Importer for Paw

A [Paw Extension](https://paw.cloud/extensions) to import Postman Collection 2.0 files into Paw.

## How to use?

* In Paw, go to File menu, then Import...
* Pick the saved Postman Collection 2.0 file, and make sure the Format is "Postman Collection 2.0 Importer"

## Versions supported

* Postman 1.0 files: use instead [Postman v1 Importer (Paw)](https://paw.cloud/extensions/PostmanImporter)
* Postman 2.0 files: supported
* Postman 2.1 files: supported

## Development

⚠️ This project is entierly based on [API Flow](https://github.com/luckymarmot/API-Flow). This repository only containes the compiled file for this extension. Please refer to the *API Flow* repository for the orignal source code and for development.

The commands below refer to the *API Flow* project.

### Prerequisites

```shell
nvm install
yarn install
```

### Build and install to Paw

```shell
TARGET="postman2" make transfer
```

### Build for deployment

```shell
TARGET="postman2" make pack
```

## License

This Paw Extension is released under the [MIT License](https://github.com/luckymarmot/API-Flow/blob/develop/LICENSE). Feel free to fork, and modify!

Copyright © 2014-2017 [Paw](https://paw.cloud)

0 comments on commit 3f4170e

Please sign in to comment.