@twin.org/node-core 0.9.2-next.8 → 0.9.2
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/dist/es/builders/engineEnvBuilder.js +182 -87
- package/dist/es/builders/engineEnvBuilder.js.map +1 -1
- package/dist/es/builders/engineServerEnvBuilder.js +50 -14
- package/dist/es/builders/engineServerEnvBuilder.js.map +1 -1
- package/dist/es/builders/extensionsBuilder.js +5 -4
- package/dist/es/builders/extensionsBuilder.js.map +1 -1
- package/dist/es/builders/helper/envHelpers.js +60 -82
- package/dist/es/builders/helper/envHelpers.js.map +1 -1
- package/dist/es/cli.js +2 -1
- package/dist/es/cli.js.map +1 -1
- package/dist/es/commands/bootstrapDev.js +5 -5
- package/dist/es/commands/bootstrapDev.js.map +1 -1
- package/dist/es/commands/userCreate.js +8 -3
- package/dist/es/commands/userCreate.js.map +1 -1
- package/dist/es/commands/userUpdate.js +5 -2
- package/dist/es/commands/userUpdate.js.map +1 -1
- package/dist/es/models/IEngineEnvironmentVariables.js.map +1 -1
- package/dist/es/models/IEngineServerEnvironmentVariables.js.map +1 -1
- package/dist/es/models/engineEnvironmentVariableKeys.js +27 -0
- package/dist/es/models/engineEnvironmentVariableKeys.js.map +1 -1
- package/dist/es/models/engineServerEnvironmentVariableKeys.js +4 -1
- package/dist/es/models/engineServerEnvironmentVariableKeys.js.map +1 -1
- package/dist/es/node.js +3 -7
- package/dist/es/node.js.map +1 -1
- package/dist/es/start.js +3 -2
- package/dist/es/start.js.map +1 -1
- package/dist/types/builders/engineEnvBuilder.d.ts +9 -2
- package/dist/types/builders/helper/envHelpers.d.ts +83 -22
- package/dist/types/models/IEngineEnvironmentVariables.d.ts +113 -2
- package/dist/types/models/IEngineServerEnvironmentVariables.d.ts +12 -0
- package/docs/changelog.md +96 -0
- package/docs/reference/functions/{isTelemetryRequired.md → isTelemetryEnabled.md} +3 -3
- package/docs/reference/functions/isTracingEnabled.md +20 -0
- package/docs/reference/index.md +2 -1
- package/docs/reference/interfaces/IEngineEnvironmentVariables.md +236 -2
- package/docs/reference/interfaces/IEngineServerEnvironmentVariables.md +24 -0
- package/locales/en.json +1 -0
- package/package.json +34 -33
package/dist/es/start.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start.js","sourceRoot":"","sources":["../../src/start.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAClF,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EACN,iBAAiB,EAGjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,EAAE,wBAAwB,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAC9F,OAAO,EACN,0BAA0B,EAC1B,gCAAgC,EAChC,kBAAkB,EAClB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAQ1C;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CAC1B,WAAqC,EACrC,gBAAmC,EACnC,OAA4D,EAC5D,UAAwB,EACxB,sBAA6E;IAS7E,MAAM,0BAA0B,GAAG,OAAO,CAAC,0BAA0B,EAAE,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;IACxF,MAAM,wBAAwB,GAAG,OAAO,CAAC,wBAAwB,EAAE,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;IAEpF,MAAM,qBAAqB,GAAG,UAAU,EAAE,UAAU,EAAE,qBAAqB,IAAI,IAAI,CAAC;IACpF,MAAM,oBAAoB,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AAW,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC;gBACzE,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YAC5B,CAAC;QACF,CAAC;QACD,MAAM,GAAG,IAAI,CAAC;IACf,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE;IAEjC,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7B,OAAO;IACR,CAAC;IAED,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7B,MAAM,KAAK,GAAG,UAAU,CAAC,QAAQ,EAAE,CAAC;QACpC,IAAI,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,kBAAkB,CAAC,EAAE,CAAC;YAC9C,UAAU,CAAC,OAAO,CACjB,IAAI,CAAC,aAAa,CAAC,uCAAuC,EAAE;gBAC3D,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC;gBACvB,cAAc,EAAE,KAAK,CAAC,kBAAkB;aACxC,CAAC,CACF,CAAC;YACF,MAAM,oBAAoB,CAAC,MAAM,CAAC;gBACjC,EAAE,EAAE,UAAU,CAAC,CAAC,CAAC;gBACjB,cAAc,EAAE,KAAK,CAAC,kBAAkB;aACxC,CAAC,CAAC;YACH,OAAO;QACR,CAAC;IACF,CAAC;IAED,MAAM,IAAI,YAAY,CAAC,MAAM,EAAE,8BAA8B,EAAE;QAC9D,SAAS,EAAE,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;KAChC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { ITenantAdminComponent } from \"@twin.org/api-models\";\nimport { ContextIdKeys, ContextIdStore } from \"@twin.org/context\";\nimport { Coerce, ComponentFactory, GeneralError, I18n, Is } from \"@twin.org/core\";\nimport { Engine } from \"@twin.org/engine\";\nimport { FileStateStorage } from \"@twin.org/engine-core\";\nimport {\n\tEngineCoreFactory,\n\ttype IEngineCore,\n\ttype IEngineCoreConfig\n} from \"@twin.org/engine-models\";\nimport { EngineServer } from \"@twin.org/engine-server\";\nimport type { IEngineServerConfig } from \"@twin.org/engine-server-types\";\nimport { BlobStorageConnectorType, EntityStorageConnectorType } from \"@twin.org/engine-types\";\nimport {\n\textensionsInitialiseEngine,\n\textensionsInitialiseEngineServer,\n\tshutdownExtensions\n} from \"./builders/extensionsBuilder.js\";\nimport { executeCommand } from \"./cli.js\";\nimport type { ICliCommand } from \"./models/ICliCommand.js\";\nimport type { IEngineEnvironmentVariables } from \"./models/IEngineEnvironmentVariables.js\";\nimport type { IEnvironmentVariables } from \"./models/IEnvironmentVariables.js\";\nimport type { INodeEngineConfig } from \"./models/INodeEngineConfig.js\";\nimport type { INodeEngineState } from \"./models/INodeEngineState.js\";\nimport type { INodeOptions } from \"./models/INodeOptions.js\";\n\n/**\n * Start the engine server.\n * @param nodeOptions Optional run options for the engine server.\n * @param nodeEngineConfig The configuration for the engine server.\n * @param envVars The environment variables.\n * @param cliCommand The constructed CLI command (optional).\n * @param availableContextIdKeys The context ID keys available for operation.\n * @returns The engine server.\n */\nexport async function start(\n\tnodeOptions: INodeOptions | undefined,\n\tnodeEngineConfig: INodeEngineConfig,\n\tenvVars: IEnvironmentVariables & IEngineEnvironmentVariables,\n\tcliCommand?: ICliCommand,\n\tavailableContextIdKeys?: { key: string; requiredHandlerFeatures: string[] }[]\n): Promise<\n\t| {\n\t\t\tengine: Engine<IEngineServerConfig, INodeEngineState>;\n\t\t\tserver: EngineServer;\n\t\t\tshutdown: () => Promise<void>;\n\t }\n\t| undefined\n> {\n\tconst entityStorageConnectorType = envVars.entityStorageConnectorType?.split(\",\") ?? [];\n\tconst blobStorageConnectorType = envVars.blobStorageConnectorType?.split(\",\") ?? [];\n\n\tconst requiresEngineStarted = cliCommand?.definition?.requiresEngineStarted ?? true;\n\tconst requiresNodeIdentity = cliCommand?.definition?.requiresNodeIdentity ?? true;\n\tconst requiresOrgIdentity = cliCommand?.definition?.requiresOrgIdentity ?? true;\n\n\t// File connectors (blob/entity) and the default file-based state storage all\n\t// persist to disk under storageFileRoot, so it must be set when any of them is in use.\n\tif (\n\t\t(entityStorageConnectorType.includes(EntityStorageConnectorType.File) ||\n\t\t\tblobStorageConnectorType.includes(BlobStorageConnectorType.File) ||\n\t\t\tIs.empty(nodeOptions?.stateStorage)) &&\n\t\t!Is.stringValue(envVars.storageFileRoot) &&\n\t\trequiresEngineStarted\n\t) {\n\t\tthrow new GeneralError(\"node\", \"storageFileRootNotSet\", {\n\t\t\tstorageFileRoot: `${nodeOptions?.envPrefix ?? \"\"}STORAGE_FILE_ROOT`\n\t\t});\n\t}\n\n\t// Create the engine instance using file state storage unless one is configured in options\n\tconst engine = new Engine<IEngineServerConfig, INodeEngineState>({\n\t\tconfig: nodeEngineConfig,\n\t\tstateStorage: requiresEngineStarted\n\t\t\t? (nodeOptions?.stateStorage ?? new FileStateStorage(envVars.stateFilename ?? \"\"))\n\t\t\t: undefined,\n\t\tcustomBootstrap: async engineCore => {\n\t\t\tconfigureContextIds(\n\t\t\t\tengineCore,\n\t\t\t\tenvVars,\n\t\t\t\trequiresEngineStarted,\n\t\t\t\trequiresNodeIdentity,\n\t\t\t\trequiresOrgIdentity\n\t\t\t);\n\t\t\tif (!Is.objectValue(cliCommand) && requiresEngineStarted) {\n\t\t\t\tawait ContextIdStore.run(engineCore.getContextIds() ?? {}, async () => {\n\t\t\t\t\tawait enforceTenantOrganizationIds(engineCore, envVars);\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t});\n\n\tconfigureContextIdKeys(engine, availableContextIdKeys);\n\n\t// Construct the server with the engine.\n\tconst server = new EngineServer({ engineCore: engine });\n\n\t// Extend the engine.\n\tif (Is.function(nodeOptions?.extendEngine)) {\n\t\tawait engine.logInfo(I18n.formatMessage(\"node.extendingEngine\"));\n\t\tawait nodeOptions.extendEngine(engine);\n\t}\n\n\tawait extensionsInitialiseEngine(envVars, engine);\n\n\t// Extend the engine server.\n\tif (Is.function(nodeOptions?.extendEngineServer)) {\n\t\tawait engine.logInfo(I18n.formatMessage(\"node.extendingEngineServer\"));\n\t\tawait nodeOptions?.extendEngineServer(server);\n\t}\n\n\tawait extensionsInitialiseEngineServer(envVars, engine, server);\n\n\t// Need to register the engine with the factory so that background tasks\n\t// can clone it to spawn new instances.\n\tEngineCoreFactory.register(\"engine\", () => engine);\n\n\tif (Is.objectValue(cliCommand)) {\n\t\tawait executeCommand(engine, envVars, cliCommand);\n\t} else {\n\t\ttry {\n\t\t\t// Start the server, which also starts the engine.\n\t\t\tawait server.start();\n\n\t\t\treturn {\n\t\t\t\tengine,\n\t\t\t\tserver,\n\t\t\t\tshutdown: async () => {\n\t\t\t\t\tawait shutdownExtensions(envVars, engine);\n\t\t\t\t\tawait server.stop();\n\t\t\t\t}\n\t\t\t};\n\t\t} catch (err) {\n\t\t\tawait shutdownExtensions(envVars, engine);\n\t\t\tthrow err;\n\t\t}\n\t}\n}\n\n/**\n * Populate the engine context IDs from the current engine state.\n * @param engine The engine to configure.\n * @param envVars The environment variables.\n * @param requiresEngineStarted Whether the engine is required to be started.\n * @param requiresNodeIdentity Whether the node identity is required.\n * @param requiresOrgIdentity Whether the organization identity is required.\n * @throws GeneralError if the node identity or organization ID is required but not set.\n */\nfunction configureContextIds(\n\tengine: IEngineCore<IEngineCoreConfig, INodeEngineState>,\n\tenvVars: IEngineEnvironmentVariables,\n\trequiresEngineStarted: boolean,\n\trequiresNodeIdentity: boolean,\n\trequiresOrgIdentity: boolean\n): void {\n\tconst state = engine.getState();\n\n\tif (requiresEngineStarted) {\n\t\tif (Is.stringValue(state.nodeId)) {\n\t\t\tengine.addContextId(ContextIdKeys.Node, state.nodeId);\n\t\t} else if (requiresNodeIdentity) {\n\t\t\tthrow new GeneralError(\"node\", \"nodeIdentityNotSet\");\n\t\t}\n\n\t\tconst tenantEnabled = Coerce.boolean(envVars.tenantEnabled) ?? false;\n\t\tif (!tenantEnabled) {\n\t\t\tif (Is.stringValue(state.nodeOrganizationId)) {\n\t\t\t\tengine.addContextId(ContextIdKeys.Organization, state.nodeOrganizationId);\n\t\t\t} else if (requiresOrgIdentity) {\n\t\t\t\tthrow new GeneralError(\"node\", \"nodeOrganizationIdNotSet\");\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Configure the available context ID keys on the engine.\n * @param engine The engine to configure.\n * @param availableContextIdKeys The available context ID keys.\n */\nfunction configureContextIdKeys(\n\tengine: IEngineCore<IEngineCoreConfig, INodeEngineState>,\n\tavailableContextIdKeys: { key: string; requiredHandlerFeatures: string[] }[] | undefined\n): void {\n\tif (Is.arrayValue(availableContextIdKeys)) {\n\t\tconst added: string[] = [];\n\t\tfor (const availableContextIdKey of availableContextIdKeys) {\n\t\t\tif (!added.includes(availableContextIdKey.key)) {\n\t\t\t\tengine.addContextIdKey(\n\t\t\t\t\tavailableContextIdKey.key,\n\t\t\t\t\tavailableContextIdKey.requiredHandlerFeatures\n\t\t\t\t);\n\t\t\t\tadded.push(availableContextIdKey.key);\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Scan all tenants for a missing organization ID.\n * If exactly one tenant is missing and the node's own organization ID is available in state,\n * the value is automatically applied and persisted (legacy migration path).\n * If multiple tenants are missing, or the single missing tenant cannot be auto-recovered,\n * startup is blocked with an error listing the affected tenant IDs.\n * @param engineCore The engine core.\n * @param envVars The environment variables.\n * @returns A promise that resolves when all tenants have valid organization IDs.\n * @throws GeneralError if multiple tenants are missing their organization ID and cannot be auto-recovered.\n */\nasync function enforceTenantOrganizationIds(\n\tengineCore: IEngineCore<IEngineCoreConfig, INodeEngineState>,\n\tenvVars: IEnvironmentVariables\n): Promise<void> {\n\tconst tenantEnabled = Coerce.boolean(envVars.tenantEnabled) ?? false;\n\tif (!tenantEnabled) {\n\t\treturn;\n\t}\n\n\tconst type = engineCore.getRegisteredInstanceTypeOptional(\"tenantAdminComponent\");\n\tif (!Is.stringValue(type)) {\n\t\treturn;\n\t}\n\n\tconst tenantAdminComponent = ComponentFactory.get<ITenantAdminComponent>(type);\n\tconst missingIds: string[] = [];\n\tlet cursor: string | undefined;\n\n\tdo {\n\t\tconst { tenants, cursor: next } = await tenantAdminComponent.query(\n\t\t\tundefined,\n\t\t\t[\"id\", \"organizationId\"],\n\t\t\tcursor\n\t\t);\n\t\tfor (const tenant of tenants) {\n\t\t\tif (Is.stringValue(tenant.id) && !Is.stringValue(tenant.organizationId)) {\n\t\t\t\tmissingIds.push(tenant.id);\n\t\t\t}\n\t\t}\n\t\tcursor = next;\n\t} while (Is.stringValue(cursor));\n\n\tif (missingIds.length === 0) {\n\t\treturn;\n\t}\n\n\tif (missingIds.length === 1) {\n\t\tconst state = engineCore.getState();\n\t\tif (Is.stringValue(state.nodeOrganizationId)) {\n\t\t\tengineCore.logInfo(\n\t\t\t\tI18n.formatMessage(\"node.tenantOrganizationIdAutoAssigned\", {\n\t\t\t\t\ttenantId: missingIds[0],\n\t\t\t\t\torganizationId: state.nodeOrganizationId\n\t\t\t\t})\n\t\t\t);\n\t\t\tawait tenantAdminComponent.update({\n\t\t\t\tid: missingIds[0],\n\t\t\t\torganizationId: state.nodeOrganizationId\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t}\n\n\tthrow new GeneralError(\"node\", \"tenantsWithoutOrganizationId\", {\n\t\ttenantIds: missingIds.join(\", \")\n\t});\n}\n"]}
|
|
1
|
+
{"version":3,"file":"start.js","sourceRoot":"","sources":["../../src/start.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAClF,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,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CAAC;QACpC,IAAI,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,kBAAkB,CAAC,EAAE,CAAC;YAC9C,UAAU,CAAC,OAAO,CACjB,IAAI,CAAC,aAAa,CAAC,uCAAuC,EAAE;gBAC3D,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC;gBACvB,cAAc,EAAE,KAAK,CAAC,kBAAkB;aACxC,CAAC,CACF,CAAC;YACF,MAAM,oBAAoB,CAAC,MAAM,CAAC;gBACjC,EAAE,EAAE,UAAU,CAAC,CAAC,CAAC;gBACjB,cAAc,EAAE,KAAK,CAAC,kBAAkB;aACxC,CAAC,CAAC;YACH,OAAO;QACR,CAAC;IACF,CAAC;IAED,MAAM,IAAI,YAAY,CAAC,MAAM,EAAE,8BAA8B,EAAE;QAC9D,SAAS,EAAE,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;KAChC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { ITenantAdminComponent } from \"@twin.org/api-models\";\nimport { ContextIdKeys, ContextIdStore } from \"@twin.org/context\";\nimport { Coerce, ComponentFactory, GeneralError, I18n, Is } from \"@twin.org/core\";\nimport { Engine } from \"@twin.org/engine\";\nimport { FileStateStorage } from \"@twin.org/engine-core\";\nimport {\n\tEngineCoreFactory,\n\ttype IEngineCore,\n\ttype IEngineCoreConfig\n} from \"@twin.org/engine-models\";\nimport { EngineServer } from \"@twin.org/engine-server\";\nimport type { IEngineServerConfig } from \"@twin.org/engine-server-types\";\nimport { BlobStorageConnectorType, EntityStorageConnectorType } from \"@twin.org/engine-types\";\nimport {\n\textensionsInitialiseEngine,\n\textensionsInitialiseEngineServer,\n\tshutdownExtensions\n} from \"./builders/extensionsBuilder.js\";\nimport { commaSeparatedListToArray } from \"./builders/helper/envHelpers.js\";\nimport { executeCommand } from \"./cli.js\";\nimport type { ICliCommand } from \"./models/ICliCommand.js\";\nimport type { IEngineEnvironmentVariables } from \"./models/IEngineEnvironmentVariables.js\";\nimport type { IEnvironmentVariables } from \"./models/IEnvironmentVariables.js\";\nimport type { INodeEngineConfig } from \"./models/INodeEngineConfig.js\";\nimport type { INodeEngineState } from \"./models/INodeEngineState.js\";\nimport type { INodeOptions } from \"./models/INodeOptions.js\";\n\n/**\n * Start the engine server.\n * @param nodeOptions Optional run options for the engine server.\n * @param nodeEngineConfig The configuration for the engine server.\n * @param envVars The environment variables.\n * @param cliCommand The constructed CLI command (optional).\n * @param availableContextIdKeys The context ID keys available for operation.\n * @returns The engine server.\n */\nexport async function start(\n\tnodeOptions: INodeOptions | undefined,\n\tnodeEngineConfig: INodeEngineConfig,\n\tenvVars: IEnvironmentVariables & IEngineEnvironmentVariables,\n\tcliCommand?: ICliCommand,\n\tavailableContextIdKeys?: { key: string; requiredHandlerFeatures: string[] }[]\n): Promise<\n\t| {\n\t\t\tengine: Engine<IEngineServerConfig, INodeEngineState>;\n\t\t\tserver: EngineServer;\n\t\t\tshutdown: () => Promise<void>;\n\t }\n\t| undefined\n> {\n\tconst entityStorageConnectorType = commaSeparatedListToArray(envVars.entityStorageConnectorType);\n\tconst blobStorageConnectorType = commaSeparatedListToArray(envVars.blobStorageConnectorType);\n\n\tconst requiresEngineStarted = cliCommand?.definition?.requiresEngineStarted ?? true;\n\tconst requiresNodeIdentity = cliCommand?.definition?.requiresNodeIdentity ?? true;\n\tconst requiresOrgIdentity = cliCommand?.definition?.requiresOrgIdentity ?? true;\n\n\t// File connectors (blob/entity) and the default file-based state storage all\n\t// persist to disk under storageFileRoot, so it must be set when any of them is in use.\n\tif (\n\t\t(entityStorageConnectorType.includes(EntityStorageConnectorType.File) ||\n\t\t\tblobStorageConnectorType.includes(BlobStorageConnectorType.File) ||\n\t\t\tIs.empty(nodeOptions?.stateStorage)) &&\n\t\t!Is.stringValue(envVars.storageFileRoot) &&\n\t\trequiresEngineStarted\n\t) {\n\t\tthrow new GeneralError(\"node\", \"storageFileRootNotSet\", {\n\t\t\tstorageFileRoot: `${nodeOptions?.envPrefix ?? \"\"}STORAGE_FILE_ROOT`\n\t\t});\n\t}\n\n\t// Create the engine instance using file state storage unless one is configured in options\n\tconst engine = new Engine<IEngineServerConfig, INodeEngineState>({\n\t\tconfig: nodeEngineConfig,\n\t\tstateStorage: requiresEngineStarted\n\t\t\t? (nodeOptions?.stateStorage ?? new FileStateStorage(envVars.stateFilename ?? \"\"))\n\t\t\t: undefined,\n\t\tcustomBootstrap: async engineCore => {\n\t\t\tconfigureContextIds(\n\t\t\t\tengineCore,\n\t\t\t\tenvVars,\n\t\t\t\trequiresEngineStarted,\n\t\t\t\trequiresNodeIdentity,\n\t\t\t\trequiresOrgIdentity\n\t\t\t);\n\t\t\tif (!Is.objectValue(cliCommand) && requiresEngineStarted) {\n\t\t\t\tawait ContextIdStore.run(engineCore.getContextIds() ?? {}, async () => {\n\t\t\t\t\tawait enforceTenantOrganizationIds(engineCore, envVars);\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t});\n\n\tconfigureContextIdKeys(engine, availableContextIdKeys);\n\n\t// Construct the server with the engine.\n\tconst server = new EngineServer({ engineCore: engine });\n\n\t// Extend the engine.\n\tif (Is.function(nodeOptions?.extendEngine)) {\n\t\tawait engine.logInfo(I18n.formatMessage(\"node.extendingEngine\"));\n\t\tawait nodeOptions.extendEngine(engine);\n\t}\n\n\tawait extensionsInitialiseEngine(envVars, engine);\n\n\t// Extend the engine server.\n\tif (Is.function(nodeOptions?.extendEngineServer)) {\n\t\tawait engine.logInfo(I18n.formatMessage(\"node.extendingEngineServer\"));\n\t\tawait nodeOptions?.extendEngineServer(server);\n\t}\n\n\tawait extensionsInitialiseEngineServer(envVars, engine, server);\n\n\t// Need to register the engine with the factory so that background tasks\n\t// can clone it to spawn new instances.\n\tEngineCoreFactory.register(\"engine\", () => engine);\n\n\tif (Is.objectValue(cliCommand)) {\n\t\tawait executeCommand(engine, envVars, cliCommand);\n\t} else {\n\t\ttry {\n\t\t\t// Start the server, which also starts the engine.\n\t\t\tawait server.start();\n\n\t\t\treturn {\n\t\t\t\tengine,\n\t\t\t\tserver,\n\t\t\t\tshutdown: async () => {\n\t\t\t\t\tawait shutdownExtensions(envVars, engine);\n\t\t\t\t\tawait server.stop();\n\t\t\t\t}\n\t\t\t};\n\t\t} catch (err) {\n\t\t\tawait shutdownExtensions(envVars, engine);\n\t\t\tthrow err;\n\t\t}\n\t}\n}\n\n/**\n * Populate the engine context IDs from the current engine state.\n * @param engine The engine to configure.\n * @param envVars The environment variables.\n * @param requiresEngineStarted Whether the engine is required to be started.\n * @param requiresNodeIdentity Whether the node identity is required.\n * @param requiresOrgIdentity Whether the organization identity is required.\n * @throws GeneralError if the node identity or organization ID is required but not set.\n */\nfunction configureContextIds(\n\tengine: IEngineCore<IEngineCoreConfig, INodeEngineState>,\n\tenvVars: IEngineEnvironmentVariables,\n\trequiresEngineStarted: boolean,\n\trequiresNodeIdentity: boolean,\n\trequiresOrgIdentity: boolean\n): void {\n\tconst state = engine.getState();\n\n\tif (requiresEngineStarted) {\n\t\tif (Is.stringValue(state.nodeId)) {\n\t\t\tengine.addContextId(ContextIdKeys.Node, state.nodeId);\n\t\t} else if (requiresNodeIdentity) {\n\t\t\tthrow new GeneralError(\"node\", \"nodeIdentityNotSet\");\n\t\t}\n\n\t\tconst tenantEnabled = Coerce.boolean(envVars.tenantEnabled) ?? false;\n\t\tif (!tenantEnabled) {\n\t\t\tif (Is.stringValue(state.nodeOrganizationId)) {\n\t\t\t\tengine.addContextId(ContextIdKeys.Organization, state.nodeOrganizationId);\n\t\t\t} else if (requiresOrgIdentity) {\n\t\t\t\tthrow new GeneralError(\"node\", \"nodeOrganizationIdNotSet\");\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Configure the available context ID keys on the engine.\n * @param engine The engine to configure.\n * @param availableContextIdKeys The available context ID keys.\n */\nfunction configureContextIdKeys(\n\tengine: IEngineCore<IEngineCoreConfig, INodeEngineState>,\n\tavailableContextIdKeys: { key: string; requiredHandlerFeatures: string[] }[] | undefined\n): void {\n\tif (Is.arrayValue(availableContextIdKeys)) {\n\t\tconst added: string[] = [];\n\t\tfor (const availableContextIdKey of availableContextIdKeys) {\n\t\t\tif (!added.includes(availableContextIdKey.key)) {\n\t\t\t\tengine.addContextIdKey(\n\t\t\t\t\tavailableContextIdKey.key,\n\t\t\t\t\tavailableContextIdKey.requiredHandlerFeatures\n\t\t\t\t);\n\t\t\t\tadded.push(availableContextIdKey.key);\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Scan all tenants for a missing organization ID.\n * If exactly one tenant is missing and the node's own organization ID is available in state,\n * the value is automatically applied and persisted (legacy migration path).\n * If multiple tenants are missing, or the single missing tenant cannot be auto-recovered,\n * startup is blocked with an error listing the affected tenant IDs.\n * @param engineCore The engine core.\n * @param envVars The environment variables.\n * @returns A promise that resolves when all tenants have valid organization IDs.\n * @throws GeneralError if multiple tenants are missing their organization ID and cannot be auto-recovered.\n */\nasync function enforceTenantOrganizationIds(\n\tengineCore: IEngineCore<IEngineCoreConfig, INodeEngineState>,\n\tenvVars: IEnvironmentVariables\n): Promise<void> {\n\tconst tenantEnabled = Coerce.boolean(envVars.tenantEnabled) ?? false;\n\tif (!tenantEnabled) {\n\t\treturn;\n\t}\n\n\tconst type = engineCore.getRegisteredInstanceTypeOptional(\"tenantAdminComponent\");\n\tif (!Is.stringValue(type)) {\n\t\treturn;\n\t}\n\n\tconst tenantAdminComponent = ComponentFactory.get<ITenantAdminComponent>(type);\n\tconst missingIds: string[] = [];\n\tlet cursor: string | undefined;\n\n\tdo {\n\t\tconst { tenants, cursor: next } = await tenantAdminComponent.query(\n\t\t\tundefined,\n\t\t\t[\"id\", \"organizationId\"],\n\t\t\tcursor\n\t\t);\n\t\tfor (const tenant of tenants) {\n\t\t\tif (Is.stringValue(tenant.id) && !Is.stringValue(tenant.organizationId)) {\n\t\t\t\tmissingIds.push(tenant.id);\n\t\t\t}\n\t\t}\n\t\tcursor = next;\n\t} while (Is.stringValue(cursor));\n\n\tif (missingIds.length === 0) {\n\t\treturn;\n\t}\n\n\tif (missingIds.length === 1) {\n\t\tconst state = engineCore.getState();\n\t\tif (Is.stringValue(state.nodeOrganizationId)) {\n\t\t\tengineCore.logInfo(\n\t\t\t\tI18n.formatMessage(\"node.tenantOrganizationIdAutoAssigned\", {\n\t\t\t\t\ttenantId: missingIds[0],\n\t\t\t\t\torganizationId: state.nodeOrganizationId\n\t\t\t\t})\n\t\t\t);\n\t\t\tawait tenantAdminComponent.update({\n\t\t\t\tid: missingIds[0],\n\t\t\t\torganizationId: state.nodeOrganizationId\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t}\n\n\tthrow new GeneralError(\"node\", \"tenantsWithoutOrganizationId\", {\n\t\ttenantIds: missingIds.join(\", \")\n\t});\n}\n"]}
|
|
@@ -59,9 +59,16 @@ export declare function isTaskSchedulerRequired(envVars: IEngineEnvironmentVaria
|
|
|
59
59
|
*/
|
|
60
60
|
export declare function isAutomationRequired(envVars: IEngineEnvironmentVariables): boolean;
|
|
61
61
|
/**
|
|
62
|
-
* Checks if the telemetry subsystem is
|
|
62
|
+
* Checks if the telemetry subsystem is enabled.
|
|
63
63
|
* Returns true when any component that depends on the telemetry subsystem is enabled.
|
|
64
64
|
* @param envVars The environment variables.
|
|
65
65
|
* @returns True if telemetry is enabled.
|
|
66
66
|
*/
|
|
67
|
-
export declare function
|
|
67
|
+
export declare function isTelemetryEnabled(envVars: IEngineEnvironmentVariables): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Checks if the tracing subsystem is enabled.
|
|
70
|
+
* Returns true when any component that depends on the tracing subsystem is enabled.
|
|
71
|
+
* @param envVars The environment variables.
|
|
72
|
+
* @returns True if tracing is enabled.
|
|
73
|
+
*/
|
|
74
|
+
export declare function isTracingEnabled(envVars: IEngineEnvironmentVariables): boolean;
|
|
@@ -1,80 +1,141 @@
|
|
|
1
|
-
import type { IEngineEnvironmentVariables } from "../../models/IEngineEnvironmentVariables.js";
|
|
2
1
|
/**
|
|
3
2
|
* Coerces an env var to a boolean, falling back to the supplied default when not set.
|
|
4
3
|
* @param envVars The environment variables object.
|
|
5
4
|
* @param key The property name of the env var to coerce.
|
|
6
|
-
* @param defaultValue The value to return when the env var is absent.
|
|
7
|
-
* @returns The boolean value or
|
|
5
|
+
* @param defaultValue The value to return when the env var is absent. Omit to return undefined when absent.
|
|
6
|
+
* @returns The boolean value, the default, or undefined when absent and no default given.
|
|
8
7
|
* @throws GeneralError if the value is set but cannot be coerced to a boolean.
|
|
9
8
|
*/
|
|
10
|
-
export declare function envBoolean(envVars:
|
|
9
|
+
export declare function envBoolean<T>(envVars: T, key: keyof T, defaultValue: boolean): boolean;
|
|
10
|
+
export declare function envBoolean<T>(envVars: T, key: keyof T): boolean | undefined;
|
|
11
11
|
/**
|
|
12
12
|
* Coerces an env var that is already in milliseconds to an integer.
|
|
13
13
|
* @param envVars The environment variables object.
|
|
14
14
|
* @param key The property name of the env var to coerce.
|
|
15
|
-
* @
|
|
15
|
+
* @param defaultValue The value to return when the env var is absent. Omit to return undefined when absent.
|
|
16
|
+
* @returns The millisecond value, the default, or undefined when absent and no default given.
|
|
16
17
|
* @throws GeneralError if the value is set but cannot be coerced to an integer.
|
|
17
18
|
*/
|
|
18
|
-
export declare function envMs(envVars:
|
|
19
|
+
export declare function envMs<T>(envVars: T, key: keyof T, defaultValue: number): number;
|
|
20
|
+
export declare function envMs<T>(envVars: T, key: keyof T): number | undefined;
|
|
19
21
|
/**
|
|
20
22
|
* Coerces an env var that represents an integer count or size to an integer.
|
|
21
23
|
* @param envVars The environment variables object.
|
|
22
24
|
* @param key The property name of the env var to coerce.
|
|
23
|
-
* @
|
|
25
|
+
* @param defaultValue The value to return when the env var is absent. Omit to return undefined when absent.
|
|
26
|
+
* @returns The count, the default, or undefined when absent and no default given.
|
|
24
27
|
* @throws GeneralError if the value is set but cannot be coerced to an integer.
|
|
25
28
|
*/
|
|
26
|
-
export declare function envCount(envVars:
|
|
29
|
+
export declare function envCount<T>(envVars: T, key: keyof T, defaultValue: number): number;
|
|
30
|
+
export declare function envCount<T>(envVars: T, key: keyof T): number | undefined;
|
|
27
31
|
/**
|
|
28
|
-
* Coerces an env var that represents an integer to an integer.
|
|
32
|
+
* Coerces an env var that represents an integer to an actual integer.
|
|
29
33
|
* @param envVars The environment variables object.
|
|
30
34
|
* @param key The property name of the env var to coerce.
|
|
31
|
-
* @
|
|
35
|
+
* @param defaultValue The value to return when the env var is absent. Omit to return undefined when absent.
|
|
36
|
+
* @returns The integer, the default, or undefined when absent and no default given.
|
|
32
37
|
* @throws GeneralError if the value is set but cannot be coerced to an integer.
|
|
33
38
|
*/
|
|
34
|
-
export declare function envInteger(envVars:
|
|
39
|
+
export declare function envInteger<T>(envVars: T, key: keyof T, defaultValue: number): number;
|
|
40
|
+
export declare function envInteger<T>(envVars: T, key: keyof T): number | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Returns an env var as a typed object. Accepts a pre-parsed object, an inline JSON object string,
|
|
43
|
+
* or a value already expanded from a @json: file reference.
|
|
44
|
+
* @param envVars The environment variables object.
|
|
45
|
+
* @param key The property name of the env var to coerce.
|
|
46
|
+
* @param defaultValue The value to return when the env var is absent or cannot be parsed.
|
|
47
|
+
* @returns The parsed object, or the default when absent or the value cannot be parsed.
|
|
48
|
+
*/
|
|
49
|
+
export declare function envObject<T, U>(envVars: T, key: keyof T, defaultValue: U): U;
|
|
50
|
+
/**
|
|
51
|
+
* Returns an env var as a typed object. Accepts a pre-parsed object, an inline JSON object string,
|
|
52
|
+
* or a value already expanded from a @json: file reference.
|
|
53
|
+
* @param envVars The environment variables object.
|
|
54
|
+
* @param key The property name of the env var to coerce.
|
|
55
|
+
* @returns The parsed object, or undefined when the var is absent or the value cannot be parsed.
|
|
56
|
+
*/
|
|
57
|
+
export declare function envObject<T, U>(envVars: T, key: keyof T): U | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* Returns an env var as a typed array. Accepts a pre-parsed array, an inline JSON array string,
|
|
60
|
+
* or a value already expanded from a @json: file reference.
|
|
61
|
+
* @param envVars The environment variables object.
|
|
62
|
+
* @param key The property name of the env var to coerce.
|
|
63
|
+
* @param defaultValue The value to return when the env var is absent or cannot be parsed.
|
|
64
|
+
* @returns The parsed array, or the default when absent or the value cannot be parsed.
|
|
65
|
+
*/
|
|
66
|
+
export declare function envArray<T, U>(envVars: T, key: keyof T, defaultValue: U[]): U[];
|
|
67
|
+
/**
|
|
68
|
+
* Returns an env var as a typed array. Accepts a pre-parsed array, an inline JSON array string,
|
|
69
|
+
* or a value already expanded from a @json: file reference.
|
|
70
|
+
* @param envVars The environment variables object.
|
|
71
|
+
* @param key The property name of the env var to coerce.
|
|
72
|
+
* @returns The parsed array, or undefined when the var is absent or the value cannot be parsed.
|
|
73
|
+
*/
|
|
74
|
+
export declare function envArray<T, U>(envVars: T, key: keyof T): U[] | undefined;
|
|
35
75
|
/**
|
|
36
76
|
* Coerces an env var that is already in seconds to an integer.
|
|
37
77
|
* @param envVars The environment variables object.
|
|
38
78
|
* @param key The property name of the env var to coerce.
|
|
39
|
-
* @
|
|
79
|
+
* @param defaultValue The value to return when the env var is absent. Omit to return undefined when absent.
|
|
80
|
+
* @returns The second value, the default, or undefined when absent and no default given.
|
|
40
81
|
* @throws GeneralError if the value is set but cannot be coerced to an integer.
|
|
41
82
|
*/
|
|
42
|
-
export declare function envSeconds(envVars:
|
|
83
|
+
export declare function envSeconds<T>(envVars: T, key: keyof T, defaultValue: number): number;
|
|
84
|
+
export declare function envSeconds<T>(envVars: T, key: keyof T): number | undefined;
|
|
43
85
|
/**
|
|
44
86
|
* Coerces an env var that is already in minutes to an integer.
|
|
45
87
|
* @param envVars The environment variables object.
|
|
46
88
|
* @param key The property name of the env var to coerce.
|
|
47
|
-
* @
|
|
89
|
+
* @param defaultValue The value to return when the env var is absent. Omit to return undefined when absent.
|
|
90
|
+
* @returns The minute value, the default, or undefined when absent and no default given.
|
|
48
91
|
* @throws GeneralError if the value is set but cannot be coerced to an integer.
|
|
49
92
|
*/
|
|
50
|
-
export declare function envMinutes(envVars:
|
|
93
|
+
export declare function envMinutes<T>(envVars: T, key: keyof T, defaultValue: number): number;
|
|
94
|
+
export declare function envMinutes<T>(envVars: T, key: keyof T): number | undefined;
|
|
51
95
|
/**
|
|
52
96
|
* Coerces an env var that is a datetime string, throwing when the value is set but not a valid datetime.
|
|
53
97
|
* @param envVars The environment variables object.
|
|
54
98
|
* @param key The property name of the env var to coerce.
|
|
55
|
-
* @
|
|
99
|
+
* @param defaultValue The value to return when the env var is absent. Omit to return undefined when absent.
|
|
100
|
+
* @returns The datetime ISO string, the default, or undefined when absent and no default given.
|
|
56
101
|
* @throws GeneralError if the value is set but cannot be coerced to a datetime.
|
|
57
102
|
*/
|
|
58
|
-
export declare function envDateTime(envVars:
|
|
103
|
+
export declare function envDateTime<T>(envVars: T, key: keyof T, defaultValue: string): string;
|
|
104
|
+
export declare function envDateTime<T>(envVars: T, key: keyof T): string | undefined;
|
|
59
105
|
/**
|
|
60
106
|
* Coerces an env var to an integer and converts from seconds to milliseconds.
|
|
61
107
|
* @param envVars The environment variables object.
|
|
62
108
|
* @param key The property name of the env var to coerce.
|
|
63
|
-
* @
|
|
109
|
+
* @param defaultValue The value to return when the env var is absent. Omit to return undefined when absent.
|
|
110
|
+
* @returns The value in milliseconds, the default, or undefined when absent and no default given.
|
|
64
111
|
* @throws GeneralError if the value is set but cannot be coerced to an integer.
|
|
65
112
|
*/
|
|
66
|
-
export declare function envSecToMs(envVars:
|
|
113
|
+
export declare function envSecToMs<T>(envVars: T, key: keyof T, defaultValue: number): number;
|
|
114
|
+
export declare function envSecToMs<T>(envVars: T, key: keyof T): number | undefined;
|
|
67
115
|
/**
|
|
68
116
|
* Coerces an env var to an integer and converts from minutes to milliseconds.
|
|
69
117
|
* @param envVars The environment variables object.
|
|
70
118
|
* @param key The property name of the env var to coerce.
|
|
71
|
-
* @
|
|
119
|
+
* @param defaultValue The value to return when the env var is absent. Omit to return undefined when absent.
|
|
120
|
+
* @returns The value in milliseconds, the default, or undefined when absent and no default given.
|
|
72
121
|
* @throws GeneralError if the value is set but cannot be coerced to an integer.
|
|
73
122
|
*/
|
|
74
|
-
export declare function envMinToMs(envVars:
|
|
123
|
+
export declare function envMinToMs<T>(envVars: T, key: keyof T, defaultValue: number): number;
|
|
124
|
+
export declare function envMinToMs<T>(envVars: T, key: keyof T): number | undefined;
|
|
75
125
|
/**
|
|
76
126
|
* Converts a comma separated list to an array.
|
|
77
127
|
* @param value The comma separated list.
|
|
128
|
+
* @param defaultValue The default value to return when the list is empty or undefined.
|
|
78
129
|
* @returns The array.
|
|
79
130
|
*/
|
|
80
|
-
export declare function commaSeparatedListToArray<
|
|
131
|
+
export declare function commaSeparatedListToArray<U>(value: string | undefined, defaultValue?: U[] | undefined): U[];
|
|
132
|
+
/**
|
|
133
|
+
* Gets named key integer pairs from an env var holding comma separated key=integer pairs.
|
|
134
|
+
* @param envVars The environment variables object.
|
|
135
|
+
* @param key The property name of the env var to read.
|
|
136
|
+
* @returns The named key integer pairs, or undefined when the env var is absent or empty.
|
|
137
|
+
* @throws GeneralError if an entry is not a unique name=value pair with an integer value.
|
|
138
|
+
*/
|
|
139
|
+
export declare function envKeyIntegerPairs<T>(envVars: T, key: keyof T): {
|
|
140
|
+
[key: string]: number;
|
|
141
|
+
} | undefined;
|
|
@@ -131,6 +131,14 @@ export interface IEngineEnvironmentVariables {
|
|
|
131
131
|
* ScyllaDB port.
|
|
132
132
|
*/
|
|
133
133
|
scylladbPort?: string;
|
|
134
|
+
/**
|
|
135
|
+
* ScyllaDB connection pool: number of connections per local host.
|
|
136
|
+
*/
|
|
137
|
+
scylladbPoolCoreConnectionsPerHost?: string;
|
|
138
|
+
/**
|
|
139
|
+
* ScyllaDB connection pool: maximum requests per connection.
|
|
140
|
+
*/
|
|
141
|
+
scylladbPoolMaxRequestsPerConnection?: string;
|
|
134
142
|
/**
|
|
135
143
|
* MySQL host.
|
|
136
144
|
*/
|
|
@@ -151,6 +159,30 @@ export interface IEngineEnvironmentVariables {
|
|
|
151
159
|
* MySQL Database.
|
|
152
160
|
*/
|
|
153
161
|
mySqlDatabase?: string;
|
|
162
|
+
/**
|
|
163
|
+
* MySQL connection pool: maximum number of connections.
|
|
164
|
+
*/
|
|
165
|
+
mySqlPoolConnectionLimit?: string;
|
|
166
|
+
/**
|
|
167
|
+
* MySQL connection pool: maximum number of idle connections.
|
|
168
|
+
*/
|
|
169
|
+
mySqlPoolMaxIdle?: string;
|
|
170
|
+
/**
|
|
171
|
+
* MySQL connection pool: milliseconds before an idle connection is removed.
|
|
172
|
+
*/
|
|
173
|
+
mySqlPoolIdleTimeout?: string;
|
|
174
|
+
/**
|
|
175
|
+
* MySQL connection pool: enable TCP keep-alive.
|
|
176
|
+
*/
|
|
177
|
+
mySqlPoolEnableKeepAlive?: string;
|
|
178
|
+
/**
|
|
179
|
+
* MySQL connection pool: wait for a connection when pool is full.
|
|
180
|
+
*/
|
|
181
|
+
mySqlPoolWaitForConnections?: string;
|
|
182
|
+
/**
|
|
183
|
+
* MySQL connection pool: maximum queued requests (0 = unlimited).
|
|
184
|
+
*/
|
|
185
|
+
mySqlPoolQueueLimit?: string;
|
|
154
186
|
/**
|
|
155
187
|
* MongoDB host.
|
|
156
188
|
*/
|
|
@@ -171,6 +203,22 @@ export interface IEngineEnvironmentVariables {
|
|
|
171
203
|
* MongoDB Database.
|
|
172
204
|
*/
|
|
173
205
|
mongoDbDatabase?: string;
|
|
206
|
+
/**
|
|
207
|
+
* MongoDB connection pool: maximum number of connections.
|
|
208
|
+
*/
|
|
209
|
+
mongoDbPoolMaxPoolSize?: string;
|
|
210
|
+
/**
|
|
211
|
+
* MongoDB connection pool: minimum number of connections to maintain.
|
|
212
|
+
*/
|
|
213
|
+
mongoDbPoolMinPoolSize?: string;
|
|
214
|
+
/**
|
|
215
|
+
* MongoDB connection pool: milliseconds a connection can remain idle before removal.
|
|
216
|
+
*/
|
|
217
|
+
mongoDbPoolMaxIdleTime?: string;
|
|
218
|
+
/**
|
|
219
|
+
* MongoDB connection pool: milliseconds to wait for a connection before throwing.
|
|
220
|
+
*/
|
|
221
|
+
mongoDbPoolWaitQueueTimeout?: string;
|
|
174
222
|
/**
|
|
175
223
|
* PostgreSQl host.
|
|
176
224
|
*/
|
|
@@ -191,6 +239,22 @@ export interface IEngineEnvironmentVariables {
|
|
|
191
239
|
* PostgreSQl Database.
|
|
192
240
|
*/
|
|
193
241
|
postgreSqlDatabase?: string;
|
|
242
|
+
/**
|
|
243
|
+
* PostgreSQL connection pool: maximum number of connections.
|
|
244
|
+
*/
|
|
245
|
+
postgreSqlPoolMax?: string;
|
|
246
|
+
/**
|
|
247
|
+
* PostgreSQL connection pool: seconds a connection can remain idle before being closed.
|
|
248
|
+
*/
|
|
249
|
+
postgreSqlPoolIdleTimeout?: string;
|
|
250
|
+
/**
|
|
251
|
+
* PostgreSQL connection pool: seconds to wait when establishing a connection.
|
|
252
|
+
*/
|
|
253
|
+
postgreSqlPoolConnectTimeout?: string;
|
|
254
|
+
/**
|
|
255
|
+
* PostgreSQL connection pool: maximum seconds a connection can remain open.
|
|
256
|
+
*/
|
|
257
|
+
postgreSqlPoolMaxLifetime?: string;
|
|
194
258
|
/**
|
|
195
259
|
* The security token for accessing IPFS API.
|
|
196
260
|
*/
|
|
@@ -348,6 +412,10 @@ export interface IEngineEnvironmentVariables {
|
|
|
348
412
|
* The number of rotated log files to retain when using the file logging connector, defaults to 5. Set to 0 or negative to keep all rotated files.
|
|
349
413
|
*/
|
|
350
414
|
loggingFileMaxRetainedFiles?: string;
|
|
415
|
+
/**
|
|
416
|
+
* A list of components to exclude from telemetry, can be a comma separated list of component Class names e.g. "ComponentA,ComponentB".
|
|
417
|
+
*/
|
|
418
|
+
telemetrySilentComponents?: string;
|
|
351
419
|
/**
|
|
352
420
|
* The name of the OpenTelemetry logger, only required if using open-telemetry as logging connector, defaults to twin-logging.
|
|
353
421
|
*/
|
|
@@ -413,7 +481,7 @@ export interface IEngineEnvironmentVariables {
|
|
|
413
481
|
*/
|
|
414
482
|
messagingPushNotificationConnector?: string;
|
|
415
483
|
/**
|
|
416
|
-
* The type of telemetry connector: entity-storage.
|
|
484
|
+
* The type of telemetry connector, comma-separated for multiple: entity-storage, open-telemetry, silent.
|
|
417
485
|
*/
|
|
418
486
|
telemetryConnector?: string;
|
|
419
487
|
/**
|
|
@@ -444,12 +512,39 @@ export interface IEngineEnvironmentVariables {
|
|
|
444
512
|
* Maximum number of values retained per telemetry metric (count-based history cap). Defaults to 1440.
|
|
445
513
|
*/
|
|
446
514
|
telemetryMetricsProducerMaxHistory?: string;
|
|
515
|
+
/**
|
|
516
|
+
* The batch size for the telemetry connector, set to 1 to disable size-based flushing.
|
|
517
|
+
*/
|
|
518
|
+
telemetryBatchSize?: string;
|
|
519
|
+
/**
|
|
520
|
+
* The batch flush interval in seconds for the telemetry connector, how often to flush when using batching, defaults to 5 seconds.
|
|
521
|
+
*/
|
|
522
|
+
telemetryBatchFlushInterval?: string;
|
|
523
|
+
/**
|
|
524
|
+
* The maximum number of metric values to hold in the write-ahead cache for the telemetry connector. Set to 0 for unlimited.
|
|
525
|
+
* @default 1000
|
|
526
|
+
*/
|
|
527
|
+
telemetryMaxCacheSize?: string;
|
|
447
528
|
/**
|
|
448
529
|
* The mutex timeout in milliseconds for the telemetry connector.
|
|
449
530
|
*/
|
|
450
531
|
telemetryMutexTimeout?: string;
|
|
451
532
|
/**
|
|
452
|
-
* The
|
|
533
|
+
* The maximum number of metric definitions held in the in-memory definition cache for the telemetry connector.
|
|
534
|
+
* @default 100
|
|
535
|
+
*/
|
|
536
|
+
telemetryMetricDefinitionCacheCapacity?: string;
|
|
537
|
+
/**
|
|
538
|
+
* The time-to-idle in milliseconds for cached metric definitions in the telemetry connector.
|
|
539
|
+
* @default 3600000
|
|
540
|
+
*/
|
|
541
|
+
telemetryMetricDefinitionCacheTtiMs?: string;
|
|
542
|
+
/**
|
|
543
|
+
* A list of components to exclude from tracing, can be a comma separated list of component Class names e.g. "ComponentA,ComponentB".
|
|
544
|
+
*/
|
|
545
|
+
tracingSilentComponents?: string;
|
|
546
|
+
/**
|
|
547
|
+
* The type of tracing connector, comma-separated for multiple: entity-storage, open-telemetry, silent.
|
|
453
548
|
*/
|
|
454
549
|
tracingConnector?: string;
|
|
455
550
|
/**
|
|
@@ -512,6 +607,14 @@ export interface IEngineEnvironmentVariables {
|
|
|
512
607
|
* The mutex timeout in milliseconds for the DID resolution cache. Only used when using the IOTA identity connector and caching is enabled.
|
|
513
608
|
*/
|
|
514
609
|
identityDidResolutionCacheMutexTimeout?: string;
|
|
610
|
+
/**
|
|
611
|
+
* The number of times to retry resolving a DID after a write operation (create, update, or delete) to confirm propagation. Only used when using the IOTA identity connector.
|
|
612
|
+
*/
|
|
613
|
+
identityDidResolutionRetries?: string;
|
|
614
|
+
/**
|
|
615
|
+
* The delay in milliseconds between DID resolution retries after a write operation. Only used when using the IOTA identity connector.
|
|
616
|
+
*/
|
|
617
|
+
identityDidResolutionRetryDelay?: string;
|
|
515
618
|
/**
|
|
516
619
|
* The type of identity resolver connector: entity-storage, iota.
|
|
517
620
|
*/
|
|
@@ -752,6 +855,14 @@ export interface IEngineEnvironmentVariables {
|
|
|
752
855
|
* The mutex timeout in milliseconds for the dataspace agreement cache.
|
|
753
856
|
*/
|
|
754
857
|
dataspaceAgreementCacheMutexTimeout?: string;
|
|
858
|
+
/**
|
|
859
|
+
* The time in milliseconds after which an unused agreement is eligible for removal.
|
|
860
|
+
*/
|
|
861
|
+
dataspaceAgreementUnusedThreshold?: string;
|
|
862
|
+
/**
|
|
863
|
+
* The interval in milliseconds between agreement sweep runs.
|
|
864
|
+
*/
|
|
865
|
+
dataspaceAgreementSweepInterval?: string;
|
|
755
866
|
/**
|
|
756
867
|
* The number of times to retry failed data plane tasks.
|
|
757
868
|
*/
|
|
@@ -26,6 +26,10 @@ export interface IEngineServerEnvironmentVariables {
|
|
|
26
26
|
* The CORS headers to expose.
|
|
27
27
|
*/
|
|
28
28
|
httpExposedHeaders?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Named request body limits in bytes as comma separated name=bytes pairs, e.g. default=2097152,large=26214400.
|
|
31
|
+
*/
|
|
32
|
+
httpBodyLimits?: string;
|
|
29
33
|
/**
|
|
30
34
|
* The public origin URL for the API e.g. https://api.example.com:1234
|
|
31
35
|
*/
|
|
@@ -62,4 +66,12 @@ export interface IEngineServerEnvironmentVariables {
|
|
|
62
66
|
* List of properties to obfuscate in the REST logging output, comma separated.
|
|
63
67
|
*/
|
|
64
68
|
routeLoggingObfuscateProperties?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Comma-separated list of URL path prefixes excluded from metrics collection.
|
|
71
|
+
*/
|
|
72
|
+
routeMetricsExcludePaths?: string;
|
|
73
|
+
/**
|
|
74
|
+
* Comma-separated list of URL path prefixes excluded from tracing.
|
|
75
|
+
*/
|
|
76
|
+
routeTracingExcludePaths?: string;
|
|
65
77
|
}
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,101 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.9.2](https://github.com/iotaledger/twin-node/compare/node-core-v0.9.2...node-core-v0.9.2) (2026-08-24)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add auth admin component ([1661e57](https://github.com/iotaledger/twin-node/commit/1661e57a699d5cf9ebde333e3cbc3aaea89d7c9c))
|
|
9
|
+
* add extend engine and server methods ([ec09c7e](https://github.com/iotaledger/twin-node/commit/ec09c7eb882d9f5797f2fd372e96cad1a3716f59))
|
|
10
|
+
* add extend engine and server methods ([0136a6f](https://github.com/iotaledger/twin-node/commit/0136a6f3f4e1a82b1427ee9618b8a17c79bc7fda))
|
|
11
|
+
* additional run options ([c35e5bb](https://github.com/iotaledger/twin-node/commit/c35e5bbb8a80fe6a36628d41f64585b3723d9ad7))
|
|
12
|
+
* additional startup logging ([0740293](https://github.com/iotaledger/twin-node/commit/0740293b366032f2907046603abf587c9c324aff))
|
|
13
|
+
* improve default options and spec ([b538721](https://github.com/iotaledger/twin-node/commit/b538721902e7f65021d2715148ba59409ccce035))
|
|
14
|
+
* improve error reporting ([fcd39a1](https://github.com/iotaledger/twin-node/commit/fcd39a18da2a6ce33965a99ca5f2f36f4aba712f))
|
|
15
|
+
* initial commit ([522f1e5](https://github.com/iotaledger/twin-node/commit/522f1e515348f9b1dd1eeb3170b1249e2b0b5371))
|
|
16
|
+
* migrate env config from engine to node ([5da29b8](https://github.com/iotaledger/twin-node/commit/5da29b8d714495308320d237a68e84355bba2b47))
|
|
17
|
+
* node app use JavaScript ([14fe08c](https://github.com/iotaledger/twin-node/commit/14fe08cb760dd885a5dac9056a4d5dbc3d61df64))
|
|
18
|
+
* release to production ([6319a38](https://github.com/iotaledger/twin-node/commit/6319a38490a2c2809622f8acd170cb92bfa06942))
|
|
19
|
+
* release to production ([4f44403](https://github.com/iotaledger/twin-node/commit/4f444039832edce8fae562baa7c900ccdc2181da))
|
|
20
|
+
* release to production ([2d96e37](https://github.com/iotaledger/twin-node/commit/2d96e3737bd9663bc0d1171c2ff2c7f8b2ab01bb))
|
|
21
|
+
* release to production ([#253](https://github.com/iotaledger/twin-node/issues/253)) ([230efd0](https://github.com/iotaledger/twin-node/commit/230efd0f99af6114e707999b4c1a83a391cc1741))
|
|
22
|
+
* release to production ([#300](https://github.com/iotaledger/twin-node/issues/300)) ([4d2b09f](https://github.com/iotaledger/twin-node/commit/4d2b09f92c7815ad3fe48d54eca0972fefc782f7))
|
|
23
|
+
* release to production ([#364](https://github.com/iotaledger/twin-node/issues/364)) ([dbba3db](https://github.com/iotaledger/twin-node/commit/dbba3dbf3d9efb858b0ea28aaf88378964fcf08e))
|
|
24
|
+
* update dependencies ([9d25f16](https://github.com/iotaledger/twin-node/commit/9d25f16f1d554cd38f3bec28fdf7f8fff892ceaf))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Bug Fixes
|
|
28
|
+
|
|
29
|
+
* adding a condition to verify if the password exists when bootstrapping ([6030a42](https://github.com/iotaledger/twin-node/commit/6030a42bdaf581678d96932fd0b809396bf7b8b0))
|
|
30
|
+
* adding a condition to verify if the password exists when bootstrapping ([c66f396](https://github.com/iotaledger/twin-node/commit/c66f396717394161a7647d1f08b3d87729d96e96))
|
|
31
|
+
* broken docs ([61479fd](https://github.com/iotaledger/twin-node/commit/61479fd618f766d22c5aafec5277e1a89e22b453))
|
|
32
|
+
* pr comments [#1](https://github.com/iotaledger/twin-node/issues/1) ([66e795b](https://github.com/iotaledger/twin-node/commit/66e795b16c372ab131ec1de30085aee90e4dbbd0))
|
|
33
|
+
|
|
34
|
+
## [0.9.2-next.17](https://github.com/iotaledger/twin-node/compare/node-core-v0.9.2-next.16...node-core-v0.9.2-next.17) (2026-08-24)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
### Features
|
|
38
|
+
|
|
39
|
+
* clone mode ([#360](https://github.com/iotaledger/twin-node/issues/360)) ([8bb56fb](https://github.com/iotaledger/twin-node/commit/8bb56fb6a4b138c2ff0d1267d1be4f8c24f492a6))
|
|
40
|
+
|
|
41
|
+
## [0.9.2-next.16](https://github.com/iotaledger/twin-node/compare/node-core-v0.9.2-next.15...node-core-v0.9.2-next.16) (2026-08-21)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
### Features
|
|
45
|
+
|
|
46
|
+
* configure web server body limits from the environment ([#356](https://github.com/iotaledger/twin-node/issues/356)) ([f196ad3](https://github.com/iotaledger/twin-node/commit/f196ad368559515184e37a99d6876570074ebcd5))
|
|
47
|
+
* telemetry tracing multi ([#357](https://github.com/iotaledger/twin-node/issues/357)) ([b6412ac](https://github.com/iotaledger/twin-node/commit/b6412ac3141a94a0f9f7d1dd391451ac9247e862))
|
|
48
|
+
|
|
49
|
+
## [0.9.2-next.15](https://github.com/iotaledger/twin-node/compare/node-core-v0.9.2-next.14...node-core-v0.9.2-next.15) (2026-08-20)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
### Features
|
|
53
|
+
|
|
54
|
+
* silent telemetry and tracing options ([#351](https://github.com/iotaledger/twin-node/issues/351)) ([3a5752f](https://github.com/iotaledger/twin-node/commit/3a5752fc0bf8a028b3ebfc34878524ac799fb81e))
|
|
55
|
+
|
|
56
|
+
## [0.9.2-next.14](https://github.com/iotaledger/twin-node/compare/node-core-v0.9.2-next.13...node-core-v0.9.2-next.14) (2026-08-19)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
### Features
|
|
60
|
+
|
|
61
|
+
* telemetry batching ([#347](https://github.com/iotaledger/twin-node/issues/347)) ([5d5b0a9](https://github.com/iotaledger/twin-node/commit/5d5b0a91396298fe774ae26193b0595875cd118a))
|
|
62
|
+
|
|
63
|
+
## [0.9.2-next.13](https://github.com/iotaledger/twin-node/compare/node-core-v0.9.2-next.12...node-core-v0.9.2-next.13) (2026-08-18)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
### Features
|
|
67
|
+
|
|
68
|
+
* add tracing ([#344](https://github.com/iotaledger/twin-node/issues/344)) ([4fa71cd](https://github.com/iotaledger/twin-node/commit/4fa71cd0eafd7d708df15c8f0a85323fecd05561))
|
|
69
|
+
|
|
70
|
+
## [0.9.2-next.12](https://github.com/iotaledger/twin-node/compare/node-core-v0.9.2-next.11...node-core-v0.9.2-next.12) (2026-08-17)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
### Features
|
|
74
|
+
|
|
75
|
+
* add dsp sweep vars ([#340](https://github.com/iotaledger/twin-node/issues/340)) ([5487c13](https://github.com/iotaledger/twin-node/commit/5487c13197fcd386206ec37f9f342c55ec5b1176))
|
|
76
|
+
* rest metrics ([#341](https://github.com/iotaledger/twin-node/issues/341)) ([ebec573](https://github.com/iotaledger/twin-node/commit/ebec5736bb66adfd97f7d73912bec1ce7392e5f8))
|
|
77
|
+
|
|
78
|
+
## [0.9.2-next.11](https://github.com/iotaledger/twin-node/compare/node-core-v0.9.2-next.10...node-core-v0.9.2-next.11) (2026-08-14)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
### Features
|
|
82
|
+
|
|
83
|
+
* add tenant override ([#337](https://github.com/iotaledger/twin-node/issues/337)) ([b4ea765](https://github.com/iotaledger/twin-node/commit/b4ea7656e2557c19053365dd5d4af14d0d945cd5))
|
|
84
|
+
|
|
85
|
+
## [0.9.2-next.10](https://github.com/iotaledger/twin-node/compare/node-core-v0.9.2-next.9...node-core-v0.9.2-next.10) (2026-08-12)
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
### Features
|
|
89
|
+
|
|
90
|
+
* update dependencies ([34a5d51](https://github.com/iotaledger/twin-node/commit/34a5d5100140f6e642e8aaa1b4da5304b8ce6f0a))
|
|
91
|
+
|
|
92
|
+
## [0.9.2-next.9](https://github.com/iotaledger/twin-node/compare/node-core-v0.9.2-next.8...node-core-v0.9.2-next.9) (2026-08-12)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
### Features
|
|
96
|
+
|
|
97
|
+
* pool env vars ([#331](https://github.com/iotaledger/twin-node/issues/331)) ([338ea61](https://github.com/iotaledger/twin-node/commit/338ea612b37aa4d15971c8a09def47bee9395d0c))
|
|
98
|
+
|
|
3
99
|
## [0.9.2-next.8](https://github.com/iotaledger/twin-node/compare/node-core-v0.9.2-next.7...node-core-v0.9.2-next.8) (2026-08-11)
|
|
4
100
|
|
|
5
101
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# Function:
|
|
1
|
+
# Function: isTelemetryEnabled()
|
|
2
2
|
|
|
3
|
-
> **
|
|
3
|
+
> **isTelemetryEnabled**(`envVars`): `boolean`
|
|
4
4
|
|
|
5
|
-
Checks if the telemetry subsystem is
|
|
5
|
+
Checks if the telemetry subsystem is enabled.
|
|
6
6
|
Returns true when any component that depends on the telemetry subsystem is enabled.
|
|
7
7
|
|
|
8
8
|
## Parameters
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Function: isTracingEnabled()
|
|
2
|
+
|
|
3
|
+
> **isTracingEnabled**(`envVars`): `boolean`
|
|
4
|
+
|
|
5
|
+
Checks if the tracing subsystem is enabled.
|
|
6
|
+
Returns true when any component that depends on the tracing subsystem is enabled.
|
|
7
|
+
|
|
8
|
+
## Parameters
|
|
9
|
+
|
|
10
|
+
### envVars
|
|
11
|
+
|
|
12
|
+
[`IEngineEnvironmentVariables`](../interfaces/IEngineEnvironmentVariables.md)
|
|
13
|
+
|
|
14
|
+
The environment variables.
|
|
15
|
+
|
|
16
|
+
## Returns
|
|
17
|
+
|
|
18
|
+
`boolean`
|
|
19
|
+
|
|
20
|
+
True if tracing is enabled.
|
package/docs/reference/index.md
CHANGED
|
@@ -48,7 +48,8 @@
|
|
|
48
48
|
- [isRightsManagementRequired](functions/isRightsManagementRequired.md)
|
|
49
49
|
- [isTaskSchedulerRequired](functions/isTaskSchedulerRequired.md)
|
|
50
50
|
- [isAutomationRequired](functions/isAutomationRequired.md)
|
|
51
|
-
- [
|
|
51
|
+
- [isTelemetryEnabled](functions/isTelemetryEnabled.md)
|
|
52
|
+
- [isTracingEnabled](functions/isTracingEnabled.md)
|
|
52
53
|
- [buildEngineServerConfiguration](functions/buildEngineServerConfiguration.md)
|
|
53
54
|
- [isAuthEntityStorageRequired](functions/isAuthEntityStorageRequired.md)
|
|
54
55
|
- [extensionsConfiguration](functions/extensionsConfiguration.md)
|