@halcyontech/vscode-ibmi-types 2.13.0 → 2.13.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/api/IBMi.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as node_ssh from "node-ssh";
2
2
  import * as vscode from "vscode";
3
- import { ConnectionConfiguration } from "./Configuration";
4
- import { ComponentId } from "../components/component";
3
+ import { IBMiComponent, IBMiComponentType } from "../components/component";
5
4
  import { CommandData, CommandResult, ConnectionData, IBMiMember, RemoteCommand, SpecialAuthorities } from "../typings";
5
+ import { ConnectionConfiguration } from "./Configuration";
6
6
  import IBMiContent from "./IBMiContent";
7
7
  import { Tools } from './Tools';
8
8
  export interface MemberParts extends IBMiMember {
@@ -13,7 +13,7 @@ export default class IBMi {
13
13
  private jobCcsid;
14
14
  /** User default CCSID is job default CCSID */
15
15
  private userDefaultCCSID;
16
- private components;
16
+ private componentManager;
17
17
  client: node_ssh.NodeSSH;
18
18
  currentHost: string;
19
19
  currentPort: number;
@@ -95,7 +95,7 @@ export default class IBMi {
95
95
  * @param {string} key Key to the temp file to be re-used
96
96
  */
97
97
  getTempRemote(key: string): string;
98
- parserMemberPath(string: string): MemberParts;
98
+ parserMemberPath(string: string, checkExtension?: boolean): MemberParts;
99
99
  /**
100
100
  * @param {string} string
101
101
  * @returns {string} result
@@ -127,7 +127,7 @@ export default class IBMi {
127
127
  * @param name
128
128
  */
129
129
  upperCaseName(name: string): string;
130
- getComponent<T>(id: ComponentId): T;
130
+ getComponent<T extends IBMiComponent>(type: IBMiComponentType<T>, ignoreState?: boolean): T | undefined;
131
131
  /**
132
132
  * Run SQL statements.
133
133
  * Each statement must be separated by a semi-colon and a new line (i.e. ;\n).
@@ -12,7 +12,6 @@ export declare type SortOptions = {
12
12
  };
13
13
  export default class IBMiContent {
14
14
  readonly ibmi: IBMi;
15
- private chgJobCCSID;
16
15
  constructor(ibmi: IBMi);
17
16
  private get config();
18
17
  private getTempRemote;
@@ -149,7 +148,7 @@ export default class IBMiContent {
149
148
  type: string;
150
149
  member?: string;
151
150
  }, authorities?: Authority[]): Promise<boolean>;
152
- testStreamFile(path: string, right: "f" | "d" | "r" | "w" | "x"): Promise<boolean>;
151
+ testStreamFile(path: string, right: "e" | "f" | "d" | "r" | "w" | "x"): Promise<boolean>;
153
152
  isProtectedPath(path: string): boolean;
154
153
  /**
155
154
  *
@@ -169,5 +168,11 @@ export default class IBMiContent {
169
168
  sourcePhysicalFileToToolTip(path: string, object: IBMiObject): Promise<MarkdownString>;
170
169
  memberToToolTip(path: string, member: IBMiMember): MarkdownString;
171
170
  ifsFileToToolTip(path: string, ifsFile: IFSFile): MarkdownString;
171
+ /**
172
+ * Creates an empty unicode streamfile
173
+ * @param path the full path to the streamfile
174
+ * @throws an Error if the file could not be correctly created
175
+ */
176
+ createStreamFile(path: string): Promise<void>;
172
177
  }
173
178
  export {};
package/api/Search.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { IBMiMember, SearchResults } from '../typings';
2
2
  import Instance from './Instance';
3
3
  export declare namespace Search {
4
- function searchMembers(instance: Instance, library: string, sourceFile: string, searchTerm: string, members: IBMiMember[] | string, readOnly?: boolean): Promise<SearchResults>;
4
+ function searchMembers(instance: Instance, library: string, sourceFile: string, searchTerm: string, members: string | IBMiMember[], readOnly?: boolean): Promise<SearchResults>;
5
5
  function searchIFS(instance: Instance, path: string, searchTerm: string): Promise<SearchResults | undefined>;
6
6
  function findIFS(instance: Instance, path: string, findTerm: string): Promise<SearchResults | undefined>;
7
7
  }
package/api/Tools.d.ts CHANGED
@@ -70,6 +70,7 @@ export declare namespace Tools {
70
70
  function fixSQL(statement: string, removeComments?: boolean): string;
71
71
  function generateTooltipHtmlTable(header: string, rows: Record<string, any>): string;
72
72
  function fixWindowsPath(path: string): string;
73
+ function assumeType(str: string): string | number;
73
74
  /**
74
75
  * Runs a function while a context value is set to true.
75
76
  *
@@ -79,4 +80,10 @@ export declare namespace Tools {
79
80
  * @param task the function to run while the context value is `true`
80
81
  */
81
82
  function withContext<T>(context: string, task: () => Promise<T>): Promise<T>;
83
+ /**
84
+ * Converts a timestamp from the attr command (in the form `Thu Dec 21 21:47:02 2023`) into a Date object
85
+ * @param timestamp an attr timestamp string
86
+ * @returns a Date object
87
+ */
88
+ function parseAttrDate(timestamp: string): number;
82
89
  }
@@ -1,3 +1,4 @@
1
+ import IBMi from "../IBMi";
1
2
  declare type ConfigLine = {
2
3
  key: string;
3
4
  value?: string;
@@ -31,5 +32,5 @@ interface DebugServiceDetails {
31
32
  }
32
33
  export declare function resetDebugServiceDetails(): void;
33
34
  export declare function getDebugServiceDetails(): Promise<DebugServiceDetails>;
34
- export declare function getJavaHome(version: string): "/QOpenSys/QIBM/ProdData/JavaVM/jdk11/64bit" | "/QOpenSys/QIBM/ProdData/JavaVM/jdk80/64bit";
35
+ export declare function getJavaHome(connection: IBMi, version: string): string;
35
36
  export {};
@@ -1,32 +1,56 @@
1
1
  import IBMi from "../api/IBMi";
2
- import { CopyToImport } from "./copyToImport";
3
- import { GetMemberInfo } from "./getMemberInfo";
4
- import { GetNewLibl } from "./getNewLibl";
5
- export declare enum ComponentState {
6
- NotChecked = "NotChecked",
7
- NotInstalled = "NotInstalled",
8
- Installed = "Installed",
9
- Error = "Error"
10
- }
11
- interface ComponentRegistry {
12
- GetNewLibl?: GetNewLibl;
13
- CopyToImport?: CopyToImport;
14
- GetMemberInfo?: GetMemberInfo;
15
- }
16
- export declare type ComponentId = keyof ComponentRegistry;
17
- export declare abstract class ComponentT {
18
- connection: IBMi;
19
- state: ComponentState;
20
- currentVersion: number;
2
+ export declare type ComponentState = `NotChecked` | `NotInstalled` | `Installed` | `NeedsUpdate` | `Error`;
3
+ export declare type ComponentIdentification = {
4
+ name: string;
5
+ version: number;
6
+ };
7
+ export declare type IBMiComponentType<T extends IBMiComponent> = new (c: IBMi) => T;
8
+ /**
9
+ * Defines a component that is managed per IBM i.
10
+ *
11
+ * Any class extending {@link IBMiComponent} needs to register itself in the Component Registry.
12
+ *
13
+ * For example, this class:
14
+ * ```
15
+ * class MyIBMIComponent extends IBMiComponent {
16
+ * //implements getName(), getRemoteState() and update()
17
+ * }
18
+ * ```
19
+ * Must be registered like this, when the extension providing the component gets activated:
20
+ * ```
21
+ * export async function activate(context: ExtensionContext) {
22
+ * const codeForIBMiExtension = vscode.extensions.getExtension<CodeForIBMi>('halcyontechltd.code-for-ibmi');
23
+ * if (codeForIBMiExtension) {
24
+ * codeForIBMi = codeForIBMiExtension.isActive ? codeForIBMiExtension.exports : await codeForIBMiExtension.activate();
25
+ * codeForIBMi.componentRegistry.registerComponent(context, MyIBMIComponent);
26
+ * }
27
+ * }
28
+ * ```
29
+ *
30
+ */
31
+ export declare abstract class IBMiComponent {
32
+ protected readonly connection: IBMi;
33
+ private state;
21
34
  constructor(connection: IBMi);
22
- abstract getInstalledVersion(): Promise<number | undefined>;
23
- abstract checkState(): Promise<boolean>;
24
- abstract getState(): ComponentState;
25
- }
26
- export declare class ComponentManager {
27
- private registered;
28
- startup(connection: IBMi): Promise<void>;
29
- get<T>(id: ComponentId): T | undefined;
30
- private static checkState;
35
+ getState(): ComponentState;
36
+ check(): Promise<this>;
37
+ toString(): string;
38
+ /**
39
+ * The name of this component; mainly used for display and logging purposes
40
+ *
41
+ * @returns a human-readable name
42
+ */
43
+ abstract getIdentification(): ComponentIdentification;
44
+ /**
45
+ * @returns the component's {@link ComponentState state} on the IBM i
46
+ */
47
+ protected abstract getRemoteState(): ComponentState | Promise<ComponentState>;
48
+ /**
49
+ * Called whenever the components needs to be installed or updated, depending on its {@link ComponentState state}.
50
+ *
51
+ * The Component Manager is responsible for calling this, so the {@link ComponentState state} doesn't need to be checked here.
52
+ *
53
+ * @returns the component's {@link ComponentState state} after the update is done
54
+ */
55
+ protected abstract update(): ComponentState | Promise<ComponentState>;
31
56
  }
32
- export {};
@@ -1,15 +1,12 @@
1
- import IBMi from "../api/IBMi";
2
1
  import { WrapResult } from "../typings";
3
- import { ComponentState, ComponentT } from "./component";
4
- export declare class CopyToImport implements ComponentT {
5
- connection: IBMi;
6
- private readonly name;
7
- state: ComponentState;
8
- currentVersion: number;
9
- constructor(connection: IBMi);
10
- getInstalledVersion(): Promise<number>;
11
- checkState(): Promise<boolean>;
12
- getState(): ComponentState;
2
+ import { ComponentState, IBMiComponent } from "./component";
3
+ export declare class CopyToImport extends IBMiComponent {
13
4
  static isSimple(statement: string): boolean;
5
+ getIdentification(): {
6
+ name: string;
7
+ version: number;
8
+ };
9
+ protected getRemoteState(): ComponentState;
10
+ protected update(): ComponentState | Promise<ComponentState>;
14
11
  wrap(statement: string): WrapResult;
15
12
  }
@@ -1,19 +1,15 @@
1
- import IBMi from "../api/IBMi";
2
1
  import { IBMiMember } from "../typings";
3
- import { ComponentState, ComponentT } from "./component";
4
- export declare class GetMemberInfo implements ComponentT {
5
- connection: IBMi;
6
- readonly name = "GETMBRINFO";
7
- state: ComponentState;
8
- currentVersion: number;
9
- constructor(connection: IBMi);
10
- getInstalledVersion(): Promise<number>;
11
- checkState(): Promise<boolean>;
12
- getState(): ComponentState;
13
- /**
14
- *
15
- * @param filter: the criterias used to list the members
16
- * @returns
17
- */
2
+ import { ComponentState, IBMiComponent } from "./component";
3
+ export declare class GetMemberInfo extends IBMiComponent {
4
+ private readonly procedureName;
5
+ private readonly currentVersion;
6
+ private installedVersion;
7
+ getIdentification(): {
8
+ name: string;
9
+ version: number;
10
+ };
11
+ protected getRemoteState(): Promise<ComponentState>;
12
+ protected update(): Promise<ComponentState>;
18
13
  getMemberInfo(library: string, sourceFile: string, member: string): Promise<IBMiMember | undefined>;
14
+ getMultipleMemberInfo(members: IBMiMember[]): Promise<IBMiMember[] | undefined>;
19
15
  }
@@ -1,15 +1,13 @@
1
- import IBMi from "../api/IBMi";
2
- import { ComponentState, ComponentT } from "./component";
3
- export declare class GetNewLibl implements ComponentT {
4
- connection: IBMi;
5
- state: ComponentState;
6
- currentVersion: number;
7
- constructor(connection: IBMi);
8
- getInstalledVersion(): Promise<number>;
9
- checkState(): Promise<boolean>;
10
- getState(): ComponentState;
1
+ import { ComponentState, IBMiComponent } from "./component";
2
+ export declare class GetNewLibl extends IBMiComponent {
3
+ getIdentification(): {
4
+ name: string;
5
+ version: number;
6
+ };
7
+ protected getRemoteState(): Promise<ComponentState>;
8
+ protected update(): Promise<ComponentState>;
11
9
  getLibraryListFromCommand(ileCommand: string): Promise<{
12
10
  currentLibrary: string;
13
11
  libraryList: string[];
14
- } | undefined>;
12
+ }>;
15
13
  }
@@ -0,0 +1,16 @@
1
+ import vscode from "vscode";
2
+ import IBMi from "../api/IBMi";
3
+ import { IBMiComponent, IBMiComponentType } from "./component";
4
+ export declare class ComponentRegistry {
5
+ private readonly components;
6
+ registerComponent(context: vscode.ExtensionContext, component: IBMiComponentType<any>): void;
7
+ getComponents(): Map<string, IBMiComponentType<any>[]>;
8
+ }
9
+ export declare const extensionComponentRegistry: ComponentRegistry;
10
+ export declare class ComponentManager {
11
+ private readonly connection;
12
+ private readonly registered;
13
+ constructor(connection: IBMi);
14
+ startup(): Promise<void>;
15
+ get<T extends IBMiComponent>(type: IBMiComponentType<T>, ignoreState?: boolean): T | undefined;
16
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@halcyontech/vscode-ibmi-types",
3
- "version": "2.13.0",
3
+ "version": "2.13.3",
4
4
  "description": "Types for vscode-ibmi",
5
5
  "typings": "./typings.d.ts",
6
6
  "scripts": {
package/typings.d.ts CHANGED
@@ -6,12 +6,14 @@ import { CustomUI } from "./api/CustomUI";
6
6
  import Instance from "./api/Instance";
7
7
  import { Tools } from "./api/Tools";
8
8
  import { DeployTools } from "./api/local/deployTools";
9
+ import { ComponentRegistry } from './components/manager';
9
10
  export interface CodeForIBMi {
10
11
  instance: Instance;
11
12
  customUI: () => CustomUI;
12
13
  deployTools: typeof DeployTools;
13
14
  evfeventParser: (lines: string[]) => Map<string, FileError[]>;
14
15
  tools: typeof Tools;
16
+ componentRegistry: ComponentRegistry;
15
17
  }
16
18
  export declare type DeploymentMethod = "all" | "staged" | "unstaged" | "changed" | "compare";
17
19
  export interface DeploymentParameters {