@grandlinex/swagger-mate 1.3.3 → 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.
- package/dist/cjs/Swagger/Client/SwaggerClient.d.ts +0 -3
- package/dist/cjs/Swagger/Client/SwaggerClient.js +5 -38
- package/dist/cjs/index.d.ts +0 -1
- package/dist/cjs/index.js +0 -1
- package/dist/mjs/Swagger/Client/SwaggerClient.d.ts +0 -3
- package/dist/mjs/Swagger/Client/SwaggerClient.js +5 -38
- package/dist/mjs/index.d.ts +0 -1
- package/dist/mjs/index.js +0 -1
- package/package.json +7 -7
- package/res/templates/class/ApiCon.ts +1 -1
- package/res/templates/class/CApiCon.ts +1 -1
- package/res/templates/class/IApiCon.ts +1 -1
- package/res/templates/class/index.ts +2 -3
- package/dist/cjs/Swagger/debug/BaseCon.d.ts +0 -172
- package/dist/cjs/Swagger/debug/BaseCon.js +0 -380
- package/dist/cjs/Swagger/debug/FetchCon.d.ts +0 -3
- package/dist/cjs/Swagger/debug/FetchCon.js +0 -79
- package/dist/cjs/Swagger/debug/NodeCon.d.ts +0 -3
- package/dist/cjs/Swagger/debug/NodeCon.js +0 -158
- package/dist/cjs/Swagger/debug/index.d.ts +0 -5
- package/dist/cjs/Swagger/debug/index.js +0 -27
- package/dist/mjs/Swagger/debug/BaseCon.d.ts +0 -172
- package/dist/mjs/Swagger/debug/BaseCon.js +0 -373
- package/dist/mjs/Swagger/debug/FetchCon.d.ts +0 -3
- package/dist/mjs/Swagger/debug/FetchCon.js +0 -77
- package/dist/mjs/Swagger/debug/NodeCon.d.ts +0 -3
- package/dist/mjs/Swagger/debug/NodeCon.js +0 -120
- package/dist/mjs/Swagger/debug/index.d.ts +0 -5
- package/dist/mjs/Swagger/debug/index.js +0 -5
- package/res/templates/class/AxiosCon.ts +0 -49
- package/res/templates/class/BaseCon.ts +0 -476
- package/res/templates/class/FetchCon.ts +0 -93
- 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
|
|
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'),
|
|
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,
|
|
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
|
|
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);
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ 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';
|
package/dist/cjs/index.js
CHANGED
|
@@ -25,7 +25,6 @@ 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);
|
|
@@ -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
|
|
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'),
|
|
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,
|
|
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
|
|
165
|
+
buildCon(conf);
|
|
199
166
|
createPackage(name, version, module);
|
|
200
167
|
if (writeMeta || writeMeta === undefined) {
|
|
201
168
|
SwaggerUtil.writeMeta(conf, 'JSON', baseR);
|
package/dist/mjs/index.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ 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';
|
package/dist/mjs/index.js
CHANGED
|
@@ -2,7 +2,6 @@ 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';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grandlinex/swagger-mate",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.5",
|
|
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
|
-
"
|
|
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": "
|
|
30
|
-
"run-dev": "
|
|
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": "
|
|
33
|
-
"test-coverage": "
|
|
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": {
|
|
@@ -47,6 +46,7 @@
|
|
|
47
46
|
"form-data": ">=4.0.5"
|
|
48
47
|
},
|
|
49
48
|
"devDependencies": {
|
|
49
|
+
"@grandlinex/base-con": "1.0.0",
|
|
50
50
|
"axios": "1.13.2",
|
|
51
51
|
"node-fetch": "3.3.2",
|
|
52
52
|
"cross-env": "10.0.0",
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* DO NOT EDIT THIS FILE
|
|
4
4
|
*/
|
|
5
5
|
import * as TX from './ApiTypes.js';
|
|
6
|
-
import BaseCon,
|
|
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{
|
|
@@ -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,172 +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
|
-
constructor(conf: {
|
|
59
|
-
con: ConHandle;
|
|
60
|
-
endpoint: string;
|
|
61
|
-
logger?: (arg: any) => void;
|
|
62
|
-
});
|
|
63
|
-
/**
|
|
64
|
-
* Retrieves the API endpoint.
|
|
65
|
-
*
|
|
66
|
-
* @return {string} The API endpoint string.
|
|
67
|
-
*/
|
|
68
|
-
getApiEndpoint(): string;
|
|
69
|
-
/**
|
|
70
|
-
* Sets the API endpoint URL used by the client.
|
|
71
|
-
*
|
|
72
|
-
* @param {string} endpoint - The full URL of the API endpoint.
|
|
73
|
-
* @returns {void}
|
|
74
|
-
*/
|
|
75
|
-
setApiEndpoint(endpoint: string): void;
|
|
76
|
-
/**
|
|
77
|
-
* Indicates whether the instance is considered connected.
|
|
78
|
-
*
|
|
79
|
-
* The instance is regarded as connected when it either does not require authentication
|
|
80
|
-
* (`noAuth` is true) or it has an authorization token set (`authorization` is not null),
|
|
81
|
-
* and it is not currently marked as disconnected.
|
|
82
|
-
*
|
|
83
|
-
* @return {boolean} `true` if the instance is connected, `false` otherwise.
|
|
84
|
-
*/
|
|
85
|
-
isConnected(): boolean;
|
|
86
|
-
/**
|
|
87
|
-
* Returns the current authorization token.
|
|
88
|
-
*
|
|
89
|
-
* @return {string} The authorization token or an empty string if none is set.
|
|
90
|
-
*/
|
|
91
|
-
token(): string;
|
|
92
|
-
private p;
|
|
93
|
-
/**
|
|
94
|
-
* Sends a ping request to the API to verify connectivity and version availability.
|
|
95
|
-
*
|
|
96
|
-
* @return {boolean} `true` if the API responded with a 200 status code and a valid version object; `false` otherwise.
|
|
97
|
-
*/
|
|
98
|
-
ping(): Promise<boolean>;
|
|
99
|
-
/**
|
|
100
|
-
* Validates the current authentication token by performing a ping and a test request
|
|
101
|
-
* to the backend. The method first ensures connectivity via {@link ping}. If the ping
|
|
102
|
-
* succeeds, it attempts to retrieve a token from the `/test/auth` endpoint using the
|
|
103
|
-
* current token in the `Authorization` header. The operation is considered successful
|
|
104
|
-
* if the response status code is 200 or 201.
|
|
105
|
-
*
|
|
106
|
-
* If any step fails, an error is logged and the method returns {@code false}. On
|
|
107
|
-
* success, it returns {@code true}.
|
|
108
|
-
*
|
|
109
|
-
* @return {Promise<boolean>} A promise that resolves to {@code true} if the token
|
|
110
|
-
* test succeeds, otherwise {@code false}.
|
|
111
|
-
*/
|
|
112
|
-
testToken(): Promise<boolean>;
|
|
113
|
-
/**
|
|
114
|
-
* Attempts to establish a connection to the backend without authentication.
|
|
115
|
-
*
|
|
116
|
-
* This method sends a ping request. If the ping succeeds, it clears any
|
|
117
|
-
* existing authorization data, marks the instance as connected,
|
|
118
|
-
* enables the no‑authentication mode, and returns `true`. If the ping
|
|
119
|
-
* fails, it logs a warning, clears authorization, marks the instance
|
|
120
|
-
* as disconnected, and returns `false`.
|
|
121
|
-
*
|
|
122
|
-
* @return {Promise<boolean>} `true` when a connection is successfully
|
|
123
|
-
* established without authentication, otherwise `false`.
|
|
124
|
-
*/
|
|
125
|
-
connectNoAuth(): Promise<boolean>;
|
|
126
|
-
/**
|
|
127
|
-
* Forces a connection using the provided bearer token.
|
|
128
|
-
*
|
|
129
|
-
* @param {string} token The token to be used for authentication.
|
|
130
|
-
* @returns {void}
|
|
131
|
-
*/
|
|
132
|
-
forceConnectWithToken(token: string): void;
|
|
133
|
-
/**
|
|
134
|
-
* Establishes a connection to the backend using the supplied credentials.
|
|
135
|
-
* Performs a health‑check ping first; if successful, it requests an authentication
|
|
136
|
-
* token from the `/token` endpoint. When the token is obtained, the method
|
|
137
|
-
* updates internal state (authorization header, connection flags) and, unless
|
|
138
|
-
* a dry run is requested, sets up a reconnection routine. Any errors are
|
|
139
|
-
* logged and the method resolves to `false`.
|
|
140
|
-
*
|
|
141
|
-
* @param {string} email - The user's email address for authentication.
|
|
142
|
-
* @param {string} pw - The password (or token) for the specified user.
|
|
143
|
-
* @param {boolean} [dry=false] - If `true`, the method performs a dry run
|
|
144
|
-
* without persisting credentials or configuring reconnection logic.
|
|
145
|
-
*
|
|
146
|
-
* @returns Promise<boolean> `true` if the connection was successfully
|
|
147
|
-
* established, otherwise `false`.
|
|
148
|
-
*/
|
|
149
|
-
connect(email: string, pw: string, dry?: boolean): Promise<boolean>;
|
|
150
|
-
/**
|
|
151
|
-
* Performs an HTTP request using the client’s internal connection.
|
|
152
|
-
*
|
|
153
|
-
* The method verifies that the client is connected before attempting a request.
|
|
154
|
-
* It automatically injects the authorization token, permanent headers, and any
|
|
155
|
-
* headers supplied in `config`. If the request body is a `FormData` instance
|
|
156
|
-
* (or provides a `getHeaders` method), the appropriate form headers are added.
|
|
157
|
-
*
|
|
158
|
-
* Response handling:
|
|
159
|
-
* - `200` or `201`: returns `success: true` with the received data.
|
|
160
|
-
* - `498`: attempts to reconnect and retries the request once.
|
|
161
|
-
* - `401`: logs an authentication error, marks the client as disconnected.
|
|
162
|
-
* - `403` and other status codes: return `success: false` with the status code.
|
|
163
|
-
*
|
|
164
|
-
* @param {'POST'|'GET'|'PATCH'|'DELETE'} type The HTTP method to use.
|
|
165
|
-
* @param {string} path The endpoint path relative to the base URL.
|
|
166
|
-
* @param {J} [body] Optional request payload. May be `FormData` or a plain object.
|
|
167
|
-
* @param {ConHandleConfig} [config] Optional Axios-like configuration for the request.
|
|
168
|
-
* @returns {Promise<HandleRes<T>>} A promise that resolves to a `HandleRes` object
|
|
169
|
-
* containing the response data, status code, any error information, and headers.
|
|
170
|
-
*/
|
|
171
|
-
handle<T, J>(type: 'POST' | 'GET' | 'PATCH' | 'DELETE', path: string, body?: J, config?: ConHandleConfig): Promise<HandleRes<T>>;
|
|
172
|
-
}
|