@targetprocess/yaft-meta-client 0.3.0 → 0.3.1-alpha.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@targetprocess/yaft-meta-client",
3
- "version": "0.3.0",
3
+ "version": "0.3.1-alpha.1",
4
4
  "description": "Client for yaft-meta service",
5
5
  "keywords": [
6
6
  "yaft"
@@ -22,10 +22,10 @@
22
22
  },
23
23
  "devDependencies": {
24
24
  "nswag": "^13.8.2",
25
- "typescript": "^4.0.0"
25
+ "typescript": "~4.4.4"
26
26
  },
27
27
  "publishConfig": {
28
28
  "access": "public"
29
29
  },
30
- "gitHead": "26e890ce1a5074d9534f91ddb955de278628fb20"
30
+ "gitHead": "895c2f9b75e64cebcf6da3c1512797844c424bcd"
31
31
  }
@@ -1,93 +0,0 @@
1
- export interface IYaftMetaClient {
2
- /**
3
- * Get feature toggles meta
4
- * @param clusterName Cluster name
5
- * @return Successful response
6
- */
7
- getFtMeta(clusterName: string): Promise<FtMeta[]>;
8
- /**
9
- * Update feature toggles meta
10
- * @param clusterName Cluster name
11
- * @return Successful response
12
- */
13
- createOrUpdateFtMeta(payload: FtMeta[], clusterName: string): Promise<FtMeta[]>;
14
- }
15
- export declare class YaftMetaClient implements IYaftMetaClient {
16
- private http;
17
- private baseUrl;
18
- protected jsonParseReviver: ((key: string, value: any) => any) | undefined;
19
- constructor(baseUrl?: string, http?: {
20
- fetch(url: RequestInfo, init?: RequestInit): Promise<Response>;
21
- });
22
- /**
23
- * Get feature toggles meta
24
- * @param clusterName Cluster name
25
- * @return Successful response
26
- */
27
- getFtMeta(clusterName: string): Promise<FtMeta[]>;
28
- protected processGetFtMeta(response: Response): Promise<FtMeta[]>;
29
- /**
30
- * Update feature toggles meta
31
- * @param clusterName Cluster name
32
- * @return Successful response
33
- */
34
- createOrUpdateFtMeta(payload: FtMeta[], clusterName: string): Promise<FtMeta[]>;
35
- protected processCreateOrUpdateFtMeta(response: Response): Promise<FtMeta[]>;
36
- }
37
- export interface ErrorDto {
38
- /** Error message */
39
- message: string;
40
- }
41
- /** Cluster identifier */
42
- export interface ClusterRef {
43
- /** Cluster name */
44
- name: string;
45
- }
46
- export interface App {
47
- /** Application name */
48
- name: string;
49
- /** Application version */
50
- version?: string | undefined;
51
- }
52
- export interface FeatureToggle {
53
- /** Feature toggle name (must be unique) */
54
- name: string;
55
- /** Feature toggle human-readable description */
56
- description?: string | undefined;
57
- /** Array of tags specifying FT type (business/tech) or domain (metrics/rules/SSO/etc) */
58
- tags?: string[] | undefined;
59
- /** Alternative name of feature toggle */
60
- alias?: string | undefined;
61
- /** Responsible team name */
62
- responsibleTeam?: string | undefined;
63
- /** Planned date of feature toggle removal */
64
- validBefore?: Date | undefined;
65
- /** Default feature toggle value that is set from code/app config. If no value is provided it is treated as false */
66
- defaultValue?: boolean | undefined;
67
- /** Ids of related US/bug/feature in Plan TP */
68
- entityIds?: number[] | undefined;
69
- }
70
- /** Feature toggle metadata */
71
- export interface FtMeta extends FeatureToggle {
72
- /** Cluster reference */
73
- cluster: ClusterRef;
74
- /** Application that owns this feature toggle */
75
- app: App;
76
- /** Date of feature toggle introduction */
77
- validSince: Date;
78
- }
79
- export declare class ApiException extends Error {
80
- message: string;
81
- status: number;
82
- response: string;
83
- headers: {
84
- [key: string]: any;
85
- };
86
- result: any;
87
- constructor(message: string, status: number, response: string, headers: {
88
- [key: string]: any;
89
- }, result: any);
90
- protected isApiException: boolean;
91
- static isApiException(obj: any): obj is ApiException;
92
- }
93
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,eAAe;IAC5B;;;;OAIG;IACH,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAClD;;;;OAIG;IAC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 @@
1
- "use strict";
2
- /* tslint:disable */
3
- /* eslint-disable */
4
- //----------------------
5
- // <auto-generated>
6
- // Generated using the NSwag toolchain v13.8.2.0 (NJsonSchema v10.2.1.0 (Newtonsoft.Json v11.0.0.0)) (http://NSwag.org)
7
- // </auto-generated>
8
- //----------------------
9
- // ReSharper disable InconsistentNaming
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.ApiException = exports.YaftMetaClient = void 0;
12
- class YaftMetaClient {
13
- constructor(baseUrl, http) {
14
- this.jsonParseReviver = undefined;
15
- this.http = http ? http : window;
16
- this.baseUrl = baseUrl !== undefined && baseUrl !== null ? baseUrl : "";
17
- }
18
- /**
19
- * Get feature toggles meta
20
- * @param clusterName Cluster name
21
- * @return Successful response
22
- */
23
- getFtMeta(clusterName) {
24
- let url_ = this.baseUrl + "/meta/{clusterName}";
25
- if (clusterName === undefined || clusterName === null)
26
- throw new Error("The parameter 'clusterName' must be defined.");
27
- url_ = url_.replace("{clusterName}", encodeURIComponent("" + clusterName));
28
- url_ = url_.replace(/[?&]$/, "");
29
- let options_ = {
30
- method: "GET",
31
- headers: {
32
- "Accept": "application/json"
33
- }
34
- };
35
- return this.http.fetch(url_, options_).then((_response) => {
36
- return this.processGetFtMeta(_response);
37
- });
38
- }
39
- processGetFtMeta(response) {
40
- const status = response.status;
41
- let _headers = {};
42
- if (response.headers && response.headers.forEach) {
43
- response.headers.forEach((v, k) => _headers[k] = v);
44
- }
45
- ;
46
- if (status === 200) {
47
- return response.text().then((_responseText) => {
48
- let result200 = null;
49
- result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
50
- return result200;
51
- });
52
- }
53
- else if (status === 400) {
54
- return response.text().then((_responseText) => {
55
- let result400 = null;
56
- result400 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
57
- return throwException("Validation failed", status, _responseText, _headers, result400);
58
- });
59
- }
60
- else if (status === 401) {
61
- return response.text().then((_responseText) => {
62
- let result401 = null;
63
- result401 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
64
- return throwException("Unauthorized", status, _responseText, _headers, result401);
65
- });
66
- }
67
- else if (status === 403) {
68
- return response.text().then((_responseText) => {
69
- let result403 = null;
70
- result403 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
71
- return throwException("Forbidden", status, _responseText, _headers, result403);
72
- });
73
- }
74
- else if (status === 404) {
75
- return response.text().then((_responseText) => {
76
- let result404 = null;
77
- result404 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
78
- return throwException("Not found", status, _responseText, _headers, result404);
79
- });
80
- }
81
- else if (status === 500) {
82
- return response.text().then((_responseText) => {
83
- let result500 = null;
84
- result500 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
85
- return throwException("General error", status, _responseText, _headers, result500);
86
- });
87
- }
88
- else if (status !== 200 && status !== 204) {
89
- return response.text().then((_responseText) => {
90
- return throwException("An unexpected server error occurred.", status, _responseText, _headers);
91
- });
92
- }
93
- return Promise.resolve(null);
94
- }
95
- /**
96
- * Update feature toggles meta
97
- * @param clusterName Cluster name
98
- * @return Successful response
99
- */
100
- createOrUpdateFtMeta(payload, clusterName) {
101
- let url_ = this.baseUrl + "/meta/{clusterName}";
102
- if (clusterName === undefined || clusterName === null)
103
- throw new Error("The parameter 'clusterName' must be defined.");
104
- url_ = url_.replace("{clusterName}", encodeURIComponent("" + clusterName));
105
- url_ = url_.replace(/[?&]$/, "");
106
- const content_ = JSON.stringify(payload);
107
- let options_ = {
108
- body: content_,
109
- method: "PUT",
110
- headers: {
111
- "Content-Type": "application/json",
112
- "Accept": "application/json"
113
- }
114
- };
115
- return this.http.fetch(url_, options_).then((_response) => {
116
- return this.processCreateOrUpdateFtMeta(_response);
117
- });
118
- }
119
- processCreateOrUpdateFtMeta(response) {
120
- const status = response.status;
121
- let _headers = {};
122
- if (response.headers && response.headers.forEach) {
123
- response.headers.forEach((v, k) => _headers[k] = v);
124
- }
125
- ;
126
- if (status === 200) {
127
- return response.text().then((_responseText) => {
128
- let result200 = null;
129
- result200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
130
- return result200;
131
- });
132
- }
133
- else if (status === 400) {
134
- return response.text().then((_responseText) => {
135
- let result400 = null;
136
- result400 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
137
- return throwException("Validation failed", status, _responseText, _headers, result400);
138
- });
139
- }
140
- else if (status === 401) {
141
- return response.text().then((_responseText) => {
142
- let result401 = null;
143
- result401 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
144
- return throwException("Unauthorized", status, _responseText, _headers, result401);
145
- });
146
- }
147
- else if (status === 403) {
148
- return response.text().then((_responseText) => {
149
- let result403 = null;
150
- result403 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
151
- return throwException("Forbidden", status, _responseText, _headers, result403);
152
- });
153
- }
154
- else if (status === 404) {
155
- return response.text().then((_responseText) => {
156
- let result404 = null;
157
- result404 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
158
- return throwException("Not found", status, _responseText, _headers, result404);
159
- });
160
- }
161
- else if (status === 500) {
162
- return response.text().then((_responseText) => {
163
- let result500 = null;
164
- result500 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
165
- return throwException("General error", status, _responseText, _headers, result500);
166
- });
167
- }
168
- else if (status !== 200 && status !== 204) {
169
- return response.text().then((_responseText) => {
170
- return throwException("An unexpected server error occurred.", status, _responseText, _headers);
171
- });
172
- }
173
- return Promise.resolve(null);
174
- }
175
- }
176
- exports.YaftMetaClient = YaftMetaClient;
177
- class ApiException extends Error {
178
- constructor(message, status, response, headers, result) {
179
- super();
180
- this.isApiException = true;
181
- this.message = message;
182
- this.status = status;
183
- this.response = response;
184
- this.headers = headers;
185
- this.result = result;
186
- }
187
- static isApiException(obj) {
188
- return obj.isApiException === true;
189
- }
190
- }
191
- exports.ApiException = ApiException;
192
- function throwException(message, status, response, headers, result) {
193
- if (result !== null && result !== undefined)
194
- throw result;
195
- else
196
- throw new ApiException(message, status, response, headers, null);
197
- }