@j-256/ccam 0.1.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/LICENSE +21 -0
- package/README.md +209 -0
- package/dist/auth/browser-login.d.ts +14 -0
- package/dist/auth/browser-login.js +72 -0
- package/dist/auth/manual-login.d.ts +10 -0
- package/dist/auth/manual-login.js +33 -0
- package/dist/auth/paths.d.ts +4 -0
- package/dist/auth/paths.js +15 -0
- package/dist/auth/profile-resolver.d.ts +26 -0
- package/dist/auth/profile-resolver.js +42 -0
- package/dist/auth/profile-store.d.ts +38 -0
- package/dist/auth/profile-store.js +125 -0
- package/dist/auth/prompt.d.ts +9 -0
- package/dist/auth/prompt.js +70 -0
- package/dist/bin.d.ts +3 -0
- package/dist/bin.js +4 -0
- package/dist/client-factory.d.ts +6 -0
- package/dist/client-factory.js +40 -0
- package/dist/commands/auth.d.ts +77 -0
- package/dist/commands/auth.js +387 -0
- package/dist/commands/client.d.ts +3 -0
- package/dist/commands/client.js +365 -0
- package/dist/commands/instance.d.ts +11 -0
- package/dist/commands/instance.js +128 -0
- package/dist/commands/org-config.d.ts +3 -0
- package/dist/commands/org-config.js +31 -0
- package/dist/commands/org.d.ts +11 -0
- package/dist/commands/org.js +234 -0
- package/dist/commands/permission.d.ts +3 -0
- package/dist/commands/permission.js +60 -0
- package/dist/commands/realm.d.ts +3 -0
- package/dist/commands/realm.js +58 -0
- package/dist/commands/role.d.ts +3 -0
- package/dist/commands/role.js +77 -0
- package/dist/commands/service-type.d.ts +3 -0
- package/dist/commands/service-type.js +57 -0
- package/dist/commands/user.d.ts +14 -0
- package/dist/commands/user.js +573 -0
- package/dist/error-handler.d.ts +2 -0
- package/dist/error-handler.js +28 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/output/csv.d.ts +3 -0
- package/dist/output/csv.js +57 -0
- package/dist/output/default-columns.d.ts +2 -0
- package/dist/output/default-columns.js +16 -0
- package/dist/output/detect.d.ts +4 -0
- package/dist/output/detect.js +6 -0
- package/dist/output/index.d.ts +15 -0
- package/dist/output/index.js +34 -0
- package/dist/output/json.d.ts +2 -0
- package/dist/output/json.js +10 -0
- package/dist/output/shared.d.ts +13 -0
- package/dist/output/shared.js +41 -0
- package/dist/output/table.d.ts +2 -0
- package/dist/output/table.js +72 -0
- package/dist/output/types.d.ts +2 -0
- package/dist/output/types.js +2 -0
- package/dist/output/yaml-fmt.d.ts +2 -0
- package/dist/output/yaml-fmt.js +11 -0
- package/dist/program.d.ts +3 -0
- package/dist/program.js +37 -0
- package/dist/shared.d.ts +46 -0
- package/dist/shared.js +96 -0
- package/dist/tui/App.d.ts +7 -0
- package/dist/tui/App.js +30 -0
- package/dist/tui/components/AuditTab.d.ts +8 -0
- package/dist/tui/components/AuditTab.js +80 -0
- package/dist/tui/components/FooterBar.d.ts +17 -0
- package/dist/tui/components/FooterBar.js +23 -0
- package/dist/tui/components/FullScreenLayout.d.ts +6 -0
- package/dist/tui/components/FullScreenLayout.js +11 -0
- package/dist/tui/components/HeaderBar.d.ts +5 -0
- package/dist/tui/components/HeaderBar.js +10 -0
- package/dist/tui/components/InfoTab.d.ts +8 -0
- package/dist/tui/components/InfoTab.js +70 -0
- package/dist/tui/components/ResourcePicker.d.ts +10 -0
- package/dist/tui/components/ResourcePicker.js +36 -0
- package/dist/tui/components/SubResourceTab.d.ts +7 -0
- package/dist/tui/components/SubResourceTab.js +193 -0
- package/dist/tui/components/TabBar.d.ts +11 -0
- package/dist/tui/components/TabBar.js +13 -0
- package/dist/tui/components/Table.d.ts +32 -0
- package/dist/tui/components/Table.js +175 -0
- package/dist/tui/context/client.d.ts +7 -0
- package/dist/tui/context/client.js +14 -0
- package/dist/tui/context/navigation.d.ts +14 -0
- package/dist/tui/context/navigation.js +25 -0
- package/dist/tui/context/terminal-size.d.ts +9 -0
- package/dist/tui/context/terminal-size.js +26 -0
- package/dist/tui/format.d.ts +20 -0
- package/dist/tui/format.js +57 -0
- package/dist/tui/hooks/use-audit-log.d.ts +12 -0
- package/dist/tui/hooks/use-audit-log.js +71 -0
- package/dist/tui/hooks/use-local-collection.d.ts +8 -0
- package/dist/tui/hooks/use-local-collection.js +30 -0
- package/dist/tui/hooks/use-paginated-resource.d.ts +23 -0
- package/dist/tui/hooks/use-paginated-resource.js +115 -0
- package/dist/tui/hooks/use-resource-detail.d.ts +7 -0
- package/dist/tui/hooks/use-resource-detail.js +30 -0
- package/dist/tui/hooks/use-scroll-window.d.ts +7 -0
- package/dist/tui/hooks/use-scroll-window.js +29 -0
- package/dist/tui/index.d.ts +2 -0
- package/dist/tui/index.js +22 -0
- package/dist/tui/navigation.d.ts +11 -0
- package/dist/tui/navigation.js +29 -0
- package/dist/tui/resource-configs/api-clients.d.ts +3 -0
- package/dist/tui/resource-configs/api-clients.js +118 -0
- package/dist/tui/resource-configs/index.d.ts +14 -0
- package/dist/tui/resource-configs/index.js +28 -0
- package/dist/tui/resource-configs/instances.d.ts +3 -0
- package/dist/tui/resource-configs/instances.js +24 -0
- package/dist/tui/resource-configs/org-configuration.d.ts +3 -0
- package/dist/tui/resource-configs/org-configuration.js +28 -0
- package/dist/tui/resource-configs/organizations.d.ts +3 -0
- package/dist/tui/resource-configs/organizations.js +104 -0
- package/dist/tui/resource-configs/permissions.d.ts +3 -0
- package/dist/tui/resource-configs/permissions.js +25 -0
- package/dist/tui/resource-configs/realms.d.ts +3 -0
- package/dist/tui/resource-configs/realms.js +36 -0
- package/dist/tui/resource-configs/roles.d.ts +3 -0
- package/dist/tui/resource-configs/roles.js +56 -0
- package/dist/tui/resource-configs/service-types.d.ts +3 -0
- package/dist/tui/resource-configs/service-types.js +24 -0
- package/dist/tui/resource-configs/users.d.ts +3 -0
- package/dist/tui/resource-configs/users.js +126 -0
- package/dist/tui/types.d.ts +99 -0
- package/dist/tui/types.js +23 -0
- package/dist/tui/views/ResourceDetailView.d.ts +7 -0
- package/dist/tui/views/ResourceDetailView.js +123 -0
- package/dist/tui/views/ResourceListView.d.ts +6 -0
- package/dist/tui/views/ResourceListView.js +140 -0
- package/dist/tui/views/ViewRouter.d.ts +2 -0
- package/dist/tui/views/ViewRouter.js +60 -0
- package/package.json +62 -0
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { CcamNotFoundError } from 'ccam-sdk';
|
|
2
|
+
import { addGlobalOptions, parseExpand, resolveGlobalOptions, writePageInfoIfTable } from '../shared.js';
|
|
3
|
+
import { resolveProfile } from '../auth/profile-resolver.js';
|
|
4
|
+
import { createClientFromResolved } from '../client-factory.js';
|
|
5
|
+
import { handleError } from '../error-handler.js';
|
|
6
|
+
import { renderOutput, resolveFormat } from '../output/index.js';
|
|
7
|
+
import { DEFAULT_COLUMNS } from '../output/default-columns.js';
|
|
8
|
+
const ORG_REALMS_EXPAND = ['instance'];
|
|
9
|
+
export function selectOrgFinder(filters) {
|
|
10
|
+
if (filters.sfAccountId) {
|
|
11
|
+
return 'findBySfAccountId';
|
|
12
|
+
}
|
|
13
|
+
if (filters.name || filters.startsWith) {
|
|
14
|
+
return 'findByName';
|
|
15
|
+
}
|
|
16
|
+
return 'list';
|
|
17
|
+
}
|
|
18
|
+
async function resolveOrgId(client, idOrName) {
|
|
19
|
+
// Try direct get first (handles UUIDs and non-UUID IDs like "Demandware Inc.")
|
|
20
|
+
try {
|
|
21
|
+
const org = await client.organizations.get(idOrName);
|
|
22
|
+
return org.id;
|
|
23
|
+
}
|
|
24
|
+
catch (err) {
|
|
25
|
+
if (!(err instanceof CcamNotFoundError))
|
|
26
|
+
throw err;
|
|
27
|
+
}
|
|
28
|
+
// Fall back to name search
|
|
29
|
+
const searchResult = await client.organizations.search.findByName({
|
|
30
|
+
term: idOrName,
|
|
31
|
+
page: 0,
|
|
32
|
+
size: 1,
|
|
33
|
+
});
|
|
34
|
+
if (!searchResult.content || searchResult.content.length === 0) {
|
|
35
|
+
process.stderr.write(`Error: No organization found with ID or name "${idOrName}"\n`);
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
return searchResult.content[0].id;
|
|
39
|
+
}
|
|
40
|
+
async function listOrgs(options) {
|
|
41
|
+
try {
|
|
42
|
+
const resolved = resolveGlobalOptions(options);
|
|
43
|
+
const profileResolved = await resolveProfile({
|
|
44
|
+
flags: { profile: options.profile, host: resolved.host },
|
|
45
|
+
});
|
|
46
|
+
const client = await createClientFromResolved(profileResolved);
|
|
47
|
+
const filters = {
|
|
48
|
+
name: options.name,
|
|
49
|
+
startsWith: options.startsWith,
|
|
50
|
+
sfAccountId: options.sfAccountId,
|
|
51
|
+
};
|
|
52
|
+
const finder = selectOrgFinder(filters);
|
|
53
|
+
let result;
|
|
54
|
+
switch (finder) {
|
|
55
|
+
case 'list':
|
|
56
|
+
result = await client.organizations.list({
|
|
57
|
+
page: resolved.page,
|
|
58
|
+
size: resolved.size,
|
|
59
|
+
sort: resolved.sort,
|
|
60
|
+
});
|
|
61
|
+
break;
|
|
62
|
+
case 'findByName':
|
|
63
|
+
result = await client.organizations.search.findByName({
|
|
64
|
+
term: filters.name,
|
|
65
|
+
startsWith: filters.startsWith,
|
|
66
|
+
ignoreCase: options.ignoreCase,
|
|
67
|
+
page: resolved.page,
|
|
68
|
+
size: resolved.size,
|
|
69
|
+
});
|
|
70
|
+
break;
|
|
71
|
+
case 'findBySfAccountId':
|
|
72
|
+
result = await client.organizations.search.findBySfAccountId({
|
|
73
|
+
sfAccountId: filters.sfAccountId,
|
|
74
|
+
page: resolved.page,
|
|
75
|
+
size: resolved.size,
|
|
76
|
+
});
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
const format = resolveFormat(resolved.format, process.stdout.isTTY);
|
|
80
|
+
renderOutput(result.content, { format, fields: resolved.fields, defaultFields: DEFAULT_COLUMNS.org });
|
|
81
|
+
writePageInfoIfTable(format, result);
|
|
82
|
+
}
|
|
83
|
+
catch (err) {
|
|
84
|
+
handleError(err);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
async function getOrg(idOrName, options) {
|
|
88
|
+
try {
|
|
89
|
+
const resolved = resolveGlobalOptions(options);
|
|
90
|
+
const profileResolved = await resolveProfile({
|
|
91
|
+
flags: { profile: options.profile, host: resolved.host },
|
|
92
|
+
});
|
|
93
|
+
const client = await createClientFromResolved(profileResolved);
|
|
94
|
+
const orgId = await resolveOrgId(client, idOrName);
|
|
95
|
+
const result = await client.organizations.get(orgId);
|
|
96
|
+
const format = resolveFormat(resolved.format, process.stdout.isTTY);
|
|
97
|
+
renderOutput(result, { format, fields: resolved.fields, defaultFields: DEFAULT_COLUMNS.orgDetail });
|
|
98
|
+
}
|
|
99
|
+
catch (err) {
|
|
100
|
+
handleError(err);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
async function getOrgRealms(idOrName, options) {
|
|
104
|
+
try {
|
|
105
|
+
const resolved = resolveGlobalOptions(options);
|
|
106
|
+
const profileResolved = await resolveProfile({
|
|
107
|
+
flags: { profile: options.profile, host: resolved.host },
|
|
108
|
+
});
|
|
109
|
+
const client = await createClientFromResolved(profileResolved);
|
|
110
|
+
const orgId = await resolveOrgId(client, idOrName);
|
|
111
|
+
const expand = parseExpand(options.expand, ORG_REALMS_EXPAND);
|
|
112
|
+
const result = expand ? await client.organizations.realms(orgId, { expand }) : await client.organizations.realms(orgId);
|
|
113
|
+
const format = resolveFormat(resolved.format, process.stdout.isTTY);
|
|
114
|
+
renderOutput(result.content, { format, fields: resolved.fields, defaultFields: DEFAULT_COLUMNS.realm });
|
|
115
|
+
}
|
|
116
|
+
catch (err) {
|
|
117
|
+
handleError(err);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
async function getOrgInstances(idOrName, options) {
|
|
121
|
+
try {
|
|
122
|
+
const resolved = resolveGlobalOptions(options);
|
|
123
|
+
const profileResolved = await resolveProfile({
|
|
124
|
+
flags: { profile: options.profile, host: resolved.host },
|
|
125
|
+
});
|
|
126
|
+
const client = await createClientFromResolved(profileResolved);
|
|
127
|
+
const orgId = await resolveOrgId(client, idOrName);
|
|
128
|
+
const result = await client.organizations.instances(orgId);
|
|
129
|
+
const format = resolveFormat(resolved.format, process.stdout.isTTY);
|
|
130
|
+
renderOutput(result.content, { format, fields: resolved.fields, defaultFields: DEFAULT_COLUMNS.instance });
|
|
131
|
+
}
|
|
132
|
+
catch (err) {
|
|
133
|
+
handleError(err);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
async function auditOrg(idOrName, options) {
|
|
137
|
+
try {
|
|
138
|
+
const resolved = resolveGlobalOptions(options);
|
|
139
|
+
const profileResolved = await resolveProfile({
|
|
140
|
+
flags: { profile: options.profile, host: resolved.host },
|
|
141
|
+
});
|
|
142
|
+
const client = await createClientFromResolved(profileResolved);
|
|
143
|
+
const orgId = await resolveOrgId(client, idOrName);
|
|
144
|
+
const querySize = options.querySize !== undefined ? parseInt(options.querySize, 10) : undefined;
|
|
145
|
+
const result = await client.organizations.auditLogs(orgId, querySize !== undefined ? { querySize } : undefined);
|
|
146
|
+
const format = resolveFormat(resolved.format, process.stdout.isTTY);
|
|
147
|
+
renderOutput(result.content, { format, fields: resolved.fields, defaultFields: DEFAULT_COLUMNS.auditLog });
|
|
148
|
+
}
|
|
149
|
+
catch (err) {
|
|
150
|
+
handleError(err);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
async function updateOrg(id, options) {
|
|
154
|
+
try {
|
|
155
|
+
const resolved = resolveGlobalOptions(options);
|
|
156
|
+
const profileResolved = await resolveProfile({
|
|
157
|
+
flags: { profile: options.profile, host: resolved.host },
|
|
158
|
+
});
|
|
159
|
+
const client = await createClientFromResolved(profileResolved);
|
|
160
|
+
const data = {};
|
|
161
|
+
if (options.name !== undefined)
|
|
162
|
+
data.name = options.name;
|
|
163
|
+
if (options.contactUsers)
|
|
164
|
+
data.contactUsers = options.contactUsers.split(',');
|
|
165
|
+
if (options.emailDomains)
|
|
166
|
+
data.emailDomains = options.emailDomains.split(',');
|
|
167
|
+
if (options.passwordMinEntropy)
|
|
168
|
+
data.passwordMinEntropy = parseInt(options.passwordMinEntropy, 10);
|
|
169
|
+
if (options.type)
|
|
170
|
+
data.type = options.type;
|
|
171
|
+
const result = await client.organizations.update(id, data);
|
|
172
|
+
const format = resolveFormat(resolved.format, process.stdout.isTTY);
|
|
173
|
+
renderOutput(result, { format, fields: resolved.fields });
|
|
174
|
+
}
|
|
175
|
+
catch (err) {
|
|
176
|
+
handleError(err);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
export function registerOrgCommands(program) {
|
|
180
|
+
const org = program
|
|
181
|
+
.command('org')
|
|
182
|
+
.description('Manage organizations');
|
|
183
|
+
// org list
|
|
184
|
+
const list = org
|
|
185
|
+
.command('list')
|
|
186
|
+
.description('List organizations with optional filters');
|
|
187
|
+
addGlobalOptions(list)
|
|
188
|
+
.option('--name <name>', 'Search organizations by name (exact match)')
|
|
189
|
+
.option('--starts-with <prefix>', 'Search organizations by name prefix')
|
|
190
|
+
.option('--sf-account-id <id>', 'Find organization by Salesforce Account ID')
|
|
191
|
+
.option('--ignore-case', 'Case-insensitive name search (use with --name or --starts-with)')
|
|
192
|
+
.action(listOrgs);
|
|
193
|
+
// org get
|
|
194
|
+
const get = org
|
|
195
|
+
.command('get')
|
|
196
|
+
.argument('<idOrName>', 'Organization ID (UUID) or name')
|
|
197
|
+
.description('Get a specific organization');
|
|
198
|
+
addGlobalOptions(get).action(getOrg);
|
|
199
|
+
// org realms
|
|
200
|
+
const realms = org
|
|
201
|
+
.command('realms')
|
|
202
|
+
.argument('<idOrName>', 'Organization ID (UUID) or name')
|
|
203
|
+
.description('List realms belonging to an organization');
|
|
204
|
+
addGlobalOptions(realms)
|
|
205
|
+
.option('--expand <fields>', 'Expand related resources (instance)')
|
|
206
|
+
.action(getOrgRealms);
|
|
207
|
+
// org instances
|
|
208
|
+
const instances = org
|
|
209
|
+
.command('instances')
|
|
210
|
+
.argument('<idOrName>', 'Organization ID (UUID) or name')
|
|
211
|
+
.description('List instances belonging to an organization');
|
|
212
|
+
addGlobalOptions(instances).action(getOrgInstances);
|
|
213
|
+
// org audit
|
|
214
|
+
const audit = org
|
|
215
|
+
.command('audit')
|
|
216
|
+
.argument('<idOrName>', 'Organization ID (UUID) or name')
|
|
217
|
+
.description('Get audit log for an organization');
|
|
218
|
+
addGlobalOptions(audit)
|
|
219
|
+
.option('--query-size <n>', 'Limit audit log query window size')
|
|
220
|
+
.action(auditOrg);
|
|
221
|
+
// org update
|
|
222
|
+
const update = org
|
|
223
|
+
.command('update')
|
|
224
|
+
.argument('<id>', 'Organization ID')
|
|
225
|
+
.description('Update an organization');
|
|
226
|
+
addGlobalOptions(update)
|
|
227
|
+
.option('--name <name>', 'Organization name')
|
|
228
|
+
.option('--contact-users <ids>', 'Comma-separated contact user IDs')
|
|
229
|
+
.option('--email-domains <domains>', 'Comma-separated email domains')
|
|
230
|
+
.option('--password-min-entropy <n>', 'Minimum password entropy')
|
|
231
|
+
.option('--type <type>', 'Organization type')
|
|
232
|
+
.action(updateOrg);
|
|
233
|
+
}
|
|
234
|
+
//# sourceMappingURL=org.js.map
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { addGlobalOptions, resolveGlobalOptions, writePageInfoIfTable } from '../shared.js';
|
|
2
|
+
import { resolveProfile } from '../auth/profile-resolver.js';
|
|
3
|
+
import { createClientFromResolved } from '../client-factory.js';
|
|
4
|
+
import { handleError } from '../error-handler.js';
|
|
5
|
+
import { renderOutput, resolveFormat } from '../output/index.js';
|
|
6
|
+
import { DEFAULT_COLUMNS } from '../output/default-columns.js';
|
|
7
|
+
async function getPermission(name, options) {
|
|
8
|
+
try {
|
|
9
|
+
const resolved = resolveGlobalOptions(options);
|
|
10
|
+
const profileResolved = await resolveProfile({
|
|
11
|
+
flags: { profile: options.profile, host: resolved.host },
|
|
12
|
+
});
|
|
13
|
+
const client = await createClientFromResolved(profileResolved);
|
|
14
|
+
const result = await client.permissions.get(name);
|
|
15
|
+
const format = resolveFormat(resolved.format, process.stdout.isTTY);
|
|
16
|
+
renderOutput(result, { format, fields: resolved.fields, defaultFields: DEFAULT_COLUMNS.permission });
|
|
17
|
+
}
|
|
18
|
+
catch (err) {
|
|
19
|
+
handleError(err);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
async function listPermissions(options) {
|
|
23
|
+
try {
|
|
24
|
+
const resolved = resolveGlobalOptions(options);
|
|
25
|
+
const profileResolved = await resolveProfile({
|
|
26
|
+
flags: { profile: options.profile, host: resolved.host },
|
|
27
|
+
});
|
|
28
|
+
const client = await createClientFromResolved(profileResolved);
|
|
29
|
+
const result = await client.permissions.list({
|
|
30
|
+
page: resolved.page,
|
|
31
|
+
size: resolved.size,
|
|
32
|
+
...(options.admin !== undefined ? { adminPermission: options.admin } : {}),
|
|
33
|
+
});
|
|
34
|
+
const format = resolveFormat(resolved.format, process.stdout.isTTY);
|
|
35
|
+
renderOutput(result.content, { format, fields: resolved.fields, defaultFields: DEFAULT_COLUMNS.permission });
|
|
36
|
+
writePageInfoIfTable(format, result);
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
handleError(err);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export function registerPermissionCommands(program) {
|
|
43
|
+
const permission = program
|
|
44
|
+
.command('permission')
|
|
45
|
+
.description('Manage permissions');
|
|
46
|
+
// permission list
|
|
47
|
+
const list = permission
|
|
48
|
+
.command('list')
|
|
49
|
+
.description('List permissions');
|
|
50
|
+
addGlobalOptions(list)
|
|
51
|
+
.option('--admin', 'Filter to admin permissions only')
|
|
52
|
+
.action(listPermissions);
|
|
53
|
+
// permission get
|
|
54
|
+
const get = permission
|
|
55
|
+
.command('get')
|
|
56
|
+
.argument('<name>', 'Permission name (e.g. "READ_USER", "WRITE_ORGANIZATION")')
|
|
57
|
+
.description('Get a specific permission');
|
|
58
|
+
addGlobalOptions(get).action(getPermission);
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=permission.js.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { addGlobalOptions, resolveGlobalOptions, writePageInfoIfTable } from '../shared.js';
|
|
2
|
+
import { resolveProfile } from '../auth/profile-resolver.js';
|
|
3
|
+
import { createClientFromResolved } from '../client-factory.js';
|
|
4
|
+
import { handleError } from '../error-handler.js';
|
|
5
|
+
import { renderOutput, resolveFormat } from '../output/index.js';
|
|
6
|
+
import { DEFAULT_COLUMNS } from '../output/default-columns.js';
|
|
7
|
+
async function listRealms(options) {
|
|
8
|
+
try {
|
|
9
|
+
const resolved = resolveGlobalOptions(options);
|
|
10
|
+
const profileResolved = await resolveProfile({
|
|
11
|
+
flags: { profile: options.profile, host: resolved.host },
|
|
12
|
+
});
|
|
13
|
+
const client = await createClientFromResolved(profileResolved);
|
|
14
|
+
const result = await client.realms.list({
|
|
15
|
+
page: resolved.page,
|
|
16
|
+
size: resolved.size,
|
|
17
|
+
sort: resolved.sort,
|
|
18
|
+
});
|
|
19
|
+
const format = resolveFormat(resolved.format, process.stdout.isTTY);
|
|
20
|
+
renderOutput(result.content, { format, fields: resolved.fields, defaultFields: DEFAULT_COLUMNS.realm });
|
|
21
|
+
writePageInfoIfTable(format, result);
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
handleError(err);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
async function getRealm(id, options) {
|
|
28
|
+
try {
|
|
29
|
+
const resolved = resolveGlobalOptions(options);
|
|
30
|
+
const profileResolved = await resolveProfile({
|
|
31
|
+
flags: { profile: options.profile, host: resolved.host },
|
|
32
|
+
});
|
|
33
|
+
const client = await createClientFromResolved(profileResolved);
|
|
34
|
+
const result = await client.realms.get(id);
|
|
35
|
+
const format = resolveFormat(resolved.format, process.stdout.isTTY);
|
|
36
|
+
renderOutput(result, { format, fields: resolved.fields, defaultFields: DEFAULT_COLUMNS.realm });
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
handleError(err);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export function registerRealmCommands(program) {
|
|
43
|
+
const realm = program
|
|
44
|
+
.command('realm')
|
|
45
|
+
.description('Manage realms');
|
|
46
|
+
// realm list
|
|
47
|
+
const list = realm
|
|
48
|
+
.command('list')
|
|
49
|
+
.description('List realms');
|
|
50
|
+
addGlobalOptions(list).action(listRealms);
|
|
51
|
+
// realm get
|
|
52
|
+
const get = realm
|
|
53
|
+
.command('get')
|
|
54
|
+
.argument('<id>', 'Realm ID (4-character code)')
|
|
55
|
+
.description('Get a specific realm');
|
|
56
|
+
addGlobalOptions(get).action(getRealm);
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=realm.js.map
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { addGlobalOptions, parseExpand, resolveGlobalOptions, writePageInfoIfTable } from '../shared.js';
|
|
2
|
+
import { resolveProfile } from '../auth/profile-resolver.js';
|
|
3
|
+
import { createClientFromResolved } from '../client-factory.js';
|
|
4
|
+
import { handleError } from '../error-handler.js';
|
|
5
|
+
import { renderOutput, resolveFormat } from '../output/index.js';
|
|
6
|
+
import { DEFAULT_COLUMNS } from '../output/default-columns.js';
|
|
7
|
+
const ROLE_EXPAND = ['serviceType'];
|
|
8
|
+
async function listRoles(options) {
|
|
9
|
+
try {
|
|
10
|
+
const resolved = resolveGlobalOptions(options);
|
|
11
|
+
const profileResolved = await resolveProfile({
|
|
12
|
+
flags: { profile: options.profile, host: resolved.host },
|
|
13
|
+
});
|
|
14
|
+
const client = await createClientFromResolved(profileResolved);
|
|
15
|
+
const baseOpts = {
|
|
16
|
+
page: resolved.page,
|
|
17
|
+
size: resolved.size,
|
|
18
|
+
sort: resolved.sort,
|
|
19
|
+
};
|
|
20
|
+
const expand = parseExpand(options.expand, ROLE_EXPAND);
|
|
21
|
+
let result;
|
|
22
|
+
if (expand === 'serviceType') {
|
|
23
|
+
result = await client.roles.list({
|
|
24
|
+
...baseOpts,
|
|
25
|
+
expand,
|
|
26
|
+
...(options.targetType !== undefined ? { roleTargetType: options.targetType } : {}),
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
result = await client.roles.list(baseOpts);
|
|
31
|
+
}
|
|
32
|
+
const format = resolveFormat(resolved.format, process.stdout.isTTY);
|
|
33
|
+
renderOutput(result.content, { format, fields: resolved.fields, defaultFields: DEFAULT_COLUMNS.role });
|
|
34
|
+
writePageInfoIfTable(format, result);
|
|
35
|
+
}
|
|
36
|
+
catch (err) {
|
|
37
|
+
handleError(err);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
async function getRole(id, options) {
|
|
41
|
+
try {
|
|
42
|
+
const resolved = resolveGlobalOptions(options);
|
|
43
|
+
const profileResolved = await resolveProfile({
|
|
44
|
+
flags: { profile: options.profile, host: resolved.host },
|
|
45
|
+
});
|
|
46
|
+
const client = await createClientFromResolved(profileResolved);
|
|
47
|
+
const expand = parseExpand(options.expand, ROLE_EXPAND);
|
|
48
|
+
const result = expand ? await client.roles.get(id, { expand }) : await client.roles.get(id);
|
|
49
|
+
const format = resolveFormat(resolved.format, process.stdout.isTTY);
|
|
50
|
+
renderOutput(result, { format, fields: resolved.fields, defaultFields: DEFAULT_COLUMNS.roleDetail });
|
|
51
|
+
}
|
|
52
|
+
catch (err) {
|
|
53
|
+
handleError(err);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export function registerRoleCommands(program) {
|
|
57
|
+
const role = program
|
|
58
|
+
.command('role')
|
|
59
|
+
.description('Manage roles');
|
|
60
|
+
// role list
|
|
61
|
+
const list = role
|
|
62
|
+
.command('list')
|
|
63
|
+
.description('List roles');
|
|
64
|
+
addGlobalOptions(list)
|
|
65
|
+
.option('--expand <fields>', 'Expand related resources (serviceType)')
|
|
66
|
+
.option('--target-type <type>', 'Filter by role target type (User, ApiClient)')
|
|
67
|
+
.action(listRoles);
|
|
68
|
+
// role get
|
|
69
|
+
const get = role
|
|
70
|
+
.command('get')
|
|
71
|
+
.argument('<id>', 'Role ID')
|
|
72
|
+
.description('Get a specific role');
|
|
73
|
+
addGlobalOptions(get)
|
|
74
|
+
.option('--expand <fields>', 'Expand related resources (serviceType)')
|
|
75
|
+
.action(getRole);
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=role.js.map
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { addGlobalOptions, resolveGlobalOptions, writePageInfoIfTable } from '../shared.js';
|
|
2
|
+
import { resolveProfile } from '../auth/profile-resolver.js';
|
|
3
|
+
import { createClientFromResolved } from '../client-factory.js';
|
|
4
|
+
import { handleError } from '../error-handler.js';
|
|
5
|
+
import { renderOutput, resolveFormat } from '../output/index.js';
|
|
6
|
+
import { DEFAULT_COLUMNS } from '../output/default-columns.js';
|
|
7
|
+
async function getServiceType(id, options) {
|
|
8
|
+
try {
|
|
9
|
+
const resolved = resolveGlobalOptions(options);
|
|
10
|
+
const profileResolved = await resolveProfile({
|
|
11
|
+
flags: { profile: options.profile, host: resolved.host },
|
|
12
|
+
});
|
|
13
|
+
const client = await createClientFromResolved(profileResolved);
|
|
14
|
+
const result = await client.serviceTypes.get(id);
|
|
15
|
+
const format = resolveFormat(resolved.format, process.stdout.isTTY);
|
|
16
|
+
renderOutput(result, { format, fields: resolved.fields, defaultFields: DEFAULT_COLUMNS.serviceType });
|
|
17
|
+
}
|
|
18
|
+
catch (err) {
|
|
19
|
+
handleError(err);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
async function listServiceTypes(options) {
|
|
23
|
+
try {
|
|
24
|
+
const resolved = resolveGlobalOptions(options);
|
|
25
|
+
const profileResolved = await resolveProfile({
|
|
26
|
+
flags: { profile: options.profile, host: resolved.host },
|
|
27
|
+
});
|
|
28
|
+
const client = await createClientFromResolved(profileResolved);
|
|
29
|
+
const result = await client.serviceTypes.list({
|
|
30
|
+
page: resolved.page,
|
|
31
|
+
size: resolved.size,
|
|
32
|
+
});
|
|
33
|
+
const format = resolveFormat(resolved.format, process.stdout.isTTY);
|
|
34
|
+
renderOutput(result.content, { format, fields: resolved.fields, defaultFields: DEFAULT_COLUMNS.serviceType });
|
|
35
|
+
writePageInfoIfTable(format, result);
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
handleError(err);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export function registerServiceTypeCommands(program) {
|
|
42
|
+
const serviceType = program
|
|
43
|
+
.command('service-type')
|
|
44
|
+
.description('Manage service types');
|
|
45
|
+
// service-type list
|
|
46
|
+
const list = serviceType
|
|
47
|
+
.command('list')
|
|
48
|
+
.description('List service types');
|
|
49
|
+
addGlobalOptions(list).action(listServiceTypes);
|
|
50
|
+
// service-type get
|
|
51
|
+
const get = serviceType
|
|
52
|
+
.command('get')
|
|
53
|
+
.argument('<id>', 'Service type ID (e.g. "ECOM", "CDN")')
|
|
54
|
+
.description('Get a specific service type');
|
|
55
|
+
addGlobalOptions(get).action(getServiceType);
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=service-type.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
interface UserFilters {
|
|
3
|
+
login?: string;
|
|
4
|
+
org?: string;
|
|
5
|
+
role?: string;
|
|
6
|
+
orgRealmAccess?: string;
|
|
7
|
+
modifiedAfter?: string;
|
|
8
|
+
all?: boolean;
|
|
9
|
+
}
|
|
10
|
+
type UserFinder = 'list' | 'findByLogin' | 'findByOrg' | 'findAllByOrg' | 'findByRole' | 'findByOrgAndRole' | 'findByOrgRealmAccess';
|
|
11
|
+
export declare function selectUserFinder(filters: UserFilters): UserFinder;
|
|
12
|
+
export declare function registerUserCommands(program: Command): void;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=user.d.ts.map
|