@twin.org/engine 0.0.3-next.25 → 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,36 @@
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
18
+
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)
20
+
21
+
22
+ ### Bug Fixes
23
+
24
+ * use custom instance type for entity storage registration ([#90](https://github.com/twinfoundation/engine/issues/90)) ([2c23995](https://github.com/twinfoundation/engine/commit/2c239953dab4510a4cf97063ee90d048210bf4a6))
25
+
26
+
27
+ ### Dependencies
28
+
29
+ * The following workspace dependencies were updated
30
+ * dependencies
31
+ * @twin.org/engine-core bumped from 0.0.3-next.25 to 0.0.3-next.26
32
+ * @twin.org/engine-models bumped from 0.0.3-next.25 to 0.0.3-next.26
33
+ * @twin.org/engine-types bumped from 0.0.3-next.25 to 0.0.3-next.26
2
34
 
3
35
  ## [0.0.3-next.25](https://github.com/twinfoundation/engine/compare/engine-v0.0.3-next.24...engine-v0.0.3-next.25) (2026-03-02)
4
36
 
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
 
@@ -51,3 +51,567 @@ Runtime name for the class.
51
51
  #### Overrides
52
52
 
53
53
  `EngineCore.CLASS_NAME`
54
+
55
+ ***
56
+
57
+ ### LOGGING\_COMPONENT\_TYPE\_NAME {#logging_component_type_name}
58
+
59
+ > `readonly` `static` **LOGGING\_COMPONENT\_TYPE\_NAME**: `string`
60
+
61
+ Name for the engine logger component, used for direct console logging.
62
+
63
+ #### Inherited from
64
+
65
+ `EngineCore.LOGGING_COMPONENT_TYPE_NAME`
66
+
67
+ ***
68
+
69
+ ### LOGGING\_CONNECTOR\_TYPE\_NAME {#logging_connector_type_name}
70
+
71
+ > `readonly` `static` **LOGGING\_CONNECTOR\_TYPE\_NAME**: `string`
72
+
73
+ Name for the engine logger connector, used for direct console logging.
74
+
75
+ #### Inherited from
76
+
77
+ `EngineCore.LOGGING_CONNECTOR_TYPE_NAME`
78
+
79
+ ***
80
+
81
+ ### \_context {#_context}
82
+
83
+ > `protected` **\_context**: `IEngineCoreContext`\<`C`, `S`\>
84
+
85
+ The core context.
86
+
87
+ #### Inherited from
88
+
89
+ `EngineCore._context`
90
+
91
+ ***
92
+
93
+ ### \_contextIdKeys {#_contextidkeys}
94
+
95
+ > `protected` `readonly` **\_contextIdKeys**: `object`[]
96
+
97
+ The context ID keys.
98
+
99
+ #### key
100
+
101
+ > **key**: `string`
102
+
103
+ #### componentFeatures
104
+
105
+ > **componentFeatures**: `string`[]
106
+
107
+ #### Inherited from
108
+
109
+ `EngineCore._contextIdKeys`
110
+
111
+ ***
112
+
113
+ ### \_contextIds? {#_contextids}
114
+
115
+ > `protected` `optional` **\_contextIds?**: `IContextIds`
116
+
117
+ The context IDs.
118
+
119
+ #### Inherited from
120
+
121
+ `EngineCore._contextIds`
122
+
123
+ ## Methods
124
+
125
+ ### addTypeInitialiser() {#addtypeinitialiser}
126
+
127
+ > **addTypeInitialiser**(`type`, `module`, `method`): `void`
128
+
129
+ Add a type initialiser.
130
+
131
+ #### Parameters
132
+
133
+ ##### type
134
+
135
+ `string`
136
+
137
+ The type to add the initialiser for.
138
+
139
+ ##### module
140
+
141
+ `string`
142
+
143
+ The name of the module which contains the initialiser method.
144
+
145
+ ##### method
146
+
147
+ `string`
148
+
149
+ The name of the method to call.
150
+
151
+ #### Returns
152
+
153
+ `void`
154
+
155
+ #### Inherited from
156
+
157
+ `EngineCore.addTypeInitialiser`
158
+
159
+ ***
160
+
161
+ ### getTypeConfig() {#gettypeconfig}
162
+
163
+ > **getTypeConfig**(`type`): `IEngineCoreTypeConfig`[] \| `undefined`
164
+
165
+ Get the type config for a specific type.
166
+
167
+ #### Parameters
168
+
169
+ ##### type
170
+
171
+ `string`
172
+
173
+ The type to get the config for.
174
+
175
+ #### Returns
176
+
177
+ `IEngineCoreTypeConfig`[] \| `undefined`
178
+
179
+ The type config or undefined if not found.
180
+
181
+ #### Inherited from
182
+
183
+ `EngineCore.getTypeConfig`
184
+
185
+ ***
186
+
187
+ ### addContextIdKey() {#addcontextidkey}
188
+
189
+ > **addContextIdKey**(`key`, `componentFeatures`): `void`
190
+
191
+ Add a context ID key to the engine.
192
+
193
+ #### Parameters
194
+
195
+ ##### key
196
+
197
+ `string`
198
+
199
+ The context ID key.
200
+
201
+ ##### componentFeatures
202
+
203
+ `string`[]
204
+
205
+ The component features for the context ID handler.
206
+
207
+ #### Returns
208
+
209
+ `void`
210
+
211
+ #### Inherited from
212
+
213
+ `EngineCore.addContextIdKey`
214
+
215
+ ***
216
+
217
+ ### getContextIdKeys() {#getcontextidkeys}
218
+
219
+ > **getContextIdKeys**(): `string`[]
220
+
221
+ Get the context ID keys for the engine.
222
+
223
+ #### Returns
224
+
225
+ `string`[]
226
+
227
+ The context IDs keys.
228
+
229
+ #### Inherited from
230
+
231
+ `EngineCore.getContextIdKeys`
232
+
233
+ ***
234
+
235
+ ### addContextId() {#addcontextid}
236
+
237
+ > **addContextId**(`key`, `value`): `void`
238
+
239
+ Add a context ID to the engine.
240
+
241
+ #### Parameters
242
+
243
+ ##### key
244
+
245
+ `string`
246
+
247
+ The context ID key.
248
+
249
+ ##### value
250
+
251
+ `string`
252
+
253
+ The context ID value.
254
+
255
+ #### Returns
256
+
257
+ `void`
258
+
259
+ #### Inherited from
260
+
261
+ `EngineCore.addContextId`
262
+
263
+ ***
264
+
265
+ ### getContextIds() {#getcontextids}
266
+
267
+ > **getContextIds**(): `IContextIds` \| `undefined`
268
+
269
+ Get the context IDs for the engine.
270
+
271
+ #### Returns
272
+
273
+ `IContextIds` \| `undefined`
274
+
275
+ The context IDs or undefined if none are set.
276
+
277
+ #### Inherited from
278
+
279
+ `EngineCore.getContextIds`
280
+
281
+ ***
282
+
283
+ ### start() {#start}
284
+
285
+ > **start**(`skipComponentStart?`): `Promise`\<`void`\>
286
+
287
+ Start the engine core.
288
+
289
+ #### Parameters
290
+
291
+ ##### skipComponentStart?
292
+
293
+ `boolean`
294
+
295
+ Should the component start be skipped.
296
+
297
+ #### Returns
298
+
299
+ `Promise`\<`void`\>
300
+
301
+ Nothing.
302
+
303
+ #### Inherited from
304
+
305
+ `EngineCore.start`
306
+
307
+ ***
308
+
309
+ ### stop() {#stop}
310
+
311
+ > **stop**(): `Promise`\<`void`\>
312
+
313
+ Stop the engine core.
314
+
315
+ #### Returns
316
+
317
+ `Promise`\<`void`\>
318
+
319
+ Nothing.
320
+
321
+ #### Inherited from
322
+
323
+ `EngineCore.stop`
324
+
325
+ ***
326
+
327
+ ### isStarted() {#isstarted}
328
+
329
+ > **isStarted**(): `boolean`
330
+
331
+ Is the engine started.
332
+
333
+ #### Returns
334
+
335
+ `boolean`
336
+
337
+ True if the engine is started.
338
+
339
+ #### Inherited from
340
+
341
+ `EngineCore.isStarted`
342
+
343
+ ***
344
+
345
+ ### isPrimary() {#isprimary}
346
+
347
+ > **isPrimary**(): `boolean`
348
+
349
+ Is this the primary engine instance.
350
+
351
+ #### Returns
352
+
353
+ `boolean`
354
+
355
+ True if the engine is the primary instance.
356
+
357
+ #### Inherited from
358
+
359
+ `EngineCore.isPrimary`
360
+
361
+ ***
362
+
363
+ ### isClone() {#isclone}
364
+
365
+ > **isClone**(): `boolean`
366
+
367
+ Is this engine instance a clone.
368
+
369
+ #### Returns
370
+
371
+ `boolean`
372
+
373
+ True if the engine instance is a clone.
374
+
375
+ #### Inherited from
376
+
377
+ `EngineCore.isClone`
378
+
379
+ ***
380
+
381
+ ### logInfo() {#loginfo}
382
+
383
+ > **logInfo**(`message`): `Promise`\<`void`\>
384
+
385
+ Log info.
386
+
387
+ #### Parameters
388
+
389
+ ##### message
390
+
391
+ `string`
392
+
393
+ The message to log.
394
+
395
+ #### Returns
396
+
397
+ `Promise`\<`void`\>
398
+
399
+ #### Inherited from
400
+
401
+ `EngineCore.logInfo`
402
+
403
+ ***
404
+
405
+ ### logError() {#logerror}
406
+
407
+ > **logError**(`error`): `Promise`\<`void`\>
408
+
409
+ Log error.
410
+
411
+ #### Parameters
412
+
413
+ ##### error
414
+
415
+ `IError`
416
+
417
+ The error to log.
418
+
419
+ #### Returns
420
+
421
+ `Promise`\<`void`\>
422
+
423
+ #### Inherited from
424
+
425
+ `EngineCore.logError`
426
+
427
+ ***
428
+
429
+ ### getConfig() {#getconfig}
430
+
431
+ > **getConfig**(): `C`
432
+
433
+ Get the config for the engine.
434
+
435
+ #### Returns
436
+
437
+ `C`
438
+
439
+ The config for the engine.
440
+
441
+ #### Inherited from
442
+
443
+ `EngineCore.getConfig`
444
+
445
+ ***
446
+
447
+ ### getState() {#getstate}
448
+
449
+ > **getState**(): `S`
450
+
451
+ Get the state of the engine.
452
+
453
+ #### Returns
454
+
455
+ `S`
456
+
457
+ The state of the engine.
458
+
459
+ #### Inherited from
460
+
461
+ `EngineCore.getState`
462
+
463
+ ***
464
+
465
+ ### setStateDirty() {#setstatedirty}
466
+
467
+ > **setStateDirty**(): `void`
468
+
469
+ Set the state to dirty so it gets saved.
470
+
471
+ #### Returns
472
+
473
+ `void`
474
+
475
+ #### Inherited from
476
+
477
+ `EngineCore.setStateDirty`
478
+
479
+ ***
480
+
481
+ ### getRegisteredInstances() {#getregisteredinstances}
482
+
483
+ > **getRegisteredInstances**(): `object`
484
+
485
+ Get all the registered instances.
486
+
487
+ #### Returns
488
+
489
+ `object`
490
+
491
+ The registered instances.
492
+
493
+ #### Inherited from
494
+
495
+ `EngineCore.getRegisteredInstances`
496
+
497
+ ***
498
+
499
+ ### getRegisteredInstanceType() {#getregisteredinstancetype}
500
+
501
+ > **getRegisteredInstanceType**(`componentConnectorType`, `features?`): `string`
502
+
503
+ Get the registered instance type for the component/connector.
504
+
505
+ #### Parameters
506
+
507
+ ##### componentConnectorType
508
+
509
+ `string`
510
+
511
+ The type of the component/connector.
512
+
513
+ ##### features?
514
+
515
+ `string`[]
516
+
517
+ The requested features of the component, if not specified the default entry will be retrieved.
518
+
519
+ #### Returns
520
+
521
+ `string`
522
+
523
+ The instance type matching the criteria if one is registered.
524
+
525
+ #### Throws
526
+
527
+ If a matching instance was not found.
528
+
529
+ #### Inherited from
530
+
531
+ `EngineCore.getRegisteredInstanceType`
532
+
533
+ ***
534
+
535
+ ### getRegisteredInstanceTypeOptional() {#getregisteredinstancetypeoptional}
536
+
537
+ > **getRegisteredInstanceTypeOptional**(`componentConnectorType`, `features?`): `string` \| `undefined`
538
+
539
+ Get the registered instance type for the component/connector if it exists.
540
+
541
+ #### Parameters
542
+
543
+ ##### componentConnectorType
544
+
545
+ `string`
546
+
547
+ The type of the component/connector.
548
+
549
+ ##### features?
550
+
551
+ `string`[]
552
+
553
+ The requested features of the component, if not specified the default entry will be retrieved.
554
+
555
+ #### Returns
556
+
557
+ `string` \| `undefined`
558
+
559
+ The instance type matching the criteria if one is registered.
560
+
561
+ #### Inherited from
562
+
563
+ `EngineCore.getRegisteredInstanceTypeOptional`
564
+
565
+ ***
566
+
567
+ ### getCloneData() {#getclonedata}
568
+
569
+ > **getCloneData**(): `IEngineCoreClone`\<`C`, `S`\>
570
+
571
+ Get the data required to create a clone of the engine.
572
+
573
+ #### Returns
574
+
575
+ `IEngineCoreClone`\<`C`, `S`\>
576
+
577
+ The clone data.
578
+
579
+ #### Inherited from
580
+
581
+ `EngineCore.getCloneData`
582
+
583
+ ***
584
+
585
+ ### populateClone() {#populateclone}
586
+
587
+ > **populateClone**(`cloneData`, `contextIds?`, `silent?`): `void`
588
+
589
+ Populate the engine from the clone data.
590
+
591
+ #### Parameters
592
+
593
+ ##### cloneData
594
+
595
+ `IEngineCoreClone`\<`C`, `S`\>
596
+
597
+ The clone data to populate from.
598
+
599
+ ##### contextIds?
600
+
601
+ `IContextIds`
602
+
603
+ The context IDs to use for the clone.
604
+
605
+ ##### silent?
606
+
607
+ `boolean`
608
+
609
+ Should the clone be silent.
610
+
611
+ #### Returns
612
+
613
+ `void`
614
+
615
+ #### Inherited from
616
+
617
+ `EngineCore.populateClone`
@@ -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.25",
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.25",
20
- "@twin.org/engine-models": "0.0.3-next.25",
21
- "@twin.org/engine-types": "0.0.3-next.25",
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
  },