@halcyontech/vscode-ibmi-types 2.18.0 → 3.0.6

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.
Files changed (54) hide show
  1. package/Instance.d.ts +2 -1
  2. package/api/CCSIDs.d.ts +8 -0
  3. package/api/CompileTools.d.ts +2 -0
  4. package/api/Filter.d.ts +2 -2
  5. package/api/IBMi.d.ts +37 -32
  6. package/api/IBMiContent.d.ts +18 -33
  7. package/api/{Search.d.ts → SearchTools.d.ts} +1 -1
  8. package/api/Tools.d.ts +15 -21
  9. package/api/actions.d.ts +12 -0
  10. package/api/components/component.d.ts +30 -15
  11. package/api/components/manager.d.ts +6 -3
  12. package/api/components/mapepire/index.d.ts +25 -0
  13. package/api/components/mapepire/sqlJob.d.ts +20 -0
  14. package/api/components/mapepire/types.d.ts +7 -0
  15. package/api/components/mapepire/version.d.ts +4 -0
  16. package/api/components/runtime.d.ts +15 -5
  17. package/api/configuration/DebugConfiguration.d.ts +5 -6
  18. package/api/configuration/config/types.d.ts +13 -9
  19. package/api/configuration/serverFile.d.ts +2 -5
  20. package/api/configuration/storage/BaseStorage.d.ts +1 -2
  21. package/api/configuration/storage/CodeForIStorage.d.ts +14 -14
  22. package/api/configuration/storage/ConnectionStorage.d.ts +6 -3
  23. package/api/connectionProfiles.d.ts +14 -0
  24. package/api/password.d.ts +8 -0
  25. package/api/queue.d.ts +9 -0
  26. package/api/tests/components/customCli.d.ts +7 -4
  27. package/api/types.d.ts +34 -20
  28. package/commands/open.d.ts +1 -1
  29. package/config/passwords.d.ts +3 -0
  30. package/debug/certificates.d.ts +1 -1
  31. package/debug/index.d.ts +1 -1
  32. package/debug/server.d.ts +7 -8
  33. package/editors/actionEditor.d.ts +15 -0
  34. package/editors/connectionProfileEditor.d.ts +3 -0
  35. package/editors/customEditorProvider.d.ts +29 -0
  36. package/filesystems/local/deployTools.d.ts +6 -5
  37. package/filesystems/local/env.d.ts +1 -1
  38. package/filesystems/qsys/FSUtils.d.ts +4 -3
  39. package/filesystems/qsys/sourceDateHandler.d.ts +2 -0
  40. package/mergeProfiles.d.ts +1 -0
  41. package/package.json +1 -1
  42. package/typings.d.ts +14 -5
  43. package/ui/Tools.d.ts +5 -2
  44. package/ui/actions.d.ts +4 -4
  45. package/ui/connection.d.ts +2 -0
  46. package/ui/diagnostics.d.ts +1 -1
  47. package/ui/types.d.ts +8 -3
  48. package/uri/handler.d.ts +1 -1
  49. package/webviews/CustomUI.d.ts +19 -13
  50. package/api/components/copyToImport.d.ts +0 -14
  51. package/api/components/cqsh/index.d.ts +0 -17
  52. package/api/components/getMemberInfo.d.ts +0 -19
  53. package/api/components/getNewLibl.d.ts +0 -20
  54. package/filesystems/local/actions.d.ts +0 -5
package/Instance.d.ts CHANGED
@@ -11,6 +11,7 @@ export interface ConnectionOptions {
11
11
  }
12
12
  export default class Instance {
13
13
  private connection;
14
+ connected?: Promise<ConnectionResult>;
14
15
  private output;
15
16
  private storage;
16
17
  private emitter;
@@ -21,7 +22,7 @@ export default class Instance {
21
22
  getOutputContent(): string;
22
23
  private resetOutput;
23
24
  connect(options: ConnectionOptions): Promise<ConnectionResult>;
24
- disconnect(): Promise<void>;
25
+ disconnect(keepTabsOpened?: boolean): Promise<void>;
25
26
  private setConnection;
26
27
  getConnection(): IBMi;
27
28
  getLibraryList(connection: IBMi, workspaceFolder?: vscode.WorkspaceFolder): Promise<ILELibrarySettings>;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * CCSID (Coded Character Set Identifier) definitions
3
+ * This file contains a comprehensive list of CCSIDs used for character encoding conversions
4
+ */
5
+ export declare const CCSIDS: {
6
+ ccsid: string;
7
+ description: string;
8
+ }[];
@@ -10,7 +10,9 @@ export declare namespace CompileTools {
10
10
  interface RunCommandEvents {
11
11
  writeEvent?: (content: string) => void;
12
12
  commandConfirm?: (command: string) => Promise<string>;
13
+ updateProgress?: (message: string) => void;
13
14
  }
15
+ export function reset(): void;
14
16
  /**
15
17
  * Execute a command
16
18
  */
package/api/Filter.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- declare type Filter = {
1
+ type Filter = {
2
2
  test: (text: string) => boolean;
3
3
  noFilter: boolean;
4
4
  };
5
- export declare type FilterType = 'simple' | 'regex';
5
+ export type FilterType = 'simple' | 'regex';
6
6
  export declare function parseFilter(filterString?: string, type?: FilterType): Filter;
7
7
  /**
8
8
  * Return filterString if it is a single, generic name filter (e.g. QSYS*)
package/api/IBMi.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- /// <reference types="node" />
1
+ import { BindingValue } from "@ibm/mapepire-js";
2
2
  import * as node_ssh from "node-ssh";
3
+ import { ClientErrorExtensions } from "ssh2";
3
4
  import { EventEmitter } from 'stream';
4
5
  import IBMiContent from "./IBMiContent";
5
6
  import { Tools } from './Tools';
@@ -9,26 +10,27 @@ import { ConnectionManager } from './configuration/config/ConnectionManager';
9
10
  import { ConnectionConfig, RemoteConfigFile } from './configuration/config/types';
10
11
  import { ConfigFile } from './configuration/serverFile';
11
12
  import { CodeForIStorage } from './configuration/storage/CodeForIStorage';
12
- import { AspInfo, CommandData, CommandResult, ConnectionData, EditorPath, IBMiMember, RemoteCommand } from './types';
13
+ import { AspInfo, CacheItem, CommandData, CommandResult, ConnectionData, EditorPath, IBMiMember, QsysPath, RemoteCommand } from './types';
13
14
  export interface MemberParts extends IBMiMember {
14
15
  basename: string;
15
16
  }
16
- export declare type ConnectionMessageType = 'info' | 'warning' | 'error';
17
- export declare type ConnectionErrorCode = `shell_config` | `home_directory_creation` | `QCPTOIMPF_exists` | `QCPFRMIMPF_exists` | `default_not_bash` | `invalid_bashrc` | `invalid_temp_lib` | `no_auto_conv_ebcdic` | `not_loaded_debug_config` | `no_sql_runner` | `ccsid_warning`;
17
+ export type ConnectionMessageType = 'info' | 'warning' | 'error';
18
+ export type ConnectionErrorCode = `shell_config` | `home_directory_creation` | `home_directory_permissions` | `QCPTOIMPF_exists` | `QCPFRMIMPF_exists` | `default_not_bash` | `invalid_bashrc` | `invalid_temp_lib` | `no_auto_conv_ebcdic` | `not_loaded_debug_config` | `no_sql_runner` | `ccsid_warning` | `component_signature_mismatch`;
18
19
  export interface ConnectionResult {
19
20
  success: boolean;
20
21
  error?: string;
21
22
  errorCodes?: ConnectionErrorCode[];
22
23
  }
23
- declare type DisconnectCallback = (conn: IBMi) => Promise<void>;
24
+ export type DisconnectedCallback = (conn: IBMi, error?: Error & ClientErrorExtensions) => Promise<void>;
24
25
  interface ConnectionCallbacks {
25
26
  onConnectedOperations?: Function[];
26
- timeoutCallback?: (conn: IBMi) => Promise<void>;
27
+ onDisconnected?: DisconnectedCallback;
27
28
  uiErrorHandler: (connection: IBMi, error: ConnectionErrorCode, data?: any) => Promise<boolean>;
28
29
  progress: (detail: {
29
30
  message: string;
30
31
  }) => void;
31
32
  message: (type: ConnectionMessageType, message: string) => void;
33
+ inputBox: (prompt: string, placeHolder: string, ignoreFocusOut: boolean) => Promise<string | undefined>;
32
34
  cancelEmitter?: EventEmitter;
33
35
  }
34
36
  interface ConnectionOptions {
@@ -39,6 +41,7 @@ interface ConnectionOptions {
39
41
  }
40
42
  interface ConnectionConfigFiles {
41
43
  settings: ConfigFile<RemoteConfigFile>;
44
+ [key: string]: ConfigFile<any>;
42
45
  }
43
46
  export default class IBMi {
44
47
  static GlobalStorage: CodeForIStorage;
@@ -50,9 +53,6 @@ export default class IBMi {
50
53
  private systemVersion;
51
54
  private qccsid;
52
55
  private userJobCcsid;
53
- /** User default CCSID is job default CCSID */
54
- private userDefaultCCSID;
55
- private sshdCcsid;
56
56
  private componentManager;
57
57
  private configFiles;
58
58
  /**
@@ -70,6 +70,8 @@ export default class IBMi {
70
70
  currentConnectionName: string;
71
71
  private tempRemoteFiles;
72
72
  defaultUserLibraries: string[];
73
+ private sqlJob;
74
+ splfUserData: string | undefined;
73
75
  /**
74
76
  * Used to store ASP numbers and their names
75
77
  * Their names usually maps up to a directory in
@@ -78,6 +80,7 @@ export default class IBMi {
78
80
  private iAspInfo;
79
81
  private currentAsp;
80
82
  private libraryAsps;
83
+ connectionSuccessful: boolean;
81
84
  /**
82
85
  * @deprecated Will be replaced with {@link IBMi.getAllIAsps} in v3.0.0
83
86
  */
@@ -94,39 +97,38 @@ export default class IBMi {
94
97
  };
95
98
  shell?: string;
96
99
  maximumArgsLength: number;
100
+ ccsidCache: Map<string, CacheItem<number>>;
97
101
  appendOutput: (text: string) => void;
98
- private disconnectedCallback;
99
102
  /**
100
- * Will only be called once per connection.
103
+ * getConfigFile can return pre-defined configuration files,
104
+ * but can lazy load new configuration files as well.
105
+ *
106
+ * This does not load the configuration file from the server,
107
+ * it only returns a ConfigFile instance. You should check the
108
+ * state of the ConfigFile instance to see if it has been loaded,
109
+ * and if not, call `loadFromServer()` on it.
101
110
  */
102
- setDisconnectedCallback(callback: DisconnectCallback): void;
103
111
  getConfigFile<T>(id: keyof ConnectionConfigFiles): ConfigFile<T>;
104
- get canUseCqsh(): boolean;
112
+ loadRemoteConfigs(): Promise<void>;
105
113
  /**
106
114
  * Primarily used for running SQL statements.
107
115
  */
108
116
  get userCcsidInvalid(): boolean;
109
- /**
110
- * Determines if the client should do variant translation.
111
- * False when cqsh should be used.
112
- * True when cqsh is not available and the job CCSID is not the same as the SSHD CCSID.
113
- */
114
- get requiresTranslation(): boolean;
115
117
  get dangerousVariants(): boolean;
116
118
  get connected(): boolean;
117
119
  getContent(): IBMiContent;
118
120
  getConfig(): ConnectionConfig;
119
121
  setConfig(newConfig: ConnectionConfig): void;
122
+ getTempDirectory(): string;
120
123
  constructor();
121
124
  connect(connectionObject: ConnectionData, options: ConnectionOptions): Promise<ConnectionResult>;
122
- private ensureTempLibraryExists;
123
- private ensureTempDirectory;
125
+ private checkOrCreateTempLibrary;
126
+ private checkOrCreateTempDirectory;
124
127
  /**
125
128
  * Can return 0 if the OS version was not detected.
126
129
  */
127
130
  getSystemVersion(): number;
128
131
  usingBash(): boolean;
129
- loadRemoteConfigs(): Promise<void>;
130
132
  /**
131
133
  * - Send PASE/QSH/ILE commands simply
132
134
  * - Commands sent here end in the 'IBM i Output' channel
@@ -143,18 +145,24 @@ export default class IBMi {
143
145
  * Commands sent here end up in the 'Code for IBM i' output channel.
144
146
  */
145
147
  sendCommand(options: CommandData): Promise<CommandResult>;
146
- private disconnect;
147
- dispose(): Promise<void>;
148
+ disconnect(): Promise<void>;
149
+ private dispose;
148
150
  /**
149
151
  * SQL only available when runner is installed and CCSID is valid.
150
152
  */
151
153
  get enableSQL(): boolean;
152
154
  sqlRunnerAvailable(): boolean;
155
+ getSqlJobId(): string;
153
156
  /**
154
157
  * Generates path to a temp file on the IBM i
155
158
  * @param {string} key Key to the temp file to be re-used
156
159
  */
157
160
  getTempRemote(key: string): string;
161
+ /**
162
+ * Cleans up a temp file and removes it from cache
163
+ * @param {string} key Key to the temp file to clean up
164
+ */
165
+ clearTempRemote(key: string): Promise<void>;
158
166
  parserMemberPath(string: string, checkExtension?: boolean): MemberParts;
159
167
  /**
160
168
  * @param {string} string
@@ -166,8 +174,6 @@ export default class IBMi {
166
174
  * @returns {string} result
167
175
  */
168
176
  sysNameInAmerican(string: string): string;
169
- getLastDownloadLocation(): string;
170
- setLastDownloadLocation(location: string): Promise<void>;
171
177
  /**
172
178
  * Creates a temporary directory and pass it on to a `process` function.
173
179
  * The directory is guaranteed to be empty when created and deleted after the `process` is done.
@@ -180,7 +186,7 @@ export default class IBMi {
180
186
  */
181
187
  upperCaseName(name: string): string;
182
188
  getComponentManager(): ComponentManager;
183
- getComponent<T extends IBMiComponent>(name: string, options?: ComponentSearchProps): T;
189
+ getComponent<T extends IBMiComponent>(name: string, options?: ComponentSearchProps): Promise<T>;
184
190
  /**
185
191
  * Run SQL statements.
186
192
  * Each statement must be separated by a semi-colon and a new line (i.e. ;\n).
@@ -189,17 +195,15 @@ export default class IBMi {
189
195
  * @param statements
190
196
  * @returns a Result set
191
197
  */
192
- runSQL(statements: string, options?: {
193
- fakeBindings?: (string | number)[];
194
- forceSafe?: boolean;
198
+ runSQL(statements: string | string[], options?: {
199
+ bindings?: BindingValue[];
200
+ rows?: number;
195
201
  }): Promise<Tools.DB2Row[]>;
196
202
  validQsysName(name: string): boolean;
197
203
  getCcsid(): number;
198
204
  getCcsids(): {
199
205
  qccsid: number;
200
206
  runtimeCcsid: number;
201
- userDefaultCCSID: number;
202
- sshdCcsid: number;
203
207
  };
204
208
  debugPTFInstalled(): boolean;
205
209
  private getUserProfileAsp;
@@ -208,6 +212,7 @@ export default class IBMi {
208
212
  getIAspName(by: string | number): string | undefined;
209
213
  getCurrentIAspName(): string;
210
214
  lookupLibraryIAsp(library: string): Promise<string | undefined>;
215
+ getFileCcsid(path: string | QsysPath): Promise<number>;
211
216
  getLibraryIAsp(library: string): string;
212
217
  /**
213
218
  * @deprecated Use {@link IBMiContent.uploadFiles} instead.
@@ -1,13 +1,11 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import * as node_ssh from "node-ssh";
4
2
  import { FilterType } from './Filter';
5
3
  import { default as IBMi } from './IBMi';
6
4
  import { Tools } from './Tools';
7
5
  import { AttrOperands, CommandResult, EditorPath, IBMiError, IBMiMember, IBMiObject, IFSFile, ModuleExport, ProgramExportImportInfo, QsysPath, SpecialAuthorities } from './types';
8
- declare type Authority = "*ADD" | "*DLT" | "*EXECUTE" | "*READ" | "*UPD" | "*NONE" | "*ALL" | "*CHANGE" | "*USE" | "*EXCLUDE" | "*AUTLMGT";
9
- export declare type SortOrder = `name` | `type`;
10
- export declare type SortOptions = {
6
+ type Authority = "*ADD" | "*DLT" | "*EXECUTE" | "*READ" | "*UPD" | "*NONE" | "*ALL" | "*CHANGE" | "*USE" | "*EXCLUDE" | "*AUTLMGT";
7
+ export type SortOrder = `name` | `type`;
8
+ export type SortOptions = {
11
9
  order: "name" | "date";
12
10
  ascending?: boolean;
13
11
  };
@@ -23,7 +21,7 @@ export default class IBMiContent {
23
21
  * @param remotePath Remote IFS path
24
22
  * @param localPath Local path to download file to
25
23
  */
26
- downloadStreamfileRaw(remotePath: string, localPath?: string): Promise<Buffer>;
24
+ downloadStreamfileRaw(remotePath: string, localPath?: string): Promise<NonSharedBuffer>;
27
25
  /**
28
26
  * @deprecated Use {@link IBMiContent.downloadStreamfileRaw()} instead
29
27
  */
@@ -48,16 +46,6 @@ export default class IBMiContent {
48
46
  * @param localPath
49
47
  */
50
48
  downloadMemberContent(library: string, sourceFile: string, member: string, localPath?: string): Promise<string>;
51
- /**
52
- * @deprecated Will be removed in `v3.0.0`; use {@link IBMiContent.downloadMemberContent()} without the `asp` parameter instead.
53
- *
54
- * @param asp
55
- * @param library
56
- * @param sourceFile
57
- * @param member
58
- * @param localPath
59
- */
60
- downloadMemberContent(asp: string | undefined, library: string, sourceFile: string, member: string, localPath?: string): Promise<string>;
61
49
  /**
62
50
  * Upload to a member
63
51
  *
@@ -67,15 +55,6 @@ export default class IBMiContent {
67
55
  * @param content
68
56
  */
69
57
  uploadMemberContent(library: string, sourceFile: string, member: string, content: string | Uint8Array): Promise<boolean>;
70
- /**
71
- * @deprecated Will be removed in `v3.0.0`; use {@link IBMiContent.uploadMemberContent()} without the `asp` parameter instead.
72
- * @param asp
73
- * @param library
74
- * @param sourceFile
75
- * @param member
76
- * @param content
77
- */
78
- uploadMemberContent(asp: string | undefined, library: string, sourceFile: string, member: string, content: string | Uint8Array): Promise<boolean>;
79
58
  /**
80
59
  * @param statements Either an SQL statement or CL statement. CL statements start with @
81
60
  * @returns result set
@@ -151,17 +130,11 @@ export default class IBMiContent {
151
130
  getMemberList(filter: {
152
131
  library: string;
153
132
  sourceFile: string;
154
- members?: string;
133
+ members?: string | string[];
155
134
  extensions?: string;
156
135
  sort?: SortOptions;
157
136
  filterType?: FilterType;
158
137
  }): Promise<IBMiMember[]>;
159
- /**
160
- *
161
- * @param filter: the criterias used to list the members
162
- * @returns
163
- */
164
- getMemberInfo(library: string, sourceFile: string, member: string): Promise<any>;
165
138
  /**
166
139
  * Get list of items in a path
167
140
  * @param remotePath
@@ -208,7 +181,6 @@ export default class IBMiContent {
208
181
  valid: boolean;
209
182
  missing: SpecialAuthorities[];
210
183
  }>;
211
- getSshCcsid(): Promise<number>;
212
184
  getSysEnvVars(): Promise<{
213
185
  [name: string]: string;
214
186
  }>;
@@ -239,5 +211,18 @@ export default class IBMiContent {
239
211
  * @returns the {@link CommandResult} of the `mv` command execution
240
212
  */
241
213
  move(paths: string | string[], toDirectory: string): Promise<CommandResult>;
214
+ /**
215
+ * Returns the signature of an SQL component
216
+ * @param library
217
+ * @param name
218
+ * @param type
219
+ * @returns
220
+ */
221
+ getSQLRoutineSignature(library: string, name: string, type: "PROCEDURE" | "FUNCTION"): Promise<string>;
222
+ getSHA256FileHash(remoteFile: string): Promise<string>;
223
+ getLibraryListFromCommand(command: string): Promise<{
224
+ currentLibrary: string;
225
+ libraryList: string[];
226
+ }>;
242
227
  }
243
228
  export {};
@@ -1,6 +1,6 @@
1
1
  import IBMi from './IBMi';
2
2
  import { IBMiMember, SearchResults } from './types';
3
- export declare namespace Search {
3
+ export declare namespace SearchTools {
4
4
  function searchMembers(connection: IBMi, library: string, sourceFile: string, searchTerm: string, members: string | IBMiMember[], readOnly?: boolean): Promise<SearchResults>;
5
5
  function searchIFS(connection: IBMi, path: string, searchTerm: string): Promise<SearchResults | undefined>;
6
6
  function findIFS(connection: IBMi, path: string, findTerm: string): Promise<SearchResults | undefined>;
package/api/Tools.d.ts CHANGED
@@ -4,20 +4,8 @@ export declare namespace Tools {
4
4
  sqlstate: string;
5
5
  constructor(message: string);
6
6
  }
7
- interface DB2Headers {
8
- name: string;
9
- from: number;
10
- length: number;
11
- }
12
7
  interface DB2Row extends Record<string, string | number | null> {
13
8
  }
14
- /**
15
- * Parse standard out for `/usr/bin/db2`
16
- * @param output /usr/bin/db2's output
17
- * @returns rows
18
- */
19
- function db2Parse(output: string, input?: string): DB2Row[];
20
- function bufferToUx(input: string): string;
21
9
  function makeid(length?: number): string;
22
10
  /**
23
11
  * Build the IFS path string to an object or member
@@ -41,17 +29,8 @@ export declare namespace Tools {
41
29
  function sanitizeObjNamesForPase(libraries: string[]): string[];
42
30
  function parseMessages(output: string): IBMiMessages;
43
31
  function parseQSysPath(path: string): QsysPath;
44
- /**
45
- * Fixes an SQL statement to make it compatible with db2 CLI program QZDFMDB2.
46
- * - Changes `@clCommand` statements into Call `QSYS2.QCMDEX('clCommand')` procedure calls
47
- * - Makes sure each comment (`--`) starts on a new line
48
- * @param statement the statement to fix
49
- * @returns statement compatible with QZDFMDB2
50
- */
51
- function fixSQL(statement: string, removeComments?: boolean): string;
52
32
  function fileToPath(file: EditorPath): string;
53
33
  function fixWindowsPath(path: string): string;
54
- function assumeType(str: string, col?: string): string | number;
55
34
  /**
56
35
  * Converts a timestamp from the attr command (in the form `Thu Dec 21 21:47:02 2023`) into a Date object
57
36
  * @param timestamp an attr timestamp string
@@ -75,4 +54,19 @@ export declare namespace Tools {
75
54
  * @returns
76
55
  */
77
56
  function resolvePath(path: string): string;
57
+ /**
58
+ * Determines if CCSID conversion should be applied based on configuration and source file CCSID.
59
+ * @param sourceCcsid The CCSID of the source file
60
+ * @param config Connection configuration containing conversion settings
61
+ * @returns {requiresConversion, targetCcsid} - whether conversion is required and the target CCSID to use
62
+ */
63
+ function determineCcsidConversion(sourceCcsid: number, config: {
64
+ ccsidConversionEnabled?: boolean;
65
+ ccsidConvertFrom?: string;
66
+ ccsidConvertTo?: string;
67
+ }): {
68
+ requiresConversion: boolean;
69
+ targetCcsid: number;
70
+ };
71
+ function ensureFullPath(inputPath: string, remoteHomeDirectory: string | undefined): string;
78
72
  }
@@ -0,0 +1,12 @@
1
+ import vscode from "vscode";
2
+ import { Action } from "./types";
3
+ export declare namespace ActionTools {
4
+ function getActions(workspace?: vscode.WorkspaceFolder): Promise<Action[]>;
5
+ function getConnectionActions(): Action[];
6
+ function getLocalActionsFiles(workspace: vscode.WorkspaceFolder): Promise<vscode.Uri[]>;
7
+ function updateAction(action: Action, workspace?: vscode.WorkspaceFolder, options?: {
8
+ newName?: string;
9
+ oldType?: string;
10
+ delete?: boolean;
11
+ }): Promise<void>;
12
+ }
@@ -1,13 +1,20 @@
1
1
  import IBMi from "../IBMi";
2
- export declare type ComponentState = `NotChecked` | `NotInstalled` | `Installed` | `NeedsUpdate` | `Error`;
3
- export declare type ComponentIdentification = {
2
+ type ComponentStatus = `NotChecked` | `NotInstalled` | `NeedsUpdate` | `Installed` | `Error`;
3
+ /** @deprecated use {@link SecureComponentState} instead */
4
+ export type ComponentState = ComponentStatus;
5
+ export type SecureComponentState = {
6
+ status: ComponentStatus;
7
+ remoteSignature?: string;
8
+ };
9
+ export type ComponentIdentification = {
4
10
  name: string;
5
11
  version: number | string;
12
+ signature: string;
6
13
  userManaged?: boolean;
7
14
  };
8
- export declare type ComponentInstallState = {
15
+ export type ComponentInstallState = {
9
16
  id: ComponentIdentification;
10
- state: ComponentState;
17
+ state: SecureComponentState;
11
18
  };
12
19
  /**
13
20
  * Defines a component that is managed per IBM i.
@@ -17,7 +24,7 @@ export declare type ComponentInstallState = {
17
24
  * For example, this class:
18
25
  * ```
19
26
  * class MyIBMIComponent implements IBMiComponent {
20
- * //implements getName, getRemoteState and update
27
+ * //implements getIdentification, getRemoteState and update
21
28
  * }
22
29
  * ```
23
30
  * Must be registered like this, when the extension providing the component gets activated:
@@ -32,26 +39,33 @@ export declare type ComponentInstallState = {
32
39
  * ```
33
40
  *
34
41
  */
35
- export declare type IBMiComponent = {
42
+ export type IBMiComponent = {
36
43
  /**
37
- * The identification of this component; name must be unique
44
+ * The identification of this component: a unique name and a signature
38
45
  *
39
- * @returns a human-readable name
46
+ * @returns a {@link ComponentIdentification}
40
47
  */
41
48
  getIdentification(): ComponentIdentification;
42
49
  setInstallDirectory?(installDirectory: string): Promise<void>;
43
50
  /**
44
- * @returns the component's {@link ComponentState state} on the IBM i
51
+ * Check and retrieve the Component's state from the remote system.
52
+ *
53
+ * @param connection
54
+ * @param installDirectory
55
+ * @param signature a unique identifier (i.e. a hash), part of the component's identification. It should be compared against a hash retrieved from the remote system.
56
+ * @returns the component's {@link SecureComponentState state} on the IBM i
45
57
  */
46
- getRemoteState(connection: IBMi, installDirectory: string): ComponentState | Promise<ComponentState>;
58
+ getRemoteState(connection: IBMi, installDirectory: string): ComponentState | SecureComponentState | Promise<ComponentState | SecureComponentState>;
47
59
  /**
48
- * Called whenever the components needs to be installed or updated, depending on its {@link ComponentState state}.
49
- *
50
- * The Component Manager is responsible for calling this, so the {@link ComponentState state} doesn't need to be checked here.
60
+ * Called whenever the components needs to be installed or updated, depending on its {@link SecureComponentState state}.
51
61
  *
52
- * @returns the component's {@link ComponentState state} after the update is done
62
+ * The Component Manager is responsible for calling this, so the {@link SecureComponentState state} doesn't need to be checked here.
63
+ * @param connection
64
+ * @param installDirectory
65
+ * @param signature a unique identifier (i.e. a hash), part of the component's identification. It should be compared against a hash retrieved from the remote system.
66
+ * @returns the component's {@link SecureComponentState state} after the update is done
53
67
  */
54
- update(connection: IBMi, installDirectory: string): ComponentState | Promise<ComponentState>;
68
+ update(connection: IBMi, installDirectory: string): ComponentState | SecureComponentState | Promise<ComponentState | SecureComponentState>;
55
69
  /**
56
70
  * Called when connecting to clear every persitent information related to the previous connection
57
71
  */
@@ -62,3 +76,4 @@ export declare type IBMiComponent = {
62
76
  */
63
77
  uninstall?(connection: IBMi): Promise<void>;
64
78
  };
79
+ export {};
@@ -1,5 +1,5 @@
1
1
  import IBMi from "../IBMi";
2
- import { ComponentIdentification, ComponentInstallState, ComponentState, IBMiComponent } from "./component";
2
+ import { ComponentIdentification, ComponentInstallState, IBMiComponent, SecureComponentState } from "./component";
3
3
  import { IBMiComponentRuntime } from "./runtime";
4
4
  interface ExtensionContextI {
5
5
  extension: {
@@ -11,8 +11,10 @@ export interface ComponentSearchProps {
11
11
  }
12
12
  export declare class ComponentRegistry {
13
13
  private readonly components;
14
+ private readonly disabled;
14
15
  registerComponent(context: ExtensionContextI | string, component: IBMiComponent): void;
15
16
  getComponents(): Map<string, IBMiComponent[]>;
17
+ disableComponent(key: string, id: string): void;
16
18
  }
17
19
  export declare const extensionComponentRegistry: ComponentRegistry;
18
20
  export declare class ComponentManager {
@@ -27,11 +29,12 @@ export declare class ComponentManager {
27
29
  getAllAvailableComponents(): IBMiComponent[];
28
30
  installComponent(key: string): Promise<ComponentInstallState>;
29
31
  uninstallComponent(key: string): Promise<ComponentInstallState>;
30
- getRemoteState(key: string): Promise<ComponentState | undefined>;
32
+ getRemoteState(key: string): Promise<SecureComponentState | undefined>;
31
33
  startup(lastInstalled?: ComponentInstallState[]): Promise<void>;
34
+ startupComponent(key: string | IBMiComponent, lastInstalled?: ComponentInstallState[]): Promise<SecureComponentState>;
32
35
  /**
33
36
  * Returns the latest version of an installed component, or fetch a specific version
34
37
  */
35
- get<T extends IBMiComponent>(id: string, options?: ComponentSearchProps): T | undefined;
38
+ get<T extends IBMiComponent>(id: string, options?: ComponentSearchProps): Promise<T | undefined>;
36
39
  }
37
40
  export { IBMiComponentRuntime };
@@ -0,0 +1,25 @@
1
+ import { SQLJob } from "@ibm/mapepire-js";
2
+ import IBMi from "../../IBMi";
3
+ import { IBMiComponent, SecureComponentState } from "../component";
4
+ import { sshSqlJob } from "./sqlJob";
5
+ export declare class Mapepire implements IBMiComponent {
6
+ static readonly ID = "mapepire";
7
+ private readonly localAssetPath;
8
+ private installPath;
9
+ private readonly version;
10
+ readonly jobs: Map<string, SQLJob>;
11
+ constructor(localAssetRoot: string);
12
+ getIdentification(): {
13
+ name: string;
14
+ version: string;
15
+ signature: string;
16
+ };
17
+ setInstallDirectory(installDirectory: string): Promise<void>;
18
+ getRemoteState(connection: IBMi, installDirectory: string): Promise<SecureComponentState>;
19
+ update(connection: IBMi): Promise<SecureComponentState>;
20
+ getInitCommand(javaHome: string): string | undefined;
21
+ static useExec(connection: IBMi): Promise<boolean>;
22
+ newJob(connection: IBMi, javaPath?: string): Promise<sshSqlJob>;
23
+ endJobs(): Promise<void>;
24
+ reset(): void;
25
+ }
@@ -0,0 +1,20 @@
1
+ import type { ConnectionResult, ServerRequest } from "@ibm/mapepire-js";
2
+ import { SQLJob } from "@ibm/mapepire-js";
3
+ import { ClientChannel } from "ssh2";
4
+ import { Mapepire } from ".";
5
+ import IBMi from "../../IBMi";
6
+ import { JobStatus } from "./types";
7
+ export declare class sshSqlJob extends SQLJob {
8
+ static application: string;
9
+ private channel;
10
+ private onClose?;
11
+ getSshChannel(mapepire: Mapepire, connection: IBMi, javaPath: string): Promise<ClientChannel>;
12
+ send<T>(content: ServerRequest): Promise<T>;
13
+ getStatus(): JobStatus;
14
+ /**
15
+ * The same as mapepire-js#connect, but with SSH
16
+ */
17
+ connectSsh(channel: ClientChannel): Promise<ConnectionResult>;
18
+ close(): Promise<void>;
19
+ private end;
20
+ }
@@ -0,0 +1,7 @@
1
+ export declare enum JobStatus {
2
+ NOT_STARTED = "notStarted",
3
+ CONNECTING = "connecting",
4
+ READY = "ready",
5
+ BUSY = "busy",
6
+ ENDED = "ended"
7
+ }
@@ -0,0 +1,4 @@
1
+ export declare const VERSION = "2.3.5";
2
+ export declare const SERVER_VERSION_TAG = "v2.3.5";
3
+ export declare const SERVER_FILE_PREFIX = "mapepire-server-";
4
+ export declare const SERVER_VERSION_FILE = "mapepire-server-2.3.5.jar";
@@ -1,5 +1,5 @@
1
1
  import IBMi from "../IBMi";
2
- import { ComponentState, IBMiComponent } from "./component";
2
+ import { ComponentState, IBMiComponent, SecureComponentState } from "./component";
3
3
  export declare class IBMiComponentRuntime {
4
4
  protected readonly connection: IBMi;
5
5
  readonly component: IBMiComponent;
@@ -8,10 +8,20 @@ export declare class IBMiComponentRuntime {
8
8
  private cachedInstallDirectory;
9
9
  constructor(connection: IBMi, component: IBMiComponent);
10
10
  getInstallDirectory(): Promise<string>;
11
- getState(): ComponentState;
12
- setState(newState: ComponentState): Promise<void>;
13
- overrideState(newState: ComponentState): Promise<void>;
14
- update(installDirectory: string): Promise<void>;
11
+ getState(): SecureComponentState;
12
+ setState(newState: SecureComponentState): Promise<void>;
13
+ overrideState(newState: SecureComponentState): Promise<void>;
14
+ update(): Promise<void>;
15
15
  startupCheck(): Promise<this>;
16
+ getCurrentState(): Promise<SecureComponentState>;
17
+ /**
18
+ * Ensure smooth transition for Components not returning a {@link SecureComponentState} yet.
19
+ * Remove once {@link ComponentState} is removed.
20
+ *
21
+ * @param state a deprecated {@link ComponentState} or a {@link SecureComponentState}
22
+ * @returns a {@link SecureComponentState} with a blank signature if `state` is a {@link ComponentState}
23
+ */
24
+ handleState(state: ComponentState | SecureComponentState): SecureComponentState;
25
+ deprecationWarning(local?: boolean): void;
16
26
  toString(): string;
17
27
  }