Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/cli/config/config-export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export default function setup() {
includeReadOnly: options.readOnly,
onlyRealm: options.realmOnly,
onlyGlobal: options.globalOnly,
onlyCustom: options.onlyCustom
onlyCustom: options.onlyCustom,
}
);
if (!outcome) process.exitCode = 1;
Expand Down Expand Up @@ -209,7 +209,7 @@ export default function setup() {
includeReadOnly: options.readOnly,
onlyRealm: options.realmOnly,
onlyGlobal: options.globalOnly,
onlyCustom: options.onlyCustom
onlyCustom: options.onlyCustom,
}
);
if (!outcome) process.exitCode = 1;
Expand Down
6 changes: 3 additions & 3 deletions src/cli/config/config-import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export default function setup() {
includeDefault: options.default,
includeActiveValues: options.includeActiveValues,
source: options.source,
onlyCustom: options.onlyCustom
onlyCustom: options.onlyCustom,
});
if (!outcome) process.exitCode = 1;
}
Expand All @@ -159,7 +159,7 @@ export default function setup() {
includeDefault: options.default,
includeActiveValues: options.includeActiveValues,
source: options.source,
onlyCustom: options.onlyCustom
onlyCustom: options.onlyCustom,
});
if (!outcome) process.exitCode = 1;
}
Expand All @@ -177,7 +177,7 @@ export default function setup() {
includeDefault: options.default,
includeActiveValues: options.includeActiveValues,
source: options.source,
onlyCustom: options.onlyCustom
onlyCustom: options.onlyCustom,
}
);
if (!outcome) process.exitCode = 1;
Expand Down
4 changes: 4 additions & 0 deletions src/cli/iga/iga.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { FrodoStubCommand } from '../FrodoCommand';
import RequestFormCmd from './request-forms/iga-request-forms';
import WorkflowCmd from './workflow/iga-workflow';

export default function setup() {
Expand All @@ -7,6 +8,9 @@ export default function setup() {
);

program.addCommand(WorkflowCmd().name('workflow').showHelpAfterError());
program.addCommand(
RequestFormCmd().name('request-form').showHelpAfterError()
);

program.showHelpAfterError();
return program;
Expand Down
144 changes: 144 additions & 0 deletions src/cli/iga/request-forms/iga-request-form-import.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
import { frodo, state } from '@rockcarver/frodo-lib';
import { Option } from 'commander';

import { getTokens } from '../../../ops/AuthenticateOps';
import {
importFirstRequestFormFromFile,
importRequestFormFromFile,
importRequestFormsFromFile,
importRequestFormsFromFiles,
} from '../../../ops/cloud/iga/IgaRequestFormsOps';
import { printMessage, verboseMessage } from '../../../utils/Console.js';
import { FrodoCommand } from '../../FrodoCommand';

const { CLOUD_DEPLOYMENT_TYPE_KEY } = frodo.utils.constants;

const deploymentTypes = [CLOUD_DEPLOYMENT_TYPE_KEY];

export default function setup() {
const program = new FrodoCommand(
'frodo iga request-form import',
[],
deploymentTypes
);

program
.description('Import request forms.')
.addOption(
new Option(
'-n, --request-form-name <request-form-name>',
'Request for name. If specified, -a and -A are ignored.'
)
)
.addOption(new Option('-f, --file <file>', 'Name of the import file.'))
.addOption(
new Option(
'-a, --all',
'Import all request forms from single file. Ignored with -n.'
)
)
.addOption(
new Option(
'-A, --all-separate',
'Import all request forms from separate files (*.requestforms.json) in the current directory. Ignored with -n or -a.'
)
)
.addOption(
new Option(
'--no-deps',
'Do not import any dependencies (email templates, request forms, events, etc.).'
)
)
.action(
// implement program logic inside action handler
async (host, realm, user, password, options, command) => {
command.handleDefaultArgsAndOpts(
host,
realm,
user,
password,
options,
command
);
const isImportById = options.requestFormName && options.file;
const isImportAll = options.all && options.file;
const isImportAllSeparate = options.allSeparate && !options.file;
const isImportFirst = !!options.file;
if (
!isImportById &&
!isImportAll &&
!isImportAllSeparate &&
!isImportFirst
) {
printMessage(
'Unrecognized combination of options or no options...',
'error'
);
program.help();
process.exitCode = 1;
return;
}
const getTokensIsSuccessful = await getTokens(
false,
true,
deploymentTypes
);
if (!getTokensIsSuccessful) {
printMessage('Error getting tokens', 'error');
process.exitCode = 1;
return;
}
if (!state.getIsIGA()) {
printMessage(
'Command not supported for non-IGA cloud tenants',
'error'
);
process.exitCode = 1;
return;
}
// import by id
if (isImportById) {
verboseMessage(
`Importing request forms "${options.requestFormName}"...`
);
const outcome = await importRequestFormFromFile(
options.requestFormName,
options.file,
{
deps: options.deps,
}
);
if (!outcome) process.exitCode = 1;
}
// --all -a
else if (isImportAll) {
verboseMessage(
`Importing all request form from a single file (${options.file})...`
);
const outcome = await importRequestFormsFromFile(options.file);
if (!outcome) process.exitCode = 1;
}
// --all-separate -A
else if (isImportAllSeparate) {
verboseMessage(
'Importing all request forms from separate files (*.requestform.json) in current directory...'
);
const outcome = await importRequestFormsFromFiles();
if (!outcome) process.exitCode = 1;
}
// import first request form from file
else if (isImportFirst) {
verboseMessage(
`Importing first request form from file "${options.file}"...`
);
const outcome = await importFirstRequestFormFromFile(options.file, {
deps: options.deps,
});
if (!outcome) process.exitCode = 1;
}
}
// end program logic inside action handler
);

return program;
}
83 changes: 83 additions & 0 deletions src/cli/iga/request-forms/iga-request-forms-delete.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import { frodo, state } from '@rockcarver/frodo-lib';
import { Option } from 'commander';

import { getTokens } from '../../../ops/AuthenticateOps';
import {
deleteAllRequestForms,
deleteRequestForm,
} from '../../../ops/cloud/iga/IgaRequestFormsOps';
import { printMessage, verboseMessage } from '../../../utils/Console.js';
import { FrodoCommand } from '../../FrodoCommand';

const { CLOUD_DEPLOYMENT_TYPE_KEY } = frodo.utils.constants;

const deploymentTypes = [CLOUD_DEPLOYMENT_TYPE_KEY];

export default function setup() {
const program = new FrodoCommand('frodo iga request-form delete');

program
.description('Delete request form.')
.addOption(
new Option(
'-n, --request-form-name <request-form-name>',
'Request form. If specified, -a is ignored.'
)
)
.addOption(new Option('-a, --all', 'Delete all request forms.'))
.action(
// implement command logic inside action handler
async (host, realm, user, password, options, command) => {
command.handleDefaultArgsAndOpts(
host,
realm,
user,
password,
options,
command
);
if (!options.requestFormName && !options.all) {
printMessage(
'Unrecognized combination of options or no options...',
'error'
);
program.help();
process.exitCode = 1;
return;
}
const getTokensIsSuccessful = await getTokens(
false,
true,
deploymentTypes
);
if (!getTokensIsSuccessful) {
printMessage('Error getting tokens', 'error');
process.exitCode = 1;
return;
}
if (!state.getIsIGA()) {
printMessage(
'Command not supported for non-IGA cloud tenants',
'error'
);
process.exitCode = 1;
return;
}
// delete by name
if (options.requestFormName) {
verboseMessage('Deleting request-form...');
const outcome = await deleteRequestForm(options.requestFormName);
if (!outcome) process.exitCode = 1;
}
// --all -a
else if (options.all) {
verboseMessage('Deleting all request-form...');
const outcome = await deleteAllRequestForms();
if (!outcome) process.exitCode = 1;
}
}
// end command logic inside action handler
);

return program;
}
70 changes: 70 additions & 0 deletions src/cli/iga/request-forms/iga-request-forms-describe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { frodo, state } from '@rockcarver/frodo-lib';
import { Option } from 'commander';

import { getTokens } from '../../../ops/AuthenticateOps';
import { describeRequestForm } from '../../../ops/cloud/iga/IgaRequestFormsOps';
import { printMessage, verboseMessage } from '../../../utils/Console';
import { FrodoCommand } from '../../FrodoCommand';

const { CLOUD_DEPLOYMENT_TYPE_KEY } = frodo.utils.constants;
const deploymentTypes = [CLOUD_DEPLOYMENT_TYPE_KEY];

export default function setup() {
const program = new FrodoCommand('frodo iga request-form describe');
program
.description('Describe request form.')
.addOption(
new Option(
'-n, --request-form-name <name>',
'Request form name. If not specified, will describe the first request form in the provided export file.'
)
)
.addOption(
new Option(
'-f, --file <file>',
'Request form file. If not specified, will describe the first request form in the provided export file.'
)
)

.action(async (host, realm, user, password, options, command) => {
command.handleDefaultArgsAndOpts(
host,
realm,
user,
password,
options,
command
);
if (!options.name && !options.file) {
printMessage(
'Unrecognized combination of options or no options...',
'error'
);
program.help();
process.exitCode = 1;
return;
}
const getTokensIsSuccessful = await getTokens(
false,
true,
deploymentTypes
);
if (!getTokensIsSuccessful) {
printMessage('Error getting tokens', 'error');
process.exitCode = 1;
return;
}
if (!state.getIsIGA()) {
printMessage(
'Command not supported for non-IGA cloud tenants',
'error'
);
process.exitCode = 1;
return;
}
verboseMessage(`Describing request form ${options.name}...`);
const outcome = await describeRequestForm(options.name, options.file);
if (!outcome) process.exitCode = 1;
});
return program;
}
Loading