@rapidrest/core 1.3.0 → 1.3.2
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/lib/ClassLoader.js +3 -2
- package/dist/lib/ClassLoader.js.map +1 -1
- package/dist/lib/JWTUtils.js +1 -0
- package/dist/lib/JWTUtils.js.map +1 -1
- package/dist/lib/StringUtils.js +3 -3
- package/dist/types/JWTUtils.d.ts +1 -0
- package/dist/types/StringUtils.d.ts +3 -3
- package/package.json +2 -7
- package/docs/Makefile +0 -20
- package/docs/conf.py +0 -58
- package/docs/index.rst +0 -17
- package/docs/make.bat +0 -35
- package/docs/reference/@rapidrest/namespaces/ObjectDecorators/README.md +0 -21
- package/docs/reference/@rapidrest/namespaces/ObjectDecorators/functions/Config.md +0 -33
- package/docs/reference/@rapidrest/namespaces/ObjectDecorators/functions/Destroy.md +0 -27
- package/docs/reference/@rapidrest/namespaces/ObjectDecorators/functions/Init.md +0 -33
- package/docs/reference/@rapidrest/namespaces/ObjectDecorators/functions/Inject.md +0 -33
- package/docs/reference/@rapidrest/namespaces/ObjectDecorators/functions/Logger.md +0 -27
- package/docs/reference/@rapidrest/namespaces/ObjectDecorators/functions/Nullable.md +0 -27
- package/docs/reference/@rapidrest/namespaces/ObjectDecorators/functions/Validator.md +0 -25
- package/docs/reference/@rapidrest/namespaces/ObjectDecorators/type-aliases/ValidatorFunction.md +0 -31
- package/docs/reference/README.md +0 -35
- package/docs/reference/classes/AlertUtils.md +0 -158
- package/docs/reference/classes/ApiError.md +0 -251
- package/docs/reference/classes/ClassLoader.md +0 -224
- package/docs/reference/classes/Event.md +0 -109
- package/docs/reference/classes/EventUtils.md +0 -123
- package/docs/reference/classes/FileUtils.md +0 -193
- package/docs/reference/classes/JWTUtils.md +0 -139
- package/docs/reference/classes/MessagingUtils.md +0 -167
- package/docs/reference/classes/OASUtils.md +0 -227
- package/docs/reference/classes/ObjectFactory.md +0 -276
- package/docs/reference/classes/ObjectUtils.md +0 -60
- package/docs/reference/classes/StringUtils.md +0 -169
- package/docs/reference/classes/ThreadPool.md +0 -249
- package/docs/reference/classes/ThreadWorker.md +0 -91
- package/docs/reference/classes/UserUtils.md +0 -185
- package/docs/reference/classes/ValidationUtils.md +0 -294
- package/docs/reference/enumerations/AlertPriority.md +0 -61
- package/docs/reference/enumerations/JWTUtilsCompressionMethods.md +0 -21
- package/docs/reference/enumerations/WorkerMessageType.md +0 -43
- package/docs/reference/functions/sleep.md +0 -25
- package/docs/reference/globals.md +0 -73
- package/docs/reference/interfaces/Alert.md +0 -101
- package/docs/reference/interfaces/AlertAttachment.md +0 -51
- package/docs/reference/interfaces/AlertClose.md +0 -31
- package/docs/reference/interfaces/AlertUtilsAttachmentOptions.md +0 -42
- package/docs/reference/interfaces/AlertUtilsOptions.md +0 -41
- package/docs/reference/interfaces/InstanceOptions.md +0 -41
- package/docs/reference/interfaces/JWTPayload.md +0 -143
- package/docs/reference/interfaces/JWTUser.md +0 -55
- package/docs/reference/interfaces/JWTUtilsConfig.md +0 -45
- package/docs/reference/interfaces/JWTUtilsPayloadKeyOptions.md +0 -68
- package/docs/reference/interfaces/JWTUtilsPayloadOptions.md +0 -40
- package/docs/reference/interfaces/JWTUtilsPayloadPasswordOptions.md +0 -78
- package/docs/reference/interfaces/NewEvent.md +0 -25
- package/docs/reference/interfaces/OriginSettings.md +0 -25
- package/docs/reference/interfaces/SlackConfig.md +0 -33
- package/docs/reference/interfaces/SmtpAuth.md +0 -25
- package/docs/reference/interfaces/SmtpConfig.md +0 -41
- package/docs/reference/interfaces/Template.md +0 -105
- package/docs/reference/interfaces/TemplateMapBase.md +0 -13
- package/docs/reference/interfaces/TwilioConfig.md +0 -33
- package/docs/reference/interfaces/WorkerMessage.md +0 -31
- package/docs/reference/interfaces/WorkerOptions.md +0 -61
- package/docs/reference/type-aliases/BooleanFunc.md +0 -23
- package/docs/reference/type-aliases/TemplateMap.md +0 -17
- package/docs/reference/type-aliases/WorkerCallback.md +0 -31
- package/docs/reference/variables/Logger.md +0 -25
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
[**@rapidrest/core**](../README.md)
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[@rapidrest/core](../globals.md) / AlertUtils
|
|
6
|
-
|
|
7
|
-
# Class: AlertUtils
|
|
8
|
-
|
|
9
|
-
Defined in: [src/AlertUtils.ts:116](https://github.com/rapidrest/core/blob/df82e91f4c858ef61526c7f35789a4199b84d999/src/AlertUtils.ts#L116)
|
|
10
|
-
|
|
11
|
-
The `AlertUtils` class is used to send alerts about important system events that have occurred
|
|
12
|
-
and require further monitoring or intervention.
|
|
13
|
-
|
|
14
|
-
## Constructors
|
|
15
|
-
|
|
16
|
-
### Constructor
|
|
17
|
-
|
|
18
|
-
> **new AlertUtils**(`options`): `AlertUtils`
|
|
19
|
-
|
|
20
|
-
Defined in: [src/AlertUtils.ts:128](https://github.com/rapidrest/core/blob/df82e91f4c858ef61526c7f35789a4199b84d999/src/AlertUtils.ts#L128)
|
|
21
|
-
|
|
22
|
-
Creates a new instance of `AuthUtils` with the provided defaults.
|
|
23
|
-
|
|
24
|
-
#### Parameters
|
|
25
|
-
|
|
26
|
-
##### options
|
|
27
|
-
|
|
28
|
-
[`AlertUtilsOptions`](../interfaces/AlertUtilsOptions.md)
|
|
29
|
-
|
|
30
|
-
The configuration options to use.
|
|
31
|
-
|
|
32
|
-
#### Returns
|
|
33
|
-
|
|
34
|
-
`AlertUtils`
|
|
35
|
-
|
|
36
|
-
## Methods
|
|
37
|
-
|
|
38
|
-
### addAttachment()
|
|
39
|
-
|
|
40
|
-
> **addAttachment**(`id`, `attachment`, `indexFile?`): `Promise`\<`boolean`\>
|
|
41
|
-
|
|
42
|
-
Defined in: [src/AlertUtils.ts:298](https://github.com/rapidrest/core/blob/df82e91f4c858ef61526c7f35789a4199b84d999/src/AlertUtils.ts#L298)
|
|
43
|
-
|
|
44
|
-
Uploads a single attachment to the alert with the given unique identifier.
|
|
45
|
-
|
|
46
|
-
#### Parameters
|
|
47
|
-
|
|
48
|
-
##### id
|
|
49
|
-
|
|
50
|
-
`string`
|
|
51
|
-
|
|
52
|
-
The unique identifier of the alert to add an attachment for.
|
|
53
|
-
|
|
54
|
-
##### attachment
|
|
55
|
-
|
|
56
|
-
[`AlertAttachment`](../interfaces/AlertAttachment.md)
|
|
57
|
-
|
|
58
|
-
The file to upload as an attachment.
|
|
59
|
-
|
|
60
|
-
##### indexFile?
|
|
61
|
-
|
|
62
|
-
`string`
|
|
63
|
-
|
|
64
|
-
Sets the indexFile parameter of the request.
|
|
65
|
-
|
|
66
|
-
#### Returns
|
|
67
|
-
|
|
68
|
-
`Promise`\<`boolean`\>
|
|
69
|
-
|
|
70
|
-
True if the operation was successful, otherwise false.
|
|
71
|
-
|
|
72
|
-
***
|
|
73
|
-
|
|
74
|
-
### close()
|
|
75
|
-
|
|
76
|
-
> **close**(`id`, `data?`): `Promise`\<`boolean`\>
|
|
77
|
-
|
|
78
|
-
Defined in: [src/AlertUtils.ts:139](https://github.com/rapidrest/core/blob/df82e91f4c858ef61526c7f35789a4199b84d999/src/AlertUtils.ts#L139)
|
|
79
|
-
|
|
80
|
-
Attempts to close the existing alert with the given identifier.
|
|
81
|
-
|
|
82
|
-
#### Parameters
|
|
83
|
-
|
|
84
|
-
##### id
|
|
85
|
-
|
|
86
|
-
`string`
|
|
87
|
-
|
|
88
|
-
The unique identifier of the alert to close.
|
|
89
|
-
|
|
90
|
-
##### data?
|
|
91
|
-
|
|
92
|
-
[`AlertClose`](../interfaces/AlertClose.md) = `{}`
|
|
93
|
-
|
|
94
|
-
#### Returns
|
|
95
|
-
|
|
96
|
-
`Promise`\<`boolean`\>
|
|
97
|
-
|
|
98
|
-
True if the operation was successful, otherwise false.
|
|
99
|
-
|
|
100
|
-
***
|
|
101
|
-
|
|
102
|
-
### get()
|
|
103
|
-
|
|
104
|
-
> **get**(`id`): `Promise`\<[`Alert`](../interfaces/Alert.md) \| `null`\>
|
|
105
|
-
|
|
106
|
-
Defined in: [src/AlertUtils.ts:167](https://github.com/rapidrest/core/blob/df82e91f4c858ef61526c7f35789a4199b84d999/src/AlertUtils.ts#L167)
|
|
107
|
-
|
|
108
|
-
Attempts to retrieve the existing alert with the given identifier.
|
|
109
|
-
|
|
110
|
-
#### Parameters
|
|
111
|
-
|
|
112
|
-
##### id
|
|
113
|
-
|
|
114
|
-
`string`
|
|
115
|
-
|
|
116
|
-
The unique identifier of the alert to retrieve.
|
|
117
|
-
|
|
118
|
-
#### Returns
|
|
119
|
-
|
|
120
|
-
`Promise`\<[`Alert`](../interfaces/Alert.md) \| `null`\>
|
|
121
|
-
|
|
122
|
-
The retrieved alert if successful, otherwise `null`.
|
|
123
|
-
|
|
124
|
-
***
|
|
125
|
-
|
|
126
|
-
### send()
|
|
127
|
-
|
|
128
|
-
> **send**(`alert`, `vars?`, `attachments?`): `Promise`\<`string` \| `null`\>
|
|
129
|
-
|
|
130
|
-
Defined in: [src/AlertUtils.ts:191](https://github.com/rapidrest/core/blob/df82e91f4c858ef61526c7f35789a4199b84d999/src/AlertUtils.ts#L191)
|
|
131
|
-
|
|
132
|
-
Sends the provided alert to the configured monitoring service.
|
|
133
|
-
|
|
134
|
-
#### Parameters
|
|
135
|
-
|
|
136
|
-
##### alert
|
|
137
|
-
|
|
138
|
-
[`Alert`](../interfaces/Alert.md)
|
|
139
|
-
|
|
140
|
-
The alert to send.
|
|
141
|
-
|
|
142
|
-
##### vars?
|
|
143
|
-
|
|
144
|
-
`any` = `{}`
|
|
145
|
-
|
|
146
|
-
A map of vars to perform replacement on for the alert's various properties.
|
|
147
|
-
|
|
148
|
-
##### attachments?
|
|
149
|
-
|
|
150
|
-
[`AlertUtilsAttachmentOptions`](../interfaces/AlertUtilsAttachmentOptions.md)
|
|
151
|
-
|
|
152
|
-
The attachments to upload along with the alert.
|
|
153
|
-
|
|
154
|
-
#### Returns
|
|
155
|
-
|
|
156
|
-
`Promise`\<`string` \| `null`\>
|
|
157
|
-
|
|
158
|
-
The unique identifier of the created alert if the operation was successful, otherwise `null`.
|
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
[**@rapidrest/core**](../README.md)
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[@rapidrest/core](../globals.md) / ApiError
|
|
6
|
-
|
|
7
|
-
# Class: ApiError
|
|
8
|
-
|
|
9
|
-
Defined in: [src/ApiError.ts:8](https://github.com/rapidrest/core/blob/df82e91f4c858ef61526c7f35789a4199b84d999/src/ApiError.ts#L8)
|
|
10
|
-
|
|
11
|
-
Describes an error that originates from a API service. This class extends the standard `Error` class to include
|
|
12
|
-
a unique code that can be used to trace an error to source code as well as the HTTP response status returned with
|
|
13
|
-
the error.
|
|
14
|
-
|
|
15
|
-
## Extends
|
|
16
|
-
|
|
17
|
-
- `Error`
|
|
18
|
-
|
|
19
|
-
## Constructors
|
|
20
|
-
|
|
21
|
-
### Constructor
|
|
22
|
-
|
|
23
|
-
> **new ApiError**(`code`, `status`, `message?`, `templateVariables?`): `ApiError`
|
|
24
|
-
|
|
25
|
-
Defined in: [src/ApiError.ts:24](https://github.com/rapidrest/core/blob/df82e91f4c858ef61526c7f35789a4199b84d999/src/ApiError.ts#L24)
|
|
26
|
-
|
|
27
|
-
#### Parameters
|
|
28
|
-
|
|
29
|
-
##### code
|
|
30
|
-
|
|
31
|
-
`string`
|
|
32
|
-
|
|
33
|
-
##### status
|
|
34
|
-
|
|
35
|
-
`number`
|
|
36
|
-
|
|
37
|
-
##### message?
|
|
38
|
-
|
|
39
|
-
`string`
|
|
40
|
-
|
|
41
|
-
##### templateVariables?
|
|
42
|
-
|
|
43
|
-
`any`
|
|
44
|
-
|
|
45
|
-
#### Returns
|
|
46
|
-
|
|
47
|
-
`ApiError`
|
|
48
|
-
|
|
49
|
-
#### Overrides
|
|
50
|
-
|
|
51
|
-
`Error.constructor`
|
|
52
|
-
|
|
53
|
-
## Properties
|
|
54
|
-
|
|
55
|
-
### code
|
|
56
|
-
|
|
57
|
-
> **code**: `string`
|
|
58
|
-
|
|
59
|
-
Defined in: [src/ApiError.ts:10](https://github.com/rapidrest/core/blob/df82e91f4c858ef61526c7f35789a4199b84d999/src/ApiError.ts#L10)
|
|
60
|
-
|
|
61
|
-
The unique code of the error.
|
|
62
|
-
|
|
63
|
-
***
|
|
64
|
-
|
|
65
|
-
### message
|
|
66
|
-
|
|
67
|
-
> **message**: `string`
|
|
68
|
-
|
|
69
|
-
Defined in: node\_modules/typescript/lib/lib.es5.d.ts:1075
|
|
70
|
-
|
|
71
|
-
#### Inherited from
|
|
72
|
-
|
|
73
|
-
`Error.message`
|
|
74
|
-
|
|
75
|
-
***
|
|
76
|
-
|
|
77
|
-
### name
|
|
78
|
-
|
|
79
|
-
> **name**: `string`
|
|
80
|
-
|
|
81
|
-
Defined in: node\_modules/typescript/lib/lib.es5.d.ts:1074
|
|
82
|
-
|
|
83
|
-
#### Inherited from
|
|
84
|
-
|
|
85
|
-
`Error.name`
|
|
86
|
-
|
|
87
|
-
***
|
|
88
|
-
|
|
89
|
-
### stack?
|
|
90
|
-
|
|
91
|
-
> `optional` **stack?**: `string`
|
|
92
|
-
|
|
93
|
-
Defined in: node\_modules/typescript/lib/lib.es5.d.ts:1076
|
|
94
|
-
|
|
95
|
-
#### Inherited from
|
|
96
|
-
|
|
97
|
-
`Error.stack`
|
|
98
|
-
|
|
99
|
-
***
|
|
100
|
-
|
|
101
|
-
### status
|
|
102
|
-
|
|
103
|
-
> **status**: `number`
|
|
104
|
-
|
|
105
|
-
Defined in: [src/ApiError.ts:12](https://github.com/rapidrest/core/blob/df82e91f4c858ef61526c7f35789a4199b84d999/src/ApiError.ts#L12)
|
|
106
|
-
|
|
107
|
-
The HTTP status associated with the error.
|
|
108
|
-
|
|
109
|
-
***
|
|
110
|
-
|
|
111
|
-
### stackTraceLimit
|
|
112
|
-
|
|
113
|
-
> `static` **stackTraceLimit**: `number`
|
|
114
|
-
|
|
115
|
-
Defined in: node\_modules/@types/node/globals.d.ts:67
|
|
116
|
-
|
|
117
|
-
The `Error.stackTraceLimit` property specifies the number of stack frames
|
|
118
|
-
collected by a stack trace (whether generated by `new Error().stack` or
|
|
119
|
-
`Error.captureStackTrace(obj)`).
|
|
120
|
-
|
|
121
|
-
The default value is `10` but may be set to any valid JavaScript number. Changes
|
|
122
|
-
will affect any stack trace captured _after_ the value has been changed.
|
|
123
|
-
|
|
124
|
-
If set to a non-number value, or set to a negative number, stack traces will
|
|
125
|
-
not capture any frames.
|
|
126
|
-
|
|
127
|
-
#### Inherited from
|
|
128
|
-
|
|
129
|
-
`Error.stackTraceLimit`
|
|
130
|
-
|
|
131
|
-
## Methods
|
|
132
|
-
|
|
133
|
-
### ApiMessageTemplate()
|
|
134
|
-
|
|
135
|
-
> **ApiMessageTemplate**(`message`, `templateVariables?`): `string`
|
|
136
|
-
|
|
137
|
-
Defined in: [src/ApiError.ts:14](https://github.com/rapidrest/core/blob/df82e91f4c858ef61526c7f35789a4199b84d999/src/ApiError.ts#L14)
|
|
138
|
-
|
|
139
|
-
#### Parameters
|
|
140
|
-
|
|
141
|
-
##### message
|
|
142
|
-
|
|
143
|
-
`string` \| `undefined`
|
|
144
|
-
|
|
145
|
-
##### templateVariables?
|
|
146
|
-
|
|
147
|
-
`any`
|
|
148
|
-
|
|
149
|
-
#### Returns
|
|
150
|
-
|
|
151
|
-
`string`
|
|
152
|
-
|
|
153
|
-
***
|
|
154
|
-
|
|
155
|
-
### captureStackTrace()
|
|
156
|
-
|
|
157
|
-
> `static` **captureStackTrace**(`targetObject`, `constructorOpt?`): `void`
|
|
158
|
-
|
|
159
|
-
Defined in: node\_modules/@types/node/globals.d.ts:51
|
|
160
|
-
|
|
161
|
-
Creates a `.stack` property on `targetObject`, which when accessed returns
|
|
162
|
-
a string representing the location in the code at which
|
|
163
|
-
`Error.captureStackTrace()` was called.
|
|
164
|
-
|
|
165
|
-
```js
|
|
166
|
-
const myObject = {};
|
|
167
|
-
Error.captureStackTrace(myObject);
|
|
168
|
-
myObject.stack; // Similar to `new Error().stack`
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
The first line of the trace will be prefixed with
|
|
172
|
-
`${myObject.name}: ${myObject.message}`.
|
|
173
|
-
|
|
174
|
-
The optional `constructorOpt` argument accepts a function. If given, all frames
|
|
175
|
-
above `constructorOpt`, including `constructorOpt`, will be omitted from the
|
|
176
|
-
generated stack trace.
|
|
177
|
-
|
|
178
|
-
The `constructorOpt` argument is useful for hiding implementation
|
|
179
|
-
details of error generation from the user. For instance:
|
|
180
|
-
|
|
181
|
-
```js
|
|
182
|
-
function a() {
|
|
183
|
-
b();
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
function b() {
|
|
187
|
-
c();
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
function c() {
|
|
191
|
-
// Create an error without stack trace to avoid calculating the stack trace twice.
|
|
192
|
-
const { stackTraceLimit } = Error;
|
|
193
|
-
Error.stackTraceLimit = 0;
|
|
194
|
-
const error = new Error();
|
|
195
|
-
Error.stackTraceLimit = stackTraceLimit;
|
|
196
|
-
|
|
197
|
-
// Capture the stack trace above function b
|
|
198
|
-
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
|
|
199
|
-
throw error;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
a();
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
#### Parameters
|
|
206
|
-
|
|
207
|
-
##### targetObject
|
|
208
|
-
|
|
209
|
-
`object`
|
|
210
|
-
|
|
211
|
-
##### constructorOpt?
|
|
212
|
-
|
|
213
|
-
`Function`
|
|
214
|
-
|
|
215
|
-
#### Returns
|
|
216
|
-
|
|
217
|
-
`void`
|
|
218
|
-
|
|
219
|
-
#### Inherited from
|
|
220
|
-
|
|
221
|
-
`Error.captureStackTrace`
|
|
222
|
-
|
|
223
|
-
***
|
|
224
|
-
|
|
225
|
-
### prepareStackTrace()
|
|
226
|
-
|
|
227
|
-
> `static` **prepareStackTrace**(`err`, `stackTraces`): `any`
|
|
228
|
-
|
|
229
|
-
Defined in: node\_modules/@types/node/globals.d.ts:55
|
|
230
|
-
|
|
231
|
-
#### Parameters
|
|
232
|
-
|
|
233
|
-
##### err
|
|
234
|
-
|
|
235
|
-
`Error`
|
|
236
|
-
|
|
237
|
-
##### stackTraces
|
|
238
|
-
|
|
239
|
-
`CallSite`[]
|
|
240
|
-
|
|
241
|
-
#### Returns
|
|
242
|
-
|
|
243
|
-
`any`
|
|
244
|
-
|
|
245
|
-
#### See
|
|
246
|
-
|
|
247
|
-
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
|
|
248
|
-
|
|
249
|
-
#### Inherited from
|
|
250
|
-
|
|
251
|
-
`Error.prepareStackTrace`
|
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
[**@rapidrest/core**](../README.md)
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[@rapidrest/core](../globals.md) / ClassLoader
|
|
6
|
-
|
|
7
|
-
# Class: ClassLoader
|
|
8
|
-
|
|
9
|
-
Defined in: [src/ClassLoader.ts:50](https://github.com/rapidrest/core/blob/df82e91f4c858ef61526c7f35789a4199b84d999/src/ClassLoader.ts#L50)
|
|
10
|
-
|
|
11
|
-
The *ClassLoader* provides a container for dynamically loading classes at runtime using C#/Java style namespaces.
|
|
12
|
-
Namespaces are determined from the folder structure relative to the root.
|
|
13
|
-
|
|
14
|
-
Class names are derived either directly from the modules export name or inferred from the module's file path when
|
|
15
|
-
the `default` export is used.
|
|
16
|
-
|
|
17
|
-
For example, given the following example TypeScript module at relative path `com/company/MyClass.ts` would register
|
|
18
|
-
a class with fully qualified name `com.company.MyClass`.
|
|
19
|
-
|
|
20
|
-
```javascript
|
|
21
|
-
export default class MyClass {
|
|
22
|
-
// ...
|
|
23
|
-
}
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
In the event that multiple exports are defined, the fully qualified name will take on the export name instead of the
|
|
27
|
-
module name. Thus, the following example module at relative path `com/company/MyClasses.ts` would register the following
|
|
28
|
-
classes.
|
|
29
|
-
- `com.company.MyClass`
|
|
30
|
-
- `com.company.MyEnum`
|
|
31
|
-
|
|
32
|
-
```javascript
|
|
33
|
-
export class MyClass {
|
|
34
|
-
// ...
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export enum MyEnum {
|
|
38
|
-
// ...
|
|
39
|
-
}
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
**IMPORTANT**: If you use *ClassLoader* to dynamically load TypeScript files (.ts, .cts, .mts, etc.) at runtime using
|
|
43
|
-
an ESM-only project you must use the `ts-node/esm` module loader. This can be specified by passing the `--loader` to
|
|
44
|
-
node at runtime.
|
|
45
|
-
|
|
46
|
-
```
|
|
47
|
-
node --loader ts-node/esm <module>
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
## Author
|
|
51
|
-
|
|
52
|
-
Jean-Philippe Steinmetz
|
|
53
|
-
|
|
54
|
-
## Constructors
|
|
55
|
-
|
|
56
|
-
### Constructor
|
|
57
|
-
|
|
58
|
-
> **new ClassLoader**(`rootDir`, `includeJavaScript?`, `includeTypeScript?`, `ignore?`): `ClassLoader`
|
|
59
|
-
|
|
60
|
-
Defined in: [src/ClassLoader.ts:69](https://github.com/rapidrest/core/blob/df82e91f4c858ef61526c7f35789a4199b84d999/src/ClassLoader.ts#L69)
|
|
61
|
-
|
|
62
|
-
Creates a new instance of `ClassLoader` with the specified defaults.
|
|
63
|
-
|
|
64
|
-
#### Parameters
|
|
65
|
-
|
|
66
|
-
##### rootDir
|
|
67
|
-
|
|
68
|
-
`string`
|
|
69
|
-
|
|
70
|
-
The root directory to load all classes from.
|
|
71
|
-
|
|
72
|
-
##### includeJavaScript?
|
|
73
|
-
|
|
74
|
-
`boolean` = `true`
|
|
75
|
-
|
|
76
|
-
Set to `true` to load all TypeScript classes from the given `rootDir`, otherwise set to `false.
|
|
77
|
-
@param includeTypeScript Set to `true` to load all JavaScript classes from the given `rootDir`, otherwise set to `false.
|
|
78
|
-
|
|
79
|
-
##### includeTypeScript?
|
|
80
|
-
|
|
81
|
-
`boolean` = `true`
|
|
82
|
-
|
|
83
|
-
##### ignore?
|
|
84
|
-
|
|
85
|
-
(`string` \| `RegExp`)[] = `[]`
|
|
86
|
-
|
|
87
|
-
A list of regex pattern of file paths to ignore.
|
|
88
|
-
|
|
89
|
-
#### Returns
|
|
90
|
-
|
|
91
|
-
`ClassLoader`
|
|
92
|
-
|
|
93
|
-
## Properties
|
|
94
|
-
|
|
95
|
-
### classes
|
|
96
|
-
|
|
97
|
-
> `protected` **classes**: `Map`\<`string`, `any`\>
|
|
98
|
-
|
|
99
|
-
Defined in: [src/ClassLoader.ts:52](https://github.com/rapidrest/core/blob/df82e91f4c858ef61526c7f35789a4199b84d999/src/ClassLoader.ts#L52)
|
|
100
|
-
|
|
101
|
-
The map containnig all loaded classes.
|
|
102
|
-
|
|
103
|
-
***
|
|
104
|
-
|
|
105
|
-
### ignore
|
|
106
|
-
|
|
107
|
-
> `protected` **ignore**: (`string` \| `RegExp`)[] = `[]`
|
|
108
|
-
|
|
109
|
-
Defined in: [src/ClassLoader.ts:53](https://github.com/rapidrest/core/blob/df82e91f4c858ef61526c7f35789a4199b84d999/src/ClassLoader.ts#L53)
|
|
110
|
-
|
|
111
|
-
***
|
|
112
|
-
|
|
113
|
-
### includeJavaScript
|
|
114
|
-
|
|
115
|
-
> `protected` **includeJavaScript**: `boolean` = `true`
|
|
116
|
-
|
|
117
|
-
Defined in: [src/ClassLoader.ts:57](https://github.com/rapidrest/core/blob/df82e91f4c858ef61526c7f35789a4199b84d999/src/ClassLoader.ts#L57)
|
|
118
|
-
|
|
119
|
-
Indicates if JavaScript classes should be loaded.
|
|
120
|
-
|
|
121
|
-
***
|
|
122
|
-
|
|
123
|
-
### includeTypeScript
|
|
124
|
-
|
|
125
|
-
> `protected` **includeTypeScript**: `boolean` = `true`
|
|
126
|
-
|
|
127
|
-
Defined in: [src/ClassLoader.ts:55](https://github.com/rapidrest/core/blob/df82e91f4c858ef61526c7f35789a4199b84d999/src/ClassLoader.ts#L55)
|
|
128
|
-
|
|
129
|
-
Indicates if TypeScript classes should be loaded.
|
|
130
|
-
|
|
131
|
-
***
|
|
132
|
-
|
|
133
|
-
### rootDir
|
|
134
|
-
|
|
135
|
-
> `protected` **rootDir**: `string` = `"."`
|
|
136
|
-
|
|
137
|
-
Defined in: [src/ClassLoader.ts:59](https://github.com/rapidrest/core/blob/df82e91f4c858ef61526c7f35789a4199b84d999/src/ClassLoader.ts#L59)
|
|
138
|
-
|
|
139
|
-
The path to the root directory containing all classes on disk.
|
|
140
|
-
|
|
141
|
-
## Methods
|
|
142
|
-
|
|
143
|
-
### getClass()
|
|
144
|
-
|
|
145
|
-
> **getClass**(`fqn`): `any`
|
|
146
|
-
|
|
147
|
-
Defined in: [src/ClassLoader.ts:82](https://github.com/rapidrest/core/blob/df82e91f4c858ef61526c7f35789a4199b84d999/src/ClassLoader.ts#L82)
|
|
148
|
-
|
|
149
|
-
Returns the class with the specified fully qualified name.
|
|
150
|
-
|
|
151
|
-
#### Parameters
|
|
152
|
-
|
|
153
|
-
##### fqn
|
|
154
|
-
|
|
155
|
-
`string`
|
|
156
|
-
|
|
157
|
-
The fully qualified name of the class to return.
|
|
158
|
-
|
|
159
|
-
#### Returns
|
|
160
|
-
|
|
161
|
-
`any`
|
|
162
|
-
|
|
163
|
-
The class definition for the given fully qualified name if found, otherwise `undefined`.
|
|
164
|
-
|
|
165
|
-
***
|
|
166
|
-
|
|
167
|
-
### getClasses()
|
|
168
|
-
|
|
169
|
-
> **getClasses**(): `Map`\<`string`, `any`\>
|
|
170
|
-
|
|
171
|
-
Defined in: [src/ClassLoader.ts:89](https://github.com/rapidrest/core/blob/df82e91f4c858ef61526c7f35789a4199b84d999/src/ClassLoader.ts#L89)
|
|
172
|
-
|
|
173
|
-
Returns the map containing all classes that have been loaded.
|
|
174
|
-
|
|
175
|
-
#### Returns
|
|
176
|
-
|
|
177
|
-
`Map`\<`string`, `any`\>
|
|
178
|
-
|
|
179
|
-
***
|
|
180
|
-
|
|
181
|
-
### hasClass()
|
|
182
|
-
|
|
183
|
-
> **hasClass**(`fqn`): `any`
|
|
184
|
-
|
|
185
|
-
Defined in: [src/ClassLoader.ts:99](https://github.com/rapidrest/core/blob/df82e91f4c858ef61526c7f35789a4199b84d999/src/ClassLoader.ts#L99)
|
|
186
|
-
|
|
187
|
-
Returns `true` if a class exists with the specified fully qualified name.
|
|
188
|
-
|
|
189
|
-
#### Parameters
|
|
190
|
-
|
|
191
|
-
##### fqn
|
|
192
|
-
|
|
193
|
-
`string`
|
|
194
|
-
|
|
195
|
-
The fully qualified name of the class to search.
|
|
196
|
-
|
|
197
|
-
#### Returns
|
|
198
|
-
|
|
199
|
-
`any`
|
|
200
|
-
|
|
201
|
-
`true` if a class definition exists for the given fully qualified name, otherwise `false`.
|
|
202
|
-
|
|
203
|
-
***
|
|
204
|
-
|
|
205
|
-
### load()
|
|
206
|
-
|
|
207
|
-
> **load**(`dir?`): `Promise`\<`void`\>
|
|
208
|
-
|
|
209
|
-
Defined in: [src/ClassLoader.ts:109](https://github.com/rapidrest/core/blob/df82e91f4c858ef61526c7f35789a4199b84d999/src/ClassLoader.ts#L109)
|
|
210
|
-
|
|
211
|
-
Loads all modules exports contained in the directory specified. The folder must be a child
|
|
212
|
-
directory to the `rootDir` parameter passed in to the constructor.
|
|
213
|
-
|
|
214
|
-
#### Parameters
|
|
215
|
-
|
|
216
|
-
##### dir?
|
|
217
|
-
|
|
218
|
-
`string` = `""`
|
|
219
|
-
|
|
220
|
-
The directory, relative to `rootDir`, containing modules to load.
|
|
221
|
-
|
|
222
|
-
#### Returns
|
|
223
|
-
|
|
224
|
-
`Promise`\<`void`\>
|