@twin.org/node-core 0.0.3-next.16 → 0.0.3-next.18

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.
Files changed (44) hide show
  1. package/dist/es/cli.js +6 -16
  2. package/dist/es/cli.js.map +1 -1
  3. package/dist/es/commands/bootstrapLegacy.js +9 -1
  4. package/dist/es/commands/bootstrapLegacy.js.map +1 -1
  5. package/dist/es/commands/identityCreate.js +6 -0
  6. package/dist/es/commands/identityCreate.js.map +1 -1
  7. package/dist/es/commands/identityImports.js +6 -0
  8. package/dist/es/commands/identityImports.js.map +1 -1
  9. package/dist/es/commands/identityVerifiableCredentialCreate.js +6 -0
  10. package/dist/es/commands/identityVerifiableCredentialCreate.js.map +1 -1
  11. package/dist/es/commands/identityVerificationMethodCreate.js +6 -0
  12. package/dist/es/commands/identityVerificationMethodCreate.js.map +1 -1
  13. package/dist/es/commands/identityVerificationMethodImport.js +6 -0
  14. package/dist/es/commands/identityVerificationMethodImport.js.map +1 -1
  15. package/dist/es/commands/nodeSetIdentity.js +6 -0
  16. package/dist/es/commands/nodeSetIdentity.js.map +1 -1
  17. package/dist/es/commands/nodeSetTenant.js +9 -6
  18. package/dist/es/commands/nodeSetTenant.js.map +1 -1
  19. package/dist/es/commands/tenantCreate.js +7 -2
  20. package/dist/es/commands/tenantCreate.js.map +1 -1
  21. package/dist/es/commands/tenantImport.js +7 -2
  22. package/dist/es/commands/tenantImport.js.map +1 -1
  23. package/dist/es/commands/tenantUpdate.js +12 -16
  24. package/dist/es/commands/tenantUpdate.js.map +1 -1
  25. package/dist/es/commands/userCreate.js +36 -21
  26. package/dist/es/commands/userCreate.js.map +1 -1
  27. package/dist/es/commands/userUpdate.js +132 -0
  28. package/dist/es/commands/userUpdate.js.map +1 -0
  29. package/dist/es/commands/vaultKeyCreate.js +6 -0
  30. package/dist/es/commands/vaultKeyCreate.js.map +1 -1
  31. package/dist/es/commands/vaultKeyImport.js +6 -0
  32. package/dist/es/commands/vaultKeyImport.js.map +1 -1
  33. package/dist/es/node.js +14 -6
  34. package/dist/es/node.js.map +1 -1
  35. package/dist/es/start.js +11 -3
  36. package/dist/es/start.js.map +1 -1
  37. package/dist/types/cli.d.ts +0 -10
  38. package/dist/types/commands/userCreate.d.ts +3 -0
  39. package/dist/types/commands/userUpdate.d.ts +38 -0
  40. package/docs/changelog.md +14 -0
  41. package/docs/reference/index.md +0 -1
  42. package/locales/en.json +86 -5
  43. package/package.json +1 -1
  44. package/docs/reference/functions/initCli.md +0 -27
@@ -1 +1 @@
1
- {"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/node.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,EAAE,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAI9F,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAE,8BAA8B,EAAE,MAAM,sCAAsC,CAAC;AACtF,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAK/C,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EACN,qBAAqB,EACrB,UAAU,EACV,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,EAClB,mBA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AC;gBAAC,MAAM,CAAC;oBACR,4CAA4C;gBAC7C,CAAC;gBACD,MAAM;YACP,CAAC;QACF,CAAC;QAED,0CAA0C;QAC1C,IAAI,YAAY,EAAE,CAAC;YAClB,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,qBAAqB,CAAC,YAAY,CAAC,CAAC,CAAC;YACjE,WAAW,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC;YACjC,OAAO;gBACN,MAAM;gBACN,UAAU,EAAE,KAAK;aACjB,CAAC;QACH,CAAC;QAED,OAAO;YACN,MAAM,EAAE,SAAS;YACjB,UAAU,EAAE,IAAI;SAChB,CAAC;IACH,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { execSync } from \"node:child_process\";\nimport path from \"node:path\";\nimport type { IServerInfo } from \"@twin.org/api-models\";\nimport { CLIDisplay } from \"@twin.org/cli-core\";\nimport { BaseError, Coerce, EnvHelper, GeneralError, Is, ObjectHelper } from \"@twin.org/core\";\nimport type { Engine } from \"@twin.org/engine\";\nimport type { EngineServer } from \"@twin.org/engine-server\";\nimport type { IEngineServerConfig } from \"@twin.org/engine-server-types\";\nimport { ModuleHelper } from \"@twin.org/modules\";\nimport * as dotenv from \"dotenv\";\nimport { buildEngineConfiguration } from \"./builders/engineEnvBuilder.js\";\nimport { buildEngineServerConfiguration } from \"./builders/engineServerEnvBuilder.js\";\nimport { extensionsConfiguration } from \"./builders/extensionsBuilder.js\";\nimport { initCli } from \"./cli.js\";\nimport { getEnvDefaults } from \"./defaults.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\";\nimport { ModuleProtocol } from \"./models/moduleProtocol.js\";\nimport { start } from \"./start.js\";\nimport {\n\tcreateModuleImportUrl,\n\tfileExists,\n\tgetExecutionDirectory,\n\tgetExtensionsCacheDir,\n\tgetScriptDirectory,\n\thandleHttpsProtocol,\n\thandleNpmProtocol,\n\tinitialiseLocales,\n\tloadJsonFile,\n\tloadTextFile,\n\tparseModuleProtocol,\n\tresolvePackageEntryPoint\n} from \"./utils.js\";\n\nconst moduleCache: { [id: string]: unknown } = {};\n\n/**\n * Run the TWIN Node.\n * @param nodeOptions Optional configuration options for running the server.\n * @param args Optional command line arguments.\n * @returns A promise that resolves when the server is started containing a shutdown method.\n */\nexport async function run(\n\tnodeOptions?: INodeOptions,\n\targs?: 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\tlet showErrorDetails = true;\n\ttry {\n\t\tnodeOptions ??= {};\n\n\t\tconst serverInfo: IServerInfo = {\n\t\t\tname: nodeOptions?.serverName ?? \"TWIN Node\",\n\t\t\tversion: nodeOptions?.serverVersion ?? \"0.0.3-next.16\" // x-release-please-version\n\t\t};\n\n\t\tCLIDisplay.header(serverInfo.name, serverInfo.version, \"đŸŒŠī¸ \");\n\n\t\tif (!Is.stringValue(nodeOptions?.executionDirectory)) {\n\t\t\tnodeOptions.executionDirectory = getExecutionDirectory();\n\t\t}\n\t\tCLIDisplay.value(\"Execution Directory\", nodeOptions.executionDirectory);\n\n\t\tif (!Is.stringValue(nodeOptions?.scriptDirectory)) {\n\t\t\tnodeOptions.scriptDirectory = getScriptDirectory(args);\n\t\t}\n\t\tCLIDisplay.value(\"Script Directory\", nodeOptions.scriptDirectory);\n\n\t\tnodeOptions.localesDirectory =\n\t\t\tnodeOptions?.localesDirectory ??\n\t\t\tpath.resolve(path.join(nodeOptions.scriptDirectory, \"dist\", \"locales\"));\n\n\t\tCLIDisplay.value(\"Locales Directory\", nodeOptions.localesDirectory);\n\t\tawait initialiseLocales(nodeOptions.localesDirectory);\n\n\t\tnodeOptions.envPrefix ??= \"TWIN_\";\n\n\t\toverrideModuleImport(nodeOptions.executionDirectory ?? \"\");\n\n\t\t// This is the only location in the code base that should access process.env directly\n\t\t// So we can safely disable the linting rule here.\n\t\tlet finalEnvVars =\n\t\t\t// eslint-disable-next-line no-restricted-syntax\n\t\t\tprocess.env as {\n\t\t\t\t[id: string]: string;\n\t\t\t};\n\n\t\tif (Is.objectValue(nodeOptions?.envVars)) {\n\t\t\tfinalEnvVars = {\n\t\t\t\t...finalEnvVars,\n\t\t\t\t...nodeOptions.envVars\n\t\t\t};\n\t\t}\n\n\t\tfinalEnvVars = {\n\t\t\t...getEnvDefaults(nodeOptions.envPrefix),\n\t\t\t...finalEnvVars\n\t\t};\n\n\t\tconst cliCommand = initCli(finalEnvVars, args);\n\n\t\tif (cliCommand) {\n\t\t\tfinalEnvVars[`${nodeOptions.envPrefix}SILENT`] ??= \"true\";\n\t\t} else {\n\t\t\tif (Is.empty(nodeOptions?.openApiSpecFile)) {\n\t\t\t\tconst specFile = path.resolve(\n\t\t\t\t\tpath.join(nodeOptions.scriptDirectory ?? \"\", \"docs\", \"open-api\", \"spec.json\")\n\t\t\t\t);\n\t\t\t\tif (await fileExists(specFile)) {\n\t\t\t\t\tnodeOptions ??= {};\n\t\t\t\t\tnodeOptions.openApiSpecFile = specFile;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (Is.stringValue(nodeOptions.openApiSpecFile)) {\n\t\t\t\tCLIDisplay.value(\"OpenAPI Spec File\", nodeOptions.openApiSpecFile);\n\t\t\t}\n\n\t\t\tif (Is.empty(nodeOptions?.favIconFile)) {\n\t\t\t\tconst favIconFile = path.resolve(\n\t\t\t\t\tpath.join(nodeOptions.scriptDirectory ?? \"\", \"static\", \"favicon.png\")\n\t\t\t\t);\n\t\t\t\tif (await fileExists(favIconFile)) {\n\t\t\t\t\tnodeOptions ??= {};\n\t\t\t\t\tnodeOptions.favIconFile = favIconFile;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (Is.stringValue(nodeOptions.favIconFile)) {\n\t\t\t\tCLIDisplay.value(\"Favicon File\", nodeOptions.favIconFile);\n\t\t\t}\n\t\t}\n\n\t\tCLIDisplay.value(\"Environment Variable Prefix\", nodeOptions.envPrefix);\n\n\t\tconst { nodeEngineConfig, nodeEnvVars, availableContextIdKeys } = await buildConfiguration(\n\t\t\tfinalEnvVars,\n\t\t\tnodeOptions,\n\t\t\tserverInfo\n\t\t);\n\n\t\tCLIDisplay.break();\n\n\t\tconst startResult = await start(\n\t\t\tnodeOptions,\n\t\t\tnodeEngineConfig,\n\t\t\tnodeEnvVars,\n\t\t\tcliCommand,\n\t\t\tavailableContextIdKeys\n\t\t);\n\n\t\tif (!Is.empty(startResult)) {\n\t\t\tshowErrorDetails = false;\n\n\t\t\tfor (const signal of [\"SIGHUP\", \"SIGINT\", \"SIGTERM\"]) {\n\t\t\t\tprocess.on(signal, async () => {\n\t\t\t\t\tCLIDisplay.value(\"Terminate Signal\", signal);\n\t\t\t\t\tawait startResult.shutdown();\n\t\t\t\t\tprocess.exit(0);\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn startResult;\n\t} catch (err) {\n\t\tif (nodeOptions?.disableProcessExitOnFailure ?? false) {\n\t\t\tthrow err;\n\t\t}\n\n\t\tif (showErrorDetails) {\n\t\t\tconst baseError = BaseError.fromError(err);\n\t\t\tif (baseError.source === \"node\") {\n\t\t\t\tObjectHelper.propertyDelete(err, \"stack\");\n\t\t\t}\n\t\t\tCLIDisplay.error(err);\n\t\t}\n\n\t\t// eslint-disable-next-line unicorn/no-process-exit\n\t\tprocess.exit(1);\n\t}\n}\n\n/**\n * Build the configuration for the TWIN Node.\n * @param processEnv The environment variables from the process.\n * @param options The options for running the server.\n * @param serverInfo The server information.\n * @returns A promise that resolves to the engine server configuration, environment prefix, environment variables,\n * and options.\n */\nexport async function buildConfiguration(\n\tprocessEnv: {\n\t\t[id: string]: string;\n\t},\n\toptions: INodeOptions,\n\tserverInfo: IServerInfo\n): Promise<{\n\tnodeEnvVars: INodeEnvironmentVariables & { [id: string]: string | unknown };\n\tnodeEngineConfig: INodeEngineConfig;\n\tavailableContextIdKeys: { key: string; requiredHandlerFeatures: string[] }[];\n}> {\n\tconst availableContextIdKeys: { key: string; requiredHandlerFeatures: string[] }[] = [];\n\n\tlet defaultEnvOnly = false;\n\tif (Is.empty(options?.envFilenames)) {\n\t\tconst envFile = path.resolve(path.join(options.executionDirectory ?? \"\", \".env\"));\n\t\tCLIDisplay.value(\"Default Environment File\", envFile);\n\t\toptions ??= {};\n\t\toptions.envFilenames = [envFile];\n\t\tdefaultEnvOnly = true;\n\t}\n\n\tif (Is.arrayValue(options?.envFilenames)) {\n\t\tconst output = dotenv.config({\n\t\t\tpath: options?.envFilenames,\n\t\t\tquiet: true\n\t\t});\n\n\t\t// We don't want to throw an error if the default environment file is not found.\n\t\t// Only if we have custom environment files.\n\t\tif (!defaultEnvOnly && output.error) {\n\t\t\tthrow output.error;\n\t\t}\n\n\t\tif (Is.objectValue(output.parsed)) {\n\t\t\tObject.assign(processEnv, output.parsed);\n\t\t}\n\t}\n\n\tconst envVars = EnvHelper.envToJson<{ [id: string]: string | unknown }>(\n\t\tprocessEnv,\n\t\toptions.envPrefix ?? \"\"\n\t);\n\n\t// Expand any environment variables that use the @file: syntax\n\tconst keys = Object.keys(envVars);\n\tfor (const key of keys) {\n\t\tif (\n\t\t\tIs.stringValue(envVars[key]) &&\n\t\t\t(envVars[key].startsWith(\"@text:\") || envVars[key].startsWith(\"@json:\"))\n\t\t) {\n\t\t\tconst filePath = envVars[key].slice(6).trim();\n\t\t\tconst embeddedFile = path.resolve(path.join(options.executionDirectory ?? \"\", filePath));\n\n\t\t\tif (envVars[key].startsWith(\"@text:\")) {\n\t\t\t\tCLIDisplay.value(`Expanding Environment Variable: ${key} from text file`, embeddedFile);\n\t\t\t\tenvVars[key] = await loadTextFile(embeddedFile);\n\t\t\t} else if (envVars[key].startsWith(\"@json:\")) {\n\t\t\t\tCLIDisplay.value(`Expanding Environment Variable: ${key} from JSON file`, embeddedFile);\n\t\t\t\tenvVars[key] = await loadJsonFile(embeddedFile);\n\t\t\t}\n\t\t}\n\t}\n\n\t// Extend the environment variables with any additional custom configuration.\n\tif (Is.function(options?.extendEnvVars)) {\n\t\tCLIDisplay.task(\"Extending Environment Variables\");\n\t\tawait options.extendEnvVars(envVars);\n\t}\n\n\t// Build the engine configuration from the environment variables.\n\tconst coreConfig = await buildEngineConfiguration(envVars, availableContextIdKeys);\n\tconst engineServerConfig = await buildEngineServerConfiguration(\n\t\tenvVars,\n\t\tavailableContextIdKeys,\n\t\tcoreConfig,\n\t\tserverInfo,\n\t\toptions?.openApiSpecFile,\n\t\toptions?.favIconFile\n\t);\n\n\t// Merge any custom configuration provided in the options.\n\tif (Is.arrayValue(options?.configFilenames)) {\n\t\tfor (const configFile of options.configFilenames) {\n\t\t\tCLIDisplay.value(\"Loading Configuration File\", configFile);\n\t\t\tconst configFilePath = path.resolve(path.join(options.executionDirectory ?? \"\", configFile));\n\t\t\tconst config = await loadJsonFile(configFilePath);\n\t\t\tObject.assign(engineServerConfig, config);\n\t\t}\n\t}\n\n\tif (Is.objectValue(options?.config)) {\n\t\tCLIDisplay.task(\"Merging Custom Configuration\");\n\t\tObject.assign(engineServerConfig, options.config);\n\t}\n\n\t// Merge any custom configuration provided in the options.\n\tif (Is.function(options?.extendConfig)) {\n\t\tCLIDisplay.task(\"Extending Configuration\");\n\t\tawait options.extendConfig(envVars, engineServerConfig);\n\t}\n\n\tconst nodeEngineConfig = await extensionsConfiguration(envVars, engineServerConfig);\n\n\treturn { nodeEngineConfig, nodeEnvVars: envVars, availableContextIdKeys };\n}\n\n/**\n * Override module imports to support protocol-based loading (npm:, https:) and local files.\n * @param executionDirectory The execution directory for resolving local module paths.\n * @param envVars The environment variables containing extension configuration (optional, uses defaults if not provided).\n */\nexport function overrideModuleImport(\n\texecutionDirectory: string,\n\tenvVars?: INodeEnvironmentVariables\n): void {\n\tconst maxSizeMb = Coerce.number(envVars?.extensionsMaxSizeMb) ?? 10;\n\tconst cacheDirectory = envVars?.extensionsCacheDirectory;\n\n\tModuleHelper.overrideImport(async moduleName => {\n\t\tif (moduleCache[moduleName]) {\n\t\t\treturn {\n\t\t\t\tmodule: moduleCache[moduleName],\n\t\t\t\tuseDefault: false\n\t\t\t};\n\t\t}\n\n\t\tconst parsed = parseModuleProtocol(moduleName);\n\t\tlet resolvedPath: string | undefined;\n\n\t\tswitch (parsed.protocol) {\n\t\t\tcase ModuleProtocol.Npm: {\n\t\t\t\tconst result = await handleNpmProtocol(\n\t\t\t\t\tparsed.identifier,\n\t\t\t\t\texecutionDirectory,\n\t\t\t\t\tcacheDirectory\n\t\t\t\t);\n\t\t\t\tresolvedPath = result.resolvedPath;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase ModuleProtocol.Https: {\n\t\t\t\tconst result = await handleHttpsProtocol(\n\t\t\t\t\tparsed.identifier,\n\t\t\t\t\texecutionDirectory,\n\t\t\t\t\tmaxSizeMb,\n\t\t\t\t\tcacheDirectory,\n\t\t\t\t\tenvVars?.extensionsCacheTtlHours,\n\t\t\t\t\tenvVars?.extensionsForceRefresh\n\t\t\t\t);\n\t\t\t\tresolvedPath = result.resolvedPath;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase ModuleProtocol.Http: {\n\t\t\t\tthrow new GeneralError(\"node\", \"insecureProtocol\", { protocol: ModuleProtocol.Http });\n\t\t\t}\n\n\t\t\tcase ModuleProtocol.Local: {\n\t\t\t\tlet localFilename = path.resolve(moduleName);\n\n\t\t\t\tlet exists = await fileExists(localFilename);\n\t\t\t\tif (!exists) {\n\t\t\t\t\tlocalFilename = path.resolve(executionDirectory, moduleName);\n\t\t\t\t\texists = await fileExists(localFilename);\n\t\t\t\t}\n\n\t\t\t\tif (exists) {\n\t\t\t\t\tresolvedPath = localFilename;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase ModuleProtocol.Default: {\n\t\t\t\ttry {\n\t\t\t\t\tconst npmRoot = execSync(\"npm root\").toString().trim().replace(/\\\\/g, \"/\");\n\t\t\t\t\tconst packagePath = path.resolve(npmRoot, moduleName);\n\t\t\t\t\tconst mainFile = await resolvePackageEntryPoint(packagePath, moduleName);\n\t\t\t\t\tconst modulePath = path.resolve(packagePath, mainFile);\n\t\t\t\t\tconst exists = await fileExists(modulePath);\n\t\t\t\t\tif (exists) {\n\t\t\t\t\t\tresolvedPath = modulePath;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t} catch {\n\t\t\t\t\t// Continue to fallback resolution\n\t\t\t\t}\n\n\t\t\t\t// Fallback: resolve from npm protocol cache directory (installed via handleNpmProtocol)\n\t\t\t\ttry {\n\t\t\t\t\tconst cacheNpmRoot = path.resolve(\n\t\t\t\t\t\tgetExtensionsCacheDir(executionDirectory, ModuleProtocol.Npm, cacheDirectory),\n\t\t\t\t\t\t\"node_modules\"\n\t\t\t\t\t);\n\n\t\t\t\t\tconst packagePath = path.resolve(cacheNpmRoot, moduleName);\n\t\t\t\t\tconst mainFile = await resolvePackageEntryPoint(packagePath, moduleName);\n\t\t\t\t\tconst modulePath = path.resolve(packagePath, mainFile);\n\t\t\t\t\tconst exists = await fileExists(modulePath);\n\t\t\t\t\tif (exists) {\n\t\t\t\t\t\tresolvedPath = modulePath;\n\t\t\t\t\t}\n\t\t\t\t} catch {\n\t\t\t\t\t// No cached resolution either; fall through\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\t// Common module loading and caching logic\n\t\tif (resolvedPath) {\n\t\t\tconst module = await import(createModuleImportUrl(resolvedPath));\n\t\t\tmoduleCache[moduleName] = module;\n\t\t\treturn {\n\t\t\t\tmodule,\n\t\t\t\tuseDefault: false\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tmodule: undefined,\n\t\t\tuseDefault: true\n\t\t};\n\t});\n}\n"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AAM,GAAG,MAAM,UAAU,CAAC,UAAU,CAAC,CAAC;oBAC5C,IAAI,MAAM,EAAE,CAAC;wBACZ,YAAY,GAAG,UAAU,CAAC;oBAC3B,CAAC;gBACF,CAAC;gBAAC,MAAM,CAAC;oBACR,4CAA4C;gBAC7C,CAAC;gBACD,MAAM;YACP,CAAC;QACF,CAAC;QAED,0CAA0C;QAC1C,IAAI,YAAY,EAAE,CAAC;YAClB,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,qBAAqB,CAAC,YAAY,CAAC,CAAC,CAAC;YACjE,WAAW,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC;YACjC,OAAO;gBACN,MAAM;gBACN,UAAU,EAAE,KAAK;aACjB,CAAC;QACH,CAAC;QAED,OAAO;YACN,MAAM,EAAE,SAAS;YACjB,UAAU,EAAE,IAAI;SAChB,CAAC;IACH,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { execSync } from \"node:child_process\";\nimport path from \"node:path\";\nimport type { IServerInfo } from \"@twin.org/api-models\";\nimport { CLIDisplay } from \"@twin.org/cli-core\";\nimport { BaseError, Coerce, EnvHelper, GeneralError, Is, ObjectHelper } from \"@twin.org/core\";\nimport type { Engine } from \"@twin.org/engine\";\nimport type { EngineServer } from \"@twin.org/engine-server\";\nimport type { IEngineServerConfig } from \"@twin.org/engine-server-types\";\nimport { ModuleHelper } from \"@twin.org/modules\";\nimport * as dotenv from \"dotenv\";\nimport { buildEngineConfiguration } from \"./builders/engineEnvBuilder.js\";\nimport { buildEngineServerConfiguration } from \"./builders/engineServerEnvBuilder.js\";\nimport { extensionsConfiguration } from \"./builders/extensionsBuilder.js\";\nimport { constructCliCommand, parseCommandLineArgs, registerCommands } from \"./cli.js\";\nimport { getEnvDefaults } from \"./defaults.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\";\nimport { ModuleProtocol } from \"./models/moduleProtocol.js\";\nimport { start } from \"./start.js\";\nimport {\n\tcreateModuleImportUrl,\n\tfileExists,\n\tgetExecutionDirectory,\n\tgetExtensionsCacheDir,\n\tgetScriptDirectory,\n\thandleHttpsProtocol,\n\thandleNpmProtocol,\n\tinitialiseLocales,\n\tloadJsonFile,\n\tloadTextFile,\n\tparseModuleProtocol,\n\tresolvePackageEntryPoint\n} from \"./utils.js\";\n\nconst moduleCache: { [id: string]: unknown } = {};\n\n/**\n * Run the TWIN Node.\n * @param nodeOptions Optional configuration options for running the server.\n * @param args Optional command line arguments.\n * @returns A promise that resolves when the server is started containing a shutdown method.\n */\nexport async function run(\n\tnodeOptions?: INodeOptions,\n\targs?: 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\tlet showErrorDetails = true;\n\ttry {\n\t\tnodeOptions ??= {};\n\n\t\tconst serverInfo: IServerInfo = {\n\t\t\tname: nodeOptions?.serverName ?? \"TWIN Node\",\n\t\t\tversion: nodeOptions?.serverVersion ?? \"0.0.3-next.18\" // x-release-please-version\n\t\t};\n\n\t\tCLIDisplay.header(serverInfo.name, serverInfo.version, \"đŸŒŠī¸ \");\n\n\t\tif (!Is.stringValue(nodeOptions?.executionDirectory)) {\n\t\t\tnodeOptions.executionDirectory = getExecutionDirectory();\n\t\t}\n\t\tCLIDisplay.value(\"Execution Directory\", nodeOptions.executionDirectory);\n\n\t\tif (!Is.stringValue(nodeOptions?.scriptDirectory)) {\n\t\t\tnodeOptions.scriptDirectory = getScriptDirectory(args);\n\t\t}\n\t\tCLIDisplay.value(\"Script Directory\", nodeOptions.scriptDirectory);\n\n\t\tnodeOptions.localesDirectory =\n\t\t\tnodeOptions?.localesDirectory ??\n\t\t\tpath.resolve(path.join(nodeOptions.scriptDirectory, \"dist\", \"locales\"));\n\n\t\tCLIDisplay.value(\"Locales Directory\", nodeOptions.localesDirectory);\n\t\tawait initialiseLocales(nodeOptions.localesDirectory);\n\n\t\tnodeOptions.envPrefix ??= \"TWIN_\";\n\n\t\toverrideModuleImport(nodeOptions.executionDirectory ?? \"\");\n\n\t\tconst commandLineArgs = parseCommandLineArgs(args);\n\n\t\tconst hasEnvPrefix = commandLineArgs.options?.find(option => option.key === \"env-prefix\");\n\t\tif (hasEnvPrefix) {\n\t\t\tnodeOptions.envPrefix = Coerce.string(hasEnvPrefix.value) ?? nodeOptions.envPrefix;\n\t\t}\n\n\t\tCLIDisplay.value(\"Environment Variable Prefix\", nodeOptions.envPrefix);\n\n\t\t// This is the only location in the code base that should access process.env directly\n\t\t// So we can safely disable the linting rule here.\n\t\tlet finalEnvVars =\n\t\t\t// eslint-disable-next-line no-restricted-syntax\n\t\t\tprocess.env as {\n\t\t\t\t[id: string]: string;\n\t\t\t};\n\n\t\tif (Is.objectValue(nodeOptions?.envVars)) {\n\t\t\tfinalEnvVars = {\n\t\t\t\t...finalEnvVars,\n\t\t\t\t...nodeOptions.envVars\n\t\t\t};\n\t\t}\n\n\t\tfinalEnvVars = {\n\t\t\t...getEnvDefaults(nodeOptions.envPrefix),\n\t\t\t...finalEnvVars\n\t\t};\n\n\t\tlet cliCommand;\n\t\tif (Is.arrayValue(commandLineArgs.options)) {\n\t\t\tregisterCommands();\n\t\t\tcliCommand = constructCliCommand(finalEnvVars, commandLineArgs);\n\t\t}\n\n\t\tif (Is.object(cliCommand)) {\n\t\t\tfinalEnvVars[`${nodeOptions.envPrefix}SILENT`] ??= \"true\";\n\t\t} else {\n\t\t\tif (Is.empty(nodeOptions?.openApiSpecFile)) {\n\t\t\t\tconst specFile = path.resolve(\n\t\t\t\t\tpath.join(nodeOptions.scriptDirectory ?? \"\", \"docs\", \"open-api\", \"spec.json\")\n\t\t\t\t);\n\t\t\t\tif (await fileExists(specFile)) {\n\t\t\t\t\tnodeOptions ??= {};\n\t\t\t\t\tnodeOptions.openApiSpecFile = specFile;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (Is.stringValue(nodeOptions.openApiSpecFile)) {\n\t\t\t\tCLIDisplay.value(\"OpenAPI Spec File\", nodeOptions.openApiSpecFile);\n\t\t\t}\n\n\t\t\tif (Is.empty(nodeOptions?.favIconFile)) {\n\t\t\t\tconst favIconFile = path.resolve(\n\t\t\t\t\tpath.join(nodeOptions.scriptDirectory ?? \"\", \"static\", \"favicon.png\")\n\t\t\t\t);\n\t\t\t\tif (await fileExists(favIconFile)) {\n\t\t\t\t\tnodeOptions ??= {};\n\t\t\t\t\tnodeOptions.favIconFile = favIconFile;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (Is.stringValue(nodeOptions.favIconFile)) {\n\t\t\t\tCLIDisplay.value(\"Favicon File\", nodeOptions.favIconFile);\n\t\t\t}\n\t\t}\n\n\t\tconst { nodeEngineConfig, nodeEnvVars, availableContextIdKeys } = await buildConfiguration(\n\t\t\tfinalEnvVars,\n\t\t\tnodeOptions,\n\t\t\tserverInfo\n\t\t);\n\n\t\tCLIDisplay.break();\n\n\t\tconst startResult = await start(\n\t\t\tnodeOptions,\n\t\t\tnodeEngineConfig,\n\t\t\tnodeEnvVars,\n\t\t\tcliCommand,\n\t\t\tavailableContextIdKeys\n\t\t);\n\n\t\tif (!Is.empty(startResult)) {\n\t\t\tshowErrorDetails = false;\n\n\t\t\tfor (const signal of [\"SIGHUP\", \"SIGINT\", \"SIGTERM\"]) {\n\t\t\t\tprocess.on(signal, async () => {\n\t\t\t\t\tCLIDisplay.value(\"Terminate Signal\", signal);\n\t\t\t\t\tawait startResult.shutdown();\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn startResult;\n\t} catch (err) {\n\t\tif (nodeOptions?.disableProcessExitOnFailure ?? false) {\n\t\t\tthrow err;\n\t\t}\n\n\t\tif (showErrorDetails) {\n\t\t\tconst baseError = BaseError.fromError(err);\n\t\t\tif (baseError.source === \"node\") {\n\t\t\t\tObjectHelper.propertyDelete(err, \"stack\");\n\t\t\t}\n\t\t\tCLIDisplay.error(err);\n\t\t}\n\n\t\t// eslint-disable-next-line unicorn/no-process-exit\n\t\tprocess.exit(1);\n\t}\n}\n\n/**\n * Build the configuration for the TWIN Node.\n * @param processEnv The environment variables from the process.\n * @param options The options for running the server.\n * @param serverInfo The server information.\n * @returns A promise that resolves to the engine server configuration, environment prefix, environment variables,\n * and options.\n */\nexport async function buildConfiguration(\n\tprocessEnv: {\n\t\t[id: string]: string;\n\t},\n\toptions: INodeOptions,\n\tserverInfo: IServerInfo\n): Promise<{\n\tnodeEnvVars: INodeEnvironmentVariables & { [id: string]: string | unknown };\n\tnodeEngineConfig: INodeEngineConfig;\n\tavailableContextIdKeys: { key: string; requiredHandlerFeatures: string[] }[];\n}> {\n\tconst availableContextIdKeys: { key: string; requiredHandlerFeatures: string[] }[] = [];\n\n\tlet defaultEnvOnly = false;\n\tif (Is.empty(options?.envFilenames)) {\n\t\tconst envFile = path.resolve(path.join(options.executionDirectory ?? \"\", \".env\"));\n\t\tCLIDisplay.value(\"Default Environment File\", envFile);\n\t\toptions ??= {};\n\t\toptions.envFilenames = [envFile];\n\t\tdefaultEnvOnly = true;\n\t}\n\n\tif (Is.arrayValue(options?.envFilenames)) {\n\t\tconst output = dotenv.config({\n\t\t\tpath: options?.envFilenames,\n\t\t\tquiet: true\n\t\t});\n\n\t\t// We don't want to throw an error if the default environment file is not found.\n\t\t// Only if we have custom environment files.\n\t\tif (!defaultEnvOnly && output.error) {\n\t\t\tthrow output.error;\n\t\t}\n\n\t\tif (Is.objectValue(output.parsed)) {\n\t\t\tObject.assign(processEnv, output.parsed);\n\t\t}\n\t}\n\n\tconst envVars = EnvHelper.envToJson<{ [id: string]: string | unknown }>(\n\t\tprocessEnv,\n\t\toptions.envPrefix ?? \"\"\n\t);\n\n\t// Expand any environment variables that use the @file: syntax\n\tconst keys = Object.keys(envVars);\n\tfor (const key of keys) {\n\t\tif (\n\t\t\tIs.stringValue(envVars[key]) &&\n\t\t\t(envVars[key].startsWith(\"@text:\") || envVars[key].startsWith(\"@json:\"))\n\t\t) {\n\t\t\tconst filePath = envVars[key].slice(6).trim();\n\t\t\tconst embeddedFile = path.resolve(path.join(options.executionDirectory ?? \"\", filePath));\n\n\t\t\tif (envVars[key].startsWith(\"@text:\")) {\n\t\t\t\tCLIDisplay.value(`Expanding Environment Variable: ${key} from text file`, embeddedFile);\n\t\t\t\tenvVars[key] = await loadTextFile(embeddedFile);\n\t\t\t} else if (envVars[key].startsWith(\"@json:\")) {\n\t\t\t\tCLIDisplay.value(`Expanding Environment Variable: ${key} from JSON file`, embeddedFile);\n\t\t\t\tenvVars[key] = await loadJsonFile(embeddedFile);\n\t\t\t}\n\t\t}\n\t}\n\n\t// Extend the environment variables with any additional custom configuration.\n\tif (Is.function(options?.extendEnvVars)) {\n\t\tCLIDisplay.task(\"Extending Environment Variables\");\n\t\tawait options.extendEnvVars(envVars);\n\t}\n\n\t// Build the engine configuration from the environment variables.\n\tconst coreConfig = await buildEngineConfiguration(envVars, availableContextIdKeys);\n\tconst engineServerConfig = await buildEngineServerConfiguration(\n\t\tenvVars,\n\t\tavailableContextIdKeys,\n\t\tcoreConfig,\n\t\tserverInfo,\n\t\toptions?.openApiSpecFile,\n\t\toptions?.favIconFile\n\t);\n\n\t// Merge any custom configuration provided in the options.\n\tif (Is.arrayValue(options?.configFilenames)) {\n\t\tfor (const configFile of options.configFilenames) {\n\t\t\tCLIDisplay.value(\"Loading Configuration File\", configFile);\n\t\t\tconst configFilePath = path.resolve(path.join(options.executionDirectory ?? \"\", configFile));\n\t\t\tconst config = await loadJsonFile(configFilePath);\n\t\t\tObject.assign(engineServerConfig, config);\n\t\t}\n\t}\n\n\tif (Is.objectValue(options?.config)) {\n\t\tCLIDisplay.task(\"Merging Custom Configuration\");\n\t\tObject.assign(engineServerConfig, options.config);\n\t}\n\n\t// Merge any custom configuration provided in the options.\n\tif (Is.function(options?.extendConfig)) {\n\t\tCLIDisplay.task(\"Extending Configuration\");\n\t\tawait options.extendConfig(envVars, engineServerConfig);\n\t}\n\n\tconst nodeEngineConfig = await extensionsConfiguration(envVars, engineServerConfig);\n\n\treturn { nodeEngineConfig, nodeEnvVars: envVars, availableContextIdKeys };\n}\n\n/**\n * Override module imports to support protocol-based loading (npm:, https:) and local files.\n * @param executionDirectory The execution directory for resolving local module paths.\n * @param envVars The environment variables containing extension configuration (optional, uses defaults if not provided).\n */\nexport function overrideModuleImport(\n\texecutionDirectory: string,\n\tenvVars?: INodeEnvironmentVariables\n): void {\n\tconst maxSizeMb = Coerce.number(envVars?.extensionsMaxSizeMb) ?? 10;\n\tconst cacheDirectory = envVars?.extensionsCacheDirectory;\n\n\tModuleHelper.overrideImport(async moduleName => {\n\t\tif (moduleCache[moduleName]) {\n\t\t\treturn {\n\t\t\t\tmodule: moduleCache[moduleName],\n\t\t\t\tuseDefault: false\n\t\t\t};\n\t\t}\n\n\t\tconst parsed = parseModuleProtocol(moduleName);\n\t\tlet resolvedPath: string | undefined;\n\n\t\tswitch (parsed.protocol) {\n\t\t\tcase ModuleProtocol.Npm: {\n\t\t\t\tconst result = await handleNpmProtocol(\n\t\t\t\t\tparsed.identifier,\n\t\t\t\t\texecutionDirectory,\n\t\t\t\t\tcacheDirectory\n\t\t\t\t);\n\t\t\t\tresolvedPath = result.resolvedPath;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase ModuleProtocol.Https: {\n\t\t\t\tconst result = await handleHttpsProtocol(\n\t\t\t\t\tparsed.identifier,\n\t\t\t\t\texecutionDirectory,\n\t\t\t\t\tmaxSizeMb,\n\t\t\t\t\tcacheDirectory,\n\t\t\t\t\tenvVars?.extensionsCacheTtlHours,\n\t\t\t\t\tenvVars?.extensionsForceRefresh\n\t\t\t\t);\n\t\t\t\tresolvedPath = result.resolvedPath;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase ModuleProtocol.Http: {\n\t\t\t\tthrow new GeneralError(\"node\", \"insecureProtocol\", { protocol: ModuleProtocol.Http });\n\t\t\t}\n\n\t\t\tcase ModuleProtocol.Local: {\n\t\t\t\tlet localFilename = path.resolve(moduleName);\n\n\t\t\t\tlet exists = await fileExists(localFilename);\n\t\t\t\tif (!exists) {\n\t\t\t\t\tlocalFilename = path.resolve(executionDirectory, moduleName);\n\t\t\t\t\texists = await fileExists(localFilename);\n\t\t\t\t}\n\n\t\t\t\tif (exists) {\n\t\t\t\t\tresolvedPath = localFilename;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase ModuleProtocol.Default: {\n\t\t\t\ttry {\n\t\t\t\t\tconst npmRoot = execSync(\"npm root\").toString().trim().replace(/\\\\/g, \"/\");\n\t\t\t\t\tconst packagePath = path.resolve(npmRoot, moduleName);\n\t\t\t\t\tconst mainFile = await resolvePackageEntryPoint(packagePath, moduleName);\n\t\t\t\t\tconst modulePath = path.resolve(packagePath, mainFile);\n\t\t\t\t\tconst exists = await fileExists(modulePath);\n\t\t\t\t\tif (exists) {\n\t\t\t\t\t\tresolvedPath = modulePath;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t} catch {\n\t\t\t\t\t// Continue to fallback resolution\n\t\t\t\t}\n\n\t\t\t\t// Fallback: resolve from npm protocol cache directory (installed via handleNpmProtocol)\n\t\t\t\ttry {\n\t\t\t\t\tconst cacheNpmRoot = path.resolve(\n\t\t\t\t\t\tgetExtensionsCacheDir(executionDirectory, ModuleProtocol.Npm, cacheDirectory),\n\t\t\t\t\t\t\"node_modules\"\n\t\t\t\t\t);\n\n\t\t\t\t\tconst packagePath = path.resolve(cacheNpmRoot, moduleName);\n\t\t\t\t\tconst mainFile = await resolvePackageEntryPoint(packagePath, moduleName);\n\t\t\t\t\tconst modulePath = path.resolve(packagePath, mainFile);\n\t\t\t\t\tconst exists = await fileExists(modulePath);\n\t\t\t\t\tif (exists) {\n\t\t\t\t\t\tresolvedPath = modulePath;\n\t\t\t\t\t}\n\t\t\t\t} catch {\n\t\t\t\t\t// No cached resolution either; fall through\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\t// Common module loading and caching logic\n\t\tif (resolvedPath) {\n\t\t\tconst module = await import(createModuleImportUrl(resolvedPath));\n\t\t\tmoduleCache[moduleName] = module;\n\t\t\treturn {\n\t\t\t\tmodule,\n\t\t\t\tuseDefault: false\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tmodule: undefined,\n\t\t\tuseDefault: true\n\t\t};\n\t});\n}\n"]}
package/dist/es/start.js CHANGED
@@ -42,9 +42,10 @@ export async function start(nodeOptions, nodeEngineConfig, envVars, cliCommand,
42
42
  ? (nodeOptions?.stateStorage ?? new FileStateStorage(envVars.stateFilename ?? ""))
43
43
  : undefined,
44
44
  customBootstrap: async (engineCore, context) => {
45
- configureContextIds(engineCore, envVars, requiresEngineStarted, requiresNodeIdentity, requiresTenantId, availableContextIdKeys);
45
+ configureContextIds(engineCore, envVars, requiresEngineStarted, requiresNodeIdentity, requiresTenantId);
46
46
  }
47
47
  });
48
+ configureContextIdKeys(engine, availableContextIdKeys);
48
49
  // Construct the server with the engine.
49
50
  const server = new EngineServer({ engineCore: engine });
50
51
  // Extend the engine.
@@ -91,10 +92,9 @@ export async function start(nodeOptions, nodeEngineConfig, envVars, cliCommand,
91
92
  * @param requiresEngineStarted Whether the engine is required to be started.
92
93
  * @param requiresNodeIdentity Whether the node identity is required.
93
94
  * @param requiresTenantId Whether the tenant id is required.
94
- * @param availableContextIdKeys The available context ID keys.
95
95
  * @throws GeneralError Throws if the node identity or tenant is required but not set.
96
96
  */
97
- function configureContextIds(engine, envVars, requiresEngineStarted, requiresNodeIdentity, requiresTenantId, availableContextIdKeys) {
97
+ function configureContextIds(engine, envVars, requiresEngineStarted, requiresNodeIdentity, requiresTenantId) {
98
98
  const state = engine.getState();
99
99
  if (requiresEngineStarted && requiresNodeIdentity) {
100
100
  const nodeIdentityEnabled = Coerce.boolean(envVars.nodeIdentityEnabled) ?? true;
@@ -118,6 +118,14 @@ function configureContextIds(engine, envVars, requiresEngineStarted, requiresNod
118
118
  }
119
119
  }
120
120
  }
121
+ }
122
+ /**
123
+ * Configure the context IDs for the engine.
124
+ * @param engine The engine to configure.
125
+ * @param availableContextIdKeys The available context ID keys.
126
+ * @throws GeneralError Throws if the node identity or tenant is required but not set.
127
+ */
128
+ function configureContextIdKeys(engine, availableContextIdKeys) {
121
129
  if (Is.arrayValue(availableContextIdKeys)) {
122
130
  const added = [];
123
131
  for (const availableContextIdKey of availableContextIdKeys) {
@@ -1 +1 @@
1
- {"version":3,"file":"start.js","sourceRoot":"","sources":["../../src/start.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAChE,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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AC;gBACP,MAAM,IAAI,YAAY,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;YACpD,CAAC;QACF,CAAC;IACF,CAAC;IAED,IAAI,EAAE,CAAC,UAAU,CAAC,sBAAsB,CAAC,EAAE,CAAC;QAC3C,MAAM,KAAK,GAAa,EAAE,CAAC;QAC3B,KAAK,MAAM,qBAAqB,IAAI,sBAAsB,EAAE,CAAC;YAC5D,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,qBAAqB,CAAC,GAAG,CAAC,EAAE,CAAC;gBAChD,MAAM,CAAC,eAAe,CACrB,qBAAqB,CAAC,GAAG,EACzB,qBAAqB,CAAC,uBAAuB,CAC7C,CAAC;gBACF,KAAK,CAAC,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC;YACvC,CAAC;QACF,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ContextIdKeys } from \"@twin.org/context\";\nimport { Coerce, 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 requiresTenantId = cliCommand?.definition?.requiresTenantId ?? true;\n\n\t// If the blob storage or entity storage is configured with file connectors\n\t// then we need to make sure the storageFileRoot is set\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, context) => {\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\trequiresTenantId,\n\t\t\t\tavailableContextIdKeys\n\t\t\t);\n\t\t}\n\t});\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 * Configure the context IDs for the engine.\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 requiresTenantId Whether the tenant id is required.\n * @param availableContextIdKeys The available context ID keys.\n * @throws GeneralError Throws if the node identity or tenant is required but not set.\n */\nfunction configureContextIds(\n\tengine: IEngineCore<IEngineCoreConfig, INodeEngineState>,\n\tenvVars: INodeEnvironmentVariables,\n\trequiresEngineStarted: boolean,\n\trequiresNodeIdentity: boolean,\n\trequiresTenantId: boolean,\n\tavailableContextIdKeys: { key: string; requiredHandlerFeatures: string[] }[] | undefined\n): void {\n\tconst state = engine.getState();\n\n\tif (requiresEngineStarted && requiresNodeIdentity) {\n\t\tconst nodeIdentityEnabled = Coerce.boolean(envVars.nodeIdentityEnabled) ?? true;\n\t\tif (nodeIdentityEnabled) {\n\t\t\tif (Is.stringValue(state.nodeId)) {\n\t\t\t\tengine.addContextId(ContextIdKeys.Node, state.nodeId);\n\t\t\t} else {\n\t\t\t\tthrow new GeneralError(\"node\", \"nodeIdentityNotSet\");\n\t\t\t}\n\t\t}\n\t}\n\n\tif (requiresEngineStarted && requiresTenantId) {\n\t\tconst tenantEnabled = Coerce.boolean(envVars.tenantEnabled) ?? false;\n\t\tif (tenantEnabled) {\n\t\t\tif (Is.stringValue(state.nodeTenantId)) {\n\t\t\t\tengine.addContextId(ContextIdKeys.Tenant, state.nodeTenantId);\n\t\t\t} else {\n\t\t\t\tthrow new GeneralError(\"node\", \"nodeTenantNotSet\");\n\t\t\t}\n\t\t}\n\t}\n\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"]}
1
+ {"version":3,"file":"start.js","sourceRoot":"","sources":["../../src/start.ts"],"names":[],"mappings":"AAAA,gC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AC;gBACF,KAAK,CAAC,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC;YACvC,CAAC;QACF,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ContextIdKeys } from \"@twin.org/context\";\nimport { Coerce, 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 requiresTenantId = cliCommand?.definition?.requiresTenantId ?? true;\n\n\t// If the blob storage or entity storage is configured with file connectors\n\t// then we need to make sure the storageFileRoot is set\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, context) => {\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\trequiresTenantId\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 * Configure the context IDs for the engine.\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 requiresTenantId Whether the tenant id is required.\n * @throws GeneralError Throws if the node identity or tenant is required but not set.\n */\nfunction configureContextIds(\n\tengine: IEngineCore<IEngineCoreConfig, INodeEngineState>,\n\tenvVars: INodeEnvironmentVariables,\n\trequiresEngineStarted: boolean,\n\trequiresNodeIdentity: boolean,\n\trequiresTenantId: boolean\n): void {\n\tconst state = engine.getState();\n\n\tif (requiresEngineStarted && requiresNodeIdentity) {\n\t\tconst nodeIdentityEnabled = Coerce.boolean(envVars.nodeIdentityEnabled) ?? true;\n\t\tif (nodeIdentityEnabled) {\n\t\t\tif (Is.stringValue(state.nodeId)) {\n\t\t\t\tengine.addContextId(ContextIdKeys.Node, state.nodeId);\n\t\t\t} else {\n\t\t\t\tthrow new GeneralError(\"node\", \"nodeIdentityNotSet\");\n\t\t\t}\n\t\t}\n\t}\n\n\tif (requiresEngineStarted && requiresTenantId) {\n\t\tconst tenantEnabled = Coerce.boolean(envVars.tenantEnabled) ?? false;\n\t\tif (tenantEnabled) {\n\t\t\tif (Is.stringValue(state.nodeTenantId)) {\n\t\t\t\tengine.addContextId(ContextIdKeys.Tenant, state.nodeTenantId);\n\t\t\t} else {\n\t\t\t\tthrow new GeneralError(\"node\", \"nodeTenantNotSet\");\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Configure the context IDs for the engine.\n * @param engine The engine to configure.\n * @param availableContextIdKeys The available context ID keys.\n * @throws GeneralError Throws if the node identity or tenant is required but not set.\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"]}
@@ -2,16 +2,6 @@ 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
4
  import type { INodeEnvironmentVariables } from "./models/INodeEnvironmentVariables.js";
5
- /**
6
- * Initialise the CLI.
7
- * @param processEnv The environment variables from the process.
8
- * @param args The command line arguments.
9
- * @returns The constructed CLI command if there is one.
10
- * @throws GeneralError if the command is missing or invalid.
11
- */
12
- export declare function initCli(processEnv: {
13
- [id: string]: string;
14
- }, args?: string[]): ICliCommand | undefined;
15
5
  /**
16
6
  * Parse command line arguments.
17
7
  * @param args The command line arguments.
@@ -17,6 +17,7 @@ export declare function getCommandDefinitionUserCreate(commandDefinitions: {
17
17
  * @param params.organizationIdentity The organization DID for the user.
18
18
  * @param params.email The email for the user.
19
19
  * @param params.password The password for the user.
20
+ * @param params.scope The scope for the user.
20
21
  * @param params.givenName The given name for the user.
21
22
  * @param params.familyName The family name for the user.
22
23
  * @param params.overwriteMode The mode to use when a user with the same identity already exists.
@@ -30,6 +31,7 @@ export declare function userCreate(engineCore: IEngineCore, envVars: INodeEnviro
30
31
  organizationIdentity?: string;
31
32
  email?: string;
32
33
  password?: string;
34
+ scope?: string;
33
35
  givenName?: string;
34
36
  familyName?: string;
35
37
  overwriteMode?: "skip" | "overwrite" | "error";
@@ -41,6 +43,7 @@ export declare function userCreate(engineCore: IEngineCore, envVars: INodeEnviro
41
43
  organizationDid: string;
42
44
  email: string;
43
45
  password: string;
46
+ scope: string[];
44
47
  givenName: string;
45
48
  familyName: string;
46
49
  } | undefined>;
@@ -0,0 +1,38 @@
1
+ import type { IEngineCore } from "@twin.org/engine-models";
2
+ import type { ICliCommandDefinition } from "../models/ICliCommandDefinition.js";
3
+ import type { INodeEnvironmentVariables } from "../models/INodeEnvironmentVariables.js";
4
+ /**
5
+ * Get the command definition parameters.
6
+ * @param commandDefinitions The registered command definitions.
7
+ */
8
+ export declare function getCommandDefinitionUserUpdate(commandDefinitions: {
9
+ [id: string]: ICliCommandDefinition;
10
+ }): void;
11
+ /**
12
+ * Command for creating a user.
13
+ * @param engineCore The engine core.
14
+ * @param envVars The environment variables for the node.
15
+ * @param params The parameters for the command.
16
+ * @param params.userIdentity The DID for the user.
17
+ * @param params.organizationIdentity The organization DID for the user.
18
+ * @param params.email The email for the user.
19
+ * @param params.scope The scope for the user.
20
+ * @param params.givenName The given name for the user.
21
+ * @param params.familyName The family name for the user.
22
+ * @returns The updated user details or undefined if skipped.
23
+ */
24
+ export declare function userUpdate(engineCore: IEngineCore, envVars: INodeEnvironmentVariables, params: {
25
+ userIdentity?: string;
26
+ organizationIdentity?: string;
27
+ email?: string;
28
+ scope?: string;
29
+ givenName?: string;
30
+ familyName?: string;
31
+ }): Promise<{
32
+ did: string;
33
+ organizationDid: string;
34
+ email: string;
35
+ scope: string[];
36
+ givenName: string;
37
+ familyName: string;
38
+ } | undefined>;
package/docs/changelog.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @twin.org/node-core - Changelog
2
2
 
3
+ ## [0.0.3-next.18](https://github.com/twinfoundation/node/compare/node-core-v0.0.3-next.17...node-core-v0.0.3-next.18) (2026-02-04)
4
+
5
+
6
+ ### Features
7
+
8
+ * env-prefix option and user-update cli command ([#83](https://github.com/twinfoundation/node/issues/83)) ([fc48efa](https://github.com/twinfoundation/node/commit/fc48efa7ad72173def048170c3afb5eeb9f1b292))
9
+
10
+ ## [0.0.3-next.17](https://github.com/twinfoundation/node/compare/node-core-v0.0.3-next.16...node-core-v0.0.3-next.17) (2026-02-02)
11
+
12
+
13
+ ### Features
14
+
15
+ * update rights management ([5c992c6](https://github.com/twinfoundation/node/commit/5c992c6b0d72f3eeaa39ee267e096d9a3f477f4e))
16
+
3
17
  ## [0.0.3-next.16](https://github.com/twinfoundation/node/compare/node-core-v0.0.3-next.15...node-core-v0.0.3-next.16) (2026-01-28)
4
18
 
5
19
 
@@ -45,7 +45,6 @@
45
45
  - [extensionsInitialiseEngine](functions/extensionsInitialiseEngine.md)
46
46
  - [extensionsInitialiseEngineServer](functions/extensionsInitialiseEngineServer.md)
47
47
  - [shutdownExtensions](functions/shutdownExtensions.md)
48
- - [initCli](functions/initCli.md)
49
48
  - [parseCommandLineArgs](functions/parseCommandLineArgs.md)
50
49
  - [constructCliCommand](functions/constructCliCommand.md)
51
50
  - [executeCommand](functions/executeCommand.md)
package/locales/en.json CHANGED
@@ -38,8 +38,7 @@
38
38
  "tenantAdminComponentNotRegistered": "Multi-tenant support must be enabled to use this command."
39
39
  },
40
40
  "tenantUpdate": {
41
- "tenantAdminComponentNotRegistered": "Multi-tenant support must be enabled to use this command.",
42
- "tenantNotFound": "The tenant with ID \"{notFoundId}\" was not found in the system."
41
+ "tenantAdminComponentNotRegistered": "Multi-tenant support must be enabled to use this command."
43
42
  },
44
43
  "userCreate": {
45
44
  "passwordTooShort": "The password provided is too short, it must be at least {minLength} characters long.",
@@ -49,7 +48,6 @@
49
48
  "vaultKeyAlreadyExists": "The vault key with ID already exists and overwriteMode is set to \"error\"."
50
49
  },
51
50
  "nodeSetTenant": {
52
- "tenantNotFound": "The tenant with ID \"{notFoundId}\" was not found in the system.",
53
51
  "tenantAdminComponentNotRegistered": "Multi-tenant support must be enabled to use this command."
54
52
  },
55
53
  "nodeSetIdentity": {
@@ -86,6 +84,9 @@
86
84
  "description": "Bootstrap in legacy mode for backwards compatibility, **will be deprecated in future versions**",
87
85
  "example": "bootstrap-legacy --load-env=\"./.env.bootstrap-legacy\"",
88
86
  "params": {
87
+ "env-prefix": {
88
+ "description": "Prefix to use for standard .env files e.g. TWIN_."
89
+ },
89
90
  "load-env": {
90
91
  "description": "Comma separated list of paths to .env files to read input parameters from."
91
92
  }
@@ -110,6 +111,9 @@
110
111
  "description": "Create an identity",
111
112
  "example": "identity-create --mnemonic=\"...\" --fund-wallet=true",
112
113
  "params": {
114
+ "env-prefix": {
115
+ "description": "Prefix to use for standard .env files e.g. TWIN_."
116
+ },
113
117
  "mnemonic": {
114
118
  "description": "The mnemonic phrase to use for the identity. If not provided, a random mnemonic will be generated."
115
119
  },
@@ -161,6 +165,9 @@
161
165
  "description": "Import an identity",
162
166
  "example": "identity-import --identity=\"did:iota:...\" --mnemonic=\"...\"",
163
167
  "params": {
168
+ "env-prefix": {
169
+ "description": "Prefix to use for standard .env files e.g. TWIN_."
170
+ },
164
171
  "identity": {
165
172
  "description": "The DID of the identity to import."
166
173
  },
@@ -180,6 +187,9 @@
180
187
  "description": "Create a verifiable credential",
181
188
  "example": "identity-verifiable-credential-create --identity=\"did:iota:....\" --verification-method-id=\"my-id\" --subject-json=\"./subject.json\"",
182
189
  "params": {
190
+ "env-prefix": {
191
+ "description": "Prefix to use for standard .env files e.g. TWIN_."
192
+ },
183
193
  "identity": {
184
194
  "description": "The DID of the identity to use to create the credential."
185
195
  },
@@ -221,6 +231,9 @@
221
231
  "description": "Import an identity verification method",
222
232
  "example": "identity-verification-method-import --identity=\"did:iota:....\" --verification-method-type=\"verificationMethod\" --verification-method-id=\"my-key-1\" ----private-key-hex=\"15...a2\"",
223
233
  "params": {
234
+ "env-prefix": {
235
+ "description": "Prefix to use for standard .env files e.g. TWIN_."
236
+ },
224
237
  "identity": {
225
238
  "description": "The DID of the identity to import the verification method to."
226
239
  },
@@ -250,6 +263,9 @@
250
263
  "description": "Create an identity verification method",
251
264
  "example": "identity-verification-method-create --identity=\"did:iota:....\" --verification-method-type=\"verificationMethod\" --verification-method-id=\"my-key-1\" --controller=\"did:iota:....\"",
252
265
  "params": {
266
+ "env-prefix": {
267
+ "description": "Prefix to use for standard .env files e.g. TWIN_."
268
+ },
253
269
  "identity": {
254
270
  "description": "The DID of the identity to add the verification method to."
255
271
  },
@@ -298,6 +314,9 @@
298
314
  "description": "Set the node identity",
299
315
  "example": "node-set-identity --identity=\"did:iota...\"",
300
316
  "params": {
317
+ "env-prefix": {
318
+ "description": "Prefix to use for standard .env files e.g. TWIN_."
319
+ },
301
320
  "identity": {
302
321
  "description": "The identity to set in the node."
303
322
  },
@@ -314,6 +333,9 @@
314
333
  "description": "Create a tenant with associated api key",
315
334
  "example": "tenant-create --tenant-id=\"0011..aabb\" --api-key=\"aabb..0099\" --label=\"My Tenant\" --public-origin=\"https://example.com:1234\"",
316
335
  "params": {
336
+ "env-prefix": {
337
+ "description": "Prefix to use for standard .env files e.g. TWIN_."
338
+ },
317
339
  "tenant-id": {
318
340
  "description": "The tenant ID to add. If not provided a random tenant id will be generated."
319
341
  },
@@ -351,6 +373,9 @@
351
373
  "description": "Import a tenant with associated api key",
352
374
  "example": "tenant-import --tenant-id=\"0011..aabb\" --api-key=\"aabb..0099\" --label=\"My Tenant\" --public-origin=\"https://example.com:1234\"",
353
375
  "params": {
376
+ "env-prefix": {
377
+ "description": "Prefix to use for standard .env files e.g. TWIN_."
378
+ },
354
379
  "tenant-id": {
355
380
  "description": "The tenant ID to import."
356
381
  },
@@ -376,6 +401,9 @@
376
401
  "description": "Update a tenant with associated api key",
377
402
  "example": "tenant-update --tenant-id=\"0011..aabb\" --api-key=\"aabb..0099\" --label=\"My Tenant\" --public-origin=\"https://example.com:1234\"",
378
403
  "params": {
404
+ "env-prefix": {
405
+ "description": "Prefix to use for standard .env files e.g. TWIN_."
406
+ },
379
407
  "tenant-id": {
380
408
  "description": "The tenant ID to update."
381
409
  },
@@ -401,6 +429,9 @@
401
429
  "description": "Set the node tenant",
402
430
  "example": "node-set-tenant --tenant-id=\"0011..aabb\"",
403
431
  "params": {
432
+ "env-prefix": {
433
+ "description": "Prefix to use for standard .env files e.g. TWIN_."
434
+ },
404
435
  "tenant-id": {
405
436
  "description": "The tenant ID to add. If not provided a random tenant id will be generated."
406
437
  },
@@ -414,8 +445,11 @@
414
445
  },
415
446
  "user-create": {
416
447
  "description": "Create a user",
417
- "example": "user-create --user-identity=\"did:iota:....\" --organization-identity=\"did:iota:....\" --email=\"bob@examples.com\" --password=\"pass1234\" --givenName=\"Bob\" --familyName=\"Smith\"",
448
+ "example": "user-create --user-identity=\"did:iota:....\" --organization-identity=\"did:iota:....\" --email=\"bob@examples.com\" --password=\"pass1234\" --scope=\"tenant-admin\" --givenName=\"Bob\" --familyName=\"Smith\"",
418
449
  "params": {
450
+ "env-prefix": {
451
+ "description": "Prefix to use for standard .env files e.g. TWIN_."
452
+ },
419
453
  "user-identity": {
420
454
  "description": "The DID to associate the user with."
421
455
  },
@@ -428,6 +462,9 @@
428
462
  "password": {
429
463
  "description": "The password for the user."
430
464
  },
465
+ "scope": {
466
+ "description": "List of scopes to associate with the user, comma separated."
467
+ },
431
468
  "given-name": {
432
469
  "description": "The given name of the user."
433
470
  },
@@ -456,13 +493,54 @@
456
493
  "storingProfile": "Storing profile",
457
494
  "userCreated": "User created",
458
495
  "skipping": "The user with ID already exists, skipping creation",
459
- "overwriting": "Overwriting existing user with ID"
496
+ "overwriting": "Overwriting existing user with ID",
497
+ "email": "Email",
498
+ "password": "Password"
499
+ }
500
+ },
501
+ "user-update": {
502
+ "description": "Update a user",
503
+ "example": "user-update --email=\"bob@examples.com\" --user-identity=\"did:iota:....\" --organization-identity=\"did:iota:....\" --scope=\"tenant-admin\" --givenName=\"Bob\" --familyName=\"Smith\"",
504
+ "params": {
505
+ "env-prefix": {
506
+ "description": "Prefix to use for standard .env files e.g. TWIN_."
507
+ },
508
+ "user-identity": {
509
+ "description": "The DID to associate the user with."
510
+ },
511
+ "organization-identity": {
512
+ "description": "The organization DID to associate the user with."
513
+ },
514
+ "email": {
515
+ "description": "The email address of the user."
516
+ },
517
+ "scope": {
518
+ "description": "List of scopes to associate with the user, comma separated."
519
+ },
520
+ "given-name": {
521
+ "description": "The given name of the user."
522
+ },
523
+ "family-name": {
524
+ "description": "The family name of the user."
525
+ },
526
+ "load-env": {
527
+ "description": "Comma separated list of paths to .env files to read input parameters from."
528
+ }
529
+ },
530
+ "labels": {
531
+ "updating": "Updating user",
532
+ "storingUser": "Storing user",
533
+ "storingProfile": "Storing profile",
534
+ "userUpdated": "User updated"
460
535
  }
461
536
  },
462
537
  "vault-key-create": {
463
538
  "description": "Create a vault key for an identity",
464
539
  "example": "vault-key-create --identity=\"did:iota:....\" --key-id=\"my-key\" --type=\"Ed25519\"",
465
540
  "params": {
541
+ "env-prefix": {
542
+ "description": "Prefix to use for standard .env files e.g. TWIN_."
543
+ },
466
544
  "identity": {
467
545
  "description": "The DID to associate the key with."
468
546
  },
@@ -505,6 +583,9 @@
505
583
  "description": "Import a vault key for an identity",
506
584
  "example": "vault-key-import --identity=\"did:iota:....\" --key-id=\"my-key\" --key-type=Ed25519 --private-key-hex=\"15...a2\"",
507
585
  "params": {
586
+ "env-prefix": {
587
+ "description": "Prefix to use for standard .env files e.g. TWIN_."
588
+ },
508
589
  "identity": {
509
590
  "description": "The DID to associate the key with."
510
591
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/node-core",
3
- "version": "0.0.3-next.16",
3
+ "version": "0.0.3-next.18",
4
4
  "description": "TWIN Node Core for serving APIs using the specified configuration",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,27 +0,0 @@
1
- # Function: initCli()
2
-
3
- > **initCli**(`processEnv`, `args?`): [`ICliCommand`](../interfaces/ICliCommand.md) \| `undefined`
4
-
5
- Initialise the CLI.
6
-
7
- ## Parameters
8
-
9
- ### processEnv
10
-
11
- The environment variables from the process.
12
-
13
- ### args?
14
-
15
- `string`[]
16
-
17
- The command line arguments.
18
-
19
- ## Returns
20
-
21
- [`ICliCommand`](../interfaces/ICliCommand.md) \| `undefined`
22
-
23
- The constructed CLI command if there is one.
24
-
25
- ## Throws
26
-
27
- GeneralError if the command is missing or invalid.