@petarmihaylov/node-raas
Version:
A tiny library and CLI for interacting with the Reports as a Service - RAAS - API from UKG - Ultimate Kronos Group. This project is maintained by the team behind RaasTastic and the community. It provides a balanced set of features that should suit a broad
118 lines (117 loc) • 6.09 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const core_1 = require("@oclif/core");
const core_raas_1 = require("../lib/core-raas");
const chalk_1 = tslib_1.__importDefault(require("chalk"));
const formatters_1 = require("../utils/formatters");
const actions_1 = require("../lib/actions");
class Pull extends core_1.Command {
async run() {
const { args, flags } = await this.parse(Pull);
const reportPath = args.reportPathOrId[0] === 'i' ?
`storeID("${args.reportPathOrId}")` :
args.reportPathOrId;
const raasCredential = {
UserName: flags.username,
Password: flags.password,
ClientAccessKey: flags.customerApiKey,
UserAccessKey: flags.userApiKey,
};
this.log(chalk_1.default.blue('Starting a report pull...'));
this.log((0, formatters_1.blueMagenta)('Report Path/ID:', reportPath));
if (flags.printCreds) {
this.log((0, formatters_1.blueMagenta)('Username:', flags.username));
this.log((0, formatters_1.blueMagenta)('Password:', flags.password));
this.log((0, formatters_1.blueMagenta)('Customer API Key:', flags.customerApiKey));
this.log((0, formatters_1.blueMagenta)('User API Key:', flags.userApiKey));
this.log((0, formatters_1.blueMagenta)('Base Endpoint URL:', flags.baseEndpointUrl));
}
// Set up the SOAP clients
const clients = await (0, core_raas_1.config)(flags.baseEndpointUrl);
const logOnResult = await (0, actions_1.logOnAction)(clients, raasCredential, flags);
await (0, actions_1.getReportParametersAction)(clients, logOnResult, reportPath, flags);
const executeReportResult = await (0, actions_1.executeReportAction)(clients, logOnResult, reportPath, flags);
const retrieveReportResult = await (0, actions_1.retrieveReportAction)(clients, executeReportResult, flags);
const decodedStream = (0, formatters_1.decodeStream)(retrieveReportResult.result[0].ReportStream);
await (0, formatters_1.saveStream)(decodedStream, 'export', formatters_1.FileExportExtensions.XML);
await (0, actions_1.logOffAction)(clients, logOnResult, flags);
}
}
exports.default = Pull;
Pull.description = 'Pull data from a BI report through Reports as a Service (RAAS).';
Pull.examples = [
'$ node-raas pull "i22500177CDE54018AC31713BEBE2F644" -u ServiceAccount -p "u(3Unv0ERjlaksdjf*jfa89wfjklj23j!@3j423j#OI@^j2342" -c B5JLX -a BB7VDK0000K0 -e rental4.ultipro.com',
"$ node-raas pull \"/content/folder[@name='zzzCompany Folders']/folder[@name='Eastwood Industries - Master SC(72)']/folder[@name='UltiPro']/folder[@name='Customs']/report[@name='Audit Report 2']\" -u ServiceAccount -p \"u(3Unv0ERjlaksdjf*jfa89wfjklj23j!@3j423j#OI@^j2342\" -c B5JLX -a BB7VDK0000K0 -e rental4.ultipro.com",
];
Pull.flags = {
// flag with no value (-h, --help)
help: core_1.Flags.help({ char: 'h' }),
// flag with a value (-u, --username="VALUE")
username: core_1.Flags.string({
char: 'u',
required: true,
description: 'Username of user or service account. Employee User is required for pulling UKG Time Management data.',
env: 'USERNAME',
}),
// flag with a value (-p, --password="VALUE")
password: core_1.Flags.string({
char: 'p',
required: true,
description: 'Password for the provided username. Be sure to escape any special characters for your command line. (Ex: ! should be \\! in bash shells.)',
env: 'PASSWORD',
}),
// flag with a value (-c, --customer-api-key="VALUE")
customerApiKey: core_1.Flags.string({
char: 'c',
required: true,
description: 'A 5-character alpha-numeric key from UKG Pro > MENU > SYSTEM CONFIGURATION > Security > Service Account Administration or Web Services.',
env: 'CUSTOMER_API_KEY',
}),
// flag with a value (-a, --user-api-key="VALUE")
userApiKey: core_1.Flags.string({
char: 'a',
required: true,
description: 'A 12-character alpha-numeric key for the provided username from UKG Pro > MENU > SYSTEM CONFIGURATION > Security > Service Account Administration. If using an Employee User use the User API Key from UKG Pro > MENU > SYSTEM CONFIGURATION > Security > Web Services.',
env: 'USER_API_KEY',
}),
// flag with a value (-e, --base-endpoint-url="VALUE")
baseEndpointUrl: core_1.Flags.string({
char: 'e',
required: true,
options: [
'servicet.ultipro.com',
'service2.ultipro.com',
'service3.ultipro.ca',
'service4.ultipro.com',
'service5.ultipro.com',
'rental2.ultipro.com',
'rental3.ultipro.ca',
'rental4.ultipro.com',
'rental5.ultipro.com',
],
description: 'Base endpoint URL from UKG Pro > MENU > SYSTEM CONFIGURATION > Security > Web Services. Do not include the protocol (https://).',
env: 'BASE_ENDPOINT_URL',
}),
// flag with no value (-l, --list-creds)
printCreds: core_1.Flags.boolean({
char: 'l',
description: 'Print the credentials. Useful when ensuring flag input is processed correctly. As a best practice, credentials should be surrounded in double-quotes and any special characters for your conssole escaped. (Ex: ! should be \\! in bash.)',
default: false,
}),
// flag with no value (-v, --verbose)
verbose: core_1.Flags.boolean({
char: 'v',
description: 'Output raw request/response combination for failing requests.',
default: false,
env: 'VERBOSE',
}),
};
Pull.args = [
{
name: 'reportPathOrId',
required: true,
description: 'Report path or ID from Cognos (BI). Obtained by inspecting Properties of a BI report. (Right-click > Properties > General > Advanced > [Search path | ID].)',
default: process.env.REPORT_PATH_OR_ID,
},
];