@flowcore/cli-plugin-iam 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/README.md +78 -0
- package/bin/dev.cmd +3 -0
- package/bin/dev.js +5 -0
- package/bin/run.cmd +3 -0
- package/bin/run.js +5 -0
- package/dist/commands/get/policy.d.ts +17 -0
- package/dist/commands/get/policy.js +165 -0
- package/dist/commands/get/role.d.ts +17 -0
- package/dist/commands/get/role.js +157 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/services/organization.service.d.ts +15 -0
- package/dist/services/organization.service.js +13 -0
- package/dist/utils/clients/iam/Api.d.ts +707 -0
- package/dist/utils/clients/iam/Api.js +482 -0
- package/dist/utils/clients/iam/Health.d.ts +10 -0
- package/dist/utils/clients/iam/Health.js +24 -0
- package/dist/utils/clients/iam/Transformers.d.ts +119 -0
- package/dist/utils/clients/iam/Transformers.js +81 -0
- package/dist/utils/clients/iam/http-client.d.ts +59 -0
- package/dist/utils/clients/iam/http-client.js +160 -0
- package/dist/utils/combine-merge.util.d.ts +2 -0
- package/dist/utils/combine-merge.util.js +16 -0
- package/dist/utils/fetch-manifest.util.d.ts +6 -0
- package/dist/utils/fetch-manifest.util.js +56 -0
- package/dist/utils/queries/fetch-organization-by-tenant.gql.d.ts +14 -0
- package/dist/utils/queries/fetch-organization-by-tenant.gql.js +16 -0
- package/dist/utils/read-pipe.util.d.ts +1 -0
- package/dist/utils/read-pipe.util.js +14 -0
- package/oclif.manifest.json +127 -0
- package/package.json +93 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 1.0.0 (2024-09-29)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* :tada: initial commit ([72c9ba6](https://github.com/flowcore-io/cli-plugin-iam/commit/72c9ba65bd10c43d7e6711fbc39eb877ee257bb2))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **configuration:** :wrench: updated eslint configuration ([f9d2bac](https://github.com/flowcore-io/cli-plugin-iam/commit/f9d2bac01baa39963273922dbad697da6496a41b))
|
package/README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
Flowcore CLI Plugin - Iam
|
|
2
|
+
=================
|
|
3
|
+
|
|
4
|
+
Flowcore CLI plugin for managing the IAM of the Flowcore Platform
|
|
5
|
+
|
|
6
|
+
[](https://npmjs.org/package/@flowcore/flowcore-cli-plugin-scenario)
|
|
7
|
+
[](https://oclif.io)
|
|
8
|
+
[](https://github.com/@flowcore/flowcore-cli-plugin-scenario/actions/workflows/build.yml)
|
|
9
|
+
|
|
10
|
+
<!-- toc -->
|
|
11
|
+
* [Usage](#usage)
|
|
12
|
+
* [Commands](#commands)
|
|
13
|
+
<!-- tocstop -->
|
|
14
|
+
# Usage
|
|
15
|
+
<!-- usage -->
|
|
16
|
+
```sh-session
|
|
17
|
+
$ npm install -g @flowcore/cli-plugin-iam
|
|
18
|
+
$ iam COMMAND
|
|
19
|
+
running command...
|
|
20
|
+
$ iam (--version)
|
|
21
|
+
@flowcore/cli-plugin-iam/1.0.0 linux-x64 node-v20.17.0
|
|
22
|
+
$ iam --help [COMMAND]
|
|
23
|
+
USAGE
|
|
24
|
+
$ iam COMMAND
|
|
25
|
+
...
|
|
26
|
+
```
|
|
27
|
+
<!-- usagestop -->
|
|
28
|
+
# Commands
|
|
29
|
+
<!-- commands -->
|
|
30
|
+
* [`iam get policy [NAME]`](#iam-get-policy-name)
|
|
31
|
+
* [`iam get role [NAME]`](#iam-get-role-name)
|
|
32
|
+
|
|
33
|
+
## `iam get policy [NAME]`
|
|
34
|
+
|
|
35
|
+
Get a policy
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
USAGE
|
|
39
|
+
$ iam get policy [NAME] [--profile <value>] [-j] [-t <value>] [-w]
|
|
40
|
+
|
|
41
|
+
ARGUMENTS
|
|
42
|
+
NAME name
|
|
43
|
+
|
|
44
|
+
FLAGS
|
|
45
|
+
-j, --json json output
|
|
46
|
+
-t, --tenant=<value> tenant
|
|
47
|
+
-w, --wide wide output
|
|
48
|
+
--profile=<value> Specify the configuration profile to use
|
|
49
|
+
|
|
50
|
+
DESCRIPTION
|
|
51
|
+
Get a policy
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
_See code: [src/commands/get/policy.ts](https://github.com/flowcore-io/cli-plugin-iam/blob/v1.0.0/src/commands/get/policy.ts)_
|
|
55
|
+
|
|
56
|
+
## `iam get role [NAME]`
|
|
57
|
+
|
|
58
|
+
Get a role
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
USAGE
|
|
62
|
+
$ iam get role [NAME] [--profile <value>] [-j] [-t <value>] [-w]
|
|
63
|
+
|
|
64
|
+
ARGUMENTS
|
|
65
|
+
NAME name
|
|
66
|
+
|
|
67
|
+
FLAGS
|
|
68
|
+
-j, --json json output
|
|
69
|
+
-t, --tenant=<value> tenant
|
|
70
|
+
-w, --wide wide output
|
|
71
|
+
--profile=<value> Specify the configuration profile to use
|
|
72
|
+
|
|
73
|
+
DESCRIPTION
|
|
74
|
+
Get a role
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
_See code: [src/commands/get/role.ts](https://github.com/flowcore-io/cli-plugin-iam/blob/v1.0.0/src/commands/get/role.ts)_
|
|
78
|
+
<!-- commandsstop -->
|
package/bin/dev.cmd
ADDED
package/bin/dev.js
ADDED
package/bin/run.cmd
ADDED
package/bin/run.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BaseCommand } from "@flowcore/cli-plugin-config";
|
|
2
|
+
export declare const GET_POLICY_ARGS: {
|
|
3
|
+
NAME: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
4
|
+
};
|
|
5
|
+
export default class GetPolicy extends BaseCommand<typeof GetPolicy> {
|
|
6
|
+
static args: {
|
|
7
|
+
NAME: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
8
|
+
};
|
|
9
|
+
static description: string;
|
|
10
|
+
static examples: never[];
|
|
11
|
+
static flags: {
|
|
12
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
tenant: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
wide: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
15
|
+
};
|
|
16
|
+
run(): Promise<void>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { BaseCommand, ValidateLogin } from "@flowcore/cli-plugin-config";
|
|
2
|
+
import { ClientFactory } from "@flowcore/cli-plugin-core";
|
|
3
|
+
import { Args, Flags } from "@oclif/core";
|
|
4
|
+
import _ from "lodash";
|
|
5
|
+
import { tryit } from "radash";
|
|
6
|
+
import { OrganizationService } from "../../services/organization.service.js";
|
|
7
|
+
import { Api as IamApi } from "../../utils/clients/iam/Api.js";
|
|
8
|
+
export const GET_POLICY_ARGS = {
|
|
9
|
+
NAME: Args.string({ description: "name", required: false }),
|
|
10
|
+
};
|
|
11
|
+
export default class GetPolicy extends BaseCommand {
|
|
12
|
+
static args = GET_POLICY_ARGS;
|
|
13
|
+
static description = "Get a policy";
|
|
14
|
+
static examples = [];
|
|
15
|
+
static flags = {
|
|
16
|
+
json: Flags.boolean({
|
|
17
|
+
char: "j",
|
|
18
|
+
description: "json output",
|
|
19
|
+
required: false,
|
|
20
|
+
}),
|
|
21
|
+
tenant: Flags.string({
|
|
22
|
+
char: "t",
|
|
23
|
+
description: "tenant",
|
|
24
|
+
required: false,
|
|
25
|
+
}),
|
|
26
|
+
wide: Flags.boolean({
|
|
27
|
+
char: "w",
|
|
28
|
+
description: "wide output",
|
|
29
|
+
required: false,
|
|
30
|
+
}),
|
|
31
|
+
};
|
|
32
|
+
async run() {
|
|
33
|
+
const { args, flags } = await this.parse(GetPolicy);
|
|
34
|
+
if (args.NAME && !flags.tenant) {
|
|
35
|
+
this.logger.fatal("Tenant is required when using name");
|
|
36
|
+
}
|
|
37
|
+
const graphqlClient = await ClientFactory.create(this.cliConfiguration, this.logger, flags.json);
|
|
38
|
+
const organizationService = new OrganizationService(graphqlClient);
|
|
39
|
+
const organizations = await organizationService.getMyOrganizations();
|
|
40
|
+
const iamClient = new IamApi({
|
|
41
|
+
baseUrl: "https://iam.api.flowcore.io",
|
|
42
|
+
});
|
|
43
|
+
const config = this.cliConfiguration.getConfig();
|
|
44
|
+
const login = new ValidateLogin(config.login.url);
|
|
45
|
+
await login.validate(config, this.cliConfiguration, !flags.json);
|
|
46
|
+
const { auth } = config;
|
|
47
|
+
if (!auth?.accessToken) {
|
|
48
|
+
this.logger.fatal("Not logged in, run 'flowcore login'");
|
|
49
|
+
}
|
|
50
|
+
let policiesResponse;
|
|
51
|
+
if (flags.tenant) {
|
|
52
|
+
const organization = organizations.me.organizations.find((organization) => organization.organization.org === flags.tenant);
|
|
53
|
+
if (!organization) {
|
|
54
|
+
this.logger.fatal(`Organization ${flags.tenant} not found or not accessible`);
|
|
55
|
+
}
|
|
56
|
+
const [err, response] = await tryit(iamClient.getApiV1PolicyAssociationsOrganizationByOrganizationId)(organization.organization.id, {
|
|
57
|
+
headers: {
|
|
58
|
+
Authorization: `Bearer ${auth?.accessToken}`,
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
if (err) {
|
|
62
|
+
this.logger.fatal(`Failed to get policies: ${err.message}`);
|
|
63
|
+
}
|
|
64
|
+
policiesResponse = response;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
const [err, response] = await tryit(iamClient.getApiV1Policies)({
|
|
68
|
+
headers: {
|
|
69
|
+
Authorization: `Bearer ${auth?.accessToken}`,
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
if (err) {
|
|
73
|
+
this.logger.fatal(`Failed to get policies: ${err.message}`);
|
|
74
|
+
}
|
|
75
|
+
policiesResponse = response;
|
|
76
|
+
}
|
|
77
|
+
const policies = policiesResponse.data
|
|
78
|
+
.map((policy) => {
|
|
79
|
+
const organizationLink = organizations.me.organizations.find((organization) => organization.organization.id === policy.organizationId);
|
|
80
|
+
if (!organizationLink) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
description: policy.description,
|
|
85
|
+
documents: policy.policyDocuments,
|
|
86
|
+
id: policy.id,
|
|
87
|
+
name: policy.name,
|
|
88
|
+
organization: organizationLink,
|
|
89
|
+
organizationId: policy.organizationId,
|
|
90
|
+
principal: policy.principal,
|
|
91
|
+
version: policy.version,
|
|
92
|
+
};
|
|
93
|
+
})
|
|
94
|
+
.filter((policy) => policy !== undefined);
|
|
95
|
+
if (args.NAME) {
|
|
96
|
+
const policy = policies.find((policy) => policy.name === args.NAME);
|
|
97
|
+
if (!policy) {
|
|
98
|
+
this.logger.fatal(`Policy ${args.NAME} not found`);
|
|
99
|
+
}
|
|
100
|
+
if (flags.json) {
|
|
101
|
+
console.log(JSON.stringify(_.omit(policy, "organization"), null, 2));
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
this.ui
|
|
105
|
+
.sticker()
|
|
106
|
+
.add(`Policy ${this.ui.colors.green(policy.name)}`)
|
|
107
|
+
.add("")
|
|
108
|
+
.add(`ID: ${this.ui.colors.green(policy.id)}`)
|
|
109
|
+
.add(`Description: ${this.ui.colors.green(policy.description ?? "")}`)
|
|
110
|
+
.add(`Organization: ${this.ui.colors.green(policy.organization.organization.displayName === "" ? policy.organization.organization.org : policy.organization.organization.displayName)}`)
|
|
111
|
+
.render();
|
|
112
|
+
this.logger.info("");
|
|
113
|
+
this.logger.info("Documents:");
|
|
114
|
+
const documents = policy.documents.map((document) => ({
|
|
115
|
+
action: document.action,
|
|
116
|
+
resource: document.resource,
|
|
117
|
+
statementId: document.statementId,
|
|
118
|
+
}));
|
|
119
|
+
const documentHeaders = ["Statement ID", "Resource", "Action"];
|
|
120
|
+
let documentTable = this.ui.table().head(documentHeaders);
|
|
121
|
+
for (const document of documents) {
|
|
122
|
+
const row = [
|
|
123
|
+
document.statementId,
|
|
124
|
+
document.resource,
|
|
125
|
+
document.action,
|
|
126
|
+
];
|
|
127
|
+
documentTable = documentTable.row(row);
|
|
128
|
+
}
|
|
129
|
+
documentTable.render();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
else if (flags.json) {
|
|
133
|
+
console.log(JSON.stringify(policies.map((policy) => _.omit(policy, "organization")), null, 2));
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
const headers = [
|
|
137
|
+
"Policy ID",
|
|
138
|
+
"Name",
|
|
139
|
+
"Description",
|
|
140
|
+
"Version",
|
|
141
|
+
"Documents",
|
|
142
|
+
"Principal",
|
|
143
|
+
"Organization Name",
|
|
144
|
+
...(flags.wide ? ["Organization ID"] : []),
|
|
145
|
+
];
|
|
146
|
+
const listTable = this.ui.table().head(headers);
|
|
147
|
+
for (const policy of policies) {
|
|
148
|
+
const row = [
|
|
149
|
+
policy.id,
|
|
150
|
+
policy.name,
|
|
151
|
+
policy.description ?? "",
|
|
152
|
+
policy.version,
|
|
153
|
+
policy.documents.length,
|
|
154
|
+
policy.principal ?? "",
|
|
155
|
+
policy.organization.organization.displayName === ""
|
|
156
|
+
? policy.organization.organization.org
|
|
157
|
+
: policy.organization.organization.displayName,
|
|
158
|
+
...(flags.wide ? [policy.organization.organization.id] : []),
|
|
159
|
+
];
|
|
160
|
+
listTable.row(row);
|
|
161
|
+
}
|
|
162
|
+
listTable.render();
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BaseCommand } from "@flowcore/cli-plugin-config";
|
|
2
|
+
export declare const GET_ROLE_ARGS: {
|
|
3
|
+
NAME: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
4
|
+
};
|
|
5
|
+
export default class GetRole extends BaseCommand<typeof GetRole> {
|
|
6
|
+
static args: {
|
|
7
|
+
NAME: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
8
|
+
};
|
|
9
|
+
static description: string;
|
|
10
|
+
static examples: never[];
|
|
11
|
+
static flags: {
|
|
12
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
tenant: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
wide: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
15
|
+
};
|
|
16
|
+
run(): Promise<void>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { BaseCommand, ValidateLogin } from "@flowcore/cli-plugin-config";
|
|
2
|
+
import { ClientFactory } from "@flowcore/cli-plugin-core";
|
|
3
|
+
import { Args, Flags } from "@oclif/core";
|
|
4
|
+
import _ from "lodash";
|
|
5
|
+
import { tryit } from "radash";
|
|
6
|
+
import { OrganizationService } from "../../services/organization.service.js";
|
|
7
|
+
import { Api as IamApi } from "../../utils/clients/iam/Api.js";
|
|
8
|
+
export const GET_ROLE_ARGS = {
|
|
9
|
+
NAME: Args.string({ description: "name", required: false }),
|
|
10
|
+
};
|
|
11
|
+
export default class GetRole extends BaseCommand {
|
|
12
|
+
static args = GET_ROLE_ARGS;
|
|
13
|
+
static description = "Get a role";
|
|
14
|
+
static examples = [];
|
|
15
|
+
static flags = {
|
|
16
|
+
json: Flags.boolean({
|
|
17
|
+
char: "j",
|
|
18
|
+
description: "json output",
|
|
19
|
+
required: false,
|
|
20
|
+
}),
|
|
21
|
+
tenant: Flags.string({
|
|
22
|
+
char: "t",
|
|
23
|
+
description: "tenant",
|
|
24
|
+
required: false,
|
|
25
|
+
}),
|
|
26
|
+
wide: Flags.boolean({
|
|
27
|
+
char: "w",
|
|
28
|
+
description: "wide output",
|
|
29
|
+
required: false,
|
|
30
|
+
}),
|
|
31
|
+
};
|
|
32
|
+
async run() {
|
|
33
|
+
const { args, flags } = await this.parse(GetRole);
|
|
34
|
+
if (args.NAME && !flags.tenant) {
|
|
35
|
+
this.logger.fatal("Tenant is required when using name");
|
|
36
|
+
}
|
|
37
|
+
const graphqlClient = await ClientFactory.create(this.cliConfiguration, this.logger, flags.json);
|
|
38
|
+
const organizationService = new OrganizationService(graphqlClient);
|
|
39
|
+
const organizations = await organizationService.getMyOrganizations();
|
|
40
|
+
const iamClient = new IamApi({
|
|
41
|
+
baseUrl: "https://iam.api.flowcore.io",
|
|
42
|
+
});
|
|
43
|
+
const config = this.cliConfiguration.getConfig();
|
|
44
|
+
const login = new ValidateLogin(config.login.url);
|
|
45
|
+
await login.validate(config, this.cliConfiguration, !flags.json);
|
|
46
|
+
const { auth } = config;
|
|
47
|
+
if (!auth?.accessToken) {
|
|
48
|
+
this.logger.fatal("Not logged in, run 'flowcore login'");
|
|
49
|
+
}
|
|
50
|
+
const [err, rolesResponse] = await tryit(iamClient.getApiV1Roles)({
|
|
51
|
+
headers: {
|
|
52
|
+
Authorization: `Bearer ${auth?.accessToken}`,
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
if (err) {
|
|
56
|
+
this.logger.fatal(`Failed to get roles: ${err.message}`);
|
|
57
|
+
}
|
|
58
|
+
const roles = rolesResponse.data
|
|
59
|
+
.map((role) => {
|
|
60
|
+
const organizationLink = organizations.me.organizations.find((organization) => organization.organization.id === role.organizationId);
|
|
61
|
+
if (!organizationLink) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
description: role.description,
|
|
66
|
+
id: role.id,
|
|
67
|
+
name: role.name,
|
|
68
|
+
organization: organizationLink,
|
|
69
|
+
organizationId: role.organizationId,
|
|
70
|
+
};
|
|
71
|
+
})
|
|
72
|
+
.filter((role) => role !== undefined)
|
|
73
|
+
.filter((role) => {
|
|
74
|
+
if (flags.tenant) {
|
|
75
|
+
return role.organization.organization.org === flags.tenant;
|
|
76
|
+
}
|
|
77
|
+
return true;
|
|
78
|
+
});
|
|
79
|
+
if (args.NAME) {
|
|
80
|
+
const role = roles.find((role) => role.name === args.NAME);
|
|
81
|
+
if (!role) {
|
|
82
|
+
this.logger.fatal(`Role ${args.NAME} not found`);
|
|
83
|
+
}
|
|
84
|
+
if (flags.json) {
|
|
85
|
+
console.log(JSON.stringify(_.omit(role, "organization"), null, 2));
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
this.ui
|
|
89
|
+
.sticker()
|
|
90
|
+
.add(`Role ${this.ui.colors.green(role.name)}`)
|
|
91
|
+
.add("")
|
|
92
|
+
.add(`ID: ${this.ui.colors.green(role.id)}`)
|
|
93
|
+
.add(`Description: ${this.ui.colors.green(role.description ?? "")}`)
|
|
94
|
+
.add(`Organization: ${this.ui.colors.green(role.organization.organization.displayName === "" ? role.organization.organization.org : role.organization.organization.displayName)}`)
|
|
95
|
+
.render();
|
|
96
|
+
this.logger.info("");
|
|
97
|
+
this.logger.info("Policies:");
|
|
98
|
+
const [err, policies] = await tryit(iamClient.getApiV1PolicyAssociationsOrganizationByOrganizationId)(role.organization.organization.id, {
|
|
99
|
+
headers: {
|
|
100
|
+
Authorization: `Bearer ${auth?.accessToken}`,
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
if (err) {
|
|
104
|
+
this.logger.fatal(`Failed to get policies: ${err.message}`);
|
|
105
|
+
}
|
|
106
|
+
const policyHeaders = [
|
|
107
|
+
"Policy ID",
|
|
108
|
+
"Name",
|
|
109
|
+
"Description",
|
|
110
|
+
"Version",
|
|
111
|
+
"Documents",
|
|
112
|
+
"Principal",
|
|
113
|
+
];
|
|
114
|
+
let policyTable = this.ui.table().head(policyHeaders);
|
|
115
|
+
for (const policy of policies.data) {
|
|
116
|
+
const row = [
|
|
117
|
+
policy.id,
|
|
118
|
+
policy.name,
|
|
119
|
+
policy.description ?? "",
|
|
120
|
+
policy.version,
|
|
121
|
+
policy.policyDocuments.length,
|
|
122
|
+
policy.principal ?? "",
|
|
123
|
+
];
|
|
124
|
+
policyTable = policyTable.row(row);
|
|
125
|
+
}
|
|
126
|
+
policyTable.render();
|
|
127
|
+
this.logger.info("");
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
else if (flags.json) {
|
|
131
|
+
console.log(JSON.stringify(roles.map((role) => _.omit(role, "organization")), null, 2));
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
const headers = [
|
|
135
|
+
"Role ID",
|
|
136
|
+
"Name",
|
|
137
|
+
"Description",
|
|
138
|
+
"Organization Name",
|
|
139
|
+
...(flags.wide ? ["Organization ID"] : []),
|
|
140
|
+
];
|
|
141
|
+
let listTable = this.ui.table().head(headers);
|
|
142
|
+
for (const role of roles) {
|
|
143
|
+
const row = [
|
|
144
|
+
role.id,
|
|
145
|
+
role.name,
|
|
146
|
+
role.description ?? "",
|
|
147
|
+
role.organization.organization.displayName === ""
|
|
148
|
+
? role.organization.organization.org
|
|
149
|
+
: role.organization.organization.displayName,
|
|
150
|
+
...(flags.wide ? [role.organization.organization.id] : []),
|
|
151
|
+
];
|
|
152
|
+
listTable = listTable.row(row);
|
|
153
|
+
}
|
|
154
|
+
listTable.render();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { run } from '@oclif/core';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { run } from '@oclif/core';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { QueryGraphQL } from "@flowcore/cli-plugin-core";
|
|
2
|
+
import { type FetchMyOrganizationsQueryResponse } from "../utils/queries/fetch-organization-by-tenant.gql.js";
|
|
3
|
+
export declare class OrganizationService {
|
|
4
|
+
private readonly client;
|
|
5
|
+
constructor(client: QueryGraphQL);
|
|
6
|
+
filterOrganizationsById(ids: string[]): Promise<{
|
|
7
|
+
linkType: string;
|
|
8
|
+
organization: {
|
|
9
|
+
displayName: string;
|
|
10
|
+
id: string;
|
|
11
|
+
org: string;
|
|
12
|
+
};
|
|
13
|
+
}[]>;
|
|
14
|
+
getMyOrganizations(): Promise<FetchMyOrganizationsQueryResponse>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FETCH_MY_ORGANIZATIONS_GQL_QUERY, } from "../utils/queries/fetch-organization-by-tenant.gql.js";
|
|
2
|
+
export class OrganizationService {
|
|
3
|
+
client;
|
|
4
|
+
constructor(client) {
|
|
5
|
+
this.client = client;
|
|
6
|
+
}
|
|
7
|
+
filterOrganizationsById(ids) {
|
|
8
|
+
return this.getMyOrganizations().then((organizations) => organizations.me.organizations.filter((organization) => ids.includes(organization.organization.id)));
|
|
9
|
+
}
|
|
10
|
+
async getMyOrganizations() {
|
|
11
|
+
return this.client.request(FETCH_MY_ORGANIZATIONS_GQL_QUERY);
|
|
12
|
+
}
|
|
13
|
+
}
|