Repository URL to install this package:
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('web-console-core'), require('@angular/core'), require('@angular/common/http')) :
typeof define === 'function' && define.amd ? define('@wa-motif-open-api/log-service', ['exports', 'web-console-core', '@angular/core', '@angular/common/http'], factory) :
(factory((global['wa-motif-open-api'] = global['wa-motif-open-api'] || {}, global['wa-motif-open-api']['log-service'] = {}),global.WebConsoleCore,global.ng.core,global.ng.common.http));
}(this, (function (exports,i2,i0,i1) { 'use strict';
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b)
if (b.hasOwnProperty(p))
d[p] = b[p]; };
return extendStatics(d, b);
};
function __extends(d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
function __values(o) {
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
if (m)
return m.call(o);
return {
next: function () {
if (o && i >= o.length)
o = void 0;
return { value: o && o[i++], done: !o };
}
};
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* CustomHttpUrlEncodingCodec
* Fix plus sign (+) not encoding, so sent as blank space
* See: https://github.com/angular/angular/issues/11058#issuecomment-247367318
*/
var /**
* CustomHttpUrlEncodingCodec
* Fix plus sign (+) not encoding, so sent as blank space
* See: https://github.com/angular/angular/issues/11058#issuecomment-247367318
*/ CustomHttpUrlEncodingCodec = /** @class */ (function (_super) {
__extends(CustomHttpUrlEncodingCodec, _super);
function CustomHttpUrlEncodingCodec() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* @param {?} k
* @return {?}
*/
CustomHttpUrlEncodingCodec.prototype.encodeKey = /**
* @param {?} k
* @return {?}
*/
function (k) {
k = _super.prototype.encodeKey.call(this, k);
return k.replace(/\+/gi, '%2B');
};
/**
* @param {?} v
* @return {?}
*/
CustomHttpUrlEncodingCodec.prototype.encodeValue = /**
* @param {?} v
* @return {?}
*/
function (v) {
v = _super.prototype.encodeValue.call(this, v);
return v.replace(/\+/gi, '%2B');
};
return CustomHttpUrlEncodingCodec;
}(i1.HttpUrlEncodingCodec));
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var Configuration = /** @class */ (function () {
function Configuration(configurationParameters) {
if (configurationParameters === void 0) {
configurationParameters = {};
}
this.apiKeys = configurationParameters.apiKeys;
this.username = configurationParameters.username;
this.password = configurationParameters.password;
this.accessToken = configurationParameters.accessToken;
this.basePath = configurationParameters.basePath;
this.withCredentials = configurationParameters.withCredentials;
}
/**
* Select the correct content-type to use for a request.
* Uses {@link Configuration#isJsonMime} to determine the correct content-type.
* If no content type is found return the first found type if the contentTypes is not empty
* @param contentTypes - the array of content types that are available for selection
* @returns the selected content-type or <code>undefined</code> if no selection could be made.
*/
/**
* Select the correct content-type to use for a request.
* Uses {\@link Configuration#isJsonMime} to determine the correct content-type.
* If no content type is found return the first found type if the contentTypes is not empty
* @param {?} contentTypes - the array of content types that are available for selection
* @return {?} the selected content-type or <code>undefined</code> if no selection could be made.
*/
Configuration.prototype.selectHeaderContentType = /**
* Select the correct content-type to use for a request.
* Uses {\@link Configuration#isJsonMime} to determine the correct content-type.
* If no content type is found return the first found type if the contentTypes is not empty
* @param {?} contentTypes - the array of content types that are available for selection
* @return {?} the selected content-type or <code>undefined</code> if no selection could be made.
*/
function (contentTypes) {
var _this = this;
if (contentTypes.length === 0) {
return undefined;
}
/** @type {?} */
var type = contentTypes.find(( /**
* @param {?} x
* @return {?}
*/function (x) { return _this.isJsonMime(x); }));
if (type === undefined) {
return contentTypes[0];
}
return type;
};
/**
* Select the correct accept content-type to use for a request.
* Uses {@link Configuration#isJsonMime} to determine the correct accept content-type.
* If no content type is found return the first found type if the contentTypes is not empty
* @param accepts - the array of content types that are available for selection.
* @returns the selected content-type or <code>undefined</code> if no selection could be made.
*/
/**
* Select the correct accept content-type to use for a request.
* Uses {\@link Configuration#isJsonMime} to determine the correct accept content-type.
* If no content type is found return the first found type if the contentTypes is not empty
* @param {?} accepts - the array of content types that are available for selection.
* @return {?} the selected content-type or <code>undefined</code> if no selection could be made.
*/
Configuration.prototype.selectHeaderAccept = /**
* Select the correct accept content-type to use for a request.
* Uses {\@link Configuration#isJsonMime} to determine the correct accept content-type.
* If no content type is found return the first found type if the contentTypes is not empty
* @param {?} accepts - the array of content types that are available for selection.
* @return {?} the selected content-type or <code>undefined</code> if no selection could be made.
*/
function (accepts) {
var _this = this;
if (accepts.length === 0) {
return undefined;
}
/** @type {?} */
var type = accepts.find(( /**
* @param {?} x
* @return {?}
*/function (x) { return _this.isJsonMime(x); }));
if (type === undefined) {
return accepts[0];
}
return type;
};
/**
* Check if the given MIME is a JSON MIME.
* JSON MIME examples:
* application/json
* application/json; charset=UTF8
* APPLICATION/JSON
* application/vnd.company+json
* @param mime - MIME (Multipurpose Internet Mail Extensions)
* @return True if the given MIME is JSON, false otherwise.
*/
/**
* Check if the given MIME is a JSON MIME.
* JSON MIME examples:
* application/json
* application/json; charset=UTF8
* APPLICATION/JSON
* application/vnd.company+json
* @param {?} mime - MIME (Multipurpose Internet Mail Extensions)
* @return {?} True if the given MIME is JSON, false otherwise.
*/
Configuration.prototype.isJsonMime = /**
* Check if the given MIME is a JSON MIME.
* JSON MIME examples:
* application/json
* application/json; charset=UTF8
* APPLICATION/JSON
* application/vnd.company+json
* @param {?} mime - MIME (Multipurpose Internet Mail Extensions)
* @return {?} True if the given MIME is JSON, false otherwise.
*/
function (mime) {
/** @type {?} */
var jsonMime = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
};
return Configuration;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var LogService = /** @class */ (function () {
function LogService(httpClient, basePath, configuration) {
this.httpClient = httpClient;
this.basePath = 'http://localhost:8080/rest/v2';
this.defaultHeaders = new i1.HttpHeaders();
this.configuration = new Configuration();
if (configuration) {
this.configuration = configuration;
this.configuration.basePath = configuration.basePath || basePath || this.basePath;
}
else {
this.configuration.basePath = basePath || this.basePath;
}
}
/**
* @param consumes string[] mime-types
* @return true: consumes contains 'multipart/form-data', false: otherwise
*/
/**
* @private
* @param {?} consumes string[] mime-types
* @return {?} true: consumes contains 'multipart/form-data', false: otherwise
*/
LogService.prototype.canConsumeForm = /**
* @private
* @param {?} consumes string[] mime-types
* @return {?} true: consumes contains 'multipart/form-data', false: otherwise
*/
function (consumes) {
var e_1, _a;
/** @type {?} */
var form = 'multipart/form-data';
try {
for (var consumes_1 = __values(consumes), consumes_1_1 = consumes_1.next(); !consumes_1_1.done; consumes_1_1 = consumes_1.next()) {
var consume = consumes_1_1.value;
if (form === consume) {
return true;
}
}
}
catch (e_1_1) {
e_1 = { error: e_1_1 };
}
finally {
try {
if (consumes_1_1 && !consumes_1_1.done && (_a = consumes_1.return))
_a.call(consumes_1);
}
finally {
if (e_1)
throw e_1.error;
}
}
return false;
};
/**
* @param {?=} observe
* @param {?=} reportProgress
* @return {?}
*/
LogService.prototype.downloadCurrentLog = /**
* @param {?=} observe
* @param {?=} reportProgress
* @return {?}
*/
function (observe, reportProgress) {
if (observe === void 0) {
observe = 'body';
}
if (reportProgress === void 0) {
reportProgress = false;
}
/** @type {?} */
var headers = this.defaultHeaders;
// authentication (vipera_basic) required
if (this.configuration.username || this.configuration.password) {
headers = headers.set('Authorization', 'Basic ' + btoa(this.configuration.username + ':' + this.configuration.password));
}
// authentication (vipera_cookie) required
// authentication (vipera_oauth2) required
if (this.configuration.accessToken) {
/** @type {?} */
var accessToken = typeof this.configuration.accessToken === 'function'
? this.configuration.accessToken()
: this.configuration.accessToken;
headers = headers.set('Authorization', 'Bearer ' + accessToken);
}
// to determine the Accept header
/** @type {?} */
var httpHeaderAccepts = [
'application/zip',
'application/json'
];
/** @type {?} */
var httpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected !== undefined) {
headers = headers.set('Accept', httpHeaderAcceptSelected);
}
return this.httpClient.get(this.configuration.basePath + "/logs/current", {
responseType: "blob",
withCredentials: this.configuration.withCredentials,
headers: headers,
observe: observe,
reportProgress: reportProgress
});
};
/**
* @param {?} component
* @param {?=} observe
* @param {?=} reportProgress
* @return {?}
*/
LogService.prototype.getComponentLogLevel = /**
* @param {?} component
* @param {?=} observe
* @param {?=} reportProgress
* @return {?}
*/
function (component, observe, reportProgress) {
if (observe === void 0) {
observe = 'body';
}
if (reportProgress === void 0) {
Loading ...