From 8cdf317367f80d1f49b40ce39e77f1cd22f96e3f Mon Sep 17 00:00:00 2001 From: EKhan Date: Mon, 6 Jan 2025 15:21:33 +0000 Subject: [PATCH] Updated following review Signed-off-by: EKhan --- .../sdk/src/constants/CicsCmci.constants.ts | 19 +++++++- packages/sdk/src/utils/Utils.ts | 48 +++++++++---------- .../src/commands/closeLocalFileCommand.ts | 2 +- .../disableLocalFileCommand.ts | 2 +- .../enableCommands/enableLocalFileCommand.ts | 2 +- .../vsce/src/commands/openLocalFileCommand.ts | 2 +- 6 files changed, 44 insertions(+), 31 deletions(-) diff --git a/packages/sdk/src/constants/CicsCmci.constants.ts b/packages/sdk/src/constants/CicsCmci.constants.ts index 059dbc3e..d7cd569e 100644 --- a/packages/sdk/src/constants/CicsCmci.constants.ts +++ b/packages/sdk/src/constants/CicsCmci.constants.ts @@ -100,9 +100,24 @@ export const CicsCmciConstants = { PARAMETER: "PARAMETER", /** - * The CICS CMCI external resource names + * The CICS CMCI transaction definition */ - CICS_CMCI_EXTERNAL_RESOURCES: ["CICSLocalTransaction", "CICSRemoteTransaction", "CICSDefinitionTransaction", "CICSLocalFile"], + CICS_CMCI_TRANSACTION_DEFINITION: "CICSDefinitionTransaction", + + /** + * The CICS CMCI local transaction + */ + CICS_CMCI_LOCAL_TRANSACTION: "CICSLocalTransaction", + + /** + * The CICS CMCI remote transaction + */ + CICS_CMCI_REMOTE_TRANSACTION: "CICSRemoteTransaction", + + /** + * The CICS CMCI local file + */ + CICS_CMCI_LOCAL_FILE: "CICSLocalFile", /** * CICSTask parameter diff --git a/packages/sdk/src/utils/Utils.ts b/packages/sdk/src/utils/Utils.ts index e3eea19f..9d45a7b9 100644 --- a/packages/sdk/src/utils/Utils.ts +++ b/packages/sdk/src/utils/Utils.ts @@ -31,36 +31,34 @@ export class Utils { let delimiter = "?"; // initial delimiter - const cicsPlex = (options && options.cicsPlex) == null ? "" : `${encodeURIComponent(options.cicsPlex)}/`; - const region = (options && options.regionName) == null ? "" : encodeURIComponent(options.regionName); + const cicsPlex = options?.cicsPlex == null ? "" : `${encodeURIComponent(options.cicsPlex)}/`; + const region = options?.regionName == null ? "" : encodeURIComponent(options.regionName); let cmciResource = `/${CicsCmciConstants.CICS_SYSTEM_MANAGEMENT}/${resourceName}/${cicsPlex}${region}`; - if (options) { - if (options.criteria) { - cmciResource += `${delimiter}${CicsCmciConstants.CRITERIA}=${this.enforceParentheses(encodeURIComponent(options.criteria))}`; - delimiter = "&"; - } + if (options?.criteria) { + cmciResource += `${delimiter}${CicsCmciConstants.CRITERIA}=${this.enforceParentheses(encodeURIComponent(options.criteria))}`; + delimiter = "&"; + } - if (options.parameter) { - cmciResource += `${delimiter}PARAMETER=${encodeURIComponent(options.parameter)}`; - delimiter = "&"; - } + if (options?.parameter) { + cmciResource += `${delimiter}PARAMETER=${encodeURIComponent(options.parameter)}`; + delimiter = "&"; + } - if (options.queryParams && options.queryParams.summonly) { - cmciResource += `${delimiter}${CicsCmciConstants.SUMM_ONLY}`; - delimiter = "&"; - } + if (options?.queryParams?.summonly) { + cmciResource += `${delimiter}${CicsCmciConstants.SUMM_ONLY}`; + delimiter = "&"; + } - if (options.queryParams && options.queryParams.nodiscard) { - cmciResource += `${delimiter}${CicsCmciConstants.NO_DISCARD}`; - delimiter = "&"; - } + if (options?.queryParams?.nodiscard) { + cmciResource += `${delimiter}${CicsCmciConstants.NO_DISCARD}`; + delimiter = "&"; + } - if (options.queryParams && options.queryParams.overrideWarningCount) { - cmciResource += `${delimiter}${CicsCmciConstants.OVERRIDE_WARNING_COUNT}`; - delimiter = "&"; - } + if (options?.queryParams?.overrideWarningCount) { + cmciResource += `${delimiter}${CicsCmciConstants.OVERRIDE_WARNING_COUNT}`; + delimiter = "&"; } return cmciResource; @@ -71,7 +69,7 @@ export class Utils { let cmciResource = `/${CicsCmciConstants.CICS_SYSTEM_MANAGEMENT}/${CicsCmciConstants.CICS_RESULT_CACHE}/${cacheToken}`; - if (options && options.startIndex) { + if (options?.startIndex) { cmciResource += `/${options.startIndex}`; if (options.count) { @@ -87,7 +85,7 @@ export class Utils { delimiter = "&"; } - if (options && options.summonly) { + if (options?.summonly) { cmciResource += `${delimiter}${CicsCmciConstants.SUMM_ONLY}`; } diff --git a/packages/vsce/src/commands/closeLocalFileCommand.ts b/packages/vsce/src/commands/closeLocalFileCommand.ts index 08cfceb0..62d23a3e 100644 --- a/packages/vsce/src/commands/closeLocalFileCommand.ts +++ b/packages/vsce/src/commands/closeLocalFileCommand.ts @@ -149,7 +149,7 @@ async function closeLocalFile( "criteria": `FILE='${parms.name}'` }; - const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_CMCI_EXTERNAL_RESOURCES[3], options); + const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_CMCI_LOCAL_FILE, options); return await CicsCmciRestClient.putExpectParsedXml(session, cmciResource, [], requestBody); } diff --git a/packages/vsce/src/commands/disableCommands/disableLocalFileCommand.ts b/packages/vsce/src/commands/disableCommands/disableLocalFileCommand.ts index 4815103c..e2f5d7b6 100644 --- a/packages/vsce/src/commands/disableCommands/disableLocalFileCommand.ts +++ b/packages/vsce/src/commands/disableCommands/disableLocalFileCommand.ts @@ -137,7 +137,7 @@ async function disableLocalFile( "criteria": `FILE='${parms.name}'` }; - const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_CMCI_EXTERNAL_RESOURCES[3], options); + const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_CMCI_LOCAL_FILE, options); return await CicsCmciRestClient.putExpectParsedXml(session, cmciResource, [], requestBody); } diff --git a/packages/vsce/src/commands/enableCommands/enableLocalFileCommand.ts b/packages/vsce/src/commands/enableCommands/enableLocalFileCommand.ts index 5c60bbba..417616b5 100644 --- a/packages/vsce/src/commands/enableCommands/enableLocalFileCommand.ts +++ b/packages/vsce/src/commands/enableCommands/enableLocalFileCommand.ts @@ -116,7 +116,7 @@ async function enableLocalFile(session: imperative.AbstractSession, parms: { nam "criteria": `FILE='${parms.name}'` }; - const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_CMCI_EXTERNAL_RESOURCES[3], options); + const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_CMCI_LOCAL_FILE, options); return await CicsCmciRestClient.putExpectParsedXml(session, cmciResource, [], requestBody); } diff --git a/packages/vsce/src/commands/openLocalFileCommand.ts b/packages/vsce/src/commands/openLocalFileCommand.ts index e3c3712f..2251786c 100644 --- a/packages/vsce/src/commands/openLocalFileCommand.ts +++ b/packages/vsce/src/commands/openLocalFileCommand.ts @@ -126,7 +126,7 @@ async function openLocalFile(session: imperative.AbstractSession, parms: { name: "criteria": `FILE='${parms.name}'` }; - const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_CMCI_EXTERNAL_RESOURCES[3], options); + const cmciResource = Utils.getResourceUri(CicsCmciConstants.CICS_CMCI_LOCAL_FILE, options); return await CicsCmciRestClient.putExpectParsedXml(session, cmciResource, [], requestBody); }