@grandlinex/swagger-mate 1.3.4 → 1.3.6

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 +1 -1
  4. package/dist/cjs/index.js +1 -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 +1 -1
  8. package/dist/mjs/index.js +1 -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,5 +1,4 @@
1
1
  import { SwaggerConfig } from '../Meta/SwaggerTypes.js';
2
- type Excludes = ('NodeCon' | 'FetchCon' | 'AxiosCon')[];
3
2
  export default class SwaggerClient {
4
3
  static genAPICConnector(options: {
5
4
  conf: SwaggerConfig;
@@ -7,7 +6,5 @@ export default class SwaggerClient {
7
6
  version?: string;
8
7
  writeMeta?: boolean;
9
8
  module?: boolean;
10
- exclude?: Excludes;
11
9
  }): void;
12
10
  }
13
- export {};
@@ -136,37 +136,13 @@ function interfaceHandler(conf) {
136
136
  }
137
137
  return interfaceList.join('\n');
138
138
  }
139
- function indexHelper(template, exclude) {
140
- const exportList = [
141
- 'ApiCon',
142
- 'BaseCon',
143
- 'CApiCon',
144
- 'IApiCon',
145
- 'FormData',
146
- ];
147
- const lines = [...template.split('\n')];
148
- if (!exclude || !exclude.includes('NodeCon')) {
149
- lines.push(`import NodeCon from './NodeCon.js';`);
150
- exportList.push('NodeCon');
151
- }
152
- if (!exclude || !exclude.includes('FetchCon')) {
153
- lines.push(`import FetchCon from './FetchCon.js';`);
154
- exportList.push('FetchCon');
155
- }
156
- if (!exclude || !exclude.includes('AxiosCon')) {
157
- lines.push(`import AxiosCon from './AxiosCon.js';`);
158
- exportList.push('AxiosCon');
159
- }
160
- lines.push(`export { ${exportList.join(', ')} };`);
161
- return lines.join('\n');
162
- }
163
- function buildCon(conf, exclude) {
139
+ function buildCon(conf) {
164
140
  const template = (0, PathHelp_js_1.default)((0, PathHelp_js_1.getBaseFolder)(), '..', 'res', 'templates');
165
141
  const funcTemo = fs.readFileSync(Path.join(template, 'class', 'ApiCon.ts'), 'utf-8');
166
142
  const indexTemp = fs.readFileSync(Path.join(template, 'class', 'index.ts'), 'utf-8');
167
143
  const ifTemp = fs.readFileSync(Path.join(template, 'class', 'IApiCon.ts'), 'utf-8');
168
144
  const cTemp = fs.readFileSync(Path.join(template, 'class', 'CApiCon.ts'), 'utf-8');
169
- fs.writeFileSync(Path.join(baseGen, 'index.ts'), indexHelper(indexTemp, exclude));
145
+ fs.writeFileSync(Path.join(baseGen, 'index.ts'), indexTemp);
170
146
  fs.writeFileSync(Path.join(baseGen, 'ApiTypes.ts'), interfaceHandler(conf));
171
147
  const [con, iCon, cCon] = insertHandler(conf, [funcTemo, ifTemp, cTemp]);
172
148
  fs.writeFileSync(Path.join(baseGen, 'ApiCon.ts'), con);
@@ -186,6 +162,7 @@ function createPackage(name, version, module) {
186
162
  typescript: '5.9.2',
187
163
  },
188
164
  peerDependencies: {
165
+ '@grandlinex/base-con': '1.0.0',
189
166
  axios: '>=1.13.2',
190
167
  'form-data': '>=4.0.5',
191
168
  },
@@ -219,21 +196,11 @@ function createPackage(name, version, module) {
219
196
  }
220
197
  class SwaggerClient {
221
198
  static genAPICConnector(options) {
222
- const { name, version, writeMeta, module, exclude, conf } = options;
199
+ const { name, version, writeMeta, module, conf } = options;
223
200
  const template = (0, PathHelp_js_1.default)((0, PathHelp_js_1.getBaseFolder)(), '..', 'res', 'templates');
224
201
  core_1.XUtil.createFolderBulk(baseR, baseGen);
225
- cp(Path.join(template, 'class'), 'BaseCon.ts');
226
- if (!exclude || !exclude.includes('FetchCon')) {
227
- cp(Path.join(template, 'class'), 'FetchCon.ts');
228
- }
229
- if (!exclude || !exclude.includes('NodeCon')) {
230
- cp(Path.join(template, 'class'), 'NodeCon.ts');
231
- }
232
- if (!exclude || !exclude.includes('AxiosCon')) {
233
- cp(Path.join(template, 'class'), 'AxiosCon.ts');
234
- }
235
202
  cp(Path.join(template, 'class'), 'index.ts');
236
- buildCon(conf, exclude);
203
+ buildCon(conf);
237
204
  createPackage(name, version, module);
238
205
  if (writeMeta || writeMeta === undefined) {
239
206
  SwaggerUtil_js_1.default.writeMeta(conf, 'JSON', baseR);
@@ -2,9 +2,9 @@ import SwaggerUtil from './Swagger/SwaggerUtil.js';
2
2
  import SPathUtil from './Swagger/Path/SPathUtil.js';
3
3
  import SwaggerClient from './Swagger/Client/SwaggerClient.js';
4
4
  export * from './Swagger/Path/ESchemaEditor.js';
5
- export * from './Swagger/debug/index.js';
6
5
  export * from './Swagger/annotation/index.js';
7
6
  export * from './Swagger/Meta/Swagger.js';
8
7
  export * from './Swagger/Meta/SwaggerTypes.js';
9
8
  export * from './Swagger/Meta/SwaggerTypesStatic.js';
9
+ export * from '@grandlinex/base-con';
10
10
  export { SwaggerUtil, SPathUtil, SwaggerClient };
package/dist/cjs/index.js CHANGED
@@ -25,8 +25,8 @@ exports.SPathUtil = SPathUtil_js_1.default;
25
25
  const SwaggerClient_js_1 = __importDefault(require("./Swagger/Client/SwaggerClient.js"));
26
26
  exports.SwaggerClient = SwaggerClient_js_1.default;
27
27
  __exportStar(require("./Swagger/Path/ESchemaEditor.js"), exports);
28
- __exportStar(require("./Swagger/debug/index.js"), exports);
29
28
  __exportStar(require("./Swagger/annotation/index.js"), exports);
30
29
  __exportStar(require("./Swagger/Meta/Swagger.js"), exports);
31
30
  __exportStar(require("./Swagger/Meta/SwaggerTypes.js"), exports);
32
31
  __exportStar(require("./Swagger/Meta/SwaggerTypesStatic.js"), exports);
32
+ __exportStar(require("@grandlinex/base-con"), exports);
@@ -1,5 +1,4 @@
1
1
  import { SwaggerConfig } from '../Meta/SwaggerTypes.js';
2
- type Excludes = ('NodeCon' | 'FetchCon' | 'AxiosCon')[];
3
2
  export default class SwaggerClient {
4
3
  static genAPICConnector(options: {
5
4
  conf: SwaggerConfig;
@@ -7,7 +6,5 @@ export default class SwaggerClient {
7
6
  version?: string;
8
7
  writeMeta?: boolean;
9
8
  module?: boolean;
10
- exclude?: Excludes;
11
9
  }): void;
12
10
  }
13
- export {};
@@ -98,37 +98,13 @@ function interfaceHandler(conf) {
98
98
  }
99
99
  return interfaceList.join('\n');
100
100
  }
101
- function indexHelper(template, exclude) {
102
- const exportList = [
103
- 'ApiCon',
104
- 'BaseCon',
105
- 'CApiCon',
106
- 'IApiCon',
107
- 'FormData',
108
- ];
109
- const lines = [...template.split('\n')];
110
- if (!exclude || !exclude.includes('NodeCon')) {
111
- lines.push(`import NodeCon from './NodeCon.js';`);
112
- exportList.push('NodeCon');
113
- }
114
- if (!exclude || !exclude.includes('FetchCon')) {
115
- lines.push(`import FetchCon from './FetchCon.js';`);
116
- exportList.push('FetchCon');
117
- }
118
- if (!exclude || !exclude.includes('AxiosCon')) {
119
- lines.push(`import AxiosCon from './AxiosCon.js';`);
120
- exportList.push('AxiosCon');
121
- }
122
- lines.push(`export { ${exportList.join(', ')} };`);
123
- return lines.join('\n');
124
- }
125
- function buildCon(conf, exclude) {
101
+ function buildCon(conf) {
126
102
  const template = PathHelp(getBaseFolder(), '..', 'res', 'templates');
127
103
  const funcTemo = fs.readFileSync(Path.join(template, 'class', 'ApiCon.ts'), 'utf-8');
128
104
  const indexTemp = fs.readFileSync(Path.join(template, 'class', 'index.ts'), 'utf-8');
129
105
  const ifTemp = fs.readFileSync(Path.join(template, 'class', 'IApiCon.ts'), 'utf-8');
130
106
  const cTemp = fs.readFileSync(Path.join(template, 'class', 'CApiCon.ts'), 'utf-8');
131
- fs.writeFileSync(Path.join(baseGen, 'index.ts'), indexHelper(indexTemp, exclude));
107
+ fs.writeFileSync(Path.join(baseGen, 'index.ts'), indexTemp);
132
108
  fs.writeFileSync(Path.join(baseGen, 'ApiTypes.ts'), interfaceHandler(conf));
133
109
  const [con, iCon, cCon] = insertHandler(conf, [funcTemo, ifTemp, cTemp]);
134
110
  fs.writeFileSync(Path.join(baseGen, 'ApiCon.ts'), con);
@@ -148,6 +124,7 @@ function createPackage(name, version, module) {
148
124
  typescript: '5.9.2',
149
125
  },
150
126
  peerDependencies: {
127
+ '@grandlinex/base-con': '1.0.0',
151
128
  axios: '>=1.13.2',
152
129
  'form-data': '>=4.0.5',
153
130
  },
@@ -181,21 +158,11 @@ function createPackage(name, version, module) {
181
158
  }
182
159
  export default class SwaggerClient {
183
160
  static genAPICConnector(options) {
184
- const { name, version, writeMeta, module, exclude, conf } = options;
161
+ const { name, version, writeMeta, module, conf } = options;
185
162
  const template = PathHelp(getBaseFolder(), '..', 'res', 'templates');
186
163
  XUtil.createFolderBulk(baseR, baseGen);
187
- cp(Path.join(template, 'class'), 'BaseCon.ts');
188
- if (!exclude || !exclude.includes('FetchCon')) {
189
- cp(Path.join(template, 'class'), 'FetchCon.ts');
190
- }
191
- if (!exclude || !exclude.includes('NodeCon')) {
192
- cp(Path.join(template, 'class'), 'NodeCon.ts');
193
- }
194
- if (!exclude || !exclude.includes('AxiosCon')) {
195
- cp(Path.join(template, 'class'), 'AxiosCon.ts');
196
- }
197
164
  cp(Path.join(template, 'class'), 'index.ts');
198
- buildCon(conf, exclude);
165
+ buildCon(conf);
199
166
  createPackage(name, version, module);
200
167
  if (writeMeta || writeMeta === undefined) {
201
168
  SwaggerUtil.writeMeta(conf, 'JSON', baseR);
@@ -2,9 +2,9 @@ import SwaggerUtil from './Swagger/SwaggerUtil.js';
2
2
  import SPathUtil from './Swagger/Path/SPathUtil.js';
3
3
  import SwaggerClient from './Swagger/Client/SwaggerClient.js';
4
4
  export * from './Swagger/Path/ESchemaEditor.js';
5
- export * from './Swagger/debug/index.js';
6
5
  export * from './Swagger/annotation/index.js';
7
6
  export * from './Swagger/Meta/Swagger.js';
8
7
  export * from './Swagger/Meta/SwaggerTypes.js';
9
8
  export * from './Swagger/Meta/SwaggerTypesStatic.js';
9
+ export * from '@grandlinex/base-con';
10
10
  export { SwaggerUtil, SPathUtil, SwaggerClient };
package/dist/mjs/index.js CHANGED
@@ -2,9 +2,9 @@ import SwaggerUtil from './Swagger/SwaggerUtil.js';
2
2
  import SPathUtil from './Swagger/Path/SPathUtil.js';
3
3
  import SwaggerClient from './Swagger/Client/SwaggerClient.js';
4
4
  export * from './Swagger/Path/ESchemaEditor.js';
5
- export * from './Swagger/debug/index.js';
6
5
  export * from './Swagger/annotation/index.js';
7
6
  export * from './Swagger/Meta/Swagger.js';
8
7
  export * from './Swagger/Meta/SwaggerTypes.js';
9
8
  export * from './Swagger/Meta/SwaggerTypesStatic.js';
9
+ export * from '@grandlinex/base-con';
10
10
  export { SwaggerUtil, SPathUtil, SwaggerClient };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grandlinex/swagger-mate",
3
- "version": "1.3.4",
3
+ "version": "1.3.6",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -19,18 +19,17 @@
19
19
  "module": "dist/mjs/index.js",
20
20
  "description": "GrandLineX Swagger-Mate Project",
21
21
  "scripts": {
22
- "pre-build": "node ./preBuild.js",
23
- "buildprep": "npm run pre-build && npm run build-mjs && npm run build-cjs && npm run build-fix",
22
+ "buildprep": "npm run build-mjs && npm run build-cjs && npm run build-fix",
24
23
  "build-mjs": "tsc",
25
24
  "build-cjs": "tsc -p tsconfig-cjs.json",
26
25
  "build-fix": "node ./node_modules/@grandlinex/core/fix.js",
27
26
  "pack": "npm run buildprep && npm pack",
28
27
  "start": "node dist/cjs/run.js",
29
- "start-dev": "npm run pre-build && cross-env dev=true ts-node src/run.ts",
30
- "run-dev": "npm run pre-build && cross-env dev=true node --no-warnings=ExperimentalWarning --loader ts-node/esm src/tests/run.ts",
28
+ "start-dev": "cross-env dev=true ts-node src/run.ts",
29
+ "run-dev": "cross-env dev=true node --no-warnings=ExperimentalWarning --loader ts-node/esm src/tests/run.ts",
31
30
  "lint": "eslint src",
32
- "test": "npm run pre-build && cross-env dev=true jest --runInBand ",
33
- "test-coverage": "npm run pre-build && cross-env dev=true jest --runInBand --ci --collectCoverage --coverageDirectory=\"./coverage\" --reporters=default --reporters=jest-junit",
31
+ "test": "cross-env dev=true jest --runInBand ",
32
+ "test-coverage": "cross-env dev=true jest --runInBand --ci --collectCoverage --coverageDirectory=\"./coverage\" --reporters=default --reporters=jest-junit",
34
33
  "makeDocs": "typedoc"
35
34
  },
36
35
  "bin": {
@@ -39,6 +38,7 @@
39
38
  },
40
39
  "dependencies": {
41
40
  "@grandlinex/core": "1.3.1",
41
+ "@grandlinex/base-con": "1.0.0",
42
42
  "js-yaml": "4.1.1",
43
43
  "reflect-metadata": "0.2.2"
44
44
  },
@@ -3,7 +3,7 @@
3
3
  * DO NOT EDIT THIS FILE
4
4
  */
5
5
  import * as TX from './ApiTypes.js';
6
- import BaseCon,{ HandleRes } from './BaseCon.js';
6
+ import { BaseCon, HandleRes } from '@grandlinex/base-con';
7
7
  import IApiCon from './IApiCon.js';
8
8
 
9
9
  export default class ApiCon extends BaseCon implements IApiCon{
@@ -3,7 +3,7 @@
3
3
  * DO NOT EDIT THIS FILE
4
4
  */
5
5
  import * as TX from './ApiTypes.js';
6
- import { HandleRes } from './BaseCon.js';
6
+ import { HandleRes } from '@grandlinex/base-con';
7
7
  import IApiCon from './IApiCon.js';
8
8
 
9
9
  export default abstract class CApiCon implements IApiCon{
@@ -3,7 +3,7 @@
3
3
  * DO NOT EDIT THIS FILE
4
4
  */
5
5
  import * as TX from './ApiTypes.js';
6
- import { HandleRes } from './BaseCon.js';
6
+ import { HandleRes } from '@grandlinex/base-con';
7
7
 
8
8
  export default interface IApiCon {
9
9
  /* REPLACE_ME */
@@ -4,12 +4,11 @@
4
4
  */
5
5
  import FormData from 'form-data';
6
6
  import ApiCon from './ApiCon.js';
7
- import BaseCon from './BaseCon.js';
8
7
  import CApiCon from './CApiCon.js';
9
8
  import IApiCon from './IApiCon.js';
10
9
 
11
-
12
- export * from './BaseCon.js';
10
+ export * from '@grandlinex/base-con';
13
11
  export * from './ApiTypes.js';
14
12
 
15
13
  export default ApiCon;
14
+ export {FormData, ApiCon, CApiCon, IApiCon};
@@ -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
- }