@rapidrest/core 1.0.1
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/LICENSE +23 -0
- package/README.rst +37 -0
- package/dist/lib/AlertUtils.js +239 -0
- package/dist/lib/AlertUtils.js.map +1 -0
- package/dist/lib/ApiError.js +34 -0
- package/dist/lib/ApiError.js.map +1 -0
- package/dist/lib/ClassLoader.js +159 -0
- package/dist/lib/ClassLoader.js.map +1 -0
- package/dist/lib/FileUtils.js +190 -0
- package/dist/lib/FileUtils.js.map +1 -0
- package/dist/lib/JWTUtils.js +111 -0
- package/dist/lib/JWTUtils.js.map +1 -0
- package/dist/lib/Logger.js +28 -0
- package/dist/lib/Logger.js.map +1 -0
- package/dist/lib/MessagingUtils.js +218 -0
- package/dist/lib/MessagingUtils.js.map +1 -0
- package/dist/lib/NotificationsUtils.js +52 -0
- package/dist/lib/NotificationsUtils.js.map +1 -0
- package/dist/lib/OASUtils.js +207 -0
- package/dist/lib/OASUtils.js.map +1 -0
- package/dist/lib/ObjectFactory.js +302 -0
- package/dist/lib/ObjectFactory.js.map +1 -0
- package/dist/lib/ObjectUtils.js +49 -0
- package/dist/lib/ObjectUtils.js.map +1 -0
- package/dist/lib/StringUtils.js +104 -0
- package/dist/lib/StringUtils.js.map +1 -0
- package/dist/lib/TelemetryUtils.js +159 -0
- package/dist/lib/TelemetryUtils.js.map +1 -0
- package/dist/lib/UserUtils.js +138 -0
- package/dist/lib/UserUtils.js.map +1 -0
- package/dist/lib/ValidationUtils.js +130 -0
- package/dist/lib/ValidationUtils.js.map +1 -0
- package/dist/lib/decorators/ObjectDecorators.js +95 -0
- package/dist/lib/decorators/ObjectDecorators.js.map +1 -0
- package/dist/lib/decorators/index.js +2 -0
- package/dist/lib/decorators/index.js.map +1 -0
- package/dist/lib/index.js +18 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/sleep.js +15 -0
- package/dist/lib/sleep.js.map +1 -0
- package/dist/lib/threads/ThreadLogger.js +43 -0
- package/dist/lib/threads/ThreadLogger.js.map +1 -0
- package/dist/lib/threads/ThreadPool.js +270 -0
- package/dist/lib/threads/ThreadPool.js.map +1 -0
- package/dist/lib/threads/ThreadWorker.js +25 -0
- package/dist/lib/threads/ThreadWorker.js.map +1 -0
- package/dist/lib/threads/ThreadWorkerEntry.js +77 -0
- package/dist/lib/threads/ThreadWorkerEntry.js.map +1 -0
- package/dist/lib/threads/index.js +3 -0
- package/dist/lib/threads/index.js.map +1 -0
- package/dist/types/AlertUtils.d.ts +132 -0
- package/dist/types/ApiError.d.ts +13 -0
- package/dist/types/ClassLoader.d.ts +87 -0
- package/dist/types/FileUtils.d.ts +46 -0
- package/dist/types/JWTUtils.d.ts +139 -0
- package/dist/types/Logger.d.ts +7 -0
- package/dist/types/MessagingUtils.d.ts +77 -0
- package/dist/types/NotificationsUtils.d.ts +32 -0
- package/dist/types/OASUtils.d.ts +54 -0
- package/dist/types/ObjectFactory.d.ts +77 -0
- package/dist/types/ObjectUtils.d.ts +17 -0
- package/dist/types/StringUtils.d.ts +52 -0
- package/dist/types/TelemetryUtils.d.ts +84 -0
- package/dist/types/UserUtils.d.ts +61 -0
- package/dist/types/ValidationUtils.d.ts +66 -0
- package/dist/types/decorators/ObjectDecorators.d.ts +55 -0
- package/dist/types/decorators/index.d.ts +1 -0
- package/dist/types/index.d.ts +17 -0
- package/dist/types/sleep.d.ts +5 -0
- package/dist/types/threads/ThreadLogger.d.ts +15 -0
- package/dist/types/threads/ThreadPool.d.ts +115 -0
- package/dist/types/threads/ThreadWorker.d.ts +41 -0
- package/dist/types/threads/ThreadWorkerEntry.d.ts +1 -0
- package/dist/types/threads/index.d.ts +2 -0
- package/docs/Makefile +20 -0
- package/docs/conf.py +58 -0
- package/docs/index.rst +17 -0
- package/docs/make.bat +35 -0
- package/docs/reference/@rapidrest/namespaces/ObjectDecorators/README.md +21 -0
- package/docs/reference/@rapidrest/namespaces/ObjectDecorators/functions/Config.md +47 -0
- package/docs/reference/@rapidrest/namespaces/ObjectDecorators/functions/Destroy.md +27 -0
- package/docs/reference/@rapidrest/namespaces/ObjectDecorators/functions/Init.md +33 -0
- package/docs/reference/@rapidrest/namespaces/ObjectDecorators/functions/Inject.md +45 -0
- package/docs/reference/@rapidrest/namespaces/ObjectDecorators/functions/Logger.md +27 -0
- package/docs/reference/@rapidrest/namespaces/ObjectDecorators/functions/Nullable.md +27 -0
- package/docs/reference/@rapidrest/namespaces/ObjectDecorators/functions/Validator.md +39 -0
- package/docs/reference/@rapidrest/namespaces/ObjectDecorators/type-aliases/ValidatorFunction.md +31 -0
- package/docs/reference/README.md +73 -0
- package/docs/reference/classes/AlertUtils.md +158 -0
- package/docs/reference/classes/ApiError.md +263 -0
- package/docs/reference/classes/ClassLoader.md +224 -0
- package/docs/reference/classes/Event.md +109 -0
- package/docs/reference/classes/EventUtils.md +123 -0
- package/docs/reference/classes/FileUtils.md +193 -0
- package/docs/reference/classes/JWTUtils.md +91 -0
- package/docs/reference/classes/MessagingUtils.md +145 -0
- package/docs/reference/classes/OASUtils.md +213 -0
- package/docs/reference/classes/ObjectFactory.md +274 -0
- package/docs/reference/classes/ObjectUtils.md +60 -0
- package/docs/reference/classes/StringUtils.md +169 -0
- package/docs/reference/classes/ThreadPool.md +249 -0
- package/docs/reference/classes/ThreadWorker.md +91 -0
- package/docs/reference/classes/UserUtils.md +239 -0
- package/docs/reference/classes/ValidationUtils.md +294 -0
- package/docs/reference/enumerations/AlertPriority.md +61 -0
- package/docs/reference/enumerations/JWTUtilsCompressionMethods.md +21 -0
- package/docs/reference/enumerations/WorkerMessageType.md +43 -0
- package/docs/reference/functions/sleep.md +25 -0
- package/docs/reference/interfaces/Alert.md +101 -0
- package/docs/reference/interfaces/AlertAttachment.md +51 -0
- package/docs/reference/interfaces/AlertClose.md +31 -0
- package/docs/reference/interfaces/AlertUtilsAttachmentOptions.md +42 -0
- package/docs/reference/interfaces/AlertUtilsOptions.md +41 -0
- package/docs/reference/interfaces/InstanceOptions.md +35 -0
- package/docs/reference/interfaces/JWTPayload.md +143 -0
- package/docs/reference/interfaces/JWTUser.md +55 -0
- package/docs/reference/interfaces/JWTUtilsConfig.md +45 -0
- package/docs/reference/interfaces/JWTUtilsPayloadKeyOptions.md +68 -0
- package/docs/reference/interfaces/JWTUtilsPayloadOptions.md +40 -0
- package/docs/reference/interfaces/JWTUtilsPayloadPasswordOptions.md +78 -0
- package/docs/reference/interfaces/NewEvent.md +25 -0
- package/docs/reference/interfaces/OriginSettings.md +25 -0
- package/docs/reference/interfaces/SlackConfig.md +33 -0
- package/docs/reference/interfaces/SmtpAuth.md +25 -0
- package/docs/reference/interfaces/SmtpConfig.md +41 -0
- package/docs/reference/interfaces/Template.md +81 -0
- package/docs/reference/interfaces/TemplateMapBase.md +13 -0
- package/docs/reference/interfaces/TwilioConfig.md +33 -0
- package/docs/reference/interfaces/WorkerMessage.md +31 -0
- package/docs/reference/interfaces/WorkerOptions.md +61 -0
- package/docs/reference/type-aliases/BooleanFunc.md +23 -0
- package/docs/reference/type-aliases/TemplateMap.md +17 -0
- package/docs/reference/type-aliases/WorkerCallback.md +31 -0
- package/docs/reference/variables/Logger.md +21 -0
- package/package.json +96 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
[**@rapidrest/core**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@rapidrest/core](../README.md) / MessagingUtils
|
|
6
|
+
|
|
7
|
+
# Class: MessagingUtils
|
|
8
|
+
|
|
9
|
+
Defined in: src/MessagingUtils.ts:68
|
|
10
|
+
|
|
11
|
+
Simple utility class for sending templated messages via e-mail, SMS and more.
|
|
12
|
+
|
|
13
|
+
## Constructors
|
|
14
|
+
|
|
15
|
+
### Constructor
|
|
16
|
+
|
|
17
|
+
> **new MessagingUtils**(): `MessagingUtils`
|
|
18
|
+
|
|
19
|
+
#### Returns
|
|
20
|
+
|
|
21
|
+
`MessagingUtils`
|
|
22
|
+
|
|
23
|
+
## Properties
|
|
24
|
+
|
|
25
|
+
### slackApps
|
|
26
|
+
|
|
27
|
+
> `protected` **slackApps**: `any`[] = `[]`
|
|
28
|
+
|
|
29
|
+
Defined in: src/MessagingUtils.ts:69
|
|
30
|
+
|
|
31
|
+
***
|
|
32
|
+
|
|
33
|
+
### slackConfigs
|
|
34
|
+
|
|
35
|
+
> `protected` **slackConfigs**: `any`[] = `[]`
|
|
36
|
+
|
|
37
|
+
Defined in: src/MessagingUtils.ts:71
|
|
38
|
+
|
|
39
|
+
## Methods
|
|
40
|
+
|
|
41
|
+
### init()
|
|
42
|
+
|
|
43
|
+
> **init**(): `Promise`\<`void`\>
|
|
44
|
+
|
|
45
|
+
Defined in: src/MessagingUtils.ts:83
|
|
46
|
+
|
|
47
|
+
#### Returns
|
|
48
|
+
|
|
49
|
+
`Promise`\<`void`\>
|
|
50
|
+
|
|
51
|
+
***
|
|
52
|
+
|
|
53
|
+
### sendEmail()
|
|
54
|
+
|
|
55
|
+
> **sendEmail**(`templateName`, `templateVars`, `options`): `Promise`\<`any`\>
|
|
56
|
+
|
|
57
|
+
Defined in: src/MessagingUtils.ts:149
|
|
58
|
+
|
|
59
|
+
Sends an email using the given template name and variables.
|
|
60
|
+
|
|
61
|
+
#### Parameters
|
|
62
|
+
|
|
63
|
+
##### templateName
|
|
64
|
+
|
|
65
|
+
`string`
|
|
66
|
+
|
|
67
|
+
The name of the email template to send.
|
|
68
|
+
|
|
69
|
+
##### templateVars
|
|
70
|
+
|
|
71
|
+
`any`
|
|
72
|
+
|
|
73
|
+
The map of variables to inject into the template.
|
|
74
|
+
|
|
75
|
+
##### options
|
|
76
|
+
|
|
77
|
+
`any` = `{}`
|
|
78
|
+
|
|
79
|
+
The map of additional options to pass into the sendMail function.
|
|
80
|
+
|
|
81
|
+
#### Returns
|
|
82
|
+
|
|
83
|
+
`Promise`\<`any`\>
|
|
84
|
+
|
|
85
|
+
***
|
|
86
|
+
|
|
87
|
+
### sendSlack()
|
|
88
|
+
|
|
89
|
+
> **sendSlack**(`templateName`, `templateVars`): `Promise`\<`any`[] \| `undefined`\>
|
|
90
|
+
|
|
91
|
+
Defined in: src/MessagingUtils.ts:204
|
|
92
|
+
|
|
93
|
+
Sends an Slack message using the given template name and variables.
|
|
94
|
+
|
|
95
|
+
#### Parameters
|
|
96
|
+
|
|
97
|
+
##### templateName
|
|
98
|
+
|
|
99
|
+
`string`
|
|
100
|
+
|
|
101
|
+
The name of the Slack template to send.
|
|
102
|
+
|
|
103
|
+
##### templateVars
|
|
104
|
+
|
|
105
|
+
`any`
|
|
106
|
+
|
|
107
|
+
The map of variables to inject into the template.
|
|
108
|
+
|
|
109
|
+
#### Returns
|
|
110
|
+
|
|
111
|
+
`Promise`\<`any`[] \| `undefined`\>
|
|
112
|
+
|
|
113
|
+
***
|
|
114
|
+
|
|
115
|
+
### sendSMS()
|
|
116
|
+
|
|
117
|
+
> **sendSMS**(`templateName`, `templateVars`, `options`): `Promise`\<`any`\>
|
|
118
|
+
|
|
119
|
+
Defined in: src/MessagingUtils.ts:241
|
|
120
|
+
|
|
121
|
+
Sends an SMS using the given template name and variables.
|
|
122
|
+
|
|
123
|
+
#### Parameters
|
|
124
|
+
|
|
125
|
+
##### templateName
|
|
126
|
+
|
|
127
|
+
`string`
|
|
128
|
+
|
|
129
|
+
The name of the SMS template to send.
|
|
130
|
+
|
|
131
|
+
##### templateVars
|
|
132
|
+
|
|
133
|
+
`any`
|
|
134
|
+
|
|
135
|
+
The map of variables to inject into the template.
|
|
136
|
+
|
|
137
|
+
##### options
|
|
138
|
+
|
|
139
|
+
`any` = `{}`
|
|
140
|
+
|
|
141
|
+
The map of additional options to pass into the sendMail function.
|
|
142
|
+
|
|
143
|
+
#### Returns
|
|
144
|
+
|
|
145
|
+
`Promise`\<`any`\>
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
[**@rapidrest/core**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@rapidrest/core](../README.md) / OASUtils
|
|
6
|
+
|
|
7
|
+
# Class: OASUtils
|
|
8
|
+
|
|
9
|
+
Defined in: src/OASUtils.ts:12
|
|
10
|
+
|
|
11
|
+
## Constructors
|
|
12
|
+
|
|
13
|
+
### Constructor
|
|
14
|
+
|
|
15
|
+
> **new OASUtils**(): `OASUtils`
|
|
16
|
+
|
|
17
|
+
#### Returns
|
|
18
|
+
|
|
19
|
+
`OASUtils`
|
|
20
|
+
|
|
21
|
+
## Methods
|
|
22
|
+
|
|
23
|
+
### getDatastore()
|
|
24
|
+
|
|
25
|
+
> `static` **getDatastore**(`spec`, `name`): `any`
|
|
26
|
+
|
|
27
|
+
Defined in: src/OASUtils.ts:20
|
|
28
|
+
|
|
29
|
+
Gets the datastore definition with the specified name.
|
|
30
|
+
|
|
31
|
+
#### Parameters
|
|
32
|
+
|
|
33
|
+
##### spec
|
|
34
|
+
|
|
35
|
+
`any`
|
|
36
|
+
|
|
37
|
+
The OpenAPI specification to search.
|
|
38
|
+
|
|
39
|
+
##### name
|
|
40
|
+
|
|
41
|
+
`string`
|
|
42
|
+
|
|
43
|
+
The name of the datastore to retrieve.
|
|
44
|
+
|
|
45
|
+
#### Returns
|
|
46
|
+
|
|
47
|
+
`any`
|
|
48
|
+
|
|
49
|
+
The definition for the datastore with the given name if found, otherwise `undefined`.
|
|
50
|
+
|
|
51
|
+
***
|
|
52
|
+
|
|
53
|
+
### getObject()
|
|
54
|
+
|
|
55
|
+
> `static` **getObject**(`spec`, `path`): `any`
|
|
56
|
+
|
|
57
|
+
Defined in: src/OASUtils.ts:37
|
|
58
|
+
|
|
59
|
+
Gets the specification object at the specified path.
|
|
60
|
+
|
|
61
|
+
#### Parameters
|
|
62
|
+
|
|
63
|
+
##### spec
|
|
64
|
+
|
|
65
|
+
`any`
|
|
66
|
+
|
|
67
|
+
The OpenAPI specification to reference.
|
|
68
|
+
|
|
69
|
+
##### path
|
|
70
|
+
|
|
71
|
+
`string`
|
|
72
|
+
|
|
73
|
+
The path of the object to retrieve.
|
|
74
|
+
|
|
75
|
+
#### Returns
|
|
76
|
+
|
|
77
|
+
`any`
|
|
78
|
+
|
|
79
|
+
The object at the specified path if found, otherwise `undefined`.
|
|
80
|
+
|
|
81
|
+
***
|
|
82
|
+
|
|
83
|
+
### getResponse()
|
|
84
|
+
|
|
85
|
+
> `static` **getResponse**(`obj`): `any`
|
|
86
|
+
|
|
87
|
+
Defined in: src/OASUtils.ts:64
|
|
88
|
+
|
|
89
|
+
Returns the first available response object for a 2XX response as defined by the provided Operation schema object.
|
|
90
|
+
|
|
91
|
+
#### Parameters
|
|
92
|
+
|
|
93
|
+
##### obj
|
|
94
|
+
|
|
95
|
+
`any`
|
|
96
|
+
|
|
97
|
+
The Operation schema object to search.
|
|
98
|
+
|
|
99
|
+
#### Returns
|
|
100
|
+
|
|
101
|
+
`any`
|
|
102
|
+
|
|
103
|
+
***
|
|
104
|
+
|
|
105
|
+
### getResponseContent()
|
|
106
|
+
|
|
107
|
+
> `static` **getResponseContent**(`obj`): `any`
|
|
108
|
+
|
|
109
|
+
Defined in: src/OASUtils.ts:83
|
|
110
|
+
|
|
111
|
+
Returns the first available response content object for a 2XX response as defined by the provided Operation schema object.
|
|
112
|
+
|
|
113
|
+
#### Parameters
|
|
114
|
+
|
|
115
|
+
##### obj
|
|
116
|
+
|
|
117
|
+
`any`
|
|
118
|
+
|
|
119
|
+
The Operation schema object to search.
|
|
120
|
+
|
|
121
|
+
#### Returns
|
|
122
|
+
|
|
123
|
+
`any`
|
|
124
|
+
|
|
125
|
+
***
|
|
126
|
+
|
|
127
|
+
### getSchema()
|
|
128
|
+
|
|
129
|
+
> `static` **getSchema**(`spec`, `name`): `any`
|
|
130
|
+
|
|
131
|
+
Defined in: src/OASUtils.ts:95
|
|
132
|
+
|
|
133
|
+
Retrieves the schema definition with the given name.
|
|
134
|
+
|
|
135
|
+
#### Parameters
|
|
136
|
+
|
|
137
|
+
##### spec
|
|
138
|
+
|
|
139
|
+
`any`
|
|
140
|
+
|
|
141
|
+
The OpenAPI specification object to reference.
|
|
142
|
+
|
|
143
|
+
##### name
|
|
144
|
+
|
|
145
|
+
`string`
|
|
146
|
+
|
|
147
|
+
The name of the schema to retrieve.
|
|
148
|
+
|
|
149
|
+
#### Returns
|
|
150
|
+
|
|
151
|
+
`any`
|
|
152
|
+
|
|
153
|
+
The schema definition with the given name.
|
|
154
|
+
|
|
155
|
+
***
|
|
156
|
+
|
|
157
|
+
### getTypeInfo()
|
|
158
|
+
|
|
159
|
+
> `static` **getTypeInfo**(`schemaDef`, `spec`, `convertDataType`): `any`
|
|
160
|
+
|
|
161
|
+
Defined in: src/OASUtils.ts:118
|
|
162
|
+
|
|
163
|
+
Extracts the type information for a given schema Object definition.
|
|
164
|
+
|
|
165
|
+
#### Parameters
|
|
166
|
+
|
|
167
|
+
##### schemaDef
|
|
168
|
+
|
|
169
|
+
`any`
|
|
170
|
+
|
|
171
|
+
The schema definition object to extract type information from.
|
|
172
|
+
|
|
173
|
+
##### spec
|
|
174
|
+
|
|
175
|
+
`any`
|
|
176
|
+
|
|
177
|
+
The entire OpenAPI specification object.
|
|
178
|
+
|
|
179
|
+
##### convertDataType
|
|
180
|
+
|
|
181
|
+
`Function`
|
|
182
|
+
|
|
183
|
+
The function that converts OpenAPI Specification types to native types.
|
|
184
|
+
|
|
185
|
+
#### Returns
|
|
186
|
+
|
|
187
|
+
`any`
|
|
188
|
+
|
|
189
|
+
A tuple containing the type, subType and subSchemaRef information.
|
|
190
|
+
|
|
191
|
+
***
|
|
192
|
+
|
|
193
|
+
### loadSpec()
|
|
194
|
+
|
|
195
|
+
> `static` **loadSpec**(`file`): `Promise`\<`any`\>
|
|
196
|
+
|
|
197
|
+
Defined in: src/OASUtils.ts:173
|
|
198
|
+
|
|
199
|
+
Attempts to load the Open API specification at the given path or URL.
|
|
200
|
+
|
|
201
|
+
#### Parameters
|
|
202
|
+
|
|
203
|
+
##### file
|
|
204
|
+
|
|
205
|
+
`string`
|
|
206
|
+
|
|
207
|
+
The path or URL of the OpenAPI Specification file to load.
|
|
208
|
+
|
|
209
|
+
#### Returns
|
|
210
|
+
|
|
211
|
+
`Promise`\<`any`\>
|
|
212
|
+
|
|
213
|
+
A promise whose result will be the loaded OpenAPI Specification as an object.
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
[**@rapidrest/core**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@rapidrest/core](../README.md) / ObjectFactory
|
|
6
|
+
|
|
7
|
+
# Class: ObjectFactory
|
|
8
|
+
|
|
9
|
+
Defined in: src/ObjectFactory.ts:24
|
|
10
|
+
|
|
11
|
+
The `ObjectFactory` is a manager for creating objects based on registered
|
|
12
|
+
class types. This allows for the tracking of multiple instances of objects
|
|
13
|
+
so that references can be referenced by unique name.
|
|
14
|
+
|
|
15
|
+
## Author
|
|
16
|
+
|
|
17
|
+
Jean-Philippe Steinmetz
|
|
18
|
+
|
|
19
|
+
## Constructors
|
|
20
|
+
|
|
21
|
+
### Constructor
|
|
22
|
+
|
|
23
|
+
> **new ObjectFactory**(`config?`, `logger?`): `ObjectFactory`
|
|
24
|
+
|
|
25
|
+
Defined in: src/ObjectFactory.ts:37
|
|
26
|
+
|
|
27
|
+
#### Parameters
|
|
28
|
+
|
|
29
|
+
##### config?
|
|
30
|
+
|
|
31
|
+
`any`
|
|
32
|
+
|
|
33
|
+
##### logger?
|
|
34
|
+
|
|
35
|
+
`any`
|
|
36
|
+
|
|
37
|
+
#### Returns
|
|
38
|
+
|
|
39
|
+
`ObjectFactory`
|
|
40
|
+
|
|
41
|
+
## Properties
|
|
42
|
+
|
|
43
|
+
### classes
|
|
44
|
+
|
|
45
|
+
> `readonly` **classes**: `Map`\<`string`, `any`\>
|
|
46
|
+
|
|
47
|
+
Defined in: src/ObjectFactory.ts:26
|
|
48
|
+
|
|
49
|
+
A map for string fully qualified class names to their class types.
|
|
50
|
+
|
|
51
|
+
***
|
|
52
|
+
|
|
53
|
+
### config
|
|
54
|
+
|
|
55
|
+
> `protected` **config**: `any`
|
|
56
|
+
|
|
57
|
+
Defined in: src/ObjectFactory.ts:29
|
|
58
|
+
|
|
59
|
+
The global application configuration object.
|
|
60
|
+
|
|
61
|
+
***
|
|
62
|
+
|
|
63
|
+
### instances
|
|
64
|
+
|
|
65
|
+
> `readonly` **instances**: `Map`\<`string`, `any`\>
|
|
66
|
+
|
|
67
|
+
Defined in: src/ObjectFactory.ts:32
|
|
68
|
+
|
|
69
|
+
A map for the unique name to the intance of a particular class type.
|
|
70
|
+
|
|
71
|
+
***
|
|
72
|
+
|
|
73
|
+
### logger
|
|
74
|
+
|
|
75
|
+
> `protected` **logger**: `any`
|
|
76
|
+
|
|
77
|
+
Defined in: src/ObjectFactory.ts:35
|
|
78
|
+
|
|
79
|
+
The application logging utility.
|
|
80
|
+
|
|
81
|
+
## Methods
|
|
82
|
+
|
|
83
|
+
### clear()
|
|
84
|
+
|
|
85
|
+
> **clear**(): `void`
|
|
86
|
+
|
|
87
|
+
Defined in: src/ObjectFactory.ts:104
|
|
88
|
+
|
|
89
|
+
Deletes all instantiated objects.
|
|
90
|
+
|
|
91
|
+
#### Returns
|
|
92
|
+
|
|
93
|
+
`void`
|
|
94
|
+
|
|
95
|
+
***
|
|
96
|
+
|
|
97
|
+
### clearAll()
|
|
98
|
+
|
|
99
|
+
> **clearAll**(): `void`
|
|
100
|
+
|
|
101
|
+
Defined in: src/ObjectFactory.ts:111
|
|
102
|
+
|
|
103
|
+
Deletes all instantiated objects and registered class types.
|
|
104
|
+
|
|
105
|
+
#### Returns
|
|
106
|
+
|
|
107
|
+
`void`
|
|
108
|
+
|
|
109
|
+
***
|
|
110
|
+
|
|
111
|
+
### destroy()
|
|
112
|
+
|
|
113
|
+
> **destroy**(`objs?`): `Promise`\<`void`\>
|
|
114
|
+
|
|
115
|
+
Defined in: src/ObjectFactory.ts:47
|
|
116
|
+
|
|
117
|
+
Destroys the specified objects. If `undefined` is passed in, all objects managed by the factory are destroyed.
|
|
118
|
+
|
|
119
|
+
#### Parameters
|
|
120
|
+
|
|
121
|
+
##### objs?
|
|
122
|
+
|
|
123
|
+
`any`
|
|
124
|
+
|
|
125
|
+
#### Returns
|
|
126
|
+
|
|
127
|
+
`Promise`\<`void`\>
|
|
128
|
+
|
|
129
|
+
***
|
|
130
|
+
|
|
131
|
+
### getInitMethods()
|
|
132
|
+
|
|
133
|
+
> **getInitMethods**(`obj`): `Function`[]
|
|
134
|
+
|
|
135
|
+
Defined in: src/ObjectFactory.ts:186
|
|
136
|
+
|
|
137
|
+
Searches an object for one or more functions that implement a `@Init` decorator.
|
|
138
|
+
|
|
139
|
+
#### Parameters
|
|
140
|
+
|
|
141
|
+
##### obj
|
|
142
|
+
|
|
143
|
+
`any`
|
|
144
|
+
|
|
145
|
+
The object to search.
|
|
146
|
+
|
|
147
|
+
#### Returns
|
|
148
|
+
|
|
149
|
+
`Function`[]
|
|
150
|
+
|
|
151
|
+
The list of functions that implements the `@Init` decorator if found, otherwise undefined.
|
|
152
|
+
|
|
153
|
+
***
|
|
154
|
+
|
|
155
|
+
### getInstance()
|
|
156
|
+
|
|
157
|
+
> **getInstance**\<`T`\>(`nameOrType`): `T` \| `undefined`
|
|
158
|
+
|
|
159
|
+
Defined in: src/ObjectFactory.ts:220
|
|
160
|
+
|
|
161
|
+
Returns the object instance with the given unique name. Unique names take the form `<ClassName>:<InstanceName>`.
|
|
162
|
+
It is possible to only specifiy the `<ClassName>`, doing so will automatically look for the `<ClassName>:default`
|
|
163
|
+
instance or the first found instance of the given type.
|
|
164
|
+
|
|
165
|
+
#### Type Parameters
|
|
166
|
+
|
|
167
|
+
##### T
|
|
168
|
+
|
|
169
|
+
`T`
|
|
170
|
+
|
|
171
|
+
#### Parameters
|
|
172
|
+
|
|
173
|
+
##### nameOrType
|
|
174
|
+
|
|
175
|
+
`any`
|
|
176
|
+
|
|
177
|
+
The unique name or class type of the object to retrieve.
|
|
178
|
+
|
|
179
|
+
#### Returns
|
|
180
|
+
|
|
181
|
+
`T` \| `undefined`
|
|
182
|
+
|
|
183
|
+
The object instance associated with the given name if found, otherwise `undefined`.
|
|
184
|
+
|
|
185
|
+
***
|
|
186
|
+
|
|
187
|
+
### initialize()
|
|
188
|
+
|
|
189
|
+
> **initialize**\<`T`\>(`obj`): `Promise`\<`T`\>
|
|
190
|
+
|
|
191
|
+
Defined in: src/ObjectFactory.ts:120
|
|
192
|
+
|
|
193
|
+
Scans the given object for any properties with the `@Inject` decorator and assigns the correct values.
|
|
194
|
+
|
|
195
|
+
#### Type Parameters
|
|
196
|
+
|
|
197
|
+
##### T
|
|
198
|
+
|
|
199
|
+
`T`
|
|
200
|
+
|
|
201
|
+
#### Parameters
|
|
202
|
+
|
|
203
|
+
##### obj
|
|
204
|
+
|
|
205
|
+
`any`
|
|
206
|
+
|
|
207
|
+
The object to initialize with injected defaults
|
|
208
|
+
|
|
209
|
+
#### Returns
|
|
210
|
+
|
|
211
|
+
`Promise`\<`T`\>
|
|
212
|
+
|
|
213
|
+
***
|
|
214
|
+
|
|
215
|
+
### newInstance()
|
|
216
|
+
|
|
217
|
+
> **newInstance**\<`T`\>(`type`, `options?`): `T` \| `Promise`\<`T`\>
|
|
218
|
+
|
|
219
|
+
Defined in: src/ObjectFactory.ts:265
|
|
220
|
+
|
|
221
|
+
Creates a new instance of the class specified with the provided unique name or type and constructor arguments. If an existing
|
|
222
|
+
object has already been created with the given name, that instance is returned, otherwise a new instance is created
|
|
223
|
+
using the provided arguments.
|
|
224
|
+
|
|
225
|
+
#### Type Parameters
|
|
226
|
+
|
|
227
|
+
##### T
|
|
228
|
+
|
|
229
|
+
`T`
|
|
230
|
+
|
|
231
|
+
#### Parameters
|
|
232
|
+
|
|
233
|
+
##### type
|
|
234
|
+
|
|
235
|
+
`any`
|
|
236
|
+
|
|
237
|
+
The fully qualified name or type of the class to instantiate. If a type is given it's class name will be inferred
|
|
238
|
+
via the constructor name.
|
|
239
|
+
|
|
240
|
+
##### options?
|
|
241
|
+
|
|
242
|
+
[`InstanceOptions`](../interfaces/InstanceOptions.md)
|
|
243
|
+
|
|
244
|
+
#### Returns
|
|
245
|
+
|
|
246
|
+
`T` \| `Promise`\<`T`\>
|
|
247
|
+
|
|
248
|
+
***
|
|
249
|
+
|
|
250
|
+
### register()
|
|
251
|
+
|
|
252
|
+
> **register**(`clazz`, `fqn?`): `void`
|
|
253
|
+
|
|
254
|
+
Defined in: src/ObjectFactory.ts:336
|
|
255
|
+
|
|
256
|
+
Registers the given class type for the provided fully qualified name.
|
|
257
|
+
|
|
258
|
+
#### Parameters
|
|
259
|
+
|
|
260
|
+
##### clazz
|
|
261
|
+
|
|
262
|
+
`any`
|
|
263
|
+
|
|
264
|
+
The class type to register.
|
|
265
|
+
|
|
266
|
+
##### fqn?
|
|
267
|
+
|
|
268
|
+
`string`
|
|
269
|
+
|
|
270
|
+
The fully qualified name of the class to register. If not specified, the class name will be used.
|
|
271
|
+
|
|
272
|
+
#### Returns
|
|
273
|
+
|
|
274
|
+
`void`
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
[**@rapidrest/core**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@rapidrest/core](../README.md) / ObjectUtils
|
|
6
|
+
|
|
7
|
+
# Class: ObjectUtils
|
|
8
|
+
|
|
9
|
+
Defined in: src/ObjectUtils.ts:12
|
|
10
|
+
|
|
11
|
+
Utility class for working with objects.
|
|
12
|
+
|
|
13
|
+
## Author
|
|
14
|
+
|
|
15
|
+
Jean-Philippe Steinmetz
|
|
16
|
+
|
|
17
|
+
## Constructors
|
|
18
|
+
|
|
19
|
+
### Constructor
|
|
20
|
+
|
|
21
|
+
> **new ObjectUtils**(): `ObjectUtils`
|
|
22
|
+
|
|
23
|
+
#### Returns
|
|
24
|
+
|
|
25
|
+
`ObjectUtils`
|
|
26
|
+
|
|
27
|
+
## Methods
|
|
28
|
+
|
|
29
|
+
### validate()
|
|
30
|
+
|
|
31
|
+
> `static` **validate**(`obj`, `clazz?`, `recurse?`): `void`
|
|
32
|
+
|
|
33
|
+
Defined in: src/ObjectUtils.ts:21
|
|
34
|
+
|
|
35
|
+
Performs validation of the given object or array. Validation is performed by scanning the object class for properties
|
|
36
|
+
decorated with `@Validator` and executing the provided validation function.
|
|
37
|
+
|
|
38
|
+
#### Parameters
|
|
39
|
+
|
|
40
|
+
##### obj
|
|
41
|
+
|
|
42
|
+
`any`
|
|
43
|
+
|
|
44
|
+
The object or array of objects to validate.
|
|
45
|
+
|
|
46
|
+
##### clazz?
|
|
47
|
+
|
|
48
|
+
`any`
|
|
49
|
+
|
|
50
|
+
The class type that contains the validation metadata.
|
|
51
|
+
|
|
52
|
+
##### recurse?
|
|
53
|
+
|
|
54
|
+
`boolean`
|
|
55
|
+
|
|
56
|
+
Set to `true` to validate all child objects.
|
|
57
|
+
|
|
58
|
+
#### Returns
|
|
59
|
+
|
|
60
|
+
`void`
|