@grandlinex/swagger-mate 1.3.4 → 1.3.5

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.
Files changed (33) hide show
  1. package/dist/cjs/Swagger/Client/SwaggerClient.d.ts +0 -3
  2. package/dist/cjs/Swagger/Client/SwaggerClient.js +5 -38
  3. package/dist/cjs/index.d.ts +0 -1
  4. package/dist/cjs/index.js +0 -1
  5. package/dist/mjs/Swagger/Client/SwaggerClient.d.ts +0 -3
  6. package/dist/mjs/Swagger/Client/SwaggerClient.js +5 -38
  7. package/dist/mjs/index.d.ts +0 -1
  8. package/dist/mjs/index.js +0 -1
  9. package/package.json +7 -7
  10. package/res/templates/class/ApiCon.ts +1 -1
  11. package/res/templates/class/CApiCon.ts +1 -1
  12. package/res/templates/class/IApiCon.ts +1 -1
  13. package/res/templates/class/index.ts +2 -3
  14. package/dist/cjs/Swagger/debug/BaseCon.d.ts +0 -202
  15. package/dist/cjs/Swagger/debug/BaseCon.js +0 -432
  16. package/dist/cjs/Swagger/debug/FetchCon.d.ts +0 -3
  17. package/dist/cjs/Swagger/debug/FetchCon.js +0 -79
  18. package/dist/cjs/Swagger/debug/NodeCon.d.ts +0 -3
  19. package/dist/cjs/Swagger/debug/NodeCon.js +0 -158
  20. package/dist/cjs/Swagger/debug/index.d.ts +0 -5
  21. package/dist/cjs/Swagger/debug/index.js +0 -27
  22. package/dist/mjs/Swagger/debug/BaseCon.d.ts +0 -202
  23. package/dist/mjs/Swagger/debug/BaseCon.js +0 -425
  24. package/dist/mjs/Swagger/debug/FetchCon.d.ts +0 -3
  25. package/dist/mjs/Swagger/debug/FetchCon.js +0 -77
  26. package/dist/mjs/Swagger/debug/NodeCon.d.ts +0 -3
  27. package/dist/mjs/Swagger/debug/NodeCon.js +0 -120
  28. package/dist/mjs/Swagger/debug/index.d.ts +0 -5
  29. package/dist/mjs/Swagger/debug/index.js +0 -5
  30. package/res/templates/class/AxiosCon.ts +0 -49
  31. package/res/templates/class/BaseCon.ts +0 -533
  32. package/res/templates/class/FetchCon.ts +0 -93
  33. package/res/templates/class/NodeCon.ts +0 -172
@@ -1,27 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- var __importDefault = (this && this.__importDefault) || function (mod) {
17
- return (mod && mod.__esModule) ? mod : { "default": mod };
18
- };
19
- Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.BaseCon = exports.FetchCon = exports.NodeCon = void 0;
21
- const BaseCon_js_1 = __importDefault(require("./BaseCon.js"));
22
- exports.BaseCon = BaseCon_js_1.default;
23
- const NodeCon_js_1 = __importDefault(require("./NodeCon.js"));
24
- exports.NodeCon = NodeCon_js_1.default;
25
- const FetchCon_js_1 = __importDefault(require("./FetchCon.js"));
26
- exports.FetchCon = FetchCon_js_1.default;
27
- __exportStar(require("./BaseCon.js"), exports);
@@ -1,202 +0,0 @@
1
- /**
2
- * THIS FILE IS AUTOMATICALLY GENERATED
3
- * DO NOT EDIT THIS FILE
4
- */
5
- export type ErrorType = {
6
- type: string;
7
- global?: string[];
8
- field?: {
9
- key: string;
10
- message: string;
11
- }[];
12
- };
13
- export type HeaderType = string | string[] | number | undefined;
14
- export type HandleRes<T> = {
15
- success: boolean;
16
- data: T | null;
17
- code?: number;
18
- error?: ErrorType;
19
- headers?: Record<string, HeaderType>;
20
- };
21
- export type PathParam = {
22
- [key: string]: string | number | undefined;
23
- };
24
- export declare function isErrorType(x: any): x is ErrorType;
25
- export interface ConHandleConfig {
26
- headers?: Record<string, string>;
27
- param?: PathParam;
28
- query?: PathParam;
29
- }
30
- export interface ConHandleResponse<T> {
31
- code: number;
32
- data: T | null;
33
- headers: Record<string, HeaderType>;
34
- }
35
- export interface ConHandle {
36
- get<T>(url: string, config?: ConHandleConfig): Promise<ConHandleResponse<T>>;
37
- post<T, J>(url: string, body?: J, config?: ConHandleConfig): Promise<ConHandleResponse<T>>;
38
- patch<T, J>(url: string, body?: J, config?: ConHandleConfig): Promise<ConHandleResponse<T>>;
39
- delete<T>(url: string, config?: ConHandleConfig): Promise<ConHandleResponse<T>>;
40
- }
41
- /**
42
- * BaseCon provides a minimal client for interacting with an HTTP backend.
43
- * It manages connection state, authentication tokens, and reconnection
44
- * logic while delegating actual HTTP requests to a supplied {@link ConHandle}.
45
- *
46
- * @class
47
- */
48
- export default class BaseCon {
49
- private api;
50
- private permanentHeader;
51
- private authorization;
52
- private noAuth;
53
- private disconnected;
54
- private readonly logger;
55
- con: ConHandle;
56
- reconnect: () => Promise<boolean>;
57
- onReconnect: (con: BaseCon) => Promise<boolean>;
58
- /**
59
- * Initializes a new instance of the client.
60
- *
61
- * @param {Object} conf Configuration object.
62
- * @param {ConHandle} conf.con - Connection handle.
63
- * @param {string} conf.endpoint - API endpoint URL.
64
- * @param {(arg: any) => void} [conf.logger] - Optional logger function; defaults to console.log.
65
- * @param {Record<string, string>} [conf.permanentHeader] - Optional permanent headers to include in requests.
66
- * @return {void}
67
- */
68
- constructor(conf: {
69
- con: ConHandle;
70
- endpoint: string;
71
- logger?: (arg: any) => void;
72
- permanentHeader?: Record<string, string>;
73
- });
74
- /**
75
- * Retrieves the API endpoint.
76
- *
77
- * @return {string} The API endpoint string.
78
- */
79
- getApiEndpoint(): string;
80
- /**
81
- * Sets the API endpoint URL used by the client.
82
- *
83
- * @param {string} endpoint - The full URL of the API endpoint.
84
- * @returns {void}
85
- */
86
- setApiEndpoint(endpoint: string): void;
87
- /**
88
- * Indicates whether the instance is considered connected.
89
- *
90
- * The instance is regarded as connected when it either does not require authentication
91
- * (`noAuth` is true) or it has an authorization token set (`authorization` is not null),
92
- * and it is not currently marked as disconnected.
93
- *
94
- * @return {boolean} `true` if the instance is connected, `false` otherwise.
95
- */
96
- isConnected(): boolean;
97
- /**
98
- * Retrieves the current authorization token.
99
- *
100
- * @return {string|null} The token string used for authorization, or {@code null} if no token is set.
101
- */
102
- token(): string | null;
103
- /**
104
- * Returns the bearer token string if an authorization value has been set.
105
- *
106
- * @return {string|null} The bearer token prefixed with "Bearer ", or {@code null} when no authorization is present.
107
- */
108
- getBearer(): string | null;
109
- private p;
110
- /**
111
- * Sends a ping request to the API to verify connectivity and version availability.
112
- *
113
- * @return {boolean} `true` if the API responded with a 200 status code and a valid version object; `false` otherwise.
114
- */
115
- ping(): Promise<boolean>;
116
- /**
117
- * Builds the Authorization header for HTTP requests.
118
- *
119
- * If the instance has an authorization token, this method returns an object
120
- * containing a single `Authorization` header with the Bearer token value.
121
- * When no token is available, an empty header object is returned.
122
- *
123
- * @return {Record<string, string>} The headers object containing the
124
- * `Authorization` header when applicable, otherwise an empty object.
125
- */
126
- private tokenHeader;
127
- setPermanentHeader(header: Record<string, string>): void;
128
- /**
129
- * Validates the current authentication token by performing a ping and a test request
130
- * to the backend. The method first ensures connectivity via {@link ping}. If the ping
131
- * succeeds, it attempts to retrieve a token from the `/test/auth` endpoint using the
132
- * current token in the `Authorization` header. The operation is considered successful
133
- * if the response status code is 200 or 201.
134
- *
135
- * If any step fails, an error is logged and the method returns {@code false}. On
136
- * success, it returns {@code true}.
137
- *
138
- * @return {Promise<boolean>} A promise that resolves to {@code true} if the token
139
- * test succeeds, otherwise {@code false}.
140
- */
141
- testToken(): Promise<boolean>;
142
- /**
143
- * Attempts to establish a connection to the backend without authentication.
144
- *
145
- * This method sends a ping request. If the ping succeeds, it clears any
146
- * existing authorization data, marks the instance as connected,
147
- * enables the no‑authentication mode, and returns `true`. If the ping
148
- * fails, it logs a warning, clears authorization, marks the instance
149
- * as disconnected, and returns `false`.
150
- *
151
- * @return {Promise<boolean>} `true` when a connection is successfully
152
- * established without authentication, otherwise `false`.
153
- */
154
- connectNoAuth(): Promise<boolean>;
155
- /**
156
- * Forces a connection using the provided bearer token.
157
- *
158
- * @param {string|null} token The token to be used for authentication.
159
- * @returns {void}
160
- */
161
- forceConnect(token: string | null): void;
162
- coppyFrom(con: BaseCon): void;
163
- /**
164
- * Establishes a connection to the backend using the supplied credentials.
165
- * Performs a health‑check ping first; if successful, it requests an authentication
166
- * token from the `/token` endpoint. When the token is obtained, the method
167
- * updates internal state (authorization header, connection flags) and, unless
168
- * a dry run is requested, sets up a reconnection routine. Any errors are
169
- * logged and the method resolves to `false`.
170
- *
171
- * @param {string} email - The user's email address for authentication.
172
- * @param {string} pw - The password (or token) for the specified user.
173
- * @param {boolean} [dry=false] - If `true`, the method performs a dry run
174
- * without persisting credentials or configuring reconnection logic.
175
- *
176
- * @returns Promise<boolean> `true` if the connection was successfully
177
- * established, otherwise `false`.
178
- */
179
- connect(email: string, pw: string, dry?: boolean): Promise<boolean>;
180
- /**
181
- * Performs an HTTP request using the client’s internal connection.
182
- *
183
- * The method verifies that the client is connected before attempting a request.
184
- * It automatically injects the authorization token, permanent headers, and any
185
- * headers supplied in `config`. If the request body is a `FormData` instance
186
- * (or provides a `getHeaders` method), the appropriate form headers are added.
187
- *
188
- * Response handling:
189
- * - `200` or `201`: returns `success: true` with the received data.
190
- * - `498`: attempts to reconnect and retries the request once.
191
- * - `401`: logs an authentication error, marks the client as disconnected.
192
- * - `403` and other status codes: return `success: false` with the status code.
193
- *
194
- * @param {'POST'|'GET'|'PATCH'|'DELETE'} type The HTTP method to use.
195
- * @param {string} path The endpoint path relative to the base URL.
196
- * @param {J} [body] Optional request payload. May be `FormData` or a plain object.
197
- * @param {ConHandleConfig} [config] Optional Axios-like configuration for the request.
198
- * @returns {Promise<HandleRes<T>>} A promise that resolves to a `HandleRes` object
199
- * containing the response data, status code, any error information, and headers.
200
- */
201
- handle<T, J>(type: 'POST' | 'GET' | 'PATCH' | 'DELETE', path: string, body?: J, config?: ConHandleConfig): Promise<HandleRes<T>>;
202
- }
@@ -1,425 +0,0 @@
1
- /**
2
- * THIS FILE IS AUTOMATICALLY GENERATED
3
- * DO NOT EDIT THIS FILE
4
- */
5
- import FormData from 'form-data';
6
- export function isErrorType(x) {
7
- return x && typeof x === 'object' && x.type === 'error';
8
- }
9
- /**
10
- * BaseCon provides a minimal client for interacting with an HTTP backend.
11
- * It manages connection state, authentication tokens, and reconnection
12
- * logic while delegating actual HTTP requests to a supplied {@link ConHandle}.
13
- *
14
- * @class
15
- */
16
- export default class BaseCon {
17
- /**
18
- * Initializes a new instance of the client.
19
- *
20
- * @param {Object} conf Configuration object.
21
- * @param {ConHandle} conf.con - Connection handle.
22
- * @param {string} conf.endpoint - API endpoint URL.
23
- * @param {(arg: any) => void} [conf.logger] - Optional logger function; defaults to console.log.
24
- * @param {Record<string, string>} [conf.permanentHeader] - Optional permanent headers to include in requests.
25
- * @return {void}
26
- */
27
- constructor(conf) {
28
- this.api = conf.endpoint;
29
- this.logger = conf.logger ?? console.log;
30
- this.disconnected = true;
31
- this.noAuth = false;
32
- this.authorization = null;
33
- this.con = conf.con;
34
- this.permanentHeader = conf.permanentHeader || {};
35
- this.reconnect = async () => {
36
- this.disconnected = true;
37
- return false;
38
- };
39
- this.onReconnect = () => Promise.resolve(true);
40
- this.handle = this.handle.bind(this);
41
- }
42
- /**
43
- * Retrieves the API endpoint.
44
- *
45
- * @return {string} The API endpoint string.
46
- */
47
- getApiEndpoint() {
48
- return this.api;
49
- }
50
- /**
51
- * Sets the API endpoint URL used by the client.
52
- *
53
- * @param {string} endpoint - The full URL of the API endpoint.
54
- * @returns {void}
55
- */
56
- setApiEndpoint(endpoint) {
57
- this.api = endpoint;
58
- }
59
- /**
60
- * Indicates whether the instance is considered connected.
61
- *
62
- * The instance is regarded as connected when it either does not require authentication
63
- * (`noAuth` is true) or it has an authorization token set (`authorization` is not null),
64
- * and it is not currently marked as disconnected.
65
- *
66
- * @return {boolean} `true` if the instance is connected, `false` otherwise.
67
- */
68
- isConnected() {
69
- return (this.noAuth || this.authorization !== null) && !this.disconnected;
70
- }
71
- /**
72
- * Retrieves the current authorization token.
73
- *
74
- * @return {string|null} The token string used for authorization, or {@code null} if no token is set.
75
- */
76
- token() {
77
- return this.authorization;
78
- }
79
- /**
80
- * Returns the bearer token string if an authorization value has been set.
81
- *
82
- * @return {string|null} The bearer token prefixed with "Bearer ", or {@code null} when no authorization is present.
83
- */
84
- getBearer() {
85
- if (this.authorization) {
86
- return `Bearer ${this.authorization}`;
87
- }
88
- return null;
89
- }
90
- p(path, config) {
91
- let pp = path;
92
- if (config?.param) {
93
- const e = Object.keys(config.param);
94
- for (const d of e) {
95
- pp = pp.replace(`{${d}}`, `${config.param[d]}`);
96
- }
97
- }
98
- if (config?.query) {
99
- const e = Object.keys(config.query);
100
- const slices = [];
101
- for (const d of e) {
102
- if (config.query[d]) {
103
- slices.push(`${d}=${config.query[d]}`);
104
- }
105
- }
106
- if (slices.length > 0) {
107
- pp += `?${slices.join('&')}`;
108
- }
109
- }
110
- return `${this.api}${pp}`;
111
- }
112
- /**
113
- * Sends a ping request to the API to verify connectivity and version availability.
114
- *
115
- * @return {boolean} `true` if the API responded with a 200 status code and a valid version object; `false` otherwise.
116
- */
117
- async ping() {
118
- try {
119
- const version = await this.con.get(this.p('/version'));
120
- return version.data?.api !== undefined && version.code === 200;
121
- }
122
- catch (e) {
123
- this.logger('ping failed');
124
- return false;
125
- }
126
- }
127
- /**
128
- * Builds the Authorization header for HTTP requests.
129
- *
130
- * If the instance has an authorization token, this method returns an object
131
- * containing a single `Authorization` header with the Bearer token value.
132
- * When no token is available, an empty header object is returned.
133
- *
134
- * @return {Record<string, string>} The headers object containing the
135
- * `Authorization` header when applicable, otherwise an empty object.
136
- */
137
- tokenHeader() {
138
- if (this.authorization) {
139
- return {
140
- Authorization: this.getBearer(),
141
- };
142
- }
143
- return {};
144
- }
145
- setPermanentHeader(header) {
146
- this.permanentHeader = header;
147
- }
148
- /**
149
- * Validates the current authentication token by performing a ping and a test request
150
- * to the backend. The method first ensures connectivity via {@link ping}. If the ping
151
- * succeeds, it attempts to retrieve a token from the `/test/auth` endpoint using the
152
- * current token in the `Authorization` header. The operation is considered successful
153
- * if the response status code is 200 or 201.
154
- *
155
- * If any step fails, an error is logged and the method returns {@code false}. On
156
- * success, it returns {@code true}.
157
- *
158
- * @return {Promise<boolean>} A promise that resolves to {@code true} if the token
159
- * test succeeds, otherwise {@code false}.
160
- */
161
- async testToken() {
162
- const ping = await this.ping();
163
- if (ping) {
164
- try {
165
- const con = await this.con.get(this.p('/test/auth'), {
166
- headers: this.tokenHeader(),
167
- });
168
- return con.code === 200 || con.code === 201;
169
- }
170
- catch (e) {
171
- this.logger(e);
172
- this.logger('cant connect to backend');
173
- }
174
- }
175
- this.logger('test ping failed');
176
- return false;
177
- }
178
- /**
179
- * Attempts to establish a connection to the backend without authentication.
180
- *
181
- * This method sends a ping request. If the ping succeeds, it clears any
182
- * existing authorization data, marks the instance as connected,
183
- * enables the no‑authentication mode, and returns `true`. If the ping
184
- * fails, it logs a warning, clears authorization, marks the instance
185
- * as disconnected, and returns `false`.
186
- *
187
- * @return {Promise<boolean>} `true` when a connection is successfully
188
- * established without authentication, otherwise `false`.
189
- */
190
- async connectNoAuth() {
191
- const ping = await this.ping();
192
- if (ping) {
193
- this.authorization = null;
194
- this.disconnected = false;
195
- this.noAuth = true;
196
- return true;
197
- }
198
- this.logger('cant connect to backend');
199
- this.authorization = null;
200
- this.disconnected = true;
201
- this.noAuth = false;
202
- return false;
203
- }
204
- /**
205
- * Forces a connection using the provided bearer token.
206
- *
207
- * @param {string|null} token The token to be used for authentication.
208
- * @returns {void}
209
- */
210
- forceConnect(token) {
211
- if (token) {
212
- this.authorization = token.replace('Bearer ', '').replace('bearer ', '');
213
- }
214
- else {
215
- this.authorization = null;
216
- }
217
- this.disconnected = false;
218
- this.noAuth = token === null;
219
- }
220
- coppyFrom(con) {
221
- this.authorization = con.authorization;
222
- this.disconnected = con.disconnected;
223
- this.noAuth = con.noAuth;
224
- }
225
- /**
226
- * Establishes a connection to the backend using the supplied credentials.
227
- * Performs a health‑check ping first; if successful, it requests an authentication
228
- * token from the `/token` endpoint. When the token is obtained, the method
229
- * updates internal state (authorization header, connection flags) and, unless
230
- * a dry run is requested, sets up a reconnection routine. Any errors are
231
- * logged and the method resolves to `false`.
232
- *
233
- * @param {string} email - The user's email address for authentication.
234
- * @param {string} pw - The password (or token) for the specified user.
235
- * @param {boolean} [dry=false] - If `true`, the method performs a dry run
236
- * without persisting credentials or configuring reconnection logic.
237
- *
238
- * @returns Promise<boolean> `true` if the connection was successfully
239
- * established, otherwise `false`.
240
- */
241
- async connect(email, pw, dry = false) {
242
- const ping = await this.ping();
243
- if (ping) {
244
- try {
245
- const token = await this.con.post(this.p('/token'), {
246
- username: email,
247
- token: pw,
248
- });
249
- if (token.code === 200 || token.code === 201) {
250
- if (!dry) {
251
- this.authorization = token.data.token;
252
- this.disconnected = false;
253
- this.noAuth = false;
254
- this.reconnect = async () => {
255
- return ((await this.connect(email, pw)) && (await this.testToken()));
256
- };
257
- }
258
- return true;
259
- }
260
- }
261
- catch (e) {
262
- this.logger(e);
263
- }
264
- }
265
- this.logger('cant connect to backend');
266
- this.authorization = null;
267
- this.disconnected = true;
268
- this.noAuth = false;
269
- return false;
270
- }
271
- /**
272
- * Performs an HTTP request using the client’s internal connection.
273
- *
274
- * The method verifies that the client is connected before attempting a request.
275
- * It automatically injects the authorization token, permanent headers, and any
276
- * headers supplied in `config`. If the request body is a `FormData` instance
277
- * (or provides a `getHeaders` method), the appropriate form headers are added.
278
- *
279
- * Response handling:
280
- * - `200` or `201`: returns `success: true` with the received data.
281
- * - `498`: attempts to reconnect and retries the request once.
282
- * - `401`: logs an authentication error, marks the client as disconnected.
283
- * - `403` and other status codes: return `success: false` with the status code.
284
- *
285
- * @param {'POST'|'GET'|'PATCH'|'DELETE'} type The HTTP method to use.
286
- * @param {string} path The endpoint path relative to the base URL.
287
- * @param {J} [body] Optional request payload. May be `FormData` or a plain object.
288
- * @param {ConHandleConfig} [config] Optional Axios-like configuration for the request.
289
- * @returns {Promise<HandleRes<T>>} A promise that resolves to a `HandleRes` object
290
- * containing the response data, status code, any error information, and headers.
291
- */
292
- async handle(type, path, body, config) {
293
- if (!this.isConnected()) {
294
- this.logger('Disconnected');
295
- return {
296
- success: false,
297
- data: null,
298
- code: -1,
299
- };
300
- }
301
- let formHeader = null;
302
- const cK = body;
303
- if (cK &&
304
- (cK instanceof FormData || typeof cK?.getHeaders === 'function')) {
305
- formHeader = cK?.getHeaders?.() || {};
306
- }
307
- else {
308
- formHeader = {};
309
- }
310
- let dat;
311
- switch (type) {
312
- case 'GET':
313
- dat = await this.con.get(this.p(path, config), {
314
- ...config,
315
- headers: {
316
- ...this.tokenHeader(),
317
- ...formHeader,
318
- ...config?.headers,
319
- ...this.permanentHeader,
320
- },
321
- });
322
- break;
323
- case 'POST':
324
- dat = await this.con.post(this.p(path, config), body, {
325
- ...config,
326
- headers: {
327
- ...this.tokenHeader(),
328
- ...formHeader,
329
- ...config?.headers,
330
- ...this.permanentHeader,
331
- },
332
- });
333
- break;
334
- case 'PATCH':
335
- dat = await this.con.patch(this.p(path, config), body, {
336
- ...config,
337
- headers: {
338
- ...this.tokenHeader(),
339
- ...formHeader,
340
- ...config?.headers,
341
- ...this.permanentHeader,
342
- },
343
- });
344
- break;
345
- case 'DELETE':
346
- dat = await this.con.delete(this.p(path, config), {
347
- ...config,
348
- headers: {
349
- ...this.tokenHeader(),
350
- ...formHeader,
351
- ...config?.headers,
352
- ...this.permanentHeader,
353
- },
354
- });
355
- break;
356
- default:
357
- return {
358
- success: false,
359
- data: null,
360
- code: -1,
361
- };
362
- }
363
- let error;
364
- if (isErrorType(dat.data)) {
365
- error = dat.data;
366
- }
367
- let x = false;
368
- switch (dat.code) {
369
- case 200:
370
- case 201:
371
- return {
372
- success: true,
373
- data: dat.data,
374
- code: dat.code,
375
- error,
376
- headers: dat.headers,
377
- };
378
- case 498:
379
- x = await this.reconnect();
380
- if (x) {
381
- this.onReconnect(this).catch((dx) => {
382
- this.logger(dx);
383
- });
384
- return this.handle(type, path, body, config);
385
- }
386
- this.reconnect = async () => {
387
- this.disconnected = true;
388
- return false;
389
- };
390
- this.disconnected = true;
391
- return {
392
- success: false,
393
- data: null,
394
- code: dat.code,
395
- error,
396
- headers: dat.headers,
397
- };
398
- case 401:
399
- this.logger('AUTH NOT VALID');
400
- return {
401
- success: false,
402
- data: null,
403
- code: dat.code,
404
- error,
405
- headers: dat.headers,
406
- };
407
- case 403:
408
- return {
409
- success: false,
410
- data: null,
411
- error,
412
- code: dat.code,
413
- headers: dat.headers,
414
- };
415
- default:
416
- return {
417
- success: false,
418
- data: null,
419
- error,
420
- code: dat.code,
421
- headers: dat.headers,
422
- };
423
- }
424
- }
425
- }
@@ -1,3 +0,0 @@
1
- import { ConHandle } from './BaseCon.js';
2
- declare const FetchCon: ConHandle;
3
- export default FetchCon;