@twin.org/engine-core 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 +1 -1
- package/dist/es/engineCore.js.map +1 -1
- package/dist/es/storage/fileStateStorage.js.map +1 -1
- package/dist/es/storage/memoryStateStorage.js.map +1 -1
- package/docs/changelog.md +29 -1
- package/docs/examples.md +156 -1
- package/docs/reference/classes/EngineCore.md +34 -34
- package/docs/reference/classes/EngineModuleHelper.md +2 -2
- package/docs/reference/classes/FileStateStorage.md +7 -7
- package/docs/reference/classes/MemoryStateStorage.md +7 -7
- package/docs/reference/interfaces/IEngineCoreOptions.md +10 -10
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# TWIN Engine Core
|
|
2
2
|
|
|
3
|
-
Engine
|
|
3
|
+
Engine Core provides the runtime lifecycle and orchestration layer for engine instances. It manages component initialisation, context handling, state persistence, and cloning workflows that higher-level packages rely on.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engineCore.js","sourceRoot":"","sources":["../../src/engineCore.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EACN,uBAAuB,EACvB,cAAc,EAGd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACN,SAAS,EACT,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,MAAM,EACN,IAAI,EAEJ,EAAE,EACF,MAAM,gBAAgB,CAAC;AAWxB,OAAO,EAAE,mBAAmB,EAAsB,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,EAEN,uBAAuB,EACvB,sBAAsB,EACtB,MAAM,0BAA0B,CAAC;AAClC,O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AC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;YACvD,CAAC;YAED,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,YAA6B,oBAAoB,CAAC,CAAC,CAAC;QAC9F,CAAC;IACF,CAAC;IAED;;;OAGG;IACK,2BAA2B;QAClC,KAAK,MAAM,YAAY,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YAChD,MAAM,WAAW,GAAuB,IAAI,CAAC,iCAAiC,CAC7E,2BAA2B,EAC3B,YAAY,CAAC,iBAAiB,CAC9B,CAAC;YACF,IAAI,EAAE,CAAC,WAAW,CAAC,WAAW,CAAC,EAAE,CAAC;gBACjC,MAAM,OAAO,GAAG,gBAAgB,CAAC,GAAG,CAAoB,WAAW,CAAC,CAAC;gBACrE,uBAAuB,CAAC,QAAQ,CAAC,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC;YACnE,CAAC;QACF,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { isMainThread } from \"node:worker_threads\";\nimport {\n\tContextIdHandlerFactory,\n\tContextIdStore,\n\ttype IContextIdHandler,\n\ttype IContextIds\n} from \"@twin.org/context\";\nimport {\n\tBaseError,\n\tComponentFactory,\n\tErrorHelper,\n\tGeneralError,\n\tGuards,\n\tI18n,\n\ttype IError,\n\tIs\n} from \"@twin.org/core\";\nimport type {\n\tEngineTypeInitialiser,\n\tIEngineCore,\n\tIEngineCoreClone,\n\tIEngineCoreConfig,\n\tIEngineCoreContext,\n\tIEngineCoreTypeConfig,\n\tIEngineState,\n\tIEngineStateStorage\n} from \"@twin.org/engine-models\";\nimport { EntitySchemaFactory, type IEntitySchema } from \"@twin.org/entity\";\nimport { ConsoleLoggingConnector } from \"@twin.org/logging-connector-console\";\nimport {\n\ttype ILoggingComponent,\n\tLoggingConnectorFactory,\n\tSilentLoggingConnector\n} from \"@twin.org/logging-models\";\nimport { LoggingService } from \"@twin.org/logging-service\";\nimport { ModuleHelper } from \"@twin.org/modules\";\nimport { nameof, nameofCamelCase } from \"@twin.org/nameof\";\nimport type { IEngineCoreOptions } from \"./models/IEngineCoreOptions.js\";\nimport { MemoryStateStorage } from \"./storage/memoryStateStorage.js\";\n\n/**\n * Core for the engine.\n */\nexport class EngineCore<\n\tC extends IEngineCoreConfig = IEngineCoreConfig,\n\tS extends IEngineState = IEngineState\n> implements IEngineCore<C, S>\n{\n\t/**\n\t * Name for the engine logger component, used for direct console logging.\n\t */\n\tpublic static readonly LOGGING_COMPONENT_TYPE_NAME: string = \"engine-logging-service\";\n\n\t/**\n\t * Name for the engine logger connector, used for direct console logging.\n\t */\n\tpublic static readonly LOGGING_CONNECTOR_TYPE_NAME: string = \"engine-logging-connector\";\n\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<EngineCore>();\n\n\t/**\n\t * The core context.\n\t */\n\tprotected _context: IEngineCoreContext<C, S>;\n\n\t/**\n\t * The context ID keys.\n\t */\n\tprotected readonly _contextIdKeys: { key: string; componentFeatures: string[] }[];\n\n\t/**\n\t * The context IDs.\n\t */\n\tprotected _contextIds?: IContextIds;\n\n\t/**\n\t * The state storage interface.\n\t * @internal\n\t */\n\tprivate _stateStorage?: IEngineStateStorage<S>;\n\n\t/**\n\t * The logging component for the engine.\n\t * @internal\n\t */\n\tprivate _engineLoggingComponent?: ILoggingComponent;\n\n\t/**\n\t * Skip the bootstrap process.\n\t * @internal\n\t */\n\tprivate _skipBootstrap?: boolean;\n\n\t/**\n\t * The type initialisers.\n\t * @internal\n\t */\n\tprivate _typeInitialisers: {\n\t\ttype: string;\n\t\tmodule: string;\n\t\tmethod: string;\n\t}[];\n\n\t/**\n\t * Is the engine started.\n\t * @internal\n\t */\n\tprivate _isStarted: boolean;\n\n\t/**\n\t * Is the engine a clone.\n\t * @internal\n\t */\n\tprivate _isClone: boolean;\n\n\t/**\n\t * Add type initialisers to the engine.\n\t * @internal\n\t */\n\tprivate readonly _populateTypeInitialisers?: (\n\t\tengineCore: IEngineCore<C, S>,\n\t\tcontext: IEngineCoreContext<C, S>\n\t) => void;\n\n\t/**\n\t * Method for bootstrapping any data for the engine.\n\t * @internal\n\t */\n\tprivate readonly _customBootstrap?: (\n\t\tengineCore: IEngineCore<C, S>,\n\t\tcontext: IEngineCoreContext<C, S>\n\t) => Promise<void>;\n\n\t/**\n\t * Create a new instance of EngineCore.\n\t * @param options The options for the engine.\n\t */\n\tconstructor(options?: IEngineCoreOptions<C, S>) {\n\t\toptions = options ?? {};\n\t\toptions.config = options.config ?? ({} as C);\n\t\toptions.config.debug = options.config.debug ?? false;\n\t\toptions.config.silent = options.config.silent ?? false;\n\t\toptions.config.types ??= {};\n\n\t\tthis._skipBootstrap = options.skipBootstrap ?? false;\n\t\tthis._populateTypeInitialisers = options.populateTypeInitialisers;\n\t\tthis._customBootstrap = options.customBootstrap;\n\t\tthis._typeInitialisers = [];\n\t\tthis._contextIdKeys = [];\n\n\t\tthis._context = {\n\t\t\tconfig: options.config,\n\t\t\tregisteredInstances: {},\n\t\t\tcomponentInstances: [],\n\t\t\tstate: {} as S,\n\t\t\tstateDirty: false\n\t\t};\n\t\tthis._stateStorage = options.stateStorage;\n\t\tthis._isStarted = false;\n\t\tthis._isClone = false;\n\n\t\tif (Is.function(this._populateTypeInitialisers)) {\n\t\t\tthis._populateTypeInitialisers(this, this._context);\n\t\t}\n\t}\n\n\t/**\n\t * Add a type initialiser.\n\t * @param type The type to add the initialiser for.\n\t * @param module The name of the module which contains the initialiser method.\n\t * @param method The name of the method to call.\n\t */\n\tpublic addTypeInitialiser(type: string, module: string, method: string): void {\n\t\tGuards.stringValue(EngineCore.CLASS_NAME, nameof(type), type);\n\t\tGuards.stringValue(EngineCore.CLASS_NAME, nameof(module), module);\n\t\tGuards.stringValue(EngineCore.CLASS_NAME, nameof(method), method);\n\n\t\tconst currentIndex = this._typeInitialisers.findIndex(t => t.type === type);\n\t\tif (currentIndex >= 0) {\n\t\t\tthis._typeInitialisers[currentIndex].module = module;\n\t\t\tthis._typeInitialisers[currentIndex].method = method;\n\t\t} else {\n\t\t\tthis._typeInitialisers.push({\n\t\t\t\ttype,\n\t\t\t\tmodule,\n\t\t\t\tmethod\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Get the type config for a specific type.\n\t * @param type The type to get the config for.\n\t * @returns The type config or undefined if not found.\n\t */\n\tpublic getTypeConfig(type: string): IEngineCoreTypeConfig[] | undefined {\n\t\tGuards.stringValue(EngineCore.CLASS_NAME, nameof(type), type);\n\t\treturn this._context.config.types?.[type];\n\t}\n\n\t/**\n\t * Add a context ID key to the engine.\n\t * @param key The context ID key.\n\t * @param componentFeatures The component features for the context ID handler.\n\t */\n\tpublic addContextIdKey(key: string, componentFeatures: string[]): void {\n\t\tconst exists = this._contextIdKeys.find(k => k.key === key);\n\t\tif (Is.empty(exists)) {\n\t\t\tthis._contextIdKeys.push({ key, componentFeatures });\n\t\t}\n\t}\n\n\t/**\n\t * Get the context ID keys for the engine.\n\t * @returns The context IDs keys.\n\t */\n\tpublic getContextIdKeys(): string[] {\n\t\treturn this._contextIdKeys.map(k => k.key);\n\t}\n\n\t/**\n\t * Add a context ID to the engine.\n\t * @param key The context ID key.\n\t * @param value The context ID value.\n\t */\n\tpublic addContextId(key: string, value: string): void {\n\t\tthis._contextIds ??= {};\n\t\tthis._contextIds[key] = value;\n\t}\n\n\t/**\n\t * Get the context IDs for the engine.\n\t * @returns The context IDs or undefined if none are set.\n\t */\n\tpublic getContextIds(): IContextIds | undefined {\n\t\treturn this._contextIds;\n\t}\n\n\t/**\n\t * Start the engine core.\n\t * @param skipComponentStart Should the component start be skipped.\n\t * @returns Nothing.\n\t */\n\tpublic async start(skipComponentStart?: boolean): Promise<void> {\n\t\tif (!this._isStarted) {\n\t\t\tthis.setupEngineLogger();\n\t\t\tawait this.logInfo(I18n.formatMessage(`${nameofCamelCase<EngineCore>()}.starting`));\n\n\t\t\tif (this._context.config.debug) {\n\t\t\t\tawait this.logInfo(I18n.formatMessage(`${nameofCamelCase<EngineCore>()}.debuggingEnabled`));\n\t\t\t}\n\n\t\t\tconst skipComponent = skipComponentStart ?? false;\n\t\t\ttry {\n\t\t\t\tawait this.stateLoad();\n\n\t\t\t\tfor (const { type, module, method } of this._typeInitialisers) {\n\t\t\t\t\tawait this.initialiseTypeConfig(type, module, method);\n\t\t\t\t}\n\n\t\t\t\tthis.initialiseContextIdHandlers();\n\n\t\t\t\tawait this.bootstrap();\n\n\t\t\t\tthis._isStarted = true;\n\n\t\t\t\tif (!skipComponent) {\n\t\t\t\t\tawait this.logInfo(\n\t\t\t\t\t\tI18n.formatMessage(`${nameofCamelCase<EngineCore>()}.componentsStarting`)\n\t\t\t\t\t);\n\n\t\t\t\t\tawait ContextIdStore.run(this._contextIds ?? {}, async () => {\n\t\t\t\t\t\tfor (const instance of this._context.componentInstances) {\n\t\t\t\t\t\t\tif (!instance.initialised) {\n\t\t\t\t\t\t\t\tinstance.initialised = true;\n\n\t\t\t\t\t\t\t\tconst startMethod = instance.component.start?.bind(instance.component);\n\t\t\t\t\t\t\t\tif (Is.function(startMethod)) {\n\t\t\t\t\t\t\t\t\tawait this.logInfo(\n\t\t\t\t\t\t\t\t\t\tI18n.formatMessage(`${nameofCamelCase<EngineCore>()}.componentStarting`, {\n\t\t\t\t\t\t\t\t\t\t\tclassName: instance.component.className(),\n\t\t\t\t\t\t\t\t\t\t\tinstanceType: instance.instanceType\n\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\t\tawait startMethod(EngineCore.LOGGING_COMPONENT_TYPE_NAME);\n\t\t\t\t\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\t\t\t\t\tawait this.logError(\n\t\t\t\t\t\t\t\t\t\t\tnew GeneralError(\n\t\t\t\t\t\t\t\t\t\t\t\tEngineCore.CLASS_NAME,\n\t\t\t\t\t\t\t\t\t\t\t\t\"componentStartFailed\",\n\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\tclassName: instance.component.className(),\n\t\t\t\t\t\t\t\t\t\t\t\t\tinstanceType: instance.instanceType\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\tBaseError.fromError(err)\n\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\t\t\tthrow err;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\t\tawait this.logInfo(\n\t\t\t\t\t\tI18n.formatMessage(`${nameofCamelCase<EngineCore>()}.componentsComplete`)\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\t// If we are skipping component start then just mark them as initialised\n\t\t\t\t\t// we still need to be able to call stop on them to clean up\n\t\t\t\t\tfor (const instance of this._context.componentInstances) {\n\t\t\t\t\t\tinstance.initialised = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tawait this.logInfo(I18n.formatMessage(`${nameofCamelCase<EngineCore>()}.started`));\n\t\t\t} catch (err) {\n\t\t\t\tawait this.stop();\n\t\t\t\tawait this.logError(BaseError.fromError(err));\n\t\t\t\tthrow err;\n\t\t\t} finally {\n\t\t\t\tawait this.stateSave();\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Stop the engine core.\n\t * @returns Nothing.\n\t */\n\tpublic async stop(): Promise<void> {\n\t\tif (this._isStarted) {\n\t\t\tthis._isStarted = false;\n\n\t\t\tawait this.logInfo(I18n.formatMessage(`${nameofCamelCase<EngineCore>()}.stopping`));\n\t\t\tawait this.logInfo(I18n.formatMessage(`${nameofCamelCase<EngineCore>()}.componentsStopping`));\n\n\t\t\tawait ContextIdStore.run(this._contextIds ?? {}, async () => {\n\t\t\t\tfor (const instance of this._context.componentInstances) {\n\t\t\t\t\tif (instance.initialised) {\n\t\t\t\t\t\tinstance.initialised = false;\n\t\t\t\t\t\tconst stopMethod = instance.component.stop?.bind(instance.component);\n\t\t\t\t\t\tif (Is.function(stopMethod)) {\n\t\t\t\t\t\t\tawait this.logInfo(\n\t\t\t\t\t\t\t\tI18n.formatMessage(`${nameofCamelCase<EngineCore>()}.componentStopping`, {\n\t\t\t\t\t\t\t\t\tclassName: instance.component.className(),\n\t\t\t\t\t\t\t\t\tinstanceType: instance.instanceType\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tawait stopMethod(EngineCore.LOGGING_COMPONENT_TYPE_NAME);\n\t\t\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\t\t\tawait this.logError(\n\t\t\t\t\t\t\t\t\tnew GeneralError(\n\t\t\t\t\t\t\t\t\t\tEngineCore.CLASS_NAME,\n\t\t\t\t\t\t\t\t\t\t\"componentStopFailed\",\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tclassName: instance.component.className(),\n\t\t\t\t\t\t\t\t\t\t\tinstanceType: instance.instanceType\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tBaseError.fromError(err)\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tawait this.logInfo(I18n.formatMessage(`${nameofCamelCase<EngineCore>()}.componentsStopped`));\n\t\t\tawait this.logInfo(I18n.formatMessage(`${nameofCamelCase<EngineCore>()}.stopped`));\n\t\t}\n\n\t\tawait this.stateSave();\n\t}\n\n\t/**\n\t * Is the engine started.\n\t * @returns True if the engine is started.\n\t */\n\tpublic isStarted(): boolean {\n\t\treturn this._isStarted;\n\t}\n\n\t/**\n\t * Is this the primary engine instance.\n\t * @returns True if the engine is the primary instance.\n\t */\n\tpublic isPrimary(): boolean {\n\t\treturn isMainThread && !this._isClone;\n\t}\n\n\t/**\n\t * Is this engine instance a clone.\n\t * @returns True if the engine instance is a clone.\n\t */\n\tpublic isClone(): boolean {\n\t\treturn this._isClone;\n\t}\n\n\t/**\n\t * Log info.\n\t * @param message The message to log.\n\t */\n\tpublic async logInfo(message: string): Promise<void> {\n\t\tawait this._engineLoggingComponent?.log({\n\t\t\tsource: EngineCore.CLASS_NAME,\n\t\t\tlevel: \"info\",\n\t\t\tmessage\n\t\t});\n\t}\n\n\t/**\n\t * Log error.\n\t * @param error The error to log.\n\t */\n\tpublic async logError(error: IError): Promise<void> {\n\t\tconst formattedErrors = ErrorHelper.localizeErrors(error);\n\t\tfor (const formattedError of formattedErrors) {\n\t\t\tlet message = Is.stringValue(formattedError.source)\n\t\t\t\t? `${formattedError.source}: ${formattedError.message}`\n\t\t\t\t: formattedError.message;\n\t\t\tif (this._context.config.debug && Is.stringValue(formattedError.stack)) {\n\t\t\t\tmessage += `\\n${formattedError.stack}`;\n\t\t\t}\n\t\t\tawait this._engineLoggingComponent?.log({\n\t\t\t\tsource: EngineCore.CLASS_NAME,\n\t\t\t\tlevel: \"error\",\n\t\t\t\tmessage\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Get the config for the engine.\n\t * @returns The config for the engine.\n\t */\n\tpublic getConfig(): C {\n\t\treturn this._context.config;\n\t}\n\n\t/**\n\t * Get the state of the engine.\n\t * @returns The state of the engine.\n\t */\n\tpublic getState(): S {\n\t\treturn this._context.state;\n\t}\n\n\t/**\n\t * Set the state to dirty so it gets saved.\n\t */\n\tpublic setStateDirty(): void {\n\t\tthis._context.stateDirty = true;\n\t}\n\n\t/**\n\t * Get all the registered instances.\n\t * @returns The registered instances.\n\t */\n\tpublic getRegisteredInstances(): {\n\t\t[name: string]: {\n\t\t\ttype: string;\n\t\t\tisDefault?: boolean;\n\t\t\tfeatures?: string[];\n\t\t}[];\n\t} {\n\t\treturn this._context.registeredInstances;\n\t}\n\n\t/**\n\t * Get the registered instance type for the component/connector.\n\t * @param componentConnectorType The type of the component/connector.\n\t * @param features The requested features of the component, if not specified the default entry will be retrieved.\n\t * @returns The instance type matching the criteria if one is registered.\n\t * @throws If a matching instance was not found.\n\t */\n\tpublic getRegisteredInstanceType(componentConnectorType: string, features?: string[]): string {\n\t\tGuards.stringValue(\n\t\t\tEngineCore.CLASS_NAME,\n\t\t\tnameof(componentConnectorType),\n\t\t\tcomponentConnectorType\n\t\t);\n\n\t\tconst registeredType = this.getRegisteredInstanceTypeOptional(componentConnectorType, features);\n\n\t\tif (!Is.stringValue(registeredType)) {\n\t\t\tif (Is.arrayValue(features)) {\n\t\t\t\tthrow new GeneralError(EngineCore.CLASS_NAME, \"instanceTypeNotFoundWithFeatures\", {\n\t\t\t\t\ttype: componentConnectorType,\n\t\t\t\t\tfeatures: features.join(\",\")\n\t\t\t\t});\n\t\t\t}\n\t\t\tthrow new GeneralError(EngineCore.CLASS_NAME, \"instanceTypeNotFound\", {\n\t\t\t\ttype: componentConnectorType\n\t\t\t});\n\t\t}\n\n\t\treturn registeredType;\n\t}\n\n\t/**\n\t * Get the registered instance type for the component/connector if it exists.\n\t * @param componentConnectorType The type of the component/connector.\n\t * @param features The requested features of the component, if not specified the default entry will be retrieved.\n\t * @returns The instance type matching the criteria if one is registered.\n\t */\n\tpublic getRegisteredInstanceTypeOptional(\n\t\tcomponentConnectorType: string,\n\t\tfeatures?: string[]\n\t): string | undefined {\n\t\tlet registeredType: string | undefined;\n\n\t\tconst registeredTypes = this._context.registeredInstances[componentConnectorType];\n\t\tif (Is.arrayValue(registeredTypes)) {\n\t\t\tif (Is.arrayValue(features)) {\n\t\t\t\tregisteredType = registeredTypes.find(t =>\n\t\t\t\t\tt.features?.every(f => features.includes(f))\n\t\t\t\t)?.type;\n\t\t\t} else {\n\t\t\t\t// First look for the default entry\n\t\t\t\tregisteredType = registeredTypes.find(t => t.isDefault)?.type;\n\n\t\t\t\t// Can't find a default so just use the first entry\n\t\t\t\tif (!Is.stringValue(registeredType)) {\n\t\t\t\t\tregisteredType = registeredTypes[0]?.type;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn registeredType;\n\t}\n\n\t/**\n\t * Get the data required to create a clone of the engine.\n\t * @returns The clone data.\n\t */\n\tpublic getCloneData(): IEngineCoreClone<C, S> {\n\t\tconst entitySchemas: {\n\t\t\t[schema: string]: IEntitySchema;\n\t\t} = {};\n\n\t\tconst entitySchemaNames = EntitySchemaFactory.names();\n\t\tfor (const schemaName of entitySchemaNames) {\n\t\t\tentitySchemas[schemaName] = EntitySchemaFactory.get(schemaName);\n\t\t}\n\n\t\tconst cloneData: IEngineCoreClone<C, S> = {\n\t\t\tconfig: this._context.config,\n\t\t\tstate: this._context.state,\n\t\t\ttypeInitialisers: this._typeInitialisers,\n\t\t\tentitySchemas,\n\t\t\tcontextIdKeys: this._contextIdKeys\n\t\t};\n\n\t\treturn cloneData;\n\t}\n\n\t/**\n\t * Populate the engine from the clone data.\n\t * @param cloneData The clone data to populate from.\n\t * @param contextIds The context IDs to use for the clone.\n\t * @param silent Should the clone be silent.\n\t */\n\tpublic populateClone(\n\t\tcloneData: IEngineCoreClone<C, S>,\n\t\tcontextIds?: IContextIds,\n\t\tsilent?: boolean\n\t): void {\n\t\tGuards.object(EngineCore.CLASS_NAME, nameof(cloneData), cloneData);\n\t\tGuards.object(EngineCore.CLASS_NAME, nameof(cloneData.config), cloneData.config);\n\t\tGuards.object(EngineCore.CLASS_NAME, nameof(cloneData.state), cloneData.state);\n\t\tGuards.array(\n\t\t\tEngineCore.CLASS_NAME,\n\t\t\tnameof(cloneData.typeInitialisers),\n\t\t\tcloneData.typeInitialisers\n\t\t);\n\n\t\tthis._skipBootstrap = true;\n\t\tthis._isClone = true;\n\n\t\tif (silent ?? false) {\n\t\t\tcloneData.config.silent = true;\n\t\t}\n\n\t\tthis._context = {\n\t\t\tconfig: cloneData.config,\n\t\t\tregisteredInstances: {},\n\t\t\tcomponentInstances: [],\n\t\t\tstate: {} as S,\n\t\t\tstateDirty: false\n\t\t};\n\n\t\tthis._typeInitialisers = cloneData.typeInitialisers;\n\t\tthis._contextIdKeys.push(...cloneData.contextIdKeys);\n\t\tthis._contextIds = contextIds;\n\n\t\tfor (const schemaName of Object.keys(cloneData.entitySchemas)) {\n\t\t\tEntitySchemaFactory.register(schemaName, () => cloneData.entitySchemas[schemaName]);\n\t\t}\n\n\t\tthis._stateStorage = new MemoryStateStorage(true, cloneData.state);\n\t\tthis._isStarted = false;\n\t}\n\n\t/**\n\t * Initialise the types from connector.\n\t * @param typeKey The key for the default types.\n\t * @param instanceMethod The function to initialise the instance.\n\t * @internal\n\t */\n\tprivate async initialiseTypeConfig(\n\t\ttypeKey: string,\n\t\tmodule: string,\n\t\tmethod: string\n\t): Promise<void> {\n\t\tconst typeConfig: IEngineCoreTypeConfig[] | undefined = this._context.config.types?.[typeKey];\n\n\t\tif (Is.arrayValue(typeConfig)) {\n\t\t\tconst instanceMethod = await ModuleHelper.getModuleEntry<EngineTypeInitialiser>(\n\t\t\t\tmodule,\n\t\t\t\tmethod\n\t\t\t);\n\n\t\t\tfor (let i = 0; i < typeConfig.length; i++) {\n\t\t\t\tawait this.logInfo(\n\t\t\t\t\tI18n.formatMessage(\"engineCore.configuring\", {\n\t\t\t\t\t\tcomponentType: typeKey,\n\t\t\t\t\t\tconfigType: typeConfig[i].type\n\t\t\t\t\t})\n\t\t\t\t);\n\n\t\t\t\tconst result = instanceMethod(this, this._context, typeConfig[i]);\n\t\t\t\tconst componentCreateMethod = result.createComponent;\n\n\t\t\t\tif (Is.stringValue(result.instanceTypeName) && Is.function(componentCreateMethod)) {\n\t\t\t\t\tconst finalInstanceType = typeConfig[i].overrideInstanceType ?? result.instanceTypeName;\n\n\t\t\t\t\t// If this is a multi instance component we need to make sure we\n\t\t\t\t\t// generate a unique instance for every factory call\n\t\t\t\t\t// this is often used for REST clients where each instance might\n\t\t\t\t\t// use a different endpoint url\n\t\t\t\t\t// They are generated using the create method of factory\n\t\t\t\t\t// passing custom options, instead of the regular get method\n\t\t\t\t\t// which doesn't allow for custom options\n\t\t\t\t\tif (typeConfig[i].isMultiInstance ?? false) {\n\t\t\t\t\t\tresult.factory?.register(finalInstanceType, params =>\n\t\t\t\t\t\t\tcomponentCreateMethod({\n\t\t\t\t\t\t\t\ttype: typeConfig[i].type,\n\t\t\t\t\t\t\t\toptions: params\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst component = componentCreateMethod(typeConfig[i]);\n\t\t\t\t\t\tthis._context.componentInstances.push({\n\t\t\t\t\t\t\tinstanceType: finalInstanceType,\n\t\t\t\t\t\t\tcomponent,\n\t\t\t\t\t\t\tinitialised: false\n\t\t\t\t\t\t});\n\t\t\t\t\t\tresult.factory?.register(finalInstanceType, () => component);\n\t\t\t\t\t}\n\n\t\t\t\t\tthis._context.registeredInstances[typeKey] ??= [];\n\t\t\t\t\tthis._context.registeredInstances[typeKey].push({\n\t\t\t\t\t\ttype: finalInstanceType,\n\t\t\t\t\t\tisDefault: typeConfig[i].isDefault,\n\t\t\t\t\t\tfeatures: typeConfig[i].features\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\tthrow new GeneralError(\"engineCore\", \"componentUnknownType\", {\n\t\t\t\t\t\ttype: typeConfig[i].type,\n\t\t\t\t\t\tcomponentType: typeKey\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Setup the engine logger.\n\t * @internal\n\t */\n\tprivate setupEngineLogger(): void {\n\t\tconst silent = this._context.config.silent ?? false;\n\t\tconst engineLoggerConnector = silent\n\t\t\t? new SilentLoggingConnector()\n\t\t\t: new ConsoleLoggingConnector({\n\t\t\t\t\tconfig: {\n\t\t\t\t\t\ttranslateMessages: true,\n\t\t\t\t\t\thideGroups: true\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\tthis._context.componentInstances.push({\n\t\t\tinstanceType: EngineCore.LOGGING_CONNECTOR_TYPE_NAME,\n\t\t\tcomponent: engineLoggerConnector,\n\t\t\tinitialised: false\n\t\t});\n\n\t\tLoggingConnectorFactory.register(\n\t\t\tEngineCore.LOGGING_CONNECTOR_TYPE_NAME,\n\t\t\t() => engineLoggerConnector\n\t\t);\n\n\t\tthis._context.registeredInstances.loggingConnector = [\n\t\t\t{\n\t\t\t\ttype: EngineCore.LOGGING_CONNECTOR_TYPE_NAME\n\t\t\t}\n\t\t];\n\n\t\tconst engineLoggerComponent = new LoggingService({\n\t\t\tloggingConnectorType: EngineCore.LOGGING_CONNECTOR_TYPE_NAME\n\t\t});\n\t\tthis._engineLoggingComponent = engineLoggerComponent;\n\n\t\tComponentFactory.register(EngineCore.LOGGING_COMPONENT_TYPE_NAME, () => engineLoggerComponent);\n\t\tthis._context.registeredInstances.loggingComponent = [\n\t\t\t{\n\t\t\t\ttype: EngineCore.LOGGING_COMPONENT_TYPE_NAME\n\t\t\t}\n\t\t];\n\t}\n\n\t/**\n\t * Load the state.\n\t * @internal\n\t */\n\tprivate async stateLoad(): Promise<void> {\n\t\tif (this._stateStorage) {\n\t\t\ttry {\n\t\t\t\tthis._context.state = ((await this._stateStorage.load(this)) ?? {}) as S;\n\t\t\t\tthis._context.stateDirty = false;\n\t\t\t} catch (err) {\n\t\t\t\tawait this.logError(BaseError.fromError(err));\n\t\t\t\tthrow err;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Save the state.\n\t * @returns Nothing.\n\t * @internal\n\t */\n\tprivate async stateSave(): Promise<void> {\n\t\tif (this._stateStorage && !Is.empty(this._context.state) && this._context.stateDirty) {\n\t\t\ttry {\n\t\t\t\tawait this._stateStorage.save(this, this._context.state);\n\t\t\t\tthis._context.stateDirty = false;\n\t\t\t} catch (err) {\n\t\t\t\tawait this.logError(BaseError.fromError(err));\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Bootstrap the engine.\n\t * @internal\n\t */\n\tprivate async bootstrap(): Promise<void> {\n\t\tif (!this._skipBootstrap) {\n\t\t\tawait this.logInfo(I18n.formatMessage(`${nameofCamelCase<EngineCore>()}.bootstrapStarted`));\n\n\t\t\t// First bootstrap the components.\n\t\t\tfor (const instance of this._context.componentInstances) {\n\t\t\t\tconst bootstrapMethod = instance.component.bootstrap?.bind(instance.component);\n\t\t\t\tif (Is.function(bootstrapMethod)) {\n\t\t\t\t\tawait this.logInfo(\n\t\t\t\t\t\tI18n.formatMessage(`${nameofCamelCase<EngineCore>()}.bootstrapping`, {\n\t\t\t\t\t\t\tclassName: instance.component.className(),\n\t\t\t\t\t\t\tinstanceType: instance.instanceType\n\t\t\t\t\t\t})\n\t\t\t\t\t);\n\n\t\t\t\t\tconst bootstrapSuccess = await bootstrapMethod(EngineCore.LOGGING_COMPONENT_TYPE_NAME);\n\n\t\t\t\t\t// If the bootstrap method failed then throw an error\n\t\t\t\t\tif (!bootstrapSuccess) {\n\t\t\t\t\t\tthrow new GeneralError(EngineCore.CLASS_NAME, \"bootstrapFailed\", {\n\t\t\t\t\t\t\tclassName: instance.component.className(),\n\t\t\t\t\t\t\tinstanceType: instance.instanceType\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Now perform any custom bootstrap operations\n\t\t\tconst customBootstrap = this._customBootstrap;\n\t\t\tif (Is.function(customBootstrap)) {\n\t\t\t\tawait customBootstrap.call(this, this, this._context);\n\t\t\t}\n\n\t\t\tawait this.logInfo(I18n.formatMessage(`${nameofCamelCase<EngineCore>()}.bootstrapComplete`));\n\t\t}\n\t}\n\n\t/**\n\t * Initialise the context ID handlers.\n\t * @internal\n\t */\n\tprivate initialiseContextIdHandlers(): void {\n\t\tfor (const contextIdKey of this._contextIdKeys) {\n\t\t\tconst handlerType: string | undefined = this.getRegisteredInstanceTypeOptional(\n\t\t\t\t\"contextIdHandlerComponent\",\n\t\t\t\tcontextIdKey.componentFeatures\n\t\t\t);\n\t\t\tif (Is.stringValue(handlerType)) {\n\t\t\t\tconst handler = ComponentFactory.get<IContextIdHandler>(handlerType);\n\t\t\t\tContextIdHandlerFactory.register(contextIdKey.key, () => handler);\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"engineCore.js","sourceRoot":"","sources":["../../src/engineCore.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EACN,uBAAuB,EACvB,cAAc,EAGd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACN,SAAS,EACT,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,MAAM,EACN,IAAI,EAEJ,EAAE,EACF,MAAM,gBAAgB,CAAC;AAWxB,OAAO,EAAE,mBAAmB,EAAsB,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,EAEN,uBAAuB,EACvB,sBAAsB,EACtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAErE;;GAEG;AACH,MAAM,OAAO,UAAU;IAItB;;OAEG;IACI,MAAM,CAAU,2BAA2B,GAAW,wBAAwB,CAAC;IAEtF;;OAEG;IACI,MAAM,CAAU,2BAA2B,GAAW,0BAA0B,CAAC;IAExF;;OAEG;IACI,MAAM,CAAU,UAAU,gBAAgC;IAEjE;;OAEG;IACO,QAAQ,CAA2B;IAE7C;;OAEG;IACgB,cAAc,CAAiD;IAElF;;OAEG;IACO,WAAW,CAAe;IAEpC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,OAAO,GAAG,gBAAgB,CAAC,GAAG,CAAoB,WAAW,CAAC,CAAC;gBACrE,uBAAuB,CAAC,QAAQ,CAAC,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC;YACnE,CAAC;QACF,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { isMainThread } from \"node:worker_threads\";\nimport {\n\tContextIdHandlerFactory,\n\tContextIdStore,\n\ttype IContextIdHandler,\n\ttype IContextIds\n} from \"@twin.org/context\";\nimport {\n\tBaseError,\n\tComponentFactory,\n\tErrorHelper,\n\tGeneralError,\n\tGuards,\n\tI18n,\n\ttype IError,\n\tIs\n} from \"@twin.org/core\";\nimport type {\n\tEngineTypeInitialiser,\n\tIEngineCore,\n\tIEngineCoreClone,\n\tIEngineCoreConfig,\n\tIEngineCoreContext,\n\tIEngineCoreTypeConfig,\n\tIEngineState,\n\tIEngineStateStorage\n} from \"@twin.org/engine-models\";\nimport { EntitySchemaFactory, type IEntitySchema } from \"@twin.org/entity\";\nimport { ConsoleLoggingConnector } from \"@twin.org/logging-connector-console\";\nimport {\n\ttype ILoggingComponent,\n\tLoggingConnectorFactory,\n\tSilentLoggingConnector\n} from \"@twin.org/logging-models\";\nimport { LoggingService } from \"@twin.org/logging-service\";\nimport { ModuleHelper } from \"@twin.org/modules\";\nimport { nameof, nameofCamelCase } from \"@twin.org/nameof\";\nimport type { IEngineCoreOptions } from \"./models/IEngineCoreOptions.js\";\nimport { MemoryStateStorage } from \"./storage/memoryStateStorage.js\";\n\n/**\n * Core for the engine.\n */\nexport class EngineCore<\n\tC extends IEngineCoreConfig = IEngineCoreConfig,\n\tS extends IEngineState = IEngineState\n> implements IEngineCore<C, S> {\n\t/**\n\t * Name for the engine logger component, used for direct console logging.\n\t */\n\tpublic static readonly LOGGING_COMPONENT_TYPE_NAME: string = \"engine-logging-service\";\n\n\t/**\n\t * Name for the engine logger connector, used for direct console logging.\n\t */\n\tpublic static readonly LOGGING_CONNECTOR_TYPE_NAME: string = \"engine-logging-connector\";\n\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<EngineCore>();\n\n\t/**\n\t * The core context.\n\t */\n\tprotected _context: IEngineCoreContext<C, S>;\n\n\t/**\n\t * The context ID keys.\n\t */\n\tprotected readonly _contextIdKeys: { key: string; componentFeatures: string[] }[];\n\n\t/**\n\t * The context IDs.\n\t */\n\tprotected _contextIds?: IContextIds;\n\n\t/**\n\t * The state storage interface.\n\t * @internal\n\t */\n\tprivate _stateStorage?: IEngineStateStorage<S>;\n\n\t/**\n\t * The logging component for the engine.\n\t * @internal\n\t */\n\tprivate _engineLoggingComponent?: ILoggingComponent;\n\n\t/**\n\t * Skip the bootstrap process.\n\t * @internal\n\t */\n\tprivate _skipBootstrap?: boolean;\n\n\t/**\n\t * The type initialisers.\n\t * @internal\n\t */\n\tprivate _typeInitialisers: {\n\t\ttype: string;\n\t\tmodule: string;\n\t\tmethod: string;\n\t}[];\n\n\t/**\n\t * Is the engine started.\n\t * @internal\n\t */\n\tprivate _isStarted: boolean;\n\n\t/**\n\t * Is the engine a clone.\n\t * @internal\n\t */\n\tprivate _isClone: boolean;\n\n\t/**\n\t * Add type initialisers to the engine.\n\t * @internal\n\t */\n\tprivate readonly _populateTypeInitialisers?: (\n\t\tengineCore: IEngineCore<C, S>,\n\t\tcontext: IEngineCoreContext<C, S>\n\t) => void;\n\n\t/**\n\t * Method for bootstrapping any data for the engine.\n\t * @internal\n\t */\n\tprivate readonly _customBootstrap?: (\n\t\tengineCore: IEngineCore<C, S>,\n\t\tcontext: IEngineCoreContext<C, S>\n\t) => Promise<void>;\n\n\t/**\n\t * Create a new instance of EngineCore.\n\t * @param options The options for the engine.\n\t */\n\tconstructor(options?: IEngineCoreOptions<C, S>) {\n\t\toptions = options ?? {};\n\t\toptions.config = options.config ?? ({} as C);\n\t\toptions.config.debug = options.config.debug ?? false;\n\t\toptions.config.silent = options.config.silent ?? false;\n\t\toptions.config.types ??= {};\n\n\t\tthis._skipBootstrap = options.skipBootstrap ?? false;\n\t\tthis._populateTypeInitialisers = options.populateTypeInitialisers;\n\t\tthis._customBootstrap = options.customBootstrap;\n\t\tthis._typeInitialisers = [];\n\t\tthis._contextIdKeys = [];\n\n\t\tthis._context = {\n\t\t\tconfig: options.config,\n\t\t\tregisteredInstances: {},\n\t\t\tcomponentInstances: [],\n\t\t\tstate: {} as S,\n\t\t\tstateDirty: false\n\t\t};\n\t\tthis._stateStorage = options.stateStorage;\n\t\tthis._isStarted = false;\n\t\tthis._isClone = false;\n\n\t\tif (Is.function(this._populateTypeInitialisers)) {\n\t\t\tthis._populateTypeInitialisers(this, this._context);\n\t\t}\n\t}\n\n\t/**\n\t * Add a type initialiser.\n\t * @param type The type to add the initialiser for.\n\t * @param module The name of the module which contains the initialiser method.\n\t * @param method The name of the method to call.\n\t */\n\tpublic addTypeInitialiser(type: string, module: string, method: string): void {\n\t\tGuards.stringValue(EngineCore.CLASS_NAME, nameof(type), type);\n\t\tGuards.stringValue(EngineCore.CLASS_NAME, nameof(module), module);\n\t\tGuards.stringValue(EngineCore.CLASS_NAME, nameof(method), method);\n\n\t\tconst currentIndex = this._typeInitialisers.findIndex(t => t.type === type);\n\t\tif (currentIndex >= 0) {\n\t\t\tthis._typeInitialisers[currentIndex].module = module;\n\t\t\tthis._typeInitialisers[currentIndex].method = method;\n\t\t} else {\n\t\t\tthis._typeInitialisers.push({\n\t\t\t\ttype,\n\t\t\t\tmodule,\n\t\t\t\tmethod\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Get the type config for a specific type.\n\t * @param type The type to get the config for.\n\t * @returns The type config or undefined if not found.\n\t */\n\tpublic getTypeConfig(type: string): IEngineCoreTypeConfig[] | undefined {\n\t\tGuards.stringValue(EngineCore.CLASS_NAME, nameof(type), type);\n\t\treturn this._context.config.types?.[type];\n\t}\n\n\t/**\n\t * Add a context ID key to the engine.\n\t * @param key The context ID key.\n\t * @param componentFeatures The component features for the context ID handler.\n\t */\n\tpublic addContextIdKey(key: string, componentFeatures: string[]): void {\n\t\tconst exists = this._contextIdKeys.find(k => k.key === key);\n\t\tif (Is.empty(exists)) {\n\t\t\tthis._contextIdKeys.push({ key, componentFeatures });\n\t\t}\n\t}\n\n\t/**\n\t * Get the context ID keys for the engine.\n\t * @returns The context IDs keys.\n\t */\n\tpublic getContextIdKeys(): string[] {\n\t\treturn this._contextIdKeys.map(k => k.key);\n\t}\n\n\t/**\n\t * Add a context ID to the engine.\n\t * @param key The context ID key.\n\t * @param value The context ID value.\n\t */\n\tpublic addContextId(key: string, value: string): void {\n\t\tthis._contextIds ??= {};\n\t\tthis._contextIds[key] = value;\n\t}\n\n\t/**\n\t * Get the context IDs for the engine.\n\t * @returns The context IDs or undefined if none are set.\n\t */\n\tpublic getContextIds(): IContextIds | undefined {\n\t\treturn this._contextIds;\n\t}\n\n\t/**\n\t * Start the engine core.\n\t * @param skipComponentStart Should the component start be skipped.\n\t * @returns Nothing.\n\t */\n\tpublic async start(skipComponentStart?: boolean): Promise<void> {\n\t\tif (!this._isStarted) {\n\t\t\tthis.setupEngineLogger();\n\t\t\tawait this.logInfo(I18n.formatMessage(`${nameofCamelCase<EngineCore>()}.starting`));\n\n\t\t\tif (this._context.config.debug) {\n\t\t\t\tawait this.logInfo(I18n.formatMessage(`${nameofCamelCase<EngineCore>()}.debuggingEnabled`));\n\t\t\t}\n\n\t\t\tconst skipComponent = skipComponentStart ?? false;\n\t\t\ttry {\n\t\t\t\tawait this.stateLoad();\n\n\t\t\t\tfor (const { type, module, method } of this._typeInitialisers) {\n\t\t\t\t\tawait this.initialiseTypeConfig(type, module, method);\n\t\t\t\t}\n\n\t\t\t\tthis.initialiseContextIdHandlers();\n\n\t\t\t\tawait this.bootstrap();\n\n\t\t\t\tthis._isStarted = true;\n\n\t\t\t\tif (!skipComponent) {\n\t\t\t\t\tawait this.logInfo(\n\t\t\t\t\t\tI18n.formatMessage(`${nameofCamelCase<EngineCore>()}.componentsStarting`)\n\t\t\t\t\t);\n\n\t\t\t\t\tawait ContextIdStore.run(this._contextIds ?? {}, async () => {\n\t\t\t\t\t\tfor (const instance of this._context.componentInstances) {\n\t\t\t\t\t\t\tif (!instance.initialised) {\n\t\t\t\t\t\t\t\tinstance.initialised = true;\n\n\t\t\t\t\t\t\t\tconst startMethod = instance.component.start?.bind(instance.component);\n\t\t\t\t\t\t\t\tif (Is.function(startMethod)) {\n\t\t\t\t\t\t\t\t\tawait this.logInfo(\n\t\t\t\t\t\t\t\t\t\tI18n.formatMessage(`${nameofCamelCase<EngineCore>()}.componentStarting`, {\n\t\t\t\t\t\t\t\t\t\t\tclassName: instance.component.className(),\n\t\t\t\t\t\t\t\t\t\t\tinstanceType: instance.instanceType\n\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\t\tawait startMethod(EngineCore.LOGGING_COMPONENT_TYPE_NAME);\n\t\t\t\t\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\t\t\t\t\tawait this.logError(\n\t\t\t\t\t\t\t\t\t\t\tnew GeneralError(\n\t\t\t\t\t\t\t\t\t\t\t\tEngineCore.CLASS_NAME,\n\t\t\t\t\t\t\t\t\t\t\t\t\"componentStartFailed\",\n\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\tclassName: instance.component.className(),\n\t\t\t\t\t\t\t\t\t\t\t\t\tinstanceType: instance.instanceType\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\tBaseError.fromError(err)\n\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\t\t\tthrow err;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\t\tawait this.logInfo(\n\t\t\t\t\t\tI18n.formatMessage(`${nameofCamelCase<EngineCore>()}.componentsComplete`)\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\t// If we are skipping component start then just mark them as initialised\n\t\t\t\t\t// we still need to be able to call stop on them to clean up\n\t\t\t\t\tfor (const instance of this._context.componentInstances) {\n\t\t\t\t\t\tinstance.initialised = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tawait this.logInfo(I18n.formatMessage(`${nameofCamelCase<EngineCore>()}.started`));\n\t\t\t} catch (err) {\n\t\t\t\tawait this.stop();\n\t\t\t\tawait this.logError(BaseError.fromError(err));\n\t\t\t\tthrow err;\n\t\t\t} finally {\n\t\t\t\tawait this.stateSave();\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Stop the engine core.\n\t * @returns Nothing.\n\t */\n\tpublic async stop(): Promise<void> {\n\t\tif (this._isStarted) {\n\t\t\tthis._isStarted = false;\n\n\t\t\tawait this.logInfo(I18n.formatMessage(`${nameofCamelCase<EngineCore>()}.stopping`));\n\t\t\tawait this.logInfo(I18n.formatMessage(`${nameofCamelCase<EngineCore>()}.componentsStopping`));\n\n\t\t\tawait ContextIdStore.run(this._contextIds ?? {}, async () => {\n\t\t\t\tfor (const instance of this._context.componentInstances) {\n\t\t\t\t\tif (instance.initialised) {\n\t\t\t\t\t\tinstance.initialised = false;\n\t\t\t\t\t\tconst stopMethod = instance.component.stop?.bind(instance.component);\n\t\t\t\t\t\tif (Is.function(stopMethod)) {\n\t\t\t\t\t\t\tawait this.logInfo(\n\t\t\t\t\t\t\t\tI18n.formatMessage(`${nameofCamelCase<EngineCore>()}.componentStopping`, {\n\t\t\t\t\t\t\t\t\tclassName: instance.component.className(),\n\t\t\t\t\t\t\t\t\tinstanceType: instance.instanceType\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tawait stopMethod(EngineCore.LOGGING_COMPONENT_TYPE_NAME);\n\t\t\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\t\t\tawait this.logError(\n\t\t\t\t\t\t\t\t\tnew GeneralError(\n\t\t\t\t\t\t\t\t\t\tEngineCore.CLASS_NAME,\n\t\t\t\t\t\t\t\t\t\t\"componentStopFailed\",\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tclassName: instance.component.className(),\n\t\t\t\t\t\t\t\t\t\t\tinstanceType: instance.instanceType\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tBaseError.fromError(err)\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tawait this.logInfo(I18n.formatMessage(`${nameofCamelCase<EngineCore>()}.componentsStopped`));\n\t\t\tawait this.logInfo(I18n.formatMessage(`${nameofCamelCase<EngineCore>()}.stopped`));\n\t\t}\n\n\t\tawait this.stateSave();\n\t}\n\n\t/**\n\t * Is the engine started.\n\t * @returns True if the engine is started.\n\t */\n\tpublic isStarted(): boolean {\n\t\treturn this._isStarted;\n\t}\n\n\t/**\n\t * Is this the primary engine instance.\n\t * @returns True if the engine is the primary instance.\n\t */\n\tpublic isPrimary(): boolean {\n\t\treturn isMainThread && !this._isClone;\n\t}\n\n\t/**\n\t * Is this engine instance a clone.\n\t * @returns True if the engine instance is a clone.\n\t */\n\tpublic isClone(): boolean {\n\t\treturn this._isClone;\n\t}\n\n\t/**\n\t * Log info.\n\t * @param message The message to log.\n\t */\n\tpublic async logInfo(message: string): Promise<void> {\n\t\tawait this._engineLoggingComponent?.log({\n\t\t\tsource: EngineCore.CLASS_NAME,\n\t\t\tlevel: \"info\",\n\t\t\tmessage\n\t\t});\n\t}\n\n\t/**\n\t * Log error.\n\t * @param error The error to log.\n\t */\n\tpublic async logError(error: IError): Promise<void> {\n\t\tconst formattedErrors = ErrorHelper.localizeErrors(error);\n\t\tfor (const formattedError of formattedErrors) {\n\t\t\tlet message = Is.stringValue(formattedError.source)\n\t\t\t\t? `${formattedError.source}: ${formattedError.message}`\n\t\t\t\t: formattedError.message;\n\t\t\tif (this._context.config.debug && Is.stringValue(formattedError.stack)) {\n\t\t\t\tmessage += `\\n${formattedError.stack}`;\n\t\t\t}\n\t\t\tawait this._engineLoggingComponent?.log({\n\t\t\t\tsource: EngineCore.CLASS_NAME,\n\t\t\t\tlevel: \"error\",\n\t\t\t\tmessage\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Get the config for the engine.\n\t * @returns The config for the engine.\n\t */\n\tpublic getConfig(): C {\n\t\treturn this._context.config;\n\t}\n\n\t/**\n\t * Get the state of the engine.\n\t * @returns The state of the engine.\n\t */\n\tpublic getState(): S {\n\t\treturn this._context.state;\n\t}\n\n\t/**\n\t * Set the state to dirty so it gets saved.\n\t */\n\tpublic setStateDirty(): void {\n\t\tthis._context.stateDirty = true;\n\t}\n\n\t/**\n\t * Get all the registered instances.\n\t * @returns The registered instances.\n\t */\n\tpublic getRegisteredInstances(): {\n\t\t[name: string]: {\n\t\t\ttype: string;\n\t\t\tisDefault?: boolean;\n\t\t\tfeatures?: string[];\n\t\t}[];\n\t} {\n\t\treturn this._context.registeredInstances;\n\t}\n\n\t/**\n\t * Get the registered instance type for the component/connector.\n\t * @param componentConnectorType The type of the component/connector.\n\t * @param features The requested features of the component, if not specified the default entry will be retrieved.\n\t * @returns The instance type matching the criteria if one is registered.\n\t * @throws If a matching instance was not found.\n\t */\n\tpublic getRegisteredInstanceType(componentConnectorType: string, features?: string[]): string {\n\t\tGuards.stringValue(\n\t\t\tEngineCore.CLASS_NAME,\n\t\t\tnameof(componentConnectorType),\n\t\t\tcomponentConnectorType\n\t\t);\n\n\t\tconst registeredType = this.getRegisteredInstanceTypeOptional(componentConnectorType, features);\n\n\t\tif (!Is.stringValue(registeredType)) {\n\t\t\tif (Is.arrayValue(features)) {\n\t\t\t\tthrow new GeneralError(EngineCore.CLASS_NAME, \"instanceTypeNotFoundWithFeatures\", {\n\t\t\t\t\ttype: componentConnectorType,\n\t\t\t\t\tfeatures: features.join(\",\")\n\t\t\t\t});\n\t\t\t}\n\t\t\tthrow new GeneralError(EngineCore.CLASS_NAME, \"instanceTypeNotFound\", {\n\t\t\t\ttype: componentConnectorType\n\t\t\t});\n\t\t}\n\n\t\treturn registeredType;\n\t}\n\n\t/**\n\t * Get the registered instance type for the component/connector if it exists.\n\t * @param componentConnectorType The type of the component/connector.\n\t * @param features The requested features of the component, if not specified the default entry will be retrieved.\n\t * @returns The instance type matching the criteria if one is registered.\n\t */\n\tpublic getRegisteredInstanceTypeOptional(\n\t\tcomponentConnectorType: string,\n\t\tfeatures?: string[]\n\t): string | undefined {\n\t\tlet registeredType: string | undefined;\n\n\t\tconst registeredTypes = this._context.registeredInstances[componentConnectorType];\n\t\tif (Is.arrayValue(registeredTypes)) {\n\t\t\tif (Is.arrayValue(features)) {\n\t\t\t\tregisteredType = registeredTypes.find(t =>\n\t\t\t\t\tt.features?.every(f => features.includes(f))\n\t\t\t\t)?.type;\n\t\t\t} else {\n\t\t\t\t// First look for the default entry\n\t\t\t\tregisteredType = registeredTypes.find(t => t.isDefault)?.type;\n\n\t\t\t\t// Can't find a default so just use the first entry\n\t\t\t\tif (!Is.stringValue(registeredType)) {\n\t\t\t\t\tregisteredType = registeredTypes[0]?.type;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn registeredType;\n\t}\n\n\t/**\n\t * Get the data required to create a clone of the engine.\n\t * @returns The clone data.\n\t */\n\tpublic getCloneData(): IEngineCoreClone<C, S> {\n\t\tconst entitySchemas: {\n\t\t\t[schema: string]: IEntitySchema;\n\t\t} = {};\n\n\t\tconst entitySchemaNames = EntitySchemaFactory.names();\n\t\tfor (const schemaName of entitySchemaNames) {\n\t\t\tentitySchemas[schemaName] = EntitySchemaFactory.get(schemaName);\n\t\t}\n\n\t\tconst cloneData: IEngineCoreClone<C, S> = {\n\t\t\tconfig: this._context.config,\n\t\t\tstate: this._context.state,\n\t\t\ttypeInitialisers: this._typeInitialisers,\n\t\t\tentitySchemas,\n\t\t\tcontextIdKeys: this._contextIdKeys\n\t\t};\n\n\t\treturn cloneData;\n\t}\n\n\t/**\n\t * Populate the engine from the clone data.\n\t * @param cloneData The clone data to populate from.\n\t * @param contextIds The context IDs to use for the clone.\n\t * @param silent Should the clone be silent.\n\t */\n\tpublic populateClone(\n\t\tcloneData: IEngineCoreClone<C, S>,\n\t\tcontextIds?: IContextIds,\n\t\tsilent?: boolean\n\t): void {\n\t\tGuards.object(EngineCore.CLASS_NAME, nameof(cloneData), cloneData);\n\t\tGuards.object(EngineCore.CLASS_NAME, nameof(cloneData.config), cloneData.config);\n\t\tGuards.object(EngineCore.CLASS_NAME, nameof(cloneData.state), cloneData.state);\n\t\tGuards.array(\n\t\t\tEngineCore.CLASS_NAME,\n\t\t\tnameof(cloneData.typeInitialisers),\n\t\t\tcloneData.typeInitialisers\n\t\t);\n\n\t\tthis._skipBootstrap = true;\n\t\tthis._isClone = true;\n\n\t\tif (silent ?? false) {\n\t\t\tcloneData.config.silent = true;\n\t\t}\n\n\t\tthis._context = {\n\t\t\tconfig: cloneData.config,\n\t\t\tregisteredInstances: {},\n\t\t\tcomponentInstances: [],\n\t\t\tstate: {} as S,\n\t\t\tstateDirty: false\n\t\t};\n\n\t\tthis._typeInitialisers = cloneData.typeInitialisers;\n\t\tthis._contextIdKeys.push(...cloneData.contextIdKeys);\n\t\tthis._contextIds = contextIds;\n\n\t\tfor (const schemaName of Object.keys(cloneData.entitySchemas)) {\n\t\t\tEntitySchemaFactory.register(schemaName, () => cloneData.entitySchemas[schemaName]);\n\t\t}\n\n\t\tthis._stateStorage = new MemoryStateStorage(true, cloneData.state);\n\t\tthis._isStarted = false;\n\t}\n\n\t/**\n\t * Initialise the types from connector.\n\t * @param typeKey The key for the default types.\n\t * @param instanceMethod The function to initialise the instance.\n\t * @internal\n\t */\n\tprivate async initialiseTypeConfig(\n\t\ttypeKey: string,\n\t\tmodule: string,\n\t\tmethod: string\n\t): Promise<void> {\n\t\tconst typeConfig: IEngineCoreTypeConfig[] | undefined = this._context.config.types?.[typeKey];\n\n\t\tif (Is.arrayValue(typeConfig)) {\n\t\t\tconst instanceMethod = await ModuleHelper.getModuleEntry<EngineTypeInitialiser>(\n\t\t\t\tmodule,\n\t\t\t\tmethod\n\t\t\t);\n\n\t\t\tfor (let i = 0; i < typeConfig.length; i++) {\n\t\t\t\tawait this.logInfo(\n\t\t\t\t\tI18n.formatMessage(\"engineCore.configuring\", {\n\t\t\t\t\t\tcomponentType: typeKey,\n\t\t\t\t\t\tconfigType: typeConfig[i].type\n\t\t\t\t\t})\n\t\t\t\t);\n\n\t\t\t\tconst result = instanceMethod(this, this._context, typeConfig[i]);\n\t\t\t\tconst componentCreateMethod = result.createComponent;\n\n\t\t\t\tif (Is.stringValue(result.instanceTypeName) && Is.function(componentCreateMethod)) {\n\t\t\t\t\tconst finalInstanceType = typeConfig[i].overrideInstanceType ?? result.instanceTypeName;\n\n\t\t\t\t\t// If this is a multi instance component we need to make sure we\n\t\t\t\t\t// generate a unique instance for every factory call\n\t\t\t\t\t// this is often used for REST clients where each instance might\n\t\t\t\t\t// use a different endpoint url\n\t\t\t\t\t// They are generated using the create method of factory\n\t\t\t\t\t// passing custom options, instead of the regular get method\n\t\t\t\t\t// which doesn't allow for custom options\n\t\t\t\t\tif (typeConfig[i].isMultiInstance ?? false) {\n\t\t\t\t\t\tresult.factory?.register(finalInstanceType, params =>\n\t\t\t\t\t\t\tcomponentCreateMethod({\n\t\t\t\t\t\t\t\ttype: typeConfig[i].type,\n\t\t\t\t\t\t\t\toptions: params\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst component = componentCreateMethod(typeConfig[i]);\n\t\t\t\t\t\tthis._context.componentInstances.push({\n\t\t\t\t\t\t\tinstanceType: finalInstanceType,\n\t\t\t\t\t\t\tcomponent,\n\t\t\t\t\t\t\tinitialised: false\n\t\t\t\t\t\t});\n\t\t\t\t\t\tresult.factory?.register(finalInstanceType, () => component);\n\t\t\t\t\t}\n\n\t\t\t\t\tthis._context.registeredInstances[typeKey] ??= [];\n\t\t\t\t\tthis._context.registeredInstances[typeKey].push({\n\t\t\t\t\t\ttype: finalInstanceType,\n\t\t\t\t\t\tisDefault: typeConfig[i].isDefault,\n\t\t\t\t\t\tfeatures: typeConfig[i].features\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\tthrow new GeneralError(\"engineCore\", \"componentUnknownType\", {\n\t\t\t\t\t\ttype: typeConfig[i].type,\n\t\t\t\t\t\tcomponentType: typeKey\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Setup the engine logger.\n\t * @internal\n\t */\n\tprivate setupEngineLogger(): void {\n\t\tconst silent = this._context.config.silent ?? false;\n\t\tconst engineLoggerConnector = silent\n\t\t\t? new SilentLoggingConnector()\n\t\t\t: new ConsoleLoggingConnector({\n\t\t\t\t\tconfig: {\n\t\t\t\t\t\ttranslateMessages: true,\n\t\t\t\t\t\thideGroups: true\n\t\t\t\t\t}\n\t\t\t\t});\n\n\t\tthis._context.componentInstances.push({\n\t\t\tinstanceType: EngineCore.LOGGING_CONNECTOR_TYPE_NAME,\n\t\t\tcomponent: engineLoggerConnector,\n\t\t\tinitialised: false\n\t\t});\n\n\t\tLoggingConnectorFactory.register(\n\t\t\tEngineCore.LOGGING_CONNECTOR_TYPE_NAME,\n\t\t\t() => engineLoggerConnector\n\t\t);\n\n\t\tthis._context.registeredInstances.loggingConnector = [\n\t\t\t{\n\t\t\t\ttype: EngineCore.LOGGING_CONNECTOR_TYPE_NAME\n\t\t\t}\n\t\t];\n\n\t\tconst engineLoggerComponent = new LoggingService({\n\t\t\tloggingConnectorType: EngineCore.LOGGING_CONNECTOR_TYPE_NAME\n\t\t});\n\t\tthis._engineLoggingComponent = engineLoggerComponent;\n\n\t\tComponentFactory.register(EngineCore.LOGGING_COMPONENT_TYPE_NAME, () => engineLoggerComponent);\n\t\tthis._context.registeredInstances.loggingComponent = [\n\t\t\t{\n\t\t\t\ttype: EngineCore.LOGGING_COMPONENT_TYPE_NAME\n\t\t\t}\n\t\t];\n\t}\n\n\t/**\n\t * Load the state.\n\t * @internal\n\t */\n\tprivate async stateLoad(): Promise<void> {\n\t\tif (this._stateStorage) {\n\t\t\ttry {\n\t\t\t\tthis._context.state = ((await this._stateStorage.load(this)) ?? {}) as S;\n\t\t\t\tthis._context.stateDirty = false;\n\t\t\t} catch (err) {\n\t\t\t\tawait this.logError(BaseError.fromError(err));\n\t\t\t\tthrow err;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Save the state.\n\t * @returns Nothing.\n\t * @internal\n\t */\n\tprivate async stateSave(): Promise<void> {\n\t\tif (this._stateStorage && !Is.empty(this._context.state) && this._context.stateDirty) {\n\t\t\ttry {\n\t\t\t\tawait this._stateStorage.save(this, this._context.state);\n\t\t\t\tthis._context.stateDirty = false;\n\t\t\t} catch (err) {\n\t\t\t\tawait this.logError(BaseError.fromError(err));\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Bootstrap the engine.\n\t * @internal\n\t */\n\tprivate async bootstrap(): Promise<void> {\n\t\tif (!this._skipBootstrap) {\n\t\t\tawait this.logInfo(I18n.formatMessage(`${nameofCamelCase<EngineCore>()}.bootstrapStarted`));\n\n\t\t\t// First bootstrap the components.\n\t\t\tfor (const instance of this._context.componentInstances) {\n\t\t\t\tconst bootstrapMethod = instance.component.bootstrap?.bind(instance.component);\n\t\t\t\tif (Is.function(bootstrapMethod)) {\n\t\t\t\t\tawait this.logInfo(\n\t\t\t\t\t\tI18n.formatMessage(`${nameofCamelCase<EngineCore>()}.bootstrapping`, {\n\t\t\t\t\t\t\tclassName: instance.component.className(),\n\t\t\t\t\t\t\tinstanceType: instance.instanceType\n\t\t\t\t\t\t})\n\t\t\t\t\t);\n\n\t\t\t\t\tconst bootstrapSuccess = await bootstrapMethod(EngineCore.LOGGING_COMPONENT_TYPE_NAME);\n\n\t\t\t\t\t// If the bootstrap method failed then throw an error\n\t\t\t\t\tif (!bootstrapSuccess) {\n\t\t\t\t\t\tthrow new GeneralError(EngineCore.CLASS_NAME, \"bootstrapFailed\", {\n\t\t\t\t\t\t\tclassName: instance.component.className(),\n\t\t\t\t\t\t\tinstanceType: instance.instanceType\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Now perform any custom bootstrap operations\n\t\t\tconst customBootstrap = this._customBootstrap;\n\t\t\tif (Is.function(customBootstrap)) {\n\t\t\t\tawait customBootstrap.call(this, this, this._context);\n\t\t\t}\n\n\t\t\tawait this.logInfo(I18n.formatMessage(`${nameofCamelCase<EngineCore>()}.bootstrapComplete`));\n\t\t}\n\t}\n\n\t/**\n\t * Initialise the context ID handlers.\n\t * @internal\n\t */\n\tprivate initialiseContextIdHandlers(): void {\n\t\tfor (const contextIdKey of this._contextIdKeys) {\n\t\t\tconst handlerType: string | undefined = this.getRegisteredInstanceTypeOptional(\n\t\t\t\t\"contextIdHandlerComponent\",\n\t\t\t\tcontextIdKey.componentFeatures\n\t\t\t);\n\t\t\tif (Is.stringValue(handlerType)) {\n\t\t\t\tconst handler = ComponentFactory.get<IContextIdHandler>(handlerType);\n\t\t\t\tContextIdHandlerFactory.register(contextIdKey.key, () => handler);\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileStateStorage.js","sourceRoot":"","sources":["../../../src/storage/fileStateStorage.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EA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AKG;IACI,KAAK,CAAC,IAAI,CAAC,UAAuB,EAAE,KAAQ;QAClD,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;YACzB,IAAI,CAAC;gBACJ,UAAU,CAAC,OAAO,CACjB,IAAI,CAAC,aAAa,CAAC,GAAG,kBAAmC,SAAS,EAAE;oBACnE,QAAQ,EAAE,IAAI,CAAC,SAAS;iBACxB,CAAC,CACF,CAAC;gBACF,IAAI,CAAC;oBACJ,MAAM,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;gBAChE,CAAC;gBAAC,MAAM,CAAC,CAAA,CAAC;gBACV,MAAM,SAAS,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC;YACjF,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACd,MAAM,IAAI,YAAY,CACrB,gBAAgB,CAAC,UAAU,EAC3B,cAAc,EACd,EAAE,QAAQ,EAAE,IAAI,CAAC,SAAS,EAAE,EAC5B,SAAS,CAAC,SAAS,CAAC,GAAG,CAAC,CACxB,CAAC;YACH,CAAC;QACF,CAAC;IACF,CAAC;IAED;;;;;OAKG;IACK,KAAK,CAAC,UAAU,CAAC,QAAgB;QACxC,IAAI,CAAC;YACJ,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,CAAC;YACnC,OAAO,KAAK,CAAC,MAAM,EAAE,CAAC;QACvB,CAAC;QAAC,MAAM,CAAC;YACR,OAAO,KAAK,CAAC;QACd,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { mkdir, readFile, stat, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { BaseError, GeneralError, Guards, I18n } from \"@twin.org/core\";\nimport type { IEngineCore, IEngineState, IEngineStateStorage } from \"@twin.org/engine-models\";\nimport { nameof, nameofCamelCase } from \"@twin.org/nameof\";\n\n/**\n * Store state in a file.\n */\nexport class FileStateStorage
|
|
1
|
+
{"version":3,"file":"fileStateStorage.js","sourceRoot":"","sources":["../../../src/storage/fileStateStorage.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAIvE;;GAEG;AACH,MAAM,OAAO,gBAAgB;IAG5B;;OAEG;IACI,MAAM,CAAU,UAAU,sBAAsC;IAEvE;;;OAGG;IACc,SAAS,CAAS;IAEnC;;;OAGG;IACc,aAAa,CAAU;IAExC;;;;OAIG;IACH,YAAY,QAAgB,EAAE,eAAwB,KAAK;QAC1D,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,UAAU,cAAoB,QAAQ,CAAC,CAAC;QAC5E,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;IACnC,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,IAAI,CAAC,UAAuB;QACxC,IAAI,CAAC;YACJ,UAAU,CAAC,OAAO,CACjB,IAAI,CAAC,aAAa,CAAC,GAAG,kBAAmC,UAAU,EAAE;gBACpE,QAAQ,EAAE,IAAI,CAAC,SAAS;aACxB,CAAC,CACF,CAAC;YACF,IAAI,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;gBAC3C,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;gBACvD,OAAO,IAA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,IAAI,CAAC,QAAQ,CAAC,CAAC;YACnC,OAAO,KAAK,CAAC,MAAM,EAAE,CAAC;QACvB,CAAC;QAAC,MAAM,CAAC;YACR,OAAO,KAAK,CAAC;QACd,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { mkdir, readFile, stat, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { BaseError, GeneralError, Guards, I18n } from \"@twin.org/core\";\nimport type { IEngineCore, IEngineState, IEngineStateStorage } from \"@twin.org/engine-models\";\nimport { nameof, nameofCamelCase } from \"@twin.org/nameof\";\n\n/**\n * Store state in a file.\n */\nexport class FileStateStorage<\n\tS extends IEngineState = IEngineState\n> implements IEngineStateStorage<S> {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<FileStateStorage>();\n\n\t/**\n\t * The filename to store the state.\n\t * @internal\n\t */\n\tprivate readonly _filename: string;\n\n\t/**\n\t * Readonly mode state file is not updated.\n\t * @internal\n\t */\n\tprivate readonly _readonlyMode: boolean;\n\n\t/**\n\t * Create a new instance of FileStateStorage.\n\t * @param filename The filename to store the state.\n\t * @param readonlyMode Whether the file is in read-only mode.\n\t */\n\tconstructor(filename: string, readonlyMode: boolean = false) {\n\t\tGuards.stringValue(FileStateStorage.CLASS_NAME, nameof(filename), filename);\n\t\tthis._filename = filename;\n\t\tthis._readonlyMode = readonlyMode;\n\t}\n\n\t/**\n\t * Method for loading the state.\n\t * @param engineCore The engine core to load the state for.\n\t * @returns The state of the engine or undefined if it doesn't exist.\n\t */\n\tpublic async load(engineCore: IEngineCore): Promise<S | undefined> {\n\t\ttry {\n\t\t\tengineCore.logInfo(\n\t\t\t\tI18n.formatMessage(`${nameofCamelCase<FileStateStorage>()}.loading`, {\n\t\t\t\t\tfilename: this._filename\n\t\t\t\t})\n\t\t\t);\n\t\t\tif (await this.fileExists(this._filename)) {\n\t\t\t\tconst content = await readFile(this._filename, \"utf8\");\n\t\t\t\treturn JSON.parse(content.toString()) as S;\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tFileStateStorage.CLASS_NAME,\n\t\t\t\t\"failedLoading\",\n\t\t\t\t{ filename: this._filename },\n\t\t\t\tBaseError.fromError(err)\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Method for saving the state.\n\t * @param engineCore The engine core to save the state for.\n\t * @param state The state of the engine to save.\n\t * @returns Nothing.\n\t */\n\tpublic async save(engineCore: IEngineCore, state: S): Promise<void> {\n\t\tif (!this._readonlyMode) {\n\t\t\ttry {\n\t\t\t\tengineCore.logInfo(\n\t\t\t\t\tI18n.formatMessage(`${nameofCamelCase<FileStateStorage>()}.saving`, {\n\t\t\t\t\t\tfilename: this._filename\n\t\t\t\t\t})\n\t\t\t\t);\n\t\t\t\ttry {\n\t\t\t\t\tawait mkdir(path.dirname(this._filename), { recursive: true });\n\t\t\t\t} catch {}\n\t\t\t\tawait writeFile(this._filename, JSON.stringify(state, undefined, \"\\t\"), \"utf8\");\n\t\t\t} catch (err) {\n\t\t\t\tthrow new GeneralError(\n\t\t\t\t\tFileStateStorage.CLASS_NAME,\n\t\t\t\t\t\"failedSaving\",\n\t\t\t\t\t{ filename: this._filename },\n\t\t\t\t\tBaseError.fromError(err)\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Does the specified file exist.\n\t * @param filename The filename to check for existence.\n\t * @returns True if the file exists.\n\t * @internal\n\t */\n\tprivate async fileExists(filename: string): Promise<boolean> {\n\t\ttry {\n\t\t\tconst stats = await stat(filename);\n\t\t\treturn stats.isFile();\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memoryStateStorage.js","sourceRoot":"","sources":["../../../src/storage/memoryStateStorage.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAItC;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAG9B;;OAEG;IACI,MAAM,CAAU,UAAU,wBAAwC;IAEzE;;;OAGG;IACc,aAAa,CAAU;IAExC;;;OAGG;IACK,YAAY,CAAK;IAEzB;;;;OAIG;IACH,YAAY,eAAwB,KAAK,EAAE,KAAS;QACnD,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;QAClC,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;IAC3B,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,IAAI,CAAC,UAAuB;QACxC,UAAU,CAAC,OAAO,CACjB,IAAI,CAAC,aAAa,CAAC,GAAG,oBAAqC,UAAU,EAAE;YACtE,QAAQ,EAAE,IAAI,CAAC,YAAY;SAC3B,CAAC,CACF,CAAC;QACF,OAAO,IAAI,CAAC,YAAY,CAAC;IAC1B,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,IAAI,CAAC,UAAuB,EAAE,KAAQ;QAClD,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;YACzB,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,oBAAqC,SAAS,CAAC,CAAC,CAAC;YAC1F,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;QAC3B,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { I18n } from \"@twin.org/core\";\nimport type { IEngineCore, IEngineState, IEngineStateStorage } from \"@twin.org/engine-models\";\nimport { nameof, nameofCamelCase } from \"@twin.org/nameof\";\n\n/**\n * Store state in memory.\n */\nexport class MemoryStateStorage
|
|
1
|
+
{"version":3,"file":"memoryStateStorage.js","sourceRoot":"","sources":["../../../src/storage/memoryStateStorage.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAItC;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAG9B;;OAEG;IACI,MAAM,CAAU,UAAU,wBAAwC;IAEzE;;;OAGG;IACc,aAAa,CAAU;IAExC;;;OAGG;IACK,YAAY,CAAK;IAEzB;;;;OAIG;IACH,YAAY,eAAwB,KAAK,EAAE,KAAS;QACnD,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;QAClC,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;IAC3B,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,IAAI,CAAC,UAAuB;QACxC,UAAU,CAAC,OAAO,CACjB,IAAI,CAAC,aAAa,CAAC,GAAG,oBAAqC,UAAU,EAAE;YACtE,QAAQ,EAAE,IAAI,CAAC,YAAY;SAC3B,CAAC,CACF,CAAC;QACF,OAAO,IAAI,CAAC,YAAY,CAAC;IAC1B,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,IAAI,CAAC,UAAuB,EAAE,KAAQ;QAClD,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;YACzB,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,oBAAqC,SAAS,CAAC,CAAC,CAAC;YAC1F,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;QAC3B,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { I18n } from \"@twin.org/core\";\nimport type { IEngineCore, IEngineState, IEngineStateStorage } from \"@twin.org/engine-models\";\nimport { nameof, nameofCamelCase } from \"@twin.org/nameof\";\n\n/**\n * Store state in memory.\n */\nexport class MemoryStateStorage<\n\tS extends IEngineState = IEngineState\n> implements IEngineStateStorage<S> {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<MemoryStateStorage>();\n\n\t/**\n\t * Readonly mode state file is not updated.\n\t * @internal\n\t */\n\tprivate readonly _readonlyMode: boolean;\n\n\t/**\n\t * The state object.\n\t * @internal\n\t */\n\tprivate _engineState?: S;\n\n\t/**\n\t * Create a new instance of MemoryStateStorage.\n\t * @param readonlyMode Whether the file is in read-only mode.\n\t * @param state The initial state.\n\t */\n\tconstructor(readonlyMode: boolean = false, state?: S) {\n\t\tthis._readonlyMode = readonlyMode;\n\t\tthis._engineState = state;\n\t}\n\n\t/**\n\t * Method for loading the state.\n\t * @param engineCore The engine core to load the state for.\n\t * @returns The state of the engine or undefined if it doesn't exist.\n\t */\n\tpublic async load(engineCore: IEngineCore): Promise<S | undefined> {\n\t\tengineCore.logInfo(\n\t\t\tI18n.formatMessage(`${nameofCamelCase<MemoryStateStorage>()}.loading`, {\n\t\t\t\tfilename: this._engineState\n\t\t\t})\n\t\t);\n\t\treturn this._engineState;\n\t}\n\n\t/**\n\t * Method for saving the state.\n\t * @param engineCore The engine core to save the state for.\n\t * @param state The state of the engine to save.\n\t * @returns Nothing.\n\t */\n\tpublic async save(engineCore: IEngineCore, state: S): Promise<void> {\n\t\tif (!this._readonlyMode) {\n\t\t\tengineCore.logInfo(I18n.formatMessage(`${nameofCamelCase<MemoryStateStorage>()}.saving`));\n\t\t\tthis._engineState = state;\n\t\t}\n\t}\n}\n"]}
|
package/docs/changelog.md
CHANGED
|
@@ -1,4 +1,32 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.0.3-next.27](https://github.com/twinfoundation/engine/compare/engine-core-v0.0.3-next.26...engine-core-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-models bumped from 0.0.3-next.26 to 0.0.3-next.27
|
|
16
|
+
|
|
17
|
+
## [0.0.3-next.26](https://github.com/twinfoundation/engine/compare/engine-core-v0.0.3-next.25...engine-core-v0.0.3-next.26) (2026-03-05)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Miscellaneous Chores
|
|
21
|
+
|
|
22
|
+
* **engine-core:** Synchronize repo versions
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Dependencies
|
|
26
|
+
|
|
27
|
+
* The following workspace dependencies were updated
|
|
28
|
+
* dependencies
|
|
29
|
+
* @twin.org/engine-models bumped from 0.0.3-next.25 to 0.0.3-next.26
|
|
2
30
|
|
|
3
31
|
## [0.0.3-next.25](https://github.com/twinfoundation/engine/compare/engine-core-v0.0.3-next.24...engine-core-v0.0.3-next.25) (2026-03-02)
|
|
4
32
|
|
package/docs/examples.md
CHANGED
|
@@ -1 +1,156 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Engine Core Examples
|
|
2
|
+
|
|
3
|
+
These examples focus on common runtime patterns such as lifecycle control, cloning, state storage, and module loading.
|
|
4
|
+
|
|
5
|
+
## EngineCore
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { EngineCore, MemoryStateStorage } from '@twin.org/engine-core';
|
|
9
|
+
import type { IEngineCoreConfig, IEngineState } from '@twin.org/engine-models';
|
|
10
|
+
|
|
11
|
+
interface AppState extends IEngineState {
|
|
12
|
+
runCount?: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const config: IEngineCoreConfig = {
|
|
16
|
+
debug: true,
|
|
17
|
+
silent: false,
|
|
18
|
+
types: {}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const stateStorage = new MemoryStateStorage<AppState>();
|
|
22
|
+
const engineCore = new EngineCore<IEngineCoreConfig, AppState>({
|
|
23
|
+
config,
|
|
24
|
+
stateStorage,
|
|
25
|
+
skipBootstrap: true
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
engineCore.addTypeInitialiser('loggingConnector', '@twin.org/engine-types', 'initLoggingConnector');
|
|
29
|
+
console.log(engineCore.getTypeConfig('loggingConnector')?.length ?? 0); // 0
|
|
30
|
+
|
|
31
|
+
engineCore.addContextIdKey('tenant', ['tenant']);
|
|
32
|
+
engineCore.addContextId('tenant', 'tenant-a');
|
|
33
|
+
|
|
34
|
+
console.log(engineCore.getContextIdKeys()); // ["tenant"]
|
|
35
|
+
console.log(engineCore.getContextIds()); // { tenant: "tenant-a" }
|
|
36
|
+
console.log(engineCore.isPrimary()); // true
|
|
37
|
+
console.log(engineCore.isClone()); // false
|
|
38
|
+
console.log(engineCore.isStarted()); // false
|
|
39
|
+
|
|
40
|
+
await engineCore.start(true);
|
|
41
|
+
console.log(engineCore.isStarted()); // true
|
|
42
|
+
|
|
43
|
+
await engineCore.logInfo('Engine started for tenant-a');
|
|
44
|
+
|
|
45
|
+
const state = engineCore.getState();
|
|
46
|
+
state.runCount = (state.runCount ?? 0) + 1;
|
|
47
|
+
engineCore.setStateDirty();
|
|
48
|
+
|
|
49
|
+
console.log(engineCore.getConfig().debug); // true
|
|
50
|
+
console.log(engineCore.getRegisteredInstances()); // { loggingConnector: [...], loggingComponent: [...] }
|
|
51
|
+
console.log(engineCore.getRegisteredInstanceType('loggingComponent')); // "engine-logging-service"
|
|
52
|
+
console.log(engineCore.getRegisteredInstanceTypeOptional('hostingComponent')); // undefined
|
|
53
|
+
|
|
54
|
+
await engineCore.stop();
|
|
55
|
+
console.log(engineCore.isStarted()); // false
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
import { BaseError, GeneralError } from '@twin.org/core';
|
|
60
|
+
import { EngineCore } from '@twin.org/engine-core';
|
|
61
|
+
|
|
62
|
+
const engineCore = new EngineCore({
|
|
63
|
+
config: { debug: false, silent: true, types: {} },
|
|
64
|
+
skipBootstrap: true
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const wrapped = new GeneralError(
|
|
68
|
+
EngineCore.CLASS_NAME,
|
|
69
|
+
'sampleFailure',
|
|
70
|
+
{ area: 'examples' },
|
|
71
|
+
BaseError.fromError(new Error('Sample failure'))
|
|
72
|
+
);
|
|
73
|
+
await engineCore.logError(wrapped);
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
import { EngineCore } from '@twin.org/engine-core';
|
|
78
|
+
|
|
79
|
+
const primary = new EngineCore({
|
|
80
|
+
config: { debug: false, silent: true, types: {} },
|
|
81
|
+
skipBootstrap: true
|
|
82
|
+
});
|
|
83
|
+
primary.addContextIdKey('node', ['node']);
|
|
84
|
+
|
|
85
|
+
const cloneData = primary.getCloneData();
|
|
86
|
+
|
|
87
|
+
const clone = new EngineCore({ config: { debug: false, silent: true, types: {} } });
|
|
88
|
+
clone.populateClone(cloneData, { node: 'node-1', tenant: 'tenant-a' }, true);
|
|
89
|
+
|
|
90
|
+
console.log(clone.isClone()); // true
|
|
91
|
+
console.log(clone.getContextIds()); // { node: "node-1", tenant: "tenant-a" }
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## FileStateStorage
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
import { EngineCore, FileStateStorage } from '@twin.org/engine-core';
|
|
98
|
+
|
|
99
|
+
const engineCore = new EngineCore({
|
|
100
|
+
config: { debug: false, silent: true, types: {} },
|
|
101
|
+
skipBootstrap: true
|
|
102
|
+
});
|
|
103
|
+
const fileStorage = new FileStateStorage('./data/engine-state.json');
|
|
104
|
+
|
|
105
|
+
await fileStorage.save(engineCore, { ready: true });
|
|
106
|
+
|
|
107
|
+
const loaded = await fileStorage.load(engineCore);
|
|
108
|
+
console.log(loaded); // { ready: true }
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## MemoryStateStorage
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
import { EngineCore, MemoryStateStorage } from '@twin.org/engine-core';
|
|
115
|
+
|
|
116
|
+
const engineCore = new EngineCore({
|
|
117
|
+
config: { debug: false, silent: true, types: {} },
|
|
118
|
+
skipBootstrap: true
|
|
119
|
+
});
|
|
120
|
+
const memoryStorage = new MemoryStateStorage(false, { retries: 1 });
|
|
121
|
+
|
|
122
|
+
console.log(await memoryStorage.load(engineCore)); // { retries: 1 }
|
|
123
|
+
|
|
124
|
+
await memoryStorage.save(engineCore, { retries: 2 });
|
|
125
|
+
console.log(await memoryStorage.load(engineCore)); // { retries: 2 }
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## EngineModuleHelper
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
import { EngineCore, EngineModuleHelper } from '@twin.org/engine-core';
|
|
132
|
+
import type { IEngineModuleConfig } from '@twin.org/engine-models';
|
|
133
|
+
|
|
134
|
+
const engineCore = new EngineCore({
|
|
135
|
+
config: { debug: false, silent: true, types: {} },
|
|
136
|
+
skipBootstrap: true
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
const moduleConfig: IEngineModuleConfig = {
|
|
140
|
+
moduleName: '@twin.org/logging-service',
|
|
141
|
+
className: 'LoggingService',
|
|
142
|
+
dependencies: [
|
|
143
|
+
{
|
|
144
|
+
propertyName: 'loggingConnectorType',
|
|
145
|
+
componentName: 'loggingConnector',
|
|
146
|
+
isOptional: false
|
|
147
|
+
}
|
|
148
|
+
],
|
|
149
|
+
config: {
|
|
150
|
+
level: 'info'
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const component = await EngineModuleHelper.loadComponent<unknown>(engineCore, moduleConfig);
|
|
155
|
+
console.log(component !== undefined); // true
|
|
156
|
+
```
|
|
@@ -38,7 +38,7 @@ The options for the engine.
|
|
|
38
38
|
|
|
39
39
|
## Properties
|
|
40
40
|
|
|
41
|
-
### LOGGING\_COMPONENT\_TYPE\_NAME
|
|
41
|
+
### LOGGING\_COMPONENT\_TYPE\_NAME {#logging_component_type_name}
|
|
42
42
|
|
|
43
43
|
> `readonly` `static` **LOGGING\_COMPONENT\_TYPE\_NAME**: `string` = `"engine-logging-service"`
|
|
44
44
|
|
|
@@ -46,7 +46,7 @@ Name for the engine logger component, used for direct console logging.
|
|
|
46
46
|
|
|
47
47
|
***
|
|
48
48
|
|
|
49
|
-
### LOGGING\_CONNECTOR\_TYPE\_NAME
|
|
49
|
+
### LOGGING\_CONNECTOR\_TYPE\_NAME {#logging_connector_type_name}
|
|
50
50
|
|
|
51
51
|
> `readonly` `static` **LOGGING\_CONNECTOR\_TYPE\_NAME**: `string` = `"engine-logging-connector"`
|
|
52
52
|
|
|
@@ -54,7 +54,7 @@ Name for the engine logger connector, used for direct console logging.
|
|
|
54
54
|
|
|
55
55
|
***
|
|
56
56
|
|
|
57
|
-
### CLASS\_NAME
|
|
57
|
+
### CLASS\_NAME {#class_name}
|
|
58
58
|
|
|
59
59
|
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
60
60
|
|
|
@@ -62,7 +62,7 @@ Runtime name for the class.
|
|
|
62
62
|
|
|
63
63
|
***
|
|
64
64
|
|
|
65
|
-
### \_context
|
|
65
|
+
### \_context {#_context}
|
|
66
66
|
|
|
67
67
|
> `protected` **\_context**: `IEngineCoreContext`\<`C`, `S`\>
|
|
68
68
|
|
|
@@ -70,7 +70,7 @@ The core context.
|
|
|
70
70
|
|
|
71
71
|
***
|
|
72
72
|
|
|
73
|
-
### \_contextIdKeys
|
|
73
|
+
### \_contextIdKeys {#_contextidkeys}
|
|
74
74
|
|
|
75
75
|
> `protected` `readonly` **\_contextIdKeys**: `object`[]
|
|
76
76
|
|
|
@@ -86,15 +86,15 @@ The context ID keys.
|
|
|
86
86
|
|
|
87
87
|
***
|
|
88
88
|
|
|
89
|
-
### \_contextIds?
|
|
89
|
+
### \_contextIds? {#_contextids}
|
|
90
90
|
|
|
91
|
-
> `protected` `optional` **\_contextIds
|
|
91
|
+
> `protected` `optional` **\_contextIds?**: `IContextIds`
|
|
92
92
|
|
|
93
93
|
The context IDs.
|
|
94
94
|
|
|
95
95
|
## Methods
|
|
96
96
|
|
|
97
|
-
### addTypeInitialiser()
|
|
97
|
+
### addTypeInitialiser() {#addtypeinitialiser}
|
|
98
98
|
|
|
99
99
|
> **addTypeInitialiser**(`type`, `module`, `method`): `void`
|
|
100
100
|
|
|
@@ -130,9 +130,9 @@ The name of the method to call.
|
|
|
130
130
|
|
|
131
131
|
***
|
|
132
132
|
|
|
133
|
-
### getTypeConfig()
|
|
133
|
+
### getTypeConfig() {#gettypeconfig}
|
|
134
134
|
|
|
135
|
-
> **getTypeConfig**(`type`): `
|
|
135
|
+
> **getTypeConfig**(`type`): `IEngineCoreTypeConfig`[] \| `undefined`
|
|
136
136
|
|
|
137
137
|
Get the type config for a specific type.
|
|
138
138
|
|
|
@@ -146,7 +146,7 @@ The type to get the config for.
|
|
|
146
146
|
|
|
147
147
|
#### Returns
|
|
148
148
|
|
|
149
|
-
`
|
|
149
|
+
`IEngineCoreTypeConfig`[] \| `undefined`
|
|
150
150
|
|
|
151
151
|
The type config or undefined if not found.
|
|
152
152
|
|
|
@@ -156,7 +156,7 @@ The type config or undefined if not found.
|
|
|
156
156
|
|
|
157
157
|
***
|
|
158
158
|
|
|
159
|
-
### addContextIdKey()
|
|
159
|
+
### addContextIdKey() {#addcontextidkey}
|
|
160
160
|
|
|
161
161
|
> **addContextIdKey**(`key`, `componentFeatures`): `void`
|
|
162
162
|
|
|
@@ -186,7 +186,7 @@ The component features for the context ID handler.
|
|
|
186
186
|
|
|
187
187
|
***
|
|
188
188
|
|
|
189
|
-
### getContextIdKeys()
|
|
189
|
+
### getContextIdKeys() {#getcontextidkeys}
|
|
190
190
|
|
|
191
191
|
> **getContextIdKeys**(): `string`[]
|
|
192
192
|
|
|
@@ -204,7 +204,7 @@ The context IDs keys.
|
|
|
204
204
|
|
|
205
205
|
***
|
|
206
206
|
|
|
207
|
-
### addContextId()
|
|
207
|
+
### addContextId() {#addcontextid}
|
|
208
208
|
|
|
209
209
|
> **addContextId**(`key`, `value`): `void`
|
|
210
210
|
|
|
@@ -234,15 +234,15 @@ The context ID value.
|
|
|
234
234
|
|
|
235
235
|
***
|
|
236
236
|
|
|
237
|
-
### getContextIds()
|
|
237
|
+
### getContextIds() {#getcontextids}
|
|
238
238
|
|
|
239
|
-
> **getContextIds**(): `
|
|
239
|
+
> **getContextIds**(): `IContextIds` \| `undefined`
|
|
240
240
|
|
|
241
241
|
Get the context IDs for the engine.
|
|
242
242
|
|
|
243
243
|
#### Returns
|
|
244
244
|
|
|
245
|
-
`
|
|
245
|
+
`IContextIds` \| `undefined`
|
|
246
246
|
|
|
247
247
|
The context IDs or undefined if none are set.
|
|
248
248
|
|
|
@@ -252,7 +252,7 @@ The context IDs or undefined if none are set.
|
|
|
252
252
|
|
|
253
253
|
***
|
|
254
254
|
|
|
255
|
-
### start()
|
|
255
|
+
### start() {#start}
|
|
256
256
|
|
|
257
257
|
> **start**(`skipComponentStart?`): `Promise`\<`void`\>
|
|
258
258
|
|
|
@@ -278,7 +278,7 @@ Nothing.
|
|
|
278
278
|
|
|
279
279
|
***
|
|
280
280
|
|
|
281
|
-
### stop()
|
|
281
|
+
### stop() {#stop}
|
|
282
282
|
|
|
283
283
|
> **stop**(): `Promise`\<`void`\>
|
|
284
284
|
|
|
@@ -296,7 +296,7 @@ Nothing.
|
|
|
296
296
|
|
|
297
297
|
***
|
|
298
298
|
|
|
299
|
-
### isStarted()
|
|
299
|
+
### isStarted() {#isstarted}
|
|
300
300
|
|
|
301
301
|
> **isStarted**(): `boolean`
|
|
302
302
|
|
|
@@ -314,7 +314,7 @@ True if the engine is started.
|
|
|
314
314
|
|
|
315
315
|
***
|
|
316
316
|
|
|
317
|
-
### isPrimary()
|
|
317
|
+
### isPrimary() {#isprimary}
|
|
318
318
|
|
|
319
319
|
> **isPrimary**(): `boolean`
|
|
320
320
|
|
|
@@ -332,7 +332,7 @@ True if the engine is the primary instance.
|
|
|
332
332
|
|
|
333
333
|
***
|
|
334
334
|
|
|
335
|
-
### isClone()
|
|
335
|
+
### isClone() {#isclone}
|
|
336
336
|
|
|
337
337
|
> **isClone**(): `boolean`
|
|
338
338
|
|
|
@@ -350,7 +350,7 @@ True if the engine instance is a clone.
|
|
|
350
350
|
|
|
351
351
|
***
|
|
352
352
|
|
|
353
|
-
### logInfo()
|
|
353
|
+
### logInfo() {#loginfo}
|
|
354
354
|
|
|
355
355
|
> **logInfo**(`message`): `Promise`\<`void`\>
|
|
356
356
|
|
|
@@ -374,7 +374,7 @@ The message to log.
|
|
|
374
374
|
|
|
375
375
|
***
|
|
376
376
|
|
|
377
|
-
### logError()
|
|
377
|
+
### logError() {#logerror}
|
|
378
378
|
|
|
379
379
|
> **logError**(`error`): `Promise`\<`void`\>
|
|
380
380
|
|
|
@@ -398,7 +398,7 @@ The error to log.
|
|
|
398
398
|
|
|
399
399
|
***
|
|
400
400
|
|
|
401
|
-
### getConfig()
|
|
401
|
+
### getConfig() {#getconfig}
|
|
402
402
|
|
|
403
403
|
> **getConfig**(): `C`
|
|
404
404
|
|
|
@@ -416,7 +416,7 @@ The config for the engine.
|
|
|
416
416
|
|
|
417
417
|
***
|
|
418
418
|
|
|
419
|
-
### getState()
|
|
419
|
+
### getState() {#getstate}
|
|
420
420
|
|
|
421
421
|
> **getState**(): `S`
|
|
422
422
|
|
|
@@ -434,7 +434,7 @@ The state of the engine.
|
|
|
434
434
|
|
|
435
435
|
***
|
|
436
436
|
|
|
437
|
-
### setStateDirty()
|
|
437
|
+
### setStateDirty() {#setstatedirty}
|
|
438
438
|
|
|
439
439
|
> **setStateDirty**(): `void`
|
|
440
440
|
|
|
@@ -450,7 +450,7 @@ Set the state to dirty so it gets saved.
|
|
|
450
450
|
|
|
451
451
|
***
|
|
452
452
|
|
|
453
|
-
### getRegisteredInstances()
|
|
453
|
+
### getRegisteredInstances() {#getregisteredinstances}
|
|
454
454
|
|
|
455
455
|
> **getRegisteredInstances**(): `object`
|
|
456
456
|
|
|
@@ -468,7 +468,7 @@ The registered instances.
|
|
|
468
468
|
|
|
469
469
|
***
|
|
470
470
|
|
|
471
|
-
### getRegisteredInstanceType()
|
|
471
|
+
### getRegisteredInstanceType() {#getregisteredinstancetype}
|
|
472
472
|
|
|
473
473
|
> **getRegisteredInstanceType**(`componentConnectorType`, `features?`): `string`
|
|
474
474
|
|
|
@@ -504,9 +504,9 @@ If a matching instance was not found.
|
|
|
504
504
|
|
|
505
505
|
***
|
|
506
506
|
|
|
507
|
-
### getRegisteredInstanceTypeOptional()
|
|
507
|
+
### getRegisteredInstanceTypeOptional() {#getregisteredinstancetypeoptional}
|
|
508
508
|
|
|
509
|
-
> **getRegisteredInstanceTypeOptional**(`componentConnectorType`, `features?`): `
|
|
509
|
+
> **getRegisteredInstanceTypeOptional**(`componentConnectorType`, `features?`): `string` \| `undefined`
|
|
510
510
|
|
|
511
511
|
Get the registered instance type for the component/connector if it exists.
|
|
512
512
|
|
|
@@ -526,7 +526,7 @@ The requested features of the component, if not specified the default entry will
|
|
|
526
526
|
|
|
527
527
|
#### Returns
|
|
528
528
|
|
|
529
|
-
`
|
|
529
|
+
`string` \| `undefined`
|
|
530
530
|
|
|
531
531
|
The instance type matching the criteria if one is registered.
|
|
532
532
|
|
|
@@ -536,7 +536,7 @@ The instance type matching the criteria if one is registered.
|
|
|
536
536
|
|
|
537
537
|
***
|
|
538
538
|
|
|
539
|
-
### getCloneData()
|
|
539
|
+
### getCloneData() {#getclonedata}
|
|
540
540
|
|
|
541
541
|
> **getCloneData**(): `IEngineCoreClone`\<`C`, `S`\>
|
|
542
542
|
|
|
@@ -554,7 +554,7 @@ The clone data.
|
|
|
554
554
|
|
|
555
555
|
***
|
|
556
556
|
|
|
557
|
-
### populateClone()
|
|
557
|
+
### populateClone() {#populateclone}
|
|
558
558
|
|
|
559
559
|
> **populateClone**(`cloneData`, `contextIds?`, `silent?`): `void`
|
|
560
560
|
|
|
@@ -14,7 +14,7 @@ Helper class for engine modules.
|
|
|
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
|
-
### loadComponent()
|
|
25
|
+
### loadComponent() {#loadcomponent}
|
|
26
26
|
|
|
27
27
|
> `static` **loadComponent**\<`T`\>(`engineCore`, `engineModuleConfig`): `Promise`\<`T`\>
|
|
28
28
|
|
|
@@ -16,7 +16,7 @@ Store state in a file.
|
|
|
16
16
|
|
|
17
17
|
### Constructor
|
|
18
18
|
|
|
19
|
-
> **new FileStateStorage**\<`S`\>(`filename`, `readonlyMode
|
|
19
|
+
> **new FileStateStorage**\<`S`\>(`filename`, `readonlyMode?`): `FileStateStorage`\<`S`\>
|
|
20
20
|
|
|
21
21
|
Create a new instance of FileStateStorage.
|
|
22
22
|
|
|
@@ -28,7 +28,7 @@ Create a new instance of FileStateStorage.
|
|
|
28
28
|
|
|
29
29
|
The filename to store the state.
|
|
30
30
|
|
|
31
|
-
##### readonlyMode
|
|
31
|
+
##### readonlyMode?
|
|
32
32
|
|
|
33
33
|
`boolean` = `false`
|
|
34
34
|
|
|
@@ -40,7 +40,7 @@ Whether the file is in read-only mode.
|
|
|
40
40
|
|
|
41
41
|
## Properties
|
|
42
42
|
|
|
43
|
-
### CLASS\_NAME
|
|
43
|
+
### CLASS\_NAME {#class_name}
|
|
44
44
|
|
|
45
45
|
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
46
46
|
|
|
@@ -48,9 +48,9 @@ Runtime name for the class.
|
|
|
48
48
|
|
|
49
49
|
## Methods
|
|
50
50
|
|
|
51
|
-
### load()
|
|
51
|
+
### load() {#load}
|
|
52
52
|
|
|
53
|
-
> **load**(`engineCore`): `Promise`\<`
|
|
53
|
+
> **load**(`engineCore`): `Promise`\<`S` \| `undefined`\>
|
|
54
54
|
|
|
55
55
|
Method for loading the state.
|
|
56
56
|
|
|
@@ -64,7 +64,7 @@ The engine core to load the state for.
|
|
|
64
64
|
|
|
65
65
|
#### Returns
|
|
66
66
|
|
|
67
|
-
`Promise`\<`
|
|
67
|
+
`Promise`\<`S` \| `undefined`\>
|
|
68
68
|
|
|
69
69
|
The state of the engine or undefined if it doesn't exist.
|
|
70
70
|
|
|
@@ -74,7 +74,7 @@ The state of the engine or undefined if it doesn't exist.
|
|
|
74
74
|
|
|
75
75
|
***
|
|
76
76
|
|
|
77
|
-
### save()
|
|
77
|
+
### save() {#save}
|
|
78
78
|
|
|
79
79
|
> **save**(`engineCore`, `state`): `Promise`\<`void`\>
|
|
80
80
|
|
|
@@ -16,13 +16,13 @@ Store state in memory.
|
|
|
16
16
|
|
|
17
17
|
### Constructor
|
|
18
18
|
|
|
19
|
-
> **new MemoryStateStorage**\<`S`\>(`readonlyMode
|
|
19
|
+
> **new MemoryStateStorage**\<`S`\>(`readonlyMode?`, `state?`): `MemoryStateStorage`\<`S`\>
|
|
20
20
|
|
|
21
21
|
Create a new instance of MemoryStateStorage.
|
|
22
22
|
|
|
23
23
|
#### Parameters
|
|
24
24
|
|
|
25
|
-
##### readonlyMode
|
|
25
|
+
##### readonlyMode?
|
|
26
26
|
|
|
27
27
|
`boolean` = `false`
|
|
28
28
|
|
|
@@ -40,7 +40,7 @@ The initial state.
|
|
|
40
40
|
|
|
41
41
|
## Properties
|
|
42
42
|
|
|
43
|
-
### CLASS\_NAME
|
|
43
|
+
### CLASS\_NAME {#class_name}
|
|
44
44
|
|
|
45
45
|
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
46
46
|
|
|
@@ -48,9 +48,9 @@ Runtime name for the class.
|
|
|
48
48
|
|
|
49
49
|
## Methods
|
|
50
50
|
|
|
51
|
-
### load()
|
|
51
|
+
### load() {#load}
|
|
52
52
|
|
|
53
|
-
> **load**(`engineCore`): `Promise`\<`
|
|
53
|
+
> **load**(`engineCore`): `Promise`\<`S` \| `undefined`\>
|
|
54
54
|
|
|
55
55
|
Method for loading the state.
|
|
56
56
|
|
|
@@ -64,7 +64,7 @@ The engine core to load the state for.
|
|
|
64
64
|
|
|
65
65
|
#### Returns
|
|
66
66
|
|
|
67
|
-
`Promise`\<`
|
|
67
|
+
`Promise`\<`S` \| `undefined`\>
|
|
68
68
|
|
|
69
69
|
The state of the engine or undefined if it doesn't exist.
|
|
70
70
|
|
|
@@ -74,7 +74,7 @@ The state of the engine or undefined if it doesn't exist.
|
|
|
74
74
|
|
|
75
75
|
***
|
|
76
76
|
|
|
77
|
-
### save()
|
|
77
|
+
### save() {#save}
|
|
78
78
|
|
|
79
79
|
> **save**(`engineCore`, `state`): `Promise`\<`void`\>
|
|
80
80
|
|
|
@@ -14,33 +14,33 @@ The options for creating engine core.
|
|
|
14
14
|
|
|
15
15
|
## Properties
|
|
16
16
|
|
|
17
|
-
### config?
|
|
17
|
+
### config? {#config}
|
|
18
18
|
|
|
19
|
-
> `optional` **config
|
|
19
|
+
> `optional` **config?**: `C`
|
|
20
20
|
|
|
21
21
|
The engine core config.
|
|
22
22
|
|
|
23
23
|
***
|
|
24
24
|
|
|
25
|
-
### stateStorage?
|
|
25
|
+
### stateStorage? {#statestorage}
|
|
26
26
|
|
|
27
|
-
> `optional` **stateStorage
|
|
27
|
+
> `optional` **stateStorage?**: `IEngineStateStorage`\<`S`\>
|
|
28
28
|
|
|
29
29
|
The state storage component.
|
|
30
30
|
|
|
31
31
|
***
|
|
32
32
|
|
|
33
|
-
### skipBootstrap?
|
|
33
|
+
### skipBootstrap? {#skipbootstrap}
|
|
34
34
|
|
|
35
|
-
> `optional` **skipBootstrap
|
|
35
|
+
> `optional` **skipBootstrap?**: `boolean`
|
|
36
36
|
|
|
37
37
|
Skip the bootstrap process, useful for additional engine instances.
|
|
38
38
|
|
|
39
39
|
***
|
|
40
40
|
|
|
41
|
-
### populateTypeInitialisers
|
|
41
|
+
### populateTypeInitialisers? {#populatetypeinitialisers}
|
|
42
42
|
|
|
43
|
-
> `optional` **populateTypeInitialisers
|
|
43
|
+
> `optional` **populateTypeInitialisers?**: (`engineCore`, `context`) => `void`
|
|
44
44
|
|
|
45
45
|
Populate the type initialisers for the engine.
|
|
46
46
|
|
|
@@ -60,9 +60,9 @@ Populate the type initialisers for the engine.
|
|
|
60
60
|
|
|
61
61
|
***
|
|
62
62
|
|
|
63
|
-
### customBootstrap
|
|
63
|
+
### customBootstrap? {#custombootstrap}
|
|
64
64
|
|
|
65
|
-
> `optional` **customBootstrap
|
|
65
|
+
> `optional` **customBootstrap?**: (`engineCore`, `context`) => `Promise`\<`void`\>
|
|
66
66
|
|
|
67
67
|
Custom bootstrap method for the engine.
|
|
68
68
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/engine-core",
|
|
3
|
-
"version": "0.0.3-next.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.0.3-next.27",
|
|
4
|
+
"description": "Core runtime lifecycle and state orchestration for engine instances.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/twinfoundation/engine.git",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"@twin.org/core": "next",
|
|
19
19
|
"@twin.org/crypto": "next",
|
|
20
20
|
"@twin.org/data-core": "next",
|
|
21
|
-
"@twin.org/engine-models": "0.0.3-next.
|
|
21
|
+
"@twin.org/engine-models": "0.0.3-next.27",
|
|
22
22
|
"@twin.org/entity": "next",
|
|
23
23
|
"@twin.org/logging-connector-console": "next",
|
|
24
24
|
"@twin.org/logging-models": "next",
|