angular2-cool-http
Advanced tools
Comparing version 1.3.3 to 1.3.4
41
index.js
"use strict"; | ||
const core_1 = require('@angular/core'); | ||
const http_1 = require('@angular/http'); | ||
const cool_http_service_1 = require('./src/cool-http.service'); | ||
var cool_http_service_2 = require('./src/cool-http.service'); | ||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
var core_1 = require("@angular/core"); | ||
var http_1 = require("@angular/http"); | ||
var cool_http_service_1 = require("./src/cool-http.service"); | ||
var cool_http_service_2 = require("./src/cool-http.service"); | ||
exports.CoolHttp = cool_http_service_2.CoolHttp; | ||
var http_header_model_1 = require('./src/http-header.model'); | ||
var http_header_model_1 = require("./src/http-header.model"); | ||
exports.HttpHeader = http_header_model_1.HttpHeader; | ||
class CoolHttpModule { | ||
} | ||
CoolHttpModule.decorators = [ | ||
{ type: core_1.NgModule, args: [{ | ||
exports: [http_1.HttpModule], | ||
imports: [http_1.HttpModule], | ||
providers: [cool_http_service_1.CoolHttp] | ||
},] }, | ||
]; | ||
/** @nocollapse */ | ||
CoolHttpModule.ctorParameters = () => []; | ||
var CoolHttpModule = (function () { | ||
function CoolHttpModule() { | ||
} | ||
return CoolHttpModule; | ||
}()); | ||
CoolHttpModule = __decorate([ | ||
core_1.NgModule({ | ||
exports: [], | ||
imports: [http_1.HttpModule], | ||
providers: [cool_http_service_1.CoolHttp] | ||
}) | ||
], CoolHttpModule); | ||
exports.CoolHttpModule = CoolHttpModule; | ||
//# sourceMappingURL=./index.js.map | ||
//# sourceMappingURL=index.js.map |
@@ -1,1 +0,1 @@ | ||
[{"__symbolic":"module","version":2,"metadata":{"CoolHttpModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"exports":[{"__symbolic":"reference","module":"@angular/http","name":"HttpModule"}],"imports":[{"__symbolic":"reference","module":"@angular/http","name":"HttpModule"}],"providers":[{"__symbolic":"reference","module":"./src/cool-http.service","name":"CoolHttp"}]}]}]}},"exports":[{"from":"./src/cool-http.service","export":["CoolHttp"]},{"from":"./src/http-header.model","export":["HttpHeader"]},{"from":"./src/request-interceptor.interface","export":["IRequestInterceptor"]},{"from":"./src/response-interceptor.interface","export":["IResponseInterceptor"]}]},{"__symbolic":"module","exports":[{"from":"./src/cool-http.service","export":["CoolHttp"]},{"from":"./src/http-header.model","export":["HttpHeader"]},{"from":"./src/request-interceptor.interface","export":["IRequestInterceptor"]},{"from":"./src/response-interceptor.interface","export":["IResponseInterceptor"]}],"metadata":{"CoolHttpModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"exports":[{"__symbolic":"reference","module":"@angular/http","name":"HttpModule"}],"imports":[{"__symbolic":"reference","module":"@angular/http","name":"HttpModule"}],"providers":[{"__symbolic":"reference","module":"./src/cool-http.service","name":"CoolHttp"}]}]}]}},"version":1}] | ||
[{"__symbolic":"module","version":3,"metadata":{"CoolHttpModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"exports":[],"imports":[{"__symbolic":"reference","module":"@angular/http","name":"HttpModule"}],"providers":[{"__symbolic":"reference","module":"./src/cool-http.service","name":"CoolHttp"}]}]}]}},"exports":[{"from":"./src/cool-http.service","export":["CoolHttp"]},{"from":"./src/http-header.model","export":["HttpHeader"]},{"from":"./src/request-interceptor.interface","export":["IRequestInterceptor"]},{"from":"./src/response-interceptor.interface","export":["IResponseInterceptor"]}]},{"__symbolic":"module","version":1,"metadata":{"CoolHttpModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"exports":[],"imports":[{"__symbolic":"reference","module":"@angular/http","name":"HttpModule"}],"providers":[{"__symbolic":"reference","module":"./src/cool-http.service","name":"CoolHttp"}]}]}]}},"exports":[{"from":"./src/cool-http.service","export":["CoolHttp"]},{"from":"./src/http-header.model","export":["HttpHeader"]},{"from":"./src/request-interceptor.interface","export":["IRequestInterceptor"]},{"from":"./src/response-interceptor.interface","export":["IResponseInterceptor"]}]}] |
{ | ||
"name": "angular2-cool-http", | ||
"version": "1.3.3", | ||
"version": "1.3.4", | ||
"description": "Cool features over angular2 Http Client.", | ||
@@ -9,6 +9,12 @@ "main": "index.js", | ||
"dependencies": { | ||
"rxjs": "^5.0.0-rc.5", | ||
"@angular/core": "2.3.0", | ||
"@angular/http": "2.3.0" | ||
"rxjs": "^5.0.3", | ||
"@angular/core": "2.4.4", | ||
"@angular/http": "2.4.4" | ||
}, | ||
"devDependencies": { | ||
"@angular/compiler": "2.4.4", | ||
"@angular/compiler-cli": "2.4.4", | ||
"@angular/platform-server": "2.4.4", | ||
"typescript": "2.1.5" | ||
}, | ||
"scripts": { | ||
@@ -49,9 +55,3 @@ "clean": "rm -rf ./dist", | ||
}, | ||
"homepage": "https://github.com/Hacklone/angular2-cool-http#readme", | ||
"devDependencies": { | ||
"@angular/compiler": "2.3.0", | ||
"@angular/compiler-cli": "2.3.0", | ||
"@angular/platform-server": "2.3.0", | ||
"typescript": "2.0.10" | ||
} | ||
"homepage": "https://github.com/Hacklone/angular2-cool-http#readme" | ||
} |
"use strict"; | ||
class CookieStore { | ||
getCookie(key) { | ||
let cookieCollection = this.getCookieCollection(); | ||
var CookieStore = (function () { | ||
function CookieStore() { | ||
} | ||
CookieStore.prototype.getCookie = function (key) { | ||
var cookieCollection = this.getCookieCollection(); | ||
return cookieCollection[key]; | ||
} | ||
getCookieCollection() { | ||
let currentRawCookie = document.cookie; | ||
}; | ||
CookieStore.prototype.getCookieCollection = function () { | ||
var currentRawCookie = document.cookie; | ||
if (currentRawCookie === this.lastReadRawCookieCollection) { | ||
@@ -15,7 +17,8 @@ return this.lastReadCookieCollection; | ||
if (this.lastReadRawCookieCollection.indexOf('; ') !== -1) { | ||
let cookies = this.lastReadRawCookieCollection.split('; '); | ||
for (let cookie of cookies) { | ||
let indexOfEqualSign = cookie.indexOf('='); | ||
var cookies = this.lastReadRawCookieCollection.split('; '); | ||
for (var _i = 0, cookies_1 = cookies; _i < cookies_1.length; _i++) { | ||
var cookie = cookies_1[_i]; | ||
var indexOfEqualSign = cookie.indexOf('='); | ||
if (indexOfEqualSign > 0) { | ||
let cookieName = CookieStore.tryDecodeUriComponent(cookie.substring(0, indexOfEqualSign)); | ||
var cookieName = CookieStore.tryDecodeUriComponent(cookie.substring(0, indexOfEqualSign)); | ||
this.lastReadCookieCollection[cookieName] = CookieStore.tryDecodeUriComponent(cookie.substring(indexOfEqualSign + 1)); | ||
@@ -26,4 +29,4 @@ } | ||
return this.lastReadCookieCollection; | ||
} | ||
static tryDecodeUriComponent(uriComponent) { | ||
}; | ||
CookieStore.tryDecodeUriComponent = function (uriComponent) { | ||
try { | ||
@@ -35,5 +38,6 @@ return decodeURIComponent(uriComponent); | ||
} | ||
} | ||
} | ||
}; | ||
return CookieStore; | ||
}()); | ||
exports.CookieStore = CookieStore; | ||
//# sourceMappingURL=./cookie-store.service.js.map | ||
//# sourceMappingURL=src/cookie-store.service.js.map |
@@ -1,1 +0,1 @@ | ||
[{"__symbolic":"module","version":2,"metadata":{"CookieStore":{"__symbolic":"class","members":{"getCookie":[{"__symbolic":"method"}],"getCookieCollection":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","metadata":{"CookieStore":{"__symbolic":"class","members":{"getCookie":[{"__symbolic":"method"}],"getCookieCollection":[{"__symbolic":"method"}]}}},"version":1}] | ||
[{"__symbolic":"module","version":3,"metadata":{"CookieStore":{"__symbolic":"class","members":{"getCookie":[{"__symbolic":"method"}],"getCookieCollection":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"CookieStore":{"__symbolic":"class","members":{"getCookie":[{"__symbolic":"method"}],"getCookieCollection":[{"__symbolic":"method"}]}}}}] |
"use strict"; | ||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
var __metadata = (this && this.__metadata) || function (k, v) { | ||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments)).next()); | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
const core_1 = require('@angular/core'); | ||
const http_1 = require('@angular/http'); | ||
const Rx_1 = require('rxjs/Rx'); | ||
const http_header_model_1 = require('./http-header.model'); | ||
const cookie_store_service_1 = require('./cookie-store.service'); | ||
class CoolHttp { | ||
constructor(http) { | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t; | ||
return { next: verb(0), "throw": verb(1), "return": verb(2) }; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [0, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
var core_1 = require("@angular/core"); | ||
var http_1 = require("@angular/http"); | ||
var Rx_1 = require("rxjs/Rx"); | ||
var http_header_model_1 = require("./http-header.model"); | ||
var cookie_store_service_1 = require("./cookie-store.service"); | ||
var CoolHttp = (function () { | ||
function CoolHttp(http) { | ||
this._cookieStore = new cookie_store_service_1.CookieStore(); | ||
@@ -24,3 +60,3 @@ this._globalHeaders = []; | ||
} | ||
registerBaseUrl(baseUrl) { | ||
CoolHttp.prototype.registerBaseUrl = function (baseUrl) { | ||
this._baseUrl = baseUrl; | ||
@@ -30,14 +66,14 @@ if (this._baseUrl[this._baseUrl.length - 1] !== '/') { | ||
} | ||
} | ||
setWithCredentials(status) { | ||
}; | ||
CoolHttp.prototype.setWithCredentials = function (status) { | ||
this._withCredentials = status; | ||
} | ||
registerGlobalHeader(header) { | ||
}; | ||
CoolHttp.prototype.registerGlobalHeader = function (header) { | ||
this._globalHeaders.push(header); | ||
} | ||
registerRequestInterceptor(requestInterceptor) { | ||
}; | ||
CoolHttp.prototype.registerRequestInterceptor = function (requestInterceptor) { | ||
this._requestInterceptors.push(requestInterceptor); | ||
} | ||
deregisterRequestInterceptor(requestInterceptor) { | ||
let indexOfItem = this._requestInterceptors.indexOf(requestInterceptor); | ||
}; | ||
CoolHttp.prototype.deregisterRequestInterceptor = function (requestInterceptor) { | ||
var indexOfItem = this._requestInterceptors.indexOf(requestInterceptor); | ||
if (indexOfItem === -1) { | ||
@@ -48,8 +84,8 @@ return false; | ||
return true; | ||
} | ||
registerResponseInterceptor(responseInterceptor) { | ||
}; | ||
CoolHttp.prototype.registerResponseInterceptor = function (responseInterceptor) { | ||
this._responseInterceptors.push(responseInterceptor); | ||
} | ||
deregisterResponseInterceptor(responseInterceptor) { | ||
let indexOfItem = this._responseInterceptors.indexOf(responseInterceptor); | ||
}; | ||
CoolHttp.prototype.deregisterResponseInterceptor = function (responseInterceptor) { | ||
var indexOfItem = this._responseInterceptors.indexOf(responseInterceptor); | ||
if (indexOfItem === -1) { | ||
@@ -60,4 +96,4 @@ return false; | ||
return true; | ||
} | ||
sendCookieValueInCustomHeader(cookieName, customHeaderName) { | ||
}; | ||
CoolHttp.prototype.sendCookieValueInCustomHeader = function (cookieName, customHeaderName) { | ||
this._customCookieToHeaders.push({ | ||
@@ -67,128 +103,195 @@ cookieName: cookieName, | ||
}); | ||
} | ||
getAsync(url, options = new http_1.RequestOptions()) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let that = this; | ||
return yield that.requestCoreAsync(url, 'GET', null, options, (url, data, modOptions) => { | ||
return that._http.get(url, modOptions); | ||
}; | ||
CoolHttp.prototype.getAsync = function (url, options) { | ||
if (options === void 0) { options = new http_1.RequestOptions(); } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var that; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
that = this; | ||
return [4 /*yield*/, that.requestCoreAsync(url, 'GET', null, options, function (url, data, modOptions) { | ||
return that._http.get(url, modOptions); | ||
})]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
} | ||
postAsync(url, data, options = new http_1.RequestOptions()) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let that = this; | ||
return yield that.requestCoreAsync(url, 'POST', data, options, (url, data, modOptions) => { | ||
return that._http.post(url, data, modOptions); | ||
}; | ||
CoolHttp.prototype.postAsync = function (url, data, options) { | ||
if (options === void 0) { options = new http_1.RequestOptions(); } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var that; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
that = this; | ||
return [4 /*yield*/, that.requestCoreAsync(url, 'POST', data, options, function (url, data, modOptions) { | ||
return that._http.post(url, data, modOptions); | ||
})]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
} | ||
putAsync(url, data, options = new http_1.RequestOptions()) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let that = this; | ||
return yield that.requestCoreAsync(url, 'PUT', data, options, (url, data, modOptions) => { | ||
return that._http.put(url, data, modOptions); | ||
}; | ||
CoolHttp.prototype.putAsync = function (url, data, options) { | ||
if (options === void 0) { options = new http_1.RequestOptions(); } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var that; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
that = this; | ||
return [4 /*yield*/, that.requestCoreAsync(url, 'PUT', data, options, function (url, data, modOptions) { | ||
return that._http.put(url, data, modOptions); | ||
})]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
} | ||
deleteAsync(url, options = new http_1.RequestOptions()) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let that = this; | ||
return yield that.requestCoreAsync(url, 'DELETE', null, options, (url, data, modOptions) => { | ||
return that._http['delete'](url, modOptions); | ||
}; | ||
CoolHttp.prototype.deleteAsync = function (url, options) { | ||
if (options === void 0) { options = new http_1.RequestOptions(); } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var that; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
that = this; | ||
return [4 /*yield*/, that.requestCoreAsync(url, 'DELETE', null, options, function (url, data, modOptions) { | ||
return that._http['delete'](url, modOptions); | ||
})]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
} | ||
patchAsync(url, data, options = new http_1.RequestOptions()) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let that = this; | ||
return yield that.requestCoreAsync(url, 'PATCH', data, options, (url, data, modOptions) => { | ||
return that._http.patch(url, data, modOptions); | ||
}; | ||
CoolHttp.prototype.patchAsync = function (url, data, options) { | ||
if (options === void 0) { options = new http_1.RequestOptions(); } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var that; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
that = this; | ||
return [4 /*yield*/, that.requestCoreAsync(url, 'PATCH', data, options, function (url, data, modOptions) { | ||
return that._http.patch(url, data, modOptions); | ||
})]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
} | ||
headAsync(url, options = new http_1.RequestOptions()) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let that = this; | ||
return yield that.requestCoreAsync(url, 'HEAD', null, options, (url, data, modOptions) => { | ||
return that._http.head(url, modOptions); | ||
}; | ||
CoolHttp.prototype.headAsync = function (url, options) { | ||
if (options === void 0) { options = new http_1.RequestOptions(); } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var that; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
that = this; | ||
return [4 /*yield*/, that.requestCoreAsync(url, 'HEAD', null, options, function (url, data, modOptions) { | ||
return that._http.head(url, modOptions); | ||
})]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
} | ||
requestCoreAsync(url, method, data, options, action) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
options.headers = options.headers || new http_1.Headers(); | ||
url = this.convertUrl(url); | ||
this.appendGlobalHeaders(options.headers); | ||
this.tryAppendRegisteredCookiestoCustomHeaders(options.headers); | ||
this.modifyOptions(options); | ||
let clientHeaders = this.convertAngularHeadersToHttpClientHeaders(options.headers); | ||
let shouldIntercept = yield this.invokeRequestInterceptorsAsync(url, method, data, clientHeaders); | ||
if (shouldIntercept) { | ||
return; | ||
} | ||
let response; | ||
try { | ||
response = yield action(url, data, options).toPromise(); | ||
} | ||
catch (errorResponse) { | ||
response = errorResponse; | ||
} | ||
shouldIntercept = yield this.invokeResponseInterceptorsAsync(response, url, method, data, clientHeaders); | ||
if (shouldIntercept) { | ||
return; | ||
} | ||
if (!response.ok) { | ||
throw new Error(`Failed to call api ${method} ${url}`); | ||
} | ||
let returnValue; | ||
try { | ||
returnValue = response.json(); | ||
} | ||
catch (e) { | ||
returnValue = response.text(); | ||
} | ||
return returnValue; | ||
}; | ||
CoolHttp.prototype.requestCoreAsync = function (url, method, data, options, action) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var clientHeaders, shouldIntercept, response, errorResponse_1, returnValue; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
options.headers = options.headers || new http_1.Headers(); | ||
url = this.convertUrl(url); | ||
this.appendGlobalHeaders(options.headers); | ||
this.tryAppendRegisteredCookiestoCustomHeaders(options.headers); | ||
this.modifyOptions(options); | ||
clientHeaders = this.convertAngularHeadersToHttpClientHeaders(options.headers); | ||
return [4 /*yield*/, this.invokeRequestInterceptorsAsync(url, method, data, clientHeaders)]; | ||
case 1: | ||
shouldIntercept = _a.sent(); | ||
if (shouldIntercept) { | ||
return [2 /*return*/]; | ||
} | ||
_a.label = 2; | ||
case 2: | ||
_a.trys.push([2, 4, , 5]); | ||
return [4 /*yield*/, action(url, data, options).toPromise()]; | ||
case 3: | ||
response = _a.sent(); | ||
return [3 /*break*/, 5]; | ||
case 4: | ||
errorResponse_1 = _a.sent(); | ||
response = errorResponse_1; | ||
return [3 /*break*/, 5]; | ||
case 5: return [4 /*yield*/, this.invokeResponseInterceptorsAsync(response, url, method, data, clientHeaders)]; | ||
case 6: | ||
shouldIntercept = _a.sent(); | ||
if (shouldIntercept) { | ||
return [2 /*return*/]; | ||
} | ||
if (!response.ok) { | ||
throw new Error("Failed to call api " + method + " " + url); | ||
} | ||
try { | ||
returnValue = response.json(); | ||
} | ||
catch (e) { | ||
returnValue = response.text(); | ||
} | ||
return [2 /*return*/, returnValue]; | ||
} | ||
}); | ||
}); | ||
} | ||
getObservable(url, options = new http_1.RequestOptions()) { | ||
let that = this; | ||
return that.requestCoreObservable(url, 'GET', null, options, (url, data, modOptions) => { | ||
}; | ||
CoolHttp.prototype.getObservable = function (url, options) { | ||
if (options === void 0) { options = new http_1.RequestOptions(); } | ||
var that = this; | ||
return that.requestCoreObservable(url, 'GET', null, options, function (url, data, modOptions) { | ||
return that._http.get(url, modOptions); | ||
}); | ||
} | ||
postObservable(url, data, options = new http_1.RequestOptions()) { | ||
let that = this; | ||
return that.requestCoreObservable(url, 'POST', data, options, (url, data, modOptions) => { | ||
}; | ||
CoolHttp.prototype.postObservable = function (url, data, options) { | ||
if (options === void 0) { options = new http_1.RequestOptions(); } | ||
var that = this; | ||
return that.requestCoreObservable(url, 'POST', data, options, function (url, data, modOptions) { | ||
return that._http.post(url, data, modOptions); | ||
}); | ||
} | ||
putObservable(url, data, options = new http_1.RequestOptions()) { | ||
let that = this; | ||
return that.requestCoreObservable(url, 'PUT', data, options, (url, data, modOptions) => { | ||
}; | ||
CoolHttp.prototype.putObservable = function (url, data, options) { | ||
if (options === void 0) { options = new http_1.RequestOptions(); } | ||
var that = this; | ||
return that.requestCoreObservable(url, 'PUT', data, options, function (url, data, modOptions) { | ||
return that._http.put(url, data, modOptions); | ||
}); | ||
} | ||
deleteObservable(url, options = new http_1.RequestOptions()) { | ||
let that = this; | ||
return that.requestCoreObservable(url, 'DELETE', null, options, (url, data, modOptions) => { | ||
}; | ||
CoolHttp.prototype.deleteObservable = function (url, options) { | ||
if (options === void 0) { options = new http_1.RequestOptions(); } | ||
var that = this; | ||
return that.requestCoreObservable(url, 'DELETE', null, options, function (url, data, modOptions) { | ||
return that._http['delete'](url, modOptions); | ||
}); | ||
} | ||
patchObservable(url, data, options = new http_1.RequestOptions()) { | ||
let that = this; | ||
return that.requestCoreObservable(url, 'PATCH', data, options, (url, data, modOptions) => { | ||
}; | ||
CoolHttp.prototype.patchObservable = function (url, data, options) { | ||
if (options === void 0) { options = new http_1.RequestOptions(); } | ||
var that = this; | ||
return that.requestCoreObservable(url, 'PATCH', data, options, function (url, data, modOptions) { | ||
return that._http.patch(url, data, modOptions); | ||
}); | ||
} | ||
headObservable(url, options = new http_1.RequestOptions()) { | ||
let that = this; | ||
return that.requestCoreObservable(url, 'HEAD', null, options, (url, data, modOptions) => { | ||
}; | ||
CoolHttp.prototype.headObservable = function (url, options) { | ||
if (options === void 0) { options = new http_1.RequestOptions(); } | ||
var that = this; | ||
return that.requestCoreObservable(url, 'HEAD', null, options, function (url, data, modOptions) { | ||
return that._http.head(url, modOptions); | ||
}); | ||
} | ||
requestCoreObservable(url, method, data, options, action) { | ||
}; | ||
CoolHttp.prototype.requestCoreObservable = function (url, method, data, options, action) { | ||
return Rx_1.Observable.fromPromise(this.requestCoreAsync(url, method, data, options, action)); | ||
} | ||
convertUrl(url) { | ||
let returnUrl = url; | ||
}; | ||
CoolHttp.prototype.convertUrl = function (url) { | ||
var returnUrl = url; | ||
if (this._baseUrl) { | ||
@@ -198,16 +301,18 @@ returnUrl = this._baseUrl + returnUrl; | ||
return returnUrl; | ||
} | ||
modifyOptions(options) { | ||
}; | ||
CoolHttp.prototype.modifyOptions = function (options) { | ||
if (this._withCredentials) { | ||
options.withCredentials = true; | ||
} | ||
} | ||
appendGlobalHeaders(headers) { | ||
for (const registeredHeader of this._globalHeaders) { | ||
}; | ||
CoolHttp.prototype.appendGlobalHeaders = function (headers) { | ||
for (var _i = 0, _a = this._globalHeaders; _i < _a.length; _i++) { | ||
var registeredHeader = _a[_i]; | ||
headers.append(registeredHeader.key, registeredHeader.value); | ||
} | ||
} | ||
tryAppendRegisteredCookiestoCustomHeaders(headers) { | ||
for (const cookieToHeader of this._customCookieToHeaders) { | ||
const cookieValue = this._cookieStore.getCookie(cookieToHeader.cookieName); | ||
}; | ||
CoolHttp.prototype.tryAppendRegisteredCookiestoCustomHeaders = function (headers) { | ||
for (var _i = 0, _a = this._customCookieToHeaders; _i < _a.length; _i++) { | ||
var cookieToHeader = _a[_i]; | ||
var cookieValue = this._cookieStore.getCookie(cookieToHeader.cookieName); | ||
if (cookieValue) { | ||
@@ -217,28 +322,58 @@ headers.append(cookieToHeader.customHeaderName, cookieValue); | ||
} | ||
} | ||
invokeRequestInterceptorsAsync(url, method, data, headers) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
for (const requestInterceptor of this._requestInterceptors) { | ||
const shouldIntercept = yield requestInterceptor.beforeRequestAsync(url, method, data, headers); | ||
if (shouldIntercept) { | ||
return true; | ||
}; | ||
CoolHttp.prototype.invokeRequestInterceptorsAsync = function (url, method, data, headers) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _i, _a, requestInterceptor, shouldIntercept; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
_i = 0, _a = this._requestInterceptors; | ||
_b.label = 1; | ||
case 1: | ||
if (!(_i < _a.length)) return [3 /*break*/, 4]; | ||
requestInterceptor = _a[_i]; | ||
return [4 /*yield*/, requestInterceptor.beforeRequestAsync(url, method, data, headers)]; | ||
case 2: | ||
shouldIntercept = _b.sent(); | ||
if (shouldIntercept) { | ||
return [2 /*return*/, true]; | ||
} | ||
_b.label = 3; | ||
case 3: | ||
_i++; | ||
return [3 /*break*/, 1]; | ||
case 4: return [2 /*return*/, false]; | ||
} | ||
} | ||
return false; | ||
}); | ||
}); | ||
} | ||
invokeResponseInterceptorsAsync(response, url, method, data, headers) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
for (const responseInterceptor of this._responseInterceptors) { | ||
const shouldIntercept = yield responseInterceptor.afterResponseAsync(response, url, method, data, headers); | ||
if (shouldIntercept) { | ||
return true; | ||
}; | ||
CoolHttp.prototype.invokeResponseInterceptorsAsync = function (response, url, method, data, headers) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _i, _a, responseInterceptor, shouldIntercept; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
_i = 0, _a = this._responseInterceptors; | ||
_b.label = 1; | ||
case 1: | ||
if (!(_i < _a.length)) return [3 /*break*/, 4]; | ||
responseInterceptor = _a[_i]; | ||
return [4 /*yield*/, responseInterceptor.afterResponseAsync(response, url, method, data, headers)]; | ||
case 2: | ||
shouldIntercept = _b.sent(); | ||
if (shouldIntercept) { | ||
return [2 /*return*/, true]; | ||
} | ||
_b.label = 3; | ||
case 3: | ||
_i++; | ||
return [3 /*break*/, 1]; | ||
case 4: return [2 /*return*/, false]; | ||
} | ||
} | ||
return false; | ||
}); | ||
}); | ||
} | ||
convertAngularHeadersToHttpClientHeaders(headers) { | ||
return headers.keys().map(headerKey => { | ||
const httpClientHeader = new http_header_model_1.HttpHeader(); | ||
}; | ||
CoolHttp.prototype.convertAngularHeadersToHttpClientHeaders = function (headers) { | ||
return headers.keys().map(function (headerKey) { | ||
var httpClientHeader = new http_header_model_1.HttpHeader(); | ||
httpClientHeader.key = headerKey; | ||
@@ -248,12 +383,10 @@ httpClientHeader.value = headers.get(headerKey); | ||
}); | ||
} | ||
} | ||
CoolHttp.decorators = [ | ||
{ type: core_1.Injectable }, | ||
]; | ||
/** @nocollapse */ | ||
CoolHttp.ctorParameters = () => [ | ||
{ type: http_1.Http, }, | ||
]; | ||
}; | ||
return CoolHttp; | ||
}()); | ||
CoolHttp = __decorate([ | ||
core_1.Injectable(), | ||
__metadata("design:paramtypes", [http_1.Http]) | ||
], CoolHttp); | ||
exports.CoolHttp = CoolHttp; | ||
//# sourceMappingURL=./cool-http.service.js.map | ||
//# sourceMappingURL=src/cool-http.service.js.map |
@@ -1,1 +0,1 @@ | ||
[{"__symbolic":"module","version":2,"metadata":{"CoolHttp":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/http","name":"Http"}]}],"registerBaseUrl":[{"__symbolic":"method"}],"setWithCredentials":[{"__symbolic":"method"}],"registerGlobalHeader":[{"__symbolic":"method"}],"registerRequestInterceptor":[{"__symbolic":"method"}],"deregisterRequestInterceptor":[{"__symbolic":"method"}],"registerResponseInterceptor":[{"__symbolic":"method"}],"deregisterResponseInterceptor":[{"__symbolic":"method"}],"sendCookieValueInCustomHeader":[{"__symbolic":"method"}],"getAsync":[{"__symbolic":"method"}],"postAsync":[{"__symbolic":"method"}],"putAsync":[{"__symbolic":"method"}],"deleteAsync":[{"__symbolic":"method"}],"patchAsync":[{"__symbolic":"method"}],"headAsync":[{"__symbolic":"method"}],"requestCoreAsync":[{"__symbolic":"method"}],"getObservable":[{"__symbolic":"method"}],"postObservable":[{"__symbolic":"method"}],"putObservable":[{"__symbolic":"method"}],"deleteObservable":[{"__symbolic":"method"}],"patchObservable":[{"__symbolic":"method"}],"headObservable":[{"__symbolic":"method"}],"requestCoreObservable":[{"__symbolic":"method"}],"convertUrl":[{"__symbolic":"method"}],"modifyOptions":[{"__symbolic":"method"}],"appendGlobalHeaders":[{"__symbolic":"method"}],"tryAppendRegisteredCookiestoCustomHeaders":[{"__symbolic":"method"}],"invokeRequestInterceptorsAsync":[{"__symbolic":"method"}],"invokeResponseInterceptorsAsync":[{"__symbolic":"method"}],"convertAngularHeadersToHttpClientHeaders":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","metadata":{"CoolHttp":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/http","name":"Http"}]}],"registerBaseUrl":[{"__symbolic":"method"}],"setWithCredentials":[{"__symbolic":"method"}],"registerGlobalHeader":[{"__symbolic":"method"}],"registerRequestInterceptor":[{"__symbolic":"method"}],"deregisterRequestInterceptor":[{"__symbolic":"method"}],"registerResponseInterceptor":[{"__symbolic":"method"}],"deregisterResponseInterceptor":[{"__symbolic":"method"}],"sendCookieValueInCustomHeader":[{"__symbolic":"method"}],"getAsync":[{"__symbolic":"method"}],"postAsync":[{"__symbolic":"method"}],"putAsync":[{"__symbolic":"method"}],"deleteAsync":[{"__symbolic":"method"}],"patchAsync":[{"__symbolic":"method"}],"headAsync":[{"__symbolic":"method"}],"requestCoreAsync":[{"__symbolic":"method"}],"getObservable":[{"__symbolic":"method"}],"postObservable":[{"__symbolic":"method"}],"putObservable":[{"__symbolic":"method"}],"deleteObservable":[{"__symbolic":"method"}],"patchObservable":[{"__symbolic":"method"}],"headObservable":[{"__symbolic":"method"}],"requestCoreObservable":[{"__symbolic":"method"}],"convertUrl":[{"__symbolic":"method"}],"modifyOptions":[{"__symbolic":"method"}],"appendGlobalHeaders":[{"__symbolic":"method"}],"tryAppendRegisteredCookiestoCustomHeaders":[{"__symbolic":"method"}],"invokeRequestInterceptorsAsync":[{"__symbolic":"method"}],"invokeResponseInterceptorsAsync":[{"__symbolic":"method"}],"convertAngularHeadersToHttpClientHeaders":[{"__symbolic":"method"}]}}},"version":1}] | ||
[{"__symbolic":"module","version":3,"metadata":{"CoolHttp":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/http","name":"Http"}]}],"registerBaseUrl":[{"__symbolic":"method"}],"setWithCredentials":[{"__symbolic":"method"}],"registerGlobalHeader":[{"__symbolic":"method"}],"registerRequestInterceptor":[{"__symbolic":"method"}],"deregisterRequestInterceptor":[{"__symbolic":"method"}],"registerResponseInterceptor":[{"__symbolic":"method"}],"deregisterResponseInterceptor":[{"__symbolic":"method"}],"sendCookieValueInCustomHeader":[{"__symbolic":"method"}],"getAsync":[{"__symbolic":"method"}],"postAsync":[{"__symbolic":"method"}],"putAsync":[{"__symbolic":"method"}],"deleteAsync":[{"__symbolic":"method"}],"patchAsync":[{"__symbolic":"method"}],"headAsync":[{"__symbolic":"method"}],"requestCoreAsync":[{"__symbolic":"method"}],"getObservable":[{"__symbolic":"method"}],"postObservable":[{"__symbolic":"method"}],"putObservable":[{"__symbolic":"method"}],"deleteObservable":[{"__symbolic":"method"}],"patchObservable":[{"__symbolic":"method"}],"headObservable":[{"__symbolic":"method"}],"requestCoreObservable":[{"__symbolic":"method"}],"convertUrl":[{"__symbolic":"method"}],"modifyOptions":[{"__symbolic":"method"}],"appendGlobalHeaders":[{"__symbolic":"method"}],"tryAppendRegisteredCookiestoCustomHeaders":[{"__symbolic":"method"}],"invokeRequestInterceptorsAsync":[{"__symbolic":"method"}],"invokeResponseInterceptorsAsync":[{"__symbolic":"method"}],"convertAngularHeadersToHttpClientHeaders":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"CoolHttp":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/http","name":"Http"}]}],"registerBaseUrl":[{"__symbolic":"method"}],"setWithCredentials":[{"__symbolic":"method"}],"registerGlobalHeader":[{"__symbolic":"method"}],"registerRequestInterceptor":[{"__symbolic":"method"}],"deregisterRequestInterceptor":[{"__symbolic":"method"}],"registerResponseInterceptor":[{"__symbolic":"method"}],"deregisterResponseInterceptor":[{"__symbolic":"method"}],"sendCookieValueInCustomHeader":[{"__symbolic":"method"}],"getAsync":[{"__symbolic":"method"}],"postAsync":[{"__symbolic":"method"}],"putAsync":[{"__symbolic":"method"}],"deleteAsync":[{"__symbolic":"method"}],"patchAsync":[{"__symbolic":"method"}],"headAsync":[{"__symbolic":"method"}],"requestCoreAsync":[{"__symbolic":"method"}],"getObservable":[{"__symbolic":"method"}],"postObservable":[{"__symbolic":"method"}],"putObservable":[{"__symbolic":"method"}],"deleteObservable":[{"__symbolic":"method"}],"patchObservable":[{"__symbolic":"method"}],"headObservable":[{"__symbolic":"method"}],"requestCoreObservable":[{"__symbolic":"method"}],"convertUrl":[{"__symbolic":"method"}],"modifyOptions":[{"__symbolic":"method"}],"appendGlobalHeaders":[{"__symbolic":"method"}],"tryAppendRegisteredCookiestoCustomHeaders":[{"__symbolic":"method"}],"invokeRequestInterceptorsAsync":[{"__symbolic":"method"}],"invokeResponseInterceptorsAsync":[{"__symbolic":"method"}],"convertAngularHeadersToHttpClientHeaders":[{"__symbolic":"method"}]}}}}] |
"use strict"; | ||
class HttpHeader { | ||
constructor(key, value) { | ||
var HttpHeader = (function () { | ||
function HttpHeader(key, value) { | ||
this.key = key; | ||
this.value = value; | ||
} | ||
} | ||
return HttpHeader; | ||
}()); | ||
exports.HttpHeader = HttpHeader; | ||
//# sourceMappingURL=./http-header.model.js.map | ||
//# sourceMappingURL=src/http-header.model.js.map |
@@ -1,1 +0,1 @@ | ||
[{"__symbolic":"module","version":2,"metadata":{"HttpHeader":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"string"}]}]}}}},{"__symbolic":"module","metadata":{"HttpHeader":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"string"}]}]}}},"version":1}] | ||
[{"__symbolic":"module","version":3,"metadata":{"HttpHeader":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"string"}]}]}}}},{"__symbolic":"module","version":1,"metadata":{"HttpHeader":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"string"}]}]}}}}] |
"use strict"; | ||
//# sourceMappingURL=./request-interceptor.interface.js.map | ||
//# sourceMappingURL=src/request-interceptor.interface.js.map |
"use strict"; | ||
//# sourceMappingURL=./response-interceptor.interface.js.map | ||
//# sourceMappingURL=src/response-interceptor.interface.js.map |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
62465
534
1
+ Added@angular/common@2.4.4(transitive)
+ Added@angular/core@2.4.4(transitive)
+ Added@angular/http@2.4.4(transitive)
+ Added@angular/platform-browser@2.4.4(transitive)
- Removed@angular/common@2.3.0(transitive)
- Removed@angular/core@2.3.0(transitive)
- Removed@angular/http@2.3.0(transitive)
- Removed@angular/platform-browser@2.3.0(transitive)
- Removedrxjs@5.0.0-rc.4(transitive)
- Removedsymbol-observable@1.2.0(transitive)
Updated@angular/core@2.4.4
Updated@angular/http@2.4.4
Updatedrxjs@^5.0.3