@sasjs/adapter 4.11.2 → 4.12.0

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 (59) hide show
  1. package/SASViyaApiClient.d.ts +25 -2
  2. package/SASjs.d.ts +20 -2
  3. package/api/viya/writeStream.d.ts +1 -1
  4. package/auth/getTokenRequestErrorPrefix.d.ts +2 -2
  5. package/file/generateFileUploadForm.d.ts +1 -1
  6. package/file/generateTableUploadForm.d.ts +1 -1
  7. package/index-dev.js +77153 -3
  8. package/index.js +77153 -2
  9. package/job-execution/JobExecutor.d.ts +1 -1
  10. package/minified_sas9.js +16558 -2
  11. package/node/SASViyaApiClient.d.ts +25 -2
  12. package/node/SASjs.d.ts +20 -2
  13. package/node/api/viya/writeStream.d.ts +1 -1
  14. package/node/auth/getTokenRequestErrorPrefix.d.ts +2 -2
  15. package/node/file/generateFileUploadForm.d.ts +1 -1
  16. package/node/file/generateTableUploadForm.d.ts +1 -1
  17. package/node/index.js +28247 -2
  18. package/node/job-execution/JobExecutor.d.ts +1 -1
  19. package/node/request/RequestClient.d.ts +11 -2
  20. package/node/types/FileResource.d.ts +32 -0
  21. package/node/types/PollOptions.d.ts +1 -1
  22. package/node/types/RequestClient.d.ts +1 -1
  23. package/node/types/WriteStream.d.ts +6 -3
  24. package/node/utils/getFormData.d.ts +1 -1
  25. package/package.json +12 -9
  26. package/request/RequestClient.d.ts +11 -2
  27. package/spec/SAS9ApiClient.spec.d.ts +1 -0
  28. package/spec/SASjsApiClient.spec.d.ts +1 -0
  29. package/src/SAS9ApiClient.ts +1 -1
  30. package/src/SASViyaApiClient.ts +124 -6
  31. package/src/SASjs.ts +54 -4
  32. package/src/SASjsApiClient.ts +1 -1
  33. package/src/api/viya/writeStream.ts +10 -5
  34. package/src/auth/refreshTokensForViya.ts +1 -1
  35. package/src/file/generateFileUploadForm.ts +1 -1
  36. package/src/file/generateTableUploadForm.ts +1 -1
  37. package/src/job-execution/Sas9JobExecutor.ts +1 -1
  38. package/src/job-execution/SasjsJobExecutor.ts +5 -3
  39. package/src/job-execution/WebJobExecutor.ts +5 -3
  40. package/src/request/RequestClient.ts +73 -81
  41. package/src/request/Sas9RequestClient.ts +5 -5
  42. package/src/test/SAS_server_app.ts +10 -2
  43. package/src/types/FileResource.ts +33 -0
  44. package/src/types/WriteStream.ts +9 -3
  45. package/src/utils/convertToCsv.ts +5 -1
  46. package/src/utils/getFormData.ts +2 -2
  47. package/src/utils/validateInput.ts +16 -13
  48. package/types/FileResource.d.ts +32 -0
  49. package/types/PollOptions.d.ts +1 -1
  50. package/types/RequestClient.d.ts +1 -1
  51. package/types/WriteStream.d.ts +6 -3
  52. package/types/errors/spec/SAS9AuthError.spec.d.ts +1 -0
  53. package/utils/getFormData.d.ts +1 -1
  54. package/utils/spec/parseSasViyaLog.spec.d.ts +1 -0
  55. package/utils/spec/parseViyaDebugResponse.spec.d.ts +1 -0
  56. package/index-dev.js.LICENSE.txt +0 -110
  57. package/index.js.LICENSE.txt +0 -110
  58. package/minified_sas9.js.LICENSE.txt +0 -15
  59. package/node/index.js.LICENSE.txt +0 -106
@@ -2,6 +2,7 @@
2
2
  import { Job, Session, Context, ContextAllAttributes, Folder, File, EditContextInput, PollOptions } from './types';
3
3
  import { SasAuthResponse, MacroVar, AuthConfig } from '@sasjs/utils/types';
4
4
  import { RequestClient } from './request/RequestClient';
5
+ import { FileResource } from './types/FileResource';
5
6
  interface JobExecutionResult {
6
7
  result?: {
7
8
  result: object;
@@ -138,6 +139,23 @@ export declare class SASViyaApiClient {
138
139
  * @param variables - an object that represents macro variables.
139
140
  */
140
141
  executeScript(jobPath: string, linesOfCode: string[], contextName: string, authConfig?: AuthConfig, data?: null, debug?: boolean, expectWebout?: boolean, waitForResult?: boolean, pollOptions?: PollOptions, printPid?: boolean, variables?: MacroVar): Promise<any>;
142
+ /**
143
+ * Fetches the file content for a file in the specified folder.
144
+ *
145
+ * @param folderPath - the full path to the folder containing the file. eg: /Public/folder1/folder2
146
+ * @param fileName - the name of the file in the `folderPath`
147
+ * @param accessToken - an access token for authorizing the request
148
+ */
149
+ getFileContent(folderPath: string, fileName: string, accessToken?: string): Promise<string>;
150
+ /**
151
+ * Updates the file content for a file in the specified folder.
152
+ *
153
+ * @param folderPath - the full path to the folder containing the file. eg: /Public/folder1/folder2
154
+ * @param fileName - the name of the file in the `folderPath`
155
+ * @param content - the new content to be written to the file
156
+ * @param accessToken - an access token for authorizing the request
157
+ */
158
+ updateFileContent(folderPath: string, fileName: string, content: string, accessToken?: string): Promise<FileResource>;
141
159
  /**
142
160
  * Fetches a folder. Path to the folder is required.
143
161
  * @param folderPath - the absolute path to the folder.
@@ -232,6 +250,7 @@ export declare class SASViyaApiClient {
232
250
  private uploadTables;
233
251
  private getFolderDetails;
234
252
  private getFolderUri;
253
+ private getFileUri;
235
254
  private getRecycleBinUri;
236
255
  /**
237
256
  * Returns a JSON representation of a compute context.
@@ -247,11 +266,15 @@ export declare class SASViyaApiClient {
247
266
  */
248
267
  getComputeContextById(contextId: string, accessToken?: string): Promise<ContextAllAttributes>;
249
268
  /**
250
- * Lists children folders for given Viya folder.
269
+ * Lists children folders/files for given Viya folder.
251
270
  * @param sourceFolder - the full path (eg `/Public/example/myFolder`) or URI of the source folder listed. Providing URI instead of path will save one extra request.
252
271
  * @param accessToken - an access token for authorizing the request.
272
+ * @param {Object} [options] - Additional options.
273
+ * @param {boolean} [options.returnDetails=false] - when set to true, the function will return an array of objects with member details, otherwise it will return an array of member names.
253
274
  */
254
- listFolder(sourceFolder: string, accessToken?: string, limit?: number): Promise<any[]>;
275
+ listFolder(sourceFolder: string, accessToken?: string, limit?: number, options?: {
276
+ returnDetails?: boolean;
277
+ }): Promise<any[]>;
255
278
  /**
256
279
  * Moves Viya folder to a new location. The folder may be renamed at the same time.
257
280
  * @param sourceFolder - the full path (eg `/Public/example/myFolder`) or URI of the source folder to be moved. Providing URI instead of path will save one extra request.
package/node/SASjs.d.ts CHANGED
@@ -157,6 +157,23 @@ export default class SASjs {
157
157
  * @param sasApiClient - a client for interfacing with SAS API.
158
158
  */
159
159
  createFile(fileName: string, content: Buffer, parentFolderPath: string, parentFolderUri?: string, accessToken?: string, sasApiClient?: SASViyaApiClient): Promise<import("./types").File>;
160
+ /**
161
+ * Fetches the file content for a file in the specified folder.
162
+ *
163
+ * @param folderPath - the full path to the folder containing the file. eg: /Public/folder1/folder2
164
+ * @param fileName - the name of the file in the `folderPath`
165
+ * @param accessToken - an access token for authorizing the request
166
+ */
167
+ getFileContent(folderPath: string, fileName: string, accessToken?: string): Promise<string>;
168
+ /**
169
+ * Updates the file content for a file in the specified folder.
170
+ *
171
+ * @param folderPath - the full path to the folder containing the file. eg: /Public/folder1/folder2
172
+ * @param fileName - the name of the file in the `folderPath`
173
+ * @param content - the new content to be written to the file
174
+ * @param accessToken - an access token for authorizing the request
175
+ */
176
+ updateFileContent(folderPath: string, fileName: string, content: string, accessToken?: string): Promise<import("./types/FileResource").FileResource>;
160
177
  /**
161
178
  * Fetches a folder from the SAS file system.
162
179
  * @param folderPath - path of the folder to be fetched.
@@ -173,8 +190,9 @@ export default class SASjs {
173
190
  * Lists children folders for given Viya folder.
174
191
  * @param sourceFolder - the full path (eg `/Public/example/myFolder`) or URI of the source folder listed. Providing URI instead of path will save one extra request.
175
192
  * @param accessToken - an access token for authorizing the request.
193
+ * @param returnDetails - when set to true, the function will return an array of objects with member details, otherwise it will return an array of member names.
176
194
  */
177
- listFolder(sourceFolder: string, accessToken?: string, limit?: number): Promise<any[] | undefined>;
195
+ listFolder(sourceFolder: string, accessToken?: string, limit?: number, returnDetails?: boolean): Promise<any[] | undefined>;
178
196
  /**
179
197
  * Moves folder to a new location. The folder may be renamed at the same time.
180
198
  * @param sourceFolder - the full path (eg `/Public/example/myFolder`) or URI of the source folder to be moved. Providing URI instead of path will save one extra request.
@@ -343,7 +361,7 @@ export default class SASjs {
343
361
  * @param successCallBack - function that should be triggered on every HTTP response with the status 2**.
344
362
  * @param errorCallBack - function that should be triggered on every HTTP response with the status different from 2**.
345
363
  */
346
- enableVerboseMode(successCallBack?: (response: AxiosResponse | AxiosError) => AxiosResponse, errorCallBack?: (response: AxiosResponse | AxiosError) => AxiosResponse): void;
364
+ enableVerboseMode(successCallBack?: (response: AxiosResponse) => AxiosResponse, errorCallBack?: (response: AxiosError) => AxiosError): void;
347
365
  /**
348
366
  * Turns off verbose mode to log every HTTP response.
349
367
  */
@@ -1,2 +1,2 @@
1
1
  import { WriteStream } from '../../types';
2
- export declare const writeStream: (stream: WriteStream, content: string) => Promise<void>;
2
+ export declare const writeStream: (stream: WriteStream, content: string) => Promise<boolean>;
@@ -1,6 +1,6 @@
1
1
  import { ServerType } from '@sasjs/utils/types';
2
- declare type Server = ServerType.SasViya | ServerType.Sasjs;
3
- declare type Operation = 'fetching access token' | 'refreshing tokens';
2
+ type Server = ServerType.SasViya | ServerType.Sasjs;
3
+ type Operation = 'fetching access token' | 'refreshing tokens';
4
4
  /**
5
5
  * Forms error prefix for requests related to token operations.
6
6
  * @param operation - string describing operation ('fetching access token' or 'refreshing tokens').
@@ -1,4 +1,4 @@
1
- import * as NodeFormData from 'form-data';
1
+ import NodeFormData from 'form-data';
2
2
  /**
3
3
  * One of the approaches SASjs takes to send tables-formatted JSON (see README)
4
4
  * to SAS is as multipart form data, where each table is provided as a specially
@@ -1,4 +1,4 @@
1
- import * as NodeFormData from 'form-data';
1
+ import NodeFormData from 'form-data';
2
2
  export declare const generateTableUploadForm: (formData: FormData | NodeFormData, data: any) => {
3
3
  formData: NodeFormData | FormData;
4
4
  requestParams: any;