op-client-api-proof-of-concept
Version:
OP Client API Proof of concept
406 lines (405 loc) • 17.2 kB
JavaScript
"use strict";
/* tslint:disable */
/* eslint-disable */
//----------------------
// <auto-generated>
// Generated using the NSwag toolchain v13.15.5.0 (NJsonSchema v10.6.6.0 (Newtonsoft.Json v12.0.0.0)) (http://NSwag.org)
// </auto-generated>
//----------------------
// ReSharper disable InconsistentNaming
var __extends = (this && this.__extends) || (function () {
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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.EntityPlatformApiException = exports.ODataQuery_1OfOfEntityAndEntityPlatformAnd_0AndCulture_neutralAndPublicKeyToken_ec022811a512dd5f = exports.Entity = exports.Keycloak = exports.AzureAd = exports.AuthenticationConfiguration = exports.EntityPlatformClient = void 0;
var EntityPlatformClient = /** @class */ (function () {
function EntityPlatformClient(baseUrl, http) {
this.jsonParseReviver = undefined;
this.http = http ? http : window;
this.baseUrl = baseUrl !== undefined && baseUrl !== null ? baseUrl : "https://localhost:5001";
}
/**
* Gets generic Entity list with OData Query
* @param body (optional)
* @return Entity List
*/
EntityPlatformClient.prototype.entities = function (applicationName, entityDefinitionName, body) {
var _this = this;
var url_ = this.baseUrl + "/api/Entities/{applicationName}/{entityDefinitionName}";
if (applicationName === undefined || applicationName === null)
throw new Error("The parameter 'applicationName' must be defined.");
url_ = url_.replace("{applicationName}", encodeURIComponent("" + applicationName));
if (entityDefinitionName === undefined || entityDefinitionName === null)
throw new Error("The parameter 'entityDefinitionName' must be defined.");
url_ = url_.replace("{entityDefinitionName}", encodeURIComponent("" + entityDefinitionName));
url_ = url_.replace(/[?&]$/, "");
var content_ = JSON.stringify(body);
var options_ = {
body: content_,
method: "GET",
headers: {
"Content-Type": "application/json-patch+json",
"Accept": "application/json"
}
};
return this.http.fetch(url_, options_).then(function (_response) {
return _this.processEntities(_response);
});
};
EntityPlatformClient.prototype.processEntities = function (response) {
var _this = this;
var status = response.status;
var _headers = {};
if (response.headers && response.headers.forEach) {
response.headers.forEach(function (v, k) { return _headers[k] = v; });
}
;
if (status === 200) {
return response.text().then(function (_responseText) {
var result200 = null;
var resultData200 = _responseText === "" ? null : JSON.parse(_responseText, _this.jsonParseReviver);
if (Array.isArray(resultData200)) {
result200 = [];
for (var _i = 0, resultData200_1 = resultData200; _i < resultData200_1.length; _i++) {
var item = resultData200_1[_i];
result200.push(Entity.fromJS(item));
}
}
else {
result200 = null;
}
return result200;
});
}
else if (status === 500) {
return response.text().then(function (_responseText) {
return throwException("Oops! We do not plan this to ever happen", status, _responseText, _headers);
});
}
else if (status !== 200 && status !== 204) {
return response.text().then(function (_responseText) {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
});
}
return Promise.resolve(null);
};
/**
* Gets Platform state.
* @return State values
*/
EntityPlatformClient.prototype.state = function () {
var _this = this;
var url_ = this.baseUrl + "/api/EntityPlatform/State";
url_ = url_.replace(/[?&]$/, "");
var options_ = {
method: "GET",
headers: {
"Accept": "application/json"
}
};
return this.http.fetch(url_, options_).then(function (_response) {
return _this.processState(_response);
});
};
EntityPlatformClient.prototype.processState = function (response) {
var _this = this;
var status = response.status;
var _headers = {};
if (response.headers && response.headers.forEach) {
response.headers.forEach(function (v, k) { return _headers[k] = v; });
}
;
if (status === 200) {
return response.text().then(function (_responseText) {
var result200 = null;
var resultData200 = _responseText === "" ? null : JSON.parse(_responseText, _this.jsonParseReviver);
if (resultData200) {
result200 = {};
for (var key in resultData200) {
if (resultData200.hasOwnProperty(key))
result200[key] = resultData200[key] !== undefined ? resultData200[key] : null;
}
}
else {
result200 = null;
}
return result200;
});
}
else if (status === 500) {
return response.text().then(function (_responseText) {
return throwException("Oops! We do not plan this to ever happen", status, _responseText, _headers);
});
}
else if (status !== 200 && status !== 204) {
return response.text().then(function (_responseText) {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
});
}
return Promise.resolve(null);
};
/**
* Gets the authentication configuration.
* @return Authentication configuration
*/
EntityPlatformClient.prototype.authentication = function () {
var _this = this;
var url_ = this.baseUrl + "/api/EntityPlatform/Authentication";
url_ = url_.replace(/[?&]$/, "");
var options_ = {
method: "GET",
headers: {
"Accept": "application/json"
}
};
return this.http.fetch(url_, options_).then(function (_response) {
return _this.processAuthentication(_response);
});
};
EntityPlatformClient.prototype.processAuthentication = function (response) {
var _this = this;
var status = response.status;
var _headers = {};
if (response.headers && response.headers.forEach) {
response.headers.forEach(function (v, k) { return _headers[k] = v; });
}
;
if (status === 200) {
return response.text().then(function (_responseText) {
var result200 = null;
var resultData200 = _responseText === "" ? null : JSON.parse(_responseText, _this.jsonParseReviver);
result200 = AuthenticationConfiguration.fromJS(resultData200);
return result200;
});
}
else if (status === 500) {
return response.text().then(function (_responseText) {
return throwException("Oops! We do not plan this to ever happen", status, _responseText, _headers);
});
}
else if (status !== 200 && status !== 204) {
return response.text().then(function (_responseText) {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
});
}
return Promise.resolve(null);
};
return EntityPlatformClient;
}());
exports.EntityPlatformClient = EntityPlatformClient;
var AuthenticationConfiguration = /** @class */ (function () {
function AuthenticationConfiguration(data) {
if (data) {
for (var property in data) {
if (data.hasOwnProperty(property))
this[property] = data[property];
}
}
}
AuthenticationConfiguration.prototype.init = function (_data) {
if (_data) {
this.authenticationProvider = _data["authenticationProvider"];
this.keycloak = _data["keycloak"] ? Keycloak.fromJS(_data["keycloak"]) : undefined;
this.azureAd = _data["azureAd"] ? AzureAd.fromJS(_data["azureAd"]) : undefined;
}
};
AuthenticationConfiguration.fromJS = function (data) {
data = typeof data === 'object' ? data : {};
var result = new AuthenticationConfiguration();
result.init(data);
return result;
};
AuthenticationConfiguration.prototype.toJSON = function (data) {
data = typeof data === 'object' ? data : {};
data["authenticationProvider"] = this.authenticationProvider;
data["keycloak"] = this.keycloak ? this.keycloak.toJSON() : undefined;
data["azureAd"] = this.azureAd ? this.azureAd.toJSON() : undefined;
return data;
};
return AuthenticationConfiguration;
}());
exports.AuthenticationConfiguration = AuthenticationConfiguration;
var AzureAd = /** @class */ (function () {
function AzureAd(data) {
if (data) {
for (var property in data) {
if (data.hasOwnProperty(property))
this[property] = data[property];
}
}
}
AzureAd.prototype.init = function (_data) {
if (_data) {
this.authAppName = _data["authAppName"];
this.callbackPath = _data["callbackPath"];
this.clientId = _data["clientId"];
this.domain = _data["domain"];
this.instance = _data["instance"];
this.scope = _data["scope"];
this.signedOutCallbackPath = _data["signedOutCallbackPath"];
this.tenantId = _data["tenantId"];
}
};
AzureAd.fromJS = function (data) {
data = typeof data === 'object' ? data : {};
var result = new AzureAd();
result.init(data);
return result;
};
AzureAd.prototype.toJSON = function (data) {
data = typeof data === 'object' ? data : {};
data["authAppName"] = this.authAppName;
data["callbackPath"] = this.callbackPath;
data["clientId"] = this.clientId;
data["domain"] = this.domain;
data["instance"] = this.instance;
data["scope"] = this.scope;
data["signedOutCallbackPath"] = this.signedOutCallbackPath;
data["tenantId"] = this.tenantId;
return data;
};
return AzureAd;
}());
exports.AzureAd = AzureAd;
var Keycloak = /** @class */ (function () {
function Keycloak(data) {
if (data) {
for (var property in data) {
if (data.hasOwnProperty(property))
this[property] = data[property];
}
}
}
Keycloak.prototype.init = function (_data) {
if (_data) {
this.authAppName = _data["authAppName"];
this.authority = _data["authority"];
this.clientId = _data["clientId"];
this.realmName = _data["realmName"];
if (Array.isArray(_data["validAudiences"])) {
this.validAudiences = [];
for (var _i = 0, _a = _data["validAudiences"]; _i < _a.length; _i++) {
var item = _a[_i];
this.validAudiences.push(item);
}
}
}
};
Keycloak.fromJS = function (data) {
data = typeof data === 'object' ? data : {};
var result = new Keycloak();
result.init(data);
return result;
};
Keycloak.prototype.toJSON = function (data) {
data = typeof data === 'object' ? data : {};
data["authAppName"] = this.authAppName;
data["authority"] = this.authority;
data["clientId"] = this.clientId;
data["realmName"] = this.realmName;
if (Array.isArray(this.validAudiences)) {
data["validAudiences"] = [];
for (var _i = 0, _a = this.validAudiences; _i < _a.length; _i++) {
var item = _a[_i];
data["validAudiences"].push(item);
}
}
return data;
};
return Keycloak;
}());
exports.Keycloak = Keycloak;
var Entity = /** @class */ (function () {
function Entity(data) {
if (data) {
for (var property in data) {
if (data.hasOwnProperty(property))
this[property] = data[property];
}
}
}
Entity.prototype.init = function (_data) {
if (_data) {
this.id = _data["id"];
}
};
Entity.fromJS = function (data) {
data = typeof data === 'object' ? data : {};
var result = new Entity();
result.init(data);
return result;
};
Entity.prototype.toJSON = function (data) {
data = typeof data === 'object' ? data : {};
data["id"] = this.id;
return data;
};
return Entity;
}());
exports.Entity = Entity;
var ODataQuery_1OfOfEntityAndEntityPlatformAnd_0AndCulture_neutralAndPublicKeyToken_ec022811a512dd5f = /** @class */ (function () {
function ODataQuery_1OfOfEntityAndEntityPlatformAnd_0AndCulture_neutralAndPublicKeyToken_ec022811a512dd5f(data) {
if (data) {
for (var property in data) {
if (data.hasOwnProperty(property))
this[property] = data[property];
}
}
}
ODataQuery_1OfOfEntityAndEntityPlatformAnd_0AndCulture_neutralAndPublicKeyToken_ec022811a512dd5f.prototype.init = function (_data) {
if (_data) {
this.count = _data["count"];
this.skipToken = _data["skipToken"];
}
};
ODataQuery_1OfOfEntityAndEntityPlatformAnd_0AndCulture_neutralAndPublicKeyToken_ec022811a512dd5f.fromJS = function (data) {
data = typeof data === 'object' ? data : {};
var result = new ODataQuery_1OfOfEntityAndEntityPlatformAnd_0AndCulture_neutralAndPublicKeyToken_ec022811a512dd5f();
result.init(data);
return result;
};
ODataQuery_1OfOfEntityAndEntityPlatformAnd_0AndCulture_neutralAndPublicKeyToken_ec022811a512dd5f.prototype.toJSON = function (data) {
data = typeof data === 'object' ? data : {};
data["count"] = this.count;
data["skipToken"] = this.skipToken;
return data;
};
return ODataQuery_1OfOfEntityAndEntityPlatformAnd_0AndCulture_neutralAndPublicKeyToken_ec022811a512dd5f;
}());
exports.ODataQuery_1OfOfEntityAndEntityPlatformAnd_0AndCulture_neutralAndPublicKeyToken_ec022811a512dd5f = ODataQuery_1OfOfEntityAndEntityPlatformAnd_0AndCulture_neutralAndPublicKeyToken_ec022811a512dd5f;
var EntityPlatformApiException = /** @class */ (function (_super) {
__extends(EntityPlatformApiException, _super);
function EntityPlatformApiException(message, status, response, headers, result) {
var _this = _super.call(this) || this;
_this.isApiException = true;
_this.message = message;
_this.status = status;
_this.response = response;
_this.headers = headers;
_this.result = result;
return _this;
}
EntityPlatformApiException.isApiException = function (obj) {
return obj.isApiException === true;
};
return EntityPlatformApiException;
}(Error));
exports.EntityPlatformApiException = EntityPlatformApiException;
function throwException(message, status, response, headers, result) {
if (result !== null && result !== undefined)
throw result;
else
throw new EntityPlatformApiException(message, status, response, headers, null);
}