@twin.org/engine-core 0.0.1-next.4 → 0.0.1-next.5

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.
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ var path = require('node:path');
3
4
  var core = require('@twin.org/core');
4
5
  var engineModels = require('@twin.org/engine-models');
5
6
  var entityStorageConnectorCosmosdb = require('@twin.org/entity-storage-connector-cosmosdb');
@@ -103,7 +104,11 @@ function initialiseEntityStorageConnector(engineCore, context, typeCustom, schem
103
104
  else if (type === engineModels.EntityStorageConnectorType.File) {
104
105
  entityStorageConnector = new entityStorageConnectorFile.FileEntityStorageConnector({
105
106
  entitySchema: schema,
106
- ...entityStorageConfig.options
107
+ ...entityStorageConfig.options,
108
+ config: {
109
+ ...entityStorageConfig.options.config,
110
+ directory: path.join(entityStorageConfig.options.config.directory, instanceName)
111
+ }
107
112
  });
108
113
  }
109
114
  else if (type === engineModels.EntityStorageConnectorType.AwsDynamoDb) {
@@ -1449,7 +1454,7 @@ class EngineCore {
1449
1454
  // First bootstrap the components.
1450
1455
  for (const instance of this._context.componentInstances) {
1451
1456
  if (core.Is.function(instance.component.bootstrap)) {
1452
- const bootstrapName = `component-${instance.component.CLASS_NAME}-${instance.instanceType}`;
1457
+ const bootstrapName = `${instance.component.CLASS_NAME}-${instance.instanceType}`;
1453
1458
  if (!this._context.state.bootstrappedComponents.includes(bootstrapName)) {
1454
1459
  this.logInfo(core.I18n.formatMessage("engineCore.bootstrapping", {
1455
1460
  element: bootstrapName
@@ -1578,7 +1583,7 @@ class FileStateStorage {
1578
1583
  engineCore.logInfo(core.I18n.formatMessage(`${core.StringHelper.camelCase(this.CLASS_NAME)}.saving`, {
1579
1584
  filename: this._filename
1580
1585
  }));
1581
- await promises.writeFile(this._filename, JSON.stringify(state, null, 2), "utf8");
1586
+ await promises.writeFile(this._filename, JSON.stringify(state, undefined, "\t"), "utf8");
1582
1587
  }
1583
1588
  catch (err) {
1584
1589
  throw new core.GeneralError(this.CLASS_NAME, "savingError", { filename: this._filename }, core.BaseError.fromError(err));
@@ -1,3 +1,4 @@
1
+ import path from 'node:path';
1
2
  import { StringHelper, Is, GeneralError, I18n, ComponentFactory, BaseError, ErrorHelper, Guards } from '@twin.org/core';
2
3
  import { EntityStorageConnectorType, EntityStorageComponentType, AttestationConnectorType, AttestationComponentType, AuditableItemGraphComponentType, AuditableItemStreamComponentType, BackgroundTaskConnectorType, BlobStorageConnectorType, BlobStorageComponentType, FaucetConnectorType, IdentityConnectorType, IdentityComponentType, IdentityProfileConnectorType, IdentityProfileComponentType, ImmutableProofComponentType, ImmutableStorageConnectorType, LoggingConnectorType, LoggingComponentType, NftConnectorType, NftComponentType, TelemetryConnectorType, TelemetryComponentType, VaultConnectorType, WalletConnectorType } from '@twin.org/engine-models';
3
4
  import { CosmosDbEntityStorageConnector } from '@twin.org/entity-storage-connector-cosmosdb';
@@ -101,7 +102,11 @@ function initialiseEntityStorageConnector(engineCore, context, typeCustom, schem
101
102
  else if (type === EntityStorageConnectorType.File) {
102
103
  entityStorageConnector = new FileEntityStorageConnector({
103
104
  entitySchema: schema,
104
- ...entityStorageConfig.options
105
+ ...entityStorageConfig.options,
106
+ config: {
107
+ ...entityStorageConfig.options.config,
108
+ directory: path.join(entityStorageConfig.options.config.directory, instanceName)
109
+ }
105
110
  });
106
111
  }
107
112
  else if (type === EntityStorageConnectorType.AwsDynamoDb) {
@@ -1447,7 +1452,7 @@ class EngineCore {
1447
1452
  // First bootstrap the components.
1448
1453
  for (const instance of this._context.componentInstances) {
1449
1454
  if (Is.function(instance.component.bootstrap)) {
1450
- const bootstrapName = `component-${instance.component.CLASS_NAME}-${instance.instanceType}`;
1455
+ const bootstrapName = `${instance.component.CLASS_NAME}-${instance.instanceType}`;
1451
1456
  if (!this._context.state.bootstrappedComponents.includes(bootstrapName)) {
1452
1457
  this.logInfo(I18n.formatMessage("engineCore.bootstrapping", {
1453
1458
  element: bootstrapName
@@ -1576,7 +1581,7 @@ class FileStateStorage {
1576
1581
  engineCore.logInfo(I18n.formatMessage(`${StringHelper.camelCase(this.CLASS_NAME)}.saving`, {
1577
1582
  filename: this._filename
1578
1583
  }));
1579
- await writeFile(this._filename, JSON.stringify(state, null, 2), "utf8");
1584
+ await writeFile(this._filename, JSON.stringify(state, undefined, "\t"), "utf8");
1580
1585
  }
1581
1586
  catch (err) {
1582
1587
  throw new GeneralError(this.CLASS_NAME, "savingError", { filename: this._filename }, BaseError.fromError(err));
package/docs/changelog.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # @twin.org/engine-core - Changelog
2
2
 
3
- ## v0.0.1-next.4
3
+ ## v0.0.1-next.5
4
4
 
5
5
  - Initial Release
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/engine-core",
3
- "version": "0.0.1-next.4",
3
+ "version": "0.0.1-next.5",
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.4",
46
+ "@twin.org/engine-models": "0.0.1-next.5",
47
47
  "@twin.org/entity": "next",
48
48
  "@twin.org/entity-storage-connector-cosmosdb": "next",
49
49
  "@twin.org/entity-storage-connector-dynamodb": "next",