Skip to content

Commit

Permalink
done: Properly type the rest of the interfaces 😋
Browse files Browse the repository at this point in the history
Signed-off-by: zFernand0 <[email protected]>
  • Loading branch information
zFernand0 committed Jul 29, 2024
1 parent 2702e39 commit a791abb
Show file tree
Hide file tree
Showing 15 changed files with 117 additions and 88 deletions.
10 changes: 5 additions & 5 deletions packages/zowe-explorer-api/src/extend/MainframeInteraction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ export namespace MainframeInteraction {
getSession(profile?: imperative.IProfileLoaded): imperative.Session;

/**
* Create a session for the specific profile type.
* Retrieve the status of a specific profile.
*
* @param {imperative.IProfileLoaded} profile
* will use the profile the API was retrieved with by default
* @returns {IZosmfInfoResponse} z/OSMF Check Status response
* @param {imperative.IProfileLoaded} profile the profile for which we will retrieve the status
* @param {string} profileType the type of profile being requested
* @returns {Promise<string>} The status of the profile (e.g. active, inactive, unverified)
*/
getStatus?(profile: imperative.IProfileLoaded, profileType?): Promise<string>;
getStatus?(profile: imperative.IProfileLoaded, profileType?: string): Promise<string>;

/**
* Create a session for a set command arguments. The session will be created independent
Expand Down
2 changes: 1 addition & 1 deletion packages/zowe-explorer-api/src/fs/types/abstract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class BufferBuilder extends Duplex {
this.chunks = [];
}

public _write(chunk: any, encoding: BufferEncoding, callback: (error?: Error) => void): void {
public _write(chunk: any, _encoding: BufferEncoding, callback: (error?: Error) => void): void {
this.chunks.push(chunk);
callback();
}
Expand Down
77 changes: 67 additions & 10 deletions packages/zowe-explorer-api/src/tree/IZoweTreeNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@

import * as vscode from "vscode";
import * as imperative from "@zowe/imperative";
import * as zosjobs from "@zowe/zos-jobs-for-zowe-sdk";
import { Sorting } from "./sorting";
import { ZoweTreeNodeActions } from "./ZoweNodeActions";
import type { Types } from "../Types";
import { IJob } from "@zowe/zos-jobs-for-zowe-sdk";
import { IZosFilesResponse } from "@zowe/zos-files-for-zowe-sdk";

interface TextEncoding {
kind: "text";
Expand All @@ -30,6 +31,7 @@ interface OtherEncoding {
}

export type ZosEncoding = TextEncoding | BinaryEncoding | OtherEncoding;

export type EncodingMap = Record<string, ZosEncoding>;

/**
Expand All @@ -43,60 +45,74 @@ export interface IZoweTreeNode extends vscode.TreeItem {
* Indicator that the child data may have become stale and requires refreshing.
*/
dirty: boolean;

/**
* Describes the full path of a file
*/
fullPath?: string;

/**
* Children nodes of this node
*/
children?: IZoweTreeNode[];

/**
* Any ongoing actions that must be awaited before continuing
*/
ongoingActions?: Record<ZoweTreeNodeActions.Interactions | string, Promise<any>>;

/**
* whether the node was double-clicked
*/
wasDoubleClicked?: boolean;

/**
* Sorting method for this node's children
*/
sort?: Sorting.NodeSort;

/**
* Retrieves the node label
*/
getLabel(): string | vscode.TreeItemLabel;

/**
* Retrieves the nodes parent node
*/
getParent(): IZoweTreeNode;

/**
* Retrieves the nodes children nodes
*/
getChildren(): Promise<IZoweTreeNode[]>;

/**
* Retrieves the profile name in use with this node
*/
getProfileName(): string;

/**
* Retrieves the session node in use with this node
*/
getSessionNode(): IZoweTreeNode;

/**
* Retrieves the session object in use with this node
*/
getSession(): imperative.Session;

/**
* Retrieves the profile object in use with this node
*/
getProfile(): imperative.IProfileLoaded;

/**
* Set the profile to use for this node to be the one chosen in the parameters
*
* @param profileObj The profile you will set the node to use
*/
setProfileToChoice(profileObj: imperative.IProfileLoaded): void;

/**
* Set the session to use for this node to be the one chosen in the parameters
*
Expand All @@ -116,32 +132,38 @@ export interface IZoweDatasetTreeNode extends IZoweTreeNode {
* Search criteria for a Dataset search
*/
pattern?: string;

/**
* Search criteria for a Dataset member search
*/
memberPattern?: string;

/**
* @deprecated Please use `setStats` and `getStats` instead.
*
* Additional statistics about this data set
*/
stats?: Partial<Types.DatasetStats>;

/**
* Filter method for this data set's children
*/
filter?: Sorting.DatasetFilter;

/**
* @deprecated Please use `getEncodingInMap` and `updateEncodingInMap` instead.
*
* List of child nodes and user-selected encodings
*/
encodingMap?: Record<string, ZosEncoding>;

/**
* @deprecated Please use `setEncoding` and `getEncoding` instead.
*
* Binary indicator. Default false (text)
*/
binary?: boolean;

/**
* @deprecated Please use `setEncoding` and `getEncoding` instead.
*
Expand All @@ -151,24 +173,28 @@ export interface IZoweDatasetTreeNode extends IZoweTreeNode {
* * `undefined` = user did not specify
*/
encoding?: string;

/**
* Retrieves child nodes of this IZoweDatasetTreeNode
*
* @returns {Promise<IZoweDatasetTreeNode[]>}
*/
getChildren(): Promise<IZoweDatasetTreeNode[]>;

/**
* Retrieves the etag value for the file
*
* @returns {string}
*/
getEtag(): string | PromiseLike<string>;

/**
* Sets the etag value for the file
*
* @param {string}
*/
setEtag(etag: string): void | PromiseLike<void>;

/**
* Downloads and displays a file in a text editor view
*
Expand All @@ -177,12 +203,14 @@ export interface IZoweDatasetTreeNode extends IZoweTreeNode {
* @param datasetFileProvider the tree provider
*/
openDs?(download: boolean, previewFile: boolean, datasetFileProvider: Types.IZoweDatasetTreeType): Promise<void>;

/**
* Gets the codepage value for the file
*
* @param {string}
*/
getEncoding(): ZosEncoding | PromiseLike<ZosEncoding>;

/**
* Sets the codepage value for the file
*
Expand Down Expand Up @@ -224,25 +252,33 @@ export interface IZoweUSSTreeNode extends IZoweTreeNode {
* Retrieves an abridged for of the label
*/
shortLabel?: string;

/**
* Encoding indicator.
*/
encoding?: string;

/**
* @deprecated Please use `getEncodingInMap` and `updateEncodingInMap` instead.
*
* List of child nodes and user-selected encodings
*/
encodingMap?: Record<string, ZosEncoding>;

/**
* @deprecated Please use `getEncoding` and `setEncoding` instead.
*
* Binary indicator. Default false (text)
*/
binary?: boolean;

/**
* @deprecated Please use `setAttributes` and `getAttributes` instead.
*
* File attributes
*/
attributes?: Types.FileAttributes;

/**
* Event that fires whenever an existing node is updated.
*/
Expand Down Expand Up @@ -281,6 +317,7 @@ export interface IZoweUSSTreeNode extends IZoweTreeNode {
* @returns {string}
*/
getEtag(): string | PromiseLike<string>;

/**
* Sets the etag value for the file
*
Expand All @@ -303,71 +340,82 @@ export interface IZoweUSSTreeNode extends IZoweTreeNode {
*
* @param {string} newNamePath
*/
rename?(newNamePath: string);
rename?(newNamePath: string): Promise<IZosFilesResponse>;

/**
* Gets the codepage value for the file
*
* @param {string}
*/
getEncoding(): ZosEncoding | PromiseLike<ZosEncoding>;

/**
* Sets the codepage value for the file
*
* @param {string}
*/
setEncoding(encoding: ZosEncoding): void | PromiseLike<void>;

// /**
// * Opens the text document
// * @return vscode.TextDocument
// */
// getOpenedDocumentInstance?(): vscode.TextDocument;

/**
* Downloads and displays a file in a text editor view
*
* @param download Download the file default false
* @param preview the file, true or false
* @param ussFileProvider the tree provider
*/
openUSS?(download: boolean, previewFile: boolean, ussFileProvider: Types.IZoweUSSTreeType): Promise<void>;
openUSS?(download: boolean, previewFile: boolean, ussFileProvider: Types.IZoweUSSTreeType): void | Promise<void>;

/**
* Returns the local file path for the ZoweUSSNode
* @deprecated Zowe Explorer no longer uses local file paths for uploading and downloading USS files.
*/
getUSSDocumentFilePath?(): string;

/**
* Refreshes the node with current mainframe data
*
*/
refreshUSS?();
refreshUSS?(): void | Promise<void>;

/**
*
* @param ussFileProvider Deletes the USS tree node
* @param filePath
* @param cancelled optional
*/
deleteUSSNode?(ussFileProvider: Types.IZoweUSSTreeType, filePath: string, cancelled?: boolean);
deleteUSSNode?(ussFileProvider: Types.IZoweUSSTreeType, filePath: string, cancelled?: boolean): void | Promise<void>;

/**
* Process for renaming a USS Node. This could be a Favorite Node
*
* @param {USSTree} ussFileProvider
* @param {string} filePath
*/
renameUSSNode?(ussFileProvider: Types.IZoweUSSTreeType, filePath: string);
renameUSSNode?(ussFileProvider: Types.IZoweUSSTreeType, filePath: string): void | Promise<void>;

/**
* Reopens a file if it was closed (e.g. while it was being renamed).
* @param hasClosedInstance
*/
reopen?(hasClosedInstance?: boolean);
reopen?(hasClosedInstance?: boolean): void | Promise<void>;

/**
* Adds a search node to the USS favorites list
*
* @param {USSTree} ussFileProvider
*/
saveSearch?(ussFileProvider: Types.IZoweUSSTreeType);
saveSearch?(ussFileProvider: Types.IZoweUSSTreeType): void | Promise<void>;

/**
* Uploads a tree of USS file(s)/folder(s) to mainframe
*/
pasteUssTree?();
pasteUssTree?(): void | Promise<void>;
}

/**
Expand All @@ -381,43 +429,52 @@ export interface IZoweJobTreeNode extends IZoweTreeNode {
* Use Job-specific tree node for children.
*/
children?: IZoweJobTreeNode[];

/**
* Standard job response document
* Represents the attributes and status of a z/OS batch job
* @interface IJob
*/
job?: zosjobs.IJob;
job?: IJob;

/**
* Search criteria for a Job search
*/
searchId?: string;

/**
* Job Prefix i.e "MYJOB"
* Attribute of Job query
*/
prefix?: string;

/**
* Job Owner i.e "MYID"
* Attribute of Job query
*/
owner?: string;

/**
* Job Status i.e "ACTIVE"
* Attribute of Job query
*/
status?: string;

/**
* Returns whether the job node is a filtered search
*/
filtered?: boolean;

/**
* Filter method for this job search
*/
filter?: string;

/**
* Array of original filter search results job's children
*/
actualJobs?: IZoweTreeNode[];

/**
* Retrieves child nodes of this IZoweJobTreeNode
*
Expand Down
Loading

0 comments on commit a791abb

Please sign in to comment.