@targetprocess/tokens-client 0.1.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/src/client.d.ts +52 -0
- package/bin/src/client.d.ts.map +1 -0
- package/bin/src/client.js +115 -0
- package/bin/src/client.js.map +1 -0
- package/package.json +15 -9
- package/CHANGELOG.md +0 -28
- package/lib/client.d.ts +0 -57
- package/lib/client.js +0 -118
- package/lib/client.js.map +0 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/*********************************************************************
|
|
2
|
+
* © Copyright IBM Corp. 2024
|
|
3
|
+
*********************************************************************/
|
|
4
|
+
export interface IClient {
|
|
5
|
+
/**
|
|
6
|
+
* Validate if this token can grant access to cluster data
|
|
7
|
+
* @param clusterName Cluster name
|
|
8
|
+
* @return Successful response
|
|
9
|
+
*/
|
|
10
|
+
validateClusterToken(token: IToken, clusterName: string): Promise<IValidationResult>;
|
|
11
|
+
}
|
|
12
|
+
export declare class Client implements IClient {
|
|
13
|
+
private http;
|
|
14
|
+
private baseUrl;
|
|
15
|
+
protected jsonParseReviver: ((key: string, value: any) => any) | undefined;
|
|
16
|
+
constructor(baseUrl?: string, http?: {
|
|
17
|
+
fetch(url: RequestInfo, init?: RequestInit): Promise<Response>;
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* Validate if this token can grant access to cluster data
|
|
21
|
+
* @param clusterName Cluster name
|
|
22
|
+
* @return Successful response
|
|
23
|
+
*/
|
|
24
|
+
validateClusterToken(token: IToken, clusterName: string): Promise<IValidationResult>;
|
|
25
|
+
protected processValidateClusterToken(response: Response): Promise<IValidationResult>;
|
|
26
|
+
}
|
|
27
|
+
export interface IToken {
|
|
28
|
+
value: string;
|
|
29
|
+
}
|
|
30
|
+
export interface IValidationResult {
|
|
31
|
+
isValid: boolean;
|
|
32
|
+
message?: string | undefined;
|
|
33
|
+
}
|
|
34
|
+
export interface IErrorDto {
|
|
35
|
+
/** Error message */
|
|
36
|
+
message: string;
|
|
37
|
+
}
|
|
38
|
+
export declare class ApiException extends Error {
|
|
39
|
+
message: string;
|
|
40
|
+
status: number;
|
|
41
|
+
response: string;
|
|
42
|
+
headers: {
|
|
43
|
+
[key: string]: any;
|
|
44
|
+
};
|
|
45
|
+
result: any;
|
|
46
|
+
constructor(message: string, status: number, response: string, headers: {
|
|
47
|
+
[key: string]: any;
|
|
48
|
+
}, result: any);
|
|
49
|
+
protected isApiException: boolean;
|
|
50
|
+
static isApiException(obj: any): obj is ApiException;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA;;uEAEuE;AAWvE,MAAM,WAAW,OAAO;IACtB;;;;OAIG;IACH,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAA;CACrF;AAED,qBAAa,MAAO,YAAW,OAAO;IACpC,OAAO,CAAC,IAAI,CAAoE;IAChF,OAAO,CAAC,OAAO,CAAQ;IACvB,SAAS,CAAC,gBAAgB,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,GAAG,CAAC,GAAG,SAAS,CAAY;gBAGpF,OAAO,CAAC,EAAE,MAAM,EAChB,IAAI,CAAC,EAAE;QAAE,KAAK,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;KAAE;IAM3E;;;;OAIG;IACH,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAuBpF,SAAS,CAAC,2BAA2B,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,iBAAiB,CAAC;CA6CtF;AAED,MAAM,WAAW,MAAM;IACrB,KAAK,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC7B;AAED,MAAM,WAAW,SAAS;IACxB,oBAAoB;IACpB,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,qBAAa,YAAa,SAAQ,KAAK;IACrC,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAA;IAC/B,MAAM,EAAE,GAAG,CAAA;gBAGT,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,EAC/B,MAAM,EAAE,GAAG;IAWb,SAAS,CAAC,cAAc,UAAO;IAE/B,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,YAAY;CAGrD"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*********************************************************************
|
|
3
|
+
* © Copyright IBM Corp. 2024
|
|
4
|
+
*********************************************************************/
|
|
5
|
+
// ----------------------
|
|
6
|
+
// <auto-generated>
|
|
7
|
+
// Generated using the NSwag toolchain v13.20.0.0 (NJsonSchema v10.9.0.0 (Newtonsoft.Json v13.0.0.0)) (http://NSwag.org)
|
|
8
|
+
// </auto-generated>
|
|
9
|
+
// ----------------------
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.ApiException = exports.Client = void 0;
|
|
12
|
+
class Client {
|
|
13
|
+
http;
|
|
14
|
+
baseUrl;
|
|
15
|
+
jsonParseReviver = undefined;
|
|
16
|
+
constructor(baseUrl, http) {
|
|
17
|
+
this.http = http ? http : window;
|
|
18
|
+
this.baseUrl = baseUrl !== undefined && baseUrl !== null ? baseUrl : '';
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Validate if this token can grant access to cluster data
|
|
22
|
+
* @param clusterName Cluster name
|
|
23
|
+
* @return Successful response
|
|
24
|
+
*/
|
|
25
|
+
validateClusterToken(token, clusterName) {
|
|
26
|
+
let url_ = this.baseUrl + '/clusters/{clusterName}/tokens/validate';
|
|
27
|
+
if (clusterName === undefined || clusterName === null)
|
|
28
|
+
throw new Error("The parameter 'clusterName' must be defined.");
|
|
29
|
+
url_ = url_.replace('{clusterName}', encodeURIComponent('' + clusterName));
|
|
30
|
+
url_ = url_.replace(/[?&]$/, '');
|
|
31
|
+
const content_ = JSON.stringify(token);
|
|
32
|
+
let options_ = {
|
|
33
|
+
body: content_,
|
|
34
|
+
method: 'POST',
|
|
35
|
+
headers: {
|
|
36
|
+
'Content-Type': 'application/json',
|
|
37
|
+
Accept: 'application/json'
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
return this.http.fetch(url_, options_).then((_response) => {
|
|
41
|
+
return this.processValidateClusterToken(_response);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
processValidateClusterToken(response) {
|
|
45
|
+
const status = response.status;
|
|
46
|
+
let _headers = {};
|
|
47
|
+
if (response.headers && response.headers.forEach) {
|
|
48
|
+
response.headers.forEach((v, k) => (_headers[k] = v));
|
|
49
|
+
}
|
|
50
|
+
if (status === 200) {
|
|
51
|
+
return response.text().then(_responseText => {
|
|
52
|
+
let result200 = null;
|
|
53
|
+
result200 =
|
|
54
|
+
_responseText === ''
|
|
55
|
+
? null
|
|
56
|
+
: JSON.parse(_responseText, this.jsonParseReviver);
|
|
57
|
+
return result200;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
else if (status === 401) {
|
|
61
|
+
return response.text().then(_responseText => {
|
|
62
|
+
let result401 = null;
|
|
63
|
+
result401 =
|
|
64
|
+
_responseText === ''
|
|
65
|
+
? null
|
|
66
|
+
: JSON.parse(_responseText, this.jsonParseReviver);
|
|
67
|
+
return throwException('Unauthorized', status, _responseText, _headers, result401);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
else if (status === 500) {
|
|
71
|
+
return response.text().then(_responseText => {
|
|
72
|
+
let result500 = null;
|
|
73
|
+
result500 =
|
|
74
|
+
_responseText === ''
|
|
75
|
+
? null
|
|
76
|
+
: JSON.parse(_responseText, this.jsonParseReviver);
|
|
77
|
+
return throwException('General error', status, _responseText, _headers, result500);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
else if (status !== 200 && status !== 204) {
|
|
81
|
+
return response.text().then(_responseText => {
|
|
82
|
+
return throwException('An unexpected server error occurred.', status, _responseText, _headers);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
return Promise.resolve(null);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
exports.Client = Client;
|
|
89
|
+
class ApiException extends Error {
|
|
90
|
+
message;
|
|
91
|
+
status;
|
|
92
|
+
response;
|
|
93
|
+
headers;
|
|
94
|
+
result;
|
|
95
|
+
constructor(message, status, response, headers, result) {
|
|
96
|
+
super();
|
|
97
|
+
this.message = message;
|
|
98
|
+
this.status = status;
|
|
99
|
+
this.response = response;
|
|
100
|
+
this.headers = headers;
|
|
101
|
+
this.result = result;
|
|
102
|
+
}
|
|
103
|
+
isApiException = true;
|
|
104
|
+
static isApiException(obj) {
|
|
105
|
+
return obj.isApiException === true;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
exports.ApiException = ApiException;
|
|
109
|
+
function throwException(message, status, response, headers, result) {
|
|
110
|
+
if (result !== null && result !== undefined)
|
|
111
|
+
throw result;
|
|
112
|
+
else
|
|
113
|
+
throw new ApiException(message, status, response, headers, null);
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1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AC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;IAES,cAAc,GAAG,IAAI,CAAA;IAE/B,MAAM,CAAC,cAAc,CAAC,GAAQ;QAC5B,OAAO,GAAG,CAAC,cAAc,KAAK,IAAI,CAAA;IACpC,CAAC;CACF;AA5BD,oCA4BC;AAED,SAAS,cAAc,CACrB,OAAe,EACf,MAAc,EACd,QAAgB,EAChB,OAA+B,EAC/B,MAAY;IAEZ,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,SAAS;QAAE,MAAM,MAAM,CAAA;;QACpD,MAAM,IAAI,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC,CAAA;AACvE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,27 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@targetprocess/tokens-client",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Client for the service of managing cluster tokens",
|
|
5
5
|
"files": [
|
|
6
|
-
"
|
|
6
|
+
"bin/src"
|
|
7
7
|
],
|
|
8
|
-
"main": "
|
|
9
|
-
"typings": "
|
|
8
|
+
"main": "bin/src/client.js",
|
|
9
|
+
"typings": "bin/src/client.d.ts",
|
|
10
10
|
"scripts": {
|
|
11
|
-
"generate": "npm run _clean &&
|
|
12
|
-
"
|
|
11
|
+
"generate": "npm run _clean && npm run build",
|
|
12
|
+
"rebuild": "npm run _clean && npm run build",
|
|
13
|
+
"build": "tsc -b --pretty",
|
|
14
|
+
"_clean": "rimraf bin",
|
|
15
|
+
"prepublishOnly": "npm run rebuild"
|
|
13
16
|
},
|
|
14
17
|
"keywords": [
|
|
15
18
|
"sdk"
|
|
16
19
|
],
|
|
17
20
|
"author": "Pavel Shapel <shapel@targetprocess.com>",
|
|
18
21
|
"license": "ISC",
|
|
19
|
-
"
|
|
20
|
-
"
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/node": "^22.13.1"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"cross-fetch": "3.x"
|
|
21
27
|
},
|
|
22
28
|
"repository": {
|
|
23
29
|
"type": "git",
|
|
24
|
-
"url": "https://
|
|
30
|
+
"url": "https://github.com/TargetProcess/ci-cd_octopus"
|
|
25
31
|
},
|
|
26
32
|
"publishConfig": {
|
|
27
33
|
"access": "public"
|
package/CHANGELOG.md
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
-
|
|
6
|
-
<a name="0.1.0"></a>
|
|
7
|
-
# 0.1.0 (2017-11-29)
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
### Features
|
|
11
|
-
|
|
12
|
-
* init ([4121257](https://tp.githost.io/ci-cd/octopus/commits/4121257))
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
<a name="1.0.0"></a>
|
|
18
|
-
# 1.0.0 (2017-11-28)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
<a name="1.0.0"></a>
|
|
23
|
-
# 1.0.0 (2017-11-28)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
### Features
|
|
27
|
-
|
|
28
|
-
* init ([e62b5ce](https://tp.githost.io/ci-cd/octopus/commits/e62b5ce))
|
package/lib/client.d.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
export interface IClient {
|
|
2
|
-
/**
|
|
3
|
-
* Validate if this token can grant access to cluster data
|
|
4
|
-
* @clusterName Cluster name
|
|
5
|
-
* @return Successful response
|
|
6
|
-
*/
|
|
7
|
-
validateClusterToken(token: IToken, clusterName: string): Promise<IValidationResult>
|
|
8
|
-
}
|
|
9
|
-
export declare class Client implements IClient {
|
|
10
|
-
private http
|
|
11
|
-
private baseUrl
|
|
12
|
-
protected jsonParseReviver: ((key: string, value: any) => any) | undefined
|
|
13
|
-
constructor(
|
|
14
|
-
baseUrl?: string,
|
|
15
|
-
http?: {
|
|
16
|
-
fetch(url: RequestInfo, init?: RequestInit): Promise<Response>
|
|
17
|
-
}
|
|
18
|
-
)
|
|
19
|
-
/**
|
|
20
|
-
* Validate if this token can grant access to cluster data
|
|
21
|
-
* @clusterName Cluster name
|
|
22
|
-
* @return Successful response
|
|
23
|
-
*/
|
|
24
|
-
validateClusterToken(token: IToken, clusterName: string): Promise<IValidationResult>
|
|
25
|
-
protected processValidateClusterToken(response: Response): Promise<IValidationResult>
|
|
26
|
-
}
|
|
27
|
-
export interface IToken {
|
|
28
|
-
value: string
|
|
29
|
-
}
|
|
30
|
-
export interface IValidationResult {
|
|
31
|
-
isValid: boolean
|
|
32
|
-
message?: string | undefined
|
|
33
|
-
}
|
|
34
|
-
export interface IErrorDto {
|
|
35
|
-
/** Error message */
|
|
36
|
-
message: string
|
|
37
|
-
}
|
|
38
|
-
export declare class SwaggerException extends Error {
|
|
39
|
-
message: string
|
|
40
|
-
status: number
|
|
41
|
-
response: string
|
|
42
|
-
headers: {
|
|
43
|
-
[key: string]: any
|
|
44
|
-
}
|
|
45
|
-
result: any
|
|
46
|
-
constructor(
|
|
47
|
-
message: string,
|
|
48
|
-
status: number,
|
|
49
|
-
response: string,
|
|
50
|
-
headers: {
|
|
51
|
-
[key: string]: any
|
|
52
|
-
},
|
|
53
|
-
result: any
|
|
54
|
-
)
|
|
55
|
-
protected isSwaggerException: boolean
|
|
56
|
-
static isSwaggerException(obj: any): obj is SwaggerException
|
|
57
|
-
}
|
package/lib/client.js
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/* tslint:disable */
|
|
3
|
-
//----------------------
|
|
4
|
-
// <auto-generated>
|
|
5
|
-
// Generated using the NSwag toolchain v11.11.3.0 (NJsonSchema v9.9.17.0 (Newtonsoft.Json v9.0.0.0)) (http://NSwag.org)
|
|
6
|
-
// </auto-generated>
|
|
7
|
-
//----------------------
|
|
8
|
-
// ReSharper disable InconsistentNaming
|
|
9
|
-
var __extends = (this && this.__extends) || (function () {
|
|
10
|
-
var extendStatics = Object.setPrototypeOf ||
|
|
11
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
12
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
13
|
-
return function (d, b) {
|
|
14
|
-
extendStatics(d, b);
|
|
15
|
-
function __() { this.constructor = d; }
|
|
16
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
17
|
-
};
|
|
18
|
-
})();
|
|
19
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
var Client = /** @class */ (function () {
|
|
21
|
-
function Client(baseUrl, http) {
|
|
22
|
-
this.jsonParseReviver = undefined;
|
|
23
|
-
this.http = http ? http : window;
|
|
24
|
-
this.baseUrl = baseUrl ? baseUrl : '';
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Validate if this token can grant access to cluster data
|
|
28
|
-
* @clusterName Cluster name
|
|
29
|
-
* @return Successful response
|
|
30
|
-
*/
|
|
31
|
-
Client.prototype.validateClusterToken = function (token, clusterName) {
|
|
32
|
-
var _this = this;
|
|
33
|
-
var url_ = this.baseUrl + '/clusters/{clusterName}/tokens/validate';
|
|
34
|
-
if (clusterName === undefined || clusterName === null)
|
|
35
|
-
throw new Error("The parameter 'clusterName' must be defined.");
|
|
36
|
-
url_ = url_.replace('{clusterName}', encodeURIComponent('' + clusterName));
|
|
37
|
-
url_ = url_.replace(/[?&]$/, '');
|
|
38
|
-
var content_ = JSON.stringify(token);
|
|
39
|
-
var options_ = {
|
|
40
|
-
body: content_,
|
|
41
|
-
method: 'POST',
|
|
42
|
-
headers: {
|
|
43
|
-
'Content-Type': 'application/json',
|
|
44
|
-
Accept: 'application/json'
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
return this.http.fetch(url_, options_).then(function (_response) {
|
|
48
|
-
return _this.processValidateClusterToken(_response);
|
|
49
|
-
});
|
|
50
|
-
};
|
|
51
|
-
Client.prototype.processValidateClusterToken = function (response) {
|
|
52
|
-
var _this = this;
|
|
53
|
-
var status = response.status;
|
|
54
|
-
var _headers = {};
|
|
55
|
-
if (response.headers && response.headers.forEach) {
|
|
56
|
-
response.headers.forEach(function (v, k) { return (_headers[k] = v); });
|
|
57
|
-
}
|
|
58
|
-
if (status === 200) {
|
|
59
|
-
return response.text().then(function (_responseText) {
|
|
60
|
-
var result200 = null;
|
|
61
|
-
result200 =
|
|
62
|
-
_responseText === ''
|
|
63
|
-
? null
|
|
64
|
-
: JSON.parse(_responseText, _this.jsonParseReviver);
|
|
65
|
-
return result200;
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
else if (status === 401) {
|
|
69
|
-
return response.text().then(function (_responseText) {
|
|
70
|
-
var result401 = null;
|
|
71
|
-
result401 =
|
|
72
|
-
_responseText === '' ? null : JSON.parse(_responseText, _this.jsonParseReviver);
|
|
73
|
-
return throwException('A server error occurred.', status, _responseText, _headers, result401);
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
else if (status === 500) {
|
|
77
|
-
return response.text().then(function (_responseText) {
|
|
78
|
-
var result500 = null;
|
|
79
|
-
result500 =
|
|
80
|
-
_responseText === '' ? null : JSON.parse(_responseText, _this.jsonParseReviver);
|
|
81
|
-
return throwException('A server error occurred.', status, _responseText, _headers, result500);
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
else if (status !== 200 && status !== 204) {
|
|
85
|
-
return response.text().then(function (_responseText) {
|
|
86
|
-
return throwException('An unexpected server error occurred.', status, _responseText, _headers);
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
return Promise.resolve(null);
|
|
90
|
-
};
|
|
91
|
-
return Client;
|
|
92
|
-
}());
|
|
93
|
-
exports.Client = Client;
|
|
94
|
-
var SwaggerException = /** @class */ (function (_super) {
|
|
95
|
-
__extends(SwaggerException, _super);
|
|
96
|
-
function SwaggerException(message, status, response, headers, result) {
|
|
97
|
-
var _this = _super.call(this) || this;
|
|
98
|
-
_this.isSwaggerException = true;
|
|
99
|
-
_this.message = message;
|
|
100
|
-
_this.status = status;
|
|
101
|
-
_this.response = response;
|
|
102
|
-
_this.headers = headers;
|
|
103
|
-
_this.result = result;
|
|
104
|
-
return _this;
|
|
105
|
-
}
|
|
106
|
-
SwaggerException.isSwaggerException = function (obj) {
|
|
107
|
-
return obj.isSwaggerException === true;
|
|
108
|
-
};
|
|
109
|
-
return SwaggerException;
|
|
110
|
-
}(Error));
|
|
111
|
-
exports.SwaggerException = SwaggerException;
|
|
112
|
-
function throwException(message, status, response, headers, result) {
|
|
113
|
-
if (result !== null && result !== undefined)
|
|
114
|
-
throw result;
|
|
115
|
-
else
|
|
116
|
-
throw new SwaggerException(message, status, response, headers, null);
|
|
117
|
-
}
|
|
118
|
-
//# sourceMappingURL=client.js.map
|
package/lib/client.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";AAAA,oBAAoB;AACpB,wBAAwB;AACxB,mBAAmB;AACnB,2HAA2H;AAC3H,oBAAoB;AACpB,wBAAwB;AACxB,uCAAuC;;;;;;;;;;;;AAWvC;IAKE,gBACE,OAAgB,EAChB,IAAyE;QAJjE,qBAAgB,GAAmD,SAAS,CAAA;QAMpF,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAM,MAAM,CAAA;QACrC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAA;IACvC,CAAC;IAED;;;;OAIG;IACH,qCAAoB,GAApB,UAAqB,KAAa,EAAE,WAAmB;QAAvD,iBAqBC;QApBC,IAAI,IAAI,GA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