@twin.org/engine-server-types 0.0.3-next.3 → 0.0.3-next.30
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/README.md +1 -1
- package/dist/es/components/authentication.js +23 -19
- package/dist/es/components/authentication.js.map +1 -1
- package/dist/es/components/authenticationAdmin.js +19 -15
- package/dist/es/components/authenticationAdmin.js.map +1 -1
- package/dist/es/components/authenticationAudit.js +35 -0
- package/dist/es/components/authenticationAudit.js.map +1 -0
- package/dist/es/components/authenticationRate.js +37 -0
- package/dist/es/components/authenticationRate.js.map +1 -0
- package/dist/es/components/hosting.js +29 -0
- package/dist/es/components/hosting.js.map +1 -0
- package/dist/es/components/information.js +12 -9
- package/dist/es/components/information.js.map +1 -1
- package/dist/es/components/mimeTypeProcessor.js +7 -7
- package/dist/es/components/mimeTypeProcessor.js.map +1 -1
- package/dist/es/components/restRouteProcessor.js +38 -46
- package/dist/es/components/restRouteProcessor.js.map +1 -1
- package/dist/es/components/socketRouteProcessor.js +34 -42
- package/dist/es/components/socketRouteProcessor.js.map +1 -1
- package/dist/es/index.js +9 -0
- package/dist/es/index.js.map +1 -1
- package/dist/es/models/IEngineServerConfig.js.map +1 -1
- package/dist/es/models/config/authenticationAuditComponentConfig.js +2 -0
- package/dist/es/models/config/authenticationAuditComponentConfig.js.map +1 -0
- package/dist/es/models/config/authenticationRateComponentConfig.js +2 -0
- package/dist/es/models/config/authenticationRateComponentConfig.js.map +1 -0
- package/dist/es/models/config/hostingComponentConfig.js +2 -0
- package/dist/es/models/config/hostingComponentConfig.js.map +1 -0
- package/dist/es/models/config/restRouteProcessorConfig.js.map +1 -1
- package/dist/es/models/config/socketRouteProcessorConfig.js.map +1 -1
- package/dist/es/models/types/authenticationAuditComponentType.js +13 -0
- package/dist/es/models/types/authenticationAuditComponentType.js.map +1 -0
- package/dist/es/models/types/authenticationRateComponentType.js +13 -0
- package/dist/es/models/types/authenticationRateComponentType.js.map +1 -0
- package/dist/es/models/types/hostingComponentType.js +13 -0
- package/dist/es/models/types/hostingComponentType.js.map +1 -0
- package/dist/types/components/authentication.d.ts +3 -7
- package/dist/types/components/authenticationAdmin.d.ts +3 -7
- package/dist/types/components/authenticationAudit.d.ts +12 -0
- package/dist/types/components/authenticationRate.d.ts +12 -0
- package/dist/types/components/hosting.d.ts +12 -0
- package/dist/types/components/information.d.ts +3 -7
- package/dist/types/components/mimeTypeProcessor.d.ts +2 -7
- package/dist/types/components/restRouteProcessor.d.ts +2 -7
- package/dist/types/components/socketRouteProcessor.d.ts +2 -7
- package/dist/types/index.d.ts +9 -0
- package/dist/types/models/IEngineServerConfig.d.ts +21 -6
- package/dist/types/models/config/authenticationAuditComponentConfig.d.ts +9 -0
- package/dist/types/models/config/authenticationRateComponentConfig.d.ts +9 -0
- package/dist/types/models/config/hostingComponentConfig.d.ts +9 -0
- package/dist/types/models/config/restRouteProcessorConfig.d.ts +0 -4
- package/dist/types/models/config/socketRouteProcessorConfig.d.ts +0 -4
- package/dist/types/models/types/authenticationAuditComponentType.d.ts +13 -0
- package/dist/types/models/types/authenticationRateComponentType.d.ts +13 -0
- package/dist/types/models/types/hostingComponentType.d.ts +13 -0
- package/docs/changelog.md +463 -1
- package/docs/examples.md +64 -1
- package/docs/reference/functions/initialiseAuthenticationAdminComponent.md +2 -2
- package/docs/reference/functions/initialiseAuthenticationAuditComponent.md +31 -0
- package/docs/reference/functions/initialiseAuthenticationComponent.md +2 -2
- package/docs/reference/functions/initialiseAuthenticationRateComponent.md +31 -0
- package/docs/reference/functions/initialiseHostingComponent.md +31 -0
- package/docs/reference/functions/initialiseInformationComponent.md +2 -2
- package/docs/reference/functions/initialiseMimeTypeProcessorComponent.md +2 -2
- package/docs/reference/functions/initialiseRestRouteProcessorComponent.md +2 -2
- package/docs/reference/functions/initialiseSocketRouteProcessorComponent.md +2 -2
- package/docs/reference/index.md +12 -0
- package/docs/reference/interfaces/IEngineServerConfig.md +473 -15
- package/docs/reference/type-aliases/AuthenticationAdminComponentConfig.md +3 -3
- package/docs/reference/type-aliases/AuthenticationAuditComponentConfig.md +17 -0
- package/docs/reference/type-aliases/AuthenticationAuditComponentType.md +5 -0
- package/docs/reference/type-aliases/AuthenticationRateComponentConfig.md +17 -0
- package/docs/reference/type-aliases/AuthenticationRateComponentType.md +5 -0
- package/docs/reference/type-aliases/HostingComponentConfig.md +17 -0
- package/docs/reference/type-aliases/HostingComponentType.md +5 -0
- package/docs/reference/type-aliases/MimeTypeProcessorConfig.md +3 -3
- package/docs/reference/type-aliases/RestRouteProcessorConfig.md +1 -1
- package/docs/reference/type-aliases/SocketRouteProcessorConfig.md +1 -1
- package/docs/reference/variables/AuthenticationAdminComponentType.md +1 -1
- package/docs/reference/variables/AuthenticationAuditComponentType.md +13 -0
- package/docs/reference/variables/AuthenticationComponentType.md +2 -2
- package/docs/reference/variables/AuthenticationRateComponentType.md +13 -0
- package/docs/reference/variables/HostingComponentType.md +13 -0
- package/docs/reference/variables/InformationComponentType.md +2 -2
- package/docs/reference/variables/MimeTypeProcessorType.md +1 -1
- package/docs/reference/variables/RestRouteProcessorType.md +7 -7
- package/docs/reference/variables/SocketRouteProcessorType.md +7 -7
- package/package.json +4 -5
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# TWIN Engine Server Types
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Engine Server Types defines server-focused component and processor types for hosting and API route handling. It provides the configuration model for building predictable REST and socket integration behaviour.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
// Copyright 2024 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
1
3
|
import { EntityStorageAuthenticationRestClient } from "@twin.org/api-auth-entity-storage-rest-client";
|
|
2
4
|
import { EntityStorageAuthenticationService, initSchema as initSchemaAuthEntityStorage } from "@twin.org/api-auth-entity-storage-service";
|
|
3
5
|
import { ContextIdHelper, ContextIdKeys } from "@twin.org/context";
|
|
4
6
|
import { ComponentFactory } from "@twin.org/core";
|
|
5
|
-
import { initialiseEntityStorageConnector } from "@twin.org/engine-types";
|
|
7
|
+
import { EngineTypeHelper, initialiseEntityStorageConnector } from "@twin.org/engine-types";
|
|
6
8
|
import { AuthenticationComponentType } from "../models/types/authenticationComponentType.js";
|
|
7
9
|
/**
|
|
8
10
|
* Initialise the authentication.
|
|
@@ -11,29 +13,31 @@ import { AuthenticationComponentType } from "../models/types/authenticationCompo
|
|
|
11
13
|
* @param instanceConfig The instance config.
|
|
12
14
|
* @returns The instance created and the factory for it.
|
|
13
15
|
*/
|
|
14
|
-
export
|
|
15
|
-
let
|
|
16
|
-
let
|
|
16
|
+
export function initialiseAuthenticationComponent(engineCore, context, instanceConfig) {
|
|
17
|
+
let createComponent;
|
|
18
|
+
let instanceTypeName;
|
|
17
19
|
if (instanceConfig.type === AuthenticationComponentType.EntityStorage) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
20
|
+
createComponent = (createConfig) => {
|
|
21
|
+
initSchemaAuthEntityStorage();
|
|
22
|
+
initialiseEntityStorageConnector(engineCore, context, createConfig.options?.userEntityStorageType, "AuthenticationUser", ContextIdHelper.pickKeysFromAvailable(engineCore.getContextIdKeys(), [
|
|
23
|
+
ContextIdKeys.Node,
|
|
24
|
+
ContextIdKeys.Tenant
|
|
25
|
+
]));
|
|
26
|
+
return new EntityStorageAuthenticationService(EngineTypeHelper.mergeConfig({
|
|
27
|
+
vaultConnectorType: engineCore.getRegisteredInstanceType("vaultConnector"),
|
|
28
|
+
authenticationAuditServiceType: engineCore.getRegisteredInstanceTypeOptional("authenticationAuditComponent"),
|
|
29
|
+
authenticationRateServiceType: engineCore.getRegisteredInstanceType("authenticationRateComponent")
|
|
30
|
+
}, createConfig.options));
|
|
31
|
+
};
|
|
32
|
+
instanceTypeName = "entity-storage-authentication-service";
|
|
29
33
|
}
|
|
30
34
|
else if (instanceConfig.type === AuthenticationComponentType.RestClient) {
|
|
31
|
-
|
|
32
|
-
|
|
35
|
+
createComponent = (createConfig) => new EntityStorageAuthenticationRestClient(EngineTypeHelper.mergeConfig(createConfig.options));
|
|
36
|
+
instanceTypeName = "entity-storage-authentication-rest-client";
|
|
33
37
|
}
|
|
34
38
|
return {
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
createComponent: createComponent,
|
|
40
|
+
instanceTypeName,
|
|
37
41
|
factory: ComponentFactory
|
|
38
42
|
};
|
|
39
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authentication.js","sourceRoot":"","sources":["../../../src/components/authentication.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"authentication.js","sourceRoot":"","sources":["../../../src/components/authentication.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,qCAAqC,EAAE,MAAM,+CAA+C,CAAC;AACtG,OAAO,EACN,kCAAkC,EAClC,UAAU,IAAI,2BAA2B,EAEzC,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAmB,MAAM,gBAAgB,CAAC;AAMnE,OAAO,EAAE,gBAAgB,EAAE,gCAAgC,EAAE,MAAM,wBAAwB,CAAC;AAI5F,OAAO,EAAE,2BAA2B,EAAE,MAAM,gDAAgD,CAAC;AAE7F;;;;;;GAMG;AACH,MAAM,UAAU,iCAAiC,CAChD,UAA4C,EAC5C,OAAgD,EAChD,cAA6C;IAE7C,IAAI,eAAe,CAAC;IACpB,IAAI,gBAAgB,CAAC;IAErB,IAAI,cAAc,CAAC,IAAI,KAAK,2BAA2B,CAAC,aAAa,EAAE,CAAC;QACvE,eAAe,GAAG,CAAC,YAAmC,EAAE,EAAE;YACzD,2BAA2B,EAAE,CAAC;YAC9B,gCAAgC,CAC/B,UAAU,EACV,OAAO,EACP,YAAY,CAAC,OAAO,EAAE,qBAAqB,wBAE3C,eAAe,CAAC,qBAAqB,CAAC,UAAU,CAAC,gBAAgB,EAAE,EAAE;gBACpE,aAAa,CAAC,IAAI;gBAClB,aAAa,CAAC,MAAM;aACpB,CAAC,CACF,CAAC;YACF,OAAO,IAAI,kCAAkC,CAC5C,gBAAgB,CAAC,WAAW,CAC3B;gBACC,kBAAkB,EAAE,UAAU,CAAC,yBAAyB,CAAC,gBAAgB,CAAC;gBAC1E,8BAA8B,EAAE,UAAU,CAAC,iCAAiC,CAC3E,8BAA8B,CAC9B;gBACD,6BAA6B,EAAE,UAAU,CAAC,yBAAyB,CAClE,6BAA6B,CAC7B;aACD,EACD,YAAY,CAAC,OAAO,CACpB,CACD,CAAC;QACH,CAAC,CAAC;QACF,gBAAgB,0CAAsD,CAAC;IACxE,CAAC;SAAM,IAAI,cAAc,CAAC,IAAI,KAAK,2BAA2B,CAAC,UAAU,EAAE,CAAC;QAC3E,eAAe,GAAG,CAAC,YAAmC,EAAE,EAAE,CACzD,IAAI,qCAAqC,CACxC,gBAAgB,CAAC,WAAW,CAAqC,YAAY,CAAC,OAAO,CAAC,CACtF,CAAC;QACH,gBAAgB,8CAAyD,CAAC;IAC3E,CAAC;IAED,OAAO;QACN,eAAe,EAAE,eAAsE;QACvF,gBAAgB;QAChB,OAAO,EAAE,gBAAgB;KACzB,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { EntityStorageAuthenticationRestClient } from \"@twin.org/api-auth-entity-storage-rest-client\";\nimport {\n\tEntityStorageAuthenticationService,\n\tinitSchema as initSchemaAuthEntityStorage,\n\ttype AuthenticationUser\n} from \"@twin.org/api-auth-entity-storage-service\";\nimport { ContextIdHelper, ContextIdKeys } from \"@twin.org/context\";\nimport { ComponentFactory, type IComponent } from \"@twin.org/core\";\nimport type {\n\tEngineTypeInitialiserReturn,\n\tIEngineCore,\n\tIEngineCoreContext\n} from \"@twin.org/engine-models\";\nimport { EngineTypeHelper, initialiseEntityStorageConnector } from \"@twin.org/engine-types\";\nimport { nameof, nameofKebabCase } from \"@twin.org/nameof\";\nimport type { AuthenticationComponentConfig } from \"../models/config/authenticationComponentConfig.js\";\nimport type { IEngineServerConfig } from \"../models/IEngineServerConfig.js\";\nimport { AuthenticationComponentType } from \"../models/types/authenticationComponentType.js\";\n\n/**\n * Initialise the authentication.\n * @param engineCore The engine core.\n * @param context The context for the engine.\n * @param instanceConfig The instance config.\n * @returns The instance created and the factory for it.\n */\nexport function initialiseAuthenticationComponent(\n\tengineCore: IEngineCore<IEngineServerConfig>,\n\tcontext: IEngineCoreContext<IEngineServerConfig>,\n\tinstanceConfig: AuthenticationComponentConfig\n): EngineTypeInitialiserReturn<AuthenticationComponentConfig, typeof ComponentFactory> {\n\tlet createComponent;\n\tlet instanceTypeName;\n\n\tif (instanceConfig.type === AuthenticationComponentType.EntityStorage) {\n\t\tcreateComponent = (createConfig: typeof instanceConfig) => {\n\t\t\tinitSchemaAuthEntityStorage();\n\t\t\tinitialiseEntityStorageConnector(\n\t\t\t\tengineCore,\n\t\t\t\tcontext,\n\t\t\t\tcreateConfig.options?.userEntityStorageType,\n\t\t\t\tnameof<AuthenticationUser>(),\n\t\t\t\tContextIdHelper.pickKeysFromAvailable(engineCore.getContextIdKeys(), [\n\t\t\t\t\tContextIdKeys.Node,\n\t\t\t\t\tContextIdKeys.Tenant\n\t\t\t\t])\n\t\t\t);\n\t\t\treturn new EntityStorageAuthenticationService(\n\t\t\t\tEngineTypeHelper.mergeConfig<(typeof instanceConfig)[\"options\"]>(\n\t\t\t\t\t{\n\t\t\t\t\t\tvaultConnectorType: engineCore.getRegisteredInstanceType(\"vaultConnector\"),\n\t\t\t\t\t\tauthenticationAuditServiceType: engineCore.getRegisteredInstanceTypeOptional(\n\t\t\t\t\t\t\t\"authenticationAuditComponent\"\n\t\t\t\t\t\t),\n\t\t\t\t\t\tauthenticationRateServiceType: engineCore.getRegisteredInstanceType(\n\t\t\t\t\t\t\t\"authenticationRateComponent\"\n\t\t\t\t\t\t)\n\t\t\t\t\t},\n\t\t\t\t\tcreateConfig.options\n\t\t\t\t)\n\t\t\t);\n\t\t};\n\t\tinstanceTypeName = nameofKebabCase(EntityStorageAuthenticationService);\n\t} else if (instanceConfig.type === AuthenticationComponentType.RestClient) {\n\t\tcreateComponent = (createConfig: typeof instanceConfig) =>\n\t\t\tnew EntityStorageAuthenticationRestClient(\n\t\t\t\tEngineTypeHelper.mergeConfig<(typeof instanceConfig)[\"options\"]>(createConfig.options)\n\t\t\t);\n\t\tinstanceTypeName = nameofKebabCase(EntityStorageAuthenticationRestClient);\n\t}\n\n\treturn {\n\t\tcreateComponent: createComponent as (createConfig: typeof instanceConfig) => IComponent,\n\t\tinstanceTypeName,\n\t\tfactory: ComponentFactory\n\t};\n}\n"]}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
// Copyright 2024 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
1
3
|
import { EntityStorageAuthenticationAdminService, initSchema as initSchemaAuthEntityStorage } from "@twin.org/api-auth-entity-storage-service";
|
|
2
4
|
import { ContextIdHelper, ContextIdKeys } from "@twin.org/context";
|
|
3
5
|
import { ComponentFactory } from "@twin.org/core";
|
|
4
|
-
import { initialiseEntityStorageConnector } from "@twin.org/engine-types";
|
|
6
|
+
import { EngineTypeHelper, initialiseEntityStorageConnector } from "@twin.org/engine-types";
|
|
5
7
|
import { AuthenticationAdminComponentType } from "../models/types/authenticationAdminComponentType.js";
|
|
6
8
|
/**
|
|
7
9
|
* Initialise the authentication admin.
|
|
@@ -10,23 +12,25 @@ import { AuthenticationAdminComponentType } from "../models/types/authentication
|
|
|
10
12
|
* @param instanceConfig The instance config.
|
|
11
13
|
* @returns The instance created and the factory for it.
|
|
12
14
|
*/
|
|
13
|
-
export
|
|
14
|
-
let
|
|
15
|
-
let
|
|
15
|
+
export function initialiseAuthenticationAdminComponent(engineCore, context, instanceConfig) {
|
|
16
|
+
let createComponent;
|
|
17
|
+
let instanceTypeName;
|
|
16
18
|
if (instanceConfig.type === AuthenticationAdminComponentType.EntityStorage) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
createComponent = (createConfig) => {
|
|
20
|
+
initSchemaAuthEntityStorage();
|
|
21
|
+
initialiseEntityStorageConnector(engineCore, context, createConfig.options?.userEntityStorageType, "AuthenticationUser", ContextIdHelper.pickKeysFromAvailable(engineCore.getContextIdKeys(), [
|
|
22
|
+
ContextIdKeys.Node,
|
|
23
|
+
ContextIdKeys.Tenant
|
|
24
|
+
]));
|
|
25
|
+
return new EntityStorageAuthenticationAdminService(EngineTypeHelper.mergeConfig({
|
|
26
|
+
authenticationAuditServiceType: engineCore.getRegisteredInstanceTypeOptional("authenticationAuditComponent")
|
|
27
|
+
}, createConfig.options));
|
|
28
|
+
};
|
|
29
|
+
instanceTypeName = "entity-storage-authentication-admin-service";
|
|
26
30
|
}
|
|
27
31
|
return {
|
|
28
|
-
|
|
29
|
-
|
|
32
|
+
createComponent: createComponent,
|
|
33
|
+
instanceTypeName,
|
|
30
34
|
factory: ComponentFactory
|
|
31
35
|
};
|
|
32
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authenticationAdmin.js","sourceRoot":"","sources":["../../../src/components/authenticationAdmin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"authenticationAdmin.js","sourceRoot":"","sources":["../../../src/components/authenticationAdmin.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,uCAAuC,EACvC,UAAU,IAAI,2BAA2B,EAEzC,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAmB,MAAM,gBAAgB,CAAC;AAMnE,OAAO,EAAE,gBAAgB,EAAE,gCAAgC,EAAE,MAAM,wBAAwB,CAAC;AAI5F,OAAO,EAAE,gCAAgC,EAAE,MAAM,qDAAqD,CAAC;AAEvG;;;;;;GAMG;AACH,MAAM,UAAU,sCAAsC,CACrD,UAA4C,EAC5C,OAAgD,EAChD,cAAkD;IAElD,IAAI,eAAe,CAAC;IACpB,IAAI,gBAAgB,CAAC;IAErB,IAAI,cAAc,CAAC,IAAI,KAAK,gCAAgC,CAAC,aAAa,EAAE,CAAC;QAC5E,eAAe,GAAG,CAAC,YAAmC,EAAE,EAAE;YACzD,2BAA2B,EAAE,CAAC;YAC9B,gCAAgC,CAC/B,UAAU,EACV,OAAO,EACP,YAAY,CAAC,OAAO,EAAE,qBAAqB,wBAE3C,eAAe,CAAC,qBAAqB,CAAC,UAAU,CAAC,gBAAgB,EAAE,EAAE;gBACpE,aAAa,CAAC,IAAI;gBAClB,aAAa,CAAC,MAAM;aACpB,CAAC,CACF,CAAC;YACF,OAAO,IAAI,uCAAuC,CACjD,gBAAgB,CAAC,WAAW,CAC3B;gBACC,8BAA8B,EAAE,UAAU,CAAC,iCAAiC,CAC3E,8BAA8B,CAC9B;aACD,EACD,YAAY,CAAC,OAAO,CACpB,CACD,CAAC;QACH,CAAC,CAAC;QACF,gBAAgB,gDAA2D,CAAC;IAC7E,CAAC;IAED,OAAO;QACN,eAAe,EAAE,eAAsE;QACvF,gBAAgB;QAChB,OAAO,EAAE,gBAAgB;KACzB,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport {\n\tEntityStorageAuthenticationAdminService,\n\tinitSchema as initSchemaAuthEntityStorage,\n\ttype AuthenticationUser\n} from \"@twin.org/api-auth-entity-storage-service\";\nimport { ContextIdHelper, ContextIdKeys } from \"@twin.org/context\";\nimport { ComponentFactory, type IComponent } from \"@twin.org/core\";\nimport type {\n\tEngineTypeInitialiserReturn,\n\tIEngineCore,\n\tIEngineCoreContext\n} from \"@twin.org/engine-models\";\nimport { EngineTypeHelper, initialiseEntityStorageConnector } from \"@twin.org/engine-types\";\nimport { nameof, nameofKebabCase } from \"@twin.org/nameof\";\nimport type { AuthenticationAdminComponentConfig } from \"../models/config/authenticationAdminComponentConfig.js\";\nimport type { IEngineServerConfig } from \"../models/IEngineServerConfig.js\";\nimport { AuthenticationAdminComponentType } from \"../models/types/authenticationAdminComponentType.js\";\n\n/**\n * Initialise the authentication admin.\n * @param engineCore The engine core.\n * @param context The context for the engine.\n * @param instanceConfig The instance config.\n * @returns The instance created and the factory for it.\n */\nexport function initialiseAuthenticationAdminComponent(\n\tengineCore: IEngineCore<IEngineServerConfig>,\n\tcontext: IEngineCoreContext<IEngineServerConfig>,\n\tinstanceConfig: AuthenticationAdminComponentConfig\n): EngineTypeInitialiserReturn<AuthenticationAdminComponentConfig, typeof ComponentFactory> {\n\tlet createComponent;\n\tlet instanceTypeName;\n\n\tif (instanceConfig.type === AuthenticationAdminComponentType.EntityStorage) {\n\t\tcreateComponent = (createConfig: typeof instanceConfig) => {\n\t\t\tinitSchemaAuthEntityStorage();\n\t\t\tinitialiseEntityStorageConnector(\n\t\t\t\tengineCore,\n\t\t\t\tcontext,\n\t\t\t\tcreateConfig.options?.userEntityStorageType,\n\t\t\t\tnameof<AuthenticationUser>(),\n\t\t\t\tContextIdHelper.pickKeysFromAvailable(engineCore.getContextIdKeys(), [\n\t\t\t\t\tContextIdKeys.Node,\n\t\t\t\t\tContextIdKeys.Tenant\n\t\t\t\t])\n\t\t\t);\n\t\t\treturn new EntityStorageAuthenticationAdminService(\n\t\t\t\tEngineTypeHelper.mergeConfig<(typeof instanceConfig)[\"options\"]>(\n\t\t\t\t\t{\n\t\t\t\t\t\tauthenticationAuditServiceType: engineCore.getRegisteredInstanceTypeOptional(\n\t\t\t\t\t\t\t\"authenticationAuditComponent\"\n\t\t\t\t\t\t)\n\t\t\t\t\t},\n\t\t\t\t\tcreateConfig.options\n\t\t\t\t)\n\t\t\t);\n\t\t};\n\t\tinstanceTypeName = nameofKebabCase(EntityStorageAuthenticationAdminService);\n\t}\n\n\treturn {\n\t\tcreateComponent: createComponent as (createConfig: typeof instanceConfig) => IComponent,\n\t\tinstanceTypeName,\n\t\tfactory: ComponentFactory\n\t};\n}\n"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Copyright 2026 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
import { EntityStorageAuthenticationAuditService, initSchema as initSchemaAuthEntityStorage } from "@twin.org/api-auth-entity-storage-service";
|
|
4
|
+
import { ContextIdHelper, ContextIdKeys } from "@twin.org/context";
|
|
5
|
+
import { ComponentFactory } from "@twin.org/core";
|
|
6
|
+
import { EngineTypeHelper, initialiseEntityStorageConnector } from "@twin.org/engine-types";
|
|
7
|
+
import { AuthenticationAuditComponentType } from "../models/types/authenticationAuditComponentType.js";
|
|
8
|
+
/**
|
|
9
|
+
* Initialise the authentication audit.
|
|
10
|
+
* @param engineCore The engine core.
|
|
11
|
+
* @param context The context for the engine.
|
|
12
|
+
* @param instanceConfig The instance config.
|
|
13
|
+
* @returns The instance created and the factory for it.
|
|
14
|
+
*/
|
|
15
|
+
export function initialiseAuthenticationAuditComponent(engineCore, context, instanceConfig) {
|
|
16
|
+
let createComponent;
|
|
17
|
+
let instanceTypeName;
|
|
18
|
+
if (instanceConfig.type === AuthenticationAuditComponentType.EntityStorage) {
|
|
19
|
+
createComponent = (createConfig) => {
|
|
20
|
+
initSchemaAuthEntityStorage();
|
|
21
|
+
initialiseEntityStorageConnector(engineCore, context, createConfig.options?.authenticationAuditEntryStorageType, "AuthenticationAuditEntry", ContextIdHelper.pickKeysFromAvailable(engineCore.getContextIdKeys(), [
|
|
22
|
+
ContextIdKeys.Node,
|
|
23
|
+
ContextIdKeys.Tenant
|
|
24
|
+
]));
|
|
25
|
+
return new EntityStorageAuthenticationAuditService(EngineTypeHelper.mergeConfig(createConfig.options));
|
|
26
|
+
};
|
|
27
|
+
instanceTypeName = "entity-storage-authentication-audit-service";
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
createComponent: createComponent,
|
|
31
|
+
instanceTypeName,
|
|
32
|
+
factory: ComponentFactory
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=authenticationAudit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authenticationAudit.js","sourceRoot":"","sources":["../../../src/components/authenticationAudit.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,uCAAuC,EACvC,UAAU,IAAI,2BAA2B,EAEzC,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAmB,MAAM,gBAAgB,CAAC;AAMnE,OAAO,EAAE,gBAAgB,EAAE,gCAAgC,EAAE,MAAM,wBAAwB,CAAC;AAI5F,OAAO,EAAE,gCAAgC,EAAE,MAAM,qDAAqD,CAAC;AAEvG;;;;;;GAMG;AACH,MAAM,UAAU,sCAAsC,CACrD,UAA4C,EAC5C,OAAgD,EAChD,cAAkD;IAElD,IAAI,eAAe,CAAC;IACpB,IAAI,gBAAgB,CAAC;IAErB,IAAI,cAAc,CAAC,IAAI,KAAK,gCAAgC,CAAC,aAAa,EAAE,CAAC;QAC5E,eAAe,GAAG,CAAC,YAAmC,EAAE,EAAE;YACzD,2BAA2B,EAAE,CAAC;YAC9B,gCAAgC,CAC/B,UAAU,EACV,OAAO,EACP,YAAY,CAAC,OAAO,EAAE,mCAAmC,8BAEzD,eAAe,CAAC,qBAAqB,CAAC,UAAU,CAAC,gBAAgB,EAAE,EAAE;gBACpE,aAAa,CAAC,IAAI;gBAClB,aAAa,CAAC,MAAM;aACpB,CAAC,CACF,CAAC;YACF,OAAO,IAAI,uCAAuC,CACjD,gBAAgB,CAAC,WAAW,CAAqC,YAAY,CAAC,OAAO,CAAC,CACtF,CAAC;QACH,CAAC,CAAC;QACF,gBAAgB,gDAA2D,CAAC;IAC7E,CAAC;IAED,OAAO;QACN,eAAe,EAAE,eAAsE;QACvF,gBAAgB;QAChB,OAAO,EAAE,gBAAgB;KACzB,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport {\n\tEntityStorageAuthenticationAuditService,\n\tinitSchema as initSchemaAuthEntityStorage,\n\ttype AuthenticationAuditEntry\n} from \"@twin.org/api-auth-entity-storage-service\";\nimport { ContextIdHelper, ContextIdKeys } from \"@twin.org/context\";\nimport { ComponentFactory, type IComponent } from \"@twin.org/core\";\nimport type {\n\tEngineTypeInitialiserReturn,\n\tIEngineCore,\n\tIEngineCoreContext\n} from \"@twin.org/engine-models\";\nimport { EngineTypeHelper, initialiseEntityStorageConnector } from \"@twin.org/engine-types\";\nimport { nameof, nameofKebabCase } from \"@twin.org/nameof\";\nimport type { AuthenticationAuditComponentConfig } from \"../models/config/authenticationAuditComponentConfig.js\";\nimport type { IEngineServerConfig } from \"../models/IEngineServerConfig.js\";\nimport { AuthenticationAuditComponentType } from \"../models/types/authenticationAuditComponentType.js\";\n\n/**\n * Initialise the authentication audit.\n * @param engineCore The engine core.\n * @param context The context for the engine.\n * @param instanceConfig The instance config.\n * @returns The instance created and the factory for it.\n */\nexport function initialiseAuthenticationAuditComponent(\n\tengineCore: IEngineCore<IEngineServerConfig>,\n\tcontext: IEngineCoreContext<IEngineServerConfig>,\n\tinstanceConfig: AuthenticationAuditComponentConfig\n): EngineTypeInitialiserReturn<AuthenticationAuditComponentConfig, typeof ComponentFactory> {\n\tlet createComponent;\n\tlet instanceTypeName;\n\n\tif (instanceConfig.type === AuthenticationAuditComponentType.EntityStorage) {\n\t\tcreateComponent = (createConfig: typeof instanceConfig) => {\n\t\t\tinitSchemaAuthEntityStorage();\n\t\t\tinitialiseEntityStorageConnector(\n\t\t\t\tengineCore,\n\t\t\t\tcontext,\n\t\t\t\tcreateConfig.options?.authenticationAuditEntryStorageType,\n\t\t\t\tnameof<AuthenticationAuditEntry>(),\n\t\t\t\tContextIdHelper.pickKeysFromAvailable(engineCore.getContextIdKeys(), [\n\t\t\t\t\tContextIdKeys.Node,\n\t\t\t\t\tContextIdKeys.Tenant\n\t\t\t\t])\n\t\t\t);\n\t\t\treturn new EntityStorageAuthenticationAuditService(\n\t\t\t\tEngineTypeHelper.mergeConfig<(typeof instanceConfig)[\"options\"]>(createConfig.options)\n\t\t\t);\n\t\t};\n\t\tinstanceTypeName = nameofKebabCase(EntityStorageAuthenticationAuditService);\n\t}\n\n\treturn {\n\t\tcreateComponent: createComponent as (createConfig: typeof instanceConfig) => IComponent,\n\t\tinstanceTypeName,\n\t\tfactory: ComponentFactory\n\t};\n}\n"]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Copyright 2026 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
import { EntityStorageAuthenticationRateService, initSchema as initSchemaAuthEntityStorage } from "@twin.org/api-auth-entity-storage-service";
|
|
4
|
+
import { ContextIdHelper, ContextIdKeys } from "@twin.org/context";
|
|
5
|
+
import { ComponentFactory } from "@twin.org/core";
|
|
6
|
+
import { EngineTypeHelper, initialiseEntityStorageConnector } from "@twin.org/engine-types";
|
|
7
|
+
import { AuthenticationRateComponentType } from "../models/types/authenticationRateComponentType.js";
|
|
8
|
+
/**
|
|
9
|
+
* Initialise the authentication rate.
|
|
10
|
+
* @param engineCore The engine core.
|
|
11
|
+
* @param context The context for the engine.
|
|
12
|
+
* @param instanceConfig The instance config.
|
|
13
|
+
* @returns The instance created and the factory for it.
|
|
14
|
+
*/
|
|
15
|
+
export function initialiseAuthenticationRateComponent(engineCore, context, instanceConfig) {
|
|
16
|
+
let createComponent;
|
|
17
|
+
let instanceTypeName;
|
|
18
|
+
if (instanceConfig.type === AuthenticationRateComponentType.EntityStorage) {
|
|
19
|
+
createComponent = (createConfig) => {
|
|
20
|
+
initSchemaAuthEntityStorage();
|
|
21
|
+
initialiseEntityStorageConnector(engineCore, context, createConfig.options?.authenticationRateEntryStorageType, "AuthenticationRateEntry", ContextIdHelper.pickKeysFromAvailable(engineCore.getContextIdKeys(), [
|
|
22
|
+
ContextIdKeys.Node,
|
|
23
|
+
ContextIdKeys.Tenant
|
|
24
|
+
]));
|
|
25
|
+
return new EntityStorageAuthenticationRateService(EngineTypeHelper.mergeConfig({
|
|
26
|
+
taskSchedulerComponentType: engineCore.getRegisteredInstanceType("taskSchedulerComponent")
|
|
27
|
+
}, createConfig.options));
|
|
28
|
+
};
|
|
29
|
+
instanceTypeName = "entity-storage-authentication-rate-service";
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
createComponent: createComponent,
|
|
33
|
+
instanceTypeName,
|
|
34
|
+
factory: ComponentFactory
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=authenticationRate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authenticationRate.js","sourceRoot":"","sources":["../../../src/components/authenticationRate.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,sCAAsC,EACtC,UAAU,IAAI,2BAA2B,EAEzC,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAmB,MAAM,gBAAgB,CAAC;AAMnE,OAAO,EAAE,gBAAgB,EAAE,gCAAgC,EAAE,MAAM,wBAAwB,CAAC;AAI5F,OAAO,EAAE,+BAA+B,EAAE,MAAM,oDAAoD,CAAC;AAErG;;;;;;GAMG;AACH,MAAM,UAAU,qCAAqC,CACpD,UAA4C,EAC5C,OAAgD,EAChD,cAAiD;IAEjD,IAAI,eAAe,CAAC;IACpB,IAAI,gBAAgB,CAAC;IAErB,IAAI,cAAc,CAAC,IAAI,KAAK,+BAA+B,CAAC,aAAa,EAAE,CAAC;QAC3E,eAAe,GAAG,CAAC,YAAmC,EAAE,EAAE;YACzD,2BAA2B,EAAE,CAAC;YAC9B,gCAAgC,CAC/B,UAAU,EACV,OAAO,EACP,YAAY,CAAC,OAAO,EAAE,kCAAkC,6BAExD,eAAe,CAAC,qBAAqB,CAAC,UAAU,CAAC,gBAAgB,EAAE,EAAE;gBACpE,aAAa,CAAC,IAAI;gBAClB,aAAa,CAAC,MAAM;aACpB,CAAC,CACF,CAAC;YACF,OAAO,IAAI,sCAAsC,CAChD,gBAAgB,CAAC,WAAW,CAC3B;gBACC,0BAA0B,EACzB,UAAU,CAAC,yBAAyB,CAAC,wBAAwB,CAAC;aAC/D,EACD,YAAY,CAAC,OAAO,CACpB,CACD,CAAC;QACH,CAAC,CAAC;QACF,gBAAgB,+CAA0D,CAAC;IAC5E,CAAC;IAED,OAAO;QACN,eAAe,EAAE,eAAsE;QACvF,gBAAgB;QAChB,OAAO,EAAE,gBAAgB;KACzB,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport {\n\tEntityStorageAuthenticationRateService,\n\tinitSchema as initSchemaAuthEntityStorage,\n\ttype AuthenticationRateEntry\n} from \"@twin.org/api-auth-entity-storage-service\";\nimport { ContextIdHelper, ContextIdKeys } from \"@twin.org/context\";\nimport { ComponentFactory, type IComponent } from \"@twin.org/core\";\nimport type {\n\tEngineTypeInitialiserReturn,\n\tIEngineCore,\n\tIEngineCoreContext\n} from \"@twin.org/engine-models\";\nimport { EngineTypeHelper, initialiseEntityStorageConnector } from \"@twin.org/engine-types\";\nimport { nameof, nameofKebabCase } from \"@twin.org/nameof\";\nimport type { AuthenticationRateComponentConfig } from \"../models/config/authenticationRateComponentConfig.js\";\nimport type { IEngineServerConfig } from \"../models/IEngineServerConfig.js\";\nimport { AuthenticationRateComponentType } from \"../models/types/authenticationRateComponentType.js\";\n\n/**\n * Initialise the authentication rate.\n * @param engineCore The engine core.\n * @param context The context for the engine.\n * @param instanceConfig The instance config.\n * @returns The instance created and the factory for it.\n */\nexport function initialiseAuthenticationRateComponent(\n\tengineCore: IEngineCore<IEngineServerConfig>,\n\tcontext: IEngineCoreContext<IEngineServerConfig>,\n\tinstanceConfig: AuthenticationRateComponentConfig\n): EngineTypeInitialiserReturn<AuthenticationRateComponentConfig, typeof ComponentFactory> {\n\tlet createComponent;\n\tlet instanceTypeName;\n\n\tif (instanceConfig.type === AuthenticationRateComponentType.EntityStorage) {\n\t\tcreateComponent = (createConfig: typeof instanceConfig) => {\n\t\t\tinitSchemaAuthEntityStorage();\n\t\t\tinitialiseEntityStorageConnector(\n\t\t\t\tengineCore,\n\t\t\t\tcontext,\n\t\t\t\tcreateConfig.options?.authenticationRateEntryStorageType,\n\t\t\t\tnameof<AuthenticationRateEntry>(),\n\t\t\t\tContextIdHelper.pickKeysFromAvailable(engineCore.getContextIdKeys(), [\n\t\t\t\t\tContextIdKeys.Node,\n\t\t\t\t\tContextIdKeys.Tenant\n\t\t\t\t])\n\t\t\t);\n\t\t\treturn new EntityStorageAuthenticationRateService(\n\t\t\t\tEngineTypeHelper.mergeConfig<(typeof instanceConfig)[\"options\"]>(\n\t\t\t\t\t{\n\t\t\t\t\t\ttaskSchedulerComponentType:\n\t\t\t\t\t\t\tengineCore.getRegisteredInstanceType(\"taskSchedulerComponent\")\n\t\t\t\t\t},\n\t\t\t\t\tcreateConfig.options\n\t\t\t\t)\n\t\t\t);\n\t\t};\n\t\tinstanceTypeName = nameofKebabCase(EntityStorageAuthenticationRateService);\n\t}\n\n\treturn {\n\t\tcreateComponent: createComponent as (createConfig: typeof instanceConfig) => IComponent,\n\t\tinstanceTypeName,\n\t\tfactory: ComponentFactory\n\t};\n}\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Copyright 2024 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
import { HostingService } from "@twin.org/api-service";
|
|
4
|
+
import { ComponentFactory } from "@twin.org/core";
|
|
5
|
+
import { EngineTypeHelper } from "@twin.org/engine-types";
|
|
6
|
+
import { HostingComponentType } from "../models/types/hostingComponentType.js";
|
|
7
|
+
/**
|
|
8
|
+
* Initialise the hosting component.
|
|
9
|
+
* @param engineCore The engine core.
|
|
10
|
+
* @param context The context for the engine.
|
|
11
|
+
* @param instanceConfig The instance config.
|
|
12
|
+
* @returns The instance created and the factory for it.
|
|
13
|
+
*/
|
|
14
|
+
export function initialiseHostingComponent(engineCore, context, instanceConfig) {
|
|
15
|
+
let createComponent;
|
|
16
|
+
let instanceTypeName;
|
|
17
|
+
if (instanceConfig.type === HostingComponentType.Service) {
|
|
18
|
+
createComponent = (createConfig) => new HostingService(EngineTypeHelper.mergeConfig({
|
|
19
|
+
tenantAdminComponentType: engineCore.getRegisteredInstanceTypeOptional("tenantAdminComponent")
|
|
20
|
+
}, createConfig.options));
|
|
21
|
+
instanceTypeName = "hosting-service";
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
createComponent: createComponent,
|
|
25
|
+
instanceTypeName,
|
|
26
|
+
factory: ComponentFactory
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=hosting.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hosting.js","sourceRoot":"","sources":["../../../src/components/hosting.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAmB,MAAM,gBAAgB,CAAC;AAMnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAI1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AAE/E;;;;;;GAMG;AACH,MAAM,UAAU,0BAA0B,CACzC,UAA4C,EAC5C,OAAgD,EAChD,cAAsC;IAEtC,IAAI,eAAe,CAAC;IACpB,IAAI,gBAAgB,CAAC;IAErB,IAAI,cAAc,CAAC,IAAI,KAAK,oBAAoB,CAAC,OAAO,EAAE,CAAC;QAC1D,eAAe,GAAG,CAAC,YAAmC,EAAE,EAAE,CACzD,IAAI,cAAc,CACjB,gBAAgB,CAAC,WAAW,CAC3B;YACC,wBAAwB,EACvB,UAAU,CAAC,iCAAiC,CAAC,sBAAsB,CAAC;SACrE,EACD,YAAY,CAAC,OAAO,CACpB,CACD,CAAC;QACH,gBAAgB,oBAAkC,CAAC;IACpD,CAAC;IAED,OAAO;QACN,eAAe,EAAE,eAAsE;QACvF,gBAAgB;QAChB,OAAO,EAAE,gBAAgB;KACzB,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { HostingService } from \"@twin.org/api-service\";\nimport { ComponentFactory, type IComponent } from \"@twin.org/core\";\nimport type {\n\tEngineTypeInitialiserReturn,\n\tIEngineCore,\n\tIEngineCoreContext\n} from \"@twin.org/engine-models\";\nimport { EngineTypeHelper } from \"@twin.org/engine-types\";\nimport { nameofKebabCase } from \"@twin.org/nameof\";\nimport type { HostingComponentConfig } from \"../models/config/hostingComponentConfig.js\";\nimport type { IEngineServerConfig } from \"../models/IEngineServerConfig.js\";\nimport { HostingComponentType } from \"../models/types/hostingComponentType.js\";\n\n/**\n * Initialise the hosting component.\n * @param engineCore The engine core.\n * @param context The context for the engine.\n * @param instanceConfig The instance config.\n * @returns The instance created and the factory for it.\n */\nexport function initialiseHostingComponent(\n\tengineCore: IEngineCore<IEngineServerConfig>,\n\tcontext: IEngineCoreContext<IEngineServerConfig>,\n\tinstanceConfig: HostingComponentConfig\n): EngineTypeInitialiserReturn<HostingComponentConfig, typeof ComponentFactory> {\n\tlet createComponent;\n\tlet instanceTypeName;\n\n\tif (instanceConfig.type === HostingComponentType.Service) {\n\t\tcreateComponent = (createConfig: typeof instanceConfig) =>\n\t\t\tnew HostingService(\n\t\t\t\tEngineTypeHelper.mergeConfig<(typeof instanceConfig)[\"options\"]>(\n\t\t\t\t\t{\n\t\t\t\t\t\ttenantAdminComponentType:\n\t\t\t\t\t\t\tengineCore.getRegisteredInstanceTypeOptional(\"tenantAdminComponent\")\n\t\t\t\t\t},\n\t\t\t\t\tcreateConfig.options\n\t\t\t\t)\n\t\t\t);\n\t\tinstanceTypeName = nameofKebabCase(HostingService);\n\t}\n\n\treturn {\n\t\tcreateComponent: createComponent as (createConfig: typeof instanceConfig) => IComponent,\n\t\tinstanceTypeName,\n\t\tfactory: ComponentFactory\n\t};\n}\n"]}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
// Copyright 2024 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
1
3
|
import { InformationRestClient } from "@twin.org/api-rest-client";
|
|
2
4
|
import { InformationService } from "@twin.org/api-service";
|
|
3
5
|
import { ComponentFactory } from "@twin.org/core";
|
|
6
|
+
import { EngineTypeHelper } from "@twin.org/engine-types";
|
|
4
7
|
import { InformationComponentType } from "../models/types/informationComponentType.js";
|
|
5
8
|
/**
|
|
6
9
|
* Initialise the information component.
|
|
@@ -9,20 +12,20 @@ import { InformationComponentType } from "../models/types/informationComponentTy
|
|
|
9
12
|
* @param instanceConfig The instance config.
|
|
10
13
|
* @returns The instance created and the factory for it.
|
|
11
14
|
*/
|
|
12
|
-
export
|
|
13
|
-
let
|
|
14
|
-
let
|
|
15
|
+
export function initialiseInformationComponent(engineCore, context, instanceConfig) {
|
|
16
|
+
let createComponent;
|
|
17
|
+
let instanceTypeName;
|
|
15
18
|
if (instanceConfig.type === InformationComponentType.Service) {
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
createComponent = (createConfig) => new InformationService(EngineTypeHelper.mergeConfig(createConfig.options));
|
|
20
|
+
instanceTypeName = "information-service";
|
|
18
21
|
}
|
|
19
22
|
else if (instanceConfig.type === InformationComponentType.RestClient) {
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
createComponent = (createConfig) => new InformationRestClient(EngineTypeHelper.mergeConfig(createConfig.options));
|
|
24
|
+
instanceTypeName = "information-rest-client";
|
|
22
25
|
}
|
|
23
26
|
return {
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
createComponent: createComponent,
|
|
28
|
+
instanceTypeName,
|
|
26
29
|
factory: ComponentFactory
|
|
27
30
|
};
|
|
28
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"information.js","sourceRoot":"","sources":["../../../src/components/information.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"information.js","sourceRoot":"","sources":["../../../src/components/information.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAmB,MAAM,gBAAgB,CAAC;AAMnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAI1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,6CAA6C,CAAC;AAEvF;;;;;;GAMG;AACH,MAAM,UAAU,8BAA8B,CAC7C,UAA4C,EAC5C,OAAgD,EAChD,cAA0C;IAE1C,IAAI,eAAe,CAAC;IACpB,IAAI,gBAAgB,CAAC;IAErB,IAAI,cAAc,CAAC,IAAI,KAAK,wBAAwB,CAAC,OAAO,EAAE,CAAC;QAC9D,eAAe,GAAG,CAAC,YAAmC,EAAE,EAAE,CACzD,IAAI,kBAAkB,CACrB,gBAAgB,CAAC,WAAW,CAAqC,YAAY,CAAC,OAAO,CAAC,CACtF,CAAC;QACH,gBAAgB,wBAAsC,CAAC;IACxD,CAAC;SAAM,IAAI,cAAc,CAAC,IAAI,KAAK,wBAAwB,CAAC,UAAU,EAAE,CAAC;QACxE,eAAe,GAAG,CAAC,YAAmC,EAAE,EAAE,CACzD,IAAI,qBAAqB,CACxB,gBAAgB,CAAC,WAAW,CAAqC,YAAY,CAAC,OAAO,CAAC,CACtF,CAAC;QACH,gBAAgB,4BAAyC,CAAC;IAC3D,CAAC;IAED,OAAO;QACN,eAAe,EAAE,eAAsE;QACvF,gBAAgB;QAChB,OAAO,EAAE,gBAAgB;KACzB,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { InformationRestClient } from \"@twin.org/api-rest-client\";\nimport { InformationService } from \"@twin.org/api-service\";\nimport { ComponentFactory, type IComponent } from \"@twin.org/core\";\nimport type {\n\tEngineTypeInitialiserReturn,\n\tIEngineCore,\n\tIEngineCoreContext\n} from \"@twin.org/engine-models\";\nimport { EngineTypeHelper } from \"@twin.org/engine-types\";\nimport { nameofKebabCase } from \"@twin.org/nameof\";\nimport type { InformationComponentConfig } from \"../models/config/informationComponentConfig.js\";\nimport type { IEngineServerConfig } from \"../models/IEngineServerConfig.js\";\nimport { InformationComponentType } from \"../models/types/informationComponentType.js\";\n\n/**\n * Initialise the information component.\n * @param engineCore The engine core.\n * @param context The context for the engine.\n * @param instanceConfig The instance config.\n * @returns The instance created and the factory for it.\n */\nexport function initialiseInformationComponent(\n\tengineCore: IEngineCore<IEngineServerConfig>,\n\tcontext: IEngineCoreContext<IEngineServerConfig>,\n\tinstanceConfig: InformationComponentConfig\n): EngineTypeInitialiserReturn<InformationComponentConfig, typeof ComponentFactory> {\n\tlet createComponent;\n\tlet instanceTypeName;\n\n\tif (instanceConfig.type === InformationComponentType.Service) {\n\t\tcreateComponent = (createConfig: typeof instanceConfig) =>\n\t\t\tnew InformationService(\n\t\t\t\tEngineTypeHelper.mergeConfig<(typeof instanceConfig)[\"options\"]>(createConfig.options)\n\t\t\t);\n\t\tinstanceTypeName = nameofKebabCase(InformationService);\n\t} else if (instanceConfig.type === InformationComponentType.RestClient) {\n\t\tcreateComponent = (createConfig: typeof instanceConfig) =>\n\t\t\tnew InformationRestClient(\n\t\t\t\tEngineTypeHelper.mergeConfig<(typeof instanceConfig)[\"options\"]>(createConfig.options)\n\t\t\t);\n\t\tinstanceTypeName = nameofKebabCase(InformationRestClient);\n\t}\n\n\treturn {\n\t\tcreateComponent: createComponent as (createConfig: typeof instanceConfig) => IComponent,\n\t\tinstanceTypeName,\n\t\tfactory: ComponentFactory\n\t};\n}\n"]}
|
|
@@ -10,16 +10,16 @@ import { MimeTypeProcessorType } from "../models/types/mimeTypeProcessorType.js"
|
|
|
10
10
|
* @param instanceConfig The instance config.
|
|
11
11
|
* @returns The instance created and the factory for it.
|
|
12
12
|
*/
|
|
13
|
-
export
|
|
14
|
-
let
|
|
15
|
-
let
|
|
13
|
+
export function initialiseMimeTypeProcessorComponent(engineCore, context, instanceConfig) {
|
|
14
|
+
let createComponent;
|
|
15
|
+
let instanceTypeName;
|
|
16
16
|
if (instanceConfig.type === MimeTypeProcessorType.Jwt) {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
createComponent = (createConfig) => new JwtMimeTypeProcessor();
|
|
18
|
+
instanceTypeName = "jwt-mime-type-processor";
|
|
19
19
|
}
|
|
20
20
|
return {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
createComponent: createComponent,
|
|
22
|
+
instanceTypeName,
|
|
23
23
|
factory: MimeTypeProcessorFactory
|
|
24
24
|
};
|
|
25
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mimeTypeProcessor.js","sourceRoot":"","sources":["../../../src/components/mimeTypeProcessor.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,wBAAwB,
|
|
1
|
+
{"version":3,"file":"mimeTypeProcessor.js","sourceRoot":"","sources":["../../../src/components/mimeTypeProcessor.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAUhE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AAEjF;;;;;;GAMG;AACH,MAAM,UAAU,oCAAoC,CACnD,UAA4C,EAC5C,OAAgD,EAChD,cAAuC;IAEvC,IAAI,eAAe,CAAC;IACpB,IAAI,gBAAgB,CAAC;IAErB,IAAI,cAAc,CAAC,IAAI,KAAK,qBAAqB,CAAC,GAAG,EAAE,CAAC;QACvD,eAAe,GAAG,CAAC,YAAmC,EAAE,EAAE,CAAC,IAAI,oBAAoB,EAAE,CAAC;QACtF,gBAAgB,4BAAwC,CAAC;IAC1D,CAAC;IAED,OAAO;QACN,eAAe,EAAE,eAAsE;QACvF,gBAAgB;QAChB,OAAO,EAAE,wBAAwB;KACjC,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { MimeTypeProcessorFactory } from \"@twin.org/api-models\";\nimport { JwtMimeTypeProcessor } from \"@twin.org/api-processors\";\nimport type { IComponent } from \"@twin.org/core\";\nimport type {\n\tEngineTypeInitialiserReturn,\n\tIEngineCore,\n\tIEngineCoreContext\n} from \"@twin.org/engine-models\";\nimport { nameofKebabCase } from \"@twin.org/nameof\";\nimport type { MimeTypeProcessorConfig } from \"../models/config/mimeTypeProcessorConfig.js\";\nimport type { IEngineServerConfig } from \"../models/IEngineServerConfig.js\";\nimport { MimeTypeProcessorType } from \"../models/types/mimeTypeProcessorType.js\";\n\n/**\n * Initialise the mime type processor.\n * @param engineCore The engine core.\n * @param context The context for the engine.\n * @param instanceConfig The instance config.\n * @returns The instance created and the factory for it.\n */\nexport function initialiseMimeTypeProcessorComponent(\n\tengineCore: IEngineCore<IEngineServerConfig>,\n\tcontext: IEngineCoreContext<IEngineServerConfig>,\n\tinstanceConfig: MimeTypeProcessorConfig\n): EngineTypeInitialiserReturn<MimeTypeProcessorConfig, typeof MimeTypeProcessorFactory> {\n\tlet createComponent;\n\tlet instanceTypeName;\n\n\tif (instanceConfig.type === MimeTypeProcessorType.Jwt) {\n\t\tcreateComponent = (createConfig: typeof instanceConfig) => new JwtMimeTypeProcessor();\n\t\tinstanceTypeName = nameofKebabCase(JwtMimeTypeProcessor);\n\t}\n\n\treturn {\n\t\tcreateComponent: createComponent as (createConfig: typeof instanceConfig) => IComponent,\n\t\tinstanceTypeName,\n\t\tfactory: MimeTypeProcessorFactory\n\t};\n}\n"]}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
// Copyright 2024 IOTA Stiftung.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
-
import { AuthHeaderProcessor } from "@twin.org/api-auth-entity-storage-service";
|
|
3
|
+
import { AuthHeaderProcessor, initSchema as initSchemaAuthEntityStorage } from "@twin.org/api-auth-entity-storage-service";
|
|
4
4
|
import { RestRouteProcessorFactory } from "@twin.org/api-models";
|
|
5
|
-
import {
|
|
5
|
+
import { ContextIdProcessor, LoggingProcessor, RestRouteProcessor, StaticContextIdProcessor } from "@twin.org/api-processors";
|
|
6
6
|
import { initSchema as initSchemaTenantProcessor, TenantProcessor } from "@twin.org/api-tenant-processor";
|
|
7
7
|
import { ContextIdHelper, ContextIdKeys } from "@twin.org/context";
|
|
8
|
-
import { initialiseEntityStorageConnector } from "@twin.org/engine-types";
|
|
9
|
-
import { VerifiableCredentialAuthenticationProcessor } from "@twin.org/identity-authentication";
|
|
8
|
+
import { EngineTypeHelper, initialiseEntityStorageConnector } from "@twin.org/engine-types";
|
|
10
9
|
import { RestRouteProcessorType } from "../models/types/restRouteProcessorType.js";
|
|
11
10
|
/**
|
|
12
11
|
* Initialise the rest route processor.
|
|
@@ -15,61 +14,54 @@ import { RestRouteProcessorType } from "../models/types/restRouteProcessorType.j
|
|
|
15
14
|
* @param instanceConfig The instance config.
|
|
16
15
|
* @returns The instance created and the factory for it.
|
|
17
16
|
*/
|
|
18
|
-
export
|
|
19
|
-
let
|
|
20
|
-
let
|
|
17
|
+
export function initialiseRestRouteProcessorComponent(engineCore, context, instanceConfig) {
|
|
18
|
+
let createComponent;
|
|
19
|
+
let instanceTypeName;
|
|
21
20
|
if (instanceConfig.type === RestRouteProcessorType.AuthHeader) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
loggingComponentType: engineCore.getRegisteredInstanceType("loggingComponent"),
|
|
34
|
-
config: {
|
|
35
|
-
...instanceConfig.options?.config
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
instanceType = "verifiable-credential-authentication-processor";
|
|
21
|
+
createComponent = (createConfig) => {
|
|
22
|
+
initSchemaAuthEntityStorage();
|
|
23
|
+
initialiseEntityStorageConnector(engineCore, context, createConfig.options?.userEntityStorageType, "AuthenticationUser", ContextIdHelper.pickKeysFromAvailable(engineCore.getContextIdKeys(), [
|
|
24
|
+
ContextIdKeys.Node,
|
|
25
|
+
ContextIdKeys.Tenant
|
|
26
|
+
]));
|
|
27
|
+
return new AuthHeaderProcessor(EngineTypeHelper.mergeConfig({
|
|
28
|
+
vaultConnectorType: engineCore.getRegisteredInstanceType("vaultConnector")
|
|
29
|
+
}, createConfig.options));
|
|
30
|
+
};
|
|
31
|
+
instanceTypeName = "auth-header-processor";
|
|
39
32
|
}
|
|
40
33
|
else if (instanceConfig.type === RestRouteProcessorType.Logging) {
|
|
41
|
-
|
|
42
|
-
loggingComponentType: engineCore.getRegisteredInstanceType("loggingComponent")
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
instanceType = "logging-processor";
|
|
34
|
+
createComponent = (createConfig) => new LoggingProcessor(EngineTypeHelper.mergeConfig({
|
|
35
|
+
loggingComponentType: engineCore.getRegisteredInstanceType("loggingComponent")
|
|
36
|
+
}, createConfig.options));
|
|
37
|
+
instanceTypeName = "logging-processor";
|
|
48
38
|
}
|
|
49
39
|
else if (instanceConfig.type === RestRouteProcessorType.ContextId) {
|
|
50
|
-
|
|
51
|
-
|
|
40
|
+
createComponent = (createConfig) => new ContextIdProcessor(EngineTypeHelper.mergeConfig(createConfig.options));
|
|
41
|
+
instanceTypeName = "context-id-processor";
|
|
52
42
|
}
|
|
53
43
|
else if (instanceConfig.type === RestRouteProcessorType.StaticContextId) {
|
|
54
|
-
|
|
55
|
-
|
|
44
|
+
createComponent = (createConfig) => new StaticContextIdProcessor(EngineTypeHelper.mergeConfig(createConfig.options));
|
|
45
|
+
instanceTypeName = "static-context-id-processor";
|
|
56
46
|
}
|
|
57
47
|
else if (instanceConfig.type === RestRouteProcessorType.RestRoute) {
|
|
58
|
-
|
|
59
|
-
|
|
48
|
+
createComponent = (createConfig) => new RestRouteProcessor(EngineTypeHelper.mergeConfig(createConfig.options));
|
|
49
|
+
instanceTypeName = "rest-route-processor";
|
|
60
50
|
}
|
|
61
51
|
else if (instanceConfig.type === RestRouteProcessorType.Tenant) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
52
|
+
createComponent = (createConfig) => {
|
|
53
|
+
initSchemaTenantProcessor();
|
|
54
|
+
initialiseEntityStorageConnector(engineCore, context, createConfig.options?.tenantEntityStorageType, "Tenant", ContextIdHelper.pickKeysFromAvailable(engineCore.getContextIdKeys(), [
|
|
55
|
+
ContextIdKeys.Node,
|
|
56
|
+
ContextIdKeys.Tenant
|
|
57
|
+
]));
|
|
58
|
+
return new TenantProcessor(EngineTypeHelper.mergeConfig(createConfig.options));
|
|
59
|
+
};
|
|
60
|
+
instanceTypeName = "tenant-processor";
|
|
69
61
|
}
|
|
70
62
|
return {
|
|
71
|
-
|
|
72
|
-
|
|
63
|
+
createComponent: createComponent,
|
|
64
|
+
instanceTypeName,
|
|
73
65
|
factory: RestRouteProcessorFactory
|
|
74
66
|
};
|
|
75
67
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restRouteProcessor.js","sourceRoot":"","sources":["../../../src/components/restRouteProcessor.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,
|
|
1
|
+
{"version":3,"file":"restRouteProcessor.js","sourceRoot":"","sources":["../../../src/components/restRouteProcessor.ts"],"names":[],"mappings":"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","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport {\n\tAuthHeaderProcessor,\n\tinitSchema as initSchemaAuthEntityStorage,\n\ttype AuthenticationUser\n} from \"@twin.org/api-auth-entity-storage-service\";\nimport { RestRouteProcessorFactory } from \"@twin.org/api-models\";\nimport {\n\tContextIdProcessor,\n\tLoggingProcessor,\n\tRestRouteProcessor,\n\tStaticContextIdProcessor\n} from \"@twin.org/api-processors\";\nimport {\n\tinitSchema as initSchemaTenantProcessor,\n\tTenantProcessor,\n\ttype Tenant\n} from \"@twin.org/api-tenant-processor\";\nimport { ContextIdHelper, ContextIdKeys } from \"@twin.org/context\";\nimport type { IComponent } from \"@twin.org/core\";\nimport type {\n\tEngineTypeInitialiserReturn,\n\tIEngineCore,\n\tIEngineCoreContext\n} from \"@twin.org/engine-models\";\nimport { EngineTypeHelper, initialiseEntityStorageConnector } from \"@twin.org/engine-types\";\nimport { nameof, nameofKebabCase } from \"@twin.org/nameof\";\nimport type { RestRouteProcessorConfig } from \"../models/config/restRouteProcessorConfig.js\";\nimport type { IEngineServerConfig } from \"../models/IEngineServerConfig.js\";\nimport { RestRouteProcessorType } from \"../models/types/restRouteProcessorType.js\";\n\n/**\n * Initialise the rest route processor.\n * @param engineCore The engine core.\n * @param context The context for the engine.\n * @param instanceConfig The instance config.\n * @returns The instance created and the factory for it.\n */\nexport function initialiseRestRouteProcessorComponent(\n\tengineCore: IEngineCore<IEngineServerConfig>,\n\tcontext: IEngineCoreContext<IEngineServerConfig>,\n\tinstanceConfig: RestRouteProcessorConfig\n): EngineTypeInitialiserReturn<RestRouteProcessorConfig, typeof RestRouteProcessorFactory> {\n\tlet createComponent;\n\tlet instanceTypeName;\n\n\tif (instanceConfig.type === RestRouteProcessorType.AuthHeader) {\n\t\tcreateComponent = (createConfig: typeof instanceConfig) => {\n\t\t\tinitSchemaAuthEntityStorage();\n\t\t\tinitialiseEntityStorageConnector(\n\t\t\t\tengineCore,\n\t\t\t\tcontext,\n\t\t\t\tcreateConfig.options?.userEntityStorageType,\n\t\t\t\tnameof<AuthenticationUser>(),\n\t\t\t\tContextIdHelper.pickKeysFromAvailable(engineCore.getContextIdKeys(), [\n\t\t\t\t\tContextIdKeys.Node,\n\t\t\t\t\tContextIdKeys.Tenant\n\t\t\t\t])\n\t\t\t);\n\n\t\t\treturn new AuthHeaderProcessor(\n\t\t\t\tEngineTypeHelper.mergeConfig<(typeof instanceConfig)[\"options\"]>(\n\t\t\t\t\t{\n\t\t\t\t\t\tvaultConnectorType: engineCore.getRegisteredInstanceType(\"vaultConnector\")\n\t\t\t\t\t},\n\t\t\t\t\tcreateConfig.options\n\t\t\t\t)\n\t\t\t);\n\t\t};\n\t\tinstanceTypeName = nameofKebabCase(AuthHeaderProcessor);\n\t} else if (instanceConfig.type === RestRouteProcessorType.Logging) {\n\t\tcreateComponent = (createConfig: typeof instanceConfig) =>\n\t\t\tnew LoggingProcessor(\n\t\t\t\tEngineTypeHelper.mergeConfig<(typeof instanceConfig)[\"options\"]>(\n\t\t\t\t\t{\n\t\t\t\t\t\tloggingComponentType: engineCore.getRegisteredInstanceType(\"loggingComponent\")\n\t\t\t\t\t},\n\t\t\t\t\tcreateConfig.options\n\t\t\t\t)\n\t\t\t);\n\t\tinstanceTypeName = nameofKebabCase(LoggingProcessor);\n\t} else if (instanceConfig.type === RestRouteProcessorType.ContextId) {\n\t\tcreateComponent = (createConfig: typeof instanceConfig) =>\n\t\t\tnew ContextIdProcessor(\n\t\t\t\tEngineTypeHelper.mergeConfig<(typeof instanceConfig)[\"options\"]>(createConfig.options)\n\t\t\t);\n\t\tinstanceTypeName = nameofKebabCase(ContextIdProcessor);\n\t} else if (instanceConfig.type === RestRouteProcessorType.StaticContextId) {\n\t\tcreateComponent = (createConfig: typeof instanceConfig) =>\n\t\t\tnew StaticContextIdProcessor(\n\t\t\t\tEngineTypeHelper.mergeConfig<(typeof instanceConfig)[\"options\"]>(createConfig.options)\n\t\t\t);\n\t\tinstanceTypeName = nameofKebabCase(StaticContextIdProcessor);\n\t} else if (instanceConfig.type === RestRouteProcessorType.RestRoute) {\n\t\tcreateComponent = (createConfig: typeof instanceConfig) =>\n\t\t\tnew RestRouteProcessor(\n\t\t\t\tEngineTypeHelper.mergeConfig<(typeof instanceConfig)[\"options\"]>(createConfig.options)\n\t\t\t);\n\t\tinstanceTypeName = nameofKebabCase(RestRouteProcessor);\n\t} else if (instanceConfig.type === RestRouteProcessorType.Tenant) {\n\t\tcreateComponent = (createConfig: typeof instanceConfig) => {\n\t\t\tinitSchemaTenantProcessor();\n\t\t\tinitialiseEntityStorageConnector(\n\t\t\t\tengineCore,\n\t\t\t\tcontext,\n\t\t\t\tcreateConfig.options?.tenantEntityStorageType,\n\t\t\t\tnameof<Tenant>(),\n\t\t\t\tContextIdHelper.pickKeysFromAvailable(engineCore.getContextIdKeys(), [\n\t\t\t\t\tContextIdKeys.Node,\n\t\t\t\t\tContextIdKeys.Tenant\n\t\t\t\t])\n\t\t\t);\n\t\t\treturn new TenantProcessor(\n\t\t\t\tEngineTypeHelper.mergeConfig<(typeof instanceConfig)[\"options\"]>(createConfig.options)\n\t\t\t);\n\t\t};\n\t\tinstanceTypeName = nameofKebabCase(TenantProcessor);\n\t}\n\n\treturn {\n\t\tcreateComponent: createComponent as (createConfig: typeof instanceConfig) => IComponent,\n\t\tinstanceTypeName,\n\t\tfactory: RestRouteProcessorFactory\n\t};\n}\n"]}
|