@twin.org/engine-core 0.0.3-next.9 → 0.9.0

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.
@@ -14,33 +14,33 @@ The options for creating engine core.
14
14
 
15
15
  ## Properties
16
16
 
17
- ### config?
17
+ ### config? {#config}
18
18
 
19
- > `optional` **config**: `C`
19
+ > `optional` **config?**: `C`
20
20
 
21
21
  The engine core config.
22
22
 
23
23
  ***
24
24
 
25
- ### stateStorage?
25
+ ### stateStorage? {#statestorage}
26
26
 
27
- > `optional` **stateStorage**: `IEngineStateStorage`\<`S`\>
27
+ > `optional` **stateStorage?**: `IEngineStateStorage`\<`S`\>
28
28
 
29
29
  The state storage component.
30
30
 
31
31
  ***
32
32
 
33
- ### skipBootstrap?
33
+ ### skipBootstrap? {#skipbootstrap}
34
34
 
35
- > `optional` **skipBootstrap**: `boolean`
35
+ > `optional` **skipBootstrap?**: `boolean`
36
36
 
37
37
  Skip the bootstrap process, useful for additional engine instances.
38
38
 
39
39
  ***
40
40
 
41
- ### populateTypeInitialisers()?
41
+ ### populateTypeInitialisers? {#populatetypeinitialisers}
42
42
 
43
- > `optional` **populateTypeInitialisers**: (`engineCore`, `context`) => `void`
43
+ > `optional` **populateTypeInitialisers?**: (`engineCore`, `context`) => `void`
44
44
 
45
45
  Populate the type initialisers for the engine.
46
46
 
@@ -60,9 +60,9 @@ Populate the type initialisers for the engine.
60
60
 
61
61
  ***
62
62
 
63
- ### customBootstrap()?
63
+ ### customBootstrap? {#custombootstrap}
64
64
 
65
- > `optional` **customBootstrap**: (`engineCore`, `context`) => `Promise`\<`void`\>
65
+ > `optional` **customBootstrap?**: (`engineCore`, `context`) => `Promise`\<`void`\>
66
66
 
67
67
  Custom bootstrap method for the engine.
68
68
 
package/locales/en.json CHANGED
@@ -5,14 +5,12 @@
5
5
  "bootstrapFailed": "Failed to bootstrap component type \"{className}\" with instance type \"{instanceType}\"",
6
6
  "componentStartFailed": "Failed to start component type \"{className}\" with instance type \"{instanceType}\"",
7
7
  "componentStopFailed": "Failed to stop component type \"{className}\" with instance type \"{instanceType}\"",
8
- "instanceTypeNotFound": "Instance type not found for \"{type}\" with features \"{features}\""
8
+ "instanceTypeNotFound": "Instance type not found for \"{type}\"",
9
+ "instanceTypeNotFoundWithFeatures": "Instance type not found for \"{type}\" with features \"{features}\""
9
10
  },
10
11
  "fileStateStorage": {
11
12
  "failedLoading": "Failed to load file state storage from \"{filename}\"",
12
13
  "failedSaving": "Failed to save file state storage to \"{filename}\""
13
- },
14
- "engineModuleHelper": {
15
- "moduleNotClass": "The module \"{moduleName}\" does not export a class \"{className}\""
16
14
  }
17
15
  },
18
16
  "engineCore": {
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@twin.org/engine-core",
3
- "version": "0.0.3-next.9",
4
- "description": "Engine core.",
3
+ "version": "0.9.0",
4
+ "description": "Core runtime lifecycle and state orchestration for engine instances.",
5
5
  "repository": {
6
6
  "type": "git",
7
- "url": "git+https://github.com/twinfoundation/engine.git",
7
+ "url": "git+https://github.com/iotaledger/twin-engine.git",
8
8
  "directory": "packages/engine-core"
9
9
  },
10
10
  "author": "martyn.janes@iota.org",
@@ -14,17 +14,17 @@
14
14
  "node": ">=20.0.0"
15
15
  },
16
16
  "dependencies": {
17
- "@twin.org/context": "next",
18
- "@twin.org/core": "next",
19
- "@twin.org/crypto": "next",
20
- "@twin.org/data-core": "next",
21
- "@twin.org/engine-models": "0.0.3-next.9",
22
- "@twin.org/entity": "next",
23
- "@twin.org/logging-connector-console": "next",
24
- "@twin.org/logging-models": "next",
25
- "@twin.org/logging-service": "next",
26
- "@twin.org/modules": "next",
27
- "@twin.org/nameof": "next"
17
+ "@twin.org/context": "^0.9.0",
18
+ "@twin.org/core": "^0.9.0",
19
+ "@twin.org/crypto": "^0.9.0",
20
+ "@twin.org/data-core": "^0.9.0",
21
+ "@twin.org/engine-models": "^0.9.0",
22
+ "@twin.org/entity": "^0.9.0",
23
+ "@twin.org/logging-connector-console": "^0.9.0",
24
+ "@twin.org/logging-models": "^0.9.0",
25
+ "@twin.org/logging-service": "^0.9.0",
26
+ "@twin.org/modules": "^0.9.0",
27
+ "@twin.org/nameof": "^0.9.0"
28
28
  },
29
29
  "main": "./dist/es/index.js",
30
30
  "types": "./dist/types/index.d.ts",
@@ -54,7 +54,7 @@
54
54
  "utilities"
55
55
  ],
56
56
  "bugs": {
57
- "url": "git+https://github.com/twinfoundation/engine/issues"
57
+ "url": "git+https://github.com/iotaledger/twin-engine/issues"
58
58
  },
59
59
  "homepage": "https://twindev.org"
60
60
  }
@@ -1,46 +0,0 @@
1
- // Copyright 2024 IOTA Stiftung.
2
- // SPDX-License-Identifier: Apache-2.0.
3
- import { GeneralError, Is } from "@twin.org/core";
4
- import { ModuleHelper } from "@twin.org/modules";
5
- /**
6
- * Helper class for engine modules.
7
- */
8
- export class EngineModuleHelper {
9
- /**
10
- * Runtime name for the class.
11
- */
12
- static CLASS_NAME = "EngineModuleHelper";
13
- /**
14
- * Loads an engine component and constructs it with the relevant dependencies and configuration.
15
- * @param engineCore The engine core.
16
- * @param engineModuleConfig The configuration for the module.
17
- * @returns The instantiated component.
18
- */
19
- static async loadComponent(engineCore, engineModuleConfig) {
20
- const moduleClass = await ModuleHelper.getModuleEntry(engineModuleConfig.moduleName, engineModuleConfig.className);
21
- const isClass = Is.class(moduleClass);
22
- if (!isClass) {
23
- throw new GeneralError(EngineModuleHelper.CLASS_NAME, "moduleNotClass", {
24
- moduleName: engineModuleConfig.moduleName,
25
- className: engineModuleConfig.className
26
- });
27
- }
28
- const constructorOptions = {};
29
- if (Is.arrayValue(engineModuleConfig.dependencies)) {
30
- for (const dependency of engineModuleConfig.dependencies) {
31
- if (dependency.isOptional ?? false) {
32
- constructorOptions[dependency.propertyName] = engineCore.getRegisteredInstanceType(dependency.componentName, dependency.features);
33
- }
34
- else {
35
- constructorOptions[dependency.propertyName] =
36
- engineCore.getRegisteredInstanceTypeOptional(dependency.componentName, dependency.features);
37
- }
38
- }
39
- }
40
- if (Is.object(engineModuleConfig.config)) {
41
- constructorOptions.config = engineModuleConfig.config;
42
- }
43
- return new moduleClass(constructorOptions);
44
- }
45
- }
46
- //# sourceMappingURL=engineModuleHelper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"engineModuleHelper.js","sourceRoot":"","sources":["../../../src/utils/engineModuleHelper.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAC9B;;OAEG;IACI,MAAM,CAAU,UAAU,wBAAwC;IAEzE;;;;;OAKG;IACI,MAAM,CAAC,KAAK,CAAC,aAAa,CAChC,UAAuB,EACvB,kBAAuC;QAEvC,MAAM,WAAW,GAAG,MAAM,YAAY,CAAC,cAAc,CACpD,kBAAkB,CAAC,UAAU,EAC7B,kBAAkB,CAAC,SAAS,CAC5B,CAAC;QAEF,MAAM,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QACtC,IAAI,CAAC,OAAO,EAAE,CAAC;YACd,MAAM,IAAI,YAAY,CAAC,kBAAkB,CAAC,UAAU,EAAE,gBAAgB,EAAE;gBACvE,UAAU,EAAE,kBAAkB,CAAC,UAAU;gBACzC,SAAS,EAAE,kBAAkB,CAAC,SAAS;aACvC,CAAC,CAAC;QACJ,CAAC;QAED,MAAM,kBAAkB,GAA+B,EAAE,CAAC;QAE1D,IAAI,EAAE,CAAC,UAAU,CAAC,kBAAkB,CAAC,YAAY,CAAC,EAAE,CAAC;YACpD,KAAK,MAAM,UAAU,IAAI,kBAAkB,CAAC,YAAY,EAAE,CAAC;gBAC1D,IAAI,UAAU,CAAC,UAAU,IAAI,KAAK,EAAE,CAAC;oBACpC,kBAAkB,CAAC,UAAU,CAAC,YAAY,CAAC,GAAG,UAAU,CAAC,yBAAyB,CACjF,UAAU,CAAC,aAAa,EACxB,UAAU,CAAC,QAAQ,CACnB,CAAC;gBACH,CAAC;qBAAM,CAAC;oBACP,kBAAkB,CAAC,UAAU,CAAC,YAAY,CAAC;wBAC1C,UAAU,CAAC,iCAAiC,CAC3C,UAAU,CAAC,aAAa,EACxB,UAAU,CAAC,QAAQ,CACnB,CAAC;gBACJ,CAAC;YACF,CAAC;QACF,CAAC;QAED,IAAI,EAAE,CAAC,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE,CAAC;YAC1C,kBAAkB,CAAC,MAAM,GAAG,kBAAkB,CAAC,MAAM,CAAC;QACvD,CAAC;QAED,OAAO,IAAI,WAAW,CAAC,kBAAkB,CAAM,CAAC;IACjD,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { GeneralError, Is } from \"@twin.org/core\";\nimport type { IEngineCore, IEngineModuleConfig } from \"@twin.org/engine-models\";\nimport { ModuleHelper } from \"@twin.org/modules\";\nimport { nameof } from \"@twin.org/nameof\";\n\n/**\n * Helper class for engine modules.\n */\nexport class EngineModuleHelper {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<EngineModuleHelper>();\n\n\t/**\n\t * Loads an engine component and constructs it with the relevant dependencies and configuration.\n\t * @param engineCore The engine core.\n\t * @param engineModuleConfig The configuration for the module.\n\t * @returns The instantiated component.\n\t */\n\tpublic static async loadComponent<T>(\n\t\tengineCore: IEngineCore,\n\t\tengineModuleConfig: IEngineModuleConfig\n\t): Promise<T> {\n\t\tconst moduleClass = await ModuleHelper.getModuleEntry(\n\t\t\tengineModuleConfig.moduleName,\n\t\t\tengineModuleConfig.className\n\t\t);\n\n\t\tconst isClass = Is.class(moduleClass);\n\t\tif (!isClass) {\n\t\t\tthrow new GeneralError(EngineModuleHelper.CLASS_NAME, \"moduleNotClass\", {\n\t\t\t\tmoduleName: engineModuleConfig.moduleName,\n\t\t\t\tclassName: engineModuleConfig.className\n\t\t\t});\n\t\t}\n\n\t\tconst constructorOptions: { [key: string]: unknown } = {};\n\n\t\tif (Is.arrayValue(engineModuleConfig.dependencies)) {\n\t\t\tfor (const dependency of engineModuleConfig.dependencies) {\n\t\t\t\tif (dependency.isOptional ?? false) {\n\t\t\t\t\tconstructorOptions[dependency.propertyName] = engineCore.getRegisteredInstanceType(\n\t\t\t\t\t\tdependency.componentName,\n\t\t\t\t\t\tdependency.features\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tconstructorOptions[dependency.propertyName] =\n\t\t\t\t\t\tengineCore.getRegisteredInstanceTypeOptional(\n\t\t\t\t\t\t\tdependency.componentName,\n\t\t\t\t\t\t\tdependency.features\n\t\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (Is.object(engineModuleConfig.config)) {\n\t\t\tconstructorOptions.config = engineModuleConfig.config;\n\t\t}\n\n\t\treturn new moduleClass(constructorOptions) as T;\n\t}\n}\n"]}
@@ -1,17 +0,0 @@
1
- import type { IEngineCore, IEngineModuleConfig } from "@twin.org/engine-models";
2
- /**
3
- * Helper class for engine modules.
4
- */
5
- export declare class EngineModuleHelper {
6
- /**
7
- * Runtime name for the class.
8
- */
9
- static readonly CLASS_NAME: string;
10
- /**
11
- * Loads an engine component and constructs it with the relevant dependencies and configuration.
12
- * @param engineCore The engine core.
13
- * @param engineModuleConfig The configuration for the module.
14
- * @returns The instantiated component.
15
- */
16
- static loadComponent<T>(engineCore: IEngineCore, engineModuleConfig: IEngineModuleConfig): Promise<T>;
17
- }
@@ -1,55 +0,0 @@
1
- # Class: EngineModuleHelper
2
-
3
- Helper class for engine modules.
4
-
5
- ## Constructors
6
-
7
- ### Constructor
8
-
9
- > **new EngineModuleHelper**(): `EngineModuleHelper`
10
-
11
- #### Returns
12
-
13
- `EngineModuleHelper`
14
-
15
- ## Properties
16
-
17
- ### CLASS\_NAME
18
-
19
- > `readonly` `static` **CLASS\_NAME**: `string`
20
-
21
- Runtime name for the class.
22
-
23
- ## Methods
24
-
25
- ### loadComponent()
26
-
27
- > `static` **loadComponent**\<`T`\>(`engineCore`, `engineModuleConfig`): `Promise`\<`T`\>
28
-
29
- Loads an engine component and constructs it with the relevant dependencies and configuration.
30
-
31
- #### Type Parameters
32
-
33
- ##### T
34
-
35
- `T`
36
-
37
- #### Parameters
38
-
39
- ##### engineCore
40
-
41
- `IEngineCore`
42
-
43
- The engine core.
44
-
45
- ##### engineModuleConfig
46
-
47
- `IEngineModuleConfig`
48
-
49
- The configuration for the module.
50
-
51
- #### Returns
52
-
53
- `Promise`\<`T`\>
54
-
55
- The instantiated component.