@twin.org/engine 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
2
2
 
3
- Engine implementation.
3
+ Engine provides a ready-to-use runtime that extends the core layer with built-in type initialisers. It helps applications start from a practical baseline while still allowing customisation of configuration and component selection.
4
4
 
5
5
  ## Installation
6
6
 
package/docs/changelog.md CHANGED
@@ -1,4 +1,20 @@
1
- # @twin.org/engine - Changelog
1
+ # Changelog
2
+
3
+ ## [0.0.3-next.27](https://github.com/twinfoundation/engine/compare/engine-v0.0.3-next.26...engine-v0.0.3-next.27) (2026-03-20)
4
+
5
+
6
+ ### Features
7
+
8
+ * update dependencies ([e6ebe42](https://github.com/twinfoundation/engine/commit/e6ebe42b9d61066227ad8b45dae14c8f8615b760))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/engine-core bumped from 0.0.3-next.26 to 0.0.3-next.27
16
+ * @twin.org/engine-models bumped from 0.0.3-next.26 to 0.0.3-next.27
17
+ * @twin.org/engine-types bumped from 0.0.3-next.26 to 0.0.3-next.27
2
18
 
3
19
  ## [0.0.3-next.26](https://github.com/twinfoundation/engine/compare/engine-v0.0.3-next.25...engine-v0.0.3-next.26) (2026-03-05)
4
20
 
package/docs/examples.md CHANGED
@@ -1,35 +1,68 @@
1
- # @twin.org/engine - Examples
1
+ # Engine Examples
2
2
 
3
- ## Environment Variables
3
+ These examples show a practical way to configure and run an instance with built-in type initialisers and custom entity storage.
4
4
 
5
- The engine supports various environment variables for configuration. Here are some key examples:
5
+ ## Engine
6
6
 
7
- ### IOTA DLT Configuration
7
+ ```typescript
8
+ import { Engine } from '@twin.org/engine';
9
+ import type { IEngineConfig } from '@twin.org/engine-types';
8
10
 
9
- Basic IOTA configuration:
11
+ const config: IEngineConfig = {
12
+ debug: true,
13
+ silent: false,
14
+ types: {}
15
+ };
10
16
 
11
- ```bash
12
- # IOTA Node Configuration
13
- IOTA_NODE_ENDPOINT="https://api.devnet.iota.cafe"
14
- IOTA_FAUCET_ENDPOINT="https://faucet.devnet.iota.cafe"
15
- IOTA_EXPLORER_ENDPOINT="https://explorer.iota.org/"
16
- IOTA_NETWORK="devnet"
17
- IOTA_COIN_TYPE="4218"
18
- ```
17
+ const engine = new Engine({ config, skipBootstrap: true });
18
+
19
+ engine.addContextIdKey('tenant', ['tenant']);
20
+ engine.addContextId('tenant', 'tenant-a');
19
21
 
20
- ### IOTA Gas Station Configuration (Optional)
22
+ engine.addTypeInitialiser('loggingConnector', '@twin.org/engine-types', 'initLoggingConnector');
21
23
 
22
- The IOTA Gas Station pattern allows for sponsored transactions and improved UX:
24
+ console.log(engine.getContextIdKeys()); // ["tenant"]
25
+ console.log(engine.getContextIds()); // { tenant: "tenant-a" }
26
+ console.log(engine.isStarted()); // false
23
27
 
24
- ```bash
25
- # Gas Station Configuration
26
- IOTA_GAS_STATION_ENDPOINT="https://gas-station.example.com"
27
- IOTA_GAS_STATION_AUTH_TOKEN="your-auth-token"
28
+ await engine.start(true);
29
+ console.log(engine.isStarted()); // true
30
+
31
+ await engine.stop();
32
+ console.log(engine.isStarted()); // false
28
33
  ```
29
34
 
30
- **Configuration Options:**
35
+ ## EngineConfigHelper
36
+
37
+ ```typescript
38
+ import { EngineConfigHelper } from '@twin.org/engine';
39
+ import type { IEngineConfig } from '@twin.org/engine-types';
40
+ import type { IEntitySchema } from '@twin.org/entity';
31
41
 
32
- - `IOTA_GAS_STATION_ENDPOINT`: The URL of the gas station service
33
- - `IOTA_GAS_STATION_AUTH_TOKEN`: Authentication token for the gas station
42
+ interface Product {
43
+ id: string;
44
+ name: string;
45
+ }
34
46
 
35
- When gas station is configured, all IOTA-related connectors (wallet, nft, verifiable-storage, identity, identity-resolver) will automatically use the centralized configuration and have access to gas station functionality.
47
+ const config: IEngineConfig = {
48
+ debug: false,
49
+ silent: true,
50
+ types: {}
51
+ };
52
+
53
+ const productSchema = {
54
+ type: 'Product',
55
+ properties: {
56
+ id: { type: 'string', isPrimary: true },
57
+ name: { type: 'string' }
58
+ }
59
+ } as IEntitySchema<Product>;
60
+
61
+ EngineConfigHelper.addCustomEntityStorage(config, 'product', productSchema, '/products', [
62
+ 'node',
63
+ 'tenant'
64
+ ]);
65
+
66
+ console.log(config.types.entityStorageComponent?.length ?? 0); // 1
67
+ console.log(config.types.entityStorageComponent?.[0].restPath); // "/products"
68
+ ```
@@ -42,7 +42,7 @@ The options for the engine.
42
42
 
43
43
  ## Properties
44
44
 
45
- ### CLASS\_NAME
45
+ ### CLASS\_NAME {#class_name}
46
46
 
47
47
  > `readonly` `static` **CLASS\_NAME**: `string`
48
48
 
@@ -54,7 +54,7 @@ Runtime name for the class.
54
54
 
55
55
  ***
56
56
 
57
- ### LOGGING\_COMPONENT\_TYPE\_NAME
57
+ ### LOGGING\_COMPONENT\_TYPE\_NAME {#logging_component_type_name}
58
58
 
59
59
  > `readonly` `static` **LOGGING\_COMPONENT\_TYPE\_NAME**: `string`
60
60
 
@@ -66,7 +66,7 @@ Name for the engine logger component, used for direct console logging.
66
66
 
67
67
  ***
68
68
 
69
- ### LOGGING\_CONNECTOR\_TYPE\_NAME
69
+ ### LOGGING\_CONNECTOR\_TYPE\_NAME {#logging_connector_type_name}
70
70
 
71
71
  > `readonly` `static` **LOGGING\_CONNECTOR\_TYPE\_NAME**: `string`
72
72
 
@@ -78,7 +78,7 @@ Name for the engine logger connector, used for direct console logging.
78
78
 
79
79
  ***
80
80
 
81
- ### \_context
81
+ ### \_context {#_context}
82
82
 
83
83
  > `protected` **\_context**: `IEngineCoreContext`\<`C`, `S`\>
84
84
 
@@ -90,7 +90,7 @@ The core context.
90
90
 
91
91
  ***
92
92
 
93
- ### \_contextIdKeys
93
+ ### \_contextIdKeys {#_contextidkeys}
94
94
 
95
95
  > `protected` `readonly` **\_contextIdKeys**: `object`[]
96
96
 
@@ -110,9 +110,9 @@ The context ID keys.
110
110
 
111
111
  ***
112
112
 
113
- ### \_contextIds?
113
+ ### \_contextIds? {#_contextids}
114
114
 
115
- > `protected` `optional` **\_contextIds**: `IContextIds`
115
+ > `protected` `optional` **\_contextIds?**: `IContextIds`
116
116
 
117
117
  The context IDs.
118
118
 
@@ -122,7 +122,7 @@ The context IDs.
122
122
 
123
123
  ## Methods
124
124
 
125
- ### addTypeInitialiser()
125
+ ### addTypeInitialiser() {#addtypeinitialiser}
126
126
 
127
127
  > **addTypeInitialiser**(`type`, `module`, `method`): `void`
128
128
 
@@ -158,7 +158,7 @@ The name of the method to call.
158
158
 
159
159
  ***
160
160
 
161
- ### getTypeConfig()
161
+ ### getTypeConfig() {#gettypeconfig}
162
162
 
163
163
  > **getTypeConfig**(`type`): `IEngineCoreTypeConfig`[] \| `undefined`
164
164
 
@@ -184,7 +184,7 @@ The type config or undefined if not found.
184
184
 
185
185
  ***
186
186
 
187
- ### addContextIdKey()
187
+ ### addContextIdKey() {#addcontextidkey}
188
188
 
189
189
  > **addContextIdKey**(`key`, `componentFeatures`): `void`
190
190
 
@@ -214,7 +214,7 @@ The component features for the context ID handler.
214
214
 
215
215
  ***
216
216
 
217
- ### getContextIdKeys()
217
+ ### getContextIdKeys() {#getcontextidkeys}
218
218
 
219
219
  > **getContextIdKeys**(): `string`[]
220
220
 
@@ -232,7 +232,7 @@ The context IDs keys.
232
232
 
233
233
  ***
234
234
 
235
- ### addContextId()
235
+ ### addContextId() {#addcontextid}
236
236
 
237
237
  > **addContextId**(`key`, `value`): `void`
238
238
 
@@ -262,7 +262,7 @@ The context ID value.
262
262
 
263
263
  ***
264
264
 
265
- ### getContextIds()
265
+ ### getContextIds() {#getcontextids}
266
266
 
267
267
  > **getContextIds**(): `IContextIds` \| `undefined`
268
268
 
@@ -280,7 +280,7 @@ The context IDs or undefined if none are set.
280
280
 
281
281
  ***
282
282
 
283
- ### start()
283
+ ### start() {#start}
284
284
 
285
285
  > **start**(`skipComponentStart?`): `Promise`\<`void`\>
286
286
 
@@ -306,7 +306,7 @@ Nothing.
306
306
 
307
307
  ***
308
308
 
309
- ### stop()
309
+ ### stop() {#stop}
310
310
 
311
311
  > **stop**(): `Promise`\<`void`\>
312
312
 
@@ -324,7 +324,7 @@ Nothing.
324
324
 
325
325
  ***
326
326
 
327
- ### isStarted()
327
+ ### isStarted() {#isstarted}
328
328
 
329
329
  > **isStarted**(): `boolean`
330
330
 
@@ -342,7 +342,7 @@ True if the engine is started.
342
342
 
343
343
  ***
344
344
 
345
- ### isPrimary()
345
+ ### isPrimary() {#isprimary}
346
346
 
347
347
  > **isPrimary**(): `boolean`
348
348
 
@@ -360,7 +360,7 @@ True if the engine is the primary instance.
360
360
 
361
361
  ***
362
362
 
363
- ### isClone()
363
+ ### isClone() {#isclone}
364
364
 
365
365
  > **isClone**(): `boolean`
366
366
 
@@ -378,7 +378,7 @@ True if the engine instance is a clone.
378
378
 
379
379
  ***
380
380
 
381
- ### logInfo()
381
+ ### logInfo() {#loginfo}
382
382
 
383
383
  > **logInfo**(`message`): `Promise`\<`void`\>
384
384
 
@@ -402,7 +402,7 @@ The message to log.
402
402
 
403
403
  ***
404
404
 
405
- ### logError()
405
+ ### logError() {#logerror}
406
406
 
407
407
  > **logError**(`error`): `Promise`\<`void`\>
408
408
 
@@ -426,7 +426,7 @@ The error to log.
426
426
 
427
427
  ***
428
428
 
429
- ### getConfig()
429
+ ### getConfig() {#getconfig}
430
430
 
431
431
  > **getConfig**(): `C`
432
432
 
@@ -444,7 +444,7 @@ The config for the engine.
444
444
 
445
445
  ***
446
446
 
447
- ### getState()
447
+ ### getState() {#getstate}
448
448
 
449
449
  > **getState**(): `S`
450
450
 
@@ -462,7 +462,7 @@ The state of the engine.
462
462
 
463
463
  ***
464
464
 
465
- ### setStateDirty()
465
+ ### setStateDirty() {#setstatedirty}
466
466
 
467
467
  > **setStateDirty**(): `void`
468
468
 
@@ -478,7 +478,7 @@ Set the state to dirty so it gets saved.
478
478
 
479
479
  ***
480
480
 
481
- ### getRegisteredInstances()
481
+ ### getRegisteredInstances() {#getregisteredinstances}
482
482
 
483
483
  > **getRegisteredInstances**(): `object`
484
484
 
@@ -496,7 +496,7 @@ The registered instances.
496
496
 
497
497
  ***
498
498
 
499
- ### getRegisteredInstanceType()
499
+ ### getRegisteredInstanceType() {#getregisteredinstancetype}
500
500
 
501
501
  > **getRegisteredInstanceType**(`componentConnectorType`, `features?`): `string`
502
502
 
@@ -532,7 +532,7 @@ If a matching instance was not found.
532
532
 
533
533
  ***
534
534
 
535
- ### getRegisteredInstanceTypeOptional()
535
+ ### getRegisteredInstanceTypeOptional() {#getregisteredinstancetypeoptional}
536
536
 
537
537
  > **getRegisteredInstanceTypeOptional**(`componentConnectorType`, `features?`): `string` \| `undefined`
538
538
 
@@ -564,7 +564,7 @@ The instance type matching the criteria if one is registered.
564
564
 
565
565
  ***
566
566
 
567
- ### getCloneData()
567
+ ### getCloneData() {#getclonedata}
568
568
 
569
569
  > **getCloneData**(): `IEngineCoreClone`\<`C`, `S`\>
570
570
 
@@ -582,7 +582,7 @@ The clone data.
582
582
 
583
583
  ***
584
584
 
585
- ### populateClone()
585
+ ### populateClone() {#populateclone}
586
586
 
587
587
  > **populateClone**(`cloneData`, `contextIds?`, `silent?`): `void`
588
588
 
@@ -14,7 +14,7 @@ Helper methods for engine config.
14
14
 
15
15
  ## Properties
16
16
 
17
- ### CLASS\_NAME
17
+ ### CLASS\_NAME {#class_name}
18
18
 
19
19
  > `readonly` `static` **CLASS\_NAME**: `string`
20
20
 
@@ -22,7 +22,7 @@ Runtime name for the class.
22
22
 
23
23
  ## Methods
24
24
 
25
- ### addCustomEntityStorage()
25
+ ### addCustomEntityStorage() {#addcustomentitystorage}
26
26
 
27
27
  > `static` **addCustomEntityStorage**\<`T`\>(`engineConfig`, `entityTypeName`, `entitySchema`, `restPath?`, `partitionContextIds?`): `void`
28
28
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@twin.org/engine",
3
- "version": "0.0.3-next.26",
4
- "description": "Engine implementation.",
3
+ "version": "0.0.3-next.27",
4
+ "description": "Ready-to-use engine runtime that preloads built-in type initialisers.",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/twinfoundation/engine.git",
@@ -16,9 +16,9 @@
16
16
  "dependencies": {
17
17
  "@twin.org/context": "next",
18
18
  "@twin.org/core": "next",
19
- "@twin.org/engine-core": "0.0.3-next.26",
20
- "@twin.org/engine-models": "0.0.3-next.26",
21
- "@twin.org/engine-types": "0.0.3-next.26",
19
+ "@twin.org/engine-core": "0.0.3-next.27",
20
+ "@twin.org/engine-models": "0.0.3-next.27",
21
+ "@twin.org/engine-types": "0.0.3-next.27",
22
22
  "@twin.org/entity": "next",
23
23
  "@twin.org/nameof": "next"
24
24
  },