@asposecloud/aspose-tasks-cloud
Version:
Aspose.Tasks Cloud SDK for Node.js
114 lines (110 loc) • 4.83 kB
JavaScript
/*
* MIT License
* Copyright (c) 2019 Aspose Pty Ltd
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const api_1 = require("../src/api");
const model_1 = require("../src/model/model");
const fs = require("fs");
let apiInstance;
const uploadedFiles = new Set();
after(function () {
return __awaiter(this, void 0, void 0, function* () {
for (const uploadedFile of uploadedFiles) {
yield apiInstance.deleteFile({ path: uploadedFile, storageName: undefined, versionId: undefined });
}
});
});
/**
* Initialize TasksApi
*/
function initializeTasksApi(debugMode) {
const config = require("../../testConfig.json");
const tasksApi = new TestTasksApi(config.AppSid, config.AppKey, config.BaseUrl, config.AuthUrl, debugMode);
apiInstance = tasksApi;
return tasksApi;
}
exports.initializeTasksApi = initializeTasksApi;
function getDateOnly(arg) {
return new Date(arg.getFullYear(), arg.getMonth(), arg.getDate());
}
exports.getDateOnly = getDateOnly;
function getTimeOnly(arg) {
return new Date(0, 0, 0, arg.getHours(), arg.getMinutes(), arg.getSeconds());
}
exports.getTimeOnly = getTimeOnly;
function convertArrayBufferToStrings(buffer) {
const uintArray = new Uint8Array(buffer);
const string = String.fromCharCode.apply(this, uintArray);
if (string.indexOf("\r\n") >= 0) {
return string.split("\r\n");
}
else {
return string.split("\n");
}
}
exports.convertArrayBufferToStrings = convertArrayBufferToStrings;
/**
* TasksApi class with simplified file uploading
*/
class TestTasksApi extends api_1.TasksApi {
/**
* @param appSID App SID.
* @param appKey App key.
* @param baseUrl Base api Url.
* @param authUrl Auth api Url.
* @param debugMode A value indicating whether debug mode. In debug mode all requests and responses are logged to console.
*/
constructor(appSID, appKey, baseUrl, authUrl, debugMode) {
super(appSID, appKey, baseUrl, authUrl, debugMode);
}
/**
* Uploads file to storage.
* @param remotePath Path in storage.
* @param localPath Path to file
*/
uploadFileToStorage(remotePath, localPath) {
const _super = Object.create(null, {
uploadFile: { get: () => super.uploadFile }
});
return __awaiter(this, void 0, void 0, function* () {
const request = new model_1.UploadFileRequest();
request.path = remotePath;
request.file = fs.readFileSync(localPath);
;
uploadedFiles.add(remotePath);
return _super.uploadFile.call(this, request);
});
}
}
exports.TestTasksApi = TestTasksApi;
exports.remoteBaseFolder = "Temp/SdkTests/node/";
exports.remoteBaseTestDataFolder = "Temp/SdkTests/node/TestData/";
exports.remoteBaseTestOutFolder = "Temp/SdkTests/node/TestOut/";
exports.localBaseTestDataFolder = "./testData/";
//# sourceMappingURL=baseTest.js.map
;