@twin.org/engine-types 0.0.3-next.25 → 0.0.3-next.26

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.
@@ -25,35 +25,38 @@ import { EngineTypeHelper } from "../utils/engineTypeHelper.js";
25
25
  * @param typeCustom Override the type of connector to use instead of default configuration.
26
26
  * @param schema The schema for the entity storage.
27
27
  * @param partitionContextIds The context IDs to use for partitioning the data.
28
- * @returns The name of the instance type that was created.
29
28
  * @throws GeneralError when the configuration is invalid.
30
29
  */
31
30
  export function initialiseEntityStorageConnector(engineCore, context, typeCustom, schema, partitionContextIds) {
32
- const instanceName = StringHelper.kebabCase(schema);
33
- if (!EntityStorageConnectorFactory.hasName(instanceName)) {
34
- let entityStorageConfig;
35
- if (Is.stringValue(typeCustom)) {
36
- // A custom type has been specified, so look it up
37
- entityStorageConfig = context.config.types.entityStorageConnector?.find(c => c.type === typeCustom || c.overrideInstanceType === typeCustom);
38
- if (Is.empty(entityStorageConfig)) {
39
- throw new GeneralError("engineTypes", "entityStorageCustomMissing", {
40
- typeCustom,
41
- storageName: instanceName
42
- });
43
- }
31
+ const kebabName = StringHelper.kebabCase(schema);
32
+ let instanceName = kebabName;
33
+ let entityStorageConfig;
34
+ if (Is.stringValue(typeCustom)) {
35
+ // A custom type has been specified, so look it up
36
+ entityStorageConfig = context.config.types.entityStorageConnector?.find(c => c.type === typeCustom || c.overrideInstanceType === typeCustom);
37
+ if (Is.empty(entityStorageConfig)) {
38
+ throw new GeneralError("engineTypes", "entityStorageCustomMissing", {
39
+ typeCustom,
40
+ storageName: instanceName
41
+ });
44
42
  }
45
- else {
46
- // The default entity storage method is either the one with the isDefault flag set
47
- // or pick the first one if no default is set.
48
- entityStorageConfig =
49
- context.config.types.entityStorageConnector?.find(c => c.isDefault ?? false) ??
50
- context.config.types.entityStorageConnector?.[0];
51
- if (Is.empty(entityStorageConfig)) {
52
- throw new GeneralError("engineTypes", "entityStorageMissing", {
53
- storageName: instanceName
54
- });
55
- }
43
+ // Since we have a custom type we need to use that as the instance name for the
44
+ // connector so that it can be looked up by other components
45
+ instanceName = typeCustom;
46
+ }
47
+ else {
48
+ // The default entity storage method is either the one with the isDefault flag set
49
+ // or pick the first one if no default is set.
50
+ entityStorageConfig =
51
+ context.config.types.entityStorageConnector?.find(c => c.isDefault ?? false) ??
52
+ context.config.types.entityStorageConnector?.[0];
53
+ if (Is.empty(entityStorageConfig)) {
54
+ throw new GeneralError("engineTypes", "entityStorageMissing", {
55
+ storageName: instanceName
56
+ });
56
57
  }
58
+ }
59
+ if (!EntityStorageConnectorFactory.hasName(instanceName)) {
57
60
  const type = entityStorageConfig.type;
58
61
  let entityStorageConnector;
59
62
  engineCore.logInfo(I18n.formatMessage("info.engineTypes.configuringEntityStorage", {
@@ -159,13 +162,13 @@ export function initialiseEntityStorageConnector(engineCore, context, typeCustom
159
162
  // Create the entity storage that is wrapped by the synchronised connector
160
163
  // by removing the custom type it will default to the standard storage
161
164
  // mechanism for entity storage
162
- const wrappedInstanceName = initialiseEntityStorageConnector(engineCore, context, undefined, schema, partitionContextIds);
165
+ initialiseEntityStorageConnector(engineCore, context, undefined, schema, partitionContextIds);
163
166
  // Use the wrapped instance name as the entity storage connector type
164
167
  // for the synchronised connector
165
168
  entityStorageConnector = new SynchronisedEntityStorageConnector({
166
169
  entitySchema: schema,
167
170
  ...entityStorageConfig.options,
168
- entityStorageConnectorType: wrappedInstanceName,
171
+ entityStorageConnectorType: kebabName,
169
172
  eventBusComponentType: engineCore.getRegisteredInstanceType("eventBusComponent"),
170
173
  config: {
171
174
  ...entityStorageConfig.options.config
@@ -185,7 +188,6 @@ export function initialiseEntityStorageConnector(engineCore, context, typeCustom
185
188
  });
186
189
  EntityStorageConnectorFactory.register(instanceName, () => entityStorageConnector);
187
190
  }
188
- return instanceName;
189
191
  }
190
192
  /**
191
193
  * Initialise the entity storage connector.
@@ -1 +1 @@
1
- {"version":3,"file":"entityStorage.js","sourceRoot":"","sources":["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YAAY,CAAC,OAAO,EAAE;gBACtF,iBAAiB,EAAE,SAAS;aAC5B,CAAC,CACF,CAAC;QACH,CAAC,CAAC;QACF,gBAAgB,GAAG,SAAS,CAAC;IAC9B,CAAC;SAAM,IAAI,cAAc,CAAC,IAAI,KAAK,0BAA0B,CAAC,UAAU,EAAE,CAAC;QAC1E,MAAM,SAAS,GAAG,YAAY,CAAC,SAAS,CAAC,cAAc,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;QACnF,eAAe,GAAG,CAAC,YAAmC,EAAE,EAAE,CACzD,IAAI,uBAAuB,CAC1B,gBAAgB,CAAC,WAAW,CAAqC,YAAY,CAAC,OAAO,EAAE;YACtF,UAAU,EAAE,SAAS;SACrB,CAAC,CACF,CAAC;QACH,gBAAgB,GAAG,GAAG,4BAAwC,IAAI,SAAS,EAAE,CAAC;IAC/E,CAAC;IAED,OAAO;QACN,eAAe,EAAE,eAAsE;QACvF,gBAAgB;QAChB,OAAO,EAAE,gBAAgB;KACzB,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport path from \"node:path\";\nimport {\n\tComponentFactory,\n\tGeneralError,\n\tI18n,\n\ttype IComponent,\n\tIs,\n\tStringHelper\n} from \"@twin.org/core\";\nimport type {\n\tEngineTypeInitialiserReturn,\n\tIEngineCore,\n\tIEngineCoreContext\n} from \"@twin.org/engine-models\";\nimport { CosmosDbEntityStorageConnector } from \"@twin.org/entity-storage-connector-cosmosdb\";\nimport { DynamoDbEntityStorageConnector } from \"@twin.org/entity-storage-connector-dynamodb\";\nimport { FileEntityStorageConnector } from \"@twin.org/entity-storage-connector-file\";\nimport { FirestoreEntityStorageConnector } from \"@twin.org/entity-storage-connector-gcp-firestore\";\nimport { MemoryEntityStorageConnector } from \"@twin.org/entity-storage-connector-memory\";\nimport { MongoDbEntityStorageConnector } from \"@twin.org/entity-storage-connector-mongodb\";\nimport { MySqlEntityStorageConnector } from \"@twin.org/entity-storage-connector-mysql\";\nimport { PostgreSqlEntityStorageConnector } from \"@twin.org/entity-storage-connector-postgresql\";\nimport { ScyllaDBTableConnector } from \"@twin.org/entity-storage-connector-scylladb\";\nimport { SynchronisedEntityStorageConnector } from \"@twin.org/entity-storage-connector-synchronised\";\nimport {\n\tEntityStorageConnectorFactory,\n\ttype IEntityStorageConnector\n} from \"@twin.org/entity-storage-models\";\nimport { EntityStorageRestClient } from \"@twin.org/entity-storage-rest-client\";\nimport { EntityStorageService } from \"@twin.org/entity-storage-service\";\nimport { nameofKebabCase } from \"@twin.org/nameof\";\nimport type { EntityStorageComponentConfig } from \"../models/config/entityStorageComponentConfig.js\";\nimport type { IEngineConfig } from \"../models/IEngineConfig.js\";\nimport { EntityStorageComponentType } from \"../models/types/entityStorageComponentType.js\";\nimport { EntityStorageConnectorType } from \"../models/types/entityStorageConnectorType.js\";\nimport { EngineTypeHelper } from \"../utils/engineTypeHelper.js\";\n\n/**\n * Initialise the entity storage connector.\n * @param engineCore The engine core.\n * @param context The context for the engine.\n * @param typeCustom Override the type of connector to use instead of default configuration.\n * @param schema The schema for the entity storage.\n * @param partitionContextIds The context IDs to use for partitioning the data.\n * @returns The name of the instance type that was created.\n * @throws GeneralError when the configuration is invalid.\n */\nexport function initialiseEntityStorageConnector(\n\tengineCore: IEngineCore<IEngineConfig>,\n\tcontext: IEngineCoreContext<IEngineConfig>,\n\ttypeCustom: string | undefined,\n\tschema: string,\n\tpartitionContextIds: string[]\n): string {\n\tconst instanceName = StringHelper.kebabCase(schema);\n\n\tif (!EntityStorageConnectorFactory.hasName(instanceName)) {\n\t\tlet entityStorageConfig;\n\n\t\tif (Is.stringValue(typeCustom)) {\n\t\t\t// A custom type has been specified, so look it up\n\t\t\tentityStorageConfig = context.config.types.entityStorageConnector?.find(\n\t\t\t\tc => c.type === typeCustom || c.overrideInstanceType === typeCustom\n\t\t\t);\n\t\t\tif (Is.empty(entityStorageConfig)) {\n\t\t\t\tthrow new GeneralError(\"engineTypes\", \"entityStorageCustomMissing\", {\n\t\t\t\t\ttypeCustom,\n\t\t\t\t\tstorageName: instanceName\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\t// The default entity storage method is either the one with the isDefault flag set\n\t\t\t// or pick the first one if no default is set.\n\t\t\tentityStorageConfig =\n\t\t\t\tcontext.config.types.entityStorageConnector?.find(c => c.isDefault ?? false) ??\n\t\t\t\tcontext.config.types.entityStorageConnector?.[0];\n\t\t\tif (Is.empty(entityStorageConfig)) {\n\t\t\t\tthrow new GeneralError(\"engineTypes\", \"entityStorageMissing\", {\n\t\t\t\t\tstorageName: instanceName\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tconst type = entityStorageConfig.type;\n\t\tlet entityStorageConnector: IEntityStorageConnector;\n\n\t\tengineCore.logInfo(\n\t\t\tI18n.formatMessage(\"info.engineTypes.configuringEntityStorage\", {\n\t\t\t\telement: \"Entity Storage\",\n\t\t\t\tstorageName: instanceName,\n\t\t\t\tstorageType: type\n\t\t\t})\n\t\t);\n\n\t\tif (type === EntityStorageConnectorType.Memory) {\n\t\t\tentityStorageConnector = new MemoryEntityStorageConnector({\n\t\t\t\tentitySchema: schema,\n\t\t\t\tpartitionContextIds\n\t\t\t});\n\t\t} else if (type === EntityStorageConnectorType.File) {\n\t\t\tentityStorageConnector = new FileEntityStorageConnector({\n\t\t\t\tentitySchema: schema,\n\t\t\t\tpartitionContextIds,\n\t\t\t\t...entityStorageConfig.options,\n\t\t\t\tconfig: {\n\t\t\t\t\t...entityStorageConfig.options.config,\n\t\t\t\t\tdirectory: path.join(\n\t\t\t\t\t\tentityStorageConfig.options.config.directory,\n\t\t\t\t\t\t`${entityStorageConfig.options.folderPrefix ?? \"\"}${instanceName}`\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t});\n\t\t} else if (type === EntityStorageConnectorType.AwsDynamoDb) {\n\t\t\tentityStorageConnector = new DynamoDbEntityStorageConnector({\n\t\t\t\tentitySchema: schema,\n\t\t\t\tpartitionContextIds,\n\t\t\t\t...entityStorageConfig.options,\n\t\t\t\tconfig: {\n\t\t\t\t\t...entityStorageConfig.options.config,\n\t\t\t\t\ttableName: `${entityStorageConfig.options.tablePrefix ?? \"\"}${instanceName}`\n\t\t\t\t}\n\t\t\t});\n\t\t} else if (type === EntityStorageConnectorType.AzureCosmosDb) {\n\t\t\tentityStorageConnector = new CosmosDbEntityStorageConnector({\n\t\t\t\tentitySchema: schema,\n\t\t\t\tpartitionContextIds,\n\t\t\t\t...entityStorageConfig.options,\n\t\t\t\tconfig: {\n\t\t\t\t\t...entityStorageConfig.options.config,\n\t\t\t\t\tcontainerId: `${entityStorageConfig.options.tablePrefix ?? \"\"}${instanceName}`\n\t\t\t\t}\n\t\t\t});\n\t\t} else if (type === EntityStorageConnectorType.GcpFirestoreDb) {\n\t\t\tentityStorageConnector = new FirestoreEntityStorageConnector({\n\t\t\t\tentitySchema: schema,\n\t\t\t\tpartitionContextIds,\n\t\t\t\t...entityStorageConfig.options,\n\t\t\t\tconfig: {\n\t\t\t\t\t...entityStorageConfig.options.config,\n\t\t\t\t\tcollectionName: `${entityStorageConfig.options.tablePrefix ?? \"\"}${instanceName}`\n\t\t\t\t}\n\t\t\t});\n\t\t} else if (type === EntityStorageConnectorType.ScyllaDb) {\n\t\t\tentityStorageConnector = new ScyllaDBTableConnector({\n\t\t\t\tentitySchema: schema,\n\t\t\t\tpartitionContextIds,\n\t\t\t\t...entityStorageConfig.options,\n\t\t\t\tconfig: {\n\t\t\t\t\t...entityStorageConfig.options.config,\n\t\t\t\t\ttableName: `${entityStorageConfig.options.tablePrefix ?? \"\"}${instanceName}`\n\t\t\t\t}\n\t\t\t});\n\t\t} else if (type === EntityStorageConnectorType.MySqlDb) {\n\t\t\tentityStorageConnector = new MySqlEntityStorageConnector({\n\t\t\t\tentitySchema: schema,\n\t\t\t\tpartitionContextIds,\n\t\t\t\t...entityStorageConfig.options,\n\t\t\t\tconfig: {\n\t\t\t\t\t...entityStorageConfig.options.config,\n\t\t\t\t\ttableName: `${entityStorageConfig.options.tablePrefix ?? \"\"}${instanceName}`\n\t\t\t\t}\n\t\t\t});\n\t\t} else if (type === EntityStorageConnectorType.MongoDb) {\n\t\t\tentityStorageConnector = new MongoDbEntityStorageConnector({\n\t\t\t\tentitySchema: schema,\n\t\t\t\tpartitionContextIds,\n\t\t\t\t...entityStorageConfig.options,\n\t\t\t\tconfig: {\n\t\t\t\t\t...entityStorageConfig.options.config,\n\t\t\t\t\tcollection: `${entityStorageConfig.options.tablePrefix ?? \"\"}${instanceName}`\n\t\t\t\t}\n\t\t\t});\n\t\t} else if (type === EntityStorageConnectorType.PostgreSql) {\n\t\t\tentityStorageConnector = new PostgreSqlEntityStorageConnector({\n\t\t\t\tentitySchema: schema,\n\t\t\t\tpartitionContextIds,\n\t\t\t\t...entityStorageConfig.options,\n\t\t\t\tconfig: {\n\t\t\t\t\t...entityStorageConfig.options.config,\n\t\t\t\t\ttableName: `${entityStorageConfig.options.tablePrefix ?? \"\"}${instanceName}`\n\t\t\t\t}\n\t\t\t});\n\t\t} else if (type === EntityStorageConnectorType.Synchronised) {\n\t\t\t// Create the entity storage that is wrapped by the synchronised connector\n\t\t\t// by removing the custom type it will default to the standard storage\n\t\t\t// mechanism for entity storage\n\t\t\tconst wrappedInstanceName = initialiseEntityStorageConnector(\n\t\t\t\tengineCore,\n\t\t\t\tcontext,\n\t\t\t\tundefined,\n\t\t\t\tschema,\n\t\t\t\tpartitionContextIds\n\t\t\t);\n\n\t\t\t// Use the wrapped instance name as the entity storage connector type\n\t\t\t// for the synchronised connector\n\t\t\tentityStorageConnector = new SynchronisedEntityStorageConnector({\n\t\t\t\tentitySchema: schema,\n\t\t\t\t...entityStorageConfig.options,\n\t\t\t\tentityStorageConnectorType: wrappedInstanceName,\n\t\t\t\teventBusComponentType: engineCore.getRegisteredInstanceType(\"eventBusComponent\"),\n\t\t\t\tconfig: {\n\t\t\t\t\t...entityStorageConfig.options.config\n\t\t\t\t}\n\t\t\t});\n\t\t} else {\n\t\t\tthrow new GeneralError(\"engineTypes\", \"connectorUnknownType\", {\n\t\t\t\ttype,\n\t\t\t\tconnectorType: \"entityStorageConnector\"\n\t\t\t});\n\t\t}\n\n\t\tcontext.componentInstances.push({\n\t\t\tinstanceType: instanceName,\n\t\t\tcomponent: entityStorageConnector,\n\t\t\tinitialised: false\n\t\t});\n\t\tEntityStorageConnectorFactory.register(instanceName, () => entityStorageConnector);\n\t}\n\n\treturn instanceName;\n}\n\n/**\n * Initialise the entity storage connector.\n * @param engineCore The engine core.\n * @param context The context for the engine.\n * @param instanceConfig The instance config.\n * @returns The instance created and the factory for it.\n */\nexport function initialiseEntityStorageComponent(\n\tengineCore: IEngineCore<IEngineConfig>,\n\tcontext: IEngineCoreContext<IEngineConfig>,\n\tinstanceConfig: EntityStorageComponentConfig\n): EngineTypeInitialiserReturn<EntityStorageComponentConfig, typeof ComponentFactory> {\n\tlet createComponent;\n\tlet instanceTypeName;\n\n\tif (instanceConfig.type === EntityStorageComponentType.Service) {\n\t\tconst kebabName = StringHelper.kebabCase(instanceConfig.options.entityStorageType);\n\t\tcreateComponent = (createConfig: typeof instanceConfig) => {\n\t\t\t// See if there is a custom entity storage for this type, otherwise just use the default one.\n\t\t\tconst hasCustom = context.config.types.entityStorageConnector?.some(\n\t\t\t\tc => c.type === kebabName || c.overrideInstanceType === kebabName\n\t\t\t);\n\n\t\t\tinitialiseEntityStorageConnector(\n\t\t\t\tengineCore,\n\t\t\t\tcontext,\n\t\t\t\thasCustom ? kebabName : undefined,\n\t\t\t\tcreateConfig.options.entityStorageType,\n\t\t\t\tcreateConfig.options.partitionContextIds\n\t\t\t);\n\n\t\t\treturn new EntityStorageService(\n\t\t\t\tEngineTypeHelper.mergeConfig<(typeof instanceConfig)[\"options\"]>(createConfig.options, {\n\t\t\t\t\tentityStorageType: kebabName\n\t\t\t\t})\n\t\t\t);\n\t\t};\n\t\tinstanceTypeName = kebabName;\n\t} else if (instanceConfig.type === EntityStorageComponentType.RestClient) {\n\t\tconst kebabName = StringHelper.kebabCase(instanceConfig.options.entityStorageType);\n\t\tcreateComponent = (createConfig: typeof instanceConfig) =>\n\t\t\tnew EntityStorageRestClient(\n\t\t\t\tEngineTypeHelper.mergeConfig<(typeof instanceConfig)[\"options\"]>(createConfig.options, {\n\t\t\t\t\tpathPrefix: kebabName\n\t\t\t\t})\n\t\t\t);\n\t\tinstanceTypeName = `${nameofKebabCase(EntityStorageRestClient)}-${kebabName}`;\n\t}\n\n\treturn {\n\t\tcreateComponent: createComponent as (createConfig: typeof instanceConfig) => IComponent,\n\t\tinstanceTypeName,\n\t\tfactory: ComponentFactory\n\t};\n}\n"]}
1
+ {"version":3,"file":"entityStorage.js","sourceRoot":"","sources":["../../../src/components/entityStorage.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EACN,gBAAgB,EAChB,YAAY,EACZ,IAAI,EAEJ,EAAE,EACF,YAAY,EACZ,MAAM,gBAAgB,CAAC;AAMxB,OAAO,EAAE,8BAA8B,EAAE,MAAM,6CAA6C,CAAC;AAC7F,OAAO,EAAE,8BAA8B,EAAE,MAAM,6CAA6C,CAAC;AAC7F,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,+BAA+B,EAAE,MAAM,kDAAkD,CAAC;AACnG,OAAO,EAAE,4BAA4B,EAAE,MAAM,2CAA2C,CAAC;AACzF,OAAO,EAAE,6BAA6B,EAAE,MAAM,4CAA4C,CAAC;AAC3F,OAAO,EAAE,2BAA2B,EAAE,MAAM,0CAA0C,CAAC;AACvF,OAAO,EAAE,gCAAgC,EAAE,MAAM,+CAA+C,CAAC;AACjG,OAAO,EAAE,sBAAsB,EAAE,MAAM,6CAA6C,CAAC;AACrF,OAAO,EAAE,kCAAkC,EAAE,MAAM,iDAAiD,CAAC;AACrG,OAAO,EACN,6BAA6B,EAE7B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nimport {\n\tComponentFactory,\n\tGeneralError,\n\tI18n,\n\ttype IComponent,\n\tIs,\n\tStringHelper\n} from \"@twin.org/core\";\nimport type {\n\tEngineTypeInitialiserReturn,\n\tIEngineCore,\n\tIEngineCoreContext\n} from \"@twin.org/engine-models\";\nimport { CosmosDbEntityStorageConnector } from \"@twin.org/entity-storage-connector-cosmosdb\";\nimport { DynamoDbEntityStorageConnector } from \"@twin.org/entity-storage-connector-dynamodb\";\nimport { FileEntityStorageConnector } from \"@twin.org/entity-storage-connector-file\";\nimport { FirestoreEntityStorageConnector } from \"@twin.org/entity-storage-connector-gcp-firestore\";\nimport { MemoryEntityStorageConnector } from \"@twin.org/entity-storage-connector-memory\";\nimport { MongoDbEntityStorageConnector } from \"@twin.org/entity-storage-connector-mongodb\";\nimport { MySqlEntityStorageConnector } from \"@twin.org/entity-storage-connector-mysql\";\nimport { PostgreSqlEntityStorageConnector } from \"@twin.org/entity-storage-connector-postgresql\";\nimport { ScyllaDBTableConnector } from \"@twin.org/entity-storage-connector-scylladb\";\nimport { SynchronisedEntityStorageConnector } from \"@twin.org/entity-storage-connector-synchronised\";\nimport {\n\tEntityStorageConnectorFactory,\n\ttype IEntityStorageConnector\n} from \"@twin.org/entity-storage-models\";\nimport { EntityStorageRestClient } from \"@twin.org/entity-storage-rest-client\";\nimport { EntityStorageService } from \"@twin.org/entity-storage-service\";\nimport { nameofKebabCase } from \"@twin.org/nameof\";\nimport type { EntityStorageComponentConfig } from \"../models/config/entityStorageComponentConfig.js\";\nimport type { IEngineConfig } from \"../models/IEngineConfig.js\";\nimport { EntityStorageComponentType } from \"../models/types/entityStorageComponentType.js\";\nimport { EntityStorageConnectorType } from \"../models/types/entityStorageConnectorType.js\";\nimport { EngineTypeHelper } from \"../utils/engineTypeHelper.js\";\n\n/**\n * Initialise the entity storage connector.\n * @param engineCore The engine core.\n * @param context The context for the engine.\n * @param typeCustom Override the type of connector to use instead of default configuration.\n * @param schema The schema for the entity storage.\n * @param partitionContextIds The context IDs to use for partitioning the data.\n * @throws GeneralError when the configuration is invalid.\n */\nexport function initialiseEntityStorageConnector(\n\tengineCore: IEngineCore<IEngineConfig>,\n\tcontext: IEngineCoreContext<IEngineConfig>,\n\ttypeCustom: string | undefined,\n\tschema: string,\n\tpartitionContextIds: string[]\n): void {\n\tconst kebabName = StringHelper.kebabCase(schema);\n\tlet instanceName = kebabName;\n\n\tlet entityStorageConfig;\n\n\tif (Is.stringValue(typeCustom)) {\n\t\t// A custom type has been specified, so look it up\n\t\tentityStorageConfig = context.config.types.entityStorageConnector?.find(\n\t\t\tc => c.type === typeCustom || c.overrideInstanceType === typeCustom\n\t\t);\n\t\tif (Is.empty(entityStorageConfig)) {\n\t\t\tthrow new GeneralError(\"engineTypes\", \"entityStorageCustomMissing\", {\n\t\t\t\ttypeCustom,\n\t\t\t\tstorageName: instanceName\n\t\t\t});\n\t\t}\n\n\t\t// Since we have a custom type we need to use that as the instance name for the\n\t\t// connector so that it can be looked up by other components\n\t\tinstanceName = typeCustom;\n\t} else {\n\t\t// The default entity storage method is either the one with the isDefault flag set\n\t\t// or pick the first one if no default is set.\n\t\tentityStorageConfig =\n\t\t\tcontext.config.types.entityStorageConnector?.find(c => c.isDefault ?? false) ??\n\t\t\tcontext.config.types.entityStorageConnector?.[0];\n\t\tif (Is.empty(entityStorageConfig)) {\n\t\t\tthrow new GeneralError(\"engineTypes\", \"entityStorageMissing\", {\n\t\t\t\tstorageName: instanceName\n\t\t\t});\n\t\t}\n\t}\n\n\tif (!EntityStorageConnectorFactory.hasName(instanceName)) {\n\t\tconst type = entityStorageConfig.type;\n\t\tlet entityStorageConnector: IEntityStorageConnector;\n\n\t\tengineCore.logInfo(\n\t\t\tI18n.formatMessage(\"info.engineTypes.configuringEntityStorage\", {\n\t\t\t\telement: \"Entity Storage\",\n\t\t\t\tstorageName: instanceName,\n\t\t\t\tstorageType: type\n\t\t\t})\n\t\t);\n\n\t\tif (type === EntityStorageConnectorType.Memory) {\n\t\t\tentityStorageConnector = new MemoryEntityStorageConnector({\n\t\t\t\tentitySchema: schema,\n\t\t\t\tpartitionContextIds\n\t\t\t});\n\t\t} else if (type === EntityStorageConnectorType.File) {\n\t\t\tentityStorageConnector = new FileEntityStorageConnector({\n\t\t\t\tentitySchema: schema,\n\t\t\t\tpartitionContextIds,\n\t\t\t\t...entityStorageConfig.options,\n\t\t\t\tconfig: {\n\t\t\t\t\t...entityStorageConfig.options.config,\n\t\t\t\t\tdirectory: path.join(\n\t\t\t\t\t\tentityStorageConfig.options.config.directory,\n\t\t\t\t\t\t`${entityStorageConfig.options.folderPrefix ?? \"\"}${instanceName}`\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t});\n\t\t} else if (type === EntityStorageConnectorType.AwsDynamoDb) {\n\t\t\tentityStorageConnector = new DynamoDbEntityStorageConnector({\n\t\t\t\tentitySchema: schema,\n\t\t\t\tpartitionContextIds,\n\t\t\t\t...entityStorageConfig.options,\n\t\t\t\tconfig: {\n\t\t\t\t\t...entityStorageConfig.options.config,\n\t\t\t\t\ttableName: `${entityStorageConfig.options.tablePrefix ?? \"\"}${instanceName}`\n\t\t\t\t}\n\t\t\t});\n\t\t} else if (type === EntityStorageConnectorType.AzureCosmosDb) {\n\t\t\tentityStorageConnector = new CosmosDbEntityStorageConnector({\n\t\t\t\tentitySchema: schema,\n\t\t\t\tpartitionContextIds,\n\t\t\t\t...entityStorageConfig.options,\n\t\t\t\tconfig: {\n\t\t\t\t\t...entityStorageConfig.options.config,\n\t\t\t\t\tcontainerId: `${entityStorageConfig.options.tablePrefix ?? \"\"}${instanceName}`\n\t\t\t\t}\n\t\t\t});\n\t\t} else if (type === EntityStorageConnectorType.GcpFirestoreDb) {\n\t\t\tentityStorageConnector = new FirestoreEntityStorageConnector({\n\t\t\t\tentitySchema: schema,\n\t\t\t\tpartitionContextIds,\n\t\t\t\t...entityStorageConfig.options,\n\t\t\t\tconfig: {\n\t\t\t\t\t...entityStorageConfig.options.config,\n\t\t\t\t\tcollectionName: `${entityStorageConfig.options.tablePrefix ?? \"\"}${instanceName}`\n\t\t\t\t}\n\t\t\t});\n\t\t} else if (type === EntityStorageConnectorType.ScyllaDb) {\n\t\t\tentityStorageConnector = new ScyllaDBTableConnector({\n\t\t\t\tentitySchema: schema,\n\t\t\t\tpartitionContextIds,\n\t\t\t\t...entityStorageConfig.options,\n\t\t\t\tconfig: {\n\t\t\t\t\t...entityStorageConfig.options.config,\n\t\t\t\t\ttableName: `${entityStorageConfig.options.tablePrefix ?? \"\"}${instanceName}`\n\t\t\t\t}\n\t\t\t});\n\t\t} else if (type === EntityStorageConnectorType.MySqlDb) {\n\t\t\tentityStorageConnector = new MySqlEntityStorageConnector({\n\t\t\t\tentitySchema: schema,\n\t\t\t\tpartitionContextIds,\n\t\t\t\t...entityStorageConfig.options,\n\t\t\t\tconfig: {\n\t\t\t\t\t...entityStorageConfig.options.config,\n\t\t\t\t\ttableName: `${entityStorageConfig.options.tablePrefix ?? \"\"}${instanceName}`\n\t\t\t\t}\n\t\t\t});\n\t\t} else if (type === EntityStorageConnectorType.MongoDb) {\n\t\t\tentityStorageConnector = new MongoDbEntityStorageConnector({\n\t\t\t\tentitySchema: schema,\n\t\t\t\tpartitionContextIds,\n\t\t\t\t...entityStorageConfig.options,\n\t\t\t\tconfig: {\n\t\t\t\t\t...entityStorageConfig.options.config,\n\t\t\t\t\tcollection: `${entityStorageConfig.options.tablePrefix ?? \"\"}${instanceName}`\n\t\t\t\t}\n\t\t\t});\n\t\t} else if (type === EntityStorageConnectorType.PostgreSql) {\n\t\t\tentityStorageConnector = new PostgreSqlEntityStorageConnector({\n\t\t\t\tentitySchema: schema,\n\t\t\t\tpartitionContextIds,\n\t\t\t\t...entityStorageConfig.options,\n\t\t\t\tconfig: {\n\t\t\t\t\t...entityStorageConfig.options.config,\n\t\t\t\t\ttableName: `${entityStorageConfig.options.tablePrefix ?? \"\"}${instanceName}`\n\t\t\t\t}\n\t\t\t});\n\t\t} else if (type === EntityStorageConnectorType.Synchronised) {\n\t\t\t// Create the entity storage that is wrapped by the synchronised connector\n\t\t\t// by removing the custom type it will default to the standard storage\n\t\t\t// mechanism for entity storage\n\t\t\tinitialiseEntityStorageConnector(engineCore, context, undefined, schema, partitionContextIds);\n\n\t\t\t// Use the wrapped instance name as the entity storage connector type\n\t\t\t// for the synchronised connector\n\t\t\tentityStorageConnector = new SynchronisedEntityStorageConnector({\n\t\t\t\tentitySchema: schema,\n\t\t\t\t...entityStorageConfig.options,\n\t\t\t\tentityStorageConnectorType: kebabName,\n\t\t\t\teventBusComponentType: engineCore.getRegisteredInstanceType(\"eventBusComponent\"),\n\t\t\t\tconfig: {\n\t\t\t\t\t...entityStorageConfig.options.config\n\t\t\t\t}\n\t\t\t});\n\t\t} else {\n\t\t\tthrow new GeneralError(\"engineTypes\", \"connectorUnknownType\", {\n\t\t\t\ttype,\n\t\t\t\tconnectorType: \"entityStorageConnector\"\n\t\t\t});\n\t\t}\n\n\t\tcontext.componentInstances.push({\n\t\t\tinstanceType: instanceName,\n\t\t\tcomponent: entityStorageConnector,\n\t\t\tinitialised: false\n\t\t});\n\t\tEntityStorageConnectorFactory.register(instanceName, () => entityStorageConnector);\n\t}\n}\n\n/**\n * Initialise the entity storage connector.\n * @param engineCore The engine core.\n * @param context The context for the engine.\n * @param instanceConfig The instance config.\n * @returns The instance created and the factory for it.\n */\nexport function initialiseEntityStorageComponent(\n\tengineCore: IEngineCore<IEngineConfig>,\n\tcontext: IEngineCoreContext<IEngineConfig>,\n\tinstanceConfig: EntityStorageComponentConfig\n): EngineTypeInitialiserReturn<EntityStorageComponentConfig, typeof ComponentFactory> {\n\tlet createComponent;\n\tlet instanceTypeName;\n\n\tif (instanceConfig.type === EntityStorageComponentType.Service) {\n\t\tconst kebabName = StringHelper.kebabCase(instanceConfig.options.entityStorageType);\n\t\tcreateComponent = (createConfig: typeof instanceConfig) => {\n\t\t\t// See if there is a custom entity storage for this type, otherwise just use the default one.\n\t\t\tconst hasCustom = context.config.types.entityStorageConnector?.some(\n\t\t\t\tc => c.type === kebabName || c.overrideInstanceType === kebabName\n\t\t\t);\n\n\t\t\tinitialiseEntityStorageConnector(\n\t\t\t\tengineCore,\n\t\t\t\tcontext,\n\t\t\t\thasCustom ? kebabName : undefined,\n\t\t\t\tcreateConfig.options.entityStorageType,\n\t\t\t\tcreateConfig.options.partitionContextIds\n\t\t\t);\n\n\t\t\treturn new EntityStorageService(\n\t\t\t\tEngineTypeHelper.mergeConfig<(typeof instanceConfig)[\"options\"]>(createConfig.options, {\n\t\t\t\t\tentityStorageType: kebabName\n\t\t\t\t})\n\t\t\t);\n\t\t};\n\t\tinstanceTypeName = kebabName;\n\t} else if (instanceConfig.type === EntityStorageComponentType.RestClient) {\n\t\tconst kebabName = StringHelper.kebabCase(instanceConfig.options.entityStorageType);\n\t\tcreateComponent = (createConfig: typeof instanceConfig) =>\n\t\t\tnew EntityStorageRestClient(\n\t\t\t\tEngineTypeHelper.mergeConfig<(typeof instanceConfig)[\"options\"]>(createConfig.options, {\n\t\t\t\t\tpathPrefix: kebabName\n\t\t\t\t})\n\t\t\t);\n\t\tinstanceTypeName = `${nameofKebabCase(EntityStorageRestClient)}-${kebabName}`;\n\t}\n\n\treturn {\n\t\tcreateComponent: createComponent as (createConfig: typeof instanceConfig) => IComponent,\n\t\tinstanceTypeName,\n\t\tfactory: ComponentFactory\n\t};\n}\n"]}
@@ -20,7 +20,7 @@ export function initialiseFederatedCatalogueComponent(engineCore, context, insta
20
20
  if (instanceConfig.type === FederatedCatalogueComponentType.Service) {
21
21
  createComponent = (createConfig) => {
22
22
  initSchemaFederatedCatalogue();
23
- initialiseEntityStorageConnector(engineCore, context, createConfig.options?.datasetStorageConnectorType, "Dataset", ContextIdHelper.pickKeysFromAvailable(engineCore.getContextIdKeys(), [ContextIdKeys.Node]));
23
+ initialiseEntityStorageConnector(engineCore, context, createConfig.options?.datasetEntityStorageType, "Dataset", ContextIdHelper.pickKeysFromAvailable(engineCore.getContextIdKeys(), [ContextIdKeys.Node]));
24
24
  return new FederatedCatalogueService(EngineTypeHelper.mergeConfig({ loggingComponentType: engineCore.getRegisteredInstanceType("loggingComponent") }, createConfig.options));
25
25
  };
26
26
  instanceTypeName = "federated-catalogue-service";
@@ -1 +1 @@
1
- {"version":3,"file":"federatedCatalogue.js","sourceRoot":"","sources":["../../../src/components/federatedCatalogue.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAOlD,OAAO,EAAE,4BAA4B,EAAE,MAAM,2CAA2C,CAAC;AACzF,OAAO,EAEN,yBAAyB,EACzB,UAAU,IAAI,4BAA4B,EAC1C,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,gCAAgC,EAAE,MAAM,oBAAoB,CAAC;AAGtE,OAAO,EAAE,+BAA+B,EAAE,MAAM,oDAAoD,CAAC;AACrG,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE;;;;;;GAMG;AACH,MAAM,UAAU,qCAAqC,CACpD,UAAsC,EACtC,OAA0C,EAC1C,cAAiD;IAEjD,IAAI,eAAe,CAAC;IACpB,IAAI,gBAAgB,CAAC;IAErB,IAAI,cAAc,CAAC,IAAI,KAAK,+BAA+B,CAAC,OAAO,EAAE,CAAC;QACrE,eAAe,GAAG,CAAC,YAAmC,EAAE,EAAE;YACzD,4BAA4B,EAAE,CAAC;YAC/B,gCAAgC,CAC/B,UAAU,EACV,OAAO,EACP,YAAY,CAAC,OAAO,EAAE,2BAA2B,aAEjD,eAAe,CAAC,qBAAqB,CAAC,UAAU,CAAC,gBAAgB,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAC1F,CAAC;YACF,OAAO,IAAI,yBAAyB,CACnC,gBAAgB,CAAC,WAAW,CAC3B,EAAE,oBAAoB,EAAE,UAAU,CAAC,yBAAyB,CAAC,kBAAkB,CAAC,EAAE,EAClF,YAAY,CAAC,OAAO,CACpB,CACD,CAAC;QACH,CAAC,CAAC;QACF,gBAAgB,gCAA6C,CAAC;IAC/D,CAAC;SAAM,IAAI,cAAc,CAAC,IAAI,KAAK,+BAA+B,CAAC,UAAU,EAAE,CAAC;QAC/E,eAAe,GAAG,CAAC,YAAmC,EAAE,EAAE,CACzD,IAAI,4BAA4B,CAC/B,gBAAgB,CAAC,WAAW,CAAqC,YAAY,CAAC,OAAO,CAAC,CACtF,CAAC;QACH,gBAAgB,oCAAgD,CAAC;IAClE,CAAC;IAED,OAAO;QACN,eAAe,EAAE,eAAsE;QACvF,gBAAgB;QAEhB,OAAO,EAAE,gBAAgB;KACzB,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ContextIdHelper, ContextIdKeys } from \"@twin.org/context\";\nimport { ComponentFactory } from \"@twin.org/core\";\nimport type { IComponent } from \"@twin.org/core\";\nimport type {\n\tEngineTypeInitialiserReturn,\n\tIEngineCore,\n\tIEngineCoreContext\n} from \"@twin.org/engine-models\";\nimport { FederatedCatalogueRestClient } from \"@twin.org/federated-catalogue-rest-client\";\nimport {\n\ttype Dataset,\n\tFederatedCatalogueService,\n\tinitSchema as initSchemaFederatedCatalogue\n} from \"@twin.org/federated-catalogue-service\";\nimport { nameof, nameofKebabCase } from \"@twin.org/nameof\";\nimport { initialiseEntityStorageConnector } from \"./entityStorage.js\";\nimport type { FederatedCatalogueComponentConfig } from \"../models/config/federatedCatalogueComponentConfig.js\";\nimport type { IEngineConfig } from \"../models/IEngineConfig.js\";\nimport { FederatedCatalogueComponentType } from \"../models/types/federatedCatalogueComponentType.js\";\nimport { EngineTypeHelper } from \"../utils/engineTypeHelper.js\";\n\n/**\n * Initialise the federated catalogue component.\n * @param engineCore The engine core.\n * @param context The context for the engine.\n * @param instanceConfig The instance config.\n * @returns The instance created and the factory for it.\n */\nexport function initialiseFederatedCatalogueComponent(\n\tengineCore: IEngineCore<IEngineConfig>,\n\tcontext: IEngineCoreContext<IEngineConfig>,\n\tinstanceConfig: FederatedCatalogueComponentConfig\n): EngineTypeInitialiserReturn<typeof instanceConfig, typeof ComponentFactory> {\n\tlet createComponent;\n\tlet instanceTypeName;\n\n\tif (instanceConfig.type === FederatedCatalogueComponentType.Service) {\n\t\tcreateComponent = (createConfig: typeof instanceConfig) => {\n\t\t\tinitSchemaFederatedCatalogue();\n\t\t\tinitialiseEntityStorageConnector(\n\t\t\t\tengineCore,\n\t\t\t\tcontext,\n\t\t\t\tcreateConfig.options?.datasetStorageConnectorType,\n\t\t\t\tnameof<Dataset>(),\n\t\t\t\tContextIdHelper.pickKeysFromAvailable(engineCore.getContextIdKeys(), [ContextIdKeys.Node])\n\t\t\t);\n\t\t\treturn new FederatedCatalogueService(\n\t\t\t\tEngineTypeHelper.mergeConfig<(typeof instanceConfig)[\"options\"]>(\n\t\t\t\t\t{ loggingComponentType: engineCore.getRegisteredInstanceType(\"loggingComponent\") },\n\t\t\t\t\tcreateConfig.options\n\t\t\t\t)\n\t\t\t);\n\t\t};\n\t\tinstanceTypeName = nameofKebabCase(FederatedCatalogueService);\n\t} else if (instanceConfig.type === FederatedCatalogueComponentType.RestClient) {\n\t\tcreateComponent = (createConfig: typeof instanceConfig) =>\n\t\t\tnew FederatedCatalogueRestClient(\n\t\t\t\tEngineTypeHelper.mergeConfig<(typeof instanceConfig)[\"options\"]>(createConfig.options)\n\t\t\t);\n\t\tinstanceTypeName = nameofKebabCase(FederatedCatalogueRestClient);\n\t}\n\n\treturn {\n\t\tcreateComponent: createComponent as (createConfig: typeof instanceConfig) => IComponent,\n\t\tinstanceTypeName,\n\n\t\tfactory: ComponentFactory\n\t};\n}\n"]}
1
+ {"version":3,"file":"federatedCatalogue.js","sourceRoot":"","sources":["../../../src/components/federatedCatalogue.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC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,CAC/B,gBAAgB,CAAC,WAAW,CAAqC,YAAY,CAAC,OAAO,CAAC,CACtF,CAAC;QACH,gBAAgB,oCAAgD,CAAC;IAClE,CAAC;IAED,OAAO;QACN,eAAe,EAAE,eAAsE;QACvF,gBAAgB;QAEhB,OAAO,EAAE,gBAAgB;KACzB,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ContextIdHelper, ContextIdKeys } from \"@twin.org/context\";\nimport { ComponentFactory } from \"@twin.org/core\";\nimport type { IComponent } from \"@twin.org/core\";\nimport type {\n\tEngineTypeInitialiserReturn,\n\tIEngineCore,\n\tIEngineCoreContext\n} from \"@twin.org/engine-models\";\nimport { FederatedCatalogueRestClient } from \"@twin.org/federated-catalogue-rest-client\";\nimport {\n\ttype Dataset,\n\tFederatedCatalogueService,\n\tinitSchema as initSchemaFederatedCatalogue\n} from \"@twin.org/federated-catalogue-service\";\nimport { nameof, nameofKebabCase } from \"@twin.org/nameof\";\nimport { initialiseEntityStorageConnector } from \"./entityStorage.js\";\nimport type { FederatedCatalogueComponentConfig } from \"../models/config/federatedCatalogueComponentConfig.js\";\nimport type { IEngineConfig } from \"../models/IEngineConfig.js\";\nimport { FederatedCatalogueComponentType } from \"../models/types/federatedCatalogueComponentType.js\";\nimport { EngineTypeHelper } from \"../utils/engineTypeHelper.js\";\n\n/**\n * Initialise the federated catalogue component.\n * @param engineCore The engine core.\n * @param context The context for the engine.\n * @param instanceConfig The instance config.\n * @returns The instance created and the factory for it.\n */\nexport function initialiseFederatedCatalogueComponent(\n\tengineCore: IEngineCore<IEngineConfig>,\n\tcontext: IEngineCoreContext<IEngineConfig>,\n\tinstanceConfig: FederatedCatalogueComponentConfig\n): EngineTypeInitialiserReturn<typeof instanceConfig, typeof ComponentFactory> {\n\tlet createComponent;\n\tlet instanceTypeName;\n\n\tif (instanceConfig.type === FederatedCatalogueComponentType.Service) {\n\t\tcreateComponent = (createConfig: typeof instanceConfig) => {\n\t\t\tinitSchemaFederatedCatalogue();\n\t\t\tinitialiseEntityStorageConnector(\n\t\t\t\tengineCore,\n\t\t\t\tcontext,\n\t\t\t\tcreateConfig.options?.datasetEntityStorageType,\n\t\t\t\tnameof<Dataset>(),\n\t\t\t\tContextIdHelper.pickKeysFromAvailable(engineCore.getContextIdKeys(), [ContextIdKeys.Node])\n\t\t\t);\n\t\t\treturn new FederatedCatalogueService(\n\t\t\t\tEngineTypeHelper.mergeConfig<(typeof instanceConfig)[\"options\"]>(\n\t\t\t\t\t{ loggingComponentType: engineCore.getRegisteredInstanceType(\"loggingComponent\") },\n\t\t\t\t\tcreateConfig.options\n\t\t\t\t)\n\t\t\t);\n\t\t};\n\t\tinstanceTypeName = nameofKebabCase(FederatedCatalogueService);\n\t} else if (instanceConfig.type === FederatedCatalogueComponentType.RestClient) {\n\t\tcreateComponent = (createConfig: typeof instanceConfig) =>\n\t\t\tnew FederatedCatalogueRestClient(\n\t\t\t\tEngineTypeHelper.mergeConfig<(typeof instanceConfig)[\"options\"]>(createConfig.options)\n\t\t\t);\n\t\tinstanceTypeName = nameofKebabCase(FederatedCatalogueRestClient);\n\t}\n\n\treturn {\n\t\tcreateComponent: createComponent as (createConfig: typeof instanceConfig) => IComponent,\n\t\tinstanceTypeName,\n\n\t\tfactory: ComponentFactory\n\t};\n}\n"]}
@@ -9,10 +9,9 @@ import type { IEngineConfig } from "../models/IEngineConfig.js";
9
9
  * @param typeCustom Override the type of connector to use instead of default configuration.
10
10
  * @param schema The schema for the entity storage.
11
11
  * @param partitionContextIds The context IDs to use for partitioning the data.
12
- * @returns The name of the instance type that was created.
13
12
  * @throws GeneralError when the configuration is invalid.
14
13
  */
15
- export declare function initialiseEntityStorageConnector(engineCore: IEngineCore<IEngineConfig>, context: IEngineCoreContext<IEngineConfig>, typeCustom: string | undefined, schema: string, partitionContextIds: string[]): string;
14
+ export declare function initialiseEntityStorageConnector(engineCore: IEngineCore<IEngineConfig>, context: IEngineCoreContext<IEngineConfig>, typeCustom: string | undefined, schema: string, partitionContextIds: string[]): void;
16
15
  /**
17
16
  * Initialise the entity storage connector.
18
17
  * @param engineCore The engine core.
package/docs/changelog.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @twin.org/engine-types - Changelog
2
2
 
3
+ ## [0.0.3-next.26](https://github.com/twinfoundation/engine/compare/engine-types-v0.0.3-next.25...engine-types-v0.0.3-next.26) (2026-03-05)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * use custom instance type for entity storage registration ([#90](https://github.com/twinfoundation/engine/issues/90)) ([2c23995](https://github.com/twinfoundation/engine/commit/2c239953dab4510a4cf97063ee90d048210bf4a6))
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.25 to 0.0.3-next.26
16
+ * @twin.org/engine-models bumped from 0.0.3-next.25 to 0.0.3-next.26
17
+
3
18
  ## [0.0.3-next.25](https://github.com/twinfoundation/engine/compare/engine-types-v0.0.3-next.24...engine-types-v0.0.3-next.25) (2026-03-02)
4
19
 
5
20
 
@@ -24,7 +24,7 @@ Runtime name for the class.
24
24
 
25
25
  ### getConfigOfType()
26
26
 
27
- > `static` **getConfigOfType**\<`T`\>(`engineConfig`, `component`, `type`): `undefined` \| `IEngineCoreTypeConfig`\<`T`\>
27
+ > `static` **getConfigOfType**\<`T`\>(`engineConfig`, `component`, `type`): `IEngineCoreTypeConfig`\<`T`\> \| `undefined`
28
28
 
29
29
  Get the config for the specified component and type.
30
30
 
@@ -56,7 +56,7 @@ The type name.
56
56
 
57
57
  #### Returns
58
58
 
59
- `undefined` \| `IEngineCoreTypeConfig`\<`T`\>
59
+ `IEngineCoreTypeConfig`\<`T`\> \| `undefined`
60
60
 
61
61
  The config for the specified component and type or undefined if it does not exist.
62
62
 
@@ -1,6 +1,6 @@
1
1
  # Function: initialiseEntityStorageConnector()
2
2
 
3
- > **initialiseEntityStorageConnector**(`engineCore`, `context`, `typeCustom`, `schema`, `partitionContextIds`): `string`
3
+ > **initialiseEntityStorageConnector**(`engineCore`, `context`, `typeCustom`, `schema`, `partitionContextIds`): `void`
4
4
 
5
5
  Initialise the entity storage connector.
6
6
 
@@ -22,7 +22,7 @@ The context for the engine.
22
22
 
23
23
  Override the type of connector to use instead of default configuration.
24
24
 
25
- `undefined` | `string`
25
+ `string` | `undefined`
26
26
 
27
27
  ### schema
28
28
 
@@ -38,9 +38,7 @@ The context IDs to use for partitioning the data.
38
38
 
39
39
  ## Returns
40
40
 
41
- `string`
42
-
43
- The name of the instance type that was created.
41
+ `void`
44
42
 
45
43
  ## Throws
46
44
 
@@ -8,6 +8,42 @@ Extended engine core config with known types.
8
8
 
9
9
  ## Properties
10
10
 
11
+ ### debug?
12
+
13
+ > `optional` **debug**: `boolean`
14
+
15
+ Start the engine in debug mode.
16
+
17
+ #### Default
18
+
19
+ ```ts
20
+ false
21
+ ```
22
+
23
+ #### Inherited from
24
+
25
+ `IEngineCoreConfig.debug`
26
+
27
+ ***
28
+
29
+ ### silent?
30
+
31
+ > `optional` **silent**: `boolean`
32
+
33
+ Disable output to the console.
34
+
35
+ #### Default
36
+
37
+ ```ts
38
+ false
39
+ ```
40
+
41
+ #### Inherited from
42
+
43
+ `IEngineCoreConfig.silent`
44
+
45
+ ***
46
+
11
47
  ### types
12
48
 
13
49
  > **types**: `object`
@@ -16,7 +52,7 @@ The types to initialise in the engine.
16
52
 
17
53
  #### Index Signature
18
54
 
19
- \[`type`: `string`\]: `undefined` \| `IEngineCoreTypeConfig`[]
55
+ \[`type`: `string`\]: `IEngineCoreTypeConfig`[] \| `undefined`
20
56
 
21
57
  #### loggingConnector?
22
58
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/engine-types",
3
- "version": "0.0.3-next.25",
3
+ "version": "0.0.3-next.26",
4
4
  "description": "Types to use in an engine.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -56,8 +56,8 @@
56
56
  "@twin.org/document-management-models": "next",
57
57
  "@twin.org/document-management-rest-client": "next",
58
58
  "@twin.org/document-management-service": "next",
59
- "@twin.org/engine-core": "0.0.3-next.25",
60
- "@twin.org/engine-models": "0.0.3-next.25",
59
+ "@twin.org/engine-core": "0.0.3-next.26",
60
+ "@twin.org/engine-models": "0.0.3-next.26",
61
61
  "@twin.org/entity": "next",
62
62
  "@twin.org/entity-storage-connector-cosmosdb": "next",
63
63
  "@twin.org/entity-storage-connector-dynamodb": "next",