@twin.org/engine-core 0.0.1-next.21 → 0.0.1-next.23

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.
@@ -290,19 +290,26 @@ class EngineCore {
290
290
  config: this._context.config,
291
291
  state: this._context.state,
292
292
  typeInitialisers: this._typeInitialisers,
293
- entitySchemas
293
+ entitySchemas,
294
+ loggerTypeName: this._loggerTypeName
294
295
  };
295
296
  return cloneData;
296
297
  }
297
298
  /**
298
299
  * Populate the engine from the clone data.
299
300
  * @param cloneData The clone data to populate from.
301
+ * @param silent Should the clone be silent.
300
302
  */
301
- populateClone(cloneData) {
303
+ populateClone(cloneData, silent) {
302
304
  core.Guards.object(this.CLASS_NAME, "cloneData", cloneData);
303
305
  core.Guards.object(this.CLASS_NAME, "cloneData.config", cloneData.config);
304
306
  core.Guards.object(this.CLASS_NAME, "cloneData.state", cloneData.state);
305
307
  core.Guards.array(this.CLASS_NAME, "cloneData.typeInitialisers", cloneData.typeInitialisers);
308
+ this._loggerTypeName = cloneData.loggerTypeName;
309
+ this._skipBootstrap = true;
310
+ if (silent ?? false) {
311
+ cloneData.config.silent = true;
312
+ }
306
313
  this._context = {
307
314
  config: cloneData.config,
308
315
  defaultTypes: {},
@@ -340,21 +347,22 @@ class EngineCore {
340
347
  * @internal
341
348
  */
342
349
  setupEngineLogger() {
343
- if (!this._context.config.silent) {
344
- const engineLogger = new loggingConnectorConsole.ConsoleLoggingConnector({
350
+ const silent = this._context.config.silent ?? false;
351
+ const engineLogger = silent
352
+ ? new loggingModels.SilentLoggingConnector()
353
+ : new loggingConnectorConsole.ConsoleLoggingConnector({
345
354
  config: {
346
355
  translateMessages: true,
347
356
  hideGroups: true
348
357
  }
349
358
  });
350
- this._context.componentInstances.push({
351
- instanceType: this._loggerTypeName,
352
- component: engineLogger
353
- });
354
- loggingModels.LoggingConnectorFactory.register(this._loggerTypeName, () => engineLogger);
355
- this._engineLoggingConnector = engineLogger;
356
- this._context.defaultTypes.loggingConnector = this._loggerTypeName;
357
- }
359
+ this._context.componentInstances.push({
360
+ instanceType: this._loggerTypeName,
361
+ component: engineLogger
362
+ });
363
+ loggingModels.LoggingConnectorFactory.register(this._loggerTypeName, () => engineLogger);
364
+ this._engineLoggingConnector = engineLogger;
365
+ this._context.defaultTypes.loggingConnector = this._loggerTypeName;
358
366
  }
359
367
  /**
360
368
  * Load the state.
@@ -1,7 +1,7 @@
1
1
  import { I18n, StringHelper, Is, GeneralError, BaseError, ErrorHelper, Guards } from '@twin.org/core';
2
2
  import { EntitySchemaFactory } from '@twin.org/entity';
3
3
  import { ConsoleLoggingConnector } from '@twin.org/logging-connector-console';
4
- import { LoggingConnectorFactory } from '@twin.org/logging-models';
4
+ import { SilentLoggingConnector, LoggingConnectorFactory } from '@twin.org/logging-models';
5
5
  import { ModuleHelper } from '@twin.org/modules';
6
6
  import { readFile, mkdir, writeFile, stat } from 'node:fs/promises';
7
7
  import path from 'node:path';
@@ -288,19 +288,26 @@ class EngineCore {
288
288
  config: this._context.config,
289
289
  state: this._context.state,
290
290
  typeInitialisers: this._typeInitialisers,
291
- entitySchemas
291
+ entitySchemas,
292
+ loggerTypeName: this._loggerTypeName
292
293
  };
293
294
  return cloneData;
294
295
  }
295
296
  /**
296
297
  * Populate the engine from the clone data.
297
298
  * @param cloneData The clone data to populate from.
299
+ * @param silent Should the clone be silent.
298
300
  */
299
- populateClone(cloneData) {
301
+ populateClone(cloneData, silent) {
300
302
  Guards.object(this.CLASS_NAME, "cloneData", cloneData);
301
303
  Guards.object(this.CLASS_NAME, "cloneData.config", cloneData.config);
302
304
  Guards.object(this.CLASS_NAME, "cloneData.state", cloneData.state);
303
305
  Guards.array(this.CLASS_NAME, "cloneData.typeInitialisers", cloneData.typeInitialisers);
306
+ this._loggerTypeName = cloneData.loggerTypeName;
307
+ this._skipBootstrap = true;
308
+ if (silent ?? false) {
309
+ cloneData.config.silent = true;
310
+ }
304
311
  this._context = {
305
312
  config: cloneData.config,
306
313
  defaultTypes: {},
@@ -338,21 +345,22 @@ class EngineCore {
338
345
  * @internal
339
346
  */
340
347
  setupEngineLogger() {
341
- if (!this._context.config.silent) {
342
- const engineLogger = new ConsoleLoggingConnector({
348
+ const silent = this._context.config.silent ?? false;
349
+ const engineLogger = silent
350
+ ? new SilentLoggingConnector()
351
+ : new ConsoleLoggingConnector({
343
352
  config: {
344
353
  translateMessages: true,
345
354
  hideGroups: true
346
355
  }
347
356
  });
348
- this._context.componentInstances.push({
349
- instanceType: this._loggerTypeName,
350
- component: engineLogger
351
- });
352
- LoggingConnectorFactory.register(this._loggerTypeName, () => engineLogger);
353
- this._engineLoggingConnector = engineLogger;
354
- this._context.defaultTypes.loggingConnector = this._loggerTypeName;
355
- }
357
+ this._context.componentInstances.push({
358
+ instanceType: this._loggerTypeName,
359
+ component: engineLogger
360
+ });
361
+ LoggingConnectorFactory.register(this._loggerTypeName, () => engineLogger);
362
+ this._engineLoggingConnector = engineLogger;
363
+ this._context.defaultTypes.loggingConnector = this._loggerTypeName;
356
364
  }
357
365
  /**
358
366
  * Load the state.
@@ -75,6 +75,7 @@ export declare class EngineCore<C extends IEngineCoreConfig = IEngineCoreConfig,
75
75
  /**
76
76
  * Populate the engine from the clone data.
77
77
  * @param cloneData The clone data to populate from.
78
+ * @param silent Should the clone be silent.
78
79
  */
79
- populateClone(cloneData: IEngineCoreClone<C, S>): void;
80
+ populateClone(cloneData: IEngineCoreClone<C, S>, silent?: boolean): void;
80
81
  }
package/docs/changelog.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # @twin.org/engine-core - Changelog
2
2
 
3
- ## v0.0.1-next.21
3
+ ## v0.0.1-next.23
4
4
 
5
5
  - Initial Release
@@ -244,7 +244,7 @@ The clone data.
244
244
 
245
245
  ### populateClone()
246
246
 
247
- > **populateClone**(`cloneData`): `void`
247
+ > **populateClone**(`cloneData`, `silent`?): `void`
248
248
 
249
249
  Populate the engine from the clone data.
250
250
 
@@ -254,6 +254,10 @@ Populate the engine from the clone data.
254
254
 
255
255
  The clone data to populate from.
256
256
 
257
+ • **silent?**: `boolean`
258
+
259
+ Should the clone be silent.
260
+
257
261
  #### Returns
258
262
 
259
263
  `void`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/engine-core",
3
- "version": "0.0.1-next.21",
3
+ "version": "0.0.1-next.23",
4
4
  "description": "Engine 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.21",
46
+ "@twin.org/engine-models": "0.0.1-next.23",
47
47
  "@twin.org/entity": "next",
48
48
  "@twin.org/entity-storage-connector-cosmosdb": "next",
49
49
  "@twin.org/entity-storage-connector-dynamodb": "next",