@twin.org/node-core 0.0.3-next.65 → 0.0.3-next.67
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 +21 -19
- package/dist/es/builders/engineEnvBuilder.js.map +1 -1
- package/dist/es/builders/engineServerEnvBuilder.js +1 -0
- package/dist/es/builders/engineServerEnvBuilder.js.map +1 -1
- package/dist/es/builders/extensionsBuilder.js.map +1 -1
- package/dist/es/cli.js.map +1 -1
- package/dist/es/commands/bootstrapLegacy.js +2 -1
- package/dist/es/commands/bootstrapLegacy.js.map +1 -1
- package/dist/es/commands/help.js.map +1 -1
- package/dist/es/commands/identityCreate.js.map +1 -1
- package/dist/es/commands/identityImports.js.map +1 -1
- package/dist/es/commands/identityVerifiableCredentialCreate.js.map +1 -1
- package/dist/es/commands/identityVerificationMethodCreate.js.map +1 -1
- package/dist/es/commands/identityVerificationMethodImport.js.map +1 -1
- package/dist/es/commands/nodeSetIdentity.js.map +1 -1
- package/dist/es/commands/removeTenantOrgAlias.js.map +1 -1
- package/dist/es/commands/setNodeOrgId.js.map +1 -1
- package/dist/es/commands/setTenantOrgId.js.map +1 -1
- package/dist/es/commands/tenantCreate.js.map +1 -1
- package/dist/es/commands/tenantImport.js.map +1 -1
- package/dist/es/commands/tenantUpdate.js.map +1 -1
- package/dist/es/commands/userCreate.js.map +1 -1
- package/dist/es/commands/userUpdate.js.map +1 -1
- package/dist/es/commands/vaultKeyCreate.js.map +1 -1
- package/dist/es/commands/vaultKeyImport.js.map +1 -1
- package/dist/es/index.js +2 -0
- package/dist/es/index.js.map +1 -1
- package/dist/es/models/IBootstrapLegacyEnvironmentVariables.js +4 -0
- package/dist/es/models/IBootstrapLegacyEnvironmentVariables.js.map +1 -0
- package/dist/es/models/ICliCommandDefinition.js.map +1 -1
- package/dist/es/models/IEngineEnvironmentVariables.js.map +1 -1
- package/dist/es/models/IEngineServerEnvironmentVariables.js +2 -0
- package/dist/es/models/IEngineServerEnvironmentVariables.js.map +1 -1
- package/dist/es/models/IEnvironmentVariables.js +2 -0
- package/dist/es/models/IEnvironmentVariables.js.map +1 -0
- package/dist/es/models/INodeEnvironmentVariables.js +2 -0
- package/dist/es/models/INodeEnvironmentVariables.js.map +1 -1
- package/dist/es/models/INodeOptions.js.map +1 -1
- package/dist/es/models/bootstrapLegacyEnvironmentVariableKeys.js +24 -0
- package/dist/es/models/bootstrapLegacyEnvironmentVariableKeys.js.map +1 -0
- package/dist/es/models/engineEnvironmentVariableKeys.js +202 -0
- package/dist/es/models/engineEnvironmentVariableKeys.js.map +1 -0
- package/dist/es/models/engineServerEnvironmentVariableKeys.js +35 -0
- package/dist/es/models/engineServerEnvironmentVariableKeys.js.map +1 -0
- package/dist/es/models/nodeEnvironmentVariableKeys.js +18 -0
- package/dist/es/models/nodeEnvironmentVariableKeys.js.map +1 -0
- package/dist/es/models/nodeExtensionInitialiseMethod.js.map +1 -1
- package/dist/es/node.js +94 -2
- package/dist/es/node.js.map +1 -1
- package/dist/es/start.js.map +1 -1
- package/dist/types/builders/engineServerEnvBuilder.d.ts +3 -3
- package/dist/types/builders/extensionsBuilder.d.ts +5 -5
- package/dist/types/cli.d.ts +2 -2
- package/dist/types/commands/bootstrapLegacy.d.ts +2 -49
- package/dist/types/commands/help.d.ts +2 -2
- package/dist/types/commands/identityCreate.d.ts +2 -2
- package/dist/types/commands/identityImports.d.ts +2 -2
- package/dist/types/commands/identityVerifiableCredentialCreate.d.ts +2 -2
- package/dist/types/commands/identityVerificationMethodCreate.d.ts +2 -2
- package/dist/types/commands/identityVerificationMethodImport.d.ts +2 -2
- package/dist/types/commands/nodeSetIdentity.d.ts +2 -2
- package/dist/types/commands/removeTenantOrgAlias.d.ts +2 -2
- package/dist/types/commands/setNodeOrgId.d.ts +2 -2
- package/dist/types/commands/setTenantOrgId.d.ts +2 -2
- package/dist/types/commands/tenantCreate.d.ts +2 -2
- package/dist/types/commands/tenantImport.d.ts +2 -2
- package/dist/types/commands/tenantUpdate.d.ts +2 -2
- package/dist/types/commands/userCreate.d.ts +2 -2
- package/dist/types/commands/userUpdate.d.ts +2 -2
- package/dist/types/commands/vaultKeyCreate.d.ts +2 -2
- package/dist/types/commands/vaultKeyImport.d.ts +2 -2
- package/dist/types/index.d.ts +2 -0
- package/dist/types/models/IBootstrapLegacyEnvironmentVariables.d.ts +56 -0
- package/dist/types/models/ICliCommandDefinition.d.ts +2 -2
- package/dist/types/models/IEngineEnvironmentVariables.d.ts +39 -22
- package/dist/types/models/IEngineServerEnvironmentVariables.d.ts +1 -2
- package/dist/types/models/IEnvironmentVariables.d.ts +8 -0
- package/dist/types/models/INodeEnvironmentVariables.d.ts +1 -2
- package/dist/types/models/INodeOptions.d.ts +3 -3
- package/dist/types/models/bootstrapLegacyEnvironmentVariableKeys.d.ts +4 -0
- package/dist/types/models/engineEnvironmentVariableKeys.d.ts +4 -0
- package/dist/types/models/engineServerEnvironmentVariableKeys.d.ts +7 -0
- package/dist/types/models/nodeEnvironmentVariableKeys.d.ts +5 -0
- package/dist/types/models/nodeExtensionInitialiseMethod.d.ts +2 -2
- package/dist/types/node.d.ts +3 -3
- package/dist/types/start.d.ts +3 -2
- package/docs/changelog.md +19 -0
- package/docs/reference/functions/buildConfiguration.md +2 -2
- package/docs/reference/functions/buildEngineServerConfiguration.md +1 -1
- package/docs/reference/functions/executeCommand.md +1 -1
- package/docs/reference/functions/extensionsConfiguration.md +1 -1
- package/docs/reference/functions/extensionsInitialiseEngine.md +1 -1
- package/docs/reference/functions/extensionsInitialiseEngineServer.md +1 -1
- package/docs/reference/functions/isAuthEntityStorageRequired.md +1 -1
- package/docs/reference/functions/overrideModuleImport.md +1 -1
- package/docs/reference/functions/shutdownExtensions.md +1 -1
- package/docs/reference/functions/start.md +1 -1
- package/docs/reference/index.md +2 -0
- package/docs/reference/interfaces/IBootstrapLegacyEnvironmentVariables.md +117 -0
- package/docs/reference/interfaces/ICliCommandDefinition.md +1 -1
- package/docs/reference/interfaces/IEngineEnvironmentVariables.md +71 -40
- package/docs/reference/interfaces/IEngineServerEnvironmentVariables.md +0 -1954
- package/docs/reference/interfaces/INodeEnvironmentVariables.md +0 -2130
- package/docs/reference/interfaces/INodeOptions.md +2 -2
- package/docs/reference/type-aliases/IEnvironmentVariables.md +5 -0
- package/docs/reference/type-aliases/NodeExtensionInitialiseMethod.md +1 -1
- package/locales/en.json +7 -1
- package/package.json +1 -1
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;AAO1C;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CAC1B,WAAqC,EACrC,gBAAmC,EACnC,OAAkC,EAClC,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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.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 { INodeEngineConfig } from \"./models/INodeEngineConfig.js\";\nimport type { INodeEngineState } from \"./models/INodeEngineState.js\";\nimport type { INodeEnvironmentVariables } from \"./models/INodeEnvironmentVariables.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: INodeEnvironmentVariables,\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: INodeEnvironmentVariables,\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: INodeEnvironmentVariables\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,gBA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,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,7 +1,7 @@
|
|
|
1
1
|
import type { IServerInfo } from "@twin.org/api-models";
|
|
2
2
|
import type { IEngineCoreConfig } from "@twin.org/engine-models";
|
|
3
3
|
import { type IEngineServerConfig } from "@twin.org/engine-server-types";
|
|
4
|
-
import type {
|
|
4
|
+
import type { IEnvironmentVariables } from "../models/IEnvironmentVariables.js";
|
|
5
5
|
/**
|
|
6
6
|
* Handles the configuration of the server.
|
|
7
7
|
* @param envVars The environment variables for the engine server.
|
|
@@ -12,7 +12,7 @@ import type { IEngineServerEnvironmentVariables } from "../models/IEngineServerE
|
|
|
12
12
|
* @param favIconPath The path to the favicon.
|
|
13
13
|
* @returns The config for the core and the server.
|
|
14
14
|
*/
|
|
15
|
-
export declare function buildEngineServerConfiguration(envVars:
|
|
15
|
+
export declare function buildEngineServerConfiguration(envVars: IEnvironmentVariables & {
|
|
16
16
|
[id: string]: string | unknown;
|
|
17
17
|
}, availableContextIdKeys: {
|
|
18
18
|
key: string;
|
|
@@ -24,4 +24,4 @@ export declare function buildEngineServerConfiguration(envVars: IEngineServerEnv
|
|
|
24
24
|
* @param envVars The environment variables.
|
|
25
25
|
* @returns True if authentication entity storage is enabled.
|
|
26
26
|
*/
|
|
27
|
-
export declare function isAuthEntityStorageRequired(envVars:
|
|
27
|
+
export declare function isAuthEntityStorageRequired(envVars: IEnvironmentVariables): boolean;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import type { IEngineCore, IEngineServer } from "@twin.org/engine-models";
|
|
2
|
+
import type { IEnvironmentVariables } from "../models/IEnvironmentVariables.js";
|
|
2
3
|
import type { INodeEngineConfig } from "../models/INodeEngineConfig.js";
|
|
3
|
-
import type { INodeEnvironmentVariables } from "../models/INodeEnvironmentVariables.js";
|
|
4
4
|
/**
|
|
5
5
|
* Handles the configuration of the extensions.
|
|
6
6
|
* @param envVars The environment variables for the node.
|
|
7
7
|
* @param nodeEngineConfig The node engine config.
|
|
8
8
|
* @returns The config for the core and the server.
|
|
9
9
|
*/
|
|
10
|
-
export declare function extensionsConfiguration(envVars:
|
|
10
|
+
export declare function extensionsConfiguration(envVars: IEnvironmentVariables, nodeEngineConfig: INodeEngineConfig): Promise<INodeEngineConfig>;
|
|
11
11
|
/**
|
|
12
12
|
* Handles the initialisation of the extensions when the engine has been constructed.
|
|
13
13
|
* @param envVars The environment variables for the node.
|
|
14
14
|
* @param engineCore The engine core instance.
|
|
15
15
|
* @returns A promise that resolves when all extension engine initialisation methods have completed.
|
|
16
16
|
*/
|
|
17
|
-
export declare function extensionsInitialiseEngine(envVars:
|
|
17
|
+
export declare function extensionsInitialiseEngine(envVars: IEnvironmentVariables, engineCore: IEngineCore): Promise<void>;
|
|
18
18
|
/**
|
|
19
19
|
* Handles the initialisation of the extensions when the engine server has been constructed.
|
|
20
20
|
* @param envVars The environment variables for the node.
|
|
@@ -22,11 +22,11 @@ export declare function extensionsInitialiseEngine(envVars: INodeEnvironmentVari
|
|
|
22
22
|
* @param engineServer The engine server instance.
|
|
23
23
|
* @returns A promise that resolves when all extension engine-server initialisation methods have completed.
|
|
24
24
|
*/
|
|
25
|
-
export declare function extensionsInitialiseEngineServer(envVars:
|
|
25
|
+
export declare function extensionsInitialiseEngineServer(envVars: IEnvironmentVariables, engineCore: IEngineCore, engineServer: IEngineServer): Promise<void>;
|
|
26
26
|
/**
|
|
27
27
|
* Handles the shutdown of the extensions.
|
|
28
28
|
* @param envVars The environment variables for the node.
|
|
29
29
|
* @param engineCore The engine core instance.
|
|
30
30
|
* @returns A promise that resolves when all extension shutdown methods have completed.
|
|
31
31
|
*/
|
|
32
|
-
export declare function shutdownExtensions(envVars:
|
|
32
|
+
export declare function shutdownExtensions(envVars: IEnvironmentVariables, engineCore: IEngineCore): Promise<void>;
|
package/dist/types/cli.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { IEngineCore } from "@twin.org/engine-models";
|
|
2
2
|
import type { ICliArgs } from "./models/ICliArgs.js";
|
|
3
3
|
import type { ICliCommand } from "./models/ICliCommand.js";
|
|
4
|
-
import type {
|
|
4
|
+
import type { IEnvironmentVariables } from "./models/IEnvironmentVariables.js";
|
|
5
5
|
/**
|
|
6
6
|
* Parse command line arguments.
|
|
7
7
|
* @param args The command line arguments.
|
|
@@ -24,7 +24,7 @@ export declare function constructCliCommand(processEnv: {
|
|
|
24
24
|
* @param envVars The environment variables for the node.
|
|
25
25
|
* @param cliCommand The CLI command to execute.
|
|
26
26
|
*/
|
|
27
|
-
export declare function executeCommand(engineCore: IEngineCore, envVars:
|
|
27
|
+
export declare function executeCommand(engineCore: IEngineCore, envVars: IEnvironmentVariables, cliCommand: ICliCommand): Promise<void>;
|
|
28
28
|
/**
|
|
29
29
|
* Load the env files and process the options.
|
|
30
30
|
* @param processEnv The environment variables from the process.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { IEngineCore } from "@twin.org/engine-models";
|
|
2
2
|
import type { ICliCommandDefinition } from "../models/ICliCommandDefinition.js";
|
|
3
|
+
import type { IEnvironmentVariables } from "../models/IEnvironmentVariables.js";
|
|
3
4
|
import type { INodeEngineConfig } from "../models/INodeEngineConfig.js";
|
|
4
5
|
import type { INodeEngineState } from "../models/INodeEngineState.js";
|
|
5
|
-
import type { INodeEnvironmentVariables } from "../models/INodeEnvironmentVariables.js";
|
|
6
6
|
/**
|
|
7
7
|
* Get the command definition parameters.
|
|
8
8
|
* @param commandDefinitions The registered command definitions.
|
|
@@ -17,51 +17,4 @@ export declare function getCommandDefinitionBootstrapLegacy(commandDefinitions:
|
|
|
17
17
|
* @param params The parameters for the command.
|
|
18
18
|
* @returns A promise that resolves when the bootstrap sequence has completed.
|
|
19
19
|
*/
|
|
20
|
-
export declare function bootstrapLegacy(engineCore: IEngineCore<INodeEngineConfig, INodeEngineState>, envVars:
|
|
21
|
-
/**
|
|
22
|
-
* The features that are enabled on the node.
|
|
23
|
-
* @default []
|
|
24
|
-
*/
|
|
25
|
-
features?: string;
|
|
26
|
-
/**
|
|
27
|
-
* The identity of the node which, if empty and node-identity feature is enabled it will be generated.
|
|
28
|
-
*/
|
|
29
|
-
nodeIdentity?: string;
|
|
30
|
-
/**
|
|
31
|
-
* The mnemonic for the node identity, if empty it will be randomly generated.
|
|
32
|
-
*/
|
|
33
|
-
nodeMnemonic?: string;
|
|
34
|
-
/**
|
|
35
|
-
* A tenant id to use as a default for the node.
|
|
36
|
-
*/
|
|
37
|
-
tenantId?: string;
|
|
38
|
-
/**
|
|
39
|
-
* A tenant api key to use as a default for the node.
|
|
40
|
-
*/
|
|
41
|
-
tenantApiKey?: string;
|
|
42
|
-
/**
|
|
43
|
-
* The organisation identity. If not provided it will be generated.
|
|
44
|
-
*/
|
|
45
|
-
organizationIdentity?: string;
|
|
46
|
-
/**
|
|
47
|
-
* The mnemonic for the organisation identity, if empty it will be randomly generated.
|
|
48
|
-
*/
|
|
49
|
-
organizationMnemonic?: string;
|
|
50
|
-
/**
|
|
51
|
-
* If the admin-user feature is enabled, this will be the identity of the user. If not provided it will be generated.
|
|
52
|
-
*/
|
|
53
|
-
adminUserIdentity?: string;
|
|
54
|
-
/**
|
|
55
|
-
* The mnemonic for the admin user, if empty it will be randomly generated.
|
|
56
|
-
*/
|
|
57
|
-
adminUserMnemonic?: string;
|
|
58
|
-
/**
|
|
59
|
-
* If the admin-user feature is enabled, this will be the name of the user.
|
|
60
|
-
* @default admin@node
|
|
61
|
-
*/
|
|
62
|
-
adminUserName?: string;
|
|
63
|
-
/**
|
|
64
|
-
* If the admin-user feature is enabled, this will be the password of the user. If empty it will be randomly generated.
|
|
65
|
-
*/
|
|
66
|
-
adminUserPassword?: string;
|
|
67
|
-
}, params: {}): Promise<void>;
|
|
20
|
+
export declare function bootstrapLegacy(engineCore: IEngineCore<INodeEngineConfig, INodeEngineState>, envVars: IEnvironmentVariables, params: {}): Promise<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IEngineCore } from "@twin.org/engine-models";
|
|
2
2
|
import type { ICliCommandDefinition } from "../models/ICliCommandDefinition.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { IEnvironmentVariables } from "../models/IEnvironmentVariables.js";
|
|
4
4
|
/**
|
|
5
5
|
* Get the command definition parameters.
|
|
6
6
|
* @param commandDefinitions The registered command definitions.
|
|
@@ -17,7 +17,7 @@ export declare function getCommandDefinitionHelp(commandDefinitions: {
|
|
|
17
17
|
* @param commandDefinitions The registered command definitions.
|
|
18
18
|
* @returns A promise that resolves when help output has been displayed.
|
|
19
19
|
*/
|
|
20
|
-
export declare function help(engineCore: IEngineCore, envVars:
|
|
20
|
+
export declare function help(engineCore: IEngineCore, envVars: IEnvironmentVariables, params: {
|
|
21
21
|
command?: string;
|
|
22
22
|
}, commandDefinitions: {
|
|
23
23
|
[id: string]: ICliCommandDefinition;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { IEngineCore } from "@twin.org/engine-models";
|
|
2
2
|
import type { ICliCommandDefinition } from "../models/ICliCommandDefinition.js";
|
|
3
|
+
import type { IEnvironmentVariables } from "../models/IEnvironmentVariables.js";
|
|
3
4
|
import type { INodeEngineConfig } from "../models/INodeEngineConfig.js";
|
|
4
5
|
import type { INodeEngineState } from "../models/INodeEngineState.js";
|
|
5
|
-
import type { INodeEnvironmentVariables } from "../models/INodeEnvironmentVariables.js";
|
|
6
6
|
/**
|
|
7
7
|
* Get the command definition parameters.
|
|
8
8
|
* @param commandDefinitions The registered command definitions.
|
|
@@ -27,7 +27,7 @@ export declare function getCommandDefinitionIdentityCreate(commandDefinitions: {
|
|
|
27
27
|
* @param params.outputEnvPrefix The prefix to use for variables in the output .env file.
|
|
28
28
|
* @returns The identity details.
|
|
29
29
|
*/
|
|
30
|
-
export declare function identityCreate(engineCore: IEngineCore<INodeEngineConfig, INodeEngineState>, envVars:
|
|
30
|
+
export declare function identityCreate(engineCore: IEngineCore<INodeEngineConfig, INodeEngineState>, envVars: IEnvironmentVariables, params: {
|
|
31
31
|
mnemonic?: string;
|
|
32
32
|
identity?: string;
|
|
33
33
|
controller?: string;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { IEngineCore } from "@twin.org/engine-models";
|
|
2
2
|
import type { ICliCommandDefinition } from "../models/ICliCommandDefinition.js";
|
|
3
|
+
import type { IEnvironmentVariables } from "../models/IEnvironmentVariables.js";
|
|
3
4
|
import type { INodeEngineConfig } from "../models/INodeEngineConfig.js";
|
|
4
5
|
import type { INodeEngineState } from "../models/INodeEngineState.js";
|
|
5
|
-
import type { INodeEnvironmentVariables } from "../models/INodeEnvironmentVariables.js";
|
|
6
6
|
/**
|
|
7
7
|
* Get the command definition parameters.
|
|
8
8
|
* @param commandDefinitions The registered command definitions.
|
|
@@ -19,7 +19,7 @@ export declare function getCommandDefinitionIdentityImport(commandDefinitions: {
|
|
|
19
19
|
* @param params.mnemonic The mnemonic to use for the identity.
|
|
20
20
|
* @returns A promise that resolves when the identity mnemonic has been stored in the vault.
|
|
21
21
|
*/
|
|
22
|
-
export declare function identityImport(engineCore: IEngineCore<INodeEngineConfig, INodeEngineState>, envVars:
|
|
22
|
+
export declare function identityImport(engineCore: IEngineCore<INodeEngineConfig, INodeEngineState>, envVars: IEnvironmentVariables, params: {
|
|
23
23
|
identity?: string;
|
|
24
24
|
mnemonic?: string;
|
|
25
25
|
}): Promise<void>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { IEngineCore } from "@twin.org/engine-models";
|
|
2
2
|
import type { IDidVerifiableCredential } from "@twin.org/standards-w3c-did";
|
|
3
3
|
import type { ICliCommandDefinition } from "../models/ICliCommandDefinition.js";
|
|
4
|
+
import type { IEnvironmentVariables } from "../models/IEnvironmentVariables.js";
|
|
4
5
|
import type { INodeEngineConfig } from "../models/INodeEngineConfig.js";
|
|
5
6
|
import type { INodeEngineState } from "../models/INodeEngineState.js";
|
|
6
|
-
import type { INodeEnvironmentVariables } from "../models/INodeEnvironmentVariables.js";
|
|
7
7
|
/**
|
|
8
8
|
* Get the command definition parameters.
|
|
9
9
|
* @param commandDefinitions The registered command definitions.
|
|
@@ -27,7 +27,7 @@ export declare function getCommandDefinitionIdentityVerifiableCredentialCreate(c
|
|
|
27
27
|
* @param params.outputEnvPrefix The prefix to use for variables in the output .env file.
|
|
28
28
|
* @returns The created verifiable credential and JWT.
|
|
29
29
|
*/
|
|
30
|
-
export declare function identityVerifiableCredentialCreate(engineCore: IEngineCore<INodeEngineConfig, INodeEngineState>, envVars:
|
|
30
|
+
export declare function identityVerifiableCredentialCreate(engineCore: IEngineCore<INodeEngineConfig, INodeEngineState>, envVars: IEnvironmentVariables, params: {
|
|
31
31
|
verificationMethodId?: string;
|
|
32
32
|
identity?: string;
|
|
33
33
|
controller?: string;
|
|
@@ -2,9 +2,9 @@ import type { IEngineCore } from "@twin.org/engine-models";
|
|
|
2
2
|
import { DidVerificationMethodType } from "@twin.org/standards-w3c-did";
|
|
3
3
|
import { type IJwk } from "@twin.org/web";
|
|
4
4
|
import type { ICliCommandDefinition } from "../models/ICliCommandDefinition.js";
|
|
5
|
+
import type { IEnvironmentVariables } from "../models/IEnvironmentVariables.js";
|
|
5
6
|
import type { INodeEngineConfig } from "../models/INodeEngineConfig.js";
|
|
6
7
|
import type { INodeEngineState } from "../models/INodeEngineState.js";
|
|
7
|
-
import type { INodeEnvironmentVariables } from "../models/INodeEnvironmentVariables.js";
|
|
8
8
|
/**
|
|
9
9
|
* Get the command definition parameters.
|
|
10
10
|
* @param commandDefinitions The registered command definitions.
|
|
@@ -27,7 +27,7 @@ export declare function getCommandDefinitionIdentityVerificationMethodCreate(com
|
|
|
27
27
|
* @param params.outputEnvPrefix The prefix to use for variables in the output .env file.
|
|
28
28
|
* @returns The created verification method details or undefined if skipped.
|
|
29
29
|
*/
|
|
30
|
-
export declare function identityVerificationMethodCreate(engineCore: IEngineCore<INodeEngineConfig, INodeEngineState>, envVars:
|
|
30
|
+
export declare function identityVerificationMethodCreate(engineCore: IEngineCore<INodeEngineConfig, INodeEngineState>, envVars: IEnvironmentVariables, params: {
|
|
31
31
|
identity?: string;
|
|
32
32
|
verificationMethodType?: DidVerificationMethodType;
|
|
33
33
|
verificationMethodId?: string;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { IEngineCore } from "@twin.org/engine-models";
|
|
2
2
|
import { DidVerificationMethodType } from "@twin.org/standards-w3c-did";
|
|
3
3
|
import type { ICliCommandDefinition } from "../models/ICliCommandDefinition.js";
|
|
4
|
+
import type { IEnvironmentVariables } from "../models/IEnvironmentVariables.js";
|
|
4
5
|
import type { INodeEngineConfig } from "../models/INodeEngineConfig.js";
|
|
5
6
|
import type { INodeEngineState } from "../models/INodeEngineState.js";
|
|
6
|
-
import type { INodeEnvironmentVariables } from "../models/INodeEnvironmentVariables.js";
|
|
7
7
|
/**
|
|
8
8
|
* Get the command definition parameters.
|
|
9
9
|
* @param commandDefinitions The registered command definitions.
|
|
@@ -23,7 +23,7 @@ export declare function getCommandDefinitionIdentityVerificationMethodImport(com
|
|
|
23
23
|
* @param params.privateKeyHex The private key in hex format.
|
|
24
24
|
* @returns A promise that resolves when the verification method has been imported.
|
|
25
25
|
*/
|
|
26
|
-
export declare function identityVerificationMethodImport(engineCore: IEngineCore<INodeEngineConfig, INodeEngineState>, envVars:
|
|
26
|
+
export declare function identityVerificationMethodImport(engineCore: IEngineCore<INodeEngineConfig, INodeEngineState>, envVars: IEnvironmentVariables, params: {
|
|
27
27
|
identity?: string;
|
|
28
28
|
verificationMethodType?: DidVerificationMethodType;
|
|
29
29
|
verificationMethodId?: string;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { IEngineCore } from "@twin.org/engine-models";
|
|
2
2
|
import type { ICliCommandDefinition } from "../models/ICliCommandDefinition.js";
|
|
3
|
+
import type { IEnvironmentVariables } from "../models/IEnvironmentVariables.js";
|
|
3
4
|
import type { INodeEngineConfig } from "../models/INodeEngineConfig.js";
|
|
4
5
|
import type { INodeEngineState } from "../models/INodeEngineState.js";
|
|
5
|
-
import type { INodeEnvironmentVariables } from "../models/INodeEnvironmentVariables.js";
|
|
6
6
|
/**
|
|
7
7
|
* Get the command definition parameters.
|
|
8
8
|
* @param commandDefinitions The registered command definitions.
|
|
@@ -18,6 +18,6 @@ export declare function getCommandDefinitionNodeSetIdentity(commandDefinitions:
|
|
|
18
18
|
* @param params.identity The DID to set for the node.
|
|
19
19
|
* @returns A promise that resolves when the node identity has been persisted.
|
|
20
20
|
*/
|
|
21
|
-
export declare function nodeSetIdentity(engineCore: IEngineCore<INodeEngineConfig, INodeEngineState>, envVars:
|
|
21
|
+
export declare function nodeSetIdentity(engineCore: IEngineCore<INodeEngineConfig, INodeEngineState>, envVars: IEnvironmentVariables, params: {
|
|
22
22
|
identity?: string;
|
|
23
23
|
}): Promise<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IEngineCore } from "@twin.org/engine-models";
|
|
2
2
|
import type { ICliCommandDefinition } from "../models/ICliCommandDefinition.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { IEnvironmentVariables } from "../models/IEnvironmentVariables.js";
|
|
4
4
|
/**
|
|
5
5
|
* Get the command definition parameters.
|
|
6
6
|
* @param commandDefinitions The registered command definitions.
|
|
@@ -18,7 +18,7 @@ export declare function getCommandDefinitionRemoveTenantOrgAlias(commandDefiniti
|
|
|
18
18
|
* @returns A promise that resolves when the alias has been removed.
|
|
19
19
|
* @throws GeneralError if the tenant admin component is not registered, or the alias is not found.
|
|
20
20
|
*/
|
|
21
|
-
export declare function removeTenantOrgAlias(engineCore: IEngineCore, envVars:
|
|
21
|
+
export declare function removeTenantOrgAlias(engineCore: IEngineCore, envVars: IEnvironmentVariables, params: {
|
|
22
22
|
tenantId?: string;
|
|
23
23
|
alias?: string;
|
|
24
24
|
}): Promise<void>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { IEngineCore } from "@twin.org/engine-models";
|
|
2
2
|
import type { ICliCommandDefinition } from "../models/ICliCommandDefinition.js";
|
|
3
|
+
import type { IEnvironmentVariables } from "../models/IEnvironmentVariables.js";
|
|
3
4
|
import type { INodeEngineConfig } from "../models/INodeEngineConfig.js";
|
|
4
5
|
import type { INodeEngineState } from "../models/INodeEngineState.js";
|
|
5
|
-
import type { INodeEnvironmentVariables } from "../models/INodeEnvironmentVariables.js";
|
|
6
6
|
/**
|
|
7
7
|
* Get the command definition parameters.
|
|
8
8
|
* @param commandDefinitions The registered command definitions.
|
|
@@ -19,6 +19,6 @@ export declare function getCommandDefinitionSetNodeOrgId(commandDefinitions: {
|
|
|
19
19
|
* @returns A promise that resolves when the node organization ID has been persisted.
|
|
20
20
|
* @throws GeneralError if called while multi-tenant mode is enabled.
|
|
21
21
|
*/
|
|
22
|
-
export declare function setNodeOrgId(engineCore: IEngineCore<INodeEngineConfig, INodeEngineState>, envVars:
|
|
22
|
+
export declare function setNodeOrgId(engineCore: IEngineCore<INodeEngineConfig, INodeEngineState>, envVars: IEnvironmentVariables, params: {
|
|
23
23
|
organizationId?: string;
|
|
24
24
|
}): Promise<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IEngineCore } from "@twin.org/engine-models";
|
|
2
2
|
import type { ICliCommandDefinition } from "../models/ICliCommandDefinition.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { IEnvironmentVariables } from "../models/IEnvironmentVariables.js";
|
|
4
4
|
/**
|
|
5
5
|
* Get the command definition parameters.
|
|
6
6
|
* @param commandDefinitions The registered command definitions.
|
|
@@ -17,7 +17,7 @@ export declare function getCommandDefinitionSetTenantOrgId(commandDefinitions: {
|
|
|
17
17
|
* @param params.organizationId The organization ID to set.
|
|
18
18
|
* @returns A promise that resolves when the tenant organization ID has been stored.
|
|
19
19
|
*/
|
|
20
|
-
export declare function setTenantOrgId(engineCore: IEngineCore, envVars:
|
|
20
|
+
export declare function setTenantOrgId(engineCore: IEngineCore, envVars: IEnvironmentVariables, params: {
|
|
21
21
|
tenantId?: string;
|
|
22
22
|
organizationId?: string;
|
|
23
23
|
}): Promise<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IEngineCore } from "@twin.org/engine-models";
|
|
2
2
|
import type { ICliCommandDefinition } from "../models/ICliCommandDefinition.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { IEnvironmentVariables } from "../models/IEnvironmentVariables.js";
|
|
4
4
|
/**
|
|
5
5
|
* Get the command definition parameters.
|
|
6
6
|
* @param commandDefinitions The registered command definitions.
|
|
@@ -23,7 +23,7 @@ export declare function getCommandDefinitionTenantCreate(commandDefinitions: {
|
|
|
23
23
|
* @param params.outputEnvPrefix The prefix to use for variables in the output .env file.
|
|
24
24
|
* @returns The created tenant details.
|
|
25
25
|
*/
|
|
26
|
-
export declare function tenantCreate(engineCore: IEngineCore, envVars:
|
|
26
|
+
export declare function tenantCreate(engineCore: IEngineCore, envVars: IEnvironmentVariables, params: {
|
|
27
27
|
apiKey?: string;
|
|
28
28
|
tenantId?: string;
|
|
29
29
|
organizationId?: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IEngineCore } from "@twin.org/engine-models";
|
|
2
2
|
import type { ICliCommandDefinition } from "../models/ICliCommandDefinition.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { IEnvironmentVariables } from "../models/IEnvironmentVariables.js";
|
|
4
4
|
/**
|
|
5
5
|
* Get the command definition parameters.
|
|
6
6
|
* @param commandDefinitions The registered command definitions.
|
|
@@ -20,7 +20,7 @@ export declare function getCommandDefinitionTenantImport(commandDefinitions: {
|
|
|
20
20
|
* @param params.publicOrigin The public URL origin for the tenant.
|
|
21
21
|
* @returns A promise that resolves when the tenant record has been created.
|
|
22
22
|
*/
|
|
23
|
-
export declare function tenantImport(engineCore: IEngineCore, envVars:
|
|
23
|
+
export declare function tenantImport(engineCore: IEngineCore, envVars: IEnvironmentVariables, params: {
|
|
24
24
|
apiKey?: string;
|
|
25
25
|
tenantId?: string;
|
|
26
26
|
organizationId?: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IEngineCore } from "@twin.org/engine-models";
|
|
2
2
|
import type { ICliCommandDefinition } from "../models/ICliCommandDefinition.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { IEnvironmentVariables } from "../models/IEnvironmentVariables.js";
|
|
4
4
|
/**
|
|
5
5
|
* Get the command definition parameters.
|
|
6
6
|
* @param commandDefinitions The registered command definitions.
|
|
@@ -20,7 +20,7 @@ export declare function getCommandDefinitionTenantUpdate(commandDefinitions: {
|
|
|
20
20
|
* @param params.publicOrigin The public URL origin for the tenant.
|
|
21
21
|
* @returns A promise that resolves when the tenant record has been updated.
|
|
22
22
|
*/
|
|
23
|
-
export declare function tenantUpdate(engineCore: IEngineCore, envVars:
|
|
23
|
+
export declare function tenantUpdate(engineCore: IEngineCore, envVars: IEnvironmentVariables, params: {
|
|
24
24
|
apiKey?: string;
|
|
25
25
|
tenantId?: string;
|
|
26
26
|
organizationId?: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IEngineCore } from "@twin.org/engine-models";
|
|
2
2
|
import type { ICliCommandDefinition } from "../models/ICliCommandDefinition.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { IEnvironmentVariables } from "../models/IEnvironmentVariables.js";
|
|
4
4
|
/**
|
|
5
5
|
* Get the command definition parameters.
|
|
6
6
|
* @param commandDefinitions The registered command definitions.
|
|
@@ -27,7 +27,7 @@ export declare function getCommandDefinitionUserCreate(commandDefinitions: {
|
|
|
27
27
|
* @param params.outputEnvPrefix The prefix to use for variables in the output .env file.
|
|
28
28
|
* @returns The created user details or undefined if skipped.
|
|
29
29
|
*/
|
|
30
|
-
export declare function userCreate(engineCore: IEngineCore, envVars:
|
|
30
|
+
export declare function userCreate(engineCore: IEngineCore, envVars: IEnvironmentVariables, params: {
|
|
31
31
|
userIdentity?: string;
|
|
32
32
|
organizationIdentity?: string;
|
|
33
33
|
tenantId?: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IEngineCore } from "@twin.org/engine-models";
|
|
2
2
|
import type { ICliCommandDefinition } from "../models/ICliCommandDefinition.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { IEnvironmentVariables } from "../models/IEnvironmentVariables.js";
|
|
4
4
|
/**
|
|
5
5
|
* Get the command definition parameters.
|
|
6
6
|
* @param commandDefinitions The registered command definitions.
|
|
@@ -22,7 +22,7 @@ export declare function getCommandDefinitionUserUpdate(commandDefinitions: {
|
|
|
22
22
|
* @param params.familyName The family name for the user.
|
|
23
23
|
* @returns The updated user details or undefined if skipped.
|
|
24
24
|
*/
|
|
25
|
-
export declare function userUpdate(engineCore: IEngineCore, envVars:
|
|
25
|
+
export declare function userUpdate(engineCore: IEngineCore, envVars: IEnvironmentVariables, params: {
|
|
26
26
|
userIdentity?: string;
|
|
27
27
|
organizationIdentity?: string;
|
|
28
28
|
tenantId?: string;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { IEngineCore } from "@twin.org/engine-models";
|
|
2
2
|
import type { ICliCommandDefinition } from "../models/ICliCommandDefinition.js";
|
|
3
|
+
import type { IEnvironmentVariables } from "../models/IEnvironmentVariables.js";
|
|
3
4
|
import type { INodeEngineConfig } from "../models/INodeEngineConfig.js";
|
|
4
5
|
import type { INodeEngineState } from "../models/INodeEngineState.js";
|
|
5
|
-
import type { INodeEnvironmentVariables } from "../models/INodeEnvironmentVariables.js";
|
|
6
6
|
/**
|
|
7
7
|
* Get the command definition parameters.
|
|
8
8
|
* @param commandDefinitions The registered command definitions.
|
|
@@ -24,7 +24,7 @@ export declare function getCommandDefinitionVaultKeyCreate(commandDefinitions: {
|
|
|
24
24
|
* @param params.outputEnvPrefix The prefix to use for variables in the output .env file.
|
|
25
25
|
* @returns The created vault key details or undefined if skipped.
|
|
26
26
|
*/
|
|
27
|
-
export declare function vaultKeyCreate(engineCore: IEngineCore<INodeEngineConfig, INodeEngineState>, envVars:
|
|
27
|
+
export declare function vaultKeyCreate(engineCore: IEngineCore<INodeEngineConfig, INodeEngineState>, envVars: IEnvironmentVariables, params: {
|
|
28
28
|
identity?: string;
|
|
29
29
|
keyType?: string;
|
|
30
30
|
keyId?: string;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { IEngineCore } from "@twin.org/engine-models";
|
|
2
2
|
import type { ICliCommandDefinition } from "../models/ICliCommandDefinition.js";
|
|
3
|
+
import type { IEnvironmentVariables } from "../models/IEnvironmentVariables.js";
|
|
3
4
|
import type { INodeEngineConfig } from "../models/INodeEngineConfig.js";
|
|
4
5
|
import type { INodeEngineState } from "../models/INodeEngineState.js";
|
|
5
|
-
import type { INodeEnvironmentVariables } from "../models/INodeEnvironmentVariables.js";
|
|
6
6
|
/**
|
|
7
7
|
* Get the command definition parameters.
|
|
8
8
|
* @param commandDefinitions The registered command definitions.
|
|
@@ -21,7 +21,7 @@ export declare function getCommandDefinitionVaultKeyImport(commandDefinitions: {
|
|
|
21
21
|
* @param params.privateKeyHex The private key in hexadecimal format.
|
|
22
22
|
* @returns A promise that resolves when the key has been imported into the vault.
|
|
23
23
|
*/
|
|
24
|
-
export declare function vaultKeyImport(engineCore: IEngineCore<INodeEngineConfig, INodeEngineState>, envVars:
|
|
24
|
+
export declare function vaultKeyImport(engineCore: IEngineCore<INodeEngineConfig, INodeEngineState>, envVars: IEnvironmentVariables, params: {
|
|
25
25
|
identity?: string;
|
|
26
26
|
keyType?: string;
|
|
27
27
|
keyId?: string;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from "./builders/extensionsBuilder.js";
|
|
|
4
4
|
export * from "./cli.js";
|
|
5
5
|
export * from "./defaults.js";
|
|
6
6
|
export * from "./models/cliCommandParamType.js";
|
|
7
|
+
export * from "./models/IBootstrapLegacyEnvironmentVariables.js";
|
|
7
8
|
export * from "./models/ICacheMetadata.js";
|
|
8
9
|
export * from "./models/ICliArgs.js";
|
|
9
10
|
export * from "./models/ICliCommand.js";
|
|
@@ -11,6 +12,7 @@ export * from "./models/ICliCommandDefinition.js";
|
|
|
11
12
|
export * from "./models/ICliCommandDefinitionParam.js";
|
|
12
13
|
export * from "./models/IEngineEnvironmentVariables.js";
|
|
13
14
|
export * from "./models/IEngineServerEnvironmentVariables.js";
|
|
15
|
+
export * from "./models/IEnvironmentVariables.js";
|
|
14
16
|
export * from "./models/IModuleProtocol.js";
|
|
15
17
|
export * from "./models/INodeEngineConfig.js";
|
|
16
18
|
export * from "./models/INodeEngineState.js";
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The environment variables for the bootstrap legacy.
|
|
3
|
+
*/
|
|
4
|
+
export interface IBootstrapLegacyEnvironmentVariables {
|
|
5
|
+
/**
|
|
6
|
+
* The features that are enabled on the node.
|
|
7
|
+
* @default []
|
|
8
|
+
*/
|
|
9
|
+
features?: string;
|
|
10
|
+
/**
|
|
11
|
+
* The identity of the node which, if empty and node-identity feature is enabled it will be generated.
|
|
12
|
+
*/
|
|
13
|
+
nodeIdentity?: string;
|
|
14
|
+
/**
|
|
15
|
+
* The mnemonic for the node identity, if empty it will be randomly generated.
|
|
16
|
+
*/
|
|
17
|
+
nodeMnemonic?: string;
|
|
18
|
+
/**
|
|
19
|
+
* A tenant id to use as a default for the node.
|
|
20
|
+
*/
|
|
21
|
+
tenantId?: string;
|
|
22
|
+
/**
|
|
23
|
+
* A tenant api key to use as a default for the node.
|
|
24
|
+
*/
|
|
25
|
+
tenantApiKey?: string;
|
|
26
|
+
/**
|
|
27
|
+
* The organisation identity. If not provided it will be generated.
|
|
28
|
+
*/
|
|
29
|
+
organizationIdentity?: string;
|
|
30
|
+
/**
|
|
31
|
+
* The mnemonic for the organisation identity, if empty it will be randomly generated.
|
|
32
|
+
*/
|
|
33
|
+
organizationMnemonic?: string;
|
|
34
|
+
/**
|
|
35
|
+
* If the admin-user feature is enabled, this will be the identity of the user. If not provided it will be generated.
|
|
36
|
+
*/
|
|
37
|
+
adminUserIdentity?: string;
|
|
38
|
+
/**
|
|
39
|
+
* The mnemonic for the admin user, if empty it will be randomly generated.
|
|
40
|
+
*/
|
|
41
|
+
adminUserMnemonic?: string;
|
|
42
|
+
/**
|
|
43
|
+
* If the admin-user feature is enabled, this will be the name of the user.
|
|
44
|
+
* @default admin@node
|
|
45
|
+
*/
|
|
46
|
+
adminUserName?: string;
|
|
47
|
+
/**
|
|
48
|
+
* If the admin-user feature is enabled, this will be the password of the user. If empty it will be randomly generated.
|
|
49
|
+
*/
|
|
50
|
+
adminUserPassword?: string;
|
|
51
|
+
/**
|
|
52
|
+
* If the admin-user feature is enabled, this is a comma-separated list of scopes for the user.
|
|
53
|
+
* @default tenant-admin,user-admin (when tenant enabled) or user-admin (when tenant disabled)
|
|
54
|
+
*/
|
|
55
|
+
adminUserScope?: string;
|
|
56
|
+
}
|