@twin.org/engine-models 0.0.3-next.26 → 0.0.3-next.27

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # TWIN Engine Models
2
2
 
3
- Models which define the structure of the engine.
3
+ Engine Models defines shared contracts and factories used to compose runtime behaviour across the repository. It provides stable interfaces for core and server implementations so packages can interoperate with a clear and predictable structure.
4
4
 
5
5
  ## Installation
6
6
 
package/docs/changelog.md CHANGED
@@ -1,4 +1,11 @@
1
- # @twin.org/engine-models - Changelog
1
+ # Changelog
2
+
3
+ ## [0.0.3-next.27](https://github.com/twinfoundation/engine/compare/engine-models-v0.0.3-next.26...engine-models-v0.0.3-next.27) (2026-03-20)
4
+
5
+
6
+ ### Features
7
+
8
+ * update dependencies ([e6ebe42](https://github.com/twinfoundation/engine/commit/e6ebe42b9d61066227ad8b45dae14c8f8615b760))
2
9
 
3
10
  ## [0.0.3-next.26](https://github.com/twinfoundation/engine/compare/engine-models-v0.0.3-next.25...engine-models-v0.0.3-next.26) (2026-03-05)
4
11
 
package/docs/examples.md CHANGED
@@ -1 +1,52 @@
1
- # @twin.org/engine-models - Examples
1
+ # Engine Models Examples
2
+
3
+ These examples show how to register factories and define strongly typed contracts for core and server integrations.
4
+
5
+ ## EngineCoreFactory and EngineServerFactory
6
+
7
+ ```typescript
8
+ import { EngineCoreFactory, EngineServerFactory } from '@twin.org/engine-models';
9
+ import { EngineCore } from '@twin.org/engine-core';
10
+ import { EngineServer } from '@twin.org/engine-server';
11
+
12
+ EngineCoreFactory.register(
13
+ 'default',
14
+ () => new EngineCore({ config: { debug: false, silent: true, types: {} }, skipBootstrap: true })
15
+ );
16
+ EngineServerFactory.register(
17
+ 'default',
18
+ () => new EngineServer({ engineCore: EngineCoreFactory.get('default') })
19
+ );
20
+
21
+ const core = EngineCoreFactory.get('default');
22
+ const server = EngineServerFactory.get('default');
23
+
24
+ console.log(core.isStarted()); // false
25
+ console.log(server.getRestRoutes().length); // 0
26
+ ```
27
+
28
+ ## IEngineCoreConfig and IEngineCoreTypeConfig
29
+
30
+ ```typescript
31
+ import type { IEngineCoreConfig, IEngineCoreTypeConfig } from '@twin.org/engine-models';
32
+
33
+ const loggingConnectorConfig: IEngineCoreTypeConfig<{ config: { prettyPrint: boolean } }> = {
34
+ type: 'console',
35
+ isDefault: true,
36
+ options: {
37
+ config: {
38
+ prettyPrint: true
39
+ }
40
+ }
41
+ };
42
+
43
+ const coreConfig: IEngineCoreConfig = {
44
+ debug: true,
45
+ silent: false,
46
+ types: {
47
+ loggingConnector: [loggingConnectorConfig]
48
+ }
49
+ };
50
+
51
+ console.log(coreConfig.types.loggingConnector?.[0].type); // "console"
52
+ ```
@@ -14,25 +14,25 @@ Engine type initialiser return type.
14
14
 
15
15
  ## Properties
16
16
 
17
- ### instanceTypeName?
17
+ ### instanceTypeName? {#instancetypename}
18
18
 
19
- > `optional` **instanceTypeName**: `string`
19
+ > `optional` **instanceTypeName?**: `string`
20
20
 
21
21
  The instance type created.
22
22
 
23
23
  ***
24
24
 
25
- ### factory?
25
+ ### factory? {#factory}
26
26
 
27
- > `optional` **factory**: `F`
27
+ > `optional` **factory?**: `F`
28
28
 
29
29
  The factory to store the instance in.
30
30
 
31
31
  ***
32
32
 
33
- ### createComponent()?
33
+ ### createComponent? {#createcomponent}
34
34
 
35
- > `optional` **createComponent**: (`additionalConfig`) => `IComponent`
35
+ > `optional` **createComponent?**: (`additionalConfig`) => `IComponent`
36
36
 
37
37
  Create a new component.
38
38
 
@@ -14,7 +14,7 @@ Interface describing the engine core methods.
14
14
 
15
15
  ## Methods
16
16
 
17
- ### addTypeInitialiser()
17
+ ### addTypeInitialiser() {#addtypeinitialiser}
18
18
 
19
19
  > **addTypeInitialiser**(`type`, `module`, `method`): `void`
20
20
 
@@ -46,7 +46,7 @@ The name of the method to call.
46
46
 
47
47
  ***
48
48
 
49
- ### getTypeConfig()
49
+ ### getTypeConfig() {#gettypeconfig}
50
50
 
51
51
  > **getTypeConfig**(`type`): [`IEngineCoreTypeConfig`](../type-aliases/IEngineCoreTypeConfig.md)[] \| `undefined`
52
52
 
@@ -68,7 +68,7 @@ The type config or undefined if not found.
68
68
 
69
69
  ***
70
70
 
71
- ### addContextIdKey()
71
+ ### addContextIdKey() {#addcontextidkey}
72
72
 
73
73
  > **addContextIdKey**(`key`, `componentFeatures`): `void`
74
74
 
@@ -94,7 +94,7 @@ The component features for the context ID handler.
94
94
 
95
95
  ***
96
96
 
97
- ### getContextIdKeys()
97
+ ### getContextIdKeys() {#getcontextidkeys}
98
98
 
99
99
  > **getContextIdKeys**(): `string`[]
100
100
 
@@ -108,7 +108,7 @@ The context IDs keys.
108
108
 
109
109
  ***
110
110
 
111
- ### addContextId()
111
+ ### addContextId() {#addcontextid}
112
112
 
113
113
  > **addContextId**(`key`, `value`): `void`
114
114
 
@@ -134,7 +134,7 @@ The context ID value.
134
134
 
135
135
  ***
136
136
 
137
- ### getContextIds()
137
+ ### getContextIds() {#getcontextids}
138
138
 
139
139
  > **getContextIds**(): `IContextIds` \| `undefined`
140
140
 
@@ -148,7 +148,7 @@ The context IDs or undefined if none are set.
148
148
 
149
149
  ***
150
150
 
151
- ### start()
151
+ ### start() {#start}
152
152
 
153
153
  > **start**(`skipComponentStart?`): `Promise`\<`void`\>
154
154
 
@@ -170,7 +170,7 @@ Nothing.
170
170
 
171
171
  ***
172
172
 
173
- ### stop()
173
+ ### stop() {#stop}
174
174
 
175
175
  > **stop**(): `Promise`\<`void`\>
176
176
 
@@ -184,7 +184,7 @@ Nothing.
184
184
 
185
185
  ***
186
186
 
187
- ### isStarted()
187
+ ### isStarted() {#isstarted}
188
188
 
189
189
  > **isStarted**(): `boolean`
190
190
 
@@ -198,7 +198,7 @@ True if the engine is started.
198
198
 
199
199
  ***
200
200
 
201
- ### isPrimary()
201
+ ### isPrimary() {#isprimary}
202
202
 
203
203
  > **isPrimary**(): `boolean`
204
204
 
@@ -212,7 +212,7 @@ True if the engine is the primary instance.
212
212
 
213
213
  ***
214
214
 
215
- ### isClone()
215
+ ### isClone() {#isclone}
216
216
 
217
217
  > **isClone**(): `boolean`
218
218
 
@@ -226,7 +226,7 @@ True if the engine instance is a clone.
226
226
 
227
227
  ***
228
228
 
229
- ### logInfo()
229
+ ### logInfo() {#loginfo}
230
230
 
231
231
  > **logInfo**(`message`): `void`
232
232
 
@@ -246,7 +246,7 @@ The message to log.
246
246
 
247
247
  ***
248
248
 
249
- ### logError()
249
+ ### logError() {#logerror}
250
250
 
251
251
  > **logError**(`error`): `void`
252
252
 
@@ -266,7 +266,7 @@ The error to log.
266
266
 
267
267
  ***
268
268
 
269
- ### getConfig()
269
+ ### getConfig() {#getconfig}
270
270
 
271
271
  > **getConfig**(): `C`
272
272
 
@@ -280,7 +280,7 @@ The config for the engine.
280
280
 
281
281
  ***
282
282
 
283
- ### getState()
283
+ ### getState() {#getstate}
284
284
 
285
285
  > **getState**(): `S`
286
286
 
@@ -294,7 +294,7 @@ The state of the engine.
294
294
 
295
295
  ***
296
296
 
297
- ### setStateDirty()
297
+ ### setStateDirty() {#setstatedirty}
298
298
 
299
299
  > **setStateDirty**(): `void`
300
300
 
@@ -306,7 +306,7 @@ Set the state to dirty so it gets saved.
306
306
 
307
307
  ***
308
308
 
309
- ### getRegisteredInstances()
309
+ ### getRegisteredInstances() {#getregisteredinstances}
310
310
 
311
311
  > **getRegisteredInstances**(): `object`
312
312
 
@@ -320,7 +320,7 @@ The registered instances.
320
320
 
321
321
  ***
322
322
 
323
- ### getRegisteredInstanceType()
323
+ ### getRegisteredInstanceType() {#getregisteredinstancetype}
324
324
 
325
325
  > **getRegisteredInstanceType**(`componentConnectorType`, `features?`): `string`
326
326
 
@@ -352,7 +352,7 @@ If a matching instance was not found.
352
352
 
353
353
  ***
354
354
 
355
- ### getRegisteredInstanceTypeOptional()
355
+ ### getRegisteredInstanceTypeOptional() {#getregisteredinstancetypeoptional}
356
356
 
357
357
  > **getRegisteredInstanceTypeOptional**(`componentConnectorType`, `features?`): `string` \| `undefined`
358
358
 
@@ -380,7 +380,7 @@ The instance type matching the criteria if one is registered.
380
380
 
381
381
  ***
382
382
 
383
- ### getCloneData()
383
+ ### getCloneData() {#getclonedata}
384
384
 
385
385
  > **getCloneData**(): [`IEngineCoreClone`](IEngineCoreClone.md)\<`C`, `S`\>
386
386
 
@@ -394,7 +394,7 @@ The clone data.
394
394
 
395
395
  ***
396
396
 
397
- ### populateClone()
397
+ ### populateClone() {#populateclone}
398
398
 
399
399
  > **populateClone**(`cloneData`, `contextIds?`, `silent?`): `void`
400
400
 
@@ -14,7 +14,7 @@ Interface describing the data required to clone an engine.
14
14
 
15
15
  ## Properties
16
16
 
17
- ### config
17
+ ### config {#config}
18
18
 
19
19
  > **config**: `C`
20
20
 
@@ -22,7 +22,7 @@ The config for the engine.
22
22
 
23
23
  ***
24
24
 
25
- ### state
25
+ ### state {#state}
26
26
 
27
27
  > **state**: `S`
28
28
 
@@ -30,7 +30,7 @@ The state of the engine.
30
30
 
31
31
  ***
32
32
 
33
- ### typeInitialisers
33
+ ### typeInitialisers {#typeinitialisers}
34
34
 
35
35
  > **typeInitialisers**: `object`[]
36
36
 
@@ -50,7 +50,7 @@ The type initialisers for the engine.
50
50
 
51
51
  ***
52
52
 
53
- ### entitySchemas
53
+ ### entitySchemas {#entityschemas}
54
54
 
55
55
  > **entitySchemas**: `object`
56
56
 
@@ -62,7 +62,7 @@ The entity schemas for the engine.
62
62
 
63
63
  ***
64
64
 
65
- ### contextIdKeys
65
+ ### contextIdKeys {#contextidkeys}
66
66
 
67
67
  > **contextIdKeys**: `object`[]
68
68
 
@@ -4,9 +4,9 @@ Configuration for the engine core.
4
4
 
5
5
  ## Properties
6
6
 
7
- ### debug?
7
+ ### debug? {#debug}
8
8
 
9
- > `optional` **debug**: `boolean`
9
+ > `optional` **debug?**: `boolean`
10
10
 
11
11
  Start the engine in debug mode.
12
12
 
@@ -18,9 +18,9 @@ false
18
18
 
19
19
  ***
20
20
 
21
- ### silent?
21
+ ### silent? {#silent}
22
22
 
23
- > `optional` **silent**: `boolean`
23
+ > `optional` **silent?**: `boolean`
24
24
 
25
25
  Disable output to the console.
26
26
 
@@ -32,7 +32,7 @@ false
32
32
 
33
33
  ***
34
34
 
35
- ### types
35
+ ### types {#types}
36
36
 
37
37
  > **types**: `object`
38
38
 
@@ -14,7 +14,7 @@ The context for the engine core.
14
14
 
15
15
  ## Properties
16
16
 
17
- ### config
17
+ ### config {#config}
18
18
 
19
19
  > **config**: `C`
20
20
 
@@ -22,7 +22,7 @@ The engine core config.
22
22
 
23
23
  ***
24
24
 
25
- ### state
25
+ ### state {#state}
26
26
 
27
27
  > **state**: `S`
28
28
 
@@ -30,7 +30,7 @@ The engine core state.
30
30
 
31
31
  ***
32
32
 
33
- ### stateDirty
33
+ ### stateDirty {#statedirty}
34
34
 
35
35
  > **stateDirty**: `boolean`
36
36
 
@@ -38,7 +38,7 @@ The state dirty flag, which flags that the state needs saving.
38
38
 
39
39
  ***
40
40
 
41
- ### registeredInstances
41
+ ### registeredInstances {#registeredinstances}
42
42
 
43
43
  > **registeredInstances**: `object`
44
44
 
@@ -51,7 +51,7 @@ The default entry will be the first in the list.
51
51
 
52
52
  ***
53
53
 
54
- ### componentInstances
54
+ ### componentInstances {#componentinstances}
55
55
 
56
56
  > **componentInstances**: `object`[]
57
57
 
@@ -10,7 +10,7 @@ Configuration for the engine core type base.
10
10
 
11
11
  ## Properties
12
12
 
13
- ### type
13
+ ### type {#type}
14
14
 
15
15
  > **type**: `string`
16
16
 
@@ -18,8 +18,8 @@ The type of the instance.
18
18
 
19
19
  ***
20
20
 
21
- ### options?
21
+ ### options? {#options}
22
22
 
23
- > `optional` **options**: `T`
23
+ > `optional` **options?**: `T`
24
24
 
25
25
  The options for the instance.
@@ -4,7 +4,7 @@ Configuration for an engine module.
4
4
 
5
5
  ## Properties
6
6
 
7
- ### id
7
+ ### id {#id}
8
8
 
9
9
  > **id**: `string`
10
10
 
@@ -12,7 +12,7 @@ The unique identifier for the module.
12
12
 
13
13
  ***
14
14
 
15
- ### moduleName
15
+ ### moduleName {#modulename}
16
16
 
17
17
  > **moduleName**: `string`
18
18
 
@@ -20,7 +20,7 @@ The module that implements the additional component.
20
20
 
21
21
  ***
22
22
 
23
- ### className
23
+ ### className {#classname}
24
24
 
25
25
  > **className**: `string`
26
26
 
@@ -28,9 +28,9 @@ The class name of the additional component.
28
28
 
29
29
  ***
30
30
 
31
- ### dependencies?
31
+ ### dependencies? {#dependencies}
32
32
 
33
- > `optional` **dependencies**: `object`[]
33
+ > `optional` **dependencies?**: `object`[]
34
34
 
35
35
  Additional dependencies required by the component.
36
36
 
@@ -44,16 +44,16 @@ Additional dependencies required by the component.
44
44
 
45
45
  #### features?
46
46
 
47
- > `optional` **features**: `string`[]
47
+ > `optional` **features?**: `string`[]
48
48
 
49
49
  #### isOptional?
50
50
 
51
- > `optional` **isOptional**: `boolean`
51
+ > `optional` **isOptional?**: `boolean`
52
52
 
53
53
  ***
54
54
 
55
- ### config?
55
+ ### config? {#config}
56
56
 
57
- > `optional` **config**: `unknown`
57
+ > `optional` **config?**: `unknown`
58
58
 
59
59
  Additional configuration for the component.
@@ -4,7 +4,7 @@ Interface describing the engine server methods.
4
4
 
5
5
  ## Methods
6
6
 
7
- ### addRestRouteGenerator()
7
+ ### addRestRouteGenerator() {#addrestroutegenerator}
8
8
 
9
9
  > **addRestRouteGenerator**(`type`, `module`, `method`): `void`
10
10
 
@@ -36,7 +36,7 @@ The method to call on the module.
36
36
 
37
37
  ***
38
38
 
39
- ### addSocketRouteGenerator()
39
+ ### addSocketRouteGenerator() {#addsocketroutegenerator}
40
40
 
41
41
  > **addSocketRouteGenerator**(`type`, `module`, `method`): `void`
42
42
 
@@ -68,7 +68,7 @@ The method to call on the module.
68
68
 
69
69
  ***
70
70
 
71
- ### start()
71
+ ### start() {#start}
72
72
 
73
73
  > **start**(): `Promise`\<`void`\>
74
74
 
@@ -82,7 +82,7 @@ Nothing.
82
82
 
83
83
  ***
84
84
 
85
- ### stop()
85
+ ### stop() {#stop}
86
86
 
87
87
  > **stop**(): `Promise`\<`void`\>
88
88
 
@@ -10,7 +10,7 @@ Definition of state storage for engine.
10
10
 
11
11
  ## Methods
12
12
 
13
- ### load()
13
+ ### load() {#load}
14
14
 
15
15
  > **load**(`engineCore`): `Promise`\<`S` \| `undefined`\>
16
16
 
@@ -32,7 +32,7 @@ The state of the engine or undefined if it doesn't exist.
32
32
 
33
33
  ***
34
34
 
35
- ### save()
35
+ ### save() {#save}
36
36
 
37
37
  > **save**(`engineCore`, `state`): `Promise`\<`void`\>
38
38
 
@@ -1,4 +1,4 @@
1
- # Type Alias: EngineTypeInitialiser()\<T, F\>
1
+ # Type Alias: EngineTypeInitialiser\<T, F\>
2
2
 
3
3
  > **EngineTypeInitialiser**\<`T`, `F`\> = (`engineCore`, `context`, `instanceConfig`) => [`EngineTypeInitialiserReturn`](../interfaces/EngineTypeInitialiserReturn.md)\<`T`, `F`\>
4
4
 
@@ -8,49 +8,49 @@ Configuration for the engine core type.
8
8
 
9
9
  ### overrideInstanceType?
10
10
 
11
- > `optional` **overrideInstanceType**: `string`
11
+ > `optional` **overrideInstanceType?**: `string`
12
12
 
13
13
  The instance type to override with.
14
14
 
15
15
  ### isDefault?
16
16
 
17
- > `optional` **isDefault**: `boolean`
17
+ > `optional` **isDefault?**: `boolean`
18
18
 
19
19
  Whether this is the default instance.
20
20
 
21
21
  ### isMultiInstance?
22
22
 
23
- > `optional` **isMultiInstance**: `boolean`
23
+ > `optional` **isMultiInstance?**: `boolean`
24
24
 
25
25
  Whether this is a multi-instance component.
26
26
 
27
27
  ### features?
28
28
 
29
- > `optional` **features**: `string`[]
29
+ > `optional` **features?**: `string`[]
30
30
 
31
31
  The features supported by this instance.
32
32
 
33
33
  ### restPath?
34
34
 
35
- > `optional` **restPath**: `string`
35
+ > `optional` **restPath?**: `string`
36
36
 
37
37
  The path for the REST API.
38
38
 
39
39
  ### restOptions?
40
40
 
41
- > `optional` **restOptions**: `unknown`
41
+ > `optional` **restOptions?**: `unknown`
42
42
 
43
43
  The options for the REST API route generation.
44
44
 
45
45
  ### socketPath?
46
46
 
47
- > `optional` **socketPath**: `string`
47
+ > `optional` **socketPath?**: `string`
48
48
 
49
49
  The path for the socket API.
50
50
 
51
51
  ### socketOptions?
52
52
 
53
- > `optional` **socketOptions**: `unknown`
53
+ > `optional` **socketOptions?**: `unknown`
54
54
 
55
55
  The options for the socket API route generation.
56
56
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@twin.org/engine-models",
3
- "version": "0.0.3-next.26",
4
- "description": "Models which define the structure of the engine.",
3
+ "version": "0.0.3-next.27",
4
+ "description": "Shared contracts and factory interfaces for composing engine core and server implementations.",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/twinfoundation/engine.git",