/****************************************************************************/
/****************************************************************************/
///
import { ReadStream } from 'fs';
import { ConnectionOption } from './interfaces/ConnectionOption';
import { DatasetEntry } from './interfaces/DatasetEntry';
import { DatasetMemberEntry } from './interfaces/DatasetMemberEntry';
import { Job, JobStatus } from './interfaces/Job';
import { JobIdOption, JobLogOption } from './interfaces/JobIdOption';
import { JobListOption } from './interfaces/JobListOption';
import { USSEntry } from './interfaces/USSEntry';
/**
* Dataset allocation parameters, like
*
* ```
* {
* LRECL: 80,
* RECFM: 'FB'
* }
* ```
*/
interface AllocateParams {
[key: string]: string | number | boolean;
}
declare type Input = NodeJS.ReadableStream | Buffer | string;
/**
* Data transfer mode.
*/
export declare enum TransferMode {
/**
* The data is transferred in text mode, in which encoding conversion like ASCII/EBCDIC will happen.
*/
ASCII = "ascii",
/**
* The data is transferred in text mode, in which encoding conversion like ASCII/EBCDIC will happen, and
* the EOL of each record in dataset will be removed.
*/
ASCII_STRIP_EOL = "ascii_strip_eol",
/**
* The data is transferred in text mode, in which the trailing blanks will be removed.
*/
ASCII_NO_TRAILING_BLANKS = "ascii_no_trailing_blanks",
/**
* The data is transferred in binary mode, in which no encoding conversion will happen.
*/
BINARY = "binary",
/**
* The data is transferred in rdw mode, in which variable length dataset downloading is available.
*/
ASCII_RDW = "ascii_rdw",
/**
* The data is transferred in rdw mode, in which variable length dataset downloading is available.
*/
BINARY_RDW = "binary_rdw"
}
/**
* Job status result.
*/
export declare enum JobStatusResult {
SUCCESS = "success",
ACTIVE = "active",
FAIL = "fail",
WAITING = "waiting",
NOT_FOUND = "not found"
}
/**
* USS file type to operate.
*/
export declare enum FileToOperate {
/**
* Operate against one file or directory
*/
FILE_OR_DIRECTORY = 0,
/**
* Operate against the whole directory, including any file/directory under it.
*/
WHOLE_DIRECTORY = 1
}
declare class ZosAccessor {
private client;
private connected;
private username?;
private maxBufferSize;
/**
* Indicates zos-node-accessor in migration mode.
*/
private migrationMode;
constructor();
/**
* Set the max buffer size for downloading.
*
* @param maxBufferSize - Max buffer size in byte
*/
setMaxBufferSize(maxBufferSize: number): void;
/**
* Returns the max buffer size for downloading.
*
* @returns Max buffer size for downloading
*/
getMaxBufferSize(): number;
/**
* Sets zos-node-accessor to migration mode, which keeps the original key/value pair field in
* `DatasetEntry`, 'DatasetMemberEntry`, `UssEntry`, and `SpoolFile`, so that it makes the
* migration from v1.0.x to v2.x easy.
*
* @param migrationMode - True to enable migration mode
*/
setMigrationMode(migrationMode: boolean): void;
/**
* Returns true if it's connected to z/OS FTP service successfully.
*
* @returns True if it's connected to z/OS FTP service successfully.
*/
isConnected(): boolean;
/**
* Connects to z/OS FTP service.
*
* @param option - The option for connecting z/OS FTP service
* @returns This ZosAccessor object if success
*/
connect(option: ConnectionOption): Promise;
/**
* Closes the connection to z/OS FTP service.
*/
close(): Promise;
/**
* Submits SITE commands.
*
* @param siteCommands site commands separated with space
* @returns what's returned from server
*/
site(siteCommands: string): Promise;
/**
* Submits STAT command to query server status.
*
* @param option optional option. If not specified, query for all status.
* @returns what's returned from server
*/
stat(option?: string): Promise;
/**
* Sends any command that FTP can understand with SEND.
*
* @param command command to send
* @returns what's returned from server
*/
send(command: string): Promise;
/**
* Makes USS directory with the given directory name.
*
* @param directoryName - Directory name
* @returns Promise to return void
*/
makeDirectory(directoryName: string): Promise;
/**
* Allocates the sequential or partition (with the DCB attribut "PDSTYPE=PDS") dataset.
* These attributes are transferred as FTP site sub commands. The tested attributes includes:
*
* ```
* BLKsize/BLOCKSIze, BLocks, CYlinders, Directory, LRecl, PDSTYPE, PRImary, RECfm, SECondary, and TRacks
* ```
*
* @param datasetName - Name of the dataset to allocate
* @param allocateParamsOrString - String of space separated DCB attributes or the object of DCB attribute
* key-value pairs. eg. "LRECL=80 RECFM=FB" or {"LRECL": 80, "RECFM": "FB"}.
* @returns Promise to return void
*/
allocateDataset(datasetName: string, allocateParamsOrString?: string | AllocateParams): Promise;
private upload;
/**
* Uploads data to the specified dataset on z/OS. The tested attributes for `allocateParamsOrString` includes:
* These attributes are transferred as FTP site sub commands. The tested attributes includes:
*
* ```
* BLKsize/BLOCKSIze, BLocks, CYlinders, Directory, LRecl, PDSTYPE, PRImary, RECfm, SECondary, and TRacks
* ```
*
* @param input - Input, which can be a ReadableStream, a Buffer, or a path to a local file.
* @param destDataset - Name of the dataset to store the uploaded data.
* @param transferMode - Data transfer mode, either TransferMode.ASCII or TransferMode.BINARY.
* When transfering 'ascii' files, the end-of-line sequence of input should always be '\r\n'.
* Otherwise the transfered file will get truncated.
* @param allocateParamsOrString - A string of space separated DCB attributes or an object of DCB attribute
* key-value pairs. eg. "LRECL=80 RECFM=FB" or {"LRECL": 80, "RECFM": "FB"}.
*/
uploadDataset(input: Input, destDataset: string, transferMode?: TransferMode, allocateParamsOrString?: string | AllocateParams): Promise;
/**
* Upload data to the specified USS file on z/OS.
*
* @param input - Input, which can be a ReadableStream, a Buffer, or a path to a local file.
* @param destFilePath - Path name of the destination file on z/OS.
* @param transferMode - Data transfer mode, either TransferMode.ASCII or TransferMode.BINARY
*/
uploadFile(input: Input, destFilePath: string, transferMode?: TransferMode): Promise;
private download;
/**
* Downloads the specified dataset or member of patition dataset.
*
* @param dsn - Dataset name
* @param transferMode - TransferMode.ASCII, TransferMode.ASCII_RDW, TransferMode.ASCII_STRIP_EOL,
* TransferMode.ASCII_NO_TRAILING_BLANKS, TransferMode.BINARY, or TransferMode.BINARY_RDW.
* The `TransferMode.ASCII`, ` TransferMode.ASCII_RDW`, `TransferMode.ASCII_STRIP_EOL`,
* or TransferMode.ASCII_NO_TRAILING_BLANKS asks z/OS FTP service to
* convert `EBCDIC` characters to `ASCII`. `TransferMode.ASCII_STRIP_EOL` asks z/OS FTP
* service not to append a `CLRF` to the end of each record. The
* `TransferMode.ASCII_NO_TRAILING_BLANKS` asks z/OS FTP service to remove trailing blanks.
* `TransferMode.ASCII_RDW` and
* `TransferMode.BINARY_RDW` support to download variable length dataset, which add 4-byte
* Record Description Word (RDW) at the beginning of each record.
* @param {boolean} stream - `true` if you want to obtain a `ReadStream` of the data set content, or `false`
* to read a full dataset into memory (in Buffer). The buffer accepts up to 4MB data.
* For large dataset, use `stream=true` instead.
* @param {string} siteParams - Add extra site parameters, for example, 'sbd=(IBM-1047,ISO8859-1)' for encoding
* setting.
* @returns `ReadStream` or `Buffer`
*/
downloadDataset(dsn: string, transferMode?: TransferMode, stream?: boolean, siteParams?: string): Promise;
/**
* Downloads the specified USS file.
*
* @param filePath - USS file path name
* @param transferMode - TransferMode.ASCII, TransferMode.BINARY
* When downloading a text dataset, transferMode should be either `TransferMode.ASCII`
* so that z/OS FTP service converts `EBCDIC` characters to `ASCII`.
* @param {boolean} stream - `true` if you want to obtain a `ReadStream` of the data set content, or `false`
* to read a full dataset into memory (in Buffer). The buffer accepts up to 4MB data.
* For large dataset, use `stream=true` instead.
* @returns `ReadStream` or `Buffer`
*/
downloadFile(filePath: string, transferMode?: TransferMode, stream?: boolean): Promise;
private list;
/**
* Lists the datasets whose names match with the given dataset name.
*
* @param dsn - Full qualified name of dataset, or datadata name with wildcards (* or ?)
* @returns Dataset entries
*/
listDatasets(dsn: string): Promise;
/**
* Lists the members of partition dataset.
*
* @param partitionDsn - Full qualified name of patition dataset
* @returns Dataset member entries
*/
listMembers(partitionDsn: string): Promise;
/**
* Lists files whose names match with the given path name.
*
* @param dirPath - Directory to list or file name with widecards (* or ?)
* @returns USS file entries
*/
listFiles(dirPath: string): Promise;
/**
* Deletes the dataset or member of parition datate whose names match with the given dataset name.
*
* @param dsn - Full qualified name of dataset. The datadata name with wildcards (* or ?) is not supported.
*/
deleteDataset(dsn: string): Promise;
/**
* Deletes the USS files or directory whose names match with the given file path.
*
* @param filePath - The path name of USS file or directory. The path name with wildcards (* or ?) is not supported.
* @param fileType - Either FILE_OR_DIRECTORY or WHOLE_DIRECTORY
*/
deleteFile(filePath: string, fileType?: FileToOperate): Promise;
private rename;
/**
* Renames dataset, member in partition dataset.
*
* @param dsn Current name
* @param newDsn New name
*/
renameDataset(dsn: string, newDsn: string): Promise;
/**
* Renames USS file/directory.
*
* @param name Current name
* @param newName New name
*/
renameFile(name: string, newName: string): Promise;
/**
* Lists the jobs matching the given query option. If the query option is not provided, it will list all jobs
* of the current user.
*
* @param queryOption - Option which contains
* jobName: Job name, which is optional and can contain a wildcard (*)
* jobId: Job ID, which is optional
* owner: Job owner, which is optional and can contain a wildcard (*)
* status: Job status, eg. ALL, OUTPUT, which is optional
* @returns List of jobs
*/
listJobs(queryOption?: JobListOption): Promise;
/**
* Returns the status the job identified by job id and optional job name.
*
* @param queryOption - Option which contains
* jobId: Job ID, which is required
* owner: Job owner, which is optional
* @returns List of job status
*/
queryJob(queryOption: JobIdOption): Promise;
/**
* Returns the job RC by reading JESMSGLG.
*
* @param queryOption - Option which contains
* jobId: Job ID, which is required
* owner: Specify a JES job owner, which is optional and can contain a wildcard (*)
* @returns RC number or error string
*/
getRCFromJESMSGLG(queryOption: JobLogOption): Promise;
/**
* Returns the status of the job specified by query option. Example of the returned job status:
*
* ```
* {
* jobname: "HRECALLW",
* jobid: "JOB06385",
* owner: "USER",
* status: "OUTPUT",
* class: "A",
* rc: 0,
* spoolFiles: [
* {
* id: 2,
* stepName: "JES2",
* procStep: "N/A",
* class: "H",
* ddName: "JESJCL",
* byteCount: 315
* }
* ]
* }
* ```
*
* @param queryOption - Option which contains
* jobId: Job ID, which is required
* owner: Job owner, which is optional and can contain a wildcard (*)
* @returns Job status
*/
getJobStatus(queryOption: JobIdOption): Promise;
/**
* Returns job spool files identified by jobId.
*
* @param queryOption - Option which contains
* jobId: Job ID, which is required
* fileId: Spool file index (1, 2, 3...) or
* -1 - return all spool files joined with the `!! END OF JES SPOOL FILE !!`
* owner: Specify a JES job owner, which is optional and can contain a wildcard (*)
* @return Job log file contents
*/
getJobLog(queryOption: JobLogOption): Promise;
/**
* Deletes the job of the specified job id.
*
* @param queryOption - Option which contains
* jobId: Job ID, which is required
* owner: Job owner, which is optional and can contain a wildcard (*)
*/
deleteJob(queryOption: JobIdOption): Promise;
/**
* Submits job with the specified JCL text.
*
* @param jclText JCL text to submit
* @return Job ID
*/
submitJCL(jclText: string): Promise;
/**
* Convert allocate params object to name/value pair string.
*/
private allocateParamsToString;
/**
* Check the length of jobname and job owner. If it longer than 8 characters throw an error.
*
* @param jobname the jobname or prefix
* @param owner the owner of job
*/
private checkJobNameAndOwner;
}
export { ZosAccessor };
export { ConnectionOption } from "./interfaces/ConnectionOption";
export { DatasetEntry } from "./interfaces/DatasetEntry";
export { DatasetMemberEntry } from "./interfaces/DatasetMemberEntry";
export { Entry } from "./interfaces/Entry";
export { Job, JobStatus } from "./interfaces/Job";
export { JobLogOption, JobIdOption } from "./interfaces/JobIdOption";
export { JobListOption } from "./interfaces/JobListOption";
export { LoadLibMemberEntry } from "./interfaces/LoadLibMemberEntry";
export { SpoolFile } from "./interfaces/SpoolFile";
export { USSEntry, FileType } from "./interfaces/USSEntry";