UNPKG

@hpcc-js/comms

Version:
394 lines 15.3 kB
import { __assign, __extends, __spreadArray } from "tslib"; import { Cache, scopedLogger, StateObject } from "@hpcc-js/util"; import { DFUService } from "../services/wsDFU"; var logger = scopedLogger("logicalFile.ts"); var LogicalFileCache = /** @class */ (function (_super) { __extends(LogicalFileCache, _super); function LogicalFileCache() { return _super.call(this, function (obj) { return "".concat(obj.BaseUrl, "-").concat(obj.Cluster, "-").concat(obj.Name); }) || this; } return LogicalFileCache; }(Cache)); export { LogicalFileCache }; var _store = new LogicalFileCache(); var LogicalFile = /** @class */ (function (_super) { __extends(LogicalFile, _super); function LogicalFile(optsConnection, Cluster, Name) { var _this = _super.call(this) || this; if (optsConnection instanceof DFUService) { _this.connection = optsConnection; } else { _this.connection = new DFUService(optsConnection); } _this.clear({ Cluster: Cluster, Name: Name }); return _this; } Object.defineProperty(LogicalFile.prototype, "BaseUrl", { get: function () { return this.connection.baseUrl; }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "Cluster", { get: function () { return this.get("Cluster"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "Name", { get: function () { return this.get("Name"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "Filename", { get: function () { return this.get("Filename"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "Prefix", { get: function () { return this.get("Prefix"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "NodeGroup", { get: function () { return this.get("NodeGroup"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "NumParts", { get: function () { return this.get("NumParts"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "Description", { get: function () { return this.get("Description"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "Dir", { get: function () { return this.get("Dir"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "PathMask", { get: function () { return this.get("PathMask"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "Filesize", { get: function () { return this.get("Filesize"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "FileSizeInt64", { get: function () { return this.get("FileSizeInt64"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "RecordSize", { get: function () { return this.get("RecordSize"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "RecordCount", { get: function () { return this.get("RecordCount"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "RecordSizeInt64", { get: function () { return this.get("RecordSizeInt64"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "RecordCountInt64", { get: function () { return this.get("RecordCountInt64"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "Wuid", { get: function () { return this.get("Wuid"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "Owner", { get: function () { return this.get("Owner"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "JobName", { get: function () { return this.get("JobName"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "Persistent", { get: function () { return this.get("Persistent"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "Format", { get: function () { return this.get("Format"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "MaxRecordSize", { get: function () { return this.get("MaxRecordSize"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "CsvSeparate", { get: function () { return this.get("CsvSeparate"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "CsvQuote", { get: function () { return this.get("CsvQuote"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "CsvTerminate", { get: function () { return this.get("CsvTerminate"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "CsvEscape", { get: function () { return this.get("CsvEscape"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "Modified", { get: function () { return this.get("Modified"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "Ecl", { get: function () { return this.get("Ecl"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "Stat", { get: function () { return this.get("Stat"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "DFUFilePartsOnClusters", { get: function () { return this.get("DFUFilePartsOnClusters"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "isSuperfile", { get: function () { return this.get("isSuperfile"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "ShowFileContent", { get: function () { return this.get("ShowFileContent"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "subfiles", { get: function () { return this.get("subfiles"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "Superfiles", { get: function () { return this.get("Superfiles"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "ProtectList", { get: function () { return this.get("ProtectList"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "FromRoxieCluster", { get: function () { return this.get("FromRoxieCluster"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "Graphs", { get: function () { return this.get("Graphs"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "UserPermission", { get: function () { return this.get("UserPermission"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "ContentType", { get: function () { return this.get("ContentType"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "CompressedFileSize", { get: function () { return this.get("CompressedFileSize"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "PercentCompressed", { get: function () { return this.get("PercentCompressed"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "IsCompressed", { get: function () { return this.get("IsCompressed"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "BrowseData", { get: function () { return this.get("BrowseData"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "jsonInfo", { get: function () { return this.get("jsonInfo"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "binInfo", { get: function () { return this.get("binInfo"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "PackageID", { get: function () { return this.get("PackageID"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "Partition", { get: function () { return this.get("Partition"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "Blooms", { get: function () { return this.get("Blooms"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "ExpireDays", { get: function () { return this.get("ExpireDays"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "KeyType", { get: function () { return this.get("KeyType"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "IsRestricted", { get: function () { return this.get("IsRestricted"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "AtRestCost", { get: function () { return this.get("AtRestCost"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "AccessCost", { get: function () { return this.get("AccessCost"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "StateID", { get: function () { return this.get("StateID"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "ExpirationDate", { get: function () { return this.get("ExpirationDate"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "ExtendedIndexInfo", { get: function () { return this.get("ExtendedIndexInfo"); }, enumerable: false, configurable: true }); Object.defineProperty(LogicalFile.prototype, "properties", { get: function () { return this.get(); }, enumerable: false, configurable: true }); LogicalFile.attach = function (optsConnection, Cluster, Name, state) { var retVal = _store.get({ BaseUrl: optsConnection.baseUrl, Cluster: Cluster, Name: Name }, function () { return new LogicalFile(optsConnection, Cluster, Name); }); if (state) { retVal.set(state); } return retVal; }; LogicalFile.prototype.filePartsOnCluster = function () { var _a; return __spreadArray([], (((_a = this.DFUFilePartsOnClusters) === null || _a === void 0 ? void 0 : _a.DFUFilePartsOnCluster) || []), true); }; LogicalFile.prototype.fileParts = function () { var _a, _b; var retVal = []; for (var _i = 0, _c = ((_a = this.DFUFilePartsOnClusters) === null || _a === void 0 ? void 0 : _a.DFUFilePartsOnCluster) || []; _i < _c.length; _i++) { var poc = _c[_i]; for (var _d = 0, _e = ((_b = poc === null || poc === void 0 ? void 0 : poc.DFUFileParts) === null || _b === void 0 ? void 0 : _b.DFUPart) || []; _d < _e.length; _d++) { var part = _e[_d]; var row = __assign(__assign({}, poc), part); delete row.DFUFileParts; retVal.push(row); } } return retVal; }; LogicalFile.prototype.update = function (request) { var _this = this; return this.connection.DFUInfo(__assign(__assign({}, request), { Cluster: this.Cluster, Name: this.Name })).then(function (response) { _this.set(__assign({ Cluster: _this.Cluster }, response.FileDetail)); return response; }); }; LogicalFile.prototype.fetchInfo = function () { var _this = this; return this.connection.DFUInfo({ Cluster: this.Cluster, Name: this.Name }).then(function (response) { _this.set(__assign({ Cluster: _this.Cluster }, response.FileDetail)); return response.FileDetail; }).catch(function (e) { // deleted --- var fileMissing = e.Exception.some(function (exception) { if (exception.Code === 20038) { _this.set("Name", _this.Name + " (Deleted)"); _this.set("StateID", 999); return true; } return false; }); if (!fileMissing) { logger.warning("Unexpected ESP exception: ".concat(e.message)); throw e; } return {}; }); }; LogicalFile.prototype.fetchDefFile = function (format) { return this.connection.DFUFile({ Name: this.Name, Format: format }); }; LogicalFile.prototype.fetchListHistory = function () { return this.connection.ListHistory({ Name: this.Name }).then(function (response) { var _a; return ((_a = response === null || response === void 0 ? void 0 : response.History) === null || _a === void 0 ? void 0 : _a.Origin) || []; }); }; LogicalFile.prototype.eraseHistory = function () { return this.connection.EraseHistory({ Name: this.Name }).then(function (response) { var _a; return ((_a = response === null || response === void 0 ? void 0 : response.History) === null || _a === void 0 ? void 0 : _a.Origin) || []; }); }; return LogicalFile; }(StateObject)); export { LogicalFile }; //# sourceMappingURL=logicalFile.js.map