New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

angular-apollo

Package Overview
Dependencies
Maintainers
4
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-apollo - npm Package Compare versions

Comparing version 0.4.6 to 0.5.0

8

dist/accounts.js

@@ -26,12 +26,12 @@ "use strict";

AccountService.prototype.spotlight = function () {
return this.apiService.authorisedFetch("me/spotlight");
return this.apiService.authorised('GET', "me/spotlight");
};
AccountService.prototype.lists = function () {
return this.apiService.authorisedFetch("me/lists");
return this.apiService.authorised('GET', "me/lists");
};
AccountService.prototype.listById = function (id) {
return this.apiService.authorisedFetch("me/lists/" + id);
return this.apiService.authorised('GET', "me/lists/" + id);
};
AccountService.prototype.radios = function () {
return this.apiService.authorisedFetch("me/radios");
return this.apiService.authorised('GET', "me/radios");
};

@@ -38,0 +38,0 @@ AccountService = __decorate([

@@ -19,9 +19,6 @@ import { Http, RequestOptionsArgs } from '@angular/http';

constructor(http: Http, config: Config, secure: Secure);
authorisedPost(path: string, data: any, options?: RequestOptionsArgs): Observable<any>;
authorisedFetch(path: string, options?: RequestOptionsArgs): Observable<any>;
authorisedDelete(path: string): Observable<any>;
fetch(path: string, options?: RequestOptionsArgs): Observable<any>;
private delete(path);
post(path: string, data: any, options?: RequestOptionsArgs): Observable<any>;
authorised(method: string, path: string, data?: any, options?: RequestOptionsArgs): Observable<any>;
call(method: string, path: string, data?: any, options?: RequestOptionsArgs): any;
post(path: string, data: any, options?: RequestOptionsArgs): any;
private getPath(path);
}

@@ -23,31 +23,18 @@ "use strict";

}
ApiService.prototype.authorisedPost = function (path, data, options) {
ApiService.prototype.authorised = function (method, path, data, options) {
var _this = this;
if (options === void 0) { options = {}; }
return this.secure.authorisedRequest(options, function (options) {
return _this.post(path, data, options);
return _this.call(method, path, data, options);
});
};
ApiService.prototype.authorisedFetch = function (path, options) {
var _this = this;
ApiService.prototype.call = function (method, path, data, options) {
if (options === void 0) { options = {}; }
return this.secure.authorisedRequest(options, function (options) {
return _this.fetch(path, options);
});
method = method.toLowerCase();
if (method === 'get') {
return this.http.get(this.getPath(path), options).map(response_mapper_1.mapResponse);
}
return this.http[method](this.getPath(path), data, options).map(response_mapper_1.mapResponse);
};
ApiService.prototype.authorisedDelete = function (path) {
var _this = this;
return this.secure.authorisedRequest({}, function (options) {
return _this.delete(path);
});
};
ApiService.prototype.fetch = function (path, options) {
var url = this.getPath(path);
return this.http.get(url, options).map(response_mapper_1.mapResponse);
};
ApiService.prototype.delete = function (path) {
return this.http.delete(this.getPath(path)).map(response_mapper_1.mapResponse);
};
ApiService.prototype.post = function (path, data, options) {
var url = this.getPath(path);
options = options || {};

@@ -58,4 +45,3 @@ options = Object.assign({

var body = (typeof data === 'object') ? JSON.stringify(data) : data;
return this.http.post(url, body, options)
.map(response_mapper_1.mapResponse);
return this.call('POST', path, body, options);
};

@@ -62,0 +48,0 @@ ApiService.prototype.getPath = function (path) {

@@ -63,3 +63,3 @@ "use strict";

};
api.fetch('lists/666', options)
api.call('GET', 'lists/666', {}, options)
.subscribe(function (data) { return testing_1.expect(data).toEqual({ id: 123 }); });

@@ -80,3 +80,3 @@ }));

};
api.authorisedFetch('lists/666', options)
api.authorised('GET', 'lists/666', {}, options)
.subscribe(function (data) { return testing_1.expect(data).toEqual({ id: 123 }); });

@@ -92,3 +92,3 @@ }));

.respondWith({ body: 'not json' })
.test(function (api) { return api.fetch('blah')
.test(function (api) { return api.call('GET', 'blah')
.subscribe(function (data) { }, function (err) { return testing_1.expect(err).toEqual(jasmine.any(Error)); }); }));

@@ -98,3 +98,3 @@ testing_1.it('throws an error when the authorised fetch response body is not valid json', new test_api_call_test_1.TestApi()

.respondWith({ body: 'not json' })
.test(function (api) { return api.authorisedFetch('blah')
.test(function (api) { return api.authorised('GET', 'blah')
.subscribe(function (data) { return fail(new Error('ApiService should error')); }, function (err) { return testing_1.expect(err).toEqual(jasmine.any(Error)); }); }));

@@ -114,3 +114,3 @@ var errorStatusCodes = [404, 500];

.respondWith({ status: statusCode })
.test(function (api) { return api.fetch('blah')
.test(function (api) { return api.call('GET', 'blah')
.subscribe(function () { return fail(new Error('ApiService should error')); }, function (err) {

@@ -123,3 +123,3 @@ testing_1.expect(err).toEqual(jasmine.any(Error));

.respondWith({ status: statusCode })
.test(function (api) { return function (api) { return api.authorisedFetch('blah')
.test(function (api) { return function (api) { return api.authorised('GET', 'blah')
.subscribe(function () { return fail(new Error('ApiService should error')); }, function (err) {

@@ -132,3 +132,3 @@ testing_1.expect(err).toEqual(jasmine.any(Error));

.respondWithError(new Error('boom'))
.test(function (api) { return api.post('blah', {})
.test(function (api) { return api.call('POST', 'blah', {})
.subscribe(function () { return fail(new Error('ApiService should error')); }, function (err) { return testing_1.expect(err).toEqual(jasmine.any(Error)); }); }));

@@ -139,3 +139,3 @@ });

.respondWithError(new Error('boom'))
.test(function (api) { return api.fetch('blah')
.test(function (api) { return api.call('GET', 'blah')
.subscribe(function () { return fail(new Error('ApiService should error')); }, function (err) { return testing_1.expect(err).toEqual(jasmine.any(Error)); }); }));

@@ -145,3 +145,3 @@ testing_1.it('fails authorised fetch requests gracefully when the API is unavailable', new test_api_call_test_1.TestApi()

.respondWithError(new Error('boom'))
.test(function (api) { return api.authorisedFetch('blah')
.test(function (api) { return api.authorised('GET', 'blah')
.subscribe(function () { return fail(new Error('ApiService should error')); }, function (err) { return testing_1.expect(err).toEqual(jasmine.any(Error)); }); }));

@@ -163,3 +163,3 @@ testing_1.it('returns the json when response is 200 for post requests', (function () {

};
api.authorisedPost(url, postBody, options)
api.authorised('POST', url, postBody, options)
.subscribe(function (data) { return testing_1.expect(data).toEqual({ id: 123 }); });

@@ -176,3 +176,3 @@ });

.test(function (api) {
api.authorisedDelete('me/customradios')
api.authorised('DElETE', 'me/customradios')
.subscribe(function (data) {

@@ -179,0 +179,0 @@ testing_1.expect(data).toEqual({ id: 123 });

@@ -12,3 +12,3 @@ "use strict";

var responseBody = res.json();
if (responseBody.status) {
if (responseBody.status !== undefined) {
throw new ApiError('Error response received', responseBody);

@@ -15,0 +15,0 @@ }

@@ -22,3 +22,11 @@ "use strict";

}); });
it('throws when the body looks like an error', function () {
var expectedResponse = new http_1.Response(new http_1.ResponseOptions({
body: { status: 0, statusMessage: 'it broke' },
status: 200
}));
var getResponse = function () { return response_mapper_1.mapResponse(expectedResponse); };
expect(getResponse).toThrowError(response_mapper_1.ApiError, 'Error response received');
});
});
//# sourceMappingURL=response-mapper.test.js.map

@@ -8,3 +8,6 @@ import { List } from './schema';

save(params: CustomRadioParams): Observable<List>;
private formatBody(params);
private getRequestOptions();
delete(params: CustomRadioParams): Observable<any>;
edit(params: CustomRadioParams): Observable<any>;
}

@@ -11,0 +14,0 @@ export interface CustomRadioParams {

@@ -14,2 +14,3 @@ "use strict";

var http_1 = require('@angular/http');
var customRadioPath = 'me/customradio';
var CustomRadioService = (function () {

@@ -20,12 +21,21 @@ function CustomRadioService(apiService) {

CustomRadioService.prototype.save = function (params) {
var postData = Object.keys(params)
var postData = this.formatBody(params);
return this.apiService.authorised('POST', customRadioPath, postData, this.getRequestOptions());
};
CustomRadioService.prototype.formatBody = function (params) {
return Object.keys(params)
.map(function (key) { return (key + "=" + encodeURIComponent(params[key])); }).join('&');
return this.apiService.authorisedPost('me/customradio', postData, {
};
CustomRadioService.prototype.getRequestOptions = function () {
return {
headers: new http_1.Headers({ 'Content-Type': 'application/x-www-form-urlencoded' })
});
};
};
CustomRadioService.prototype.delete = function (params) {
return this
.apiService.authorisedDelete("me/customradio/" + params.radio_id);
.apiService.authorised('DELETE', customRadioPath + "/" + params.radio_id);
};
CustomRadioService.prototype.edit = function (params) {
return this.apiService.authorised('PUT', customRadioPath + "/" + params.radio_id, this.formatBody(params), this.getRequestOptions());
};
CustomRadioService = __decorate([

@@ -32,0 +42,0 @@ core_1.Injectable(),

@@ -22,3 +22,3 @@ "use strict";

params.set('language', 'fr');
return this.apiService.fetch('lists/' + id, {
return this.apiService.call('GET', 'lists/' + id, {
search: params

@@ -25,0 +25,0 @@ });

{
"name": "angular-apollo",
"description": "An API client for the 7digital Apollo platform built for Angular 2 projects.",
"version": "0.4.6",
"version": "0.5.0",
"main": "dist/index.js",

@@ -6,0 +6,0 @@ "repository": "https://github.com/7digital/angular-apollo.git",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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