@twin.org/engine-core 0.0.1-next.1 → 0.0.1-next.2
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/dist/cjs/index.cjs +2 -2
- package/dist/esm/index.mjs +2 -2
- package/dist/types/engineCore.d.ts +2 -2
- package/dist/types/storage/fileStateStorage.d.ts +3 -3
- package/dist/types/storage/memoryStateStorage.d.ts +3 -3
- package/docs/changelog.md +1 -1
- package/docs/reference/classes/EngineCore.md +10 -6
- package/docs/reference/classes/FileStateStorage.md +13 -9
- package/docs/reference/classes/MemoryStateStorage.md +13 -9
- package/docs/reference/functions/initialiseEntityStorageConnector.md +2 -2
- package/docs/reference/interfaces/IEngineCoreOptions.md +3 -3
- package/package.json +2 -2
package/dist/cjs/index.cjs
CHANGED
|
@@ -1407,9 +1407,9 @@ class EngineCore {
|
|
|
1407
1407
|
async stateLoad() {
|
|
1408
1408
|
if (this._stateStorage) {
|
|
1409
1409
|
try {
|
|
1410
|
-
this._context.state = (await this._stateStorage.load(this)) ?? {
|
|
1410
|
+
this._context.state = ((await this._stateStorage.load(this)) ?? {
|
|
1411
1411
|
bootstrappedComponents: []
|
|
1412
|
-
};
|
|
1412
|
+
});
|
|
1413
1413
|
this._context.state.bootstrappedComponents ??= [];
|
|
1414
1414
|
this._context.stateDirty = false;
|
|
1415
1415
|
return true;
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1405,9 +1405,9 @@ class EngineCore {
|
|
|
1405
1405
|
async stateLoad() {
|
|
1406
1406
|
if (this._stateStorage) {
|
|
1407
1407
|
try {
|
|
1408
|
-
this._context.state = (await this._stateStorage.load(this)) ?? {
|
|
1408
|
+
this._context.state = ((await this._stateStorage.load(this)) ?? {
|
|
1409
1409
|
bootstrappedComponents: []
|
|
1410
|
-
};
|
|
1410
|
+
});
|
|
1411
1411
|
this._context.state.bootstrappedComponents ??= [];
|
|
1412
1412
|
this._context.stateDirty = false;
|
|
1413
1413
|
return true;
|
|
@@ -4,7 +4,7 @@ import type { IEngineCoreOptions } from "./models/IEngineCoreOptions";
|
|
|
4
4
|
/**
|
|
5
5
|
* Core for the engine.
|
|
6
6
|
*/
|
|
7
|
-
export declare class EngineCore implements IEngineCore {
|
|
7
|
+
export declare class EngineCore<S extends IEngineState = IEngineState> implements IEngineCore<S> {
|
|
8
8
|
/**
|
|
9
9
|
* Name for the engine logger.
|
|
10
10
|
*/
|
|
@@ -54,7 +54,7 @@ export declare class EngineCore implements IEngineCore {
|
|
|
54
54
|
* Get the state of the engine.
|
|
55
55
|
* @returns The state of the engine.
|
|
56
56
|
*/
|
|
57
|
-
getState():
|
|
57
|
+
getState(): S;
|
|
58
58
|
/**
|
|
59
59
|
* Get the types for the component.
|
|
60
60
|
* @returns The default types.
|
|
@@ -2,7 +2,7 @@ import type { IEngineCore, IEngineState, IEngineStateStorage } from "@twin.org/e
|
|
|
2
2
|
/**
|
|
3
3
|
* Store state in a file.
|
|
4
4
|
*/
|
|
5
|
-
export declare class FileStateStorage implements IEngineStateStorage {
|
|
5
|
+
export declare class FileStateStorage<S extends IEngineState = IEngineState> implements IEngineStateStorage<S> {
|
|
6
6
|
/**
|
|
7
7
|
* Runtime name for the class.
|
|
8
8
|
*/
|
|
@@ -18,12 +18,12 @@ export declare class FileStateStorage implements IEngineStateStorage {
|
|
|
18
18
|
* @param engineCore The engine core to load the state for.
|
|
19
19
|
* @returns The state of the engine or undefined if it doesn't exist.
|
|
20
20
|
*/
|
|
21
|
-
load(engineCore: IEngineCore): Promise<
|
|
21
|
+
load(engineCore: IEngineCore): Promise<S | undefined>;
|
|
22
22
|
/**
|
|
23
23
|
* Method for saving the state.
|
|
24
24
|
* @param engineCore The engine core to save the state for.
|
|
25
25
|
* @param state The state of the engine to save.
|
|
26
26
|
* @returns Nothing.
|
|
27
27
|
*/
|
|
28
|
-
save(engineCore: IEngineCore, state:
|
|
28
|
+
save(engineCore: IEngineCore, state: S): Promise<void>;
|
|
29
29
|
}
|
|
@@ -2,7 +2,7 @@ import type { IEngineCore, IEngineState, IEngineStateStorage } from "@twin.org/e
|
|
|
2
2
|
/**
|
|
3
3
|
* Store state in memory.
|
|
4
4
|
*/
|
|
5
|
-
export declare class MemoryStateStorage implements IEngineStateStorage {
|
|
5
|
+
export declare class MemoryStateStorage<S extends IEngineState = IEngineState> implements IEngineStateStorage<S> {
|
|
6
6
|
/**
|
|
7
7
|
* Runtime name for the class.
|
|
8
8
|
*/
|
|
@@ -17,12 +17,12 @@ export declare class MemoryStateStorage implements IEngineStateStorage {
|
|
|
17
17
|
* @param engineCore The engine core to load the state for.
|
|
18
18
|
* @returns The state of the engine or undefined if it doesn't exist.
|
|
19
19
|
*/
|
|
20
|
-
load(engineCore: IEngineCore): Promise<
|
|
20
|
+
load(engineCore: IEngineCore): Promise<S | undefined>;
|
|
21
21
|
/**
|
|
22
22
|
* Method for saving the state.
|
|
23
23
|
* @param engineCore The engine core to save the state for.
|
|
24
24
|
* @param state The state of the engine to save.
|
|
25
25
|
* @returns Nothing.
|
|
26
26
|
*/
|
|
27
|
-
save(engineCore: IEngineCore, state:
|
|
27
|
+
save(engineCore: IEngineCore, state: S): Promise<void>;
|
|
28
28
|
}
|
package/docs/changelog.md
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
# Class: EngineCore
|
|
1
|
+
# Class: EngineCore\<S\>
|
|
2
2
|
|
|
3
3
|
Core for the engine.
|
|
4
4
|
|
|
5
|
+
## Type Parameters
|
|
6
|
+
|
|
7
|
+
• **S** *extends* `IEngineState` = `IEngineState`
|
|
8
|
+
|
|
5
9
|
## Implements
|
|
6
10
|
|
|
7
|
-
- `IEngineCore
|
|
11
|
+
- `IEngineCore`\<`S`\>
|
|
8
12
|
|
|
9
13
|
## Constructors
|
|
10
14
|
|
|
11
15
|
### new EngineCore()
|
|
12
16
|
|
|
13
|
-
> **new EngineCore
|
|
17
|
+
> **new EngineCore**\<`S`\>(`options`?): [`EngineCore`](EngineCore.md)\<`S`\>
|
|
14
18
|
|
|
15
19
|
Create a new instance of EngineCore.
|
|
16
20
|
|
|
@@ -22,7 +26,7 @@ The options for the engine.
|
|
|
22
26
|
|
|
23
27
|
#### Returns
|
|
24
28
|
|
|
25
|
-
[`EngineCore`](EngineCore.md)
|
|
29
|
+
[`EngineCore`](EngineCore.md)\<`S`\>
|
|
26
30
|
|
|
27
31
|
## Properties
|
|
28
32
|
|
|
@@ -176,13 +180,13 @@ The config for the engine.
|
|
|
176
180
|
|
|
177
181
|
### getState()
|
|
178
182
|
|
|
179
|
-
> **getState**(): `
|
|
183
|
+
> **getState**(): `S`
|
|
180
184
|
|
|
181
185
|
Get the state of the engine.
|
|
182
186
|
|
|
183
187
|
#### Returns
|
|
184
188
|
|
|
185
|
-
`
|
|
189
|
+
`S`
|
|
186
190
|
|
|
187
191
|
The state of the engine.
|
|
188
192
|
|
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
# Class: FileStateStorage
|
|
1
|
+
# Class: FileStateStorage\<S\>
|
|
2
2
|
|
|
3
3
|
Store state in a file.
|
|
4
4
|
|
|
5
|
+
## Type Parameters
|
|
6
|
+
|
|
7
|
+
• **S** *extends* `IEngineState` = `IEngineState`
|
|
8
|
+
|
|
5
9
|
## Implements
|
|
6
10
|
|
|
7
|
-
- `IEngineStateStorage
|
|
11
|
+
- `IEngineStateStorage`\<`S`\>
|
|
8
12
|
|
|
9
13
|
## Constructors
|
|
10
14
|
|
|
11
15
|
### new FileStateStorage()
|
|
12
16
|
|
|
13
|
-
> **new FileStateStorage
|
|
17
|
+
> **new FileStateStorage**\<`S`\>(`filename`, `readonlyMode`): [`FileStateStorage`](FileStateStorage.md)\<`S`\>
|
|
14
18
|
|
|
15
19
|
Create a new instance of FileStateStorage.
|
|
16
20
|
|
|
@@ -26,7 +30,7 @@ Whether the file is in read-only mode.
|
|
|
26
30
|
|
|
27
31
|
#### Returns
|
|
28
32
|
|
|
29
|
-
[`FileStateStorage`](FileStateStorage.md)
|
|
33
|
+
[`FileStateStorage`](FileStateStorage.md)\<`S`\>
|
|
30
34
|
|
|
31
35
|
## Properties
|
|
32
36
|
|
|
@@ -40,19 +44,19 @@ Runtime name for the class.
|
|
|
40
44
|
|
|
41
45
|
### load()
|
|
42
46
|
|
|
43
|
-
> **load**(`engineCore`): `Promise`\<`undefined` \| `
|
|
47
|
+
> **load**(`engineCore`): `Promise`\<`undefined` \| `S`\>
|
|
44
48
|
|
|
45
49
|
Method for loading the state.
|
|
46
50
|
|
|
47
51
|
#### Parameters
|
|
48
52
|
|
|
49
|
-
• **engineCore**: `IEngineCore
|
|
53
|
+
• **engineCore**: `IEngineCore`\<`IEngineState`\>
|
|
50
54
|
|
|
51
55
|
The engine core to load the state for.
|
|
52
56
|
|
|
53
57
|
#### Returns
|
|
54
58
|
|
|
55
|
-
`Promise`\<`undefined` \| `
|
|
59
|
+
`Promise`\<`undefined` \| `S`\>
|
|
56
60
|
|
|
57
61
|
The state of the engine or undefined if it doesn't exist.
|
|
58
62
|
|
|
@@ -70,11 +74,11 @@ Method for saving the state.
|
|
|
70
74
|
|
|
71
75
|
#### Parameters
|
|
72
76
|
|
|
73
|
-
• **engineCore**: `IEngineCore
|
|
77
|
+
• **engineCore**: `IEngineCore`\<`IEngineState`\>
|
|
74
78
|
|
|
75
79
|
The engine core to save the state for.
|
|
76
80
|
|
|
77
|
-
• **state**: `
|
|
81
|
+
• **state**: `S`
|
|
78
82
|
|
|
79
83
|
The state of the engine to save.
|
|
80
84
|
|
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
# Class: MemoryStateStorage
|
|
1
|
+
# Class: MemoryStateStorage\<S\>
|
|
2
2
|
|
|
3
3
|
Store state in memory.
|
|
4
4
|
|
|
5
|
+
## Type Parameters
|
|
6
|
+
|
|
7
|
+
• **S** *extends* `IEngineState` = `IEngineState`
|
|
8
|
+
|
|
5
9
|
## Implements
|
|
6
10
|
|
|
7
|
-
- `IEngineStateStorage
|
|
11
|
+
- `IEngineStateStorage`\<`S`\>
|
|
8
12
|
|
|
9
13
|
## Constructors
|
|
10
14
|
|
|
11
15
|
### new MemoryStateStorage()
|
|
12
16
|
|
|
13
|
-
> **new MemoryStateStorage
|
|
17
|
+
> **new MemoryStateStorage**\<`S`\>(`readonlyMode`): [`MemoryStateStorage`](MemoryStateStorage.md)\<`S`\>
|
|
14
18
|
|
|
15
19
|
Create a new instance of MemoryStateStorage.
|
|
16
20
|
|
|
@@ -22,7 +26,7 @@ Whether the file is in read-only mode.
|
|
|
22
26
|
|
|
23
27
|
#### Returns
|
|
24
28
|
|
|
25
|
-
[`MemoryStateStorage`](MemoryStateStorage.md)
|
|
29
|
+
[`MemoryStateStorage`](MemoryStateStorage.md)\<`S`\>
|
|
26
30
|
|
|
27
31
|
## Properties
|
|
28
32
|
|
|
@@ -36,19 +40,19 @@ Runtime name for the class.
|
|
|
36
40
|
|
|
37
41
|
### load()
|
|
38
42
|
|
|
39
|
-
> **load**(`engineCore`): `Promise`\<`undefined` \| `
|
|
43
|
+
> **load**(`engineCore`): `Promise`\<`undefined` \| `S`\>
|
|
40
44
|
|
|
41
45
|
Method for loading the state.
|
|
42
46
|
|
|
43
47
|
#### Parameters
|
|
44
48
|
|
|
45
|
-
• **engineCore**: `IEngineCore
|
|
49
|
+
• **engineCore**: `IEngineCore`\<`IEngineState`\>
|
|
46
50
|
|
|
47
51
|
The engine core to load the state for.
|
|
48
52
|
|
|
49
53
|
#### Returns
|
|
50
54
|
|
|
51
|
-
`Promise`\<`undefined` \| `
|
|
55
|
+
`Promise`\<`undefined` \| `S`\>
|
|
52
56
|
|
|
53
57
|
The state of the engine or undefined if it doesn't exist.
|
|
54
58
|
|
|
@@ -66,11 +70,11 @@ Method for saving the state.
|
|
|
66
70
|
|
|
67
71
|
#### Parameters
|
|
68
72
|
|
|
69
|
-
• **engineCore**: `IEngineCore
|
|
73
|
+
• **engineCore**: `IEngineCore`\<`IEngineState`\>
|
|
70
74
|
|
|
71
75
|
The engine core to save the state for.
|
|
72
76
|
|
|
73
|
-
• **state**: `
|
|
77
|
+
• **state**: `S`
|
|
74
78
|
|
|
75
79
|
The state of the engine to save.
|
|
76
80
|
|
|
@@ -6,11 +6,11 @@ Initialise the entity storage connector.
|
|
|
6
6
|
|
|
7
7
|
## Parameters
|
|
8
8
|
|
|
9
|
-
• **engineCore**: `IEngineCore
|
|
9
|
+
• **engineCore**: `IEngineCore`\<`IEngineState`\>
|
|
10
10
|
|
|
11
11
|
The engine core.
|
|
12
12
|
|
|
13
|
-
• **context**: `IEngineCoreContext
|
|
13
|
+
• **context**: `IEngineCoreContext`\<`IEngineState`\>
|
|
14
14
|
|
|
15
15
|
The context for the engine.
|
|
16
16
|
|
|
@@ -14,7 +14,7 @@ The engine core config.
|
|
|
14
14
|
|
|
15
15
|
### stateStorage?
|
|
16
16
|
|
|
17
|
-
> `optional` **stateStorage**: `IEngineStateStorage
|
|
17
|
+
> `optional` **stateStorage**: `IEngineStateStorage`\<`IEngineState`\>
|
|
18
18
|
|
|
19
19
|
The state storage component.
|
|
20
20
|
|
|
@@ -36,9 +36,9 @@ Custom bootstrap method for the engine.
|
|
|
36
36
|
|
|
37
37
|
#### Parameters
|
|
38
38
|
|
|
39
|
-
• **engineCore**: `IEngineCore
|
|
39
|
+
• **engineCore**: `IEngineCore`\<`IEngineState`\>
|
|
40
40
|
|
|
41
|
-
• **context**: `IEngineCoreContext
|
|
41
|
+
• **context**: `IEngineCoreContext`\<`IEngineState`\>
|
|
42
42
|
|
|
43
43
|
#### Returns
|
|
44
44
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/engine-core",
|
|
3
|
-
"version": "0.0.1-next.
|
|
3
|
+
"version": "0.0.1-next.2",
|
|
4
4
|
"description": "Engine implementation for a core.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@twin.org/crypto": "next",
|
|
44
44
|
"@twin.org/data-core": "next",
|
|
45
45
|
"@twin.org/data-schema-org": "next",
|
|
46
|
-
"@twin.org/engine-models": "0.0.1-next.
|
|
46
|
+
"@twin.org/engine-models": "0.0.1-next.2",
|
|
47
47
|
"@twin.org/entity": "next",
|
|
48
48
|
"@twin.org/entity-storage-connector-cosmosdb": "next",
|
|
49
49
|
"@twin.org/entity-storage-connector-dynamodb": "next",
|