all files / dist/wrappers/ StructurePropertyWrapper.js

90.91% Statements 50/55
68.97% Branches 20/29
75% Functions 12/16
97.96% Lines 48/49
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79    60× 60× 60× 60×   40×   20× 20×   20× 20×   20× 20×       10×   48×   60× 24× 24× 12×   48× 40×   10×   10×                                  
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    Iif (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) Eif (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var utils_1 = require("./../utils");
var StructurePropertyWrapper = (function () {
    function StructurePropertyWrapper(wrapperFactory, transformOptions, parent, prop) {
        this.wrapperFactory = wrapperFactory;
        this.transformOptions = transformOptions;
        this.parent = parent;
        this.prop = prop;
    }
    StructurePropertyWrapper.prototype.getName = function () {
        return this.prop.name;
    };
    StructurePropertyWrapper.prototype.hasMatchedOptInTransforms = function () {
        var _this = this;
        return this.transformOptions.getOptInPropertyTransforms().some(function (p) { return p.condition(_this.prop, _this.parent); });
    };
    StructurePropertyWrapper.prototype.getMatchedDefaultTransforms = function () {
        var _this = this;
        return this.transformOptions.getDefaultValueTransforms().filter(function (p) { return p.condition(_this.prop, _this.parent); });
    };
    StructurePropertyWrapper.prototype.getMatchedPropertyTransforms = function () {
        var _this = this;
        return this.transformOptions.getPropertyTransforms().filter(function (p) { return p.condition(_this.prop, _this.parent); });
    };
    StructurePropertyWrapper.prototype.getDefinition = function () {
        return this.prop;
    };
    StructurePropertyWrapper.prototype.getIsOptional = function () {
        return this.prop.isOptional;
    };
    StructurePropertyWrapper.prototype.getType = function () {
        return this.wrapperFactory.getStructureType(this.wrapperFactory.getStructure(this.parent), this.prop.type);
    };
    StructurePropertyWrapper.prototype.shouldIgnoreProperty = function () {
        for (var _i = 0, _a = this.transformOptions.getIgnorePropertyTransforms(); _i < _a.length; _i++) {
            var tranform = _a[_i];
            if (tranform.condition(this.prop, this.parent))
                return true;
        }
        if (this.getType().shouldIgnoreType())
            return true;
        return false;
    };
    StructurePropertyWrapper.prototype.shouldWriteOptionalAnyCheck = function () {
        return this.prop.isOptional && (this.prop.type.unionTypes.length > 0 || this.prop.type.definitions.length > 0);
    };
    StructurePropertyWrapper.prototype.getAllValidTypeStructures = function () {
        return this.getType().getAllValidDefinitions();
    };
    return StructurePropertyWrapper;
}());
__decorate([
    utils_1.Memoize
], StructurePropertyWrapper.prototype, "hasMatchedOptInTransforms", null);
__decorate([
    utils_1.Memoize
], StructurePropertyWrapper.prototype, "getMatchedDefaultTransforms", null);
__decorate([
    utils_1.Memoize
], StructurePropertyWrapper.prototype, "getMatchedPropertyTransforms", null);
__decorate([
    utils_1.Memoize
], StructurePropertyWrapper.prototype, "getType", null);
__decorate([
    utils_1.Memoize
], StructurePropertyWrapper.prototype, "shouldIgnoreProperty", null);
__decorate([
    utils_1.Memoize
], StructurePropertyWrapper.prototype, "getAllValidTypeStructures", null);
exports.StructurePropertyWrapper = StructurePropertyWrapper;
 
//# sourceMappingURL=StructurePropertyWrapper.js.map