@broadcom/jclcheck-for-zowe-cli
Version:
JCLCheck Plug-in for Zowe CLI
115 lines (114 loc) • 5.23 kB
JavaScript
;
/**
* Copyright (c) 2025. Broadcom. All rights reserved. The term
* "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
*
* This software and all information contained therein is
* confidential and proprietary and shall not be duplicated,
* used, disclosed, or disseminated in any way except as
* authorized by the applicable license agreement, without the
* express written permission of Broadcom. All authorized
* reproductions must be marked with this language.
* EXCEPT AS SET FORTH IN THE APPLICABLE LICENSE AGREEMENT, TO
* THE EXTENT PERMITTED BY APPLICABLE LAW, BROADCOM PROVIDES THIS
* SOFTWARE WITHOUT WARRANTY OF ANY KIND, INCLUDING WITHOUT
* LIMITATION, ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL BROADCOM
* BE LIABLE TO THE END USER OR ANY THIRD PARTY FOR ANY LOSS OR
* DAMAGE, DIRECT OR INDIRECT, FROM THE USE OF THIS SOFTWARE,
* INCLUDING WITHOUT LIMITATION, LOST PROFITS, BUSINESS
* INTERRUPTION, GOODWILL, OR LOST DATA, EVEN IF BROADCOM IS
* EXPRESSLY ADVISED OF SUCH LOSS OR DAMAGE.
*
**/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Check = void 0;
const imperative_1 = require("@zowe/imperative");
const JCLCheckRestClient_1 = require("../util/JCLCheckRestClient");
/**
* Node API set for JCLCHECK REST API service
*/
class Check {
/**
* Invokes the JCLCHECK REST API /check/jclContents endpoint, which checks the content provided in the body.
* @param session The Rest client session object containing the host/port/credentials/etc
* @param jcl The JCL contents to check
* @param options
*/
static jcl(session, jcl, options) {
return __awaiter(this, void 0, void 0, function* () {
imperative_1.Logger.getAppLogger().trace(`Checking input data set contents with options: ${options}`);
imperative_1.ImperativeExpect.toNotBeNullOrUndefined(session, "Required session must be defined");
imperative_1.ImperativeExpect.toBeDefinedAndNonBlank(jcl, "jcl");
let url;
if (session.ISession.basePath == null || session.ISession.basePath === "") {
url = this.context + this.contentResource;
}
else {
url = this.contentResource;
}
if (options != null) {
url = url.concat("?options=", options);
}
return JCLCheckRestClient_1.JCLCheckRestClient.putExpectJSON(session, encodeURI(url), [imperative_1.Headers.TEXT_PLAIN], jcl);
});
}
/**
* Invokes the JCLCHECK REST API /check/DataSet endpoint, which reads the contents of the data set
* provided in the URI and invokes the JCLCHECK service with the contents.
* @param session The Rest client session object containing the host/port/credentials/etc
* @param dataSet The MVS data set (PS or PDS member with LRECL 80, RECFM FB and must be cataloged)
* @param options The JCLCHECK runtime options
*/
static dataSet(session, dataSet, options) {
return __awaiter(this, void 0, void 0, function* () {
imperative_1.ImperativeExpect.toNotBeNullOrUndefined(session, "Required session must be defined");
imperative_1.ImperativeExpect.toBeDefinedAndNonBlank(dataSet, "data set");
let url;
if (session.ISession.basePath == null || session.ISession.basePath === "") {
url = this.context + this.dataSetResource(dataSet);
}
else {
url = this.dataSetResource(dataSet);
}
if (options != null) {
url = url.concat("?options=", encodeURIComponent(options));
}
return JCLCheckRestClient_1.JCLCheckRestClient.putExpectJSON(session, url, [{ "Accept": "*/*" }], undefined);
});
}
/**
* @param dataset The data set to read - placed into the URI
* @returns the URI for the data set minus the base path
*/
static dataSetResource(dataset) {
let ds = "";
if (dataset != null) {
ds = encodeURIComponent(dataset);
}
return `check/dataSet/${ds}`;
}
/**
* @returns the jcl content URI minus the base path
*/
static get contentResource() {
return "check/jclContent";
}
/**
* @returns the default base path
*/
static get context() {
return "api/v1/";
}
}
exports.Check = Check;
//# sourceMappingURL=Check.js.map