jimpex 10.0.2 → 11.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/CHANGELOG.md +29 -0
- package/README.md +7 -9
- package/dist/app/index.d.ts +1 -1
- package/dist/app/index.js +1 -22
- package/dist/app/index.js.map +1 -1
- package/dist/app/jimpex.d.ts +1 -1
- package/dist/app/jimpex.js +100 -131
- package/dist/app/jimpex.js.map +1 -1
- package/dist/controllers/common/config.d.ts +2 -2
- package/dist/controllers/common/config.js +12 -39
- package/dist/controllers/common/config.js.map +1 -1
- package/dist/controllers/common/health.d.ts +4 -4
- package/dist/controllers/common/health.js +20 -47
- package/dist/controllers/common/health.js.map +1 -1
- package/dist/controllers/common/index.d.ts +1 -1
- package/dist/controllers/common/index.js +3 -26
- package/dist/controllers/common/index.js.map +1 -1
- package/dist/controllers/common/statics.d.ts +3 -3
- package/dist/controllers/common/statics.js +32 -65
- package/dist/controllers/common/statics.js.map +1 -1
- package/dist/controllers/index.d.ts +1 -1
- package/dist/controllers/index.js +2 -24
- package/dist/controllers/index.js.map +1 -1
- package/dist/controllers/utils/gateway.d.ts +5 -5
- package/dist/controllers/utils/gateway.js +70 -91
- package/dist/controllers/utils/gateway.js.map +1 -1
- package/dist/controllers/utils/index.d.ts +1 -1
- package/dist/controllers/utils/index.js +1 -22
- package/dist/controllers/utils/index.js.map +1 -1
- package/dist/{index-C6I3NCC-.d.ts → index-BlSpNHox.d.ts} +13 -13
- package/dist/index.d.ts +3 -3
- package/dist/index.js +6 -32
- package/dist/index.js.map +1 -1
- package/dist/middlewares/common/errorHandler.d.ts +5 -5
- package/dist/middlewares/common/errorHandler.js +31 -56
- package/dist/middlewares/common/errorHandler.js.map +1 -1
- package/dist/middlewares/common/forceHTTPS.d.ts +1 -1
- package/dist/middlewares/common/forceHTTPS.js +8 -35
- package/dist/middlewares/common/forceHTTPS.js.map +1 -1
- package/dist/middlewares/common/hsts.d.ts +1 -1
- package/dist/middlewares/common/hsts.js +12 -39
- package/dist/middlewares/common/hsts.js.map +1 -1
- package/dist/middlewares/common/index.d.ts +3 -3
- package/dist/middlewares/common/index.js +3 -26
- package/dist/middlewares/common/index.js.map +1 -1
- package/dist/middlewares/html/fastHTML.d.ts +4 -4
- package/dist/middlewares/html/fastHTML.js +43 -66
- package/dist/middlewares/html/fastHTML.js.map +1 -1
- package/dist/middlewares/html/index.d.ts +2 -2
- package/dist/middlewares/html/index.js +2 -24
- package/dist/middlewares/html/index.js.map +1 -1
- package/dist/middlewares/html/showHTML.d.ts +3 -3
- package/dist/middlewares/html/showHTML.js +25 -52
- package/dist/middlewares/html/showHTML.js.map +1 -1
- package/dist/middlewares/index.d.ts +4 -4
- package/dist/middlewares/index.js +3 -26
- package/dist/middlewares/index.js.map +1 -1
- package/dist/middlewares/utils/index.d.ts +3 -3
- package/dist/middlewares/utils/index.js +1 -22
- package/dist/middlewares/utils/index.js.map +1 -1
- package/dist/middlewares/utils/versionValidator.d.ts +5 -5
- package/dist/middlewares/utils/versionValidator.js +24 -51
- package/dist/middlewares/utils/versionValidator.js.map +1 -1
- package/dist/services/common/appError.d.ts +2 -2
- package/dist/services/common/appError.js +18 -46
- package/dist/services/common/appError.js.map +1 -1
- package/dist/services/common/httpError.d.ts +2 -2
- package/dist/services/common/httpError.js +7 -33
- package/dist/services/common/httpError.js.map +1 -1
- package/dist/services/common/index.d.ts +1 -1
- package/dist/services/common/index.js +14 -42
- package/dist/services/common/index.js.map +1 -1
- package/dist/services/common/sendFile.d.ts +1 -1
- package/dist/services/common/sendFile.js +4 -29
- package/dist/services/common/sendFile.js.map +1 -1
- package/dist/services/frontend/frontendFs.d.ts +2 -2
- package/dist/services/frontend/frontendFs.js +12 -49
- package/dist/services/frontend/frontendFs.js.map +1 -1
- package/dist/services/frontend/index.d.ts +2 -2
- package/dist/services/frontend/index.js +8 -34
- package/dist/services/frontend/index.js.map +1 -1
- package/dist/services/html/htmlGenerator.d.ts +5 -5
- package/dist/services/html/htmlGenerator.js +46 -75
- package/dist/services/html/htmlGenerator.js.map +1 -1
- package/dist/services/html/index.d.ts +2 -2
- package/dist/services/html/index.js +8 -34
- package/dist/services/html/index.js.map +1 -1
- package/dist/services/http/apiClient.d.ts +1 -1
- package/dist/services/http/apiClient.js +23 -48
- package/dist/services/http/apiClient.js.map +1 -1
- package/dist/services/http/http.d.ts +5 -5
- package/dist/services/http/http.js +23 -60
- package/dist/services/http/http.js.map +1 -1
- package/dist/services/http/index.d.ts +2 -2
- package/dist/services/http/index.js +14 -42
- package/dist/services/http/index.js.map +1 -1
- package/dist/services/http/responsesBuilder.d.ts +4 -4
- package/dist/services/http/responsesBuilder.js +13 -40
- package/dist/services/http/responsesBuilder.js.map +1 -1
- package/dist/services/index.d.ts +3 -3
- package/dist/services/index.js +5 -30
- package/dist/services/index.js.map +1 -1
- package/dist/services/utils/ensureBearerToken.d.ts +2 -2
- package/dist/services/utils/ensureBearerToken.js +15 -42
- package/dist/services/utils/ensureBearerToken.js.map +1 -1
- package/dist/services/utils/index.d.ts +1 -1
- package/dist/services/utils/index.js +8 -34
- package/dist/services/utils/index.js.map +1 -1
- package/dist/types/events.d.ts +1 -1
- package/dist/types/events.js +0 -16
- package/dist/types/events.js.map +1 -1
- package/dist/types/express.js +0 -16
- package/dist/types/express.js.map +1 -1
- package/dist/types/http.js +0 -16
- package/dist/types/http.js.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.js +6 -32
- package/dist/types/index.js.map +1 -1
- package/dist/types/options.d.ts +1 -1
- package/dist/types/options.js +0 -16
- package/dist/types/options.js.map +1 -1
- package/dist/types/utils.js +0 -16
- package/dist/types/utils.js.map +1 -1
- package/dist/types/wootils.js +0 -16
- package/dist/types/wootils.js.map +1 -1
- package/dist/utils/fns/index.js +4 -28
- package/dist/utils/fns/index.js.map +1 -1
- package/dist/utils/fns/others.js +2 -26
- package/dist/utils/fns/others.js.map +1 -1
- package/dist/utils/fns/routes.js +4 -31
- package/dist/utils/fns/routes.js.map +1 -1
- package/dist/utils/fns/statuses.js +3 -37
- package/dist/utils/fns/statuses.js.map +1 -1
- package/dist/utils/fns/text.js +2 -26
- package/dist/utils/fns/text.js.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +2 -24
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/wrappers.d.ts +1 -1
- package/dist/utils/wrappers.js +20 -48
- package/dist/utils/wrappers.js.map +1 -1
- package/eslint.config.js +19 -0
- package/examples/basic/app.ts +4 -4
- package/examples/basic/controller.ts +2 -2
- package/examples/basic/index.ts +4 -4
- package/examples/basic/middleware.ts +2 -2
- package/examples/basic/service.ts +1 -1
- package/package.json +61 -49
- package/pnpm-workspace.yaml +4 -0
- package/src/app/index.ts +1 -1
- package/src/app/jimpex.ts +23 -20
- package/src/controllers/common/config.ts +4 -4
- package/src/controllers/common/health.ts +9 -5
- package/src/controllers/common/index.ts +3 -3
- package/src/controllers/common/statics.ts +12 -7
- package/src/controllers/index.ts +2 -2
- package/src/controllers/utils/gateway.ts +8 -8
- package/src/controllers/utils/index.ts +1 -1
- package/src/index.ts +6 -6
- package/src/middlewares/common/errorHandler.ts +9 -5
- package/src/middlewares/common/forceHTTPS.ts +2 -2
- package/src/middlewares/common/hsts.ts +2 -2
- package/src/middlewares/common/index.ts +3 -3
- package/src/middlewares/html/fastHTML.ts +14 -5
- package/src/middlewares/html/index.ts +2 -2
- package/src/middlewares/html/showHTML.ts +8 -4
- package/src/middlewares/index.ts +3 -3
- package/src/middlewares/utils/index.ts +1 -1
- package/src/middlewares/utils/versionValidator.ts +6 -6
- package/src/services/common/appError.ts +1 -1
- package/src/services/common/httpError.ts +2 -2
- package/src/services/common/index.ts +7 -7
- package/src/services/common/sendFile.ts +2 -2
- package/src/services/frontend/frontendFs.ts +3 -3
- package/src/services/frontend/index.ts +3 -3
- package/src/services/html/htmlGenerator.ts +11 -13
- package/src/services/html/index.ts +3 -3
- package/src/services/http/apiClient.ts +3 -3
- package/src/services/http/http.ts +5 -5
- package/src/services/http/index.ts +7 -7
- package/src/services/http/responsesBuilder.ts +5 -5
- package/src/services/index.ts +5 -5
- package/src/services/utils/ensureBearerToken.ts +4 -4
- package/src/services/utils/index.ts +3 -3
- package/src/types/events.ts +8 -8
- package/src/types/http.ts +1 -1
- package/src/types/index.ts +6 -6
- package/src/types/options.ts +2 -2
- package/src/types/utils.ts +4 -4
- package/src/utils/fns/index.ts +4 -4
- package/src/utils/fns/routes.ts +1 -1
- package/src/utils/index.ts +2 -2
- package/src/utils/wrappers.ts +6 -6
- package/tsconfig.json +9 -4
- package/tsup.config.ts +1 -2
- package/vitest.config.ts +24 -0
- package/dist/app/index.d.mts +0 -14
- package/dist/app/jimpex.d.mts +0 -14
- package/dist/controllers/common/config.d.mts +0 -79
- package/dist/controllers/common/health.d.mts +0 -83
- package/dist/controllers/common/index.d.mts +0 -22
- package/dist/controllers/common/statics.d.mts +0 -223
- package/dist/controllers/index.d.mts +0 -25
- package/dist/controllers/utils/gateway.d.mts +0 -725
- package/dist/controllers/utils/index.d.mts +0 -17
- package/dist/esm/app/index.js +0 -2
- package/dist/esm/app/index.js.map +0 -1
- package/dist/esm/app/jimpex.js +0 -640
- package/dist/esm/app/jimpex.js.map +0 -1
- package/dist/esm/chunk-V6TY7KAL.js +0 -8
- package/dist/esm/chunk-V6TY7KAL.js.map +0 -1
- package/dist/esm/controllers/common/config.js +0 -80
- package/dist/esm/controllers/common/config.js.map +0 -1
- package/dist/esm/controllers/common/health.js +0 -88
- package/dist/esm/controllers/common/health.js.map +0 -1
- package/dist/esm/controllers/common/index.js +0 -4
- package/dist/esm/controllers/common/index.js.map +0 -1
- package/dist/esm/controllers/common/statics.js +0 -226
- package/dist/esm/controllers/common/statics.js.map +0 -1
- package/dist/esm/controllers/index.js +0 -3
- package/dist/esm/controllers/index.js.map +0 -1
- package/dist/esm/controllers/utils/gateway.js +0 -559
- package/dist/esm/controllers/utils/gateway.js.map +0 -1
- package/dist/esm/controllers/utils/index.js +0 -2
- package/dist/esm/controllers/utils/index.js.map +0 -1
- package/dist/esm/index.js +0 -7
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/middlewares/common/errorHandler.js +0 -116
- package/dist/esm/middlewares/common/errorHandler.js.map +0 -1
- package/dist/esm/middlewares/common/forceHTTPS.js +0 -52
- package/dist/esm/middlewares/common/forceHTTPS.js.map +0 -1
- package/dist/esm/middlewares/common/hsts.js +0 -74
- package/dist/esm/middlewares/common/hsts.js.map +0 -1
- package/dist/esm/middlewares/common/index.js +0 -4
- package/dist/esm/middlewares/common/index.js.map +0 -1
- package/dist/esm/middlewares/html/fastHTML.js +0 -157
- package/dist/esm/middlewares/html/fastHTML.js.map +0 -1
- package/dist/esm/middlewares/html/index.js +0 -3
- package/dist/esm/middlewares/html/index.js.map +0 -1
- package/dist/esm/middlewares/html/showHTML.js +0 -100
- package/dist/esm/middlewares/html/showHTML.js.map +0 -1
- package/dist/esm/middlewares/index.js +0 -4
- package/dist/esm/middlewares/index.js.map +0 -1
- package/dist/esm/middlewares/utils/index.js +0 -2
- package/dist/esm/middlewares/utils/index.js.map +0 -1
- package/dist/esm/middlewares/utils/versionValidator.js +0 -135
- package/dist/esm/middlewares/utils/versionValidator.js.map +0 -1
- package/dist/esm/services/common/appError.js +0 -98
- package/dist/esm/services/common/appError.js.map +0 -1
- package/dist/esm/services/common/httpError.js +0 -28
- package/dist/esm/services/common/httpError.js.map +0 -1
- package/dist/esm/services/common/index.js +0 -17
- package/dist/esm/services/common/index.js.map +0 -1
- package/dist/esm/services/common/sendFile.js +0 -27
- package/dist/esm/services/common/sendFile.js.map +0 -1
- package/dist/esm/services/frontend/frontendFs.js +0 -66
- package/dist/esm/services/frontend/frontendFs.js.map +0 -1
- package/dist/esm/services/frontend/index.js +0 -11
- package/dist/esm/services/frontend/index.js.map +0 -1
- package/dist/esm/services/html/htmlGenerator.js +0 -192
- package/dist/esm/services/html/htmlGenerator.js.map +0 -1
- package/dist/esm/services/html/index.js +0 -11
- package/dist/esm/services/html/index.js.map +0 -1
- package/dist/esm/services/http/apiClient.js +0 -94
- package/dist/esm/services/http/apiClient.js.map +0 -1
- package/dist/esm/services/http/http.js +0 -180
- package/dist/esm/services/http/http.js.map +0 -1
- package/dist/esm/services/http/index.js +0 -17
- package/dist/esm/services/http/index.js.map +0 -1
- package/dist/esm/services/http/responsesBuilder.js +0 -152
- package/dist/esm/services/http/responsesBuilder.js.map +0 -1
- package/dist/esm/services/index.js +0 -6
- package/dist/esm/services/index.js.map +0 -1
- package/dist/esm/services/utils/ensureBearerToken.js +0 -94
- package/dist/esm/services/utils/ensureBearerToken.js.map +0 -1
- package/dist/esm/services/utils/index.js +0 -11
- package/dist/esm/services/utils/index.js.map +0 -1
- package/dist/esm/types/events.js +0 -1
- package/dist/esm/types/events.js.map +0 -1
- package/dist/esm/types/express.js +0 -1
- package/dist/esm/types/express.js.map +0 -1
- package/dist/esm/types/http.js +0 -1
- package/dist/esm/types/http.js.map +0 -1
- package/dist/esm/types/index.js +0 -7
- package/dist/esm/types/index.js.map +0 -1
- package/dist/esm/types/options.js +0 -1
- package/dist/esm/types/options.js.map +0 -1
- package/dist/esm/types/utils.js +0 -1
- package/dist/esm/types/utils.js.map +0 -1
- package/dist/esm/types/wootils.js +0 -1
- package/dist/esm/types/wootils.js.map +0 -1
- package/dist/esm/utils/fns/index.js +0 -5
- package/dist/esm/utils/fns/index.js.map +0 -1
- package/dist/esm/utils/fns/others.js +0 -6
- package/dist/esm/utils/fns/others.js.map +0 -1
- package/dist/esm/utils/fns/routes.js +0 -25
- package/dist/esm/utils/fns/routes.js.map +0 -1
- package/dist/esm/utils/fns/statuses.js +0 -6
- package/dist/esm/utils/fns/statuses.js.map +0 -1
- package/dist/esm/utils/fns/text.js +0 -6
- package/dist/esm/utils/fns/text.js.map +0 -1
- package/dist/esm/utils/index.js +0 -3
- package/dist/esm/utils/index.js.map +0 -1
- package/dist/esm/utils/wrappers.js +0 -41
- package/dist/esm/utils/wrappers.js.map +0 -1
- package/dist/index-Bwf7JHu9.d.mts +0 -1287
- package/dist/index.d.mts +0 -47
- package/dist/middlewares/common/errorHandler.d.mts +0 -132
- package/dist/middlewares/common/forceHTTPS.d.mts +0 -69
- package/dist/middlewares/common/hsts.d.mts +0 -110
- package/dist/middlewares/common/index.d.mts +0 -22
- package/dist/middlewares/html/fastHTML.d.mts +0 -180
- package/dist/middlewares/html/index.d.mts +0 -21
- package/dist/middlewares/html/showHTML.d.mts +0 -127
- package/dist/middlewares/index.d.mts +0 -30
- package/dist/middlewares/utils/index.d.mts +0 -20
- package/dist/middlewares/utils/versionValidator.d.mts +0 -215
- package/dist/services/common/appError.d.mts +0 -139
- package/dist/services/common/httpError.d.mts +0 -80
- package/dist/services/common/index.d.mts +0 -47
- package/dist/services/common/sendFile.d.mts +0 -102
- package/dist/services/frontend/frontendFs.d.mts +0 -96
- package/dist/services/frontend/index.d.mts +0 -40
- package/dist/services/html/htmlGenerator.d.mts +0 -237
- package/dist/services/html/index.d.mts +0 -43
- package/dist/services/http/apiClient.d.mts +0 -170
- package/dist/services/http/http.d.mts +0 -182
- package/dist/services/http/index.d.mts +0 -51
- package/dist/services/http/responsesBuilder.d.mts +0 -179
- package/dist/services/index.d.mts +0 -33
- package/dist/services/utils/ensureBearerToken.d.mts +0 -158
- package/dist/services/utils/index.d.mts +0 -44
- package/dist/types/events.d.mts +0 -14
- package/dist/types/express.d.mts +0 -10
- package/dist/types/http.d.mts +0 -82
- package/dist/types/index.d.mts +0 -14
- package/dist/types/options.d.mts +0 -14
- package/dist/types/utils.d.mts +0 -48
- package/dist/types/wootils.d.mts +0 -4
- package/dist/utils/fns/index.d.mts +0 -5
- package/dist/utils/fns/others.d.mts +0 -17
- package/dist/utils/fns/routes.d.mts +0 -39
- package/dist/utils/fns/statuses.d.mts +0 -45
- package/dist/utils/fns/text.d.mts +0 -9
- package/dist/utils/index.d.mts +0 -19
- package/dist/utils/wrappers.d.mts +0 -14
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
-
import { J as Jimpex } from '../../index-Bwf7JHu9.mjs';
|
|
3
|
-
import { Response, NextFunction } from 'express';
|
|
4
|
-
import { PathUtils } from '@homer0/path-utils';
|
|
5
|
-
import '../../types/express.mjs';
|
|
6
|
-
import '../../types/http.mjs';
|
|
7
|
-
import 'https';
|
|
8
|
-
import 'http';
|
|
9
|
-
import 'spdy';
|
|
10
|
-
import 'node-fetch';
|
|
11
|
-
import '../../types/utils.mjs';
|
|
12
|
-
import '@homer0/simple-logger';
|
|
13
|
-
import '@homer0/simple-config';
|
|
14
|
-
import '@homer0/events-hub';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* The options to create a {@link SendFile} function.
|
|
18
|
-
*
|
|
19
|
-
* @group Services/SendFile
|
|
20
|
-
*/
|
|
21
|
-
type SendFileGeneratorOptions = {
|
|
22
|
-
/**
|
|
23
|
-
* A dictionary with the dependencies to inject.
|
|
24
|
-
*/
|
|
25
|
-
inject: {
|
|
26
|
-
pathUtils: PathUtils;
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* The options for the function that actually serves a file.
|
|
31
|
-
*
|
|
32
|
-
* @group Services/SendFile
|
|
33
|
-
*/
|
|
34
|
-
type SendFileOptions = {
|
|
35
|
-
/**
|
|
36
|
-
* The response object sent by the application. Necessary to write the file.
|
|
37
|
-
*/
|
|
38
|
-
res: Response;
|
|
39
|
-
/**
|
|
40
|
-
* The path of the file to serve. Depending on the `from` option, it will be either
|
|
41
|
-
* relative to the project root, or the application executable.
|
|
42
|
-
*/
|
|
43
|
-
filepath: string;
|
|
44
|
-
/**
|
|
45
|
-
* The name of a location on the `pathUtils` service from where the `filepath` is
|
|
46
|
-
* relative to. It can be `app` for the directory containing the application executable,
|
|
47
|
-
* or `project` for the project root. It could also be any other location that the
|
|
48
|
-
* implementation may have registered.
|
|
49
|
-
*
|
|
50
|
-
* @default 'app'
|
|
51
|
-
*/
|
|
52
|
-
from?: string;
|
|
53
|
-
/**
|
|
54
|
-
* The function to move to the next middleware. It can be used to report an error in
|
|
55
|
-
* case the file can't be served.
|
|
56
|
-
*
|
|
57
|
-
* @default {() => {}}
|
|
58
|
-
*/
|
|
59
|
-
next?: NextFunction;
|
|
60
|
-
};
|
|
61
|
-
/**
|
|
62
|
-
* The type of the function that serves a file.
|
|
63
|
-
* This is exported to make it easy to type the dependency injection.
|
|
64
|
-
*
|
|
65
|
-
* @group Services/SendFile
|
|
66
|
-
*/
|
|
67
|
-
type SendFile = (options: SendFileOptions) => void;
|
|
68
|
-
/**
|
|
69
|
-
* Generates a function to send files on the application response.
|
|
70
|
-
*
|
|
71
|
-
* @param options To inject the required dependencies.
|
|
72
|
-
* @example
|
|
73
|
-
*
|
|
74
|
-
* <caption>Basic usage</caption>
|
|
75
|
-
*
|
|
76
|
-
* // Let's say this is inside an Express middleware.
|
|
77
|
-
* // Get the function
|
|
78
|
-
* const send = sendFile(pathUtils);
|
|
79
|
-
* send({ res, filepath: 'some-file.html', next });
|
|
80
|
-
* // If your app is on "/app/index.js", this will send "/app/some-file.html".
|
|
81
|
-
*
|
|
82
|
-
* @group Services
|
|
83
|
-
* @group Services/SendFile
|
|
84
|
-
*/
|
|
85
|
-
declare const sendFile: ({ inject: { pathUtils } }: SendFileGeneratorOptions) => SendFile;
|
|
86
|
-
/**
|
|
87
|
-
* The service provider that once registered on the container will set the result of
|
|
88
|
-
* {@link sendFile} as the `sendFile` service.
|
|
89
|
-
*
|
|
90
|
-
* @example
|
|
91
|
-
*
|
|
92
|
-
* // Register it on the container
|
|
93
|
-
* container.register(sendFileProvider);
|
|
94
|
-
* // Getting access to the service instance
|
|
95
|
-
* const sendFile = container.get<SendFile>('sendFile');
|
|
96
|
-
*
|
|
97
|
-
* @group Providers
|
|
98
|
-
* @group Services/SendFile
|
|
99
|
-
*/
|
|
100
|
-
declare const sendFileProvider: _homer0_jimple.Resource<"provider", "register", _homer0_jimple.ProviderRegisterFn<Jimpex>>;
|
|
101
|
-
|
|
102
|
-
export { type SendFile, type SendFileGeneratorOptions, type SendFileOptions, sendFile, sendFileProvider };
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
-
import { J as Jimpex } from '../../index-Bwf7JHu9.mjs';
|
|
3
|
-
import { PathUtils } from '@homer0/path-utils';
|
|
4
|
-
import fs from 'fs/promises';
|
|
5
|
-
import '../../types/express.mjs';
|
|
6
|
-
import 'express';
|
|
7
|
-
import '../../types/http.mjs';
|
|
8
|
-
import 'https';
|
|
9
|
-
import 'http';
|
|
10
|
-
import 'spdy';
|
|
11
|
-
import 'node-fetch';
|
|
12
|
-
import '../../types/utils.mjs';
|
|
13
|
-
import '@homer0/simple-logger';
|
|
14
|
-
import '@homer0/simple-config';
|
|
15
|
-
import '@homer0/events-hub';
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* The options to construct a {@link FrontendFs}.
|
|
19
|
-
*
|
|
20
|
-
* @group Services/FrontendFs
|
|
21
|
-
*/
|
|
22
|
-
type FrontendFsOptions = {
|
|
23
|
-
/**
|
|
24
|
-
* A dictionary with the dependencies to inject.
|
|
25
|
-
*/
|
|
26
|
-
inject: {
|
|
27
|
-
pathUtils: PathUtils;
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* This service allows the application to easily work with the filesystem. The idea behind
|
|
32
|
-
* centralizing this functionalities into a service is that is pretty common to have
|
|
33
|
-
* bundling tools to generate the frontend, and on that process files can have different
|
|
34
|
-
* paths or not even be generated all. The service can be extended/overwritten to
|
|
35
|
-
* accommodate any requirements and avoid having to update or add `if`s to every `fs` call
|
|
36
|
-
* the application does.
|
|
37
|
-
* Another _'feature'_ of this service is that all the paths are relative to the directory
|
|
38
|
-
* where the app executable is located, so you don't have to remember the relative path
|
|
39
|
-
* from the place you are accessing a file to the place where it's located.
|
|
40
|
-
*
|
|
41
|
-
* @group Services
|
|
42
|
-
* @group Services/FrontendFs
|
|
43
|
-
*/
|
|
44
|
-
declare class FrontendFs {
|
|
45
|
-
/**
|
|
46
|
-
* The service that generates the relative paths.
|
|
47
|
-
*/
|
|
48
|
-
protected readonly _pathUtils: PathUtils;
|
|
49
|
-
/**
|
|
50
|
-
* @param options The options to construct the service.
|
|
51
|
-
*/
|
|
52
|
-
constructor({ inject: { pathUtils } }: FrontendFsOptions);
|
|
53
|
-
/**
|
|
54
|
-
* Deletes a file from the file system.
|
|
55
|
-
*
|
|
56
|
-
* @param filepath The path to the file.
|
|
57
|
-
*/
|
|
58
|
-
delete(filepath: string): Promise<void>;
|
|
59
|
-
/**
|
|
60
|
-
* Reads a file from the file system.
|
|
61
|
-
*
|
|
62
|
-
* @param filepath The path to the file.
|
|
63
|
-
* @param encoding The text encoding in which the file should be read.
|
|
64
|
-
*/
|
|
65
|
-
read(filepath: string, encoding?: BufferEncoding): Promise<string>;
|
|
66
|
-
/**
|
|
67
|
-
* Writes a file on the file system.
|
|
68
|
-
*
|
|
69
|
-
* @param filepath The path to the file.
|
|
70
|
-
* @param content The contents of the file.
|
|
71
|
-
*/
|
|
72
|
-
write(filepath: string, content: Parameters<typeof fs.writeFile>[1]): Promise<void>;
|
|
73
|
-
/**
|
|
74
|
-
* Utility method to get the path of a file relative to the application executable.
|
|
75
|
-
*
|
|
76
|
-
* @param filepath The path to the file.
|
|
77
|
-
*/
|
|
78
|
-
protected getAppPath(filepath: string): string;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* The service provider that once registered on the container will set an instance of
|
|
82
|
-
* {@link FrontendFs} as the `frontendFs` service.
|
|
83
|
-
*
|
|
84
|
-
* @example
|
|
85
|
-
*
|
|
86
|
-
* // Register it on the container
|
|
87
|
-
* container.register(frontendFsProvider);
|
|
88
|
-
* // Getting access to the service instance
|
|
89
|
-
* const frontendFs = container.get<FrontendFs>('frontendFs');
|
|
90
|
-
*
|
|
91
|
-
* @group Providers
|
|
92
|
-
* @group Services/FrontendFs
|
|
93
|
-
*/
|
|
94
|
-
declare const frontendFsProvider: _homer0_jimple.Resource<"provider", "register", _homer0_jimple.ProviderRegisterFn<Jimpex>>;
|
|
95
|
-
|
|
96
|
-
export { FrontendFs, type FrontendFsOptions, frontendFsProvider };
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
-
import { J as Jimpex } from '../../index-Bwf7JHu9.mjs';
|
|
3
|
-
export { FrontendFs, FrontendFsOptions, frontendFsProvider } from './frontendFs.mjs';
|
|
4
|
-
import '../../types/express.mjs';
|
|
5
|
-
import 'express';
|
|
6
|
-
import '../../types/http.mjs';
|
|
7
|
-
import 'https';
|
|
8
|
-
import 'http';
|
|
9
|
-
import 'spdy';
|
|
10
|
-
import 'node-fetch';
|
|
11
|
-
import '../../types/utils.mjs';
|
|
12
|
-
import '@homer0/path-utils';
|
|
13
|
-
import '@homer0/simple-logger';
|
|
14
|
-
import '@homer0/simple-config';
|
|
15
|
-
import '@homer0/events-hub';
|
|
16
|
-
import 'fs/promises';
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Registers all the frontend services on the container.
|
|
20
|
-
*
|
|
21
|
-
* - {@link FrontendFs | frontendFs}
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
*
|
|
25
|
-
* // Register the collection on the container
|
|
26
|
-
* container.register(frontendServicesProvider);
|
|
27
|
-
* // Getting access to one the services instance
|
|
28
|
-
* const frontendFs = container.get<FrontendFs>('frontendFs');
|
|
29
|
-
*
|
|
30
|
-
* @group Providers
|
|
31
|
-
*/
|
|
32
|
-
declare const frontendServicesProvider: {
|
|
33
|
-
frontendFsProvider: _homer0_jimple.Resource<"provider", "register", _homer0_jimple.ProviderRegisterFn<Jimpex>>;
|
|
34
|
-
} & Record<string, _homer0_jimple.Resource<"provider", "register", _homer0_jimple.ProviderRegisterFn<Jimpex>>> & {
|
|
35
|
-
provider: true;
|
|
36
|
-
} & {
|
|
37
|
-
register: _homer0_jimple.ProviderRegisterFn<Jimpex>;
|
|
38
|
-
} & Record<string, unknown>;
|
|
39
|
-
|
|
40
|
-
export { frontendServicesProvider };
|
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
-
import { J as Jimpex } from '../../index-Bwf7JHu9.mjs';
|
|
3
|
-
import { SimpleLogger } from '@homer0/simple-logger';
|
|
4
|
-
import { SimpleConfig } from '@homer0/simple-config';
|
|
5
|
-
import { FrontendFs } from '../frontend/frontendFs.mjs';
|
|
6
|
-
import { DeferredPromise } from '@homer0/deferred';
|
|
7
|
-
import '../../types/express.mjs';
|
|
8
|
-
import 'express';
|
|
9
|
-
import '../../types/http.mjs';
|
|
10
|
-
import 'https';
|
|
11
|
-
import 'http';
|
|
12
|
-
import 'spdy';
|
|
13
|
-
import 'node-fetch';
|
|
14
|
-
import '../../types/utils.mjs';
|
|
15
|
-
import '@homer0/path-utils';
|
|
16
|
-
import '@homer0/events-hub';
|
|
17
|
-
import 'fs/promises';
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* The options to customize a {@link HTMLGenerator} instance.
|
|
21
|
-
*
|
|
22
|
-
* @group Services/HTMLGenerator
|
|
23
|
-
*/
|
|
24
|
-
type HTMLGeneratorOptions = {
|
|
25
|
-
/**
|
|
26
|
-
* The name of the file it should use as template.
|
|
27
|
-
*
|
|
28
|
-
* @default 'index.tpl.html'
|
|
29
|
-
*/
|
|
30
|
-
template: string;
|
|
31
|
-
/**
|
|
32
|
-
* The name of the generated file.
|
|
33
|
-
*
|
|
34
|
-
* @default 'index.html'
|
|
35
|
-
*/
|
|
36
|
-
file: string;
|
|
37
|
-
/**
|
|
38
|
-
* If `true`, it won't log messages on the terminal when generating the file.
|
|
39
|
-
*
|
|
40
|
-
* @default false
|
|
41
|
-
*/
|
|
42
|
-
silent: boolean;
|
|
43
|
-
/**
|
|
44
|
-
* Whether or not to delete the tempalte after generating the file.
|
|
45
|
-
*
|
|
46
|
-
* @default true
|
|
47
|
-
*/
|
|
48
|
-
deleteTemplateAfter: boolean;
|
|
49
|
-
/**
|
|
50
|
-
* The placeholder string where the information will be written.
|
|
51
|
-
*
|
|
52
|
-
* @default /\{\{appConfi(?:guration)?\}\}/
|
|
53
|
-
*/
|
|
54
|
-
replacePlaceholder: string | RegExp;
|
|
55
|
-
/**
|
|
56
|
-
* A regular expression for dynamic placeholders that will be replaced by values when
|
|
57
|
-
* the file is generated.
|
|
58
|
-
*
|
|
59
|
-
* @default /\{\{(.*?)\}\}/gi
|
|
60
|
-
*/
|
|
61
|
-
placeholderExpression: RegExp;
|
|
62
|
-
/**
|
|
63
|
-
* The name of the variable that will have the information on the file.
|
|
64
|
-
*
|
|
65
|
-
* @default 'appConfig'
|
|
66
|
-
*/
|
|
67
|
-
variableName: string;
|
|
68
|
-
/**
|
|
69
|
-
* A list of settings from the app configuration that will be used as the information to
|
|
70
|
-
* inject on the file.
|
|
71
|
-
*
|
|
72
|
-
* @default ['features', 'version', 'postMessagesPrefix']
|
|
73
|
-
*/
|
|
74
|
-
configKeys: string[];
|
|
75
|
-
};
|
|
76
|
-
/**
|
|
77
|
-
* An external service that can be used to provide the values the generator will replace
|
|
78
|
-
* in the template.
|
|
79
|
-
*
|
|
80
|
-
* @group Services/HTMLGenerator
|
|
81
|
-
*/
|
|
82
|
-
type HTMLGeneratorValuesService = {
|
|
83
|
-
/**
|
|
84
|
-
* A function that will be called to get the values to replace in the template.
|
|
85
|
-
*
|
|
86
|
-
* @param options The service customization options.
|
|
87
|
-
*/
|
|
88
|
-
getValues: (options: HTMLGeneratorOptions) => Promise<Record<string, unknown>>;
|
|
89
|
-
};
|
|
90
|
-
/**
|
|
91
|
-
* The options to construct a {@link HTMLGenerator}.
|
|
92
|
-
*
|
|
93
|
-
* @group Services/HTMLGenerator
|
|
94
|
-
*/
|
|
95
|
-
type HTMLGeneratorConstructorOptions = Partial<HTMLGeneratorOptions> & {
|
|
96
|
-
/**
|
|
97
|
-
* A dictionary with the dependencies to inject.
|
|
98
|
-
*/
|
|
99
|
-
inject: {
|
|
100
|
-
config: SimpleConfig;
|
|
101
|
-
logger: SimpleLogger;
|
|
102
|
-
frontendFs: FrontendFs;
|
|
103
|
-
/**
|
|
104
|
-
* A service that can provide the values to replace in the template. If specified, the
|
|
105
|
-
* values from `configKeys` will be ignored.
|
|
106
|
-
*/
|
|
107
|
-
valuesService?: HTMLGeneratorValuesService;
|
|
108
|
-
};
|
|
109
|
-
};
|
|
110
|
-
/**
|
|
111
|
-
* Custom options for the provider that will register an instance of {@link HTMLGenerator}
|
|
112
|
-
* as a service.
|
|
113
|
-
*
|
|
114
|
-
* @group Services/HTMLGenerator
|
|
115
|
-
*/
|
|
116
|
-
type HTMLGeneratorProviderOptions = Partial<HTMLGeneratorOptions> & {
|
|
117
|
-
/**
|
|
118
|
-
* The name that will be used to register the service on the container. This is to allow
|
|
119
|
-
* multiple "instances" of the service to be created.
|
|
120
|
-
*
|
|
121
|
-
* @default 'htmlGenerator'
|
|
122
|
-
*/
|
|
123
|
-
serviceName?: string;
|
|
124
|
-
/**
|
|
125
|
-
* The name of a service that the generator will use in order to read the values that
|
|
126
|
-
* will be replaced on the template. If the service is available, the values from
|
|
127
|
-
* `configKeys` will be ignored.
|
|
128
|
-
*
|
|
129
|
-
* @default 'htmlGeneratorValues'
|
|
130
|
-
*/
|
|
131
|
-
valuesServiceName?: string;
|
|
132
|
-
};
|
|
133
|
-
/**
|
|
134
|
-
* This is a utility service that generates an HTML file with custom information when the
|
|
135
|
-
* application is started.
|
|
136
|
-
*
|
|
137
|
-
* @group Services
|
|
138
|
-
* @group Services/HTMLGenerator
|
|
139
|
-
*/
|
|
140
|
-
declare class HTMLGenerator {
|
|
141
|
-
/**
|
|
142
|
-
* The service customization options.
|
|
143
|
-
*/
|
|
144
|
-
protected readonly _options: HTMLGeneratorOptions;
|
|
145
|
-
/**
|
|
146
|
-
* The application configuration service, to get the settings specified by the
|
|
147
|
-
* `configKeys` option.
|
|
148
|
-
*/
|
|
149
|
-
protected readonly _config: SimpleConfig;
|
|
150
|
-
/**
|
|
151
|
-
* The service that logs messages on the terminal, in case the `silent` option is `false`.
|
|
152
|
-
*/
|
|
153
|
-
protected readonly _logger: SimpleLogger;
|
|
154
|
-
/**
|
|
155
|
-
* The service that interacts with the filesystem.
|
|
156
|
-
*/
|
|
157
|
-
protected readonly _frontendFs: FrontendFs;
|
|
158
|
-
/**
|
|
159
|
-
* A service that can provide values to be replaced in the template.
|
|
160
|
-
*/
|
|
161
|
-
protected readonly _valuesService?: HTMLGeneratorValuesService;
|
|
162
|
-
/**
|
|
163
|
-
* Whether or not the file was already generated.
|
|
164
|
-
*/
|
|
165
|
-
protected _fileReady: boolean;
|
|
166
|
-
/**
|
|
167
|
-
* A deferred promise to return when another service asks if the file has been
|
|
168
|
-
* generated. Once this sevice finishes generating the file, the promise will be
|
|
169
|
-
* resolved for all implementations that hold a reference to this deferred.
|
|
170
|
-
*/
|
|
171
|
-
protected _fileDeferred?: DeferredPromise<void>;
|
|
172
|
-
/**
|
|
173
|
-
* @param options The options to construct the class.
|
|
174
|
-
* @throws If `valuesService` is specified but it doesn't have a `getValues`
|
|
175
|
-
* method.
|
|
176
|
-
*/
|
|
177
|
-
constructor({ inject: { config, logger, frontendFs, valuesService }, ...options }: HTMLGeneratorConstructorOptions);
|
|
178
|
-
/**
|
|
179
|
-
* Gets a promise that will be resolved when the file has been generated.
|
|
180
|
-
*/
|
|
181
|
-
whenReady(): Promise<void>;
|
|
182
|
-
/**
|
|
183
|
-
* Generates the HTML file.
|
|
184
|
-
*/
|
|
185
|
-
generateHTML(): Promise<void>;
|
|
186
|
-
/**
|
|
187
|
-
* Gets the customization options.
|
|
188
|
-
*/
|
|
189
|
-
get options(): Readonly<HTMLGeneratorOptions>;
|
|
190
|
-
/**
|
|
191
|
-
* Helper method to get the values that will be replaced in the template. If a "values
|
|
192
|
-
* service" was specified in the constructor, it will get the values from there,
|
|
193
|
-
* otherwise, it will use the `configKeys` option to get the values from the
|
|
194
|
-
* application configuration.
|
|
195
|
-
*/
|
|
196
|
-
protected _getValues(): Promise<Record<string, unknown>>;
|
|
197
|
-
/**
|
|
198
|
-
* Processes the HTML template by replacing the placeholders with the actual values.
|
|
199
|
-
*
|
|
200
|
-
* @param template The template for the HTML file.
|
|
201
|
-
* @param values The values dictionary that should be replaced in the template.
|
|
202
|
-
*/
|
|
203
|
-
protected _processHTML(template: string, values: Record<string, unknown>): string;
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
* The service provider that once registered on the container will set an instance of
|
|
207
|
-
* {@link HTMLGenerator} as the `htmlGenerator` service. it will also hook itself to the
|
|
208
|
-
* `after-start` event of the application in order to trigger the generator of the HTML
|
|
209
|
-
* file.
|
|
210
|
-
*
|
|
211
|
-
* @example
|
|
212
|
-
*
|
|
213
|
-
* <caption>Basic usage</caption>
|
|
214
|
-
*
|
|
215
|
-
* // Register it on the container
|
|
216
|
-
* container.register(htmlGeneratorProvider);
|
|
217
|
-
* // Getting access to the service instance
|
|
218
|
-
* const htmlGenerator = container.get<HTMLGenerator>('htmlGenerator');
|
|
219
|
-
*
|
|
220
|
-
* @example
|
|
221
|
-
*
|
|
222
|
-
* <caption>Using with custom options</caption>
|
|
223
|
-
*
|
|
224
|
-
* container.register(
|
|
225
|
-
* htmlGeneratorProvider({
|
|
226
|
-
* serviceName: 'myHtmlGenerator',
|
|
227
|
-
* valuesServiceName: 'myValuesService',
|
|
228
|
-
* template: 'my-template.tpl.html',
|
|
229
|
-
* }),
|
|
230
|
-
* );
|
|
231
|
-
*
|
|
232
|
-
* @group Providers
|
|
233
|
-
* @group Services/HTMLGenerator
|
|
234
|
-
*/
|
|
235
|
-
declare const htmlGeneratorProvider: _homer0_jimple.ResourceCreator<"provider", "register", (options?: HTMLGeneratorProviderOptions) => (app: Jimpex) => void, _homer0_jimple.ProviderRegisterFn<Jimpex>>;
|
|
236
|
-
|
|
237
|
-
export { HTMLGenerator, type HTMLGeneratorConstructorOptions, type HTMLGeneratorOptions, type HTMLGeneratorProviderOptions, type HTMLGeneratorValuesService, htmlGeneratorProvider };
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
-
import { J as Jimpex } from '../../index-Bwf7JHu9.mjs';
|
|
3
|
-
import { HTMLGeneratorProviderOptions } from './htmlGenerator.mjs';
|
|
4
|
-
export { HTMLGenerator, HTMLGeneratorConstructorOptions, HTMLGeneratorOptions, HTMLGeneratorValuesService, htmlGeneratorProvider } from './htmlGenerator.mjs';
|
|
5
|
-
import '../../types/express.mjs';
|
|
6
|
-
import 'express';
|
|
7
|
-
import '../../types/http.mjs';
|
|
8
|
-
import 'https';
|
|
9
|
-
import 'http';
|
|
10
|
-
import 'spdy';
|
|
11
|
-
import 'node-fetch';
|
|
12
|
-
import '../../types/utils.mjs';
|
|
13
|
-
import '@homer0/path-utils';
|
|
14
|
-
import '@homer0/simple-logger';
|
|
15
|
-
import '@homer0/simple-config';
|
|
16
|
-
import '@homer0/events-hub';
|
|
17
|
-
import '../frontend/frontendFs.mjs';
|
|
18
|
-
import 'fs/promises';
|
|
19
|
-
import '@homer0/deferred';
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Registers all the HTML services on the container.
|
|
23
|
-
*
|
|
24
|
-
* - {@link HTMLGenerator | htmlGenerator}
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
*
|
|
28
|
-
* // Register the collection on the container
|
|
29
|
-
* container.register(htmlServicesProvider);
|
|
30
|
-
* // Getting access to one the services instance
|
|
31
|
-
* const htmlGenerator = container.get<HTMLGenerator>('htmlGenerator');
|
|
32
|
-
*
|
|
33
|
-
* @group Providers
|
|
34
|
-
*/
|
|
35
|
-
declare const htmlServicesProvider: {
|
|
36
|
-
htmlGeneratorProvider: _homer0_jimple.ResourceCreator<"provider", "register", (options?: HTMLGeneratorProviderOptions) => (app: Jimpex) => void, _homer0_jimple.ProviderRegisterFn<Jimpex>>;
|
|
37
|
-
} & Record<string, _homer0_jimple.Resource<"provider", "register", _homer0_jimple.ProviderRegisterFn<Jimpex>>> & {
|
|
38
|
-
provider: true;
|
|
39
|
-
} & {
|
|
40
|
-
register: _homer0_jimple.ProviderRegisterFn<Jimpex>;
|
|
41
|
-
} & Record<string, unknown>;
|
|
42
|
-
|
|
43
|
-
export { HTMLGeneratorProviderOptions, htmlServicesProvider };
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
-
import { J as Jimpex } from '../../index-Bwf7JHu9.mjs';
|
|
3
|
-
import { HTTPErrorClass } from '../common/httpError.mjs';
|
|
4
|
-
import { HTTP } from './http.mjs';
|
|
5
|
-
import { APIClientOptions, APIClient as APIClient$1, ErrorResponse } from '@homer0/api-utils';
|
|
6
|
-
export { ErrorResponse } from '@homer0/api-utils';
|
|
7
|
-
import '../../types/express.mjs';
|
|
8
|
-
import 'express';
|
|
9
|
-
import '../../types/http.mjs';
|
|
10
|
-
import 'https';
|
|
11
|
-
import 'http';
|
|
12
|
-
import 'spdy';
|
|
13
|
-
import 'node-fetch';
|
|
14
|
-
import '../../types/utils.mjs';
|
|
15
|
-
import '@homer0/path-utils';
|
|
16
|
-
import '@homer0/simple-logger';
|
|
17
|
-
import '@homer0/simple-config';
|
|
18
|
-
import '@homer0/events-hub';
|
|
19
|
-
import '../../utils/fns/statuses.mjs';
|
|
20
|
-
import 'statuses';
|
|
21
|
-
import '../common/appError.mjs';
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* The required settings needed to create the an API client.
|
|
25
|
-
*
|
|
26
|
-
* @group Services/APIClient
|
|
27
|
-
*/
|
|
28
|
-
type APIClientConfig = Pick<APIClientOptions, 'url' | 'endpoints'>;
|
|
29
|
-
/**
|
|
30
|
-
* A dictionary of endpoints for the API client.
|
|
31
|
-
* This is declared as standalone because it needs to reference them multiple times.
|
|
32
|
-
*
|
|
33
|
-
* @group Services/APIClient
|
|
34
|
-
*/
|
|
35
|
-
type EndpointsType = APIClientOptions['endpoints'];
|
|
36
|
-
/**
|
|
37
|
-
* The format the settings needs to have in the application configuration in order to
|
|
38
|
-
* create a valid API client.
|
|
39
|
-
* The settings may include the endpoints dictionary in the `endpoints` property, or the
|
|
40
|
-
* gateway `property`, with `endpoints` always having priority if both exists.
|
|
41
|
-
* The reason for the `gateway` property to be valid, is in case the application also
|
|
42
|
-
* implements a {@link GatewayController}, using the same property for both things will
|
|
43
|
-
* help reduce the amount of duplicated definitions.
|
|
44
|
-
*
|
|
45
|
-
* @group Services/APIClient
|
|
46
|
-
*/
|
|
47
|
-
type APIClientSettings = Omit<APIClientConfig, 'endpoints'> & ({
|
|
48
|
-
endpoints: EndpointsType;
|
|
49
|
-
gateway?: EndpointsType;
|
|
50
|
-
} | {
|
|
51
|
-
endpoints?: EndpointsType;
|
|
52
|
-
gateway: EndpointsType;
|
|
53
|
-
});
|
|
54
|
-
/**
|
|
55
|
-
* The options to construct a {@link APIClient}.
|
|
56
|
-
*
|
|
57
|
-
* @group Services/APIClient
|
|
58
|
-
*/
|
|
59
|
-
type APIClientConstructorOptions = APIClientSettings & {
|
|
60
|
-
/**
|
|
61
|
-
* A dictionary with the dependencies to inject.
|
|
62
|
-
*/
|
|
63
|
-
inject: {
|
|
64
|
-
http: HTTP;
|
|
65
|
-
HTTPError: HTTPErrorClass;
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
/**
|
|
69
|
-
* An API client for the application to use. What makes this service special is that it
|
|
70
|
-
* formats received errors using the {@link _HTTPError} class, and as fetch client, it
|
|
71
|
-
* uses the {@link HTTP} service, allowing the application to to internally handle all the
|
|
72
|
-
* requests and responses.
|
|
73
|
-
*
|
|
74
|
-
* The only reason to use the class directly is if you want to subclass it, as you would
|
|
75
|
-
* normally just register the {@link apiClientProvider}.
|
|
76
|
-
*
|
|
77
|
-
* @group Services
|
|
78
|
-
* @group Services/APIClient
|
|
79
|
-
*/
|
|
80
|
-
declare class APIClient extends APIClient$1 {
|
|
81
|
-
/**
|
|
82
|
-
* The service that makes the requests to the API.
|
|
83
|
-
*/
|
|
84
|
-
protected readonly _http: HTTP;
|
|
85
|
-
/**
|
|
86
|
-
* The class to generate possible errors in the requests.
|
|
87
|
-
*/
|
|
88
|
-
protected readonly _HTTPError: HTTPErrorClass;
|
|
89
|
-
/**
|
|
90
|
-
* The configuration of the API it uses.
|
|
91
|
-
*/
|
|
92
|
-
protected readonly _apiConfig: APIClientConfig;
|
|
93
|
-
/**
|
|
94
|
-
* @param options The options to construct the class.
|
|
95
|
-
*/
|
|
96
|
-
constructor({ inject: { http, HTTPError }, ...rest }: APIClientConstructorOptions);
|
|
97
|
-
/**
|
|
98
|
-
* The configuration for the API.
|
|
99
|
-
*/
|
|
100
|
-
get apiConfig(): Readonly<APIClientConfig>;
|
|
101
|
-
/**
|
|
102
|
-
* Tries to obtain a message from an error caused on a failed request.
|
|
103
|
-
*
|
|
104
|
-
* @param response The response from the failed request.
|
|
105
|
-
*/
|
|
106
|
-
protected _getErrorMessageFromResponse(response: unknown): string;
|
|
107
|
-
/**
|
|
108
|
-
* Generates an {@link _HTTPError} from the response of a failed request.
|
|
109
|
-
*
|
|
110
|
-
* @param response The response from the failed request.
|
|
111
|
-
* @param status The status code of the response.
|
|
112
|
-
*/
|
|
113
|
-
protected formatError<ResponseType extends ErrorResponse>(response: ResponseType, status: number): Error;
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* The options for the provider creator that registers an {@link APIClient} in the
|
|
117
|
-
* container.
|
|
118
|
-
* These options allow the application to register multiple instances for different APIs.
|
|
119
|
-
*
|
|
120
|
-
* @group Services/APIClient
|
|
121
|
-
*/
|
|
122
|
-
type APIClientProviderOptions = {
|
|
123
|
-
/**
|
|
124
|
-
* The name of the service that will be registered into the app.
|
|
125
|
-
*
|
|
126
|
-
* @default 'apiClient'
|
|
127
|
-
*/
|
|
128
|
-
serviceName?: string;
|
|
129
|
-
/**
|
|
130
|
-
* The name of the configuration setting that has the API information.
|
|
131
|
-
*
|
|
132
|
-
* @default 'api'
|
|
133
|
-
*/
|
|
134
|
-
configSetting?: string;
|
|
135
|
-
/**
|
|
136
|
-
* The class the service will instantiate. It has to extend {@link APIClient}.
|
|
137
|
-
*
|
|
138
|
-
* @default APIClient
|
|
139
|
-
*/
|
|
140
|
-
clientClass?: typeof APIClient;
|
|
141
|
-
};
|
|
142
|
-
/**
|
|
143
|
-
* The provider creator to register an instance of {@link APIClient} on the container.
|
|
144
|
-
*
|
|
145
|
-
* @example
|
|
146
|
-
*
|
|
147
|
-
* <caption>Basic usage</caption>
|
|
148
|
-
*
|
|
149
|
-
* // Register it on the container
|
|
150
|
-
* container.register(apiClientProvider);
|
|
151
|
-
* // Getting access to the service instance
|
|
152
|
-
* const apiClient = container.get<APIClient>('apiClient');
|
|
153
|
-
*
|
|
154
|
-
* @example
|
|
155
|
-
*
|
|
156
|
-
* <caption>With custom options</caption>
|
|
157
|
-
*
|
|
158
|
-
* container.register(
|
|
159
|
-
* apiClientProvider({
|
|
160
|
-
* serviceName: 'myApiClient',
|
|
161
|
-
* configSetting: 'myApi',
|
|
162
|
-
* }),
|
|
163
|
-
* );
|
|
164
|
-
*
|
|
165
|
-
* @group Providers
|
|
166
|
-
* @group Services/APIClient
|
|
167
|
-
*/
|
|
168
|
-
declare const apiClientProvider: _homer0_jimple.ResourceCreator<"provider", "register", (options?: APIClientProviderOptions) => (app: Jimpex) => void, _homer0_jimple.ProviderRegisterFn<Jimpex>>;
|
|
169
|
-
|
|
170
|
-
export { APIClient, type APIClientConfig, type APIClientConstructorOptions, type APIClientProviderOptions, type APIClientSettings, type EndpointsType, apiClientProvider };
|