opal-security 3.2.1 → 3.2.3
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 +28 -25
- package/lib/commands/login.js +18 -11
- package/lib/commands/request/create.d.ts +2 -0
- package/lib/commands/request/create.js +41 -20
- package/lib/commands/request/get.js +7 -58
- package/lib/commands/request/list.js +3 -60
- package/lib/graphql/gql.d.ts +35 -15
- package/lib/graphql/gql.js +9 -5
- package/lib/graphql/graphql.d.ts +1138 -383
- package/lib/graphql/graphql.js +1780 -1104
- package/lib/handler.d.ts +6 -6
- package/lib/handler.js +1 -1
- package/lib/labels.d.ts +3 -0
- package/lib/labels.js +40 -0
- package/lib/lib/apollo.d.ts +3 -3
- package/lib/lib/apollo.js +24 -47
- package/lib/lib/request/api/index.d.ts +6 -0
- package/lib/lib/request/api/index.js +20 -0
- package/lib/lib/request/api/mutations/create-request.d.ts +8 -0
- package/lib/lib/request/api/mutations/create-request.js +159 -0
- package/lib/lib/request/api/queries/apps.d.ts +4 -0
- package/lib/lib/request/api/queries/apps.js +73 -0
- package/lib/lib/request/api/queries/assets.d.ts +6 -0
- package/lib/lib/request/api/queries/assets.js +136 -0
- package/lib/lib/request/api/queries/request-defaults.d.ts +5 -0
- package/lib/lib/request/api/queries/request-defaults.js +52 -0
- package/lib/lib/request/api/queries/requests.d.ts +4 -0
- package/lib/lib/request/api/queries/requests.js +163 -0
- package/lib/lib/request/api/queries/roles.d.ts +5 -0
- package/lib/lib/request/api/queries/roles.js +239 -0
- package/lib/{utils → lib/request}/displays.d.ts +7 -5
- package/lib/{utils → lib/request}/displays.js +52 -30
- package/lib/lib/request/prompts/apps-prompt.d.ts +4 -0
- package/lib/lib/request/prompts/apps-prompt.js +35 -0
- package/lib/lib/request/prompts/asset-prompt.d.ts +5 -0
- package/lib/lib/request/prompts/asset-prompt.js +81 -0
- package/lib/lib/request/prompts/duration-prompt.d.ts +2 -0
- package/lib/lib/request/prompts/duration-prompt.js +125 -0
- package/lib/lib/request/prompts/index.d.ts +8 -0
- package/lib/lib/request/prompts/index.js +20 -0
- package/lib/lib/request/prompts/reason-prompt.d.ts +2 -0
- package/lib/lib/request/prompts/reason-prompt.js +20 -0
- package/lib/lib/request/prompts/role-prompt.d.ts +4 -0
- package/lib/lib/request/prompts/role-prompt.js +44 -0
- package/lib/lib/request/prompts/validate-prompt.d.ts +4 -0
- package/lib/lib/request/prompts/validate-prompt.js +29 -0
- package/lib/lib/request/request-utils.d.ts +14 -0
- package/lib/lib/request/request-utils.js +468 -0
- package/lib/lib/request/types.d.ts +55 -0
- package/lib/lib/request/types.js +15 -0
- package/lib/lib/resources.d.ts +1 -1
- package/lib/lib/sessions.d.ts +1 -1
- package/lib/lib/sessions.js +3 -2
- package/lib/lib/util.d.ts +1 -0
- package/lib/lib/util.js +16 -0
- package/lib/types.d.ts +19 -3
- package/lib/types.js +18 -2
- package/oclif.manifest.json +54 -38
- package/package.json +4 -3
- package/lib/lib/requests.d.ts +0 -54
- package/lib/lib/requests.js +0 -1160
- package/lib/utils/utils.d.ts +0 -1
- package/lib/utils/utils.js +0 -18
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.selectRequestableItems = selectRequestableItems;
|
|
4
|
+
const _1 = require(".");
|
|
5
|
+
const api_1 = require("../api");
|
|
6
|
+
const { AutoComplete } = require("enquirer");
|
|
7
|
+
async function selectRequestableItems(cmd, client, requestMap) {
|
|
8
|
+
const initial = (await (0, api_1.queryRequestableApps)(cmd, client, "")) || [];
|
|
9
|
+
const appPrompt = new AutoComplete({
|
|
10
|
+
name: "App",
|
|
11
|
+
message: "Select an app",
|
|
12
|
+
hint: _1.selectInstructions,
|
|
13
|
+
limit: 15,
|
|
14
|
+
choices: initial,
|
|
15
|
+
async suggest(input) {
|
|
16
|
+
const filteredChoices = await (0, api_1.queryRequestableApps)(cmd, client, input || "");
|
|
17
|
+
return filteredChoices || initial;
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
const App = await appPrompt.run();
|
|
21
|
+
// Set the app in the requestMap and call choose assets step
|
|
22
|
+
if (!(App.id in requestMap)) {
|
|
23
|
+
requestMap[App.id] = {
|
|
24
|
+
appId: App.id,
|
|
25
|
+
appType: App.type,
|
|
26
|
+
appName: App.name,
|
|
27
|
+
assets: {},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
if (App.type === "OKTA_APP" || App.type === "AZURE_ENTERPRISE_APP") {
|
|
31
|
+
await (0, _1.chooseOktaAzureRoles)(cmd, client, App, requestMap);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
await (0, _1.chooseAssets)(cmd, client, App.id, requestMap);
|
|
35
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ApolloClient } from "@apollo/client";
|
|
2
|
+
import type { Command } from "@oclif/core";
|
|
3
|
+
import { type EntityValue, type RequestMap } from "../types";
|
|
4
|
+
export declare function chooseOktaAzureRoles(cmd: Command, client: ApolloClient, app: EntityValue, requestMap: RequestMap): Promise<void>;
|
|
5
|
+
export declare function chooseAssets(cmd: Command, client: ApolloClient, appId: string, requestMap: RequestMap): Promise<void>;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.chooseOktaAzureRoles = chooseOktaAzureRoles;
|
|
4
|
+
exports.chooseAssets = chooseAssets;
|
|
5
|
+
const _1 = require(".");
|
|
6
|
+
const api_1 = require("../api");
|
|
7
|
+
const types_1 = require("../types");
|
|
8
|
+
const { AutoComplete } = require("enquirer");
|
|
9
|
+
async function chooseOktaAzureRoles(cmd, client, app, requestMap) {
|
|
10
|
+
const associatedItems = (await (0, api_1.queryAssociatedItems)(cmd, client, app.id, "")) || [];
|
|
11
|
+
const rolePrompt = new AutoComplete({
|
|
12
|
+
name: "Roles",
|
|
13
|
+
message: `Select a role for ${app.name}:`,
|
|
14
|
+
hint: _1.multiSelectInstructions,
|
|
15
|
+
limit: 15,
|
|
16
|
+
multiple: true,
|
|
17
|
+
async choices(input) {
|
|
18
|
+
if (!input)
|
|
19
|
+
return associatedItems;
|
|
20
|
+
const filteredChoices = await (0, api_1.queryAssociatedItems)(cmd, client, app.id, input);
|
|
21
|
+
return filteredChoices || associatedItems;
|
|
22
|
+
},
|
|
23
|
+
validate: (answer) => {
|
|
24
|
+
if (answer.length !== 1) {
|
|
25
|
+
return "Only one role is allowed to be requested for on Okta or Azure apps.";
|
|
26
|
+
}
|
|
27
|
+
return true;
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
const Roles = await rolePrompt.run();
|
|
31
|
+
const entry = requestMap[app.id];
|
|
32
|
+
for (const role of Roles) {
|
|
33
|
+
if (!(role.id in entry.assets)) {
|
|
34
|
+
entry.assets[role.id] = {
|
|
35
|
+
assetId: role.id,
|
|
36
|
+
assetName: role.name,
|
|
37
|
+
type: (0, types_1.entityTypeFromString)(role.type),
|
|
38
|
+
roles: {},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
async function chooseAssets(cmd, client, appId, requestMap) {
|
|
44
|
+
const initial = (await (0, api_1.queryRequestableAssets)(cmd, client, appId, "")) || [];
|
|
45
|
+
const assetPrompt = new AutoComplete({
|
|
46
|
+
name: "Assets",
|
|
47
|
+
message: "Select one or more assets:",
|
|
48
|
+
hint: _1.multiSelectInstructions,
|
|
49
|
+
limit: 15,
|
|
50
|
+
multiple: true,
|
|
51
|
+
async choices(input) {
|
|
52
|
+
if (!input) {
|
|
53
|
+
return initial;
|
|
54
|
+
}
|
|
55
|
+
const filteredChoices = await (0, api_1.queryRequestableAssets)(cmd, client, appId, input);
|
|
56
|
+
return filteredChoices || initial;
|
|
57
|
+
},
|
|
58
|
+
validate: (answer) => {
|
|
59
|
+
if (answer.length < 1) {
|
|
60
|
+
return "You must select at least one item.";
|
|
61
|
+
}
|
|
62
|
+
return true;
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
const Assets = await assetPrompt.run();
|
|
66
|
+
const entry = requestMap[appId];
|
|
67
|
+
for (const asset of Assets) {
|
|
68
|
+
if (entry === undefined) {
|
|
69
|
+
throw new Error(`Error formatting app ${appId} in request`);
|
|
70
|
+
}
|
|
71
|
+
if (!(asset.id in entry.assets)) {
|
|
72
|
+
entry.assets[asset.id] = {
|
|
73
|
+
assetId: asset.id,
|
|
74
|
+
assetName: asset.name,
|
|
75
|
+
type: asset.type,
|
|
76
|
+
roles: {},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
await (0, _1.chooseRoles)(cmd, client, appId, asset.id, requestMap);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.promptForDuration = promptForDuration;
|
|
4
|
+
const { AutoComplete, Form } = require("enquirer");
|
|
5
|
+
async function promptForDuration(metadata) {
|
|
6
|
+
var _a, _b;
|
|
7
|
+
const durations = ((_b = (_a = metadata.requestDefaults) === null || _a === void 0 ? void 0 : _a.durationOptions) === null || _b === void 0 ? void 0 : _b.map((option) => {
|
|
8
|
+
var _a;
|
|
9
|
+
let label = option.label;
|
|
10
|
+
if (option.durationInMinutes ===
|
|
11
|
+
((_a = metadata.requestDefaults) === null || _a === void 0 ? void 0 : _a.maxDurationInMinutes)) {
|
|
12
|
+
label = `${label} (MAX)`;
|
|
13
|
+
}
|
|
14
|
+
if (option.durationInMinutes ===
|
|
15
|
+
metadata.requestDefaults.recommendedDurationInMinutes) {
|
|
16
|
+
label = `${label} (RECOMMENDED)`;
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
message: label,
|
|
20
|
+
value: {
|
|
21
|
+
label: label,
|
|
22
|
+
durationInMinutes: option.durationInMinutes,
|
|
23
|
+
toString: () => label,
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
})) || [];
|
|
27
|
+
// Sort durations by minutes
|
|
28
|
+
durations.sort((a, b) => {
|
|
29
|
+
// Sort so that Permanent is always last
|
|
30
|
+
if (a.message === "Permanent")
|
|
31
|
+
return 1;
|
|
32
|
+
if (b.message === "Permanent")
|
|
33
|
+
return -1;
|
|
34
|
+
return a.value.durationInMinutes - b.value.durationInMinutes;
|
|
35
|
+
});
|
|
36
|
+
const expirationSelect = new AutoComplete({
|
|
37
|
+
name: "expiration",
|
|
38
|
+
message: "When should access expire?",
|
|
39
|
+
hint: "Type to filter",
|
|
40
|
+
type: "list",
|
|
41
|
+
choices: durations,
|
|
42
|
+
pageSize: 15,
|
|
43
|
+
});
|
|
44
|
+
let selected = await expirationSelect.run();
|
|
45
|
+
switch (selected.label) {
|
|
46
|
+
case "Custom": {
|
|
47
|
+
selected = await setCustomDuration(metadata);
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
case "Permanent": {
|
|
51
|
+
selected.durationInMinutes = undefined;
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
metadata.durationInMinutes = selected.durationInMinutes;
|
|
56
|
+
metadata.durationLabel = selected.label;
|
|
57
|
+
}
|
|
58
|
+
function getDurationNumbers(duration) {
|
|
59
|
+
const d = +duration.days || 0;
|
|
60
|
+
const h = +duration.hours || 0;
|
|
61
|
+
const m = +duration.minutes || 0;
|
|
62
|
+
return { d, h, m };
|
|
63
|
+
}
|
|
64
|
+
function getDurationInMinutes(duration) {
|
|
65
|
+
const { d, h, m } = getDurationNumbers(duration);
|
|
66
|
+
const minutesInDay = 1440; // 24 hours * 60 minutes
|
|
67
|
+
const minutesInHour = 60;
|
|
68
|
+
return d * minutesInDay + h * minutesInHour + m;
|
|
69
|
+
}
|
|
70
|
+
function getDHMFromMinutes(minutes) {
|
|
71
|
+
const label = [];
|
|
72
|
+
const d = Math.floor(minutes / 1440);
|
|
73
|
+
if (d > 0) {
|
|
74
|
+
label.push(`${d}d`);
|
|
75
|
+
}
|
|
76
|
+
const remainingMinutes = minutes % 1440;
|
|
77
|
+
const h = Math.floor(remainingMinutes / 60);
|
|
78
|
+
if (h > 0) {
|
|
79
|
+
label.push(`${h}h`);
|
|
80
|
+
}
|
|
81
|
+
const m = remainingMinutes % 60;
|
|
82
|
+
if (m > 0) {
|
|
83
|
+
label.push(`${m}m`);
|
|
84
|
+
}
|
|
85
|
+
return label.join(" ");
|
|
86
|
+
}
|
|
87
|
+
async function setCustomDuration(metadata) {
|
|
88
|
+
const durationForm = new Form({
|
|
89
|
+
name: "user",
|
|
90
|
+
message: "Please set a custom access duration:",
|
|
91
|
+
choices: [
|
|
92
|
+
{ name: "days", message: "Days", initial: "0" },
|
|
93
|
+
{ name: "hours", message: "Hours", initial: "0" },
|
|
94
|
+
{ name: "minutes", message: "Minutes", initial: "0" },
|
|
95
|
+
],
|
|
96
|
+
validate: (answer) => {
|
|
97
|
+
var _a, _b, _c;
|
|
98
|
+
const { d, h, m } = getDurationNumbers(answer);
|
|
99
|
+
if (m % 1 !== 0) {
|
|
100
|
+
return "Fractional minutes not supported.";
|
|
101
|
+
}
|
|
102
|
+
const durationInMinutes = getDurationInMinutes(answer);
|
|
103
|
+
if (d < 0 || h < 0 || m < 0 || d + h + m === 0 || (h > 23 && m > 59)) {
|
|
104
|
+
return "Please enter a valid duration.";
|
|
105
|
+
}
|
|
106
|
+
if (((_a = metadata.requestDefaults) === null || _a === void 0 ? void 0 : _a.maxDurationInMinutes) &&
|
|
107
|
+
durationInMinutes > ((_b = metadata.requestDefaults) === null || _b === void 0 ? void 0 : _b.maxDurationInMinutes)) {
|
|
108
|
+
const maxDHM = getDHMFromMinutes((_c = metadata.requestDefaults) === null || _c === void 0 ? void 0 : _c.maxDurationInMinutes);
|
|
109
|
+
return `The max duration for the selected assets is ${maxDHM}.`;
|
|
110
|
+
}
|
|
111
|
+
return true;
|
|
112
|
+
},
|
|
113
|
+
return: (answer) => {
|
|
114
|
+
return getDurationInMinutes(answer);
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
const durationResult = await durationForm.run();
|
|
118
|
+
const { d, h, m } = getDurationNumbers(durationResult);
|
|
119
|
+
const durationInMinutes = getDurationInMinutes(durationResult);
|
|
120
|
+
const durationLabel = getDHMFromMinutes(durationInMinutes);
|
|
121
|
+
return {
|
|
122
|
+
durationInMinutes: durationInMinutes,
|
|
123
|
+
label: durationLabel,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { selectRequestableItems } from "./apps-prompt";
|
|
2
|
+
export { chooseOktaAzureRoles, chooseAssets } from "./asset-prompt";
|
|
3
|
+
export { chooseRoles } from "./role-prompt";
|
|
4
|
+
export { promptForReason } from "./reason-prompt";
|
|
5
|
+
export { promptForDuration } from "./duration-prompt";
|
|
6
|
+
export { doneSelectingAssets, promptRequestSubmission, } from "./validate-prompt";
|
|
7
|
+
export declare const selectInstructions: string;
|
|
8
|
+
export declare const multiSelectInstructions: string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.multiSelectInstructions = exports.selectInstructions = exports.promptRequestSubmission = exports.doneSelectingAssets = exports.promptForDuration = exports.promptForReason = exports.chooseRoles = exports.chooseAssets = exports.chooseOktaAzureRoles = exports.selectRequestableItems = void 0;
|
|
4
|
+
const chalk_1 = require("chalk");
|
|
5
|
+
var apps_prompt_1 = require("./apps-prompt");
|
|
6
|
+
Object.defineProperty(exports, "selectRequestableItems", { enumerable: true, get: function () { return apps_prompt_1.selectRequestableItems; } });
|
|
7
|
+
var asset_prompt_1 = require("./asset-prompt");
|
|
8
|
+
Object.defineProperty(exports, "chooseOktaAzureRoles", { enumerable: true, get: function () { return asset_prompt_1.chooseOktaAzureRoles; } });
|
|
9
|
+
Object.defineProperty(exports, "chooseAssets", { enumerable: true, get: function () { return asset_prompt_1.chooseAssets; } });
|
|
10
|
+
var role_prompt_1 = require("./role-prompt");
|
|
11
|
+
Object.defineProperty(exports, "chooseRoles", { enumerable: true, get: function () { return role_prompt_1.chooseRoles; } });
|
|
12
|
+
var reason_prompt_1 = require("./reason-prompt");
|
|
13
|
+
Object.defineProperty(exports, "promptForReason", { enumerable: true, get: function () { return reason_prompt_1.promptForReason; } });
|
|
14
|
+
var duration_prompt_1 = require("./duration-prompt");
|
|
15
|
+
Object.defineProperty(exports, "promptForDuration", { enumerable: true, get: function () { return duration_prompt_1.promptForDuration; } });
|
|
16
|
+
var validate_prompt_1 = require("./validate-prompt");
|
|
17
|
+
Object.defineProperty(exports, "doneSelectingAssets", { enumerable: true, get: function () { return validate_prompt_1.doneSelectingAssets; } });
|
|
18
|
+
Object.defineProperty(exports, "promptRequestSubmission", { enumerable: true, get: function () { return validate_prompt_1.promptRequestSubmission; } });
|
|
19
|
+
exports.selectInstructions = chalk_1.default.dim("[↑↓] Navigate · [Enter] Select · Type to filter");
|
|
20
|
+
exports.multiSelectInstructions = chalk_1.default.dim("[↑↓] Navigate · [Space] Select · [Enter] Confirm · Type to filter");
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.promptForReason = promptForReason;
|
|
4
|
+
const { prompt } = require("enquirer");
|
|
5
|
+
async function promptForReason(metadata) {
|
|
6
|
+
const { reason } = await prompt([
|
|
7
|
+
{
|
|
8
|
+
name: "reason",
|
|
9
|
+
message: "Why do you need access?",
|
|
10
|
+
type: "input",
|
|
11
|
+
validate: (answer) => {
|
|
12
|
+
if (!metadata.requestDefaults.reasonOptional && answer.length < 1) {
|
|
13
|
+
return "A reason for requesting these assets is required.";
|
|
14
|
+
}
|
|
15
|
+
return true;
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
]);
|
|
19
|
+
metadata.reason = reason;
|
|
20
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ApolloClient } from "@apollo/client";
|
|
2
|
+
import type { Command } from "@oclif/core";
|
|
3
|
+
import type { RequestMap } from "../types";
|
|
4
|
+
export declare function chooseRoles(cmd: Command, client: ApolloClient, appId: string, assetId: string, requestMap: RequestMap): Promise<void>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.chooseRoles = chooseRoles;
|
|
4
|
+
const _1 = require(".");
|
|
5
|
+
const api_1 = require("../api");
|
|
6
|
+
const { AutoComplete } = require("enquirer");
|
|
7
|
+
async function chooseRoles(cmd, client, appId, assetId, requestMap) {
|
|
8
|
+
var _a;
|
|
9
|
+
const entry = requestMap[appId];
|
|
10
|
+
const assetEntry = entry === null || entry === void 0 ? void 0 : entry.assets[assetId];
|
|
11
|
+
if (entry === undefined || assetEntry === undefined) {
|
|
12
|
+
throw new Error(`App ${appId} or Asset ${assetId} not found in requestMap`);
|
|
13
|
+
}
|
|
14
|
+
const assetRoles = (_a = (await (0, api_1.queryAssetRoles)(cmd, client, assetEntry.type, assetId))) !== null && _a !== void 0 ? _a : [];
|
|
15
|
+
if (assetRoles !== undefined &&
|
|
16
|
+
(assetRoles.length === 0 ||
|
|
17
|
+
(assetRoles.length === 1 && assetRoles[0].value.name === ""))) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const rolePrompt = new AutoComplete({
|
|
21
|
+
name: "Roles",
|
|
22
|
+
message: `Select one or more roles for ${assetEntry.assetName}:`,
|
|
23
|
+
hint: _1.multiSelectInstructions,
|
|
24
|
+
limit: 15,
|
|
25
|
+
multiple: true,
|
|
26
|
+
choices: assetRoles,
|
|
27
|
+
validate: (answer) => {
|
|
28
|
+
if (answer.length < 1) {
|
|
29
|
+
return "You must select at least one item.";
|
|
30
|
+
}
|
|
31
|
+
return true;
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
const roles = await rolePrompt.run();
|
|
35
|
+
if (!assetEntry.roles) {
|
|
36
|
+
assetEntry.roles = {};
|
|
37
|
+
}
|
|
38
|
+
for (const role of roles) {
|
|
39
|
+
assetEntry.roles[role.id] = {
|
|
40
|
+
roleId: role.id,
|
|
41
|
+
roleName: role.name,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.doneSelectingAssets = doneSelectingAssets;
|
|
4
|
+
exports.promptRequestSubmission = promptRequestSubmission;
|
|
5
|
+
const displays_1 = require("../displays");
|
|
6
|
+
const { Select } = require("enquirer");
|
|
7
|
+
async function doneSelectingAssets() {
|
|
8
|
+
const submitMessage = "✅ Yes, proceed with request";
|
|
9
|
+
const addMoreMessage = "❌ No, add more items";
|
|
10
|
+
const prompt = new Select({
|
|
11
|
+
name: "submitOrAdd",
|
|
12
|
+
message: "Is this all you want to request?",
|
|
13
|
+
choices: [submitMessage, addMoreMessage],
|
|
14
|
+
});
|
|
15
|
+
const submitOrAdd = await prompt.run();
|
|
16
|
+
return submitOrAdd === submitMessage;
|
|
17
|
+
}
|
|
18
|
+
async function promptRequestSubmission(cmd, metadata) {
|
|
19
|
+
(0, displays_1.displayFinalRequestSummary)(cmd, metadata);
|
|
20
|
+
const submitMessage = "✅ Yes, submit request";
|
|
21
|
+
const cancelMessage = "❌ No, cancel request";
|
|
22
|
+
const prompt = new Select({
|
|
23
|
+
name: "submitOrCancel",
|
|
24
|
+
message: "Is this all you want to request?",
|
|
25
|
+
choices: [submitMessage, cancelMessage],
|
|
26
|
+
});
|
|
27
|
+
const submitOrCancel = await prompt.run();
|
|
28
|
+
return submitOrCancel === submitMessage;
|
|
29
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ApolloClient } from "@apollo/client";
|
|
2
|
+
import type { Command } from "@oclif/core";
|
|
3
|
+
import { type ConnectionType, RequestMessageCode } from "../../graphql/graphql";
|
|
4
|
+
import { type RequestMap, type RequestMetadata } from "./types";
|
|
5
|
+
export declare function initEmptyRequestMetadata(): RequestMetadata;
|
|
6
|
+
export declare function setRequestDefaults(cmd: Command, client: ApolloClient, metadata: RequestMetadata): Promise<void>;
|
|
7
|
+
export declare function submitFinalRequest(cmd: Command, client: ApolloClient, metadata: RequestMetadata): Promise<void>;
|
|
8
|
+
export declare function getRequestLink(cmd: Command, id: string): string;
|
|
9
|
+
export declare function generateRequestLink(cmd: Command, defaultDurationInMinutes: number): string;
|
|
10
|
+
export declare function bypassRequestSelection(cmd: Command, client: ApolloClient, flagValue: string[], metadata: RequestMetadata): Promise<void>;
|
|
11
|
+
export declare function bypassDuration(cmd: Command, duration: number, metadata: RequestMetadata): void;
|
|
12
|
+
export declare function getRequestMessageFromCode(cmd: Command, code: RequestMessageCode, connectionName: string | undefined, connectionType: ConnectionType | undefined, extraParams?: string, sourceGroupRedirect?: () => void): string;
|
|
13
|
+
export declare function duplicateRequestTemplate(cmd: Command, client: ApolloClient, requestId: string, metadata: RequestMetadata): Promise<void>;
|
|
14
|
+
export declare function copyBundleAssets(cmd: Command, client: ApolloClient, bundleId: string, requestMap: RequestMap): Promise<void>;
|