opal-security 3.1.0 → 3.1.1-beta.65d1a96
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/README.md +18 -34
- package/lib/commands/request/get.d.ts +5 -1
- package/lib/commands/request/get.js +81 -5
- package/lib/commands/request/list.d.ts +0 -1
- package/lib/commands/request/list.js +1 -1
- package/lib/graphql/gql.d.ts +12 -2
- package/lib/graphql/gql.js +3 -1
- package/lib/graphql/graphql.d.ts +65 -0
- package/lib/graphql/graphql.js +375 -1
- package/lib/lib/requests.d.ts +1 -1
- package/lib/lib/requests.js +116 -42
- package/lib/utils/displays.js +4 -4
- package/oclif.manifest.json +82 -68
- package/package.json +1 -1
package/lib/graphql/graphql.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HealthStatus = exports.GroupUserSource = exports.GroupUserSortByField = exports.GroupType = exports.GroupResourceSource = exports.GroupBindingsSortByField = exports.GroupBindingSuggestionsSortByField = exports.GeneralSettingType = exports.FiltersMatchMode = exports.FactorType = exports.EventType = exports.EventSeverity = exports.ErrorNotificationSettingType = exports.EntityType = exports.ConnectionValidationStatus = exports.ConnectionValidationSeverity = exports.ConnectionType = exports.BundlesSortByField = exports.BundleItemsSortByField = exports.AuthType = exports.AuthSessionStatus = exports.AuthFlowType = exports.AssociatedItemsSortByField = exports.AssignmentsSortByField = exports.AppsSortByField = exports.AppType = exports.AppItemsSortByField = exports.AppCategory = exports.ApiAuthType = exports.ApiAccessLevel = exports.AldwinRole = exports.AccessType = exports.AccessRuleStatus = exports.AccessReviewUserWarningType = exports.AccessReviewType = exports.AccessReviewTab = exports.AccessReviewSummaryStatus = exports.AccessReviewStatus = exports.AccessReviewReviewerAssignmentPolicy = exports.AccessReviewItemsSortByField = exports.AccessReviewItemStatus = exports.AccessReviewItemOutcome = exports.AccessReviewGroupResourceVisibilityPolicy = exports.AccessReviewGroupItemKind = exports.AccessReviewEndUserView = exports.AccessReviewAssignedStatus = exports.AccessReviewAction = exports.AccessOption = exports.AccessChangeType = exports.AwsIdentityCenterImportSetting = void 0;
|
|
4
4
|
exports.TaskTrigger = exports.TagsSortByField = exports.TagFilterMatchMode = exports.SyncType = exports.SyncTaskStatus = exports.SubEventsSortByField = exports.StringFormatType = exports.SortDirection = exports.ServiceType = exports.SearchType = exports.RolePermissionTargetType = exports.RolePermission = exports.RoleAssignmentsSortByField = exports.RoleAssignmentSource = exports.RiskLevel = exports.ReviewerUserStatus = exports.ReviewerAction = exports.ReviewStageOperator = exports.ResourceUserSource = exports.ResourceUserSortByField = exports.ResourceType = exports.RequestsSortByField = exports.RequestType = exports.RequestTemplateCustomFieldType = exports.RequestStatus = exports.RequestMessageLevel = exports.RequestMessageCode = exports.RequestApprovalType = exports.RecommendationsSubscoreType = exports.RecommendationsMetricType = exports.RecommendationsFeedbackType = exports.RecommendationsEntityType = exports.PubsubPublishMessageType = exports.PubsubPublishMessageStatusCode = exports.PubsubPublishConnectionType = exports.ProvisionSource = exports.PropagationTaskType = exports.PropagationStatusCode = exports.OwnersSortByField = exports.OrganizationType = exports.OidcProviderType = exports.NotificationType = exports.MessageChannelType = exports.MfaProvider = exports.IntegrationType = exports.ImportSetting = exports.IdpConnectionUserAttributeUseAs = exports.IdpConnectionType = exports.IdentityCategory = exports.HrIdpStatus = void 0;
|
|
5
|
-
exports.PaginatedEntityDropdownDocument = exports.GetRequestableAppsQueryDocument = exports.CheckAuthSessionQueryDocument = exports.GetGroupDocument = exports.RequestDecisionLevel = exports.WebhookPubsubPublishConnectionAuthType = exports.WebhookPubsubPublishConnectionApiKeyLocation = exports.Visibility = exports.VerifyFactorStatus = exports.UsersSortByField = exports.UserProductRole = exports.UserErrorType = exports.UsageAttributionType = exports.UiSource = exports.TimePeriod = exports.TimeBucket = exports.ThirdPartyProvider = void 0;
|
|
5
|
+
exports.ResourceAccessLevelsDocument = exports.PaginatedEntityDropdownDocument = exports.GetRequestableAppsQueryDocument = exports.CheckAuthSessionQueryDocument = exports.GetRequestDocument = exports.GetGroupDocument = exports.RequestDecisionLevel = exports.WebhookPubsubPublishConnectionAuthType = exports.WebhookPubsubPublishConnectionApiKeyLocation = exports.Visibility = exports.VerifyFactorStatus = exports.UsersSortByField = exports.UserProductRole = exports.UserErrorType = exports.UsageAttributionType = exports.UiSource = exports.TimePeriod = exports.TimeBucket = exports.ThirdPartyProvider = void 0;
|
|
6
6
|
var AwsIdentityCenterImportSetting;
|
|
7
7
|
(function (AwsIdentityCenterImportSetting) {
|
|
8
8
|
AwsIdentityCenterImportSetting["All"] = "ALL";
|
|
@@ -1657,6 +1657,229 @@ exports.GetGroupDocument = {
|
|
|
1657
1657
|
},
|
|
1658
1658
|
],
|
|
1659
1659
|
};
|
|
1660
|
+
exports.GetRequestDocument = {
|
|
1661
|
+
kind: "Document",
|
|
1662
|
+
definitions: [
|
|
1663
|
+
{
|
|
1664
|
+
kind: "OperationDefinition",
|
|
1665
|
+
operation: "query",
|
|
1666
|
+
name: { kind: "Name", value: "GetRequest" },
|
|
1667
|
+
variableDefinitions: [
|
|
1668
|
+
{
|
|
1669
|
+
kind: "VariableDefinition",
|
|
1670
|
+
variable: { kind: "Variable", name: { kind: "Name", value: "id" } },
|
|
1671
|
+
type: {
|
|
1672
|
+
kind: "NonNullType",
|
|
1673
|
+
type: {
|
|
1674
|
+
kind: "NamedType",
|
|
1675
|
+
name: { kind: "Name", value: "RequestId" },
|
|
1676
|
+
},
|
|
1677
|
+
},
|
|
1678
|
+
},
|
|
1679
|
+
],
|
|
1680
|
+
selectionSet: {
|
|
1681
|
+
kind: "SelectionSet",
|
|
1682
|
+
selections: [
|
|
1683
|
+
{
|
|
1684
|
+
kind: "Field",
|
|
1685
|
+
name: { kind: "Name", value: "request" },
|
|
1686
|
+
arguments: [
|
|
1687
|
+
{
|
|
1688
|
+
kind: "Argument",
|
|
1689
|
+
name: { kind: "Name", value: "input" },
|
|
1690
|
+
value: {
|
|
1691
|
+
kind: "ObjectValue",
|
|
1692
|
+
fields: [
|
|
1693
|
+
{
|
|
1694
|
+
kind: "ObjectField",
|
|
1695
|
+
name: { kind: "Name", value: "id" },
|
|
1696
|
+
value: {
|
|
1697
|
+
kind: "Variable",
|
|
1698
|
+
name: { kind: "Name", value: "id" },
|
|
1699
|
+
},
|
|
1700
|
+
},
|
|
1701
|
+
],
|
|
1702
|
+
},
|
|
1703
|
+
},
|
|
1704
|
+
],
|
|
1705
|
+
selectionSet: {
|
|
1706
|
+
kind: "SelectionSet",
|
|
1707
|
+
selections: [
|
|
1708
|
+
{ kind: "Field", name: { kind: "Name", value: "__typename" } },
|
|
1709
|
+
{
|
|
1710
|
+
kind: "InlineFragment",
|
|
1711
|
+
typeCondition: {
|
|
1712
|
+
kind: "NamedType",
|
|
1713
|
+
name: { kind: "Name", value: "RequestResult" },
|
|
1714
|
+
},
|
|
1715
|
+
selectionSet: {
|
|
1716
|
+
kind: "SelectionSet",
|
|
1717
|
+
selections: [
|
|
1718
|
+
{
|
|
1719
|
+
kind: "Field",
|
|
1720
|
+
name: { kind: "Name", value: "request" },
|
|
1721
|
+
selectionSet: {
|
|
1722
|
+
kind: "SelectionSet",
|
|
1723
|
+
selections: [
|
|
1724
|
+
{
|
|
1725
|
+
kind: "Field",
|
|
1726
|
+
name: { kind: "Name", value: "id" },
|
|
1727
|
+
},
|
|
1728
|
+
{
|
|
1729
|
+
kind: "Field",
|
|
1730
|
+
name: { kind: "Name", value: "status" },
|
|
1731
|
+
},
|
|
1732
|
+
{
|
|
1733
|
+
kind: "Field",
|
|
1734
|
+
name: {
|
|
1735
|
+
kind: "Name",
|
|
1736
|
+
value: "requestedResources",
|
|
1737
|
+
},
|
|
1738
|
+
selectionSet: {
|
|
1739
|
+
kind: "SelectionSet",
|
|
1740
|
+
selections: [
|
|
1741
|
+
{
|
|
1742
|
+
kind: "Field",
|
|
1743
|
+
name: { kind: "Name", value: "resource" },
|
|
1744
|
+
selectionSet: {
|
|
1745
|
+
kind: "SelectionSet",
|
|
1746
|
+
selections: [
|
|
1747
|
+
{
|
|
1748
|
+
kind: "Field",
|
|
1749
|
+
name: {
|
|
1750
|
+
kind: "Name",
|
|
1751
|
+
value: "displayName",
|
|
1752
|
+
},
|
|
1753
|
+
},
|
|
1754
|
+
{
|
|
1755
|
+
kind: "Field",
|
|
1756
|
+
name: { kind: "Name", value: "id" },
|
|
1757
|
+
},
|
|
1758
|
+
],
|
|
1759
|
+
},
|
|
1760
|
+
},
|
|
1761
|
+
{
|
|
1762
|
+
kind: "Field",
|
|
1763
|
+
name: {
|
|
1764
|
+
kind: "Name",
|
|
1765
|
+
value: "accessLevel",
|
|
1766
|
+
},
|
|
1767
|
+
selectionSet: {
|
|
1768
|
+
kind: "SelectionSet",
|
|
1769
|
+
selections: [
|
|
1770
|
+
{
|
|
1771
|
+
kind: "Field",
|
|
1772
|
+
name: {
|
|
1773
|
+
kind: "Name",
|
|
1774
|
+
value: "accessLevelName",
|
|
1775
|
+
},
|
|
1776
|
+
},
|
|
1777
|
+
{
|
|
1778
|
+
kind: "Field",
|
|
1779
|
+
name: {
|
|
1780
|
+
kind: "Name",
|
|
1781
|
+
value: "accessLevelRemoteId",
|
|
1782
|
+
},
|
|
1783
|
+
},
|
|
1784
|
+
],
|
|
1785
|
+
},
|
|
1786
|
+
},
|
|
1787
|
+
],
|
|
1788
|
+
},
|
|
1789
|
+
},
|
|
1790
|
+
{
|
|
1791
|
+
kind: "Field",
|
|
1792
|
+
name: {
|
|
1793
|
+
kind: "Name",
|
|
1794
|
+
value: "durationInMinutes",
|
|
1795
|
+
},
|
|
1796
|
+
},
|
|
1797
|
+
{
|
|
1798
|
+
kind: "Field",
|
|
1799
|
+
name: { kind: "Name", value: "requestedGroups" },
|
|
1800
|
+
selectionSet: {
|
|
1801
|
+
kind: "SelectionSet",
|
|
1802
|
+
selections: [
|
|
1803
|
+
{
|
|
1804
|
+
kind: "Field",
|
|
1805
|
+
name: { kind: "Name", value: "group" },
|
|
1806
|
+
selectionSet: {
|
|
1807
|
+
kind: "SelectionSet",
|
|
1808
|
+
selections: [
|
|
1809
|
+
{
|
|
1810
|
+
kind: "Field",
|
|
1811
|
+
name: { kind: "Name", value: "id" },
|
|
1812
|
+
},
|
|
1813
|
+
{
|
|
1814
|
+
kind: "Field",
|
|
1815
|
+
name: { kind: "Name", value: "name" },
|
|
1816
|
+
},
|
|
1817
|
+
],
|
|
1818
|
+
},
|
|
1819
|
+
},
|
|
1820
|
+
{
|
|
1821
|
+
kind: "Field",
|
|
1822
|
+
name: {
|
|
1823
|
+
kind: "Name",
|
|
1824
|
+
value: "accessLevel",
|
|
1825
|
+
},
|
|
1826
|
+
selectionSet: {
|
|
1827
|
+
kind: "SelectionSet",
|
|
1828
|
+
selections: [
|
|
1829
|
+
{
|
|
1830
|
+
kind: "Field",
|
|
1831
|
+
name: {
|
|
1832
|
+
kind: "Name",
|
|
1833
|
+
value: "accessLevelName",
|
|
1834
|
+
},
|
|
1835
|
+
},
|
|
1836
|
+
{
|
|
1837
|
+
kind: "Field",
|
|
1838
|
+
name: {
|
|
1839
|
+
kind: "Name",
|
|
1840
|
+
value: "accessLevelRemoteId",
|
|
1841
|
+
},
|
|
1842
|
+
},
|
|
1843
|
+
],
|
|
1844
|
+
},
|
|
1845
|
+
},
|
|
1846
|
+
],
|
|
1847
|
+
},
|
|
1848
|
+
},
|
|
1849
|
+
{
|
|
1850
|
+
kind: "Field",
|
|
1851
|
+
name: { kind: "Name", value: "reason" },
|
|
1852
|
+
},
|
|
1853
|
+
],
|
|
1854
|
+
},
|
|
1855
|
+
},
|
|
1856
|
+
],
|
|
1857
|
+
},
|
|
1858
|
+
},
|
|
1859
|
+
{
|
|
1860
|
+
kind: "InlineFragment",
|
|
1861
|
+
typeCondition: {
|
|
1862
|
+
kind: "NamedType",
|
|
1863
|
+
name: { kind: "Name", value: "RequestNotFoundError" },
|
|
1864
|
+
},
|
|
1865
|
+
selectionSet: {
|
|
1866
|
+
kind: "SelectionSet",
|
|
1867
|
+
selections: [
|
|
1868
|
+
{
|
|
1869
|
+
kind: "Field",
|
|
1870
|
+
name: { kind: "Name", value: "message" },
|
|
1871
|
+
},
|
|
1872
|
+
],
|
|
1873
|
+
},
|
|
1874
|
+
},
|
|
1875
|
+
],
|
|
1876
|
+
},
|
|
1877
|
+
},
|
|
1878
|
+
],
|
|
1879
|
+
},
|
|
1880
|
+
},
|
|
1881
|
+
],
|
|
1882
|
+
};
|
|
1660
1883
|
exports.CheckAuthSessionQueryDocument = {
|
|
1661
1884
|
kind: "Document",
|
|
1662
1885
|
definitions: [
|
|
@@ -2026,6 +2249,157 @@ exports.PaginatedEntityDropdownDocument = {
|
|
|
2026
2249
|
],
|
|
2027
2250
|
},
|
|
2028
2251
|
},
|
|
2252
|
+
{
|
|
2253
|
+
kind: "InlineFragment",
|
|
2254
|
+
typeCondition: {
|
|
2255
|
+
kind: "NamedType",
|
|
2256
|
+
name: { kind: "Name", value: "AppNotFoundError" },
|
|
2257
|
+
},
|
|
2258
|
+
selectionSet: {
|
|
2259
|
+
kind: "SelectionSet",
|
|
2260
|
+
selections: [
|
|
2261
|
+
{
|
|
2262
|
+
kind: "Field",
|
|
2263
|
+
name: { kind: "Name", value: "message" },
|
|
2264
|
+
},
|
|
2265
|
+
],
|
|
2266
|
+
},
|
|
2267
|
+
},
|
|
2268
|
+
],
|
|
2269
|
+
},
|
|
2270
|
+
},
|
|
2271
|
+
],
|
|
2272
|
+
},
|
|
2273
|
+
},
|
|
2274
|
+
],
|
|
2275
|
+
};
|
|
2276
|
+
exports.ResourceAccessLevelsDocument = {
|
|
2277
|
+
kind: "Document",
|
|
2278
|
+
definitions: [
|
|
2279
|
+
{
|
|
2280
|
+
kind: "OperationDefinition",
|
|
2281
|
+
operation: "query",
|
|
2282
|
+
name: { kind: "Name", value: "ResourceAccessLevels" },
|
|
2283
|
+
variableDefinitions: [
|
|
2284
|
+
{
|
|
2285
|
+
kind: "VariableDefinition",
|
|
2286
|
+
variable: {
|
|
2287
|
+
kind: "Variable",
|
|
2288
|
+
name: { kind: "Name", value: "resourceId" },
|
|
2289
|
+
},
|
|
2290
|
+
type: {
|
|
2291
|
+
kind: "NonNullType",
|
|
2292
|
+
type: {
|
|
2293
|
+
kind: "NamedType",
|
|
2294
|
+
name: { kind: "Name", value: "ResourceId" },
|
|
2295
|
+
},
|
|
2296
|
+
},
|
|
2297
|
+
},
|
|
2298
|
+
],
|
|
2299
|
+
selectionSet: {
|
|
2300
|
+
kind: "SelectionSet",
|
|
2301
|
+
selections: [
|
|
2302
|
+
{
|
|
2303
|
+
kind: "Field",
|
|
2304
|
+
name: { kind: "Name", value: "accessLevels" },
|
|
2305
|
+
arguments: [
|
|
2306
|
+
{
|
|
2307
|
+
kind: "Argument",
|
|
2308
|
+
name: { kind: "Name", value: "input" },
|
|
2309
|
+
value: {
|
|
2310
|
+
kind: "ObjectValue",
|
|
2311
|
+
fields: [
|
|
2312
|
+
{
|
|
2313
|
+
kind: "ObjectField",
|
|
2314
|
+
name: { kind: "Name", value: "resourceId" },
|
|
2315
|
+
value: {
|
|
2316
|
+
kind: "Variable",
|
|
2317
|
+
name: { kind: "Name", value: "resourceId" },
|
|
2318
|
+
},
|
|
2319
|
+
},
|
|
2320
|
+
{
|
|
2321
|
+
kind: "ObjectField",
|
|
2322
|
+
name: { kind: "Name", value: "onlyMine" },
|
|
2323
|
+
value: { kind: "BooleanValue", value: false },
|
|
2324
|
+
},
|
|
2325
|
+
],
|
|
2326
|
+
},
|
|
2327
|
+
},
|
|
2328
|
+
],
|
|
2329
|
+
selectionSet: {
|
|
2330
|
+
kind: "SelectionSet",
|
|
2331
|
+
selections: [
|
|
2332
|
+
{ kind: "Field", name: { kind: "Name", value: "__typename" } },
|
|
2333
|
+
{
|
|
2334
|
+
kind: "InlineFragment",
|
|
2335
|
+
typeCondition: {
|
|
2336
|
+
kind: "NamedType",
|
|
2337
|
+
name: { kind: "Name", value: "ResourceAccessLevelsResult" },
|
|
2338
|
+
},
|
|
2339
|
+
selectionSet: {
|
|
2340
|
+
kind: "SelectionSet",
|
|
2341
|
+
selections: [
|
|
2342
|
+
{
|
|
2343
|
+
kind: "Field",
|
|
2344
|
+
name: { kind: "Name", value: "accessLevels" },
|
|
2345
|
+
selectionSet: {
|
|
2346
|
+
kind: "SelectionSet",
|
|
2347
|
+
selections: [
|
|
2348
|
+
{
|
|
2349
|
+
kind: "Field",
|
|
2350
|
+
name: { kind: "Name", value: "__typename" },
|
|
2351
|
+
},
|
|
2352
|
+
{
|
|
2353
|
+
kind: "InlineFragment",
|
|
2354
|
+
typeCondition: {
|
|
2355
|
+
kind: "NamedType",
|
|
2356
|
+
name: {
|
|
2357
|
+
kind: "Name",
|
|
2358
|
+
value: "ResourceAccessLevel",
|
|
2359
|
+
},
|
|
2360
|
+
},
|
|
2361
|
+
selectionSet: {
|
|
2362
|
+
kind: "SelectionSet",
|
|
2363
|
+
selections: [
|
|
2364
|
+
{
|
|
2365
|
+
kind: "Field",
|
|
2366
|
+
name: {
|
|
2367
|
+
kind: "Name",
|
|
2368
|
+
value: "accessLevelName",
|
|
2369
|
+
},
|
|
2370
|
+
},
|
|
2371
|
+
{
|
|
2372
|
+
kind: "Field",
|
|
2373
|
+
name: {
|
|
2374
|
+
kind: "Name",
|
|
2375
|
+
value: "accessLevelRemoteId",
|
|
2376
|
+
},
|
|
2377
|
+
},
|
|
2378
|
+
],
|
|
2379
|
+
},
|
|
2380
|
+
},
|
|
2381
|
+
],
|
|
2382
|
+
},
|
|
2383
|
+
},
|
|
2384
|
+
],
|
|
2385
|
+
},
|
|
2386
|
+
},
|
|
2387
|
+
{
|
|
2388
|
+
kind: "InlineFragment",
|
|
2389
|
+
typeCondition: {
|
|
2390
|
+
kind: "NamedType",
|
|
2391
|
+
name: { kind: "Name", value: "ResourceNotFoundError" },
|
|
2392
|
+
},
|
|
2393
|
+
selectionSet: {
|
|
2394
|
+
kind: "SelectionSet",
|
|
2395
|
+
selections: [
|
|
2396
|
+
{
|
|
2397
|
+
kind: "Field",
|
|
2398
|
+
name: { kind: "Name", value: "message" },
|
|
2399
|
+
},
|
|
2400
|
+
],
|
|
2401
|
+
},
|
|
2402
|
+
},
|
|
2029
2403
|
],
|
|
2030
2404
|
},
|
|
2031
2405
|
},
|
package/lib/lib/requests.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export interface RoleNode {
|
|
|
15
15
|
export type RequestMap = Map<string, AppNode>;
|
|
16
16
|
export declare function selectRequestableItems(cmd: Command, client: ApolloClient<NormalizedCacheObject>, requestMap: RequestMap): Promise<void>;
|
|
17
17
|
export declare function chooseAssets(cmd: Command, client: ApolloClient<NormalizedCacheObject>, appId: string, requestMap: RequestMap): Promise<void>;
|
|
18
|
-
export declare function chooseRoles(appId: string, assetId: string, requestMap: RequestMap): Promise<void>;
|
|
18
|
+
export declare function chooseRoles(cmd: Command, client: ApolloClient<NormalizedCacheObject>, appId: string, assetId: string, requestMap: RequestMap): Promise<void>;
|
|
19
19
|
export declare function doneSelectingAssets(): Promise<boolean>;
|
|
20
20
|
export declare function promptForReason(): Promise<any>;
|
|
21
21
|
export declare function promptForExpiration(): Promise<any>;
|
package/lib/lib/requests.js
CHANGED
|
@@ -11,6 +11,7 @@ const inquirer = require("inquirer");
|
|
|
11
11
|
const graphql_1 = require("../graphql");
|
|
12
12
|
inquirer.registerPrompt("autocomplete", require("inquirer-autocomplete-prompt"));
|
|
13
13
|
// Queries and Mutations
|
|
14
|
+
// TODO: add pagination ability from CLI. (Load more...) option
|
|
14
15
|
const GET_REQUESTABLE_APPS_QUERY = (0, graphql_1.graphql)(`
|
|
15
16
|
query GetRequestableAppsQuery($searchQuery: String) {
|
|
16
17
|
appsV2(
|
|
@@ -40,39 +41,6 @@ const GET_REQUESTABLE_APPS_QUERY = (0, graphql_1.graphql)(`
|
|
|
40
41
|
}
|
|
41
42
|
}
|
|
42
43
|
`);
|
|
43
|
-
const GET_ASSETS_QUERY = (0, graphql_1.graphql)(`
|
|
44
|
-
query PaginatedEntityDropdown(
|
|
45
|
-
$id: UUID!
|
|
46
|
-
$searchQuery: String
|
|
47
|
-
) {
|
|
48
|
-
app(id: $id) {
|
|
49
|
-
__typename
|
|
50
|
-
... on App {
|
|
51
|
-
id
|
|
52
|
-
items(
|
|
53
|
-
input: {
|
|
54
|
-
access: REQUESTABLE
|
|
55
|
-
searchQuery: $searchQuery
|
|
56
|
-
includeOnlyRequestable: true
|
|
57
|
-
}
|
|
58
|
-
) {
|
|
59
|
-
items {
|
|
60
|
-
key
|
|
61
|
-
resource {
|
|
62
|
-
id
|
|
63
|
-
name
|
|
64
|
-
}
|
|
65
|
-
group {
|
|
66
|
-
id
|
|
67
|
-
name
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
cursor
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
`);
|
|
76
44
|
async function queryRequestableApps(cmd, client, input) {
|
|
77
45
|
var _a, _b;
|
|
78
46
|
try {
|
|
@@ -107,8 +75,44 @@ async function queryRequestableApps(cmd, client, input) {
|
|
|
107
75
|
}
|
|
108
76
|
}
|
|
109
77
|
}
|
|
78
|
+
const GET_ASSETS_QUERY = (0, graphql_1.graphql)(`
|
|
79
|
+
query PaginatedEntityDropdown(
|
|
80
|
+
$id: UUID!
|
|
81
|
+
$searchQuery: String
|
|
82
|
+
) {
|
|
83
|
+
app(id: $id) {
|
|
84
|
+
__typename
|
|
85
|
+
... on App {
|
|
86
|
+
id
|
|
87
|
+
items(
|
|
88
|
+
input: {
|
|
89
|
+
access: REQUESTABLE
|
|
90
|
+
searchQuery: $searchQuery
|
|
91
|
+
includeOnlyRequestable: true
|
|
92
|
+
}
|
|
93
|
+
) {
|
|
94
|
+
items {
|
|
95
|
+
key
|
|
96
|
+
resource {
|
|
97
|
+
id
|
|
98
|
+
name
|
|
99
|
+
}
|
|
100
|
+
group {
|
|
101
|
+
id
|
|
102
|
+
name
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
cursor
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
... on AppNotFoundError {
|
|
109
|
+
message
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
`);
|
|
110
114
|
async function queryRequestableAssets(cmd, client, appId, input) {
|
|
111
|
-
var _a, _b, _c, _d;
|
|
115
|
+
var _a, _b, _c, _d, _e, _f;
|
|
112
116
|
try {
|
|
113
117
|
const resp = await client.query({
|
|
114
118
|
query: GET_ASSETS_QUERY,
|
|
@@ -137,10 +141,68 @@ async function queryRequestableAssets(cmd, client, appId, input) {
|
|
|
137
141
|
};
|
|
138
142
|
});
|
|
139
143
|
case "AppNotFoundError":
|
|
140
|
-
x = cmd.error(
|
|
144
|
+
x = cmd.error((_f = (_e = resp.data) === null || _e === void 0 ? void 0 : _e.app) === null || _f === void 0 ? void 0 : _f.message);
|
|
145
|
+
break;
|
|
146
|
+
default:
|
|
147
|
+
cmd.error(resp.error || "Unknown error occurred.");
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
if (error instanceof Error || typeof error === "string") {
|
|
152
|
+
cmd.error(error);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
const RESOURCE_ROLES_QUERY = (0, graphql_1.graphql)(`
|
|
157
|
+
query ResourceAccessLevels($resourceId: ResourceId!) {
|
|
158
|
+
accessLevels(input: {
|
|
159
|
+
resourceId: $resourceId,
|
|
160
|
+
onlyMine: false,
|
|
161
|
+
}) {
|
|
162
|
+
__typename
|
|
163
|
+
... on ResourceAccessLevelsResult {
|
|
164
|
+
accessLevels {
|
|
165
|
+
__typename
|
|
166
|
+
... on ResourceAccessLevel {
|
|
167
|
+
accessLevelName
|
|
168
|
+
accessLevelRemoteId
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
... on ResourceNotFoundError {
|
|
173
|
+
message
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
`);
|
|
178
|
+
async function queryResourceRoles(cmd, client, resourceId) {
|
|
179
|
+
var _a, _b, _c, _d, _e;
|
|
180
|
+
try {
|
|
181
|
+
const resp = await client.query({
|
|
182
|
+
query: RESOURCE_ROLES_QUERY,
|
|
183
|
+
variables: {
|
|
184
|
+
resourceId: resourceId,
|
|
185
|
+
},
|
|
186
|
+
fetchPolicy: "network-only", // to avoid caching
|
|
187
|
+
});
|
|
188
|
+
// no fall through doesn't consider process.exit();
|
|
189
|
+
let x;
|
|
190
|
+
switch (resp.data.accessLevels.__typename) {
|
|
191
|
+
case "ResourceAccessLevelsResult":
|
|
192
|
+
return (_c = (_b = (_a = resp.data) === null || _a === void 0 ? void 0 : _a.accessLevels) === null || _b === void 0 ? void 0 : _b.accessLevels) === null || _c === void 0 ? void 0 : _c.map((role) => {
|
|
193
|
+
return {
|
|
194
|
+
name: role.accessLevelName,
|
|
195
|
+
value: {
|
|
196
|
+
name: role.accessLevelName,
|
|
197
|
+
id: role.accessLevelRemoteId,
|
|
198
|
+
},
|
|
199
|
+
};
|
|
200
|
+
});
|
|
201
|
+
case "ResourceNotFoundError":
|
|
202
|
+
x = cmd.error((_e = (_d = resp.data) === null || _d === void 0 ? void 0 : _d.accessLevels) === null || _e === void 0 ? void 0 : _e.message);
|
|
141
203
|
break;
|
|
142
204
|
default:
|
|
143
|
-
cmd.error("Unknown error occurred.");
|
|
205
|
+
cmd.error(resp.error || "Unknown error occurred.");
|
|
144
206
|
}
|
|
145
207
|
}
|
|
146
208
|
catch (error) {
|
|
@@ -198,16 +260,28 @@ async function chooseAssets(cmd, client, appId, requestMap) {
|
|
|
198
260
|
roles: new Map(),
|
|
199
261
|
});
|
|
200
262
|
}
|
|
201
|
-
await chooseRoles(appId, asset.id, requestMap);
|
|
263
|
+
await chooseRoles(cmd, client, appId, asset.id, requestMap);
|
|
202
264
|
}
|
|
203
265
|
}
|
|
204
|
-
async function chooseRoles(appId, assetId, requestMap) {
|
|
205
|
-
var _a;
|
|
266
|
+
async function chooseRoles(cmd, client, appId, assetId, requestMap) {
|
|
267
|
+
var _a, _b;
|
|
268
|
+
const resourceRoles = (_a = (await queryResourceRoles(cmd, client, assetId))) !== null && _a !== void 0 ? _a : [];
|
|
269
|
+
if (resourceRoles !== undefined &&
|
|
270
|
+
(resourceRoles.length === 0 ||
|
|
271
|
+
(resourceRoles.length === 1 && resourceRoles[0].name === ""))) {
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
206
274
|
const { roles } = await inquirer.prompt({
|
|
207
275
|
name: "roles",
|
|
208
276
|
type: "checkbox",
|
|
209
277
|
message: `Select one or more roles for ${assetId}:`,
|
|
210
|
-
choices:
|
|
278
|
+
choices: resourceRoles,
|
|
279
|
+
validate: (answer) => {
|
|
280
|
+
if ((resourceRoles === null || resourceRoles === void 0 ? void 0 : resourceRoles.length) > 1 && answer.length < 1) {
|
|
281
|
+
return "You must select at least one role.";
|
|
282
|
+
}
|
|
283
|
+
return true;
|
|
284
|
+
},
|
|
211
285
|
});
|
|
212
286
|
const entry = requestMap.get(appId);
|
|
213
287
|
const assetEntry = entry === null || entry === void 0 ? void 0 : entry.assets.get(assetId);
|
|
@@ -215,8 +289,8 @@ async function chooseRoles(appId, assetId, requestMap) {
|
|
|
215
289
|
throw new Error(`App ${appId} or Asset ${assetId} not found in requestMap`);
|
|
216
290
|
}
|
|
217
291
|
for (const role of roles) {
|
|
218
|
-
(
|
|
219
|
-
roleName: role,
|
|
292
|
+
(_b = assetEntry.roles) === null || _b === void 0 ? void 0 : _b.set(role.id, {
|
|
293
|
+
roleName: role.name,
|
|
220
294
|
});
|
|
221
295
|
}
|
|
222
296
|
}
|
package/lib/utils/displays.js
CHANGED
|
@@ -32,18 +32,18 @@ function treeifyRequestMap(requestMap) {
|
|
|
32
32
|
const requestTree = {};
|
|
33
33
|
// Create a tree structure from the requestMap
|
|
34
34
|
// Iterate over apps
|
|
35
|
-
for (const
|
|
35
|
+
for (const appNode of requestMap.values()) {
|
|
36
36
|
const appKey = `🔧${appNode.appName}`;
|
|
37
37
|
requestTree[appKey] = {}; // Initialize the app key
|
|
38
38
|
// Iterate over assets
|
|
39
|
-
for (const
|
|
39
|
+
for (const assetNode of appNode.assets.values()) {
|
|
40
40
|
const assetKey = `📦${assetNode.assetName}`;
|
|
41
41
|
if (assetNode.roles !== undefined) {
|
|
42
42
|
// If no roles were previously selected
|
|
43
43
|
requestTree[appKey][assetKey] = {}; // Initialize the asset key
|
|
44
44
|
// Iterate over roles
|
|
45
|
-
for (const
|
|
46
|
-
requestTree[appKey][assetKey][roleName] = null; // Initialize the role key
|
|
45
|
+
for (const roleNode of assetNode.roles.values()) {
|
|
46
|
+
requestTree[appKey][assetKey][roleNode.roleName] = null; // Initialize the role key
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
else {
|