-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor to better support coming QS Cloud commands
- Loading branch information
Göran Sander
committed
Oct 24, 2024
1 parent
b74df00
commit f21f4f9
Showing
69 changed files
with
1,393 additions
and
1,100 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import prettier from 'eslint-plugin-prettier'; | ||
import globals from 'globals'; | ||
import path from 'node:path'; | ||
import { fileURLToPath } from 'node:url'; | ||
import js from '@eslint/js'; | ||
import { FlatCompat } from '@eslint/eslintrc'; | ||
|
||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = path.dirname(__filename); | ||
const compat = new FlatCompat({ | ||
baseDirectory: __dirname, | ||
recommendedConfig: js.configs.recommended, | ||
allConfig: js.configs.all, | ||
}); | ||
|
||
// export default [...compat.extends("airbnb-base", "prettier"), { | ||
export default [ | ||
...compat.extends('prettier'), | ||
{ | ||
plugins: { | ||
prettier, | ||
}, | ||
|
||
languageOptions: { | ||
globals: { | ||
...globals.node, | ||
}, | ||
|
||
ecmaVersion: 12, | ||
sourceType: 'module', | ||
}, | ||
|
||
rules: { | ||
'prettier/prettier': 'error', | ||
}, | ||
}, | ||
]; |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Option } from 'commander'; | ||
|
||
import { catchLog } from '../util/log.js'; | ||
import { qscloudSharedParamAssertOptions } from '../util/qscloud/assert-options.js'; | ||
import qscloudTestConnection from '../cmd/qscloud/testconnection.js'; | ||
|
||
export function setupQscloudTestConnectionCommand(qsCloud) { | ||
qsCloud | ||
.command('connection-test') | ||
.description('test connection to Qlik Sense Cloud.') | ||
.action(async (options) => { | ||
// SHow app version | ||
logger.info(`App version: ${appVersion}`); | ||
|
||
try { | ||
await qscloudSharedParamAssertOptions(options); | ||
const res = qscloudTestConnection(options); | ||
logger.debug(`QS CLOUD CONNECTION TEST: Result: ${res}`); | ||
} catch (err) { | ||
catchLog('QS CLOUD CONNECTION TEST', err); | ||
} | ||
}) | ||
.addOption( | ||
new Option('--log-level <level>', 'log level').choices(['error', 'warn', 'info', 'verbose', 'debug', 'silly']).default('info') | ||
) | ||
.requiredOption( | ||
'--tenant-url <url>', | ||
'URL or host of Qlik Sense cloud tenant. Example: "https://tenant.eu.qlikcloud.com" or "tenant.eu.qlikcloud.com"' | ||
) | ||
.addOption(new Option('-a, --auth-type <type>', 'authentication type').choices(['apikey']).default('apikey')) | ||
.requiredOption('--apikey <key>', 'API key used to access the Sense APIs') | ||
|
||
.option('--auth-cert-file <file>', 'Qlik Sense certificate file (exported from QMC)', './cert/client.pem') | ||
.option('--auth-cert-key-file <file>', 'Qlik Sense certificate key file (exported from QMC)', './cert/client_key.pem') | ||
.option('--auth-root-cert-file <file>', 'Qlik Sense root certificate file (exported from QMC)', './cert/root.pem') | ||
.option('--auth-jwt <jwt>', 'JSON Web Token (JWT) to use for authentication with Qlik Sense server'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { Option } from 'commander'; | ||
|
||
import { catchLog } from '../util/log.js'; | ||
// import { qseowSharedParamAssertOptions, customPropertyUserActivityBucketsAssertOptions } from '../util/qseow/assert-options.js'; | ||
// import customPropertyUserActivityBuckets from '../cmd/qseow/custom-property-user-activity-buckets.js'; | ||
|
||
export function setupQseowUserActivityCustomPropertyCommand(qseow) { | ||
// | ||
} | ||
|
||
// program | ||
// .command('user-activity-cp-create') | ||
// .description( | ||
// 'create custom property and populate it with values ("activity buckets") indicating how long ago users last logged into Sense' | ||
// ) | ||
// .action(async (options) => { | ||
// try { | ||
// let optionsLocal = options; | ||
// await qseowSharedParamAssertOptions(options); | ||
// optionsLocal = userActivityCustomPropertyAssertOptions(options); | ||
// createUserActivityCustomProperty(optionsLocal); | ||
// } catch (err) { | ||
// logger.error(`USER ACTIVITY CP: ${err}`); | ||
// } | ||
// }) | ||
// .addOption( | ||
// new Option('--log-level <level>', 'log level') | ||
// .choices(['error', 'warn', 'info', 'verbose', 'debug', 'silly']) | ||
// .default('info') | ||
// ) | ||
// .requiredOption('--host <host>', 'Qlik Sense server IP/FQDN') | ||
// .option('--port <port>', 'Qlik Sense repository API port', '4242') | ||
// .requiredOption('--virtual-proxy <prefix>', 'Qlik Sense virtual proxy prefix', '') | ||
// .requiredOption('--secure <true|false>', 'https connection to Qlik Sense must use correct certificate. Invalid certificates will result in rejected/failed connection.', true) | ||
// .option('--auth-user-dir <directory>', 'user directory for user to connect with', 'Internal') | ||
// .option('--auth-user-id <userid>', 'user ID for user to connect with', 'sa_repository') | ||
|
||
// .addOption(new Option('-a, --auth-type <type>', 'authentication type').choices(['cert', 'jwt']).default('cert')) | ||
// .option('--auth-cert-file <file>', 'Qlik Sense certificate file (exported from QMC)', './cert/client.pem') | ||
// .option('--auth-cert-key-file <file>', 'Qlik Sense certificate key file (exported from QMC)', './cert/client_key.pem') | ||
// .option('--auth-root-cert-file <file>', 'Qlik Sense root certificate file (exported from QMC)', './cert/root.pem') | ||
// .option('--jwt <JWT>', 'JSON Web Token (JWT) to use for authenticating with Qlik Sense', '') | ||
|
||
// .requiredOption('--user-directory <name>', 'name of user directory whose users will be updated with activity info') | ||
// .requiredOption('--custom-property-name <name>', 'name of custom property that will hold user activity buckets') | ||
// .addOption( | ||
// new Option('--force <true|false>', 'forcibly overwrite and replace custom property and its values if it already exists') | ||
// .choices(['true', 'false']) | ||
// .default('false') | ||
// ) | ||
// .option('--activity-buckets <buckets...>', 'custom property values/user activity buckets to be defined. In days.', [ | ||
// '1', | ||
// '7', | ||
// '14', | ||
// '30', | ||
// '90', | ||
// '180', | ||
// '365', | ||
// ]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Option } from 'commander'; | ||
|
||
import { catchLog } from '../util/log.js'; | ||
import { qseowSharedParamAssertOptions, masterItemDimDeleteAssertOptions } from '../util/qseow/assert-options.js'; | ||
import deleteMasterDimension from '../cmd/qseow/getdim.js'; | ||
|
||
export function setupQseowDeleteMasterDimensionCommand(qseow) { | ||
qseow | ||
.command('master-item-dim-delete') | ||
.description('delete master dimension(s)') | ||
.action(async (options) => { | ||
await qseowSharedParamAssertOptions(options); | ||
masterItemDimDeleteAssertOptions(options); | ||
|
||
deleteMasterDimension(options); | ||
}) | ||
.addOption( | ||
new Option('--log-level <level>', 'log level').choices(['error', 'warn', 'info', 'verbose', 'debug', 'silly']).default('info') | ||
) | ||
.requiredOption('--host <host>', 'Qlik Sense server IP/FQDN') | ||
.option('--port <port>', 'Qlik Sense server engine port (usually 4747 for cert auth, 443 for jwt auth)', '4747') | ||
.option('--schema-version <string>', 'Qlik Sense engine schema version', '12.612.0') | ||
.requiredOption('--app-id <id>', 'Qlik Sense app ID') | ||
.requiredOption('--virtual-proxy <prefix>', 'Qlik Sense virtual proxy prefix', '') | ||
.requiredOption( | ||
'--secure <true|false>', | ||
'https connection to Qlik Sense must use correct certificate. Invalid certificates will result in rejected/failed connection.', | ||
true | ||
) | ||
.requiredOption('--auth-user-dir <directory>', 'user directory for user to connect with') | ||
.requiredOption('--auth-user-id <userid>', 'user ID for user to connect with') | ||
|
||
.addOption(new Option('-a, --auth-type <type>', 'authentication type').choices(['cert', 'jwt']).default('cert')) | ||
.option('--auth-cert-file <file>', 'Qlik Sense certificate file (exported from QMC)', './cert/client.pem') | ||
.option('--auth-cert-key-file <file>', 'Qlik Sense certificate key file (exported from QMC)', './cert/client_key.pem') | ||
.option('--auth-root-cert-file <file>', 'Qlik Sense root certificate file (exported from QMC)', './cert/root.pem') | ||
.option('--auth-jwt <jwt>', 'JSON Web Token (JWT) to use for authentication with Qlik Sense server') | ||
|
||
.addOption(new Option('--id-type <type>', 'type of identifier passed in the --master-item option').choices(['id', 'name'])) | ||
.option('--master-item <ids...>', 'names or IDs of master dimensions to be deleted. Multiple IDs should be space separated') | ||
.option('--delete-all', 'delete all master dimensions') | ||
.option('--dry-run', 'do a dry run, i.e. do not delete anything - just show what would be deleted'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Option } from 'commander'; | ||
|
||
import { catchLog } from '../util/log.js'; | ||
import { qseowSharedParamAssertOptions, masterItemMeasureDeleteAssertOptions } from '../util/qseow/assert-options.js'; | ||
import deleteMasterMeasure from '../cmd/qseow/deletemeasure.js'; | ||
|
||
export function setupQseowDeleteMasterMeasureCommand(qseow) { | ||
qseow | ||
.command('master-item-measure-delete') | ||
.description('delete master measure(s)') | ||
.action(async (options) => { | ||
await qseowSharedParamAssertOptions(options); | ||
masterItemMeasureDeleteAssertOptions(options); | ||
|
||
deleteMasterMeasure(options); | ||
}) | ||
.addOption( | ||
new Option('--log-level <level>', 'log level').choices(['error', 'warn', 'info', 'verbose', 'debug', 'silly']).default('info') | ||
) | ||
.requiredOption('--host <host>', 'Qlik Sense server IP/FQDN') | ||
.option('--port <port>', 'Qlik Sense server engine port (usually 4747 for cert auth, 443 for jwt auth)', '4747') | ||
.option('--schema-version <string>', 'Qlik Sense engine schema version', '12.612.0') | ||
.requiredOption('--app-id <id>', 'Qlik Sense app ID') | ||
.requiredOption('--virtual-proxy <prefix>', 'Qlik Sense virtual proxy prefix', '') | ||
.requiredOption( | ||
'--secure <true|false>', | ||
'https connection to Qlik Sense must use correct certificate. Invalid certificates will result in rejected/failed connection.', | ||
true | ||
) | ||
.requiredOption('--auth-user-dir <directory>', 'user directory for user to connect with') | ||
.requiredOption('--auth-user-id <userid>', 'user ID for user to connect with') | ||
|
||
.addOption(new Option('-a, --auth-type <type>', 'authentication type').choices(['cert', 'jwt']).default('cert')) | ||
.option('--auth-cert-file <file>', 'Qlik Sense certificate file (exported from QMC)', './cert/client.pem') | ||
.option('--auth-cert-key-file <file>', 'Qlik Sense certificate key file (exported from QMC)', './cert/client_key.pem') | ||
.option('--auth-root-cert-file <file>', 'Qlik Sense root certificate file (exported from QMC)', './cert/root.pem') | ||
.option('--auth-jwt <jwt>', 'JSON Web Token (JWT) to use for authentication with Qlik Sense server') | ||
|
||
.addOption(new Option('--id-type <type>', 'type of identifier passed in the --master-item option').choices(['id', 'name'])) | ||
.option('--master-item <ids...>', 'names or IDs of master measures to be deleted. Multiple IDs should be space separated') | ||
.option('--delete-all', 'delete all master measures') | ||
.option('--dry-run', 'do a dry run, i.e. do not delete anything - just show what would be deleted'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { Option } from 'commander'; | ||
|
||
import { catchLog } from '../util/log.js'; | ||
import { qseowSharedParamAssertOptions, deleteSessionsAssertOptions } from '../util/qseow/assert-options.js'; | ||
import deleteSessions from '../cmd/qseow/deletesessions.js'; | ||
|
||
export function setupQseowDeleteProxySessionsCommand(qseow) { | ||
qseow | ||
.command('session-delete') | ||
.description('delete proxy session(s) on a specific virtual proxy and proxy service') | ||
.action(async (options) => { | ||
await qseowSharedParamAssertOptions(options); | ||
await deleteSessionsAssertOptions(options); | ||
|
||
deleteSessions(options); | ||
}) | ||
.addOption( | ||
new Option('--log-level <level>', 'log level').choices(['error', 'warn', 'info', 'verbose', 'debug', 'silly']).default('info') | ||
) | ||
|
||
.requiredOption('--host <host>', 'Qlik Sense host (IP/FQDN) where Qlik Repository Service (QRS) is running') | ||
.option('--qrs-port <port>', 'Qlik Sense repository service (QRS) port (usually 4242)', '4242') | ||
.requiredOption('--virtual-proxy <prefix>', 'Qlik Sense virtual proxy prefix to access QRS via', '') | ||
.requiredOption( | ||
'--secure <true|false>', | ||
'https connection to Qlik Sense must use correct certificate. Invalid certificates will result in rejected/failed connection.', | ||
true | ||
) | ||
|
||
.option('--session-id <id...>', 'session IDs to delete') | ||
.requiredOption('--session-virtual-proxy <prefix>', 'Qlik Sense virtual proxy (prefix) to delete proxy session(s) on', '') | ||
.requiredOption( | ||
'--host-proxy <host>', | ||
'Qlik Sense proxy (IP/FQDN) where sessions should be deleted. Must match the host name of a Sense node' | ||
) | ||
.option('--qps-port <port>', 'Qlik Sense proxy service (QPS) port (usually 4243)', '4243') | ||
|
||
.requiredOption('--auth-user-dir <directory>', 'user directory for user to connect with') | ||
.requiredOption('--auth-user-id <userid>', 'user ID for user to connect with') | ||
|
||
.addOption(new Option('-a, --auth-type <type>', 'authentication type').choices(['cert']).default('cert')) | ||
.option('--auth-cert-file <file>', 'Qlik Sense certificate file (exported from QMC)', './cert/client.pem') | ||
.option('--auth-cert-key-file <file>', 'Qlik Sense certificate key file (exported from QMC)', './cert/client_key.pem') | ||
.option('--auth-root-cert-file <file>', 'Qlik Sense root certificate file (exported from QMC)', './cert/root.pem'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { Option } from 'commander'; | ||
|
||
import { catchLog } from '../util/log.js'; | ||
import { qseowSharedParamAssertOptions, variableDeleteAssertOptions } from '../util/qseow/assert-options.js'; | ||
import deleteVariable from '../cmd/qseow/deletevariable.js'; | ||
|
||
export function setupQseowDeleteVariableCommand(qseow) { | ||
qseow | ||
.command('variable-delete') | ||
.description('delete one or more variables in one or more apps') | ||
.action(async (options) => { | ||
await qseowSharedParamAssertOptions(options); | ||
variableDeleteAssertOptions(options); | ||
|
||
deleteVariable(options); | ||
}) | ||
.addOption( | ||
new Option('--log-level <level>', 'log level').choices(['error', 'warn', 'info', 'verbose', 'debug', 'silly']).default('info') | ||
) | ||
.requiredOption('--host <host>', 'Qlik Sense server IP/FQDN') | ||
.option('--engine-port <port>', 'Qlik Sense server engine port (usually 4747 for cert auth, 443 for jwt auth)', '4747') | ||
.option('--qrs-port <port>', 'Qlik Sense repository service (QRS) port (usually 4242 for cert auth, 443 for jwt auth)', '4242') | ||
.option('--schema-version <string>', 'Qlik Sense engine schema version', '12.612.0') | ||
.option('--app-id <id...>', 'Qlik Sense app ID(s) to get variables from') | ||
.option('--app-tag <tag...>', 'Qlik Sense app tag(s) to get variables') | ||
.requiredOption('--virtual-proxy <prefix>', 'Qlik Sense virtual proxy prefix', '') | ||
.requiredOption( | ||
'--secure <true|false>', | ||
'https connection to Qlik Sense must use correct certificate. Invalid certificates will result in rejected/failed connection.', | ||
true | ||
) | ||
.requiredOption('--auth-user-dir <directory>', 'user directory for user to connect with') | ||
.requiredOption('--auth-user-id <userid>', 'user ID for user to connect with') | ||
|
||
.addOption(new Option('-a, --auth-type <type>', 'authentication type').choices(['cert', 'jwt']).default('cert')) | ||
.option('--auth-cert-file <file>', 'Qlik Sense certificate file (exported from QMC)', './cert/client.pem') | ||
.option('--auth-cert-key-file <file>', 'Qlik Sense certificate key file (exported from QMC)', './cert/client_key.pem') | ||
.option('--auth-root-cert-file <file>', 'Qlik Sense root certificate file (exported from QMC)', './cert/root.pem') | ||
.option('--auth-jwt <jwt>', 'JSON Web Token (JWT) to use for authentication with Qlik Sense server') | ||
|
||
.addOption( | ||
new Option('--id-type <type>', 'type of identifier passed in the --variable option').choices(['id', 'name']).default('name') | ||
) | ||
.option('--variable <ids...>', 'variables to retrieve. If not specified all variables will be retrieved') | ||
.option('--delete-all', 'delete all variables') | ||
.option('--dry-run', 'do a dry run, i.e. do not delete anything - just show what would be deleted'); | ||
} |
Oops, something went wrong.