@twin.org/node-core 0.9.1-next.3 → 0.9.1-next.5

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 (56) hide show
  1. package/dist/es/cli.js +41 -12
  2. package/dist/es/cli.js.map +1 -1
  3. package/dist/es/commands/help.js +4 -0
  4. package/dist/es/commands/help.js.map +1 -1
  5. package/dist/es/commands/identityCreate.js +3 -3
  6. package/dist/es/commands/identityCreate.js.map +1 -1
  7. package/dist/es/commands/identityList.js +65 -0
  8. package/dist/es/commands/identityList.js.map +1 -0
  9. package/dist/es/commands/identityResolve.js +83 -0
  10. package/dist/es/commands/identityResolve.js.map +1 -0
  11. package/dist/es/commands/nodeIdentityGet.js +68 -0
  12. package/dist/es/commands/nodeIdentityGet.js.map +1 -0
  13. package/dist/es/commands/{nodeSetIdentity.js → nodeIdentitySet.js} +16 -15
  14. package/dist/es/commands/nodeIdentitySet.js.map +1 -0
  15. package/dist/es/commands/nodeOrgIdGet.js +54 -0
  16. package/dist/es/commands/nodeOrgIdGet.js.map +1 -0
  17. package/dist/es/commands/{setNodeOrgId.js → nodeOrgIdSet.js} +14 -13
  18. package/dist/es/commands/nodeOrgIdSet.js.map +1 -0
  19. package/dist/es/commands/orgUsersList.js +94 -0
  20. package/dist/es/commands/orgUsersList.js.map +1 -0
  21. package/dist/es/commands/tenantGet.js +68 -0
  22. package/dist/es/commands/tenantGet.js.map +1 -0
  23. package/dist/es/commands/tenantList.js +69 -0
  24. package/dist/es/commands/tenantList.js.map +1 -0
  25. package/dist/es/commands/tenantListByOrg.js +80 -0
  26. package/dist/es/commands/tenantListByOrg.js.map +1 -0
  27. package/dist/es/commands/{setTenantOrgId.js → tenantOrgIdSet.js} +16 -15
  28. package/dist/es/commands/tenantOrgIdSet.js.map +1 -0
  29. package/dist/es/commands/userGet.js +77 -0
  30. package/dist/es/commands/userGet.js.map +1 -0
  31. package/dist/es/models/ICliCommandDefinition.js.map +1 -1
  32. package/dist/es/models/IEngineEnvironmentVariables.js.map +1 -1
  33. package/dist/es/node.js +1 -1
  34. package/dist/es/node.js.map +1 -1
  35. package/dist/types/commands/identityList.d.ts +17 -0
  36. package/dist/types/commands/identityResolve.d.ts +22 -0
  37. package/dist/types/commands/nodeIdentityGet.d.ts +20 -0
  38. package/dist/types/commands/{nodeSetIdentity.d.ts → nodeIdentitySet.d.ts} +2 -2
  39. package/dist/types/commands/nodeOrgIdGet.d.ts +19 -0
  40. package/dist/types/commands/{setNodeOrgId.d.ts → nodeOrgIdSet.d.ts} +2 -2
  41. package/dist/types/commands/orgUsersList.d.ts +27 -0
  42. package/dist/types/commands/tenantGet.d.ts +22 -0
  43. package/dist/types/commands/tenantList.d.ts +22 -0
  44. package/dist/types/commands/tenantListByOrg.d.ts +22 -0
  45. package/dist/types/commands/{setTenantOrgId.d.ts → tenantOrgIdSet.d.ts} +2 -2
  46. package/dist/types/commands/userGet.d.ts +24 -0
  47. package/dist/types/models/ICliCommandDefinition.d.ts +4 -0
  48. package/dist/types/models/IEngineEnvironmentVariables.d.ts +12 -4
  49. package/docs/changelog.md +14 -0
  50. package/docs/reference/interfaces/ICliCommandDefinition.md +8 -0
  51. package/docs/reference/interfaces/IEngineEnvironmentVariables.md +12 -4
  52. package/locales/en.json +225 -13
  53. package/package.json +1 -1
  54. package/dist/es/commands/nodeSetIdentity.js.map +0 -1
  55. package/dist/es/commands/setNodeOrgId.js.map +0 -1
  56. package/dist/es/commands/setTenantOrgId.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identityResolve.js","sourceRoot":"","sources":["../../../src/commands/identityResolve.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAEhE,OAAO,EAAE,gCAAgC,EAAE,MAAM,2BA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,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;YAC7F,CAAC;QACF,CAAC;IACF,CAAC;IAED,UAAU,CAAC,KAAK,EAAE,CAAC;IAEnB,UAAU,CAAC,IAAI,EAAE,CAAC;IAElB,OAAO,gBAAgB,CAAC;AACzB,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { CLIDisplay } from \"@twin.org/cli-core\";\nimport { GeneralError, Guards, I18n, Is } from \"@twin.org/core\";\nimport type { IEngineCore } from \"@twin.org/engine-models\";\nimport { IdentityResolverConnectorFactory } from \"@twin.org/identity-models\";\nimport type { IDidDocument } from \"@twin.org/standards-w3c-did\";\nimport type { ICliCommandDefinition } from \"../models/ICliCommandDefinition.js\";\nimport type { IEnvironmentVariables } from \"../models/IEnvironmentVariables.js\";\n\nconst COMMAND_NAME = \"identity-resolve\";\n\n/**\n * Get the command definition parameters.\n * @param commandDefinitions The registered command definitions.\n */\nexport function getCommandDefinitionIdentityResolve(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.identity-resolve.description\"),\n\t\texample: I18n.formatMessage(\"node.cli.commands.identity-resolve.example\"),\n\t\trequiresNodeIdentity: false,\n\t\trequiresOrgIdentity: 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.identity-resolve.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: \"identity\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"did\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.identity-resolve.params.identity.description\"\n\t\t\t\t),\n\t\t\t\trequired: true\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.identity-resolve.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) => identityResolve(engineCore, envVars, params)\n\t};\n}\n\n/**\n * Command for resolving an identity DID to its full document.\n * @param engineCore The engine core.\n * @param envVars The environment variables for the node.\n * @param params The parameters for the command.\n * @param params.identity The DID to resolve.\n * @returns The resolved DID document.\n */\nexport async function identityResolve(\n\tengineCore: IEngineCore,\n\tenvVars: IEnvironmentVariables,\n\tparams: {\n\t\tidentity?: string;\n\t}\n): Promise<IDidDocument> {\n\tGuards.stringValue(\"identityResolve\", \"identity\", params.identity);\n\n\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.identity-resolve.labels.resolving\"));\n\n\tconst defaultIdentityResolverConnectorType = engineCore.getRegisteredInstanceType(\n\t\t\"identityResolverConnector\"\n\t);\n\n\tconst identityResolverConnector = IdentityResolverConnectorFactory.get(\n\t\tdefaultIdentityResolverConnectorType\n\t);\n\n\tlet identityDocument: IDidDocument | undefined;\n\ttry {\n\t\tidentityDocument = await identityResolverConnector.resolveDocument(params.identity);\n\t} catch {}\n\n\tif (!Is.objectValue(identityDocument)) {\n\t\tthrow new GeneralError(\"identityResolve\", \"identityNotFound\", {\n\t\t\tidentity: params.identity\n\t\t});\n\t}\n\n\tCLIDisplay.break();\n\tCLIDisplay.value(\n\t\tI18n.formatMessage(\"node.cli.commands.identity-resolve.labels.did\"),\n\t\tidentityDocument.id\n\t);\n\n\tif (Is.arrayValue(identityDocument.verificationMethod)) {\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\"node.cli.commands.identity-resolve.labels.verificationMethods\"),\n\t\t\tidentityDocument.verificationMethod.length.toString(),\n\t\t\t1\n\t\t);\n\t\tfor (const method of identityDocument.verificationMethod) {\n\t\t\tif (Is.stringValue(method)) {\n\t\t\t\tCLIDisplay.value(method, \"\", 2);\n\t\t\t} else {\n\t\t\t\tconst m = method;\n\t\t\t\tCLIDisplay.value(Is.stringValue(m.id) ? m.id : \"\", Is.stringValue(m.type) ? m.type : \"\", 2);\n\t\t\t}\n\t\t}\n\t}\n\n\tCLIDisplay.break();\n\n\tCLIDisplay.done();\n\n\treturn identityDocument;\n}\n"]}
@@ -0,0 +1,68 @@
1
+ // Copyright 2026 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ import { CLIDisplay } from "@twin.org/cli-core";
4
+ import { GeneralError, I18n, Is } from "@twin.org/core";
5
+ import { IdentityResolverConnectorFactory } from "@twin.org/identity-models";
6
+ const COMMAND_NAME = "node-identity-get";
7
+ /**
8
+ * Get the command definition parameters.
9
+ * @param commandDefinitions The registered command definitions.
10
+ */
11
+ export function getCommandDefinitionNodeIdentityGet(commandDefinitions) {
12
+ commandDefinitions[COMMAND_NAME] = {
13
+ command: COMMAND_NAME,
14
+ description: I18n.formatMessage("node.cli.commands.node-identity-get.description"),
15
+ example: I18n.formatMessage("node.cli.commands.node-identity-get.example"),
16
+ requiresNodeIdentity: false,
17
+ requiresOrgIdentity: false,
18
+ params: [
19
+ {
20
+ key: "env-prefix",
21
+ type: "string",
22
+ description: I18n.formatMessage("node.cli.commands.node-identity-get.params.env-prefix.description"),
23
+ required: false
24
+ },
25
+ {
26
+ key: "load-env",
27
+ type: "string",
28
+ description: I18n.formatMessage("node.cli.commands.node-identity-get.params.load-env.description"),
29
+ required: false
30
+ }
31
+ ],
32
+ action: async (engineCore, envVars) => nodeIdentityGet(engineCore, envVars)
33
+ };
34
+ }
35
+ /**
36
+ * Command for retrieving the identity currently assigned to the node.
37
+ * @param engineCore The engine core.
38
+ * @param envVars The environment variables for the node.
39
+ * @returns The node identity document.
40
+ */
41
+ export async function nodeIdentityGet(engineCore, envVars) {
42
+ const state = engineCore.getState();
43
+ if (!Is.stringValue(state.nodeId)) {
44
+ throw new GeneralError("nodeIdentityGet", "nodeIdentityNotSet");
45
+ }
46
+ CLIDisplay.task(I18n.formatMessage("node.cli.commands.node-identity-get.labels.resolving"));
47
+ const defaultIdentityResolverConnectorType = engineCore.getRegisteredInstanceType("identityResolverConnector");
48
+ const identityResolverConnector = IdentityResolverConnectorFactory.get(defaultIdentityResolverConnectorType);
49
+ const identityDocument = await identityResolverConnector.resolveDocument(state.nodeId);
50
+ CLIDisplay.break();
51
+ CLIDisplay.value(I18n.formatMessage("node.cli.commands.node-identity-get.labels.did"), identityDocument.id);
52
+ if (Is.arrayValue(identityDocument.verificationMethod)) {
53
+ CLIDisplay.value(I18n.formatMessage("node.cli.commands.node-identity-get.labels.verificationMethods"), identityDocument.verificationMethod.length.toString(), 1);
54
+ for (const method of identityDocument.verificationMethod) {
55
+ if (Is.stringValue(method)) {
56
+ CLIDisplay.value(method, "", 2);
57
+ }
58
+ else {
59
+ const m = method;
60
+ CLIDisplay.value(Is.stringValue(m.id) ? m.id : "", Is.stringValue(m.type) ? m.type : "", 2);
61
+ }
62
+ }
63
+ }
64
+ CLIDisplay.break();
65
+ CLIDisplay.done();
66
+ return identityDocument;
67
+ }
68
+ //# sourceMappingURL=nodeIdentityGet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nodeIdentityGet.js","sourceRoot":"","sources":["../../../src/commands/nodeIdentityGet.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAExD,OAAO,EAAE,gCAAgC,EAAE,MAAM,2B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ftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { CLIDisplay } from \"@twin.org/cli-core\";\nimport { GeneralError, I18n, Is } from \"@twin.org/core\";\nimport type { IEngineCore } from \"@twin.org/engine-models\";\nimport { IdentityResolverConnectorFactory } from \"@twin.org/identity-models\";\nimport type { IDidDocument } from \"@twin.org/standards-w3c-did\";\nimport type { ICliCommandDefinition } from \"../models/ICliCommandDefinition.js\";\nimport type { IEnvironmentVariables } from \"../models/IEnvironmentVariables.js\";\nimport type { INodeEngineConfig } from \"../models/INodeEngineConfig.js\";\nimport type { INodeEngineState } from \"../models/INodeEngineState.js\";\n\nconst COMMAND_NAME = \"node-identity-get\";\n\n/**\n * Get the command definition parameters.\n * @param commandDefinitions The registered command definitions.\n */\nexport function getCommandDefinitionNodeIdentityGet(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.node-identity-get.description\"),\n\t\texample: I18n.formatMessage(\"node.cli.commands.node-identity-get.example\"),\n\t\trequiresNodeIdentity: false,\n\t\trequiresOrgIdentity: 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.node-identity-get.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.node-identity-get.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) => nodeIdentityGet(engineCore, envVars)\n\t};\n}\n\n/**\n * Command for retrieving the identity currently assigned to the node.\n * @param engineCore The engine core.\n * @param envVars The environment variables for the node.\n * @returns The node identity document.\n */\nexport async function nodeIdentityGet(\n\tengineCore: IEngineCore<INodeEngineConfig, INodeEngineState>,\n\tenvVars: IEnvironmentVariables\n): Promise<IDidDocument> {\n\tconst state = engineCore.getState();\n\n\tif (!Is.stringValue(state.nodeId)) {\n\t\tthrow new GeneralError(\"nodeIdentityGet\", \"nodeIdentityNotSet\");\n\t}\n\n\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.node-identity-get.labels.resolving\"));\n\n\tconst defaultIdentityResolverConnectorType = engineCore.getRegisteredInstanceType(\n\t\t\"identityResolverConnector\"\n\t);\n\n\tconst identityResolverConnector = IdentityResolverConnectorFactory.get(\n\t\tdefaultIdentityResolverConnectorType\n\t);\n\n\tconst identityDocument = await identityResolverConnector.resolveDocument(state.nodeId);\n\n\tCLIDisplay.break();\n\tCLIDisplay.value(\n\t\tI18n.formatMessage(\"node.cli.commands.node-identity-get.labels.did\"),\n\t\tidentityDocument.id\n\t);\n\n\tif (Is.arrayValue(identityDocument.verificationMethod)) {\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\"node.cli.commands.node-identity-get.labels.verificationMethods\"),\n\t\t\tidentityDocument.verificationMethod.length.toString(),\n\t\t\t1\n\t\t);\n\t\tfor (const method of identityDocument.verificationMethod) {\n\t\t\tif (Is.stringValue(method)) {\n\t\t\t\tCLIDisplay.value(method, \"\", 2);\n\t\t\t} else {\n\t\t\t\tconst m = method;\n\t\t\t\tCLIDisplay.value(Is.stringValue(m.id) ? m.id : \"\", Is.stringValue(m.type) ? m.type : \"\", 2);\n\t\t\t}\n\t\t}\n\t}\n\n\tCLIDisplay.break();\n\n\tCLIDisplay.done();\n\n\treturn identityDocument;\n}\n"]}
@@ -3,40 +3,41 @@
3
3
  import { CLIDisplay } from "@twin.org/cli-core";
4
4
  import { I18n, Is, NotFoundError } from "@twin.org/core";
5
5
  import { Did, IdentityResolverConnectorFactory } from "@twin.org/identity-models";
6
- const COMMAND_NAME = "node-set-identity";
6
+ const COMMAND_NAME = "node-identity-set";
7
7
  /**
8
8
  * Get the command definition parameters.
9
9
  * @param commandDefinitions The registered command definitions.
10
10
  */
11
- export function getCommandDefinitionNodeSetIdentity(commandDefinitions) {
11
+ export function getCommandDefinitionNodeIdentitySet(commandDefinitions) {
12
12
  commandDefinitions[COMMAND_NAME] = {
13
13
  command: COMMAND_NAME,
14
- description: I18n.formatMessage("node.cli.commands.node-set-identity.description"),
15
- example: I18n.formatMessage("node.cli.commands.node-set-identity.example"),
14
+ aliases: ["node-set-identity"],
15
+ description: I18n.formatMessage("node.cli.commands.node-identity-set.description"),
16
+ example: I18n.formatMessage("node.cli.commands.node-identity-set.example"),
16
17
  requiresNodeIdentity: false,
17
18
  requiresOrgIdentity: false,
18
19
  params: [
19
20
  {
20
21
  key: "env-prefix",
21
22
  type: "string",
22
- description: I18n.formatMessage("node.cli.commands.node-set-identity.params.env-prefix.description"),
23
+ description: I18n.formatMessage("node.cli.commands.node-identity-set.params.env-prefix.description"),
23
24
  required: false
24
25
  },
25
26
  {
26
27
  key: "identity",
27
28
  type: "string",
28
- description: I18n.formatMessage("node.cli.commands.node-set-identity.params.identity.description"),
29
+ description: I18n.formatMessage("node.cli.commands.node-identity-set.params.identity.description"),
29
30
  extendedType: "did",
30
31
  required: true
31
32
  },
32
33
  {
33
34
  key: "load-env",
34
35
  type: "string",
35
- description: I18n.formatMessage("node.cli.commands.node-set-identity.params.load-env.description"),
36
+ description: I18n.formatMessage("node.cli.commands.node-identity-set.params.load-env.description"),
36
37
  required: false
37
38
  }
38
39
  ],
39
- action: async (engineCore, envVars, params) => nodeSetIdentity(engineCore, envVars, params)
40
+ action: async (engineCore, envVars, params) => nodeIdentitySet(engineCore, envVars, params)
40
41
  };
41
42
  }
42
43
  /**
@@ -47,23 +48,23 @@ export function getCommandDefinitionNodeSetIdentity(commandDefinitions) {
47
48
  * @param params.identity The DID to set for the node.
48
49
  * @returns A promise that resolves when the node identity has been persisted.
49
50
  */
50
- export async function nodeSetIdentity(engineCore, envVars, params) {
51
- Did.guard("nodeSetIdentity", "identity", params.identity);
52
- CLIDisplay.task(I18n.formatMessage("node.cli.commands.node-set-identity.labels.resolvingIdentity"));
51
+ export async function nodeIdentitySet(engineCore, envVars, params) {
52
+ Did.guard("nodeIdentitySet", "identity", params.identity);
53
+ CLIDisplay.task(I18n.formatMessage("node.cli.commands.node-identity-set.labels.resolvingIdentity"));
53
54
  const defaultIdentityResolverConnectorType = engineCore.getRegisteredInstanceType("identityResolverConnector");
54
55
  const identityResolverConnector = IdentityResolverConnectorFactory.get(defaultIdentityResolverConnectorType);
55
56
  const identityDocument = await identityResolverConnector.resolveDocument(params.identity);
56
57
  if (Is.empty(identityDocument)) {
57
- throw new NotFoundError("nodeSetIdentity", "identityNotFound", params.identity);
58
+ throw new NotFoundError("nodeIdentitySet", "identityNotFound", params.identity);
58
59
  }
59
60
  const state = engineCore.getState();
60
61
  if (state.nodeId === params.identity) {
61
- CLIDisplay.task(I18n.formatMessage("node.cli.commands.node-set-identity.labels.skipping"));
62
+ CLIDisplay.task(I18n.formatMessage("node.cli.commands.node-identity-set.labels.skipping"));
62
63
  return;
63
64
  }
64
65
  state.nodeId = params.identity;
65
66
  engineCore.setStateDirty();
66
- CLIDisplay.task(I18n.formatMessage("node.cli.commands.node-set-identity.labels.stored"));
67
+ CLIDisplay.task(I18n.formatMessage("node.cli.commands.node-identity-set.labels.stored"));
67
68
  CLIDisplay.done();
68
69
  }
69
- //# sourceMappingURL=nodeSetIdentity.js.map
70
+ //# sourceMappingURL=nodeIdentitySet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nodeIdentitySet.js","sourceRoot":"","sources":["../../../src/commands/nodeIdentitySet.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEzD,O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1D,UAAU,CAAC,IAAI,CACd,IAAI,CAAC,aAAa,CAAC,8DAA8D,CAAC,CAClF,CAAC;IACF,MAAM,oCAAoC,GAAG,UAAU,CAAC,yBAAyB,CAChF,2BAA2B,CAC3B,CAAC;IAEF,MAAM,yBAAyB,GAAG,gCAAgC,CAAC,GAAG,CACrE,oCAAoC,CACpC,CAAC;IAEF,MAAM,gBAAgB,GAAG,MAAM,yBAAyB,CAAC,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC1F,IAAI,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC,EAAE,CAAC;QAChC,MAAM,IAAI,aAAa,CAAC,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;IACjF,CAAC;IAED,MAAM,KAAK,GAAG,UAAU,CAAC,QAAQ,EAAE,CAAC;IAEpC,IAAI,KAAK,CAAC,MAAM,KAAK,MAAM,CAAC,QAAQ,EAAE,CAAC;QACtC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,qDAAqD,CAAC,CAAC,CAAC;QAC3F,OAAO;IACR,CAAC;IAED,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC;IAC/B,UAAU,CAAC,aAAa,EAAE,CAAC;IAE3B,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,mDAAmD,CAAC,CAAC,CAAC;IAEzF,UAAU,CAAC,IAAI,EAAE,CAAC;AACnB,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { CLIDisplay } from \"@twin.org/cli-core\";\nimport { I18n, Is, NotFoundError } from \"@twin.org/core\";\nimport type { IEngineCore } from \"@twin.org/engine-models\";\nimport { Did, IdentityResolverConnectorFactory } from \"@twin.org/identity-models\";\nimport type { ICliCommandDefinition } from \"../models/ICliCommandDefinition.js\";\nimport type { IEnvironmentVariables } from \"../models/IEnvironmentVariables.js\";\nimport type { INodeEngineConfig } from \"../models/INodeEngineConfig.js\";\nimport type { INodeEngineState } from \"../models/INodeEngineState.js\";\n\nconst COMMAND_NAME = \"node-identity-set\";\n\n/**\n * Get the command definition parameters.\n * @param commandDefinitions The registered command definitions.\n */\nexport function getCommandDefinitionNodeIdentitySet(commandDefinitions: {\n\t[id: string]: ICliCommandDefinition;\n}): void {\n\tcommandDefinitions[COMMAND_NAME] = {\n\t\tcommand: COMMAND_NAME,\n\t\taliases: [\"node-set-identity\"],\n\t\tdescription: I18n.formatMessage(\"node.cli.commands.node-identity-set.description\"),\n\t\texample: I18n.formatMessage(\"node.cli.commands.node-identity-set.example\"),\n\t\trequiresNodeIdentity: false,\n\t\trequiresOrgIdentity: 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.node-identity-set.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: \"identity\",\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.node-identity-set.params.identity.description\"\n\t\t\t\t),\n\t\t\t\textendedType: \"did\",\n\t\t\t\trequired: true\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.node-identity-set.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) => nodeIdentitySet(engineCore, envVars, params)\n\t};\n}\n\n/**\n * Command for setting a node identity.\n * @param engineCore The engine core.\n * @param envVars The environment variables for the node.\n * @param params The parameters for the command.\n * @param params.identity The DID to set for the node.\n * @returns A promise that resolves when the node identity has been persisted.\n */\nexport async function nodeIdentitySet(\n\tengineCore: IEngineCore<INodeEngineConfig, INodeEngineState>,\n\tenvVars: IEnvironmentVariables,\n\tparams: {\n\t\tidentity?: string;\n\t}\n): Promise<void> {\n\tDid.guard(\"nodeIdentitySet\", \"identity\", params.identity);\n\n\tCLIDisplay.task(\n\t\tI18n.formatMessage(\"node.cli.commands.node-identity-set.labels.resolvingIdentity\")\n\t);\n\tconst defaultIdentityResolverConnectorType = engineCore.getRegisteredInstanceType(\n\t\t\"identityResolverConnector\"\n\t);\n\n\tconst identityResolverConnector = IdentityResolverConnectorFactory.get(\n\t\tdefaultIdentityResolverConnectorType\n\t);\n\n\tconst identityDocument = await identityResolverConnector.resolveDocument(params.identity);\n\tif (Is.empty(identityDocument)) {\n\t\tthrow new NotFoundError(\"nodeIdentitySet\", \"identityNotFound\", params.identity);\n\t}\n\n\tconst state = engineCore.getState();\n\n\tif (state.nodeId === params.identity) {\n\t\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.node-identity-set.labels.skipping\"));\n\t\treturn;\n\t}\n\n\tstate.nodeId = params.identity;\n\tengineCore.setStateDirty();\n\n\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.node-identity-set.labels.stored\"));\n\n\tCLIDisplay.done();\n}\n"]}
@@ -0,0 +1,54 @@
1
+ // Copyright 2026 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ import { CLIDisplay } from "@twin.org/cli-core";
4
+ import { Coerce, GeneralError, I18n, Is } from "@twin.org/core";
5
+ const COMMAND_NAME = "node-org-id-get";
6
+ /**
7
+ * Get the command definition parameters.
8
+ * @param commandDefinitions The registered command definitions.
9
+ */
10
+ export function getCommandDefinitionNodeOrgIdGet(commandDefinitions) {
11
+ commandDefinitions[COMMAND_NAME] = {
12
+ command: COMMAND_NAME,
13
+ description: I18n.formatMessage("node.cli.commands.node-org-id-get.description"),
14
+ example: I18n.formatMessage("node.cli.commands.node-org-id-get.example"),
15
+ requiresNodeIdentity: false,
16
+ requiresOrgIdentity: false,
17
+ params: [
18
+ {
19
+ key: "env-prefix",
20
+ type: "string",
21
+ description: I18n.formatMessage("node.cli.commands.node-org-id-get.params.env-prefix.description"),
22
+ required: false
23
+ },
24
+ {
25
+ key: "load-env",
26
+ type: "string",
27
+ description: I18n.formatMessage("node.cli.commands.node-org-id-get.params.load-env.description"),
28
+ required: false
29
+ }
30
+ ],
31
+ action: async (engineCore, envVars) => nodeOrgIdGet(engineCore, envVars)
32
+ };
33
+ }
34
+ /**
35
+ * Command for retrieving the organization ID currently assigned to the node.
36
+ * @param engineCore The engine core.
37
+ * @param envVars The environment variables for the node.
38
+ * @returns The node organization DID.
39
+ */
40
+ export async function nodeOrgIdGet(engineCore, envVars) {
41
+ if (Coerce.boolean(envVars.tenantEnabled) ?? false) {
42
+ throw new GeneralError("nodeOrgIdGet", "notAvailableInMultiTenantMode");
43
+ }
44
+ const state = engineCore.getState();
45
+ if (!Is.stringValue(state.nodeOrganizationId)) {
46
+ throw new GeneralError("nodeOrgIdGet", "nodeOrganizationIdNotSet");
47
+ }
48
+ CLIDisplay.break();
49
+ CLIDisplay.value(I18n.formatMessage("node.cli.commands.node-org-id-get.labels.organizationId"), state.nodeOrganizationId);
50
+ CLIDisplay.break();
51
+ CLIDisplay.done();
52
+ return state.nodeOrganizationId;
53
+ }
54
+ //# sourceMappingURL=nodeOrgIdGet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nodeOrgIdGet.js","sourceRoot":"","sources":["../../../src/commands/nodeOrgIdGet.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAOhE,MAAM,YAAY,GAAG,iBAAiB,CAAC;AAEvC;;;GAGG;AACH,MAAM,UAAU,gCAAgC,CAAC,kBAEhD;IACA,kBAAkB,CAAC,YAAY,CAA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AAU,CAAC,KAAK,EAAE,CAAC;IAEnB,UAAU,CAAC,IAAI,EAAE,CAAC;IAElB,OAAO,KAAK,CAAC,kBAAkB,CAAC;AACjC,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { CLIDisplay } from \"@twin.org/cli-core\";\nimport { Coerce, GeneralError, I18n, Is } from \"@twin.org/core\";\nimport type { IEngineCore } from \"@twin.org/engine-models\";\nimport type { ICliCommandDefinition } from \"../models/ICliCommandDefinition.js\";\nimport type { IEnvironmentVariables } from \"../models/IEnvironmentVariables.js\";\nimport type { INodeEngineConfig } from \"../models/INodeEngineConfig.js\";\nimport type { INodeEngineState } from \"../models/INodeEngineState.js\";\n\nconst COMMAND_NAME = \"node-org-id-get\";\n\n/**\n * Get the command definition parameters.\n * @param commandDefinitions The registered command definitions.\n */\nexport function getCommandDefinitionNodeOrgIdGet(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.node-org-id-get.description\"),\n\t\texample: I18n.formatMessage(\"node.cli.commands.node-org-id-get.example\"),\n\t\trequiresNodeIdentity: false,\n\t\trequiresOrgIdentity: 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.node-org-id-get.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.node-org-id-get.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) => nodeOrgIdGet(engineCore, envVars)\n\t};\n}\n\n/**\n * Command for retrieving the organization ID currently assigned to the node.\n * @param engineCore The engine core.\n * @param envVars The environment variables for the node.\n * @returns The node organization DID.\n */\nexport async function nodeOrgIdGet(\n\tengineCore: IEngineCore<INodeEngineConfig, INodeEngineState>,\n\tenvVars: IEnvironmentVariables\n): Promise<string> {\n\tif (Coerce.boolean(envVars.tenantEnabled) ?? false) {\n\t\tthrow new GeneralError(\"nodeOrgIdGet\", \"notAvailableInMultiTenantMode\");\n\t}\n\n\tconst state = engineCore.getState();\n\n\tif (!Is.stringValue(state.nodeOrganizationId)) {\n\t\tthrow new GeneralError(\"nodeOrgIdGet\", \"nodeOrganizationIdNotSet\");\n\t}\n\n\tCLIDisplay.break();\n\tCLIDisplay.value(\n\t\tI18n.formatMessage(\"node.cli.commands.node-org-id-get.labels.organizationId\"),\n\t\tstate.nodeOrganizationId\n\t);\n\tCLIDisplay.break();\n\n\tCLIDisplay.done();\n\n\treturn state.nodeOrganizationId;\n}\n"]}
@@ -3,40 +3,41 @@
3
3
  import { CLIDisplay } from "@twin.org/cli-core";
4
4
  import { Coerce, GeneralError, I18n } from "@twin.org/core";
5
5
  import { Did } from "@twin.org/identity-models";
6
- const COMMAND_NAME = "set-node-org-id";
6
+ const COMMAND_NAME = "node-org-id-set";
7
7
  /**
8
8
  * Get the command definition parameters.
9
9
  * @param commandDefinitions The registered command definitions.
10
10
  */
11
- export function getCommandDefinitionSetNodeOrgId(commandDefinitions) {
11
+ export function getCommandDefinitionNodeOrgIdSet(commandDefinitions) {
12
12
  commandDefinitions[COMMAND_NAME] = {
13
13
  command: COMMAND_NAME,
14
- description: I18n.formatMessage("node.cli.commands.set-node-org-id.description"),
15
- example: I18n.formatMessage("node.cli.commands.set-node-org-id.example"),
14
+ aliases: ["set-node-org-id"],
15
+ description: I18n.formatMessage("node.cli.commands.node-org-id-set.description"),
16
+ example: I18n.formatMessage("node.cli.commands.node-org-id-set.example"),
16
17
  requiresNodeIdentity: false,
17
18
  requiresOrgIdentity: false,
18
19
  params: [
19
20
  {
20
21
  key: "env-prefix",
21
22
  type: "string",
22
- description: I18n.formatMessage("node.cli.commands.set-node-org-id.params.env-prefix.description"),
23
+ description: I18n.formatMessage("node.cli.commands.node-org-id-set.params.env-prefix.description"),
23
24
  required: false
24
25
  },
25
26
  {
26
27
  key: "organization-id",
27
28
  type: "string",
28
29
  extendedType: "did",
29
- description: I18n.formatMessage("node.cli.commands.set-node-org-id.params.organization-id.description"),
30
+ description: I18n.formatMessage("node.cli.commands.node-org-id-set.params.organization-id.description"),
30
31
  required: true
31
32
  },
32
33
  {
33
34
  key: "load-env",
34
35
  type: "string",
35
- description: I18n.formatMessage("node.cli.commands.set-node-org-id.params.load-env.description"),
36
+ description: I18n.formatMessage("node.cli.commands.node-org-id-set.params.load-env.description"),
36
37
  required: false
37
38
  }
38
39
  ],
39
- action: async (engineCore, envVars, params) => setNodeOrgId(engineCore, envVars, params)
40
+ action: async (engineCore, envVars, params) => nodeOrgIdSet(engineCore, envVars, params)
40
41
  };
41
42
  }
42
43
  /**
@@ -48,15 +49,15 @@ export function getCommandDefinitionSetNodeOrgId(commandDefinitions) {
48
49
  * @returns A promise that resolves when the node organization ID has been persisted.
49
50
  * @throws GeneralError if called while multi-tenant mode is enabled.
50
51
  */
51
- export async function setNodeOrgId(engineCore, envVars, params) {
52
+ export async function nodeOrgIdSet(engineCore, envVars, params) {
52
53
  if (Coerce.boolean(envVars.tenantEnabled) ?? false) {
53
- throw new GeneralError("setNodeOrgId", "notAvailableInMultiTenantMode");
54
+ throw new GeneralError("nodeOrgIdSet", "notAvailableInMultiTenantMode");
54
55
  }
55
- Did.guard("setNodeOrgId", "organizationId", params.organizationId);
56
+ Did.guard("nodeOrgIdSet", "organizationId", params.organizationId);
56
57
  const state = engineCore.getState();
57
58
  state.nodeOrganizationId = params.organizationId;
58
59
  engineCore.setStateDirty();
59
- CLIDisplay.task(I18n.formatMessage("node.cli.commands.set-node-org-id.labels.stored"));
60
+ CLIDisplay.task(I18n.formatMessage("node.cli.commands.node-org-id-set.labels.stored"));
60
61
  CLIDisplay.done();
61
62
  }
62
- //# sourceMappingURL=setNodeOrgId.js.map
63
+ //# sourceMappingURL=nodeOrgIdSet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nodeOrgIdSet.js","sourceRoot":"","sources":["../../../src/commands/nodeOrgIdSet.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAE5D,OAAO,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAMhD,MAAM,YAAY,GAAG,iBAAiB,CAAC;AAEvC;;;GAGG;AACH,MAAM,UAAU,gCAAgC,CAAC,kBAEhD;IACA,kBAAkB,CAAC,YAAY,CAAC,GAAG;QAClC,OAAO,EAAE,YAAY;QACrB,OAAO,EAAE,CAAC,iBAAiB,CAAC;QAC5B,WAAW,EAAE,IAAI,CAAC,aAAa,CAAC,+CAA+C,CAAC;QAChF,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,2CAA2C,CAAC;QACxE,oBAAoB,EAAE,KAAK;QAC3B,mBAAmB,EAAE,KAAK;QAC1B,MAAM,EAAE;YACP;gBACC,GAAG,EAAE,YAAY;gBACjB,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,IAAI,CAAC,aAAa,CAC9B,iEAAiE,CACjE;gBACD,QAAQ,EAAE,KAAK;aACf;YACD;gBACC,GAAG,EAAE,iBAAiB;gBACtB,IAAI,EAAE,QAAQ;gBACd,YAAY,EAAE,KAAK;gBACnB,WAAW,EAAE,IAAI,CAAC,aAAa,CAC9B,sEAAsE,CACtE;gBACD,QAAQ,EAAE,IAAI;aACd;YACD;gBACC,GAAG,EAAE,UAAU;gBACf,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,IAAI,CAAC,aAAa,CAC9B,+DAA+D,CAC/D;gBACD,QAAQ,EAAE,KAAK;aACf;SACD;QACD,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,CAAC;KACxF,CAAC;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CACjC,UAA4D,EAC5D,OAA8B,EAC9B,MAEC;IAED,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,KAAK,EAAE,CAAC;QACpD,MAAM,IAAI,YAAY,CAAC,cAAc,EAAE,+BAA+B,CAAC,CAAC;IACzE,CAAC;IAED,GAAG,CAAC,KAAK,CAAC,cAAc,EAAE,gBAAgB,EAAE,MAAM,CAAC,cAAc,CAAC,CAAC;IAEnE,MAAM,KAAK,GAAG,UAAU,CAAC,QAAQ,EAAE,CAAC;IACpC,KAAK,CAAC,kBAAkB,GAAG,MAAM,CAAC,cAAc,CAAC;IACjD,UAAU,CAAC,aAAa,EAAE,CAAC;IAE3B,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,iDAAiD,CAAC,CAAC,CAAC;IAEvF,UAAU,CAAC,IAAI,EAAE,CAAC;AACnB,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { CLIDisplay } from \"@twin.org/cli-core\";\nimport { Coerce, GeneralError, I18n } from \"@twin.org/core\";\nimport type { IEngineCore } from \"@twin.org/engine-models\";\nimport { Did } from \"@twin.org/identity-models\";\nimport type { ICliCommandDefinition } from \"../models/ICliCommandDefinition.js\";\nimport type { IEnvironmentVariables } from \"../models/IEnvironmentVariables.js\";\nimport type { INodeEngineConfig } from \"../models/INodeEngineConfig.js\";\nimport type { INodeEngineState } from \"../models/INodeEngineState.js\";\n\nconst COMMAND_NAME = \"node-org-id-set\";\n\n/**\n * Get the command definition parameters.\n * @param commandDefinitions The registered command definitions.\n */\nexport function getCommandDefinitionNodeOrgIdSet(commandDefinitions: {\n\t[id: string]: ICliCommandDefinition;\n}): void {\n\tcommandDefinitions[COMMAND_NAME] = {\n\t\tcommand: COMMAND_NAME,\n\t\taliases: [\"set-node-org-id\"],\n\t\tdescription: I18n.formatMessage(\"node.cli.commands.node-org-id-set.description\"),\n\t\texample: I18n.formatMessage(\"node.cli.commands.node-org-id-set.example\"),\n\t\trequiresNodeIdentity: false,\n\t\trequiresOrgIdentity: 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.node-org-id-set.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: \"organization-id\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"did\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.node-org-id-set.params.organization-id.description\"\n\t\t\t\t),\n\t\t\t\trequired: true\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.node-org-id-set.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) => nodeOrgIdSet(engineCore, envVars, params)\n\t};\n}\n\n/**\n * Command for setting the node organization ID.\n * @param engineCore The engine core.\n * @param envVars The environment variables for the node.\n * @param params The parameters for the command.\n * @param params.organizationId The organization ID to set.\n * @returns A promise that resolves when the node organization ID has been persisted.\n * @throws GeneralError if called while multi-tenant mode is enabled.\n */\nexport async function nodeOrgIdSet(\n\tengineCore: IEngineCore<INodeEngineConfig, INodeEngineState>,\n\tenvVars: IEnvironmentVariables,\n\tparams: {\n\t\torganizationId?: string;\n\t}\n): Promise<void> {\n\tif (Coerce.boolean(envVars.tenantEnabled) ?? false) {\n\t\tthrow new GeneralError(\"nodeOrgIdSet\", \"notAvailableInMultiTenantMode\");\n\t}\n\n\tDid.guard(\"nodeOrgIdSet\", \"organizationId\", params.organizationId);\n\n\tconst state = engineCore.getState();\n\tstate.nodeOrganizationId = params.organizationId;\n\tengineCore.setStateDirty();\n\n\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.node-org-id-set.labels.stored\"));\n\n\tCLIDisplay.done();\n}\n"]}
@@ -0,0 +1,94 @@
1
+ import { CLIDisplay } from "@twin.org/cli-core";
2
+ import { Coerce, ComponentFactory, GeneralError, I18n, Is } from "@twin.org/core";
3
+ import { ComparisonOperator } from "@twin.org/entity";
4
+ import { EntityStorageConnectorFactory } from "@twin.org/entity-storage-models";
5
+ import { Did } from "@twin.org/identity-models";
6
+ const COMMAND_NAME = "org-users-list";
7
+ /**
8
+ * Get the command definition parameters.
9
+ * @param commandDefinitions The registered command definitions.
10
+ */
11
+ export function getCommandDefinitionOrgUsersList(commandDefinitions) {
12
+ commandDefinitions[COMMAND_NAME] = {
13
+ command: COMMAND_NAME,
14
+ description: I18n.formatMessage("node.cli.commands.org-users-list.description"),
15
+ example: I18n.formatMessage("node.cli.commands.org-users-list.example"),
16
+ requiresNodeIdentity: false,
17
+ requiresOrgIdentity: false,
18
+ params: [
19
+ {
20
+ key: "env-prefix",
21
+ type: "string",
22
+ description: I18n.formatMessage("node.cli.commands.org-users-list.params.env-prefix.description"),
23
+ required: false
24
+ },
25
+ {
26
+ key: "org-did",
27
+ type: "string",
28
+ extendedType: "did",
29
+ description: I18n.formatMessage("node.cli.commands.org-users-list.params.org-did.description"),
30
+ required: false
31
+ },
32
+ {
33
+ key: "load-env",
34
+ type: "string",
35
+ description: I18n.formatMessage("node.cli.commands.org-users-list.params.load-env.description"),
36
+ required: false
37
+ }
38
+ ],
39
+ action: async (engineCore, envVars, params) => orgUsersList(engineCore, envVars, params)
40
+ };
41
+ }
42
+ /**
43
+ * Command for listing all users belonging to a given organization DID.
44
+ * @param engineCore The engine core.
45
+ * @param envVars The environment variables for the node.
46
+ * @param params The parameters for the command.
47
+ * @param params.orgDid The organization DID to filter by. Defaults to the node organization ID in single-tenant mode.
48
+ * @returns The list of users for the organization.
49
+ */
50
+ export async function orgUsersList(engineCore, envVars, params) {
51
+ const isMultiTenant = Coerce.boolean(envVars.tenantEnabled) ?? false;
52
+ let effectiveOrgDid = params.orgDid;
53
+ if (!Is.stringValue(effectiveOrgDid) && !isMultiTenant) {
54
+ effectiveOrgDid = engineCore.getState().nodeOrganizationId;
55
+ }
56
+ if (!Is.stringValue(effectiveOrgDid)) {
57
+ throw new GeneralError("orgUsersList", "orgDidRequired");
58
+ }
59
+ Did.guard("orgUsersList", "org-did", effectiveOrgDid);
60
+ CLIDisplay.task(I18n.formatMessage("node.cli.commands.org-users-list.labels.listing"));
61
+ const authUserStorage = EntityStorageConnectorFactory.get("authentication-user");
62
+ const result = [];
63
+ const platformComponentType = engineCore.getRegisteredInstanceType("platformComponent");
64
+ const platformComponent = ComponentFactory.get(platformComponentType);
65
+ await platformComponent.execute(async () => {
66
+ let cursor;
67
+ do {
68
+ const page = await authUserStorage.query({
69
+ property: "organization",
70
+ value: effectiveOrgDid,
71
+ comparison: ComparisonOperator.Equals
72
+ }, undefined, ["email", "identity", "organization", "scope"], cursor);
73
+ for (const user of page.entities) {
74
+ if (Is.stringValue(user.email)) {
75
+ result.push({
76
+ email: user.email,
77
+ identity: user.identity ?? "",
78
+ scope: user.scope ?? ""
79
+ });
80
+ CLIDisplay.break();
81
+ CLIDisplay.value(I18n.formatMessage("node.cli.commands.org-users-list.labels.email"), user.email);
82
+ CLIDisplay.value(I18n.formatMessage("node.cli.commands.org-users-list.labels.identity"), user.identity ?? "", 1);
83
+ CLIDisplay.value(I18n.formatMessage("node.cli.commands.org-users-list.labels.scope"), user.scope ?? "", 1);
84
+ }
85
+ }
86
+ cursor = page.cursor;
87
+ } while (Is.stringValue(cursor));
88
+ });
89
+ CLIDisplay.break();
90
+ CLIDisplay.value(I18n.formatMessage("node.cli.commands.org-users-list.labels.count"), result.length.toString());
91
+ CLIDisplay.done();
92
+ return result;
93
+ }
94
+ //# sourceMappingURL=orgUsersList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orgUsersList.js","sourceRoot":"","sources":["../../../src/commands/orgUsersList.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAElF,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EACN,6BAA6B,EAE7B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAOhD,MAAM,YAAY,GAAG,gBAAgB,CAAC;AAEtC;;;GAGG;AACH,MAAM,UAAU,gCAAgC,CAAC,kBAEhD;IACA,kBAAkB,CAAC,YAAY,CAAC,GAAG;QAClC,OAAO,EAAE,YAAY;QACrB,WAAW,EAAE,IAAI,CAAC,aAAa,CAAC,8CAA8C,CAAC;QAC/E,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,0CAA0C,CAAC;QACvE,oBAAoB,EAAE,KAAK;QAC3B,mBAAmB,EAAE,KAAK;QAC1B,MAAM,EAAE;YACP;gBACC,GAAG,EAAE,YAAY;gBACjB,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,IAAI,CAAC,aAAa,CAC9B,gEAAgE,CAChE;gBACD,QAAQ,EAAE,KAAK;aACf;YACD;gBACC,GAAG,EAAE,SAAS;gBACd,IAAI,EAAE,QAAQ;gBACd,YAAY,EAAE,KAAK;gBACnB,WAAW,EAAE,IAAI,CAAC,aAAa,CAC9B,6DAA6D,CAC7D;gBACD,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IAEH,UAAU,CAAC,KAAK,EAAE,CAAC;IACnB,UAAU,CAAC,KAAK,CACf,IAAI,CAAC,aAAa,CAAC,+CAA+C,CAAC,EACnE,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,CACxB,CAAC;IAEF,UAAU,CAAC,IAAI,EAAE,CAAC;IAElB,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { AuthenticationUser } from \"@twin.org/api-auth-entity-storage-service\";\nimport type { IPlatformComponent } from \"@twin.org/api-models\";\nimport { CLIDisplay } from \"@twin.org/cli-core\";\nimport { Coerce, ComponentFactory, GeneralError, I18n, Is } from \"@twin.org/core\";\nimport type { IEngineCore } from \"@twin.org/engine-models\";\nimport { ComparisonOperator } from \"@twin.org/entity\";\nimport {\n\tEntityStorageConnectorFactory,\n\ttype IEntityStorageConnector\n} from \"@twin.org/entity-storage-models\";\nimport { Did } from \"@twin.org/identity-models\";\nimport { nameofKebabCase } from \"@twin.org/nameof\";\nimport type { ICliCommandDefinition } from \"../models/ICliCommandDefinition.js\";\nimport type { IEnvironmentVariables } from \"../models/IEnvironmentVariables.js\";\nimport type { INodeEngineConfig } from \"../models/INodeEngineConfig.js\";\nimport type { INodeEngineState } from \"../models/INodeEngineState.js\";\n\nconst COMMAND_NAME = \"org-users-list\";\n\n/**\n * Get the command definition parameters.\n * @param commandDefinitions The registered command definitions.\n */\nexport function getCommandDefinitionOrgUsersList(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.org-users-list.description\"),\n\t\texample: I18n.formatMessage(\"node.cli.commands.org-users-list.example\"),\n\t\trequiresNodeIdentity: false,\n\t\trequiresOrgIdentity: 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.org-users-list.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: \"org-did\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"did\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.org-users-list.params.org-did.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.org-users-list.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) => orgUsersList(engineCore, envVars, params)\n\t};\n}\n\n/**\n * Command for listing all users belonging to a given organization DID.\n * @param engineCore The engine core.\n * @param envVars The environment variables for the node.\n * @param params The parameters for the command.\n * @param params.orgDid The organization DID to filter by. Defaults to the node organization ID in single-tenant mode.\n * @returns The list of users for the organization.\n */\nexport async function orgUsersList(\n\tengineCore: IEngineCore<INodeEngineConfig, INodeEngineState>,\n\tenvVars: IEnvironmentVariables,\n\tparams: {\n\t\torgDid?: string;\n\t}\n): Promise<{ email: string; identity: string; scope: string }[]> {\n\tconst isMultiTenant = Coerce.boolean(envVars.tenantEnabled) ?? false;\n\tlet effectiveOrgDid: string | undefined = params.orgDid;\n\tif (!Is.stringValue(effectiveOrgDid) && !isMultiTenant) {\n\t\teffectiveOrgDid = engineCore.getState().nodeOrganizationId;\n\t}\n\n\tif (!Is.stringValue(effectiveOrgDid)) {\n\t\tthrow new GeneralError(\"orgUsersList\", \"orgDidRequired\");\n\t}\n\n\tDid.guard(\"orgUsersList\", \"org-did\", effectiveOrgDid);\n\n\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.org-users-list.labels.listing\"));\n\n\tconst authUserStorage =\n\t\tEntityStorageConnectorFactory.get<IEntityStorageConnector<AuthenticationUser>>(\n\t\t\tnameofKebabCase<AuthenticationUser>()\n\t\t);\n\n\tconst result: { email: string; identity: string; scope: string }[] = [];\n\n\tconst platformComponentType = engineCore.getRegisteredInstanceType(\"platformComponent\");\n\tconst platformComponent = ComponentFactory.get<IPlatformComponent>(platformComponentType);\n\n\tawait platformComponent.execute(async () => {\n\t\tlet cursor: string | undefined;\n\t\tdo {\n\t\t\tconst page = await authUserStorage.query(\n\t\t\t\t{\n\t\t\t\t\tproperty: \"organization\",\n\t\t\t\t\tvalue: effectiveOrgDid,\n\t\t\t\t\tcomparison: ComparisonOperator.Equals\n\t\t\t\t},\n\t\t\t\tundefined,\n\t\t\t\t[\"email\", \"identity\", \"organization\", \"scope\"],\n\t\t\t\tcursor\n\t\t\t);\n\t\t\tfor (const user of page.entities) {\n\t\t\t\tif (Is.stringValue(user.email)) {\n\t\t\t\t\tresult.push({\n\t\t\t\t\t\temail: user.email,\n\t\t\t\t\t\tidentity: user.identity ?? \"\",\n\t\t\t\t\t\tscope: user.scope ?? \"\"\n\t\t\t\t\t});\n\t\t\t\t\tCLIDisplay.break();\n\t\t\t\t\tCLIDisplay.value(\n\t\t\t\t\t\tI18n.formatMessage(\"node.cli.commands.org-users-list.labels.email\"),\n\t\t\t\t\t\tuser.email\n\t\t\t\t\t);\n\t\t\t\t\tCLIDisplay.value(\n\t\t\t\t\t\tI18n.formatMessage(\"node.cli.commands.org-users-list.labels.identity\"),\n\t\t\t\t\t\tuser.identity ?? \"\",\n\t\t\t\t\t\t1\n\t\t\t\t\t);\n\t\t\t\t\tCLIDisplay.value(\n\t\t\t\t\t\tI18n.formatMessage(\"node.cli.commands.org-users-list.labels.scope\"),\n\t\t\t\t\t\tuser.scope ?? \"\",\n\t\t\t\t\t\t1\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tcursor = page.cursor;\n\t\t} while (Is.stringValue(cursor));\n\t});\n\n\tCLIDisplay.break();\n\tCLIDisplay.value(\n\t\tI18n.formatMessage(\"node.cli.commands.org-users-list.labels.count\"),\n\t\tresult.length.toString()\n\t);\n\n\tCLIDisplay.done();\n\n\treturn result;\n}\n"]}
@@ -0,0 +1,68 @@
1
+ import { CLIDisplay } from "@twin.org/cli-core";
2
+ import { ComponentFactory, GeneralError, Guards, I18n, Is } from "@twin.org/core";
3
+ const COMMAND_NAME = "tenant-get";
4
+ /**
5
+ * Get the command definition parameters.
6
+ * @param commandDefinitions The registered command definitions.
7
+ */
8
+ export function getCommandDefinitionTenantGet(commandDefinitions) {
9
+ commandDefinitions[COMMAND_NAME] = {
10
+ command: COMMAND_NAME,
11
+ description: I18n.formatMessage("node.cli.commands.tenant-get.description"),
12
+ example: I18n.formatMessage("node.cli.commands.tenant-get.example"),
13
+ requiresNodeIdentity: false,
14
+ requiresOrgIdentity: false,
15
+ params: [
16
+ {
17
+ key: "env-prefix",
18
+ type: "string",
19
+ description: I18n.formatMessage("node.cli.commands.tenant-get.params.env-prefix.description"),
20
+ required: false
21
+ },
22
+ {
23
+ key: "tenant-id",
24
+ type: "string",
25
+ extendedType: "hex(32)",
26
+ description: I18n.formatMessage("node.cli.commands.tenant-get.params.tenant-id.description"),
27
+ required: true
28
+ },
29
+ {
30
+ key: "load-env",
31
+ type: "string",
32
+ description: I18n.formatMessage("node.cli.commands.tenant-get.params.load-env.description"),
33
+ required: false
34
+ }
35
+ ],
36
+ action: async (engineCore, envVars, params) => tenantGet(engineCore, envVars, params)
37
+ };
38
+ }
39
+ /**
40
+ * Command for retrieving a single tenant by ID.
41
+ * @param engineCore The engine core.
42
+ * @param envVars The environment variables for the node.
43
+ * @param params The parameters for the command.
44
+ * @param params.tenantId The ID of the tenant to retrieve.
45
+ * @returns The tenant record.
46
+ */
47
+ export async function tenantGet(engineCore, envVars, params) {
48
+ Guards.stringHexLength("tenantGet", "tenant-id", params.tenantId, 32);
49
+ const type = engineCore.getRegisteredInstanceTypeOptional("tenantAdminComponent");
50
+ if (!Is.stringValue(type)) {
51
+ throw new GeneralError("tenantGet", "tenantAdminComponentNotRegistered");
52
+ }
53
+ const tenantAdminComponent = ComponentFactory.get(type);
54
+ CLIDisplay.task(I18n.formatMessage("node.cli.commands.tenant-get.labels.retrieving"));
55
+ const tenant = await tenantAdminComponent.get(params.tenantId);
56
+ CLIDisplay.break();
57
+ CLIDisplay.value(I18n.formatMessage("node.cli.commands.tenant-get.labels.tenantId"), tenant.id);
58
+ CLIDisplay.value(I18n.formatMessage("node.cli.commands.tenant-get.labels.apiKey"), tenant.apiKey, 1);
59
+ CLIDisplay.value(I18n.formatMessage("node.cli.commands.tenant-get.labels.organizationId"), tenant.organizationId ?? "", 1);
60
+ CLIDisplay.value(I18n.formatMessage("node.cli.commands.tenant-get.labels.label"), tenant.label ?? "", 1);
61
+ CLIDisplay.value(I18n.formatMessage("node.cli.commands.tenant-get.labels.publicOrigin"), tenant.publicOrigin ?? "", 1);
62
+ CLIDisplay.value(I18n.formatMessage("node.cli.commands.tenant-get.labels.dateCreated"), tenant.dateCreated, 1);
63
+ CLIDisplay.value(I18n.formatMessage("node.cli.commands.tenant-get.labels.dateModified"), tenant.dateModified, 1);
64
+ CLIDisplay.break();
65
+ CLIDisplay.done();
66
+ return tenant;
67
+ }
68
+ //# sourceMappingURL=tenantGet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tenantGet.js","sourceRoot":"","sources":["../../../src/commands/tenantGet.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAKlF,MAAM,YAAY,GAAG,YAAY,CAAC;AAElC;;;GAGG;AACH,MAAM,UAAU,6BAA6B,CAAC,kBAE7C;IACA,kBAAkB,CAAC,YAAY,CAAC,GAAG;QAClC,OAAO,EAAE,YAAY;QACr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.0.\nimport type { ITenantAdminComponent, ITenant } from \"@twin.org/api-models\";\nimport { CLIDisplay } from \"@twin.org/cli-core\";\nimport { ComponentFactory, GeneralError, Guards, I18n, Is } from \"@twin.org/core\";\nimport type { IEngineCore } from \"@twin.org/engine-models\";\nimport type { ICliCommandDefinition } from \"../models/ICliCommandDefinition.js\";\nimport type { IEnvironmentVariables } from \"../models/IEnvironmentVariables.js\";\n\nconst COMMAND_NAME = \"tenant-get\";\n\n/**\n * Get the command definition parameters.\n * @param commandDefinitions The registered command definitions.\n */\nexport function getCommandDefinitionTenantGet(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.tenant-get.description\"),\n\t\texample: I18n.formatMessage(\"node.cli.commands.tenant-get.example\"),\n\t\trequiresNodeIdentity: false,\n\t\trequiresOrgIdentity: 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.tenant-get.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: \"tenant-id\",\n\t\t\t\ttype: \"string\",\n\t\t\t\textendedType: \"hex(32)\",\n\t\t\t\tdescription: I18n.formatMessage(\n\t\t\t\t\t\"node.cli.commands.tenant-get.params.tenant-id.description\"\n\t\t\t\t),\n\t\t\t\trequired: true\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(\"node.cli.commands.tenant-get.params.load-env.description\"),\n\t\t\t\trequired: false\n\t\t\t}\n\t\t],\n\t\taction: async (engineCore, envVars, params) => tenantGet(engineCore, envVars, params)\n\t};\n}\n\n/**\n * Command for retrieving a single tenant by ID.\n * @param engineCore The engine core.\n * @param envVars The environment variables for the node.\n * @param params The parameters for the command.\n * @param params.tenantId The ID of the tenant to retrieve.\n * @returns The tenant record.\n */\nexport async function tenantGet(\n\tengineCore: IEngineCore,\n\tenvVars: IEnvironmentVariables,\n\tparams: {\n\t\ttenantId?: string;\n\t}\n): Promise<ITenant> {\n\tGuards.stringHexLength(\"tenantGet\", \"tenant-id\", params.tenantId, 32);\n\n\tconst type = engineCore.getRegisteredInstanceTypeOptional(\"tenantAdminComponent\");\n\n\tif (!Is.stringValue(type)) {\n\t\tthrow new GeneralError(\"tenantGet\", \"tenantAdminComponentNotRegistered\");\n\t}\n\n\tconst tenantAdminComponent = ComponentFactory.get<ITenantAdminComponent>(type);\n\n\tCLIDisplay.task(I18n.formatMessage(\"node.cli.commands.tenant-get.labels.retrieving\"));\n\n\tconst tenant = await tenantAdminComponent.get(params.tenantId);\n\n\tCLIDisplay.break();\n\tCLIDisplay.value(I18n.formatMessage(\"node.cli.commands.tenant-get.labels.tenantId\"), tenant.id);\n\tCLIDisplay.value(\n\t\tI18n.formatMessage(\"node.cli.commands.tenant-get.labels.apiKey\"),\n\t\ttenant.apiKey,\n\t\t1\n\t);\n\tCLIDisplay.value(\n\t\tI18n.formatMessage(\"node.cli.commands.tenant-get.labels.organizationId\"),\n\t\ttenant.organizationId ?? \"\",\n\t\t1\n\t);\n\tCLIDisplay.value(\n\t\tI18n.formatMessage(\"node.cli.commands.tenant-get.labels.label\"),\n\t\ttenant.label ?? \"\",\n\t\t1\n\t);\n\tCLIDisplay.value(\n\t\tI18n.formatMessage(\"node.cli.commands.tenant-get.labels.publicOrigin\"),\n\t\ttenant.publicOrigin ?? \"\",\n\t\t1\n\t);\n\tCLIDisplay.value(\n\t\tI18n.formatMessage(\"node.cli.commands.tenant-get.labels.dateCreated\"),\n\t\ttenant.dateCreated,\n\t\t1\n\t);\n\tCLIDisplay.value(\n\t\tI18n.formatMessage(\"node.cli.commands.tenant-get.labels.dateModified\"),\n\t\ttenant.dateModified,\n\t\t1\n\t);\n\tCLIDisplay.break();\n\n\tCLIDisplay.done();\n\n\treturn tenant;\n}\n"]}
@@ -0,0 +1,69 @@
1
+ import { CLIDisplay } from "@twin.org/cli-core";
2
+ import { ComponentFactory, GeneralError, I18n, Is } from "@twin.org/core";
3
+ const COMMAND_NAME = "tenant-list";
4
+ /**
5
+ * Get the command definition parameters.
6
+ * @param commandDefinitions The registered command definitions.
7
+ */
8
+ export function getCommandDefinitionTenantList(commandDefinitions) {
9
+ commandDefinitions[COMMAND_NAME] = {
10
+ command: COMMAND_NAME,
11
+ description: I18n.formatMessage("node.cli.commands.tenant-list.description"),
12
+ example: I18n.formatMessage("node.cli.commands.tenant-list.example"),
13
+ requiresNodeIdentity: false,
14
+ requiresOrgIdentity: false,
15
+ params: [
16
+ {
17
+ key: "env-prefix",
18
+ type: "string",
19
+ description: I18n.formatMessage("node.cli.commands.tenant-list.params.env-prefix.description"),
20
+ required: false
21
+ },
22
+ {
23
+ key: "load-env",
24
+ type: "string",
25
+ description: I18n.formatMessage("node.cli.commands.tenant-list.params.load-env.description"),
26
+ required: false
27
+ }
28
+ ],
29
+ action: async (engineCore, envVars) => tenantList(engineCore, envVars)
30
+ };
31
+ }
32
+ /**
33
+ * Command for listing all tenants.
34
+ * @param engineCore The engine core.
35
+ * @param envVars The environment variables for the node.
36
+ * @returns The list of tenants.
37
+ */
38
+ export async function tenantList(engineCore, envVars) {
39
+ const type = engineCore.getRegisteredInstanceTypeOptional("tenantAdminComponent");
40
+ if (!Is.stringValue(type)) {
41
+ throw new GeneralError("tenantList", "tenantAdminComponentNotRegistered");
42
+ }
43
+ const tenantAdminComponent = ComponentFactory.get(type);
44
+ CLIDisplay.task(I18n.formatMessage("node.cli.commands.tenant-list.labels.listing"));
45
+ const result = [];
46
+ let cursor;
47
+ do {
48
+ const page = await tenantAdminComponent.query(undefined, undefined, cursor);
49
+ for (const tenant of page.tenants) {
50
+ result.push({
51
+ id: tenant.id,
52
+ apiKey: tenant.apiKey,
53
+ organizationId: tenant.organizationId ?? "",
54
+ label: tenant.label ?? ""
55
+ });
56
+ CLIDisplay.break();
57
+ CLIDisplay.value(I18n.formatMessage("node.cli.commands.tenant-list.labels.tenantId"), tenant.id);
58
+ CLIDisplay.value(I18n.formatMessage("node.cli.commands.tenant-list.labels.apiKey"), tenant.apiKey, 1);
59
+ CLIDisplay.value(I18n.formatMessage("node.cli.commands.tenant-list.labels.organizationId"), tenant.organizationId ?? "", 1);
60
+ CLIDisplay.value(I18n.formatMessage("node.cli.commands.tenant-list.labels.label"), tenant.label ?? "", 1);
61
+ }
62
+ cursor = page.cursor;
63
+ } while (Is.stringValue(cursor));
64
+ CLIDisplay.break();
65
+ CLIDisplay.value(I18n.formatMessage("node.cli.commands.tenant-list.labels.count"), result.length.toString());
66
+ CLIDisplay.done();
67
+ return result;
68
+ }
69
+ //# sourceMappingURL=tenantList.js.map