@twin.org/engine-core 0.0.1-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +21 -0
- package/dist/cjs/index.cjs +1662 -0
- package/dist/esm/index.mjs +1657 -0
- package/dist/types/components/attestation.d.ts +21 -0
- package/dist/types/components/auditableItemGraph.d.ts +11 -0
- package/dist/types/components/auditableItemStream.d.ts +11 -0
- package/dist/types/components/backgroundTask.d.ts +11 -0
- package/dist/types/components/blobStorage.d.ts +21 -0
- package/dist/types/components/entityStorage.d.ts +20 -0
- package/dist/types/components/faucet.d.ts +11 -0
- package/dist/types/components/identity.d.ts +21 -0
- package/dist/types/components/identityProfile.d.ts +21 -0
- package/dist/types/components/immutableProof.d.ts +11 -0
- package/dist/types/components/immutableStorage.d.ts +11 -0
- package/dist/types/components/logging.d.ts +21 -0
- package/dist/types/components/nft.d.ts +21 -0
- package/dist/types/components/telemetry.d.ts +21 -0
- package/dist/types/components/vault.d.ts +11 -0
- package/dist/types/components/wallet.d.ts +21 -0
- package/dist/types/engineCore.d.ts +65 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/models/IEngineCoreOptions.d.ts +22 -0
- package/dist/types/storage/fileStateStorage.d.ts +29 -0
- package/dist/types/storage/memoryStateStorage.d.ts +28 -0
- package/docs/changelog.md +5 -0
- package/docs/examples.md +1 -0
- package/docs/reference/classes/EngineCore.md +209 -0
- package/docs/reference/classes/FileStateStorage.md +89 -0
- package/docs/reference/classes/MemoryStateStorage.md +85 -0
- package/docs/reference/functions/initialiseEntityStorageConnector.md +31 -0
- package/docs/reference/index.md +15 -0
- package/docs/reference/interfaces/IEngineCoreOptions.md +45 -0
- package/locales/en.json +42 -0
- package/package.json +102 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type IEngineCoreContext, type AttestationComponentConfig, type AttestationConnectorConfig, type IEngineCore } from "@twin.org/engine-models";
|
|
2
|
+
/**
|
|
3
|
+
* Initialise the attestation connector.
|
|
4
|
+
* @param engineCore The engine core.
|
|
5
|
+
* @param context The context for the engine.
|
|
6
|
+
* @param instanceConfig The instance config.
|
|
7
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
8
|
+
* @returns The name of the instance created.
|
|
9
|
+
* @throws GeneralError if the connector type is unknown.
|
|
10
|
+
*/
|
|
11
|
+
export declare function initialiseAttestationConnector(engineCore: IEngineCore, context: IEngineCoreContext, instanceConfig: AttestationConnectorConfig, overrideInstanceType?: string): string | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Initialise the attestation component.
|
|
14
|
+
* @param engineCore The engine core.
|
|
15
|
+
* @param context The context for the engine.
|
|
16
|
+
* @param instanceConfig The instance config.
|
|
17
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
18
|
+
* @returns The name of the instance created.
|
|
19
|
+
* @throws GeneralError if the component type is unknown.
|
|
20
|
+
*/
|
|
21
|
+
export declare function initialiseAttestationComponent(engineCore: IEngineCore, context: IEngineCoreContext, instanceConfig: AttestationComponentConfig, overrideInstanceType?: string): string | undefined;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type AuditableItemGraphComponentConfig, type IEngineCore, type IEngineCoreContext } from "@twin.org/engine-models";
|
|
2
|
+
/**
|
|
3
|
+
* Initialise the auditable item graph component.
|
|
4
|
+
* @param engineCore The engine core.
|
|
5
|
+
* @param context The context for the engine.
|
|
6
|
+
* @param instanceConfig The instance config.
|
|
7
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
8
|
+
* @returns The name of the instance created.
|
|
9
|
+
* @throws GeneralError if the component type is unknown.
|
|
10
|
+
*/
|
|
11
|
+
export declare function initialiseAuditableItemGraphComponent(engineCore: IEngineCore, context: IEngineCoreContext, instanceConfig: AuditableItemGraphComponentConfig, overrideInstanceType?: string): string | undefined;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type AuditableItemStreamComponentConfig, type IEngineCore, type IEngineCoreContext } from "@twin.org/engine-models";
|
|
2
|
+
/**
|
|
3
|
+
* Initialise the auditable item stream component.
|
|
4
|
+
* @param engineCore The engine core.
|
|
5
|
+
* @param context The context for the engine.
|
|
6
|
+
* @param instanceConfig The instance config.
|
|
7
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
8
|
+
* @returns The name of the instance created.
|
|
9
|
+
* @throws GeneralError if the component type is unknown.
|
|
10
|
+
*/
|
|
11
|
+
export declare function initialiseAuditableItemStreamComponent(engineCore: IEngineCore, context: IEngineCoreContext, instanceConfig: AuditableItemStreamComponentConfig, overrideInstanceType?: string): string | undefined;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type IEngineCoreContext, type BackgroundTaskConnectorConfig, type IEngineCore } from "@twin.org/engine-models";
|
|
2
|
+
/**
|
|
3
|
+
* Initialise a background task connector.
|
|
4
|
+
* @param engineCore The engine core.
|
|
5
|
+
* @param context The context for the engine.
|
|
6
|
+
* @param instanceConfig The instance config.
|
|
7
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
8
|
+
* @returns The name of the instance created.
|
|
9
|
+
* @throws GeneralError if the connector type is unknown.
|
|
10
|
+
*/
|
|
11
|
+
export declare function initialiseBackgroundTaskConnector(engineCore: IEngineCore, context: IEngineCoreContext, instanceConfig: BackgroundTaskConnectorConfig, overrideInstanceType?: string): string | undefined;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type IEngineCoreContext, type BlobStorageComponentConfig, type BlobStorageConnectorConfig, type IEngineCore } from "@twin.org/engine-models";
|
|
2
|
+
/**
|
|
3
|
+
* Initialise the blob storage connector.
|
|
4
|
+
* @param engineCore The engine core.
|
|
5
|
+
* @param context The context for the engine.
|
|
6
|
+
* @param instanceConfig The instance config.
|
|
7
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
8
|
+
* @returns The name of the instance created.
|
|
9
|
+
* @throws GeneralError if the connector type is unknown.
|
|
10
|
+
*/
|
|
11
|
+
export declare function initialiseBlobStorageConnector(engineCore: IEngineCore, context: IEngineCoreContext, instanceConfig: BlobStorageConnectorConfig, overrideInstanceType?: string): string | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Initialise the blob storage component.
|
|
14
|
+
* @param engineCore The engine core.
|
|
15
|
+
* @param context The context for the engine.
|
|
16
|
+
* @param instanceConfig The instance config.
|
|
17
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
18
|
+
* @returns The name of the instance created.
|
|
19
|
+
* @throws GeneralError if the component type is unknown.
|
|
20
|
+
*/
|
|
21
|
+
export declare function initialiseBlobStorageComponent(engineCore: IEngineCore, context: IEngineCoreContext, instanceConfig: BlobStorageComponentConfig, overrideInstanceType?: string): string | undefined;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type EntityStorageComponentConfig, type IEngineCore, type IEngineCoreContext } from "@twin.org/engine-models";
|
|
2
|
+
/**
|
|
3
|
+
* Initialise the entity storage connector.
|
|
4
|
+
* @param engineCore The engine core.
|
|
5
|
+
* @param context The context for the engine.
|
|
6
|
+
* @param typeCustom Override the type of connector to use instead of default configuration.
|
|
7
|
+
* @param schema The schema for the entity storage.
|
|
8
|
+
* @throws GeneralError if the connector type is unknown.
|
|
9
|
+
*/
|
|
10
|
+
export declare function initialiseEntityStorageConnector(engineCore: IEngineCore, context: IEngineCoreContext, typeCustom: string | undefined, schema: string): void;
|
|
11
|
+
/**
|
|
12
|
+
* Initialise the entity storage connector.
|
|
13
|
+
* @param engineCore The engine core.
|
|
14
|
+
* @param context The context for the engine.
|
|
15
|
+
* @param instanceConfig The instance config.
|
|
16
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
17
|
+
* @returns The name of the instance created.
|
|
18
|
+
* @throws GeneralError if the connector type is unknown.
|
|
19
|
+
*/
|
|
20
|
+
export declare function initialiseEntityStorageComponent(engineCore: IEngineCore, context: IEngineCoreContext, instanceConfig: EntityStorageComponentConfig, overrideInstanceType?: string): string | undefined;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type FaucetConnectorConfig, type IEngineCore, type IEngineCoreContext } from "@twin.org/engine-models";
|
|
2
|
+
/**
|
|
3
|
+
* Initialise a faucet connector.
|
|
4
|
+
* @param engineCore The engine core.
|
|
5
|
+
* @param context The context for the engine.
|
|
6
|
+
* @param instanceConfig The instance config.
|
|
7
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
8
|
+
* @returns The name of the instance created.
|
|
9
|
+
* @throws GeneralError if the connector type is unknown.
|
|
10
|
+
*/
|
|
11
|
+
export declare function initialiseFaucetConnector(engineCore: IEngineCore, context: IEngineCoreContext, instanceConfig: FaucetConnectorConfig, overrideInstanceType?: string): string | undefined;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type IEngineCoreContext, type IdentityComponentConfig, type IdentityConnectorConfig, type IEngineCore } from "@twin.org/engine-models";
|
|
2
|
+
/**
|
|
3
|
+
* Initialise the identity connector.
|
|
4
|
+
* @param engineCore The engine core.
|
|
5
|
+
* @param context The context for the engine.
|
|
6
|
+
* @param instanceConfig The instance config.
|
|
7
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
8
|
+
* @returns The name of the instance created.
|
|
9
|
+
* @throws GeneralError if the connector type is unknown.
|
|
10
|
+
*/
|
|
11
|
+
export declare function initialiseIdentityConnector(engineCore: IEngineCore, context: IEngineCoreContext, instanceConfig: IdentityConnectorConfig, overrideInstanceType?: string): string | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Initialise the identity component.
|
|
14
|
+
* @param engineCore The engine core.
|
|
15
|
+
* @param context The context for the engine.
|
|
16
|
+
* @param instanceConfig The instance config.
|
|
17
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
18
|
+
* @returns The name of the instance created.
|
|
19
|
+
* @throws GeneralError if the component type is unknown.
|
|
20
|
+
*/
|
|
21
|
+
export declare function initialiseIdentityComponent(engineCore: IEngineCore, context: IEngineCoreContext, instanceConfig: IdentityComponentConfig, overrideInstanceType?: string): string | undefined;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type IEngineCoreContext, type IdentityProfileComponentConfig, type IdentityProfileConnectorConfig, type IEngineCore } from "@twin.org/engine-models";
|
|
2
|
+
/**
|
|
3
|
+
* Initialise the identity profile connector.
|
|
4
|
+
* @param engineCore The engine core.
|
|
5
|
+
* @param context The context for the engine.
|
|
6
|
+
* @param instanceConfig The instance config.
|
|
7
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
8
|
+
* @returns The name of the instance created.
|
|
9
|
+
* @throws GeneralError if the connector type is unknown.
|
|
10
|
+
*/
|
|
11
|
+
export declare function initialiseIdentityProfileConnector(engineCore: IEngineCore, context: IEngineCoreContext, instanceConfig: IdentityProfileConnectorConfig, overrideInstanceType?: string): string | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Initialise the identity profile component.
|
|
14
|
+
* @param engineCore The engine core.
|
|
15
|
+
* @param context The context for the engine.
|
|
16
|
+
* @param instanceConfig The instance config.
|
|
17
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
18
|
+
* @returns The name of the instance created.
|
|
19
|
+
* @throws GeneralError if the component type is unknown.
|
|
20
|
+
*/
|
|
21
|
+
export declare function initialiseIdentityProfileComponent(engineCore: IEngineCore, context: IEngineCoreContext, instanceConfig: IdentityProfileComponentConfig, overrideInstanceType?: string): string | undefined;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type IEngineCore, type IEngineCoreContext, type ImmutableProofComponentConfig } from "@twin.org/engine-models";
|
|
2
|
+
/**
|
|
3
|
+
* Initialise the immutable proof component.
|
|
4
|
+
* @param engineCore The engine core.
|
|
5
|
+
* @param context The context for the engine.
|
|
6
|
+
* @param instanceConfig The instance config.
|
|
7
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
8
|
+
* @returns The name of the instance created.
|
|
9
|
+
* @throws GeneralError if the component type is unknown.
|
|
10
|
+
*/
|
|
11
|
+
export declare function initialiseImmutableProofComponent(engineCore: IEngineCore, context: IEngineCoreContext, instanceConfig: ImmutableProofComponentConfig, overrideInstanceType?: string): string | undefined;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type IEngineCoreContext, type IEngineCore, type ImmutableStorageConnectorConfig } from "@twin.org/engine-models";
|
|
2
|
+
/**
|
|
3
|
+
* Initialise the immutable storage connector.
|
|
4
|
+
* @param engineCore The engine core.
|
|
5
|
+
* @param context The context for the engine.
|
|
6
|
+
* @param instanceConfig The instance config.
|
|
7
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
8
|
+
* @returns The name of the instance created.
|
|
9
|
+
* @throws GeneralError if the connector type is unknown.
|
|
10
|
+
*/
|
|
11
|
+
export declare function initialiseImmutableStorageConnector(engineCore: IEngineCore, context: IEngineCoreContext, instanceConfig: ImmutableStorageConnectorConfig, overrideInstanceType?: string): string | undefined;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type LoggingConnectorConfig, type IEngineCore, type LoggingComponentConfig, type IEngineCoreContext } from "@twin.org/engine-models";
|
|
2
|
+
/**
|
|
3
|
+
* Initialise the logging connector.
|
|
4
|
+
* @param engineCore The engine core.
|
|
5
|
+
* @param context The engine core context.
|
|
6
|
+
* @param instanceConfig The instance config.
|
|
7
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
8
|
+
* @returns The name of the instance created.
|
|
9
|
+
* @throws GeneralError if the connector type is unknown.
|
|
10
|
+
*/
|
|
11
|
+
export declare function initialiseLoggingConnector(engineCore: IEngineCore, context: IEngineCoreContext, instanceConfig: LoggingConnectorConfig, overrideInstanceType?: string): string | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Initialise the logging component.
|
|
14
|
+
* @param engineCore The engine core.
|
|
15
|
+
* @param context The context for the engine.
|
|
16
|
+
* @param instanceConfig The instance config.
|
|
17
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
18
|
+
* @returns The name of the instance created.
|
|
19
|
+
* @throws GeneralError if the component type is unknown.
|
|
20
|
+
*/
|
|
21
|
+
export declare function initialiseLoggingComponent(engineCore: IEngineCore, context: IEngineCoreContext, instanceConfig: LoggingComponentConfig, overrideInstanceType?: string): string | undefined;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type IEngineCoreContext, type IEngineCore, type NftComponentConfig, type NftConnectorConfig } from "@twin.org/engine-models";
|
|
2
|
+
/**
|
|
3
|
+
* Initialise the NFT connector.
|
|
4
|
+
* @param engineCore The engine core.
|
|
5
|
+
* @param context The context for the engine.
|
|
6
|
+
* @param instanceConfig The instance config.
|
|
7
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
8
|
+
* @returns The name of the instance created.
|
|
9
|
+
* @throws GeneralError if the connector type is unknown.
|
|
10
|
+
*/
|
|
11
|
+
export declare function initialiseNftConnector(engineCore: IEngineCore, context: IEngineCoreContext, instanceConfig: NftConnectorConfig, overrideInstanceType?: string): string | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Initialise the NFT component.
|
|
14
|
+
* @param engineCore The engine core.
|
|
15
|
+
* @param context The context for the engine.
|
|
16
|
+
* @param instanceConfig The instance config.
|
|
17
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
18
|
+
* @returns The name of the instance created.
|
|
19
|
+
* @throws GeneralError if the component type is unknown.
|
|
20
|
+
*/
|
|
21
|
+
export declare function initialiseNftComponent(engineCore: IEngineCore, context: IEngineCoreContext, instanceConfig: NftComponentConfig, overrideInstanceType?: string): string | undefined;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type IEngineCoreContext, type IEngineCore, type TelemetryComponentConfig, type TelemetryConnectorConfig } from "@twin.org/engine-models";
|
|
2
|
+
/**
|
|
3
|
+
* Initialise a telemetry connector.
|
|
4
|
+
* @param engineCore The engine core.
|
|
5
|
+
* @param context The context for the engine.
|
|
6
|
+
* @param instanceConfig The instance config.
|
|
7
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
8
|
+
* @returns The name of the instance created.
|
|
9
|
+
* @throws GeneralError if the connector type is unknown.
|
|
10
|
+
*/
|
|
11
|
+
export declare function initialiseTelemetryConnector(engineCore: IEngineCore, context: IEngineCoreContext, instanceConfig: TelemetryConnectorConfig, overrideInstanceType?: string): string | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Initialise the telemetry component.
|
|
14
|
+
* @param engineCore The engine core.
|
|
15
|
+
* @param context The context for the engine.
|
|
16
|
+
* @param instanceConfig The instance config.
|
|
17
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
18
|
+
* @returns The name of the instance created.
|
|
19
|
+
* @throws GeneralError if the component type is unknown.
|
|
20
|
+
*/
|
|
21
|
+
export declare function initialiseTelemetryComponent(engineCore: IEngineCore, context: IEngineCoreContext, instanceConfig: TelemetryComponentConfig, overrideInstanceType?: string): string | undefined;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type IEngineCoreContext, type IEngineCore, type VaultConnectorConfig } from "@twin.org/engine-models";
|
|
2
|
+
/**
|
|
3
|
+
* Initialise the vault connector.
|
|
4
|
+
* @param engineCore The engine core.
|
|
5
|
+
* @param context The context for the engine.
|
|
6
|
+
* @param instanceConfig The instance config.
|
|
7
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
8
|
+
* @returns The name of the instance created.
|
|
9
|
+
* @throws GeneralError if the connector type is unknown.
|
|
10
|
+
*/
|
|
11
|
+
export declare function initialiseVaultConnector(engineCore: IEngineCore, context: IEngineCoreContext, instanceConfig: VaultConnectorConfig, overrideInstanceType?: string): string | undefined;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type IEngineCoreContext, type IEngineCore, type WalletConnectorConfig } from "@twin.org/engine-models";
|
|
2
|
+
/**
|
|
3
|
+
* Initialise a wallet connector.
|
|
4
|
+
* @param engineCore The engine core.
|
|
5
|
+
* @param context The context for the node.
|
|
6
|
+
* @param instanceConfig The instance config.
|
|
7
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
8
|
+
* @returns The name of the instance created.
|
|
9
|
+
* @throws GeneralError if the connector type is unknown.
|
|
10
|
+
*/
|
|
11
|
+
export declare function initialiseWalletConnector(engineCore: IEngineCore, context: IEngineCoreContext, instanceConfig: WalletConnectorConfig, overrideInstanceType?: string): string | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Initialise the wallet storage.
|
|
14
|
+
* @param engineCore The engine core.
|
|
15
|
+
* @param context The context for the engine.
|
|
16
|
+
* @param instanceConfig The instance config.
|
|
17
|
+
* @param overrideInstanceType The instance type to override the default.
|
|
18
|
+
* @returns Nothing.
|
|
19
|
+
* @throws GeneralError if the connector type is unknown.
|
|
20
|
+
*/
|
|
21
|
+
export declare function initialiseWalletStorage(engineCore: IEngineCore, context: IEngineCoreContext, instanceConfig: WalletConnectorConfig, overrideInstanceType?: string): string | undefined;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { type IError } from "@twin.org/core";
|
|
2
|
+
import type { EngineTypeInitialiser, IEngineCore, IEngineCoreConfig, IEngineCoreTypeBaseConfig, IEngineCoreTypeConfig, IEngineState } from "@twin.org/engine-models";
|
|
3
|
+
import type { IEngineCoreOptions } from "./models/IEngineCoreOptions";
|
|
4
|
+
/**
|
|
5
|
+
* Core for the engine.
|
|
6
|
+
*/
|
|
7
|
+
export declare class EngineCore implements IEngineCore {
|
|
8
|
+
/**
|
|
9
|
+
* Name for the engine logger.
|
|
10
|
+
*/
|
|
11
|
+
static readonly LOGGER_TYPE_NAME: string;
|
|
12
|
+
/**
|
|
13
|
+
* Runtime name for the class.
|
|
14
|
+
*/
|
|
15
|
+
readonly CLASS_NAME: string;
|
|
16
|
+
/**
|
|
17
|
+
* Create a new instance of EngineCore.
|
|
18
|
+
* @param options The options for the engine.
|
|
19
|
+
*/
|
|
20
|
+
constructor(options?: IEngineCoreOptions);
|
|
21
|
+
/**
|
|
22
|
+
* Add a type initialiser.
|
|
23
|
+
* @param type The type to add the initialiser for.
|
|
24
|
+
* @param typeConfig The type config.
|
|
25
|
+
* @param initialiser The initialiser to add.
|
|
26
|
+
*/
|
|
27
|
+
addTypeInitialiser<V extends IEngineCoreTypeBaseConfig>(type: string, typeConfig: IEngineCoreTypeConfig[] | undefined, initialiser: EngineTypeInitialiser<V>): void;
|
|
28
|
+
/**
|
|
29
|
+
* Start the engine core.
|
|
30
|
+
* @returns Nothing.
|
|
31
|
+
*/
|
|
32
|
+
start(): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Stop the engine core.
|
|
35
|
+
* @returns Nothing.
|
|
36
|
+
*/
|
|
37
|
+
stop(): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Log info.
|
|
40
|
+
* @param message The message to log.
|
|
41
|
+
*/
|
|
42
|
+
logInfo(message: string): void;
|
|
43
|
+
/**
|
|
44
|
+
* Log error.
|
|
45
|
+
* @param error The error to log.
|
|
46
|
+
*/
|
|
47
|
+
logError(error: IError): void;
|
|
48
|
+
/**
|
|
49
|
+
* Get the config for the engine.
|
|
50
|
+
* @returns The config for the engine.
|
|
51
|
+
*/
|
|
52
|
+
getConfig(): IEngineCoreConfig;
|
|
53
|
+
/**
|
|
54
|
+
* Get the state of the engine.
|
|
55
|
+
* @returns The state of the engine.
|
|
56
|
+
*/
|
|
57
|
+
getState(): IEngineState;
|
|
58
|
+
/**
|
|
59
|
+
* Get the types for the component.
|
|
60
|
+
* @returns The default types.
|
|
61
|
+
*/
|
|
62
|
+
getDefaultTypes(): {
|
|
63
|
+
[type: string]: string;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { IEngineCore, IEngineCoreConfig, IEngineCoreContext, IEngineStateStorage } from "@twin.org/engine-models";
|
|
2
|
+
/**
|
|
3
|
+
* The options for creating engine core.
|
|
4
|
+
*/
|
|
5
|
+
export interface IEngineCoreOptions {
|
|
6
|
+
/**
|
|
7
|
+
* The engine core config.
|
|
8
|
+
*/
|
|
9
|
+
config?: IEngineCoreConfig;
|
|
10
|
+
/**
|
|
11
|
+
* The state storage component.
|
|
12
|
+
*/
|
|
13
|
+
stateStorage?: IEngineStateStorage;
|
|
14
|
+
/**
|
|
15
|
+
* Skip the bootstrap process, useful for additional engine instances.
|
|
16
|
+
*/
|
|
17
|
+
skipBootstrap?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Custom bootstrap method for the engine.
|
|
20
|
+
*/
|
|
21
|
+
customBootstrap?: (engineCore: IEngineCore, context: IEngineCoreContext) => Promise<void>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { IEngineCore, IEngineState, IEngineStateStorage } from "@twin.org/engine-models";
|
|
2
|
+
/**
|
|
3
|
+
* Store state in a file.
|
|
4
|
+
*/
|
|
5
|
+
export declare class FileStateStorage implements IEngineStateStorage {
|
|
6
|
+
/**
|
|
7
|
+
* Runtime name for the class.
|
|
8
|
+
*/
|
|
9
|
+
readonly CLASS_NAME: string;
|
|
10
|
+
/**
|
|
11
|
+
* Create a new instance of FileStateStorage.
|
|
12
|
+
* @param filename The filename to store the state.
|
|
13
|
+
* @param readonlyMode Whether the file is in read-only mode.
|
|
14
|
+
*/
|
|
15
|
+
constructor(filename: string, readonlyMode?: boolean);
|
|
16
|
+
/**
|
|
17
|
+
* Method for loading the state.
|
|
18
|
+
* @param engineCore The engine core to load the state for.
|
|
19
|
+
* @returns The state of the engine or undefined if it doesn't exist.
|
|
20
|
+
*/
|
|
21
|
+
load(engineCore: IEngineCore): Promise<IEngineState | undefined>;
|
|
22
|
+
/**
|
|
23
|
+
* Method for saving the state.
|
|
24
|
+
* @param engineCore The engine core to save the state for.
|
|
25
|
+
* @param state The state of the engine to save.
|
|
26
|
+
* @returns Nothing.
|
|
27
|
+
*/
|
|
28
|
+
save(engineCore: IEngineCore, state: IEngineState): Promise<void>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { IEngineCore, IEngineState, IEngineStateStorage } from "@twin.org/engine-models";
|
|
2
|
+
/**
|
|
3
|
+
* Store state in memory.
|
|
4
|
+
*/
|
|
5
|
+
export declare class MemoryStateStorage implements IEngineStateStorage {
|
|
6
|
+
/**
|
|
7
|
+
* Runtime name for the class.
|
|
8
|
+
*/
|
|
9
|
+
readonly CLASS_NAME: string;
|
|
10
|
+
/**
|
|
11
|
+
* Create a new instance of MemoryStateStorage.
|
|
12
|
+
* @param readonlyMode Whether the file is in read-only mode.
|
|
13
|
+
*/
|
|
14
|
+
constructor(readonlyMode?: boolean);
|
|
15
|
+
/**
|
|
16
|
+
* Method for loading the state.
|
|
17
|
+
* @param engineCore The engine core to load the state for.
|
|
18
|
+
* @returns The state of the engine or undefined if it doesn't exist.
|
|
19
|
+
*/
|
|
20
|
+
load(engineCore: IEngineCore): Promise<IEngineState | undefined>;
|
|
21
|
+
/**
|
|
22
|
+
* Method for saving the state.
|
|
23
|
+
* @param engineCore The engine core to save the state for.
|
|
24
|
+
* @param state The state of the engine to save.
|
|
25
|
+
* @returns Nothing.
|
|
26
|
+
*/
|
|
27
|
+
save(engineCore: IEngineCore, state: IEngineState): Promise<void>;
|
|
28
|
+
}
|
package/docs/examples.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# @twin.org/engine-core - Examples
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# Class: EngineCore
|
|
2
|
+
|
|
3
|
+
Core for the engine.
|
|
4
|
+
|
|
5
|
+
## Implements
|
|
6
|
+
|
|
7
|
+
- `IEngineCore`
|
|
8
|
+
|
|
9
|
+
## Constructors
|
|
10
|
+
|
|
11
|
+
### new EngineCore()
|
|
12
|
+
|
|
13
|
+
> **new EngineCore**(`options`?): [`EngineCore`](EngineCore.md)
|
|
14
|
+
|
|
15
|
+
Create a new instance of EngineCore.
|
|
16
|
+
|
|
17
|
+
#### Parameters
|
|
18
|
+
|
|
19
|
+
• **options?**: [`IEngineCoreOptions`](../interfaces/IEngineCoreOptions.md)
|
|
20
|
+
|
|
21
|
+
The options for the engine.
|
|
22
|
+
|
|
23
|
+
#### Returns
|
|
24
|
+
|
|
25
|
+
[`EngineCore`](EngineCore.md)
|
|
26
|
+
|
|
27
|
+
## Properties
|
|
28
|
+
|
|
29
|
+
### LOGGER\_TYPE\_NAME
|
|
30
|
+
|
|
31
|
+
> `readonly` `static` **LOGGER\_TYPE\_NAME**: `string` = `"engine"`
|
|
32
|
+
|
|
33
|
+
Name for the engine logger.
|
|
34
|
+
|
|
35
|
+
***
|
|
36
|
+
|
|
37
|
+
### CLASS\_NAME
|
|
38
|
+
|
|
39
|
+
> `readonly` **CLASS\_NAME**: `string`
|
|
40
|
+
|
|
41
|
+
Runtime name for the class.
|
|
42
|
+
|
|
43
|
+
## Methods
|
|
44
|
+
|
|
45
|
+
### addTypeInitialiser()
|
|
46
|
+
|
|
47
|
+
> **addTypeInitialiser**\<`V`\>(`type`, `typeConfig`, `initialiser`): `void`
|
|
48
|
+
|
|
49
|
+
Add a type initialiser.
|
|
50
|
+
|
|
51
|
+
#### Type Parameters
|
|
52
|
+
|
|
53
|
+
• **V** *extends* `IEngineCoreTypeBaseConfig`\<`unknown`\>
|
|
54
|
+
|
|
55
|
+
#### Parameters
|
|
56
|
+
|
|
57
|
+
• **type**: `string`
|
|
58
|
+
|
|
59
|
+
The type to add the initialiser for.
|
|
60
|
+
|
|
61
|
+
• **typeConfig**: `undefined` \| `IEngineCoreTypeConfig`[]
|
|
62
|
+
|
|
63
|
+
The type config.
|
|
64
|
+
|
|
65
|
+
• **initialiser**: `EngineTypeInitialiser`\<`V`\>
|
|
66
|
+
|
|
67
|
+
The initialiser to add.
|
|
68
|
+
|
|
69
|
+
#### Returns
|
|
70
|
+
|
|
71
|
+
`void`
|
|
72
|
+
|
|
73
|
+
#### Implementation of
|
|
74
|
+
|
|
75
|
+
`IEngineCore.addTypeInitialiser`
|
|
76
|
+
|
|
77
|
+
***
|
|
78
|
+
|
|
79
|
+
### start()
|
|
80
|
+
|
|
81
|
+
> **start**(): `Promise`\<`void`\>
|
|
82
|
+
|
|
83
|
+
Start the engine core.
|
|
84
|
+
|
|
85
|
+
#### Returns
|
|
86
|
+
|
|
87
|
+
`Promise`\<`void`\>
|
|
88
|
+
|
|
89
|
+
Nothing.
|
|
90
|
+
|
|
91
|
+
#### Implementation of
|
|
92
|
+
|
|
93
|
+
`IEngineCore.start`
|
|
94
|
+
|
|
95
|
+
***
|
|
96
|
+
|
|
97
|
+
### stop()
|
|
98
|
+
|
|
99
|
+
> **stop**(): `Promise`\<`void`\>
|
|
100
|
+
|
|
101
|
+
Stop the engine core.
|
|
102
|
+
|
|
103
|
+
#### Returns
|
|
104
|
+
|
|
105
|
+
`Promise`\<`void`\>
|
|
106
|
+
|
|
107
|
+
Nothing.
|
|
108
|
+
|
|
109
|
+
#### Implementation of
|
|
110
|
+
|
|
111
|
+
`IEngineCore.stop`
|
|
112
|
+
|
|
113
|
+
***
|
|
114
|
+
|
|
115
|
+
### logInfo()
|
|
116
|
+
|
|
117
|
+
> **logInfo**(`message`): `void`
|
|
118
|
+
|
|
119
|
+
Log info.
|
|
120
|
+
|
|
121
|
+
#### Parameters
|
|
122
|
+
|
|
123
|
+
• **message**: `string`
|
|
124
|
+
|
|
125
|
+
The message to log.
|
|
126
|
+
|
|
127
|
+
#### Returns
|
|
128
|
+
|
|
129
|
+
`void`
|
|
130
|
+
|
|
131
|
+
#### Implementation of
|
|
132
|
+
|
|
133
|
+
`IEngineCore.logInfo`
|
|
134
|
+
|
|
135
|
+
***
|
|
136
|
+
|
|
137
|
+
### logError()
|
|
138
|
+
|
|
139
|
+
> **logError**(`error`): `void`
|
|
140
|
+
|
|
141
|
+
Log error.
|
|
142
|
+
|
|
143
|
+
#### Parameters
|
|
144
|
+
|
|
145
|
+
• **error**: `IError`
|
|
146
|
+
|
|
147
|
+
The error to log.
|
|
148
|
+
|
|
149
|
+
#### Returns
|
|
150
|
+
|
|
151
|
+
`void`
|
|
152
|
+
|
|
153
|
+
#### Implementation of
|
|
154
|
+
|
|
155
|
+
`IEngineCore.logError`
|
|
156
|
+
|
|
157
|
+
***
|
|
158
|
+
|
|
159
|
+
### getConfig()
|
|
160
|
+
|
|
161
|
+
> **getConfig**(): `IEngineCoreConfig`
|
|
162
|
+
|
|
163
|
+
Get the config for the engine.
|
|
164
|
+
|
|
165
|
+
#### Returns
|
|
166
|
+
|
|
167
|
+
`IEngineCoreConfig`
|
|
168
|
+
|
|
169
|
+
The config for the engine.
|
|
170
|
+
|
|
171
|
+
#### Implementation of
|
|
172
|
+
|
|
173
|
+
`IEngineCore.getConfig`
|
|
174
|
+
|
|
175
|
+
***
|
|
176
|
+
|
|
177
|
+
### getState()
|
|
178
|
+
|
|
179
|
+
> **getState**(): `IEngineState`
|
|
180
|
+
|
|
181
|
+
Get the state of the engine.
|
|
182
|
+
|
|
183
|
+
#### Returns
|
|
184
|
+
|
|
185
|
+
`IEngineState`
|
|
186
|
+
|
|
187
|
+
The state of the engine.
|
|
188
|
+
|
|
189
|
+
#### Implementation of
|
|
190
|
+
|
|
191
|
+
`IEngineCore.getState`
|
|
192
|
+
|
|
193
|
+
***
|
|
194
|
+
|
|
195
|
+
### getDefaultTypes()
|
|
196
|
+
|
|
197
|
+
> **getDefaultTypes**(): `object`
|
|
198
|
+
|
|
199
|
+
Get the types for the component.
|
|
200
|
+
|
|
201
|
+
#### Returns
|
|
202
|
+
|
|
203
|
+
`object`
|
|
204
|
+
|
|
205
|
+
The default types.
|
|
206
|
+
|
|
207
|
+
#### Implementation of
|
|
208
|
+
|
|
209
|
+
`IEngineCore.getDefaultTypes`
|