@twin.org/engine-server-types 0.0.1-next.14
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 +201 -0
- package/README.md +21 -0
- package/dist/cjs/index.cjs +354 -0
- package/dist/esm/index.mjs +343 -0
- package/dist/types/components/authentication.d.ts +13 -0
- package/dist/types/components/information.d.ts +13 -0
- package/dist/types/components/mimeTypeProcessor.d.ts +13 -0
- package/dist/types/components/restRouteProcessor.d.ts +13 -0
- package/dist/types/components/socketRouteProcessor.d.ts +13 -0
- package/dist/types/index.d.ts +16 -0
- package/dist/types/models/IEngineServerTypesConfig.d.ts +43 -0
- package/dist/types/models/config/authenticationComponentConfig.d.ts +13 -0
- package/dist/types/models/config/informationComponentConfig.d.ts +11 -0
- package/dist/types/models/config/mimeTypeProcessorConfig.d.ts +8 -0
- package/dist/types/models/config/restRouteProcessorConfig.d.ts +32 -0
- package/dist/types/models/config/socketRouteProcessorConfig.d.ts +32 -0
- package/dist/types/models/types/authenticationComponentType.d.ts +13 -0
- package/dist/types/models/types/informationComponentType.d.ts +13 -0
- package/dist/types/models/types/mimeTypeProcessorType.d.ts +13 -0
- package/dist/types/models/types/restRouteProcessorType.d.ts +29 -0
- package/dist/types/models/types/socketRouteProcessorType.d.ts +29 -0
- package/docs/changelog.md +5 -0
- package/docs/examples.md +1 -0
- package/docs/reference/functions/initialiseAuthenticationComponent.md +33 -0
- package/docs/reference/functions/initialiseInformationComponent.md +33 -0
- package/docs/reference/functions/initialiseMimeTypeProcessorComponent.md +33 -0
- package/docs/reference/functions/initialiseRestRouteProcessorComponent.md +33 -0
- package/docs/reference/functions/initialiseSocketRouteProcessorComponent.md +33 -0
- package/docs/reference/index.md +34 -0
- package/docs/reference/interfaces/IEngineServerTypesConfig.md +59 -0
- package/docs/reference/type-aliases/AuthenticationComponentConfig.md +27 -0
- package/docs/reference/type-aliases/AuthenticationComponentType.md +5 -0
- package/docs/reference/type-aliases/InformationComponentConfig.md +19 -0
- package/docs/reference/type-aliases/InformationComponentType.md +5 -0
- package/docs/reference/type-aliases/MimeTypeProcessorConfig.md +15 -0
- package/docs/reference/type-aliases/MimeTypeProcessorType.md +5 -0
- package/docs/reference/type-aliases/RestRouteProcessorConfig.md +5 -0
- package/docs/reference/type-aliases/RestRouteProcessorType.md +5 -0
- package/docs/reference/type-aliases/SocketRouteProcessorConfig.md +5 -0
- package/docs/reference/type-aliases/SocketRouteProcessorType.md +5 -0
- package/docs/reference/variables/AuthenticationComponentType.md +13 -0
- package/docs/reference/variables/InformationComponentType.md +13 -0
- package/docs/reference/variables/MimeTypeProcessorType.md +13 -0
- package/docs/reference/variables/RestRouteProcessorType.md +37 -0
- package/docs/reference/variables/SocketRouteProcessorType.md +37 -0
- package/locales/en.json +1 -0
- package/package.json +45 -0
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
import { initSchema, EntityStorageAuthenticationService, AuthHeaderProcessor } from '@twin.org/api-auth-entity-storage-service';
|
|
2
|
+
import { I18n, GeneralError, ComponentFactory } from '@twin.org/core';
|
|
3
|
+
import { initialiseEntityStorageConnector } from '@twin.org/engine-types';
|
|
4
|
+
import { InformationService } from '@twin.org/api-service';
|
|
5
|
+
import { MimeTypeProcessorFactory, RestRouteProcessorFactory, SocketRouteProcessorFactory } from '@twin.org/api-models';
|
|
6
|
+
import { JwtMimeTypeProcessor, LoggingProcessor, NodeIdentityProcessor, StaticUserIdentityProcessor, RestRouteProcessor, SocketRouteProcessor } from '@twin.org/api-processors';
|
|
7
|
+
|
|
8
|
+
// Copyright 2024 IOTA Stiftung.
|
|
9
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
10
|
+
/**
|
|
11
|
+
* Authentication component types.
|
|
12
|
+
*/
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
14
|
+
const AuthenticationComponentType = {
|
|
15
|
+
/**
|
|
16
|
+
* Entity storage.
|
|
17
|
+
*/
|
|
18
|
+
EntityStorage: "entity-storage"
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Initialise the authentication.
|
|
23
|
+
* @param engineCore The engine core.
|
|
24
|
+
* @param context The context for the engine.
|
|
25
|
+
* @param instanceConfig The instance config.
|
|
26
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
27
|
+
* @returns The name of the instance created.
|
|
28
|
+
* @throws GeneralError if the component type is unknown.
|
|
29
|
+
*/
|
|
30
|
+
function initialiseAuthenticationComponent(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
31
|
+
engineCore.logInfo(I18n.formatMessage("engineCore.configuring", {
|
|
32
|
+
element: `Authentication Component: ${instanceConfig.type}`
|
|
33
|
+
}));
|
|
34
|
+
const type = instanceConfig.type;
|
|
35
|
+
let component;
|
|
36
|
+
let instanceType;
|
|
37
|
+
if (type === AuthenticationComponentType.EntityStorage) {
|
|
38
|
+
initSchema();
|
|
39
|
+
initialiseEntityStorageConnector(engineCore, context, instanceConfig.options?.userEntityStorageType, "AuthenticationUser");
|
|
40
|
+
component = new EntityStorageAuthenticationService({
|
|
41
|
+
vaultConnectorType: context.defaultTypes.vaultConnector,
|
|
42
|
+
...instanceConfig.options
|
|
43
|
+
});
|
|
44
|
+
instanceType = EntityStorageAuthenticationService.NAMESPACE;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
throw new GeneralError("engineCore", "componentUnknownType", {
|
|
48
|
+
type,
|
|
49
|
+
componentType: "authenticationComponent"
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
53
|
+
context.componentInstances.push({
|
|
54
|
+
instanceType: finalInstanceType,
|
|
55
|
+
component
|
|
56
|
+
});
|
|
57
|
+
ComponentFactory.register(finalInstanceType, () => component);
|
|
58
|
+
return finalInstanceType;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Copyright 2024 IOTA Stiftung.
|
|
62
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
63
|
+
/**
|
|
64
|
+
* Information component types.
|
|
65
|
+
*/
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
67
|
+
const InformationComponentType = {
|
|
68
|
+
/**
|
|
69
|
+
* Service.
|
|
70
|
+
*/
|
|
71
|
+
Service: "service"
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Initialise the information component.
|
|
76
|
+
* @param engineCore The engine core.
|
|
77
|
+
* @param context The context for the engine.
|
|
78
|
+
* @param instanceConfig The instance config.
|
|
79
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
80
|
+
* @returns The name of the instance created.
|
|
81
|
+
* @throws GeneralError if the component type is unknown.
|
|
82
|
+
*/
|
|
83
|
+
function initialiseInformationComponent(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
84
|
+
engineCore.logInfo(I18n.formatMessage("engineCore.configuring", {
|
|
85
|
+
element: `Information Component: ${instanceConfig.type}`
|
|
86
|
+
}));
|
|
87
|
+
const type = instanceConfig.type;
|
|
88
|
+
let component;
|
|
89
|
+
let instanceType;
|
|
90
|
+
if (type === InformationComponentType.Service) {
|
|
91
|
+
component = new InformationService(instanceConfig.options);
|
|
92
|
+
instanceType = InformationService.NAMESPACE;
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
throw new GeneralError("engineCore", "componentUnknownType", {
|
|
96
|
+
type,
|
|
97
|
+
componentType: "informationComponent"
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
101
|
+
context.componentInstances.push({
|
|
102
|
+
instanceType: finalInstanceType,
|
|
103
|
+
component
|
|
104
|
+
});
|
|
105
|
+
ComponentFactory.register(finalInstanceType, () => component);
|
|
106
|
+
return finalInstanceType;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Copyright 2024 IOTA Stiftung.
|
|
110
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
111
|
+
/**
|
|
112
|
+
* Mime type route processor types.
|
|
113
|
+
*/
|
|
114
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
115
|
+
const MimeTypeProcessorType = {
|
|
116
|
+
/**
|
|
117
|
+
* Jwt.
|
|
118
|
+
*/
|
|
119
|
+
Jwt: "jwt"
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
// Copyright 2024 IOTA Stiftung.
|
|
123
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
124
|
+
/**
|
|
125
|
+
* Initialise the mime type processor.
|
|
126
|
+
* @param engineCore The engine core.
|
|
127
|
+
* @param context The context for the engine.
|
|
128
|
+
* @param instanceConfig The instance config.
|
|
129
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
130
|
+
* @returns The name of the instance created.
|
|
131
|
+
* @throws GeneralError if the component type is unknown.
|
|
132
|
+
*/
|
|
133
|
+
function initialiseMimeTypeProcessorComponent(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
134
|
+
engineCore.logInfo(I18n.formatMessage("engineCore.configuring", {
|
|
135
|
+
element: `Mime Type Processor: ${instanceConfig.type}`
|
|
136
|
+
}));
|
|
137
|
+
const type = instanceConfig.type;
|
|
138
|
+
let component;
|
|
139
|
+
let instanceType;
|
|
140
|
+
if (type === MimeTypeProcessorType.Jwt) {
|
|
141
|
+
component = new JwtMimeTypeProcessor();
|
|
142
|
+
instanceType = JwtMimeTypeProcessor.NAMESPACE;
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
throw new GeneralError("engineCore", "componentUnknownType", {
|
|
146
|
+
type,
|
|
147
|
+
componentType: "mimeTypeProcessorComponent"
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
151
|
+
context.componentInstances.push({
|
|
152
|
+
instanceType: finalInstanceType,
|
|
153
|
+
component
|
|
154
|
+
});
|
|
155
|
+
MimeTypeProcessorFactory.register(finalInstanceType, () => component);
|
|
156
|
+
return finalInstanceType;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Copyright 2024 IOTA Stiftung.
|
|
160
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
161
|
+
/**
|
|
162
|
+
* REST route processor types.
|
|
163
|
+
*/
|
|
164
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
165
|
+
const RestRouteProcessorType = {
|
|
166
|
+
/**
|
|
167
|
+
* Auth header.
|
|
168
|
+
*/
|
|
169
|
+
AuthHeader: "auth-header",
|
|
170
|
+
/**
|
|
171
|
+
* Logging.
|
|
172
|
+
*/
|
|
173
|
+
Logging: "logging",
|
|
174
|
+
/**
|
|
175
|
+
* Node Identity.
|
|
176
|
+
*/
|
|
177
|
+
NodeIdentity: "node-identity",
|
|
178
|
+
/**
|
|
179
|
+
* Static User Identity.
|
|
180
|
+
*/
|
|
181
|
+
StaticUserIdentity: "static-user-identity",
|
|
182
|
+
/**
|
|
183
|
+
* REST Route.
|
|
184
|
+
*/
|
|
185
|
+
RestRoute: "rest-route"
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
// Copyright 2024 IOTA Stiftung.
|
|
189
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
190
|
+
/**
|
|
191
|
+
* Initialise the rest route processor.
|
|
192
|
+
* @param engineCore The engine core.
|
|
193
|
+
* @param context The context for the engine.
|
|
194
|
+
* @param instanceConfig The instance config.
|
|
195
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
196
|
+
* @returns The name of the instance created.
|
|
197
|
+
* @throws GeneralError if the component type is unknown.
|
|
198
|
+
*/
|
|
199
|
+
function initialiseRestRouteProcessorComponent(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
200
|
+
engineCore.logInfo(I18n.formatMessage("engineCore.configuring", {
|
|
201
|
+
element: `REST Route Processor: ${instanceConfig.type}`
|
|
202
|
+
}));
|
|
203
|
+
const type = instanceConfig.type;
|
|
204
|
+
let component;
|
|
205
|
+
let instanceType;
|
|
206
|
+
if (type === RestRouteProcessorType.AuthHeader) {
|
|
207
|
+
component = new AuthHeaderProcessor({
|
|
208
|
+
vaultConnectorType: context.defaultTypes.vaultConnector,
|
|
209
|
+
config: {
|
|
210
|
+
...instanceConfig.options?.config
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
instanceType = AuthHeaderProcessor.NAMESPACE;
|
|
214
|
+
}
|
|
215
|
+
else if (type === RestRouteProcessorType.Logging) {
|
|
216
|
+
component = new LoggingProcessor({
|
|
217
|
+
loggingConnectorType: context.defaultTypes.loggingConnector,
|
|
218
|
+
config: {
|
|
219
|
+
...instanceConfig.options?.config
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
instanceType = LoggingProcessor.NAMESPACE;
|
|
223
|
+
}
|
|
224
|
+
else if (type === RestRouteProcessorType.NodeIdentity) {
|
|
225
|
+
component = new NodeIdentityProcessor();
|
|
226
|
+
instanceType = NodeIdentityProcessor.NAMESPACE;
|
|
227
|
+
}
|
|
228
|
+
else if (type === RestRouteProcessorType.StaticUserIdentity) {
|
|
229
|
+
component = new StaticUserIdentityProcessor(instanceConfig.options);
|
|
230
|
+
instanceType = StaticUserIdentityProcessor.NAMESPACE;
|
|
231
|
+
}
|
|
232
|
+
else if (type === RestRouteProcessorType.RestRoute) {
|
|
233
|
+
component = new RestRouteProcessor(instanceConfig.options);
|
|
234
|
+
instanceType = RestRouteProcessor.NAMESPACE;
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
throw new GeneralError("engineCore", "componentUnknownType", {
|
|
238
|
+
type,
|
|
239
|
+
componentType: "restRouteProcessorComponent"
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
243
|
+
context.componentInstances.push({
|
|
244
|
+
instanceType: finalInstanceType,
|
|
245
|
+
component
|
|
246
|
+
});
|
|
247
|
+
RestRouteProcessorFactory.register(finalInstanceType, () => component);
|
|
248
|
+
return finalInstanceType;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// Copyright 2024 IOTA Stiftung.
|
|
252
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
253
|
+
/**
|
|
254
|
+
* Socket route processor types.
|
|
255
|
+
*/
|
|
256
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
257
|
+
const SocketRouteProcessorType = {
|
|
258
|
+
/**
|
|
259
|
+
* Auth header.
|
|
260
|
+
*/
|
|
261
|
+
AuthHeader: "auth-header",
|
|
262
|
+
/**
|
|
263
|
+
* Logging.
|
|
264
|
+
*/
|
|
265
|
+
Logging: "logging",
|
|
266
|
+
/**
|
|
267
|
+
* Node Identity.
|
|
268
|
+
*/
|
|
269
|
+
NodeIdentity: "node-identity",
|
|
270
|
+
/**
|
|
271
|
+
* Static User Identity.
|
|
272
|
+
*/
|
|
273
|
+
StaticUserIdentity: "static-user-identity",
|
|
274
|
+
/**
|
|
275
|
+
* Socket Route.
|
|
276
|
+
*/
|
|
277
|
+
SocketRoute: "socket-route"
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
// Copyright 2024 IOTA Stiftung.
|
|
281
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
282
|
+
/**
|
|
283
|
+
* Initialise the socket route processor.
|
|
284
|
+
* @param engineCore The engine core.
|
|
285
|
+
* @param context The context for the engine.
|
|
286
|
+
* @param instanceConfig The instance config.
|
|
287
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
288
|
+
* @returns The name of the instance created.
|
|
289
|
+
* @throws GeneralError if the component type is unknown.
|
|
290
|
+
*/
|
|
291
|
+
function initialiseSocketRouteProcessorComponent(engineCore, context, instanceConfig, overrideInstanceType) {
|
|
292
|
+
engineCore.logInfo(I18n.formatMessage("engineCore.configuring", {
|
|
293
|
+
element: `Socket Route Processor: ${instanceConfig.type}`
|
|
294
|
+
}));
|
|
295
|
+
const type = instanceConfig.type;
|
|
296
|
+
let component;
|
|
297
|
+
let instanceType;
|
|
298
|
+
if (type === SocketRouteProcessorType.AuthHeader) {
|
|
299
|
+
component = new AuthHeaderProcessor({
|
|
300
|
+
vaultConnectorType: context.defaultTypes.vaultConnector,
|
|
301
|
+
config: {
|
|
302
|
+
...instanceConfig.options?.config
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
instanceType = AuthHeaderProcessor.NAMESPACE;
|
|
306
|
+
}
|
|
307
|
+
else if (type === SocketRouteProcessorType.Logging) {
|
|
308
|
+
component = new LoggingProcessor({
|
|
309
|
+
loggingConnectorType: context.defaultTypes.loggingConnector,
|
|
310
|
+
config: {
|
|
311
|
+
...instanceConfig.options?.config
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
instanceType = LoggingProcessor.NAMESPACE;
|
|
315
|
+
}
|
|
316
|
+
else if (type === SocketRouteProcessorType.NodeIdentity) {
|
|
317
|
+
component = new NodeIdentityProcessor();
|
|
318
|
+
instanceType = NodeIdentityProcessor.NAMESPACE;
|
|
319
|
+
}
|
|
320
|
+
else if (type === SocketRouteProcessorType.StaticUserIdentity) {
|
|
321
|
+
component = new StaticUserIdentityProcessor(instanceConfig.options);
|
|
322
|
+
instanceType = StaticUserIdentityProcessor.NAMESPACE;
|
|
323
|
+
}
|
|
324
|
+
else if (type === SocketRouteProcessorType.SocketRoute) {
|
|
325
|
+
component = new SocketRouteProcessor(instanceConfig.options);
|
|
326
|
+
instanceType = SocketRouteProcessor.NAMESPACE;
|
|
327
|
+
}
|
|
328
|
+
else {
|
|
329
|
+
throw new GeneralError("engineCore", "componentUnknownType", {
|
|
330
|
+
type,
|
|
331
|
+
componentType: "socketRouteProcessorComponent"
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
const finalInstanceType = overrideInstanceType ?? instanceType;
|
|
335
|
+
context.componentInstances.push({
|
|
336
|
+
instanceType: finalInstanceType,
|
|
337
|
+
component
|
|
338
|
+
});
|
|
339
|
+
SocketRouteProcessorFactory.register(finalInstanceType, () => component);
|
|
340
|
+
return finalInstanceType;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
export { AuthenticationComponentType, InformationComponentType, MimeTypeProcessorType, RestRouteProcessorType, SocketRouteProcessorType, initialiseAuthenticationComponent, initialiseInformationComponent, initialiseMimeTypeProcessorComponent, initialiseRestRouteProcessorComponent, initialiseSocketRouteProcessorComponent };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { IEngineCoreContext, IEngineCore } from "@twin.org/engine-models";
|
|
2
|
+
import type { AuthenticationComponentConfig } from "../models/config/authenticationComponentConfig";
|
|
3
|
+
import type { IEngineServerTypesConfig } from "../models/IEngineServerTypesConfig";
|
|
4
|
+
/**
|
|
5
|
+
* Initialise the authentication.
|
|
6
|
+
* @param engineCore The engine core.
|
|
7
|
+
* @param context The context for the engine.
|
|
8
|
+
* @param instanceConfig The instance config.
|
|
9
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
10
|
+
* @returns The name of the instance created.
|
|
11
|
+
* @throws GeneralError if the component type is unknown.
|
|
12
|
+
*/
|
|
13
|
+
export declare function initialiseAuthenticationComponent(engineCore: IEngineCore<IEngineServerTypesConfig>, context: IEngineCoreContext<IEngineServerTypesConfig>, instanceConfig: AuthenticationComponentConfig, overrideInstanceType?: string): string | undefined;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { IEngineCore, IEngineCoreContext } from "@twin.org/engine-models";
|
|
2
|
+
import type { InformationComponentConfig } from "../models/config/informationComponentConfig";
|
|
3
|
+
import type { IEngineServerTypesConfig } from "../models/IEngineServerTypesConfig";
|
|
4
|
+
/**
|
|
5
|
+
* Initialise the information component.
|
|
6
|
+
* @param engineCore The engine core.
|
|
7
|
+
* @param context The context for the engine.
|
|
8
|
+
* @param instanceConfig The instance config.
|
|
9
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
10
|
+
* @returns The name of the instance created.
|
|
11
|
+
* @throws GeneralError if the component type is unknown.
|
|
12
|
+
*/
|
|
13
|
+
export declare function initialiseInformationComponent(engineCore: IEngineCore<IEngineServerTypesConfig>, context: IEngineCoreContext<IEngineServerTypesConfig>, instanceConfig: InformationComponentConfig, overrideInstanceType?: string): string | undefined;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { IEngineCore, IEngineCoreContext } from "@twin.org/engine-models";
|
|
2
|
+
import type { MimeTypeProcessorConfig } from "../models/config/mimeTypeProcessorConfig";
|
|
3
|
+
import type { IEngineServerTypesConfig } from "../models/IEngineServerTypesConfig";
|
|
4
|
+
/**
|
|
5
|
+
* Initialise the mime type processor.
|
|
6
|
+
* @param engineCore The engine core.
|
|
7
|
+
* @param context The context for the engine.
|
|
8
|
+
* @param instanceConfig The instance config.
|
|
9
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
10
|
+
* @returns The name of the instance created.
|
|
11
|
+
* @throws GeneralError if the component type is unknown.
|
|
12
|
+
*/
|
|
13
|
+
export declare function initialiseMimeTypeProcessorComponent(engineCore: IEngineCore<IEngineServerTypesConfig>, context: IEngineCoreContext<IEngineServerTypesConfig>, instanceConfig: MimeTypeProcessorConfig, overrideInstanceType?: string): string | undefined;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { IEngineCoreContext, IEngineCore } from "@twin.org/engine-models";
|
|
2
|
+
import type { RestRouteProcessorConfig } from "../models/config/restRouteProcessorConfig";
|
|
3
|
+
import type { IEngineServerTypesConfig } from "../models/IEngineServerTypesConfig";
|
|
4
|
+
/**
|
|
5
|
+
* Initialise the rest route processor.
|
|
6
|
+
* @param engineCore The engine core.
|
|
7
|
+
* @param context The context for the engine.
|
|
8
|
+
* @param instanceConfig The instance config.
|
|
9
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
10
|
+
* @returns The name of the instance created.
|
|
11
|
+
* @throws GeneralError if the component type is unknown.
|
|
12
|
+
*/
|
|
13
|
+
export declare function initialiseRestRouteProcessorComponent(engineCore: IEngineCore<IEngineServerTypesConfig>, context: IEngineCoreContext<IEngineServerTypesConfig>, instanceConfig: RestRouteProcessorConfig, overrideInstanceType?: string): string | undefined;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { IEngineCore, IEngineCoreContext } from "@twin.org/engine-models";
|
|
2
|
+
import type { SocketRouteProcessorConfig } from "../models/config/socketRouteProcessorConfig";
|
|
3
|
+
import type { IEngineServerTypesConfig } from "../models/IEngineServerTypesConfig";
|
|
4
|
+
/**
|
|
5
|
+
* Initialise the socket route processor.
|
|
6
|
+
* @param engineCore The engine core.
|
|
7
|
+
* @param context The context for the engine.
|
|
8
|
+
* @param instanceConfig The instance config.
|
|
9
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
10
|
+
* @returns The name of the instance created.
|
|
11
|
+
* @throws GeneralError if the component type is unknown.
|
|
12
|
+
*/
|
|
13
|
+
export declare function initialiseSocketRouteProcessorComponent(engineCore: IEngineCore<IEngineServerTypesConfig>, context: IEngineCoreContext<IEngineServerTypesConfig>, instanceConfig: SocketRouteProcessorConfig, overrideInstanceType?: string): string | undefined;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export * from "./components/authentication";
|
|
2
|
+
export * from "./components/information";
|
|
3
|
+
export * from "./components/mimeTypeProcessor";
|
|
4
|
+
export * from "./components/restRouteProcessor";
|
|
5
|
+
export * from "./components/socketRouteProcessor";
|
|
6
|
+
export * from "./models/config/authenticationComponentConfig";
|
|
7
|
+
export * from "./models/config/informationComponentConfig";
|
|
8
|
+
export * from "./models/config/mimeTypeProcessorConfig";
|
|
9
|
+
export * from "./models/config/restRouteProcessorConfig";
|
|
10
|
+
export * from "./models/config/socketRouteProcessorConfig";
|
|
11
|
+
export * from "./models/IEngineServerTypesConfig";
|
|
12
|
+
export * from "./models/types/authenticationComponentType";
|
|
13
|
+
export * from "./models/types/informationComponentType";
|
|
14
|
+
export * from "./models/types/mimeTypeProcessorType";
|
|
15
|
+
export * from "./models/types/restRouteProcessorType";
|
|
16
|
+
export * from "./models/types/socketRouteProcessorType";
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { IWebServerOptions } from "@twin.org/api-models";
|
|
2
|
+
import type { IEngineCoreTypeConfig } from "@twin.org/engine-models";
|
|
3
|
+
import type { IEngineCoreTypesConfig } from "@twin.org/engine-types";
|
|
4
|
+
import type { AuthenticationComponentConfig } from "./config/authenticationComponentConfig";
|
|
5
|
+
import type { InformationComponentConfig } from "./config/informationComponentConfig";
|
|
6
|
+
import type { MimeTypeProcessorConfig } from "./config/mimeTypeProcessorConfig";
|
|
7
|
+
import type { RestRouteProcessorConfig } from "./config/restRouteProcessorConfig";
|
|
8
|
+
import type { SocketRouteProcessorConfig } from "./config/socketRouteProcessorConfig";
|
|
9
|
+
/**
|
|
10
|
+
* Extended engine server config with known types.
|
|
11
|
+
*/
|
|
12
|
+
export interface IEngineServerTypesConfig extends IEngineCoreTypesConfig {
|
|
13
|
+
/**
|
|
14
|
+
* Configuration for the web server.
|
|
15
|
+
*/
|
|
16
|
+
web?: IWebServerOptions;
|
|
17
|
+
/**
|
|
18
|
+
* The types to initialise in the engine.
|
|
19
|
+
*/
|
|
20
|
+
types: IEngineCoreTypesConfig["types"] & {
|
|
21
|
+
[type: string]: IEngineCoreTypeConfig[] | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Information component options which can be overridden by individual components by specifying types other than default..
|
|
24
|
+
*/
|
|
25
|
+
informationComponent?: IEngineCoreTypeConfig<InformationComponentConfig>[];
|
|
26
|
+
/**
|
|
27
|
+
* REST route processors options which can be overridden by individual components by specifying types other than default..
|
|
28
|
+
*/
|
|
29
|
+
restRouteProcessor?: IEngineCoreTypeConfig<RestRouteProcessorConfig>[];
|
|
30
|
+
/**
|
|
31
|
+
* Socket route processors options which can be overridden by individual components by specifying types other than default..
|
|
32
|
+
*/
|
|
33
|
+
socketRouteProcessor?: IEngineCoreTypeConfig<SocketRouteProcessorConfig>[];
|
|
34
|
+
/**
|
|
35
|
+
* Mime type processors options which can be overridden by individual components by specifying types other than default..
|
|
36
|
+
*/
|
|
37
|
+
mimeTypeProcessor?: IEngineCoreTypeConfig<MimeTypeProcessorConfig>[];
|
|
38
|
+
/**
|
|
39
|
+
* Authentication component options which can be overridden by individual components by specifying types other than default..
|
|
40
|
+
*/
|
|
41
|
+
authenticationComponent?: IEngineCoreTypeConfig<AuthenticationComponentConfig>[];
|
|
42
|
+
};
|
|
43
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { IEntityStorageAuthenticationServiceConfig } from "@twin.org/api-auth-entity-storage-service";
|
|
2
|
+
import type { AuthenticationComponentType } from "../types/authenticationComponentType";
|
|
3
|
+
/**
|
|
4
|
+
* Authentication component config types.
|
|
5
|
+
*/
|
|
6
|
+
export type AuthenticationComponentConfig = {
|
|
7
|
+
type: typeof AuthenticationComponentType.EntityStorage;
|
|
8
|
+
options?: {
|
|
9
|
+
userEntityStorageType?: string;
|
|
10
|
+
vaultConnectorType?: string;
|
|
11
|
+
config?: IEntityStorageAuthenticationServiceConfig;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IInformationServiceConfig } from "@twin.org/api-service";
|
|
2
|
+
import type { InformationComponentType } from "../types/informationComponentType";
|
|
3
|
+
/**
|
|
4
|
+
* Information component config types.
|
|
5
|
+
*/
|
|
6
|
+
export type InformationComponentConfig = {
|
|
7
|
+
type: typeof InformationComponentType.Service;
|
|
8
|
+
options: {
|
|
9
|
+
config: IInformationServiceConfig;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { IAuthHeaderProcessorConfig } from "@twin.org/api-auth-entity-storage-service";
|
|
2
|
+
import type { ILoggingProcessorConfig, IRouteProcessorConfig, IStaticUserIdentityProcessorConfig } from "@twin.org/api-processors";
|
|
3
|
+
import type { RestRouteProcessorType } from "../types/restRouteProcessorType";
|
|
4
|
+
/**
|
|
5
|
+
* REST route processor config types.
|
|
6
|
+
*/
|
|
7
|
+
export type RestRouteProcessorConfig = {
|
|
8
|
+
type: typeof RestRouteProcessorType.AuthHeader;
|
|
9
|
+
options?: {
|
|
10
|
+
vaultConnectorType?: string;
|
|
11
|
+
config?: IAuthHeaderProcessorConfig;
|
|
12
|
+
};
|
|
13
|
+
} | {
|
|
14
|
+
type: typeof RestRouteProcessorType.Logging;
|
|
15
|
+
options?: {
|
|
16
|
+
loggingConnectorType?: string;
|
|
17
|
+
config?: ILoggingProcessorConfig;
|
|
18
|
+
};
|
|
19
|
+
} | {
|
|
20
|
+
type: typeof RestRouteProcessorType.NodeIdentity;
|
|
21
|
+
options?: never;
|
|
22
|
+
} | {
|
|
23
|
+
type: typeof RestRouteProcessorType.StaticUserIdentity;
|
|
24
|
+
options: {
|
|
25
|
+
config: IStaticUserIdentityProcessorConfig;
|
|
26
|
+
};
|
|
27
|
+
} | {
|
|
28
|
+
type: typeof RestRouteProcessorType.RestRoute;
|
|
29
|
+
options?: {
|
|
30
|
+
config?: IRouteProcessorConfig;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { IAuthHeaderProcessorConfig } from "@twin.org/api-auth-entity-storage-service";
|
|
2
|
+
import type { ILoggingProcessorConfig, IRouteProcessorConfig, IStaticUserIdentityProcessorConfig } from "@twin.org/api-processors";
|
|
3
|
+
import type { SocketRouteProcessorType } from "../types/socketRouteProcessorType";
|
|
4
|
+
/**
|
|
5
|
+
* Socket route processor config types.
|
|
6
|
+
*/
|
|
7
|
+
export type SocketRouteProcessorConfig = {
|
|
8
|
+
type: typeof SocketRouteProcessorType.AuthHeader;
|
|
9
|
+
options?: {
|
|
10
|
+
vaultConnectorType?: string;
|
|
11
|
+
config?: IAuthHeaderProcessorConfig;
|
|
12
|
+
};
|
|
13
|
+
} | {
|
|
14
|
+
type: typeof SocketRouteProcessorType.Logging;
|
|
15
|
+
options?: {
|
|
16
|
+
loggingConnectorType?: string;
|
|
17
|
+
config?: ILoggingProcessorConfig;
|
|
18
|
+
};
|
|
19
|
+
} | {
|
|
20
|
+
type: typeof SocketRouteProcessorType.NodeIdentity;
|
|
21
|
+
options?: never;
|
|
22
|
+
} | {
|
|
23
|
+
type: typeof SocketRouteProcessorType.StaticUserIdentity;
|
|
24
|
+
options: {
|
|
25
|
+
config: IStaticUserIdentityProcessorConfig;
|
|
26
|
+
};
|
|
27
|
+
} | {
|
|
28
|
+
type: typeof SocketRouteProcessorType.SocketRoute;
|
|
29
|
+
options?: {
|
|
30
|
+
config?: IRouteProcessorConfig;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authentication component types.
|
|
3
|
+
*/
|
|
4
|
+
export declare const AuthenticationComponentType: {
|
|
5
|
+
/**
|
|
6
|
+
* Entity storage.
|
|
7
|
+
*/
|
|
8
|
+
readonly EntityStorage: "entity-storage";
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Authentication component types.
|
|
12
|
+
*/
|
|
13
|
+
export type AuthenticationComponentType = (typeof AuthenticationComponentType)[keyof typeof AuthenticationComponentType];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Information component types.
|
|
3
|
+
*/
|
|
4
|
+
export declare const InformationComponentType: {
|
|
5
|
+
/**
|
|
6
|
+
* Service.
|
|
7
|
+
*/
|
|
8
|
+
readonly Service: "service";
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Information component types.
|
|
12
|
+
*/
|
|
13
|
+
export type InformationComponentType = (typeof InformationComponentType)[keyof typeof InformationComponentType];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mime type route processor types.
|
|
3
|
+
*/
|
|
4
|
+
export declare const MimeTypeProcessorType: {
|
|
5
|
+
/**
|
|
6
|
+
* Jwt.
|
|
7
|
+
*/
|
|
8
|
+
readonly Jwt: "jwt";
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Mime type processor types.
|
|
12
|
+
*/
|
|
13
|
+
export type MimeTypeProcessorType = (typeof MimeTypeProcessorType)[keyof typeof MimeTypeProcessorType];
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* REST route processor types.
|
|
3
|
+
*/
|
|
4
|
+
export declare const RestRouteProcessorType: {
|
|
5
|
+
/**
|
|
6
|
+
* Auth header.
|
|
7
|
+
*/
|
|
8
|
+
readonly AuthHeader: "auth-header";
|
|
9
|
+
/**
|
|
10
|
+
* Logging.
|
|
11
|
+
*/
|
|
12
|
+
readonly Logging: "logging";
|
|
13
|
+
/**
|
|
14
|
+
* Node Identity.
|
|
15
|
+
*/
|
|
16
|
+
readonly NodeIdentity: "node-identity";
|
|
17
|
+
/**
|
|
18
|
+
* Static User Identity.
|
|
19
|
+
*/
|
|
20
|
+
readonly StaticUserIdentity: "static-user-identity";
|
|
21
|
+
/**
|
|
22
|
+
* REST Route.
|
|
23
|
+
*/
|
|
24
|
+
readonly RestRoute: "rest-route";
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* REST route processor types.
|
|
28
|
+
*/
|
|
29
|
+
export type RestRouteProcessorType = (typeof RestRouteProcessorType)[keyof typeof RestRouteProcessorType];
|