@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,224 @@
|
|
|
1
|
+
[**@rapidrest/core**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@rapidrest/core](../README.md) / ClassLoader
|
|
6
|
+
|
|
7
|
+
# Class: ClassLoader
|
|
8
|
+
|
|
9
|
+
Defined in: src/ClassLoader.ts:48
|
|
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:67
|
|
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:50
|
|
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:51
|
|
110
|
+
|
|
111
|
+
***
|
|
112
|
+
|
|
113
|
+
### includeJavaScript
|
|
114
|
+
|
|
115
|
+
> `protected` **includeJavaScript**: `boolean` = `true`
|
|
116
|
+
|
|
117
|
+
Defined in: src/ClassLoader.ts:55
|
|
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:53
|
|
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:57
|
|
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:80
|
|
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:87
|
|
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:97
|
|
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:107
|
|
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`\>
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
[**@rapidrest/core**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@rapidrest/core](../README.md) / Event
|
|
6
|
+
|
|
7
|
+
# Class: Event
|
|
8
|
+
|
|
9
|
+
Defined in: src/TelemetryUtils.ts:23
|
|
10
|
+
|
|
11
|
+
Describes a single telemetry event. A telemetry event is when something occurs in the system.
|
|
12
|
+
|
|
13
|
+
## Author
|
|
14
|
+
|
|
15
|
+
Jean-Philippe Steinmetz <rapidrests@gmail.com>
|
|
16
|
+
|
|
17
|
+
## Implements
|
|
18
|
+
|
|
19
|
+
- [`NewEvent`](../interfaces/NewEvent.md)
|
|
20
|
+
|
|
21
|
+
## Constructors
|
|
22
|
+
|
|
23
|
+
### Constructor
|
|
24
|
+
|
|
25
|
+
> **new Event**(`config`, `userId`, `data`): `Event`
|
|
26
|
+
|
|
27
|
+
Defined in: src/TelemetryUtils.ts:54
|
|
28
|
+
|
|
29
|
+
#### Parameters
|
|
30
|
+
|
|
31
|
+
##### config
|
|
32
|
+
|
|
33
|
+
`any`
|
|
34
|
+
|
|
35
|
+
##### userId
|
|
36
|
+
|
|
37
|
+
`string`
|
|
38
|
+
|
|
39
|
+
##### data
|
|
40
|
+
|
|
41
|
+
[`NewEvent`](../interfaces/NewEvent.md)
|
|
42
|
+
|
|
43
|
+
#### Returns
|
|
44
|
+
|
|
45
|
+
`Event`
|
|
46
|
+
|
|
47
|
+
## Properties
|
|
48
|
+
|
|
49
|
+
### environment
|
|
50
|
+
|
|
51
|
+
> `readonly` **environment**: `string`
|
|
52
|
+
|
|
53
|
+
Defined in: src/TelemetryUtils.ts:32
|
|
54
|
+
|
|
55
|
+
The name of the environment that the event originated from. This is typically `dev` or `prod`.
|
|
56
|
+
|
|
57
|
+
***
|
|
58
|
+
|
|
59
|
+
### origin
|
|
60
|
+
|
|
61
|
+
> `readonly` **origin**: `string`
|
|
62
|
+
|
|
63
|
+
Defined in: src/TelemetryUtils.ts:37
|
|
64
|
+
|
|
65
|
+
The unique name of the service or client that the event originated from.
|
|
66
|
+
|
|
67
|
+
***
|
|
68
|
+
|
|
69
|
+
### timestamp
|
|
70
|
+
|
|
71
|
+
> `readonly` **timestamp**: `Date`
|
|
72
|
+
|
|
73
|
+
Defined in: src/TelemetryUtils.ts:42
|
|
74
|
+
|
|
75
|
+
The date and time that the event occured.
|
|
76
|
+
|
|
77
|
+
***
|
|
78
|
+
|
|
79
|
+
### type
|
|
80
|
+
|
|
81
|
+
> `readonly` **type**: `string`
|
|
82
|
+
|
|
83
|
+
Defined in: src/TelemetryUtils.ts:47
|
|
84
|
+
|
|
85
|
+
The type of event being recorded.
|
|
86
|
+
|
|
87
|
+
#### Implementation of
|
|
88
|
+
|
|
89
|
+
[`NewEvent`](../interfaces/NewEvent.md).[`type`](../interfaces/NewEvent.md#type)
|
|
90
|
+
|
|
91
|
+
***
|
|
92
|
+
|
|
93
|
+
### uid
|
|
94
|
+
|
|
95
|
+
> `readonly` **uid**: `string`
|
|
96
|
+
|
|
97
|
+
Defined in: src/TelemetryUtils.ts:27
|
|
98
|
+
|
|
99
|
+
The universally unique identifier of the event.
|
|
100
|
+
|
|
101
|
+
***
|
|
102
|
+
|
|
103
|
+
### userId
|
|
104
|
+
|
|
105
|
+
> `readonly` **userId**: `string`
|
|
106
|
+
|
|
107
|
+
Defined in: src/TelemetryUtils.ts:52
|
|
108
|
+
|
|
109
|
+
The universally unique identifer of the user that sent the event.
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
[**@rapidrest/core**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@rapidrest/core](../README.md) / EventUtils
|
|
6
|
+
|
|
7
|
+
# Class: EventUtils
|
|
8
|
+
|
|
9
|
+
Defined in: src/TelemetryUtils.ts:84
|
|
10
|
+
|
|
11
|
+
Provides a common set of static functions for recording and working with telemetry `Event` instances.
|
|
12
|
+
|
|
13
|
+
The `init` function must be called before any other function can be called.
|
|
14
|
+
|
|
15
|
+
The `record` function is used to send an event to a configured `telemetry_services` service for permanent storage.
|
|
16
|
+
|
|
17
|
+
The `on` function allows code within the same application or service to listen for outgoing events that have been
|
|
18
|
+
sent via the `record` function.
|
|
19
|
+
|
|
20
|
+
## Author
|
|
21
|
+
|
|
22
|
+
Jean-Philippe Steinmetz <rapidrests@gmail.com>
|
|
23
|
+
|
|
24
|
+
## Constructors
|
|
25
|
+
|
|
26
|
+
### Constructor
|
|
27
|
+
|
|
28
|
+
> **new EventUtils**(): `EventUtils`
|
|
29
|
+
|
|
30
|
+
#### Returns
|
|
31
|
+
|
|
32
|
+
`EventUtils`
|
|
33
|
+
|
|
34
|
+
## Methods
|
|
35
|
+
|
|
36
|
+
### init()
|
|
37
|
+
|
|
38
|
+
> `static` **init**(`config`, `logger`, `jwtToken`): `void`
|
|
39
|
+
|
|
40
|
+
Defined in: src/TelemetryUtils.ts:99
|
|
41
|
+
|
|
42
|
+
Initializes `EventUtils` with the provided defaults.
|
|
43
|
+
|
|
44
|
+
#### Parameters
|
|
45
|
+
|
|
46
|
+
##### config
|
|
47
|
+
|
|
48
|
+
`any`
|
|
49
|
+
|
|
50
|
+
The application configuration to use.
|
|
51
|
+
|
|
52
|
+
##### logger
|
|
53
|
+
|
|
54
|
+
`any`
|
|
55
|
+
|
|
56
|
+
The logging utility to use.
|
|
57
|
+
|
|
58
|
+
##### jwtToken
|
|
59
|
+
|
|
60
|
+
`string`
|
|
61
|
+
|
|
62
|
+
The user's JWT token to send telemetry events on behalf of.
|
|
63
|
+
|
|
64
|
+
#### Returns
|
|
65
|
+
|
|
66
|
+
`void`
|
|
67
|
+
|
|
68
|
+
***
|
|
69
|
+
|
|
70
|
+
### on()
|
|
71
|
+
|
|
72
|
+
> `static` **on**(`type`, `callback`): `void`
|
|
73
|
+
|
|
74
|
+
Defined in: src/TelemetryUtils.ts:173
|
|
75
|
+
|
|
76
|
+
Registers a `callback` function to receive notifications of recorded events of the given `type`. Note that only
|
|
77
|
+
events originating from the same application or service will be notified.
|
|
78
|
+
|
|
79
|
+
#### Parameters
|
|
80
|
+
|
|
81
|
+
##### type
|
|
82
|
+
|
|
83
|
+
`string`
|
|
84
|
+
|
|
85
|
+
The type of event to be notified of.
|
|
86
|
+
|
|
87
|
+
##### callback
|
|
88
|
+
|
|
89
|
+
`Function`
|
|
90
|
+
|
|
91
|
+
The function to call when an event is recorded.
|
|
92
|
+
|
|
93
|
+
#### Returns
|
|
94
|
+
|
|
95
|
+
`void`
|
|
96
|
+
|
|
97
|
+
***
|
|
98
|
+
|
|
99
|
+
### record()
|
|
100
|
+
|
|
101
|
+
> `static` **record**(`evt`, `type?`): `Promise`\<`void`\>
|
|
102
|
+
|
|
103
|
+
Defined in: src/TelemetryUtils.ts:118
|
|
104
|
+
|
|
105
|
+
Sends the given event to the telemetry service for permanent recording.
|
|
106
|
+
|
|
107
|
+
#### Parameters
|
|
108
|
+
|
|
109
|
+
##### evt
|
|
110
|
+
|
|
111
|
+
`any`
|
|
112
|
+
|
|
113
|
+
The event to send and record.
|
|
114
|
+
|
|
115
|
+
##### type?
|
|
116
|
+
|
|
117
|
+
`string`
|
|
118
|
+
|
|
119
|
+
The type of event to record. Overrides any `type` value set in `evt`.
|
|
120
|
+
|
|
121
|
+
#### Returns
|
|
122
|
+
|
|
123
|
+
`Promise`\<`void`\>
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
[**@rapidrest/core**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@rapidrest/core](../README.md) / FileUtils
|
|
6
|
+
|
|
7
|
+
# Class: FileUtils
|
|
8
|
+
|
|
9
|
+
Defined in: src/FileUtils.ts:18
|
|
10
|
+
|
|
11
|
+
Utility functions for working with files.
|
|
12
|
+
|
|
13
|
+
## Author
|
|
14
|
+
|
|
15
|
+
Jean-Philippe Steinmetz
|
|
16
|
+
|
|
17
|
+
## Constructors
|
|
18
|
+
|
|
19
|
+
### Constructor
|
|
20
|
+
|
|
21
|
+
> **new FileUtils**(): `FileUtils`
|
|
22
|
+
|
|
23
|
+
#### Returns
|
|
24
|
+
|
|
25
|
+
`FileUtils`
|
|
26
|
+
|
|
27
|
+
## Methods
|
|
28
|
+
|
|
29
|
+
### copyBinaryFile()
|
|
30
|
+
|
|
31
|
+
> `static` **copyBinaryFile**(`srcPath`, `outPath`, `variables`): `Promise`\<`void`\>
|
|
32
|
+
|
|
33
|
+
Defined in: src/FileUtils.ts:160
|
|
34
|
+
|
|
35
|
+
Generates a copy of the source file at the desired output destination using binary copy mode.
|
|
36
|
+
|
|
37
|
+
#### Parameters
|
|
38
|
+
|
|
39
|
+
##### srcPath
|
|
40
|
+
|
|
41
|
+
`string`
|
|
42
|
+
|
|
43
|
+
The source file to copy.
|
|
44
|
+
|
|
45
|
+
##### outPath
|
|
46
|
+
|
|
47
|
+
`string`
|
|
48
|
+
|
|
49
|
+
The destination file to generate.
|
|
50
|
+
|
|
51
|
+
##### variables
|
|
52
|
+
|
|
53
|
+
`any` = `{}`
|
|
54
|
+
|
|
55
|
+
The map of variable names to values to swap. Applies to outPath only.
|
|
56
|
+
|
|
57
|
+
#### Returns
|
|
58
|
+
|
|
59
|
+
`Promise`\<`void`\>
|
|
60
|
+
|
|
61
|
+
***
|
|
62
|
+
|
|
63
|
+
### copyDirectory()
|
|
64
|
+
|
|
65
|
+
> `static` **copyDirectory**(`srcPath`, `outPath`, `vars`, `excludeFilters`, `binaryFilters`, `force`): `Promise`\<`void`\>
|
|
66
|
+
|
|
67
|
+
Defined in: src/FileUtils.ts:188
|
|
68
|
+
|
|
69
|
+
Performs a deep copy of a directory tree at the given srcPath to the specified output directory. Performs
|
|
70
|
+
template replacement for all variables given and skips any files in the specified filter.
|
|
71
|
+
|
|
72
|
+
#### Parameters
|
|
73
|
+
|
|
74
|
+
##### srcPath
|
|
75
|
+
|
|
76
|
+
`string`
|
|
77
|
+
|
|
78
|
+
The path to the source directory to copy files from.
|
|
79
|
+
|
|
80
|
+
##### outPath
|
|
81
|
+
|
|
82
|
+
`string`
|
|
83
|
+
|
|
84
|
+
The path to the destination directory to copy files to.
|
|
85
|
+
|
|
86
|
+
##### vars
|
|
87
|
+
|
|
88
|
+
`any` = `{}`
|
|
89
|
+
|
|
90
|
+
The map of template variables to perform replacement on.
|
|
91
|
+
|
|
92
|
+
##### excludeFilters
|
|
93
|
+
|
|
94
|
+
`string`[] = `[]`
|
|
95
|
+
|
|
96
|
+
The list of file extension filters to exclude during the copy process.
|
|
97
|
+
|
|
98
|
+
##### binaryFilters
|
|
99
|
+
|
|
100
|
+
`string`[] = `[]`
|
|
101
|
+
|
|
102
|
+
The list of file extension filters to copy as binary only.
|
|
103
|
+
|
|
104
|
+
##### force
|
|
105
|
+
|
|
106
|
+
`boolean` = `false`
|
|
107
|
+
|
|
108
|
+
Set to `true` to force writing over any existing files.
|
|
109
|
+
|
|
110
|
+
#### Returns
|
|
111
|
+
|
|
112
|
+
`Promise`\<`void`\>
|
|
113
|
+
|
|
114
|
+
***
|
|
115
|
+
|
|
116
|
+
### copyFile()
|
|
117
|
+
|
|
118
|
+
> `static` **copyFile**(`srcPath`, `outPath`, `variables`, `overwrite`): `Promise`\<`void`\>
|
|
119
|
+
|
|
120
|
+
Defined in: src/FileUtils.ts:124
|
|
121
|
+
|
|
122
|
+
Generates a copy of the source file at the desired output destination and performs a swap of all values of the
|
|
123
|
+
variables specified.
|
|
124
|
+
|
|
125
|
+
#### Parameters
|
|
126
|
+
|
|
127
|
+
##### srcPath
|
|
128
|
+
|
|
129
|
+
`string`
|
|
130
|
+
|
|
131
|
+
The source file to copy.
|
|
132
|
+
|
|
133
|
+
##### outPath
|
|
134
|
+
|
|
135
|
+
`string`
|
|
136
|
+
|
|
137
|
+
The destination file to generate.
|
|
138
|
+
|
|
139
|
+
##### variables
|
|
140
|
+
|
|
141
|
+
`any` = `{}`
|
|
142
|
+
|
|
143
|
+
The map of variable names to values to swap.
|
|
144
|
+
|
|
145
|
+
##### overwrite
|
|
146
|
+
|
|
147
|
+
`boolean` = `false`
|
|
148
|
+
|
|
149
|
+
#### Returns
|
|
150
|
+
|
|
151
|
+
`Promise`\<`void`\>
|
|
152
|
+
|
|
153
|
+
***
|
|
154
|
+
|
|
155
|
+
### writeFile()
|
|
156
|
+
|
|
157
|
+
> `static` **writeFile**(`srcPath`, `outPath`, `contents`, `overwrite`): `Promise`\<`void`\>
|
|
158
|
+
|
|
159
|
+
Defined in: src/FileUtils.ts:29
|
|
160
|
+
|
|
161
|
+
Attempts to write the provided contents to the file path given. If a file already exists the user is prompted to
|
|
162
|
+
allow the file to be overwritten or merged. In the case of a merge, srcPath is used as a baseline in order to
|
|
163
|
+
perform a 3-way merge.
|
|
164
|
+
|
|
165
|
+
#### Parameters
|
|
166
|
+
|
|
167
|
+
##### srcPath
|
|
168
|
+
|
|
169
|
+
`string`
|
|
170
|
+
|
|
171
|
+
The baseline template file to use during a merge.
|
|
172
|
+
|
|
173
|
+
##### outPath
|
|
174
|
+
|
|
175
|
+
`string`
|
|
176
|
+
|
|
177
|
+
The destination file path to be written.
|
|
178
|
+
|
|
179
|
+
##### contents
|
|
180
|
+
|
|
181
|
+
`any`
|
|
182
|
+
|
|
183
|
+
The contents of the file to write.
|
|
184
|
+
|
|
185
|
+
##### overwrite
|
|
186
|
+
|
|
187
|
+
`boolean` = `false`
|
|
188
|
+
|
|
189
|
+
Set to `true` to overwite the file and not perform a merge.
|
|
190
|
+
|
|
191
|
+
#### Returns
|
|
192
|
+
|
|
193
|
+
`Promise`\<`void`\>
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
[**@rapidrest/core**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@rapidrest/core](../README.md) / JWTUtils
|
|
6
|
+
|
|
7
|
+
# Class: JWTUtils
|
|
8
|
+
|
|
9
|
+
Defined in: src/JWTUtils.ts:145
|
|
10
|
+
|
|
11
|
+
Utility class for working with Json Web Token (JWT) authentication tokens.
|
|
12
|
+
|
|
13
|
+
## Author
|
|
14
|
+
|
|
15
|
+
Jean-Philippe Steinmetz <rapidrests@gmail.com>
|
|
16
|
+
|
|
17
|
+
## Constructors
|
|
18
|
+
|
|
19
|
+
### Constructor
|
|
20
|
+
|
|
21
|
+
> **new JWTUtils**(): `JWTUtils`
|
|
22
|
+
|
|
23
|
+
#### Returns
|
|
24
|
+
|
|
25
|
+
`JWTUtils`
|
|
26
|
+
|
|
27
|
+
## Methods
|
|
28
|
+
|
|
29
|
+
### createToken()
|
|
30
|
+
|
|
31
|
+
> `static` **createToken**(`config`, `user`, `data?`): `string`
|
|
32
|
+
|
|
33
|
+
Defined in: src/JWTUtils.ts:154
|
|
34
|
+
|
|
35
|
+
Generates a new JWT token for the given config and user object. The user object must be a valid RapidREST
|
|
36
|
+
user.
|
|
37
|
+
|
|
38
|
+
#### Parameters
|
|
39
|
+
|
|
40
|
+
##### config
|
|
41
|
+
|
|
42
|
+
[`JWTUtilsConfig`](../interfaces/JWTUtilsConfig.md)
|
|
43
|
+
|
|
44
|
+
The JWT configuration to use when generating the token.
|
|
45
|
+
|
|
46
|
+
##### user
|
|
47
|
+
|
|
48
|
+
[`JWTUser`](../interfaces/JWTUser.md)
|
|
49
|
+
|
|
50
|
+
The user to encode into the token's payload.
|
|
51
|
+
|
|
52
|
+
##### data?
|
|
53
|
+
|
|
54
|
+
`any`
|
|
55
|
+
|
|
56
|
+
Additional data to include the token's payload.
|
|
57
|
+
|
|
58
|
+
#### Returns
|
|
59
|
+
|
|
60
|
+
`string`
|
|
61
|
+
|
|
62
|
+
***
|
|
63
|
+
|
|
64
|
+
### decodeToken()
|
|
65
|
+
|
|
66
|
+
> `static` **decodeToken**(`config`, `token`): [`JWTPayload`](../interfaces/JWTPayload.md)
|
|
67
|
+
|
|
68
|
+
Defined in: src/JWTUtils.ts:207
|
|
69
|
+
|
|
70
|
+
Decodes the given JWT authentication token using the provided configuration. If the token is not valid an
|
|
71
|
+
error is thrown with the reason. Returns the encoded user object payload upon success.
|
|
72
|
+
|
|
73
|
+
#### Parameters
|
|
74
|
+
|
|
75
|
+
##### config
|
|
76
|
+
|
|
77
|
+
[`JWTUtilsConfig`](../interfaces/JWTUtilsConfig.md)
|
|
78
|
+
|
|
79
|
+
The JWT configuration to use when validating the token.
|
|
80
|
+
|
|
81
|
+
##### token
|
|
82
|
+
|
|
83
|
+
`string`
|
|
84
|
+
|
|
85
|
+
The JWT token to validate.
|
|
86
|
+
|
|
87
|
+
#### Returns
|
|
88
|
+
|
|
89
|
+
[`JWTPayload`](../interfaces/JWTPayload.md)
|
|
90
|
+
|
|
91
|
+
The data encoded in the token's payload.
|