asposewordscloud
Version:
Aspose.Words Cloud SDK for Node.js
118 lines (117 loc) • 4.56 kB
JavaScript
/*
* --------------------------------------------------------------------------------
* <copyright company="Aspose" file="fileReference.ts">
* Copyright (c) 2025 Aspose.Words for Cloud
* </copyright>
* <summary>
* 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.
* </summary>
* --------------------------------------------------------------------------------
*/
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 });
exports.FileReference = exports.importsMapFileReference = void 0;
const uuid_1 = require("uuid");
exports.importsMapFileReference = {};
class FileReference {
/**
* Returns attribute type map
*/
static getAttributeTypeMap() {
return FileReference.attributeTypeMap;
}
constructor(source, reference, content, password) {
this.source = source;
this.reference = reference;
this.content = content;
this.password = password;
this.encryptedPassword = null;
}
collectFilesContent(_resultFilesContent) {
_resultFilesContent.push(this);
}
encryptPassword(encryptor) {
return __awaiter(this, void 0, void 0, function* () {
if (this.password !== null && this.password !== undefined) {
this.encryptedPassword = yield encryptor.encrypt(this.password);
this.password = null;
}
});
}
validate() {
// Do nothing
}
getSource() {
return this.source;
}
getReference() {
return this.reference;
}
getContent() {
return this.content;
}
static fromRemoteFilePath(remoteFilePath, password = null) {
return new FileReference(FileReference.SourceEnum.Storage, remoteFilePath, null, password);
}
static fromLocalFileContent(localFileContent, password = null) {
return new FileReference(FileReference.SourceEnum.Request, (0, uuid_1.v4)(), localFileContent, password);
}
}
exports.FileReference = FileReference;
/**
* Attribute type map
*/
FileReference.attributeTypeMap = [
{
name: "source",
baseName: "Source",
type: "FileReference.SourceEnum",
},
{
name: "reference",
baseName: "Reference",
type: "string",
},
{
name: "password",
baseName: "Password",
type: "string",
},
{
name: "encryptedPassword",
baseName: "EncryptedPassword",
type: "string",
}
];
(function (FileReference) {
let SourceEnum;
(function (SourceEnum) {
SourceEnum[SourceEnum["Storage"] = 'Storage'] = "Storage";
SourceEnum[SourceEnum["Request"] = 'Request'] = "Request";
})(SourceEnum = FileReference.SourceEnum || (FileReference.SourceEnum = {}));
})(FileReference = exports.FileReference || (exports.FileReference = {}));
;