@twin.org/node-core 0.0.3-next.4 → 0.0.3-next.40

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 (186) hide show
  1. package/README.md +3 -1
  2. package/dist/es/builders/engineEnvBuilder.js +443 -126
  3. package/dist/es/builders/engineEnvBuilder.js.map +1 -1
  4. package/dist/es/builders/engineServerEnvBuilder.js +89 -32
  5. package/dist/es/builders/engineServerEnvBuilder.js.map +1 -1
  6. package/dist/es/builders/extensionsBuilder.js.map +1 -1
  7. package/dist/es/cli.js +247 -0
  8. package/dist/es/cli.js.map +1 -0
  9. package/dist/es/commands/bootstrapLegacy.js +199 -0
  10. package/dist/es/commands/bootstrapLegacy.js.map +1 -0
  11. package/dist/es/commands/help.js +85 -0
  12. package/dist/es/commands/help.js.map +1 -0
  13. package/dist/es/commands/identityCreate.js +327 -0
  14. package/dist/es/commands/identityCreate.js.map +1 -0
  15. package/dist/es/commands/identityImports.js +82 -0
  16. package/dist/es/commands/identityImports.js.map +1 -0
  17. package/dist/es/commands/identityVerifiableCredentialCreate.js +146 -0
  18. package/dist/es/commands/identityVerifiableCredentialCreate.js.map +1 -0
  19. package/dist/es/commands/identityVerificationMethodCreate.js +228 -0
  20. package/dist/es/commands/identityVerificationMethodCreate.js.map +1 -0
  21. package/dist/es/commands/identityVerificationMethodImport.js +126 -0
  22. package/dist/es/commands/identityVerificationMethodImport.js.map +1 -0
  23. package/dist/es/commands/nodeSetIdentity.js +64 -0
  24. package/dist/es/commands/nodeSetIdentity.js.map +1 -0
  25. package/dist/es/commands/nodeSetTenant.js +68 -0
  26. package/dist/es/commands/nodeSetTenant.js.map +1 -0
  27. package/dist/es/commands/tenantCreate.js +139 -0
  28. package/dist/es/commands/tenantCreate.js.map +1 -0
  29. package/dist/es/commands/tenantImport.js +97 -0
  30. package/dist/es/commands/tenantImport.js.map +1 -0
  31. package/dist/es/commands/tenantUpdate.js +94 -0
  32. package/dist/es/commands/tenantUpdate.js.map +1 -0
  33. package/dist/es/commands/userCreate.js +239 -0
  34. package/dist/es/commands/userCreate.js.map +1 -0
  35. package/dist/es/commands/userUpdate.js +154 -0
  36. package/dist/es/commands/userUpdate.js.map +1 -0
  37. package/dist/es/commands/vaultKeyCreate.js +191 -0
  38. package/dist/es/commands/vaultKeyCreate.js.map +1 -0
  39. package/dist/es/commands/vaultKeyImport.js +104 -0
  40. package/dist/es/commands/vaultKeyImport.js.map +1 -0
  41. package/dist/es/defaults.js +19 -1
  42. package/dist/es/defaults.js.map +1 -1
  43. package/dist/es/index.js +11 -4
  44. package/dist/es/index.js.map +1 -1
  45. package/dist/es/models/ICliArgs.js +4 -0
  46. package/dist/es/models/ICliArgs.js.map +1 -0
  47. package/dist/es/models/ICliCommand.js +2 -0
  48. package/dist/es/models/ICliCommand.js.map +1 -0
  49. package/dist/es/models/ICliCommandDefinition.js +2 -0
  50. package/dist/es/models/ICliCommandDefinition.js.map +1 -0
  51. package/dist/es/models/ICliCommandDefinitionParam.js +2 -0
  52. package/dist/es/models/ICliCommandDefinitionParam.js.map +1 -0
  53. package/dist/es/models/IEngineEnvironmentVariables.js.map +1 -1
  54. package/dist/es/models/IEngineServerEnvironmentVariables.js.map +1 -1
  55. package/dist/es/models/INodeEngineState.js.map +1 -1
  56. package/dist/es/models/INodeEnvironmentVariables.js.map +1 -1
  57. package/dist/es/models/INodeOptions.js.map +1 -1
  58. package/dist/es/models/cliCommandParamType.js +4 -0
  59. package/dist/es/models/cliCommandParamType.js.map +1 -0
  60. package/dist/es/models/nodeExtensionInitialiseEngineMethod.js +2 -0
  61. package/dist/es/models/nodeExtensionInitialiseEngineMethod.js.map +1 -0
  62. package/dist/es/models/nodeExtensionInitialiseEngineServerMethod.js +2 -0
  63. package/dist/es/models/nodeExtensionInitialiseEngineServerMethod.js.map +1 -0
  64. package/dist/es/models/nodeExtensionInitialiseMethod.js +2 -0
  65. package/dist/es/models/nodeExtensionInitialiseMethod.js.map +1 -0
  66. package/dist/es/models/nodeExtensionShutdownMethod.js +4 -0
  67. package/dist/es/models/nodeExtensionShutdownMethod.js.map +1 -0
  68. package/dist/es/node.js +86 -39
  69. package/dist/es/node.js.map +1 -1
  70. package/dist/es/start.js +139 -0
  71. package/dist/es/start.js.map +1 -0
  72. package/dist/es/utils.js +12 -22
  73. package/dist/es/utils.js.map +1 -1
  74. package/dist/types/builders/engineEnvBuilder.d.ts +64 -1
  75. package/dist/types/builders/engineServerEnvBuilder.d.ts +11 -2
  76. package/dist/types/cli.d.ts +56 -0
  77. package/dist/types/commands/bootstrapLegacy.d.ts +66 -0
  78. package/dist/types/commands/help.d.ts +23 -0
  79. package/dist/types/commands/identityCreate.d.ts +39 -0
  80. package/dist/types/commands/identityImports.d.ts +24 -0
  81. package/dist/types/commands/identityVerifiableCredentialCreate.d.ts +43 -0
  82. package/dist/types/commands/identityVerificationMethodCreate.d.ts +47 -0
  83. package/dist/types/commands/identityVerificationMethodImport.d.ts +31 -0
  84. package/dist/types/commands/nodeSetIdentity.d.ts +22 -0
  85. package/dist/types/commands/nodeSetTenant.d.ts +22 -0
  86. package/dist/types/commands/tenantCreate.d.ts +38 -0
  87. package/dist/types/commands/tenantImport.d.ts +26 -0
  88. package/dist/types/commands/tenantUpdate.d.ts +26 -0
  89. package/dist/types/commands/userCreate.d.ts +51 -0
  90. package/dist/types/commands/userUpdate.d.ts +40 -0
  91. package/dist/types/commands/vaultKeyCreate.d.ts +43 -0
  92. package/dist/types/commands/vaultKeyImport.d.ts +28 -0
  93. package/dist/types/defaults.d.ts +10 -1
  94. package/dist/types/index.d.ts +11 -4
  95. package/dist/types/models/ICliArgs.d.ts +20 -0
  96. package/dist/types/models/ICliCommand.d.ts +17 -0
  97. package/dist/types/models/ICliCommandDefinition.d.ts +46 -0
  98. package/dist/types/models/ICliCommandDefinitionParam.d.ts +35 -0
  99. package/dist/types/models/IEngineEnvironmentVariables.d.ts +117 -60
  100. package/dist/types/models/IEngineServerEnvironmentVariables.d.ts +8 -0
  101. package/dist/types/models/INodeEngineState.d.ts +0 -8
  102. package/dist/types/models/INodeEnvironmentVariables.d.ts +0 -38
  103. package/dist/types/models/INodeOptions.d.ts +6 -2
  104. package/dist/types/models/cliCommandParamType.d.ts +4 -0
  105. package/dist/types/models/nodeExtensionInitialiseEngineMethod.d.ts +7 -0
  106. package/dist/types/models/nodeExtensionInitialiseEngineServerMethod.d.ts +8 -0
  107. package/dist/types/models/nodeExtensionInitialiseMethod.d.ts +8 -0
  108. package/dist/types/models/nodeExtensionShutdownMethod.d.ts +5 -0
  109. package/dist/types/node.d.ts +5 -4
  110. package/dist/types/{server.d.ts → start.d.ts} +4 -2
  111. package/dist/types/utils.d.ts +6 -8
  112. package/docs/changelog.md +532 -176
  113. package/docs/examples.md +99 -1
  114. package/docs/reference/functions/buildConfiguration.md +1 -1
  115. package/docs/reference/functions/buildEngineServerConfiguration.md +1 -1
  116. package/docs/reference/functions/constructCliCommand.md +27 -0
  117. package/docs/reference/functions/executeCommand.md +29 -0
  118. package/docs/reference/functions/getEnvDefaults.md +19 -0
  119. package/docs/reference/functions/getScriptDirectory.md +19 -0
  120. package/docs/reference/functions/isAuthEntityStorageRequired.md +20 -0
  121. package/docs/reference/functions/isAutomationRequired.md +20 -0
  122. package/docs/reference/functions/isBackgroundTasksRequired.md +20 -0
  123. package/docs/reference/functions/isFederatedCatalogueRequired.md +20 -0
  124. package/docs/reference/functions/isImmutableProofRequired.md +20 -0
  125. package/docs/reference/functions/isRightsManagementRequired.md +20 -0
  126. package/docs/reference/functions/isTaskSchedulerRequired.md +20 -0
  127. package/docs/reference/functions/isTelemetryRequired.md +20 -0
  128. package/docs/reference/functions/isTrustRequired.md +20 -0
  129. package/docs/reference/functions/isUrlTransformerRequired.md +20 -0
  130. package/docs/reference/functions/parseCommandLineArgs.md +19 -0
  131. package/docs/reference/functions/processEnvOptions.md +27 -0
  132. package/docs/reference/functions/registerCommands.md +9 -0
  133. package/docs/reference/functions/resolvePackageEntryPoint.md +2 -2
  134. package/docs/reference/functions/run.md +8 -2
  135. package/docs/reference/functions/start.md +9 -3
  136. package/docs/reference/functions/substituteEnvOptions.md +25 -0
  137. package/docs/reference/index.md +26 -13
  138. package/docs/reference/interfaces/ICacheMetadata.md +3 -3
  139. package/docs/reference/interfaces/ICliArgs.md +35 -0
  140. package/docs/reference/interfaces/ICliCommand.md +23 -0
  141. package/docs/reference/interfaces/ICliCommandDefinition.md +101 -0
  142. package/docs/reference/interfaces/ICliCommandDefinitionParam.md +65 -0
  143. package/docs/reference/interfaces/IEngineEnvironmentVariables.md +420 -311
  144. package/docs/reference/interfaces/IEngineServerEnvironmentVariables.md +545 -368
  145. package/docs/reference/interfaces/IModuleProtocol.md +3 -3
  146. package/docs/reference/interfaces/INodeEngineState.md +4 -20
  147. package/docs/reference/interfaces/INodeEnvironmentVariables.md +551 -450
  148. package/docs/reference/interfaces/INodeOptions.md +44 -36
  149. package/docs/reference/interfaces/IProtocolHandlerResult.md +2 -2
  150. package/docs/reference/type-aliases/CliCommandParamType.md +5 -0
  151. package/docs/reference/type-aliases/NodeExtensionInitialiseEngineMethod.md +1 -1
  152. package/docs/reference/type-aliases/NodeExtensionInitialiseEngineServerMethod.md +1 -1
  153. package/docs/reference/type-aliases/NodeExtensionInitialiseMethod.md +1 -1
  154. package/docs/reference/type-aliases/NodeExtensionShutdownMethod.md +1 -1
  155. package/docs/reference/variables/ModuleProtocol.md +5 -5
  156. package/docs/reference/variables/TRUST_VERIFICATION_METHOD_ID.md +3 -0
  157. package/docs/reference/variables/URL_TRANSFORMER_ENCRYPTION_KEY_ID.md +3 -0
  158. package/locales/en.json +600 -30
  159. package/package.json +10 -6
  160. package/dist/es/bootstrap.js +0 -366
  161. package/dist/es/bootstrap.js.map +0 -1
  162. package/dist/es/identity.js +0 -182
  163. package/dist/es/identity.js.map +0 -1
  164. package/dist/es/models/nodeExtensionMethods.js +0 -2
  165. package/dist/es/models/nodeExtensionMethods.js.map +0 -1
  166. package/dist/es/models/nodeFeatures.js +0 -21
  167. package/dist/es/models/nodeFeatures.js.map +0 -1
  168. package/dist/es/server.js +0 -81
  169. package/dist/es/server.js.map +0 -1
  170. package/dist/types/bootstrap.d.ts +0 -68
  171. package/dist/types/identity.d.ts +0 -14
  172. package/dist/types/models/nodeExtensionMethods.d.ts +0 -27
  173. package/dist/types/models/nodeFeatures.d.ts +0 -21
  174. package/docs/detailed-guide.md +0 -129
  175. package/docs/reference/functions/bootstrap.md +0 -29
  176. package/docs/reference/functions/bootstrapAuth.md +0 -35
  177. package/docs/reference/functions/bootstrapBlobEncryption.md +0 -35
  178. package/docs/reference/functions/bootstrapImmutableProofMethod.md +0 -35
  179. package/docs/reference/functions/bootstrapNodeAdminUser.md +0 -35
  180. package/docs/reference/functions/bootstrapNodeId.md +0 -35
  181. package/docs/reference/functions/bootstrapSynchronisedStorage.md +0 -35
  182. package/docs/reference/functions/bootstrapTenantId.md +0 -35
  183. package/docs/reference/functions/getFeatures.md +0 -19
  184. package/docs/reference/type-aliases/NodeFeatures.md +0 -5
  185. package/docs/reference/variables/NodeFeatures.md +0 -25
  186. package/docs/reference/variables/VC_AUTHENTICATION_VERIFICATION_METHOD_ID.md +0 -3
@@ -0,0 +1,199 @@
1
+ // Copyright 2026 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ import { CLIDisplay } from "@twin.org/cli-core";
4
+ import { ContextIdKeys, ContextIdStore } from "@twin.org/context";
5
+ import { Coerce, Converter, GeneralError, I18n, Is } from "@twin.org/core";
6
+ import { identityCreate } from "./identityCreate.js";
7
+ import { identityVerificationMethodCreate } from "./identityVerificationMethodCreate.js";
8
+ import { nodeSetIdentity } from "./nodeSetIdentity.js";
9
+ import { nodeSetTenant } from "./nodeSetTenant.js";
10
+ import { tenantCreate } from "./tenantCreate.js";
11
+ import { userCreate } from "./userCreate.js";
12
+ import { vaultKeyCreate } from "./vaultKeyCreate.js";
13
+ import { vaultKeyImport } from "./vaultKeyImport.js";
14
+ import { isTrustRequired, isUrlTransformerRequired } from "../builders/engineEnvBuilder.js";
15
+ const COMMAND_NAME = "bootstrap-legacy";
16
+ /**
17
+ * Get the command definition parameters.
18
+ * @param commandDefinitions The registered command definitions.
19
+ */
20
+ export function getCommandDefinitionBootstrapLegacy(commandDefinitions) {
21
+ commandDefinitions[COMMAND_NAME] = {
22
+ command: COMMAND_NAME,
23
+ description: I18n.formatMessage("node.cli.commands.bootstrap-legacy.description"),
24
+ example: I18n.formatMessage("node.cli.commands.bootstrap-legacy.example"),
25
+ requiresNodeIdentity: false,
26
+ requiresTenantId: false,
27
+ params: [
28
+ {
29
+ key: "env-prefix",
30
+ type: "string",
31
+ description: I18n.formatMessage("node.cli.commands.bootstrap-legacy.params.env-prefix.description"),
32
+ required: false
33
+ },
34
+ {
35
+ key: "load-env",
36
+ type: "string",
37
+ description: I18n.formatMessage("node.cli.commands.bootstrap-legacy.params.load-env.description"),
38
+ required: false
39
+ }
40
+ ],
41
+ action: async (engineCore, envVars, params) => bootstrapLegacy(engineCore, envVars, params)
42
+ };
43
+ }
44
+ /**
45
+ * Command for legacy bootstrap.
46
+ * @param engineCore The engine core.
47
+ * @param envVars The environment variables for the node.
48
+ * @param params The parameters for the command.
49
+ */
50
+ export async function bootstrapLegacy(engineCore, envVars, params) {
51
+ const features = (envVars.features ?? "")
52
+ .split(",")
53
+ .map(f => f.trim())
54
+ .filter(f => f.length > 0);
55
+ const state = engineCore.getState();
56
+ const requireWallet = features.includes("node-wallet");
57
+ let tenantId = state.nodeTenantId;
58
+ let nodeId = state.nodeId;
59
+ if (features.length === 0) {
60
+ throw new GeneralError("bootstrapLegacy", "noFeaturesEnabled");
61
+ }
62
+ if (features.includes("node-identity") && Is.empty(nodeId)) {
63
+ CLIDisplay.break();
64
+ CLIDisplay.section(I18n.formatMessage("node.cli.commands.bootstrap-legacy.labels.nodeIdentityCreate"));
65
+ const nodeIdentity = await identityCreate(engineCore, envVars, {
66
+ identity: envVars.nodeIdentity,
67
+ mnemonic: envVars.nodeMnemonic,
68
+ fundWallet: requireWallet
69
+ });
70
+ nodeId = nodeIdentity.did;
71
+ CLIDisplay.break();
72
+ CLIDisplay.section(I18n.formatMessage("node.cli.commands.bootstrap-legacy.labels.nodeAuthKeyCreate"));
73
+ await vaultKeyCreate(engineCore, envVars, {
74
+ identity: nodeIdentity.did,
75
+ keyType: "Ed25519",
76
+ keyId: envVars.authSigningKeyId,
77
+ overwriteMode: "skip"
78
+ });
79
+ if (isTrustRequired(envVars)) {
80
+ CLIDisplay.break();
81
+ CLIDisplay.section(I18n.formatMessage("node.cli.commands.bootstrap-legacy.labels.trustVerificationMethodCreate"));
82
+ await identityVerificationMethodCreate(engineCore, envVars, {
83
+ identity: nodeIdentity.did,
84
+ verificationMethodType: "assertionMethod",
85
+ verificationMethodId: envVars.trustVerificationMethodId,
86
+ overwriteMode: "skip"
87
+ });
88
+ }
89
+ if ((Coerce.boolean(envVars.synchronisedStorageEnabled) ?? false) &&
90
+ Is.stringBase64(envVars.synchronisedStorageBlobStorageKey)) {
91
+ CLIDisplay.break();
92
+ CLIDisplay.section(I18n.formatMessage("node.cli.commands.bootstrap-legacy.labels.synchronisedStorageKeyAdd"));
93
+ await vaultKeyImport(engineCore, envVars, {
94
+ identity: nodeIdentity.did,
95
+ keyType: "ChaCha20Poly1305",
96
+ keyId: envVars.synchronisedStorageBlobStorageEncryptionKeyId,
97
+ privateKeyHex: Converter.bytesToHex(Converter.base64ToBytes(envVars.synchronisedStorageBlobStorageKey))
98
+ });
99
+ }
100
+ if (isUrlTransformerRequired(envVars)) {
101
+ CLIDisplay.break();
102
+ CLIDisplay.section(I18n.formatMessage("node.cli.commands.bootstrap-legacy.labels.urlTransformParamKeyAdd"));
103
+ await vaultKeyCreate(engineCore, envVars, {
104
+ identity: nodeIdentity.did,
105
+ keyType: "ChaCha20Poly1305",
106
+ keyId: envVars.urlTransformerEncryptionKeyId
107
+ });
108
+ }
109
+ CLIDisplay.break();
110
+ CLIDisplay.section(I18n.formatMessage("node.cli.commands.bootstrap-legacy.labels.nodeIdentitySet"));
111
+ await nodeSetIdentity(engineCore, envVars, {
112
+ identity: nodeId
113
+ });
114
+ const tenantEnabled = Coerce.boolean(envVars.tenantEnabled) ?? false;
115
+ if (tenantEnabled) {
116
+ if (Is.empty(tenantId)) {
117
+ await ContextIdStore.run({ [ContextIdKeys.Node]: nodeId }, async () => {
118
+ CLIDisplay.break();
119
+ CLIDisplay.section(I18n.formatMessage("node.cli.commands.bootstrap-legacy.labels.nodeTenantCreate"));
120
+ const tenantDetails = await tenantCreate(engineCore, envVars, {
121
+ tenantId: envVars.tenantId,
122
+ apiKey: envVars.tenantApiKey,
123
+ label: "Node"
124
+ });
125
+ CLIDisplay.break();
126
+ CLIDisplay.section(I18n.formatMessage("node.cli.commands.bootstrap-legacy.labels.nodeTenantSet"));
127
+ await nodeSetTenant(engineCore, envVars, {
128
+ tenantId: tenantDetails.tenantId
129
+ });
130
+ tenantId = tenantDetails.tenantId;
131
+ });
132
+ }
133
+ }
134
+ }
135
+ if (features.includes("node-admin-user")) {
136
+ await ContextIdStore.run({ [ContextIdKeys.Node]: nodeId, [ContextIdKeys.Tenant]: tenantId }, async () => {
137
+ CLIDisplay.break();
138
+ CLIDisplay.section(I18n.formatMessage("node.cli.commands.bootstrap-legacy.labels.organisationCreate"));
139
+ const organisation = await identityCreate(engineCore, envVars, {
140
+ identity: envVars.organizationIdentity,
141
+ mnemonic: envVars.organizationMnemonic,
142
+ fundWallet: requireWallet
143
+ });
144
+ if (Coerce.boolean(envVars.blobStorageEnableEncryption) ?? false) {
145
+ CLIDisplay.break();
146
+ CLIDisplay.section(I18n.formatMessage("node.cli.commands.bootstrap-legacy.labels.blobStorageKeyCreate"));
147
+ await vaultKeyCreate(engineCore, envVars, {
148
+ identity: organisation.did,
149
+ keyType: "ChaCha20Poly1305",
150
+ keyId: envVars.blobStorageEncryptionKeyId,
151
+ overwriteMode: "skip"
152
+ });
153
+ }
154
+ const defaultAttestationConnectorType = engineCore.getRegisteredInstanceTypeOptional("attestationConnector");
155
+ if (!Is.empty(defaultAttestationConnectorType)) {
156
+ CLIDisplay.break();
157
+ CLIDisplay.section(I18n.formatMessage("node.cli.commands.bootstrap-legacy.labels.attestationMethodCreate"));
158
+ await identityVerificationMethodCreate(engineCore, envVars, {
159
+ identity: organisation.did,
160
+ verificationMethodType: "assertionMethod",
161
+ verificationMethodId: envVars.attestationVerificationMethodId,
162
+ overwriteMode: "skip"
163
+ });
164
+ }
165
+ const defaultImmutableProofComponentType = engineCore.getRegisteredInstanceTypeOptional("immutableProofComponent");
166
+ if (!Is.empty(defaultImmutableProofComponentType)) {
167
+ CLIDisplay.break();
168
+ CLIDisplay.section(I18n.formatMessage("node.cli.commands.bootstrap-legacy.labels.immutableProofMethodCreate"));
169
+ await identityVerificationMethodCreate(engineCore, envVars, {
170
+ identity: organisation.did,
171
+ verificationMethodType: "assertionMethod",
172
+ verificationMethodId: envVars.immutableProofVerificationMethodId,
173
+ overwriteMode: "skip"
174
+ });
175
+ }
176
+ CLIDisplay.break();
177
+ CLIDisplay.section(I18n.formatMessage("node.cli.commands.bootstrap-legacy.labels.adminIdentityCreate"));
178
+ const adminUserIdentity = await identityCreate(engineCore, envVars, {
179
+ identity: envVars.adminUserIdentity,
180
+ mnemonic: envVars.adminUserMnemonic,
181
+ controller: organisation.did
182
+ });
183
+ CLIDisplay.break();
184
+ CLIDisplay.section(I18n.formatMessage("node.cli.commands.bootstrap-legacy.labels.adminUserCreate"));
185
+ await userCreate(engineCore, envVars, {
186
+ userIdentity: adminUserIdentity.did,
187
+ organizationIdentity: organisation.did,
188
+ tenantId,
189
+ email: envVars.adminUserName ?? "admin@node",
190
+ password: envVars.adminUserPassword,
191
+ scope: ["tenant-admin", "user-admin"].join(","),
192
+ givenName: "Node",
193
+ familyName: "Admin",
194
+ overwriteMode: "skip"
195
+ });
196
+ });
197
+ }
198
+ }
199
+ //# sourceMappingURL=bootstrapLegacy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":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C,KAAK,EAAE,CAAC;YACnB,UAAU,CAAC,OAAO,CACjB,IAAI,CAAC,aAAa,CAAC,+DAA+D,CAAC,CACnF,CAAC;YACF,MAAM,iBAAiB,GAAG,MAAM,cAAc,CAAC,UAAU,EAAE,OAAO,EAAE;gBACnE,QAAQ,EAAE,OAAO,CAAC,iBAAiB;gBACnC,QAAQ,EAAE,OAAO,CAAC,iBAAiB;gBACnC,UAAU,EAAE,YAAY,CAAC,GAAG;aAC5B,CAAC,CAAC;YAEH,UAAU,CAAC,KAAK,EAAE,CAAC;YACnB,UAAU,CAAC,OAAO,CACjB,IAAI,CAAC,aAAa,CAAC,2DAA2D,CAAC,CAC/E,CAAC;YACF,MAAM,UAAU,CAAC,UAAU,EAAE,OAAO,EAAE;gBACrC,YAAY,EAAE,iBAAiB,CAAC,GAAG;gBACnC,oBAAoB,EAAE,YAAY,CAAC,GAAG;gBACtC,QAAQ;gBACR,KAAK,EAAE,OAAO,CAAC,aAAa,IAAI,YAAY;gBAC5C,QAAQ,EAAE,OAAO,CAAC,iBAAiB;gBACnC,KAAK,EAAE,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;gBAC/C,SAAS,EAAE,MAAM;gBACjB,UAAU,EAAE,OAAO;gBACnB,aAAa,EAAE,MAAM;aACrB,CAAC,CAAC;QACJ,CAAC,CACD,CAAC;IACH,CAAC;AACF,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { CLIDisplay } from \"@twin.org/cli-core\";\nimport { ContextIdKeys, ContextIdStore } from \"@twin.org/context\";\nimport { Coerce, Converter, GeneralError, I18n, Is } from \"@twin.org/core\";\nimport type { IEngineCore } from \"@twin.org/engine-models\";\nimport { identityCreate } from \"./identityCreate.js\";\nimport { identityVerificationMethodCreate } from \"./identityVerificationMethodCreate.js\";\nimport { nodeSetIdentity } from \"./nodeSetIdentity.js\";\nimport { nodeSetTenant } from \"./nodeSetTenant.js\";\nimport { tenantCreate } from \"./tenantCreate.js\";\nimport { userCreate } from \"./userCreate.js\";\nimport { vaultKeyCreate } from \"./vaultKeyCreate.js\";\nimport { vaultKeyImport } from \"./vaultKeyImport.js\";\nimport { isTrustRequired, isUrlTransformerRequired } from \"../builders/engineEnvBuilder.js\";\nimport type { ICliCommandDefinition } from \"../models/ICliCommandDefinition.js\";\nimport type { INodeEngineConfig } from \"../models/INodeEngineConfig.js\";\nimport type { INodeEngineState } from \"../models/INodeEngineState.js\";\nimport type { INodeEnvironmentVariables } from \"../models/INodeEnvironmentVariables.js\";\n\nconst COMMAND_NAME = \"bootstrap-legacy\";\n\n/**\n * Get the command definition parameters.\n * @param commandDefinitions The registered command definitions.\n */\nexport function getCommandDefinitionBootstrapLegacy(commandDefinitions: {\n\t[id: string]: ICliCommandDefinition;\n}): void {\n\tcommandDefinitions[COMMAND_NAME] = {\n\t\tcommand: COMMAND_NAME,\n\t\tdescription: I18n.formatMessage(\"node.cli.commands.bootstrap-legacy.description\"),\n\t\texample: I18n.formatMessage(\"node.cli.commands.bootstrap-legacy.example\"),\n\t\trequiresNodeIdentity: false,\n\t\trequiresTenantId: false,\n\t\tparams: [\n\t\t\t{\n\t\t\t\tkey: \"env-prefix\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.bootstrap-legacy.params.env-prefix.description\"\n\t\t\t\t),\n\t\t\t\trequired: false\n\t\t\t},\n\t\t\t{\n\t\t\t\tkey: \"load-env\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.bootstrap-legacy.params.load-env.description\"\n\t\t\t\t),\n\t\t\t\trequired: false\n\t\t\t}\n\t\t],\n\t\taction: async (engineCore, envVars, params) => bootstrapLegacy(engineCore, envVars, params)\n\t};\n}\n\n/**\n * Command for legacy bootstrap.\n * @param engineCore The engine core.\n * @param envVars The environment variables for the node.\n * @param params The parameters for the command.\n */\nexport async function bootstrapLegacy(\n\tengineCore: IEngineCore<INodeEngineConfig, INodeEngineState>,\n\tenvVars: INodeEnvironmentVariables & {\n\t\t/**\n\t\t * The features that are enabled on the node.\n\t\t * @default []\n\t\t */\n\t\tfeatures?: string;\n\n\t\t/**\n\t\t * The identity of the node which, if empty and node-identity feature is enabled it will be generated.\n\t\t */\n\t\tnodeIdentity?: string;\n\n\t\t/**\n\t\t * The mnemonic for the identity, if empty and node-identity feature is enabled it will be randomly generated.\n\t\t */\n\t\tnodeMnemonic?: string;\n\n\t\t/**\n\t\t * A tenant id to use as a default for the node.\n\t\t */\n\t\ttenantId?: string;\n\n\t\t/**\n\t\t * A tenant api key to use as a default for the node.\n\t\t */\n\t\ttenantApiKey?: string;\n\n\t\t/**\n\t\t * If the node-admin-user feature is enabled, this will be the organization of the user, if one is not provided it will be generated\n\t\t */\n\t\torganizationIdentity?: string;\n\n\t\t/**\n\t\t * The mnemonic for the organization, if empty and node-admin-user feature is enabled it will be randomly generated.\n\t\t */\n\t\torganizationMnemonic?: string;\n\n\t\t/**\n\t\t * If the node-admin-user feature is enabled, this will be the identity of the user, if one is not provided it will be generated\n\t\t */\n\t\tadminUserIdentity?: string;\n\n\t\t/**\n\t\t * The mnemonic for the admin user, if empty and node-admin-user feature is enabled it will be randomly generated.\n\t\t */\n\t\tadminUserMnemonic?: string;\n\n\t\t/**\n\t\t * If the node-admin-user feature is enabled, this will be the name of the user.\n\t\t * @default admin@node\n\t\t */\n\t\tadminUserName?: string;\n\n\t\t/**\n\t\t * If the node-admin-user feature is enabled, this will be the password of the user, if empty it will be randomly generated.\n\t\t */\n\t\tadminUserPassword?: string;\n\t},\n\tparams: {}\n): Promise<void> {\n\tconst features = (envVars.features ?? \"\")\n\t\t.split(\",\")\n\t\t.map(f => f.trim())\n\t\t.filter(f => f.length > 0);\n\n\tconst state = engineCore.getState();\n\tconst requireWallet = features.includes(\"node-wallet\");\n\tlet tenantId = state.nodeTenantId;\n\tlet nodeId = state.nodeId;\n\n\tif (features.length === 0) {\n\t\tthrow new GeneralError(\"bootstrapLegacy\", \"noFeaturesEnabled\");\n\t}\n\n\tif (features.includes(\"node-identity\") && Is.empty(nodeId)) {\n\t\tCLIDisplay.break();\n\t\tCLIDisplay.section(\n\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.nodeIdentityCreate\")\n\t\t);\n\n\t\tconst nodeIdentity = await identityCreate(engineCore, envVars, {\n\t\t\tidentity: envVars.nodeIdentity,\n\t\t\tmnemonic: envVars.nodeMnemonic,\n\t\t\tfundWallet: requireWallet\n\t\t});\n\n\t\tnodeId = nodeIdentity.did;\n\n\t\tCLIDisplay.break();\n\t\tCLIDisplay.section(\n\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.nodeAuthKeyCreate\")\n\t\t);\n\t\tawait vaultKeyCreate(engineCore, envVars, {\n\t\t\tidentity: nodeIdentity.did,\n\t\t\tkeyType: \"Ed25519\",\n\t\t\tkeyId: envVars.authSigningKeyId,\n\t\t\toverwriteMode: \"skip\"\n\t\t});\n\n\t\tif (isTrustRequired(envVars)) {\n\t\t\tCLIDisplay.break();\n\t\t\tCLIDisplay.section(\n\t\t\t\tI18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.bootstrap-legacy.labels.trustVerificationMethodCreate\"\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tawait identityVerificationMethodCreate(engineCore, envVars, {\n\t\t\t\tidentity: nodeIdentity.did,\n\t\t\t\tverificationMethodType: \"assertionMethod\",\n\t\t\t\tverificationMethodId: envVars.trustVerificationMethodId,\n\t\t\t\toverwriteMode: \"skip\"\n\t\t\t});\n\t\t}\n\n\t\tif (\n\t\t\t(Coerce.boolean(envVars.synchronisedStorageEnabled) ?? false) &&\n\t\t\tIs.stringBase64(envVars.synchronisedStorageBlobStorageKey)\n\t\t) {\n\t\t\tCLIDisplay.break();\n\t\t\tCLIDisplay.section(\n\t\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.synchronisedStorageKeyAdd\")\n\t\t\t);\n\t\t\tawait vaultKeyImport(engineCore, envVars, {\n\t\t\t\tidentity: nodeIdentity.did,\n\t\t\t\tkeyType: \"ChaCha20Poly1305\",\n\t\t\t\tkeyId: envVars.synchronisedStorageBlobStorageEncryptionKeyId,\n\t\t\t\tprivateKeyHex: Converter.bytesToHex(\n\t\t\t\t\tConverter.base64ToBytes(envVars.synchronisedStorageBlobStorageKey)\n\t\t\t\t)\n\t\t\t});\n\t\t}\n\n\t\tif (isUrlTransformerRequired(envVars)) {\n\t\t\tCLIDisplay.break();\n\t\t\tCLIDisplay.section(\n\t\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.urlTransformParamKeyAdd\")\n\t\t\t);\n\t\t\tawait vaultKeyCreate(engineCore, envVars, {\n\t\t\t\tidentity: nodeIdentity.did,\n\t\t\t\tkeyType: \"ChaCha20Poly1305\",\n\t\t\t\tkeyId: envVars.urlTransformerEncryptionKeyId\n\t\t\t});\n\t\t}\n\n\t\tCLIDisplay.break();\n\t\tCLIDisplay.section(\n\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.nodeIdentitySet\")\n\t\t);\n\t\tawait nodeSetIdentity(engineCore, envVars, {\n\t\t\tidentity: nodeId\n\t\t});\n\n\t\tconst tenantEnabled = Coerce.boolean(envVars.tenantEnabled) ?? false;\n\t\tif (tenantEnabled) {\n\t\t\tif (Is.empty(tenantId)) {\n\t\t\t\tawait ContextIdStore.run({ [ContextIdKeys.Node]: nodeId }, async () => {\n\t\t\t\t\tCLIDisplay.break();\n\t\t\t\t\tCLIDisplay.section(\n\t\t\t\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.nodeTenantCreate\")\n\t\t\t\t\t);\n\t\t\t\t\tconst tenantDetails = await tenantCreate(engineCore, envVars, {\n\t\t\t\t\t\ttenantId: envVars.tenantId,\n\t\t\t\t\t\tapiKey: envVars.tenantApiKey,\n\t\t\t\t\t\tlabel: \"Node\"\n\t\t\t\t\t});\n\n\t\t\t\t\tCLIDisplay.break();\n\t\t\t\t\tCLIDisplay.section(\n\t\t\t\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.nodeTenantSet\")\n\t\t\t\t\t);\n\t\t\t\t\tawait nodeSetTenant(engineCore, envVars, {\n\t\t\t\t\t\ttenantId: tenantDetails.tenantId\n\t\t\t\t\t});\n\n\t\t\t\t\ttenantId = tenantDetails.tenantId;\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\tif (features.includes(\"node-admin-user\")) {\n\t\tawait ContextIdStore.run(\n\t\t\t{ [ContextIdKeys.Node]: nodeId, [ContextIdKeys.Tenant]: tenantId },\n\t\t\tasync () => {\n\t\t\t\tCLIDisplay.break();\n\t\t\t\tCLIDisplay.section(\n\t\t\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.organisationCreate\")\n\t\t\t\t);\n\t\t\t\tconst organisation = await identityCreate(engineCore, envVars, {\n\t\t\t\t\tidentity: envVars.organizationIdentity,\n\t\t\t\t\tmnemonic: envVars.organizationMnemonic,\n\t\t\t\t\tfundWallet: requireWallet\n\t\t\t\t});\n\n\t\t\t\tif (Coerce.boolean(envVars.blobStorageEnableEncryption) ?? false) {\n\t\t\t\t\tCLIDisplay.break();\n\t\t\t\t\tCLIDisplay.section(\n\t\t\t\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.blobStorageKeyCreate\")\n\t\t\t\t\t);\n\t\t\t\t\tawait vaultKeyCreate(engineCore, envVars, {\n\t\t\t\t\t\tidentity: organisation.did,\n\t\t\t\t\t\tkeyType: \"ChaCha20Poly1305\",\n\t\t\t\t\t\tkeyId: envVars.blobStorageEncryptionKeyId,\n\t\t\t\t\t\toverwriteMode: \"skip\"\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tconst defaultAttestationConnectorType =\n\t\t\t\t\tengineCore.getRegisteredInstanceTypeOptional(\"attestationConnector\");\n\t\t\t\tif (!Is.empty(defaultAttestationConnectorType)) {\n\t\t\t\t\tCLIDisplay.break();\n\t\t\t\t\tCLIDisplay.section(\n\t\t\t\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.attestationMethodCreate\")\n\t\t\t\t\t);\n\t\t\t\t\tawait identityVerificationMethodCreate(engineCore, envVars, {\n\t\t\t\t\t\tidentity: organisation.did,\n\t\t\t\t\t\tverificationMethodType: \"assertionMethod\",\n\t\t\t\t\t\tverificationMethodId: envVars.attestationVerificationMethodId,\n\t\t\t\t\t\toverwriteMode: \"skip\"\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tconst defaultImmutableProofComponentType =\n\t\t\t\t\tengineCore.getRegisteredInstanceTypeOptional(\"immutableProofComponent\");\n\n\t\t\t\tif (!Is.empty(defaultImmutableProofComponentType)) {\n\t\t\t\t\tCLIDisplay.break();\n\t\t\t\t\tCLIDisplay.section(\n\t\t\t\t\t\tI18n.formatMessage(\n\t\t\t\t\t\t\t\"node.cli.commands.bootstrap-legacy.labels.immutableProofMethodCreate\"\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t\tawait identityVerificationMethodCreate(engineCore, envVars, {\n\t\t\t\t\t\tidentity: organisation.did,\n\t\t\t\t\t\tverificationMethodType: \"assertionMethod\",\n\t\t\t\t\t\tverificationMethodId: envVars.immutableProofVerificationMethodId,\n\t\t\t\t\t\toverwriteMode: \"skip\"\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tCLIDisplay.break();\n\t\t\t\tCLIDisplay.section(\n\t\t\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.adminIdentityCreate\")\n\t\t\t\t);\n\t\t\t\tconst adminUserIdentity = await identityCreate(engineCore, envVars, {\n\t\t\t\t\tidentity: envVars.adminUserIdentity,\n\t\t\t\t\tmnemonic: envVars.adminUserMnemonic,\n\t\t\t\t\tcontroller: organisation.did\n\t\t\t\t});\n\n\t\t\t\tCLIDisplay.break();\n\t\t\t\tCLIDisplay.section(\n\t\t\t\t\tI18n.formatMessage(\"node.cli.commands.bootstrap-legacy.labels.adminUserCreate\")\n\t\t\t\t);\n\t\t\t\tawait userCreate(engineCore, envVars, {\n\t\t\t\t\tuserIdentity: adminUserIdentity.did,\n\t\t\t\t\torganizationIdentity: organisation.did,\n\t\t\t\t\ttenantId,\n\t\t\t\t\temail: envVars.adminUserName ?? \"admin@node\",\n\t\t\t\t\tpassword: envVars.adminUserPassword,\n\t\t\t\t\tscope: [\"tenant-admin\", \"user-admin\"].join(\",\"),\n\t\t\t\t\tgivenName: \"Node\",\n\t\t\t\t\tfamilyName: \"Admin\",\n\t\t\t\t\toverwriteMode: \"skip\"\n\t\t\t\t});\n\t\t\t}\n\t\t);\n\t}\n}\n"]}
@@ -0,0 +1,85 @@
1
+ // Copyright 2026 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ import { CLIDisplay } from "@twin.org/cli-core";
4
+ import { I18n, Is } from "@twin.org/core";
5
+ const COMMAND_NAME = "help";
6
+ /**
7
+ * Get the command definition parameters.
8
+ * @param commandDefinitions The registered command definitions.
9
+ */
10
+ export function getCommandDefinitionHelp(commandDefinitions) {
11
+ commandDefinitions[COMMAND_NAME] = {
12
+ command: COMMAND_NAME,
13
+ description: I18n.formatMessage("node.cli.commands.help.description"),
14
+ example: "",
15
+ params: [],
16
+ action: async (engineCore, envVars, params) => help(engineCore, envVars, params, commandDefinitions),
17
+ requiresEngineStarted: false
18
+ };
19
+ }
20
+ /**
21
+ * Command for displaying help information.
22
+ * @param engineCore The engine core.
23
+ * @param envVars The environment variables for the node.
24
+ * @param params The command parameters.
25
+ * @param params.command The command to display help for.
26
+ * @param commandDefinitions The registered command definitions.
27
+ */
28
+ export async function help(engineCore, envVars, params, commandDefinitions) {
29
+ if (Is.stringValue(params.command)) {
30
+ const commandDefinition = commandDefinitions[params.command];
31
+ if (commandDefinition) {
32
+ displayCommandHelp(commandDefinition);
33
+ }
34
+ }
35
+ else {
36
+ CLIDisplay.value("", I18n.formatMessage("node.cli.commands.help.labels.commands"));
37
+ CLIDisplay.break();
38
+ for (const commandId in commandDefinitions) {
39
+ const commandDef = commandDefinitions[commandId];
40
+ if (commandId !== "help") {
41
+ CLIDisplay.value(commandDef.command, I18n.formatMessage(`node.cli.commands.${commandDef.command}.description`));
42
+ }
43
+ }
44
+ }
45
+ }
46
+ /**
47
+ * Display help for a specific command.
48
+ * @param commandDefinition The command definition.
49
+ */
50
+ function displayCommandHelp(commandDefinition) {
51
+ CLIDisplay.value(commandDefinition.command, commandDefinition.description);
52
+ CLIDisplay.break();
53
+ const defaultLabel = I18n.formatMessage("node.cli.commands.help.labels.default");
54
+ const optionsLabel = I18n.formatMessage("node.cli.commands.help.labels.options");
55
+ const requiredLabel = I18n.formatMessage("node.cli.commands.help.labels.required");
56
+ const optionalLabel = I18n.formatMessage("node.cli.commands.help.labels.optional");
57
+ if (commandDefinition.params.length > 0) {
58
+ for (const param of commandDefinition.params) {
59
+ const typeParts = [param.type];
60
+ if (Is.stringValue(param.extendedType)) {
61
+ typeParts.push(param.extendedType);
62
+ }
63
+ if (!Is.empty(param.defaultValue)) {
64
+ typeParts.push(`${defaultLabel}: '${param.defaultValue}'`);
65
+ }
66
+ if (param.required) {
67
+ typeParts.push(requiredLabel);
68
+ }
69
+ else {
70
+ typeParts.push(optionalLabel);
71
+ }
72
+ if (Is.arrayValue(param.options)) {
73
+ typeParts.push(`${optionsLabel}: [${param.options.join(", ")}]`);
74
+ }
75
+ CLIDisplay.value(param.key, `(${typeParts.join(", ")})`, 1);
76
+ CLIDisplay.value("", param.description, 1);
77
+ CLIDisplay.break();
78
+ }
79
+ }
80
+ if (Is.stringValue(commandDefinition.example)) {
81
+ CLIDisplay.break();
82
+ CLIDisplay.value(I18n.formatMessage("node.cli.commands.help.labels.example"), commandDefinition.example);
83
+ }
84
+ }
85
+ //# sourceMappingURL=help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AAI,KAAK,CAAC,QAAQ,EAAE,CAAC;gBACpB,SAAS,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YAC/B,CAAC;iBAAM,CAAC;gBACP,SAAS,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YAC/B,CAAC;YAED,IAAI,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;gBAClC,SAAS,CAAC,IAAI,CAAC,GAAG,YAAY,MAAM,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAClE,CAAC;YAED,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;YAE5D,UAAU,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;YAE3C,UAAU,CAAC,KAAK,EAAE,CAAC;QACpB,CAAC;IACF,CAAC;IAED,IAAI,EAAE,CAAC,WAAW,CAAC,iBAAiB,CAAC,OAAO,CAAC,EAAE,CAAC;QAC/C,UAAU,CAAC,KAAK,EAAE,CAAC;QACnB,UAAU,CAAC,KAAK,CACf,IAAI,CAAC,aAAa,CAAC,uCAAuC,CAAC,EAC3D,iBAAiB,CAAC,OAAO,CACzB,CAAC;IACH,CAAC;AACF,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { CLIDisplay } from \"@twin.org/cli-core\";\nimport { I18n, Is } from \"@twin.org/core\";\nimport type { IEngineCore } from \"@twin.org/engine-models\";\nimport type { ICliCommandDefinition } from \"../models/ICliCommandDefinition.js\";\nimport type { INodeEnvironmentVariables } from \"../models/INodeEnvironmentVariables.js\";\n\nconst COMMAND_NAME = \"help\";\n\n/**\n * Get the command definition parameters.\n * @param commandDefinitions The registered command definitions.\n */\nexport function getCommandDefinitionHelp(commandDefinitions: {\n\t[id: string]: ICliCommandDefinition;\n}): void {\n\tcommandDefinitions[COMMAND_NAME] = {\n\t\tcommand: COMMAND_NAME,\n\t\tdescription: I18n.formatMessage(\"node.cli.commands.help.description\"),\n\t\texample: \"\",\n\t\tparams: [],\n\t\taction: async (engineCore, envVars, params) =>\n\t\t\thelp(engineCore, envVars, params, commandDefinitions),\n\t\trequiresEngineStarted: false\n\t};\n}\n\n/**\n * Command for displaying help information.\n * @param engineCore The engine core.\n * @param envVars The environment variables for the node.\n * @param params The command parameters.\n * @param params.command The command to display help for.\n * @param commandDefinitions The registered command definitions.\n */\nexport async function help(\n\tengineCore: IEngineCore,\n\tenvVars: INodeEnvironmentVariables,\n\tparams: { command?: string },\n\tcommandDefinitions: { [id: string]: ICliCommandDefinition }\n): Promise<void> {\n\tif (Is.stringValue(params.command)) {\n\t\tconst commandDefinition = commandDefinitions[params.command];\n\t\tif (commandDefinition) {\n\t\t\tdisplayCommandHelp(commandDefinition);\n\t\t}\n\t} else {\n\t\tCLIDisplay.value(\"\", I18n.formatMessage(\"node.cli.commands.help.labels.commands\"));\n\t\tCLIDisplay.break();\n\n\t\tfor (const commandId in commandDefinitions) {\n\t\t\tconst commandDef = commandDefinitions[commandId];\n\t\t\tif (commandId !== \"help\") {\n\t\t\t\tCLIDisplay.value(\n\t\t\t\t\tcommandDef.command,\n\t\t\t\t\tI18n.formatMessage(`node.cli.commands.${commandDef.command}.description`)\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Display help for a specific command.\n * @param commandDefinition The command definition.\n */\nfunction displayCommandHelp(commandDefinition: ICliCommandDefinition): void {\n\tCLIDisplay.value(commandDefinition.command, commandDefinition.description);\n\tCLIDisplay.break();\n\n\tconst defaultLabel = I18n.formatMessage(\"node.cli.commands.help.labels.default\");\n\tconst optionsLabel = I18n.formatMessage(\"node.cli.commands.help.labels.options\");\n\tconst requiredLabel = I18n.formatMessage(\"node.cli.commands.help.labels.required\");\n\tconst optionalLabel = I18n.formatMessage(\"node.cli.commands.help.labels.optional\");\n\n\tif (commandDefinition.params.length > 0) {\n\t\tfor (const param of commandDefinition.params) {\n\t\t\tconst typeParts: string[] = [param.type];\n\t\t\tif (Is.stringValue(param.extendedType)) {\n\t\t\t\ttypeParts.push(param.extendedType);\n\t\t\t}\n\t\t\tif (!Is.empty(param.defaultValue)) {\n\t\t\t\ttypeParts.push(`${defaultLabel}: '${param.defaultValue}'`);\n\t\t\t}\n\t\t\tif (param.required) {\n\t\t\t\ttypeParts.push(requiredLabel);\n\t\t\t} else {\n\t\t\t\ttypeParts.push(optionalLabel);\n\t\t\t}\n\n\t\t\tif (Is.arrayValue(param.options)) {\n\t\t\t\ttypeParts.push(`${optionsLabel}: [${param.options.join(\", \")}]`);\n\t\t\t}\n\n\t\t\tCLIDisplay.value(param.key, `(${typeParts.join(\", \")})`, 1);\n\n\t\t\tCLIDisplay.value(\"\", param.description, 1);\n\n\t\t\tCLIDisplay.break();\n\t\t}\n\t}\n\n\tif (Is.stringValue(commandDefinition.example)) {\n\t\tCLIDisplay.break();\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\"node.cli.commands.help.labels.example\"),\n\t\t\tcommandDefinition.example\n\t\t);\n\t}\n}\n"]}