diff --git a/lerna.json b/lerna.json index daa5c34cf9..8d7b46ef3a 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "8.9.0", + "version": "8.9.1", "command": { "publish": { "ignoreChanges": [ diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 52e37e5113..2579acc821 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -16269,7 +16269,7 @@ }, "packages/cli": { "name": "@zowe/cli", - "version": "8.9.0", + "version": "8.9.1", "hasInstallScript": true, "license": "EPL-2.0", "dependencies": { @@ -16277,12 +16277,12 @@ "@zowe/imperative": "8.8.3", "@zowe/provisioning-for-zowe-sdk": "8.8.3", "@zowe/zos-console-for-zowe-sdk": "8.8.3", - "@zowe/zos-files-for-zowe-sdk": "8.9.0", - "@zowe/zos-jobs-for-zowe-sdk": "8.9.0", + "@zowe/zos-files-for-zowe-sdk": "8.9.1", + "@zowe/zos-jobs-for-zowe-sdk": "8.9.1", "@zowe/zos-logs-for-zowe-sdk": "8.8.3", "@zowe/zos-tso-for-zowe-sdk": "8.8.3", "@zowe/zos-uss-for-zowe-sdk": "8.8.3", - "@zowe/zos-workflows-for-zowe-sdk": "8.9.0", + "@zowe/zos-workflows-for-zowe-sdk": "8.9.1", "@zowe/zosmf-for-zowe-sdk": "8.8.3", "find-process": "1.4.7", "lodash": "4.17.21", @@ -16599,10 +16599,10 @@ }, "packages/workflows": { "name": "@zowe/zos-workflows-for-zowe-sdk", - "version": "8.9.0", + "version": "8.9.1", "license": "EPL-2.0", "dependencies": { - "@zowe/zos-files-for-zowe-sdk": "8.9.0" + "@zowe/zos-files-for-zowe-sdk": "8.9.1" }, "devDependencies": { "@zowe/cli-test-utils": "8.8.3", @@ -16636,7 +16636,7 @@ }, "packages/zosfiles": { "name": "@zowe/zos-files-for-zowe-sdk", - "version": "8.9.0", + "version": "8.9.1", "license": "EPL-2.0", "dependencies": { "lodash": "^4.17.21", @@ -16678,10 +16678,10 @@ }, "packages/zosjobs": { "name": "@zowe/zos-jobs-for-zowe-sdk", - "version": "8.9.0", + "version": "8.9.1", "license": "EPL-2.0", "dependencies": { - "@zowe/zos-files-for-zowe-sdk": "8.9.0" + "@zowe/zos-files-for-zowe-sdk": "8.9.1" }, "devDependencies": { "@zowe/cli-test-utils": "8.8.3", diff --git a/packages/cli/package.json b/packages/cli/package.json index bfa9205e32..8e49ec1c10 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/cli", - "version": "8.9.0", + "version": "8.9.1", "zoweVersion": "v3.0.0", "description": "Zowe CLI is a command line interface (CLI) that provides a simple and streamlined way to interact with IBM z/OS.", "author": "Zowe", @@ -62,12 +62,12 @@ "@zowe/imperative": "8.8.3", "@zowe/provisioning-for-zowe-sdk": "8.8.3", "@zowe/zos-console-for-zowe-sdk": "8.8.3", - "@zowe/zos-files-for-zowe-sdk": "8.9.0", - "@zowe/zos-jobs-for-zowe-sdk": "8.9.0", + "@zowe/zos-files-for-zowe-sdk": "8.9.1", + "@zowe/zos-jobs-for-zowe-sdk": "8.9.1", "@zowe/zos-logs-for-zowe-sdk": "8.8.3", "@zowe/zos-tso-for-zowe-sdk": "8.8.3", "@zowe/zos-uss-for-zowe-sdk": "8.8.3", - "@zowe/zos-workflows-for-zowe-sdk": "8.9.0", + "@zowe/zos-workflows-for-zowe-sdk": "8.9.1", "@zowe/zosmf-for-zowe-sdk": "8.8.3", "find-process": "1.4.7", "lodash": "4.17.21", diff --git a/packages/workflows/package.json b/packages/workflows/package.json index c32bf129ff..6bccd466ac 100644 --- a/packages/workflows/package.json +++ b/packages/workflows/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/zos-workflows-for-zowe-sdk", - "version": "8.9.0", + "version": "8.9.1", "description": "Zowe SDK to interact with the z/OS workflows APIs", "author": "Zowe", "license": "EPL-2.0", @@ -45,7 +45,7 @@ "prepack": "node ../../scripts/prepareLicenses.js" }, "dependencies": { - "@zowe/zos-files-for-zowe-sdk": "8.9.0" + "@zowe/zos-files-for-zowe-sdk": "8.9.1" }, "devDependencies": { "@zowe/cli-test-utils": "8.8.3", diff --git a/packages/zosfiles/CHANGELOG.md b/packages/zosfiles/CHANGELOG.md index e9715b05ad..3d8b3f6d79 100644 --- a/packages/zosfiles/CHANGELOG.md +++ b/packages/zosfiles/CHANGELOG.md @@ -2,8 +2,9 @@ All notable changes to the Zowe z/OS files SDK package will be documented in this file. -## Recent Changes +## `8.9.1` +- BugFix: Corrected the `apiResponse` response value from `streamToDataSet()`,`streamToUss()`,`bufferToUss()` and `bufferToDataSet()` on the Upload SDK. [#2381](https://github.com/zowe/zowe-cli/pull/2381) - BugFix: Corrected the `Upload.BufferToUssFile()` SDK function to properly tag uploaded files. [#2378](https://github.com/zowe/zowe-cli/pull/2378) ## `8.9.0` diff --git a/packages/zosfiles/__tests__/__system__/methods/upload/Upload.system.test.ts b/packages/zosfiles/__tests__/__system__/methods/upload/Upload.system.test.ts index 158729d6ce..adeaa4f699 100644 --- a/packages/zosfiles/__tests__/__system__/methods/upload/Upload.system.test.ts +++ b/packages/zosfiles/__tests__/__system__/methods/upload/Upload.system.test.ts @@ -19,6 +19,7 @@ import { deleteFiles, getUniqueDatasetName, stripNewLines, wait, waitTime } from import * as fs from "fs"; import { ITestEnvironment } from "../../../../../../__tests__/__src__/environment/ITestEnvironment"; import { runCliScript } from "../../../../../../__tests__/__packages__/cli-test-utils/src"; +import { Readable } from "stream"; let REAL_SESSION: Session; let testEnvironment: ITestEnvironment; @@ -309,6 +310,49 @@ describe("Upload Data Set", () => { } }); + it("should upload a PDS file - bufferToDataSet()", async () => { + let error; + let uploadResponse; + let getResponse; + const data: Buffer = Buffer.from(testdata); + + try { + uploadResponse = await Upload.bufferToDataSet(REAL_SESSION, data, dsname+"(TEST)"); + getResponse = await Get.dataSet(REAL_SESSION, dsname+"(TEST)"); + } catch (err) { + error = err; + Imperative.console.info("Error: " + inspect(error)); + } + + expect(error).toBeFalsy(); + + expect(uploadResponse.apiResponse).toMatchObject({"success": true, "from": "Buffer<>","to": dsname+"(TEST)"}); + expect(Buffer.from(getResponse.toString().trim())).toEqual(data); + }); + + it("should upload a PDS file - streamToDataSet()", async () => { + let error; + let uploadResponse; + let getResponse; + + const inputStream = new Readable(); + inputStream.push(testdata); + inputStream.push(null); + + try { + uploadResponse = await Upload.streamToDataSet(REAL_SESSION, inputStream, dsname+"(TEST)"); + getResponse = await Get.dataSet(REAL_SESSION, dsname+"(TEST)"); + } catch (err) { + error = err; + Imperative.console.info("Error: " + inspect(error)); + } + + expect(error).toBeFalsy(); + + expect(uploadResponse.apiResponse).toMatchObject({"success": true, "from": "Stream<>","to": dsname+"(TEST)"}); + expect(getResponse.toString().trim()).toEqual(testdata); + }); + it("should upload a file to a partitioned data set member using full path", async () => { let error; let response: IZosFilesResponse; @@ -733,7 +777,7 @@ describe("Upload USS file", () => { await deleteFiles(REAL_SESSION, ussname); }); - it("should upload a USS file", async () => { + it("should upload a USS file - bufferToUssFile()", async () => { let error; let uploadResponse; let getResponse; @@ -748,9 +792,33 @@ describe("Upload USS file", () => { } expect(error).toBeFalsy(); + + expect(uploadResponse.apiResponse).toMatchObject({"success": true, "from": "Buffer<>","to": ussname}); expect(getResponse).toEqual(Buffer.from(data.toString())); + }); + it("should upload a USS file - streamToUssFile()", async () => { + let error; + let uploadResponse; + let getResponse; + const inputStream = new Readable(); + inputStream.push(testdata); + inputStream.push(null); + + try { + uploadResponse = await Upload.streamToUssFile(REAL_SESSION, ussname, inputStream); + getResponse = await Get.USSFile(REAL_SESSION, ussname); + } catch (err) { + error = err; + Imperative.console.info("Error: " + inspect(error)); + } + + expect(error).toBeFalsy(); + + expect(uploadResponse.apiResponse).toMatchObject({"success": true, "from": "Stream<>","to": ussname}); + expect(getResponse).toEqual(Buffer.from(testdata)); }); + it("should upload a USS file in binary mode", async () => { let error; let uploadResponse; diff --git a/packages/zosfiles/__tests__/__unit__/methods/upload/Upload.unit.test.ts b/packages/zosfiles/__tests__/__unit__/methods/upload/Upload.unit.test.ts index 28812678c8..c0f92eb905 100644 --- a/packages/zosfiles/__tests__/__unit__/methods/upload/Upload.unit.test.ts +++ b/packages/zosfiles/__tests__/__unit__/methods/upload/Upload.unit.test.ts @@ -22,7 +22,7 @@ import { IUploadOptions } from "../../../../src/methods/upload/doc/IUploadOption import { Upload } from "../../../../src/methods/upload/Upload"; import { List } from "../../../../src/methods/list/List"; import { Utilities } from "../../../../src/methods/utilities/Utilities"; - +import { inspect } from "util"; import { ZosFilesUtils } from "../../../../src/utils/ZosFilesUtils"; import { stripNewLines } from "../../../../../../__tests__/__src__/TestUtils"; import { Create } from "../../../../src/methods/create"; @@ -379,7 +379,7 @@ describe("z/OS Files - Upload", () => { expect(error).toBeDefined(); expect(error).toBe(testError); }); - it("should return with proper response when upload buffer to a data set", async () => { + it("should return with proper response when upload buffer to a data set - buffer less than 10 chars", async () => { const buffer: Buffer = Buffer.from("testing"); const endpoint = path.posix.join(ZosFilesConstants.RESOURCE, ZosFilesConstants.RES_DS_FILES, dsName); const reqHeaders = [ZosmfHeaders.X_IBM_TEXT, ZosmfHeaders.ACCEPT_ENCODING]; @@ -392,6 +392,27 @@ describe("z/OS Files - Upload", () => { expect(error).toBeUndefined(); expect(response).toBeDefined(); + expect(response.apiResponse).toMatchObject({"from": "", "success": true, "to": dsName}); + + expect(zosmfPutFullSpy).toHaveBeenCalledTimes(1); + expect(zosmfPutFullSpy).toHaveBeenCalledWith(dummySession, {resource: endpoint, + reqHeaders, + writeData: buffer}); + }); + it("should return with proper response when upload buffer to a data set - buffer more than 10 chars", async () => { + const buffer: Buffer = Buffer.from("bufferLargerThan10Chars"); + const endpoint = path.posix.join(ZosFilesConstants.RESOURCE, ZosFilesConstants.RES_DS_FILES, dsName); + const reqHeaders = [ZosmfHeaders.X_IBM_TEXT, ZosmfHeaders.ACCEPT_ENCODING]; + + try { + response = await Upload.bufferToDataSet(dummySession, buffer, dsName); + } catch (err) { + error = err; + } + + expect(error).toBeUndefined(); + expect(response).toBeDefined(); + expect(response.apiResponse).toMatchObject({"from": "", "success": true, "to": dsName}); expect(zosmfPutFullSpy).toHaveBeenCalledTimes(1); expect(zosmfPutFullSpy).toHaveBeenCalledWith(dummySession, {resource: endpoint, @@ -748,6 +769,7 @@ describe("z/OS Files - Upload", () => { expect(error).toBeUndefined(); expect(response).toBeDefined(); + expect(response.apiResponse).toMatchObject({"from": "[Readable]", "success": true, "to": dsName}); expect(zosmfPutFullSpy).toHaveBeenCalledTimes(1); expect(zosmfPutFullSpy).toHaveBeenCalledWith(dummySession, {resource: endpoint, @@ -1755,6 +1777,7 @@ describe("z/OS Files - Upload", () => { expect(error).toBeUndefined(); expect(USSresponse).toBeDefined(); + expect(USSresponse.apiResponse).toMatchObject({"from": "", "success": true, "to": dsName}); const normalizedData = ZosFilesUtils.normalizeNewline(data); expect(data.length).not.toBe(normalizedData.length); @@ -1830,6 +1853,7 @@ describe("z/OS Files - Upload", () => { expect(error).toBeUndefined(); expect(USSresponse).toBeDefined(); + expect(USSresponse.apiResponse).toMatchObject({"from": "[Readable]", "success": true, "to": dsName}); expect(USSresponse.success).toBeTruthy(); expect(zosmfExpectFullSpy).toHaveBeenCalledTimes(1); diff --git a/packages/zosfiles/package.json b/packages/zosfiles/package.json index c5c305e508..d04f8d8499 100644 --- a/packages/zosfiles/package.json +++ b/packages/zosfiles/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/zos-files-for-zowe-sdk", - "version": "8.9.0", + "version": "8.9.1", "description": "Zowe SDK to interact with files and data sets on z/OS", "author": "Zowe", "license": "EPL-2.0", diff --git a/packages/zosfiles/src/methods/upload/Upload.ts b/packages/zosfiles/src/methods/upload/Upload.ts index 2f984ededa..9301c81bfc 100644 --- a/packages/zosfiles/src/methods/upload/Upload.ts +++ b/packages/zosfiles/src/methods/upload/Upload.ts @@ -30,7 +30,7 @@ import { Utilities, Tag } from "../utilities"; import { Readable } from "stream"; import { CLIENT_PROPERTY } from "../../doc/types/ZosmfRestClientProperties"; import { TransferMode } from "../../utils/ZosFilesAttributes"; - +import { inspect } from "util"; export class Upload { @@ -183,8 +183,13 @@ export class Upload { } const uploadRequest: IRestClientResponse = await ZosmfRestClient.putExpectFullResponse(session, requestOptions); + const maxBufferPreviewSize = 10; // By default, apiResponse is empty when uploading - const apiResponse: any = {}; + const apiResponse: any = { + success: true, + from: fileBuffer.length > maxBufferPreviewSize ? inspect(fileBuffer.subarray(0, maxBufferPreviewSize)).slice(0, -1) + "...>" : inspect(fileBuffer), + to: dataSetName + }; // Return Etag in apiResponse, if requested if (options.returnEtag) { @@ -242,7 +247,11 @@ export class Upload { const uploadRequest: IRestClientResponse = await ZosmfRestClient.putExpectFullResponse(session, requestOptions); // By default, apiResponse is empty when uploading - const apiResponse: any = {}; + const apiResponse: any = { + success: true, + from: inspect(fileStream, { showHidden: false, depth: -1}), + to: dataSetName + }; // Return Etag in apiResponse, if requested if (options.returnEtag) { @@ -480,8 +489,13 @@ export class Upload { } const uploadRequest: IRestClientResponse = await ZosmfRestClient.putExpectFullResponse(session, requestOptions); + const maxBufferPreviewSize = 10; // By default, apiResponse is empty when uploading - const apiResponse: any = {}; + const apiResponse: any = { + success: true, + from: fileBuffer.length > maxBufferPreviewSize ? inspect(fileBuffer.subarray(0, maxBufferPreviewSize)).slice(0, -1) + "...>" : inspect(fileBuffer), + to: origUssname + }; // Return Etag in apiResponse, if requested if (options.returnEtag) { @@ -541,7 +555,11 @@ export class Upload { } // By default, apiResponse is empty when uploading - const apiResponse: any = {}; + const apiResponse: any = { + success: true, + from: inspect(uploadStream, { showHidden: false, depth: -1}), + to: origUssname + }; // Return Etag in apiResponse, if requested if (options.returnEtag) { diff --git a/packages/zosjobs/package.json b/packages/zosjobs/package.json index 97b4a89bf0..17db41fd33 100644 --- a/packages/zosjobs/package.json +++ b/packages/zosjobs/package.json @@ -1,6 +1,6 @@ { "name": "@zowe/zos-jobs-for-zowe-sdk", - "version": "8.9.0", + "version": "8.9.1", "description": "Zowe SDK to interact with jobs on z/OS", "author": "Zowe", "license": "EPL-2.0", @@ -46,7 +46,7 @@ "prepack": "node ../../scripts/prepareLicenses.js" }, "dependencies": { - "@zowe/zos-files-for-zowe-sdk": "8.9.0" + "@zowe/zos-files-for-zowe-sdk": "8.9.1" }, "devDependencies": { "@zowe/cli-test-utils": "8.8.3",