UNPKG

@pebula/metap

Version:
1,869 lines (1,859 loc) 136 kB
import { isFunction, stringify, isString, isNumber, isStaticDecorator, ensureTargetIsType, Mixin, MixinFree, isUndefined, getProtoChain } from '@pebula/utils'; import { __extends, __spread, __values, __read, __decorate, __metadata } from 'tslib'; /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** @type {?} */ var ERROR_EXEC_TYPE = Symbol('Throw'); var Errors = /** @class */ (function () { function Errors() { // support for post instantiation mixins on the prototype (plugins) - don't use new. Errors.create(this); } Object.defineProperty(Errors.prototype, "throw", { /** * Returns a marked Errors repository where the next call to an error object will throw. * * e.g. `errors.THROW().decorator(...)` will throw */ get: /** * Returns a marked Errors repository where the next call to an error object will throw. * * e.g. `errors.THROW().decorator(...)` will throw * @template THIS * @this {THIS} * @return {THIS} */ function () { var _a; return Object.assign(Object.create((/** @type {?} */ (this))), (_a = {}, _a[ERROR_EXEC_TYPE] = 'throw', _a)); }, enumerable: true, configurable: true }); /** * @param {?} target * @param {?} message * @param {?=} propertyName * @return {?} */ Errors.prototype.decorator = /** * @param {?} target * @param {?} message * @param {?=} propertyName * @return {?} */ function (target, message, propertyName) { /** @type {?} */ var CLS = isFunction(target) ? target : target.constructor; if (!propertyName) { return this.ERROR("Invalid decorator @ " + stringify(CLS) + "}: " + message); } else { /** @type {?} */ var dot = CLS === target ? '#' : '.'; return this.ERROR("Invalid decorator @ " + stringify(target) + dot + stringify(propertyName) + ": " + message); } }; /** * @param {?} model * @param {?} message * @return {?} */ Errors.prototype.model = /** * @param {?} model * @param {?} message * @return {?} */ function (model, message) { return this.ERROR("Model Error [" + stringify(model) + "]: " + message); }; /** * @param {?} model * @param {?} expectedCol * @return {?} */ Errors.prototype.modelSingleCol = /** * @param {?} model * @param {?} expectedCol * @return {?} */ function (model, expectedCol) { return this.ERROR("Model Error:" + expectedCol ? "Expected a COLLECTION but got an OBJECT [Target: " + stringify(model) + "]" : "Expected an OBJECT but got a COLLECTION [Target: " + stringify(model) + "]"); }; /** * @internal */ /** * \@internal * @template T * @param {?} message * @param {?=} assign * @return {?} */ Errors.prototype.ERROR = /** * \@internal * @template T * @param {?} message * @param {?=} assign * @return {?} */ function (message, assign) { /** @type {?} */ var err = new Error(message); if (assign) { Object.assign(err, assign); } if (this[ERROR_EXEC_TYPE] === 'throw') { throw err; } else { return (/** @type {?} */ (err)); } }; /** * Creates a new TargetStore instance. * @param instance optional, used internally */ /** * Creates a new TargetStore instance. * @param {?=} instance optional, used internally * @return {?} */ Errors.create = /** * Creates a new TargetStore instance. * @param {?=} instance optional, used internally * @return {?} */ function (instance) { /** @type {?} */ var errors = instance || Object.create(Errors.prototype); return errors; }; return Errors; }()); /** @type {?} */ var errors = Errors.create(); var _a; /** @type {?} */ var emptyIterator = (_a = { next: /** * @return {?} */ function () { return { value: null, done: true }; } }, _a[Symbol.iterator] = /** * @return {?} */ function () { return emptyIterator; }, _a); // TODO: move to separate package along with other utils on @tdm/core /** * A dual map, key->key->value * @template K, K1, V */ var // TODO: move to separate package along with other utils on @tdm/core /** * A dual map, key->key->value * @template K, K1, V */ DualKeyMap = /** @class */ (function () { function DualKeyMap() { this.map = new Map(); this[Symbol.toStringTag] = 'Map'; } /** * @param {?} type * @param {?=} id * @return {?} */ DualKeyMap.prototype.has = /** * @param {?} type * @param {?=} id * @return {?} */ function (type, id) { if (id === undefined) { return this.map.has(type); } else { /** @type {?} */ var t = this.map.get(type); return t ? t.has(id) : false; } }; /** * @param {?} type * @param {?=} id * @return {?} */ DualKeyMap.prototype.get = /** * @param {?} type * @param {?=} id * @return {?} */ function (type, id) { /** @type {?} */ var t = this.map.get(type); return id === undefined ? t : t && t.get(id); }; /** * @param {?} type * @param {?=} id * @return {?} */ DualKeyMap.prototype.delete = /** * @param {?} type * @param {?=} id * @return {?} */ function (type, id) { if (id === undefined) { return this.map.delete(type); } else { /** @type {?} */ var t = this.map.get(type); return !(t && t.delete(id)); } }; /** * @param {?} type * @param {?} idOrMap * @param {?=} value * @return {?} */ DualKeyMap.prototype.set = /** * @param {?} type * @param {?} idOrMap * @param {?=} value * @return {?} */ function (type, idOrMap, value) { if (idOrMap instanceof Map) { if (arguments.length === 2) { this.map.set(type, idOrMap); } } else { /** @type {?} */ var t = this.map.get(type) || new Map(); t.set(idOrMap, value); this.map.set(type, t); } }; /** * @param {?=} type * @return {?} */ DualKeyMap.prototype.clear = /** * @param {?=} type * @return {?} */ function (type) { if (type === undefined) { this.map.clear(); } { /** @type {?} */ var t = this.map.get(type); t && t.clear(); } }; /** * @param {?} callbackfn * @param {?} type * @param {?=} thisArg * @return {?} */ DualKeyMap.prototype.forEach = /** * @param {?} callbackfn * @param {?} type * @param {?=} thisArg * @return {?} */ function (callbackfn, type, thisArg) { if (callbackfn === true) { this.map.forEach((/** @type {?} */ (type)), thisArg); } else { /** @type {?} */ var t = this.map.get((/** @type {?} */ (type))); t && t.forEach((/** @type {?} */ (callbackfn)), thisArg); } }; /** * @param {?=} type * @return {?} */ DualKeyMap.prototype.entries = /** * @param {?=} type * @return {?} */ function (type) { if (type === undefined) { return this.map.entries(); } else { /** @type {?} */ var t = this.map.get((/** @type {?} */ (type))); return t ? t.entries() : this.makeEmptyIterator(); } }; /** * @param {?=} type * @return {?} */ DualKeyMap.prototype.keys = /** * @param {?=} type * @return {?} */ function (type) { if (type === undefined) { return this.map.keys(); } else { /** @type {?} */ var t = this.map.get((/** @type {?} */ (type))); return t ? t.keys() : this.makeEmptyIterator(); } }; /** * @param {?=} type * @return {?} */ DualKeyMap.prototype.values = /** * @param {?=} type * @return {?} */ function (type) { if (type === undefined) { return this.map.values(); } else { /** @type {?} */ var t = this.map.get((/** @type {?} */ (type))); return t ? t.values() : this.makeEmptyIterator(); } }; Object.defineProperty(DualKeyMap.prototype, "size", { get: /** * @return {?} */ function () { return this.map.size; }, enumerable: true, configurable: true }); /** * @param {?} type * @return {?} */ DualKeyMap.prototype.sizeOf = /** * @param {?} type * @return {?} */ function (type) { /** @type {?} */ var t = this.map.get(type); return t ? t.size : 0; }; /** * @private * @return {?} */ DualKeyMap.prototype.makeEmptyIterator = /** * @private * @return {?} */ function () { return emptyIterator; }; /** * @return {?} */ DualKeyMap.prototype[Symbol.iterator] = /** * @return {?} */ function () { return this.map[Symbol.iterator](); }; return DualKeyMap; }()); if (false) { /** * @type {?} * @protected */ DualKeyMap.prototype.map; /* Skipping unnamed member: readonly [Symbol.toStringTag]: 'Map' = 'Map';*/ } /** * The child of Map and Set * @template K, V */ var /** * The child of Map and Set * @template K, V */ KeySet = /** @class */ (function () { function KeySet() { this.map = new Map(); } /** * @param {?} key * @param {?=} value * @return {?} */ KeySet.prototype.has = /** * @param {?} key * @param {?=} value * @return {?} */ function (key, value) { if (arguments.length === 1) { return this.map.has(key); } else { /** @type {?} */ var t = this.map.get(key); return t ? t.has(value) : false; } }; /** * @param {?} key * @param {?=} index * @return {?} */ KeySet.prototype.get = /** * @param {?} key * @param {?=} index * @return {?} */ function (key, index) { if (arguments.length === 1) { return this.map.get(key); } else { /** @type {?} */ var set = this.map.get(key); if (set) { return SetExt.index(set, index); } } }; /** * Set's the Set for a key. * @param key * @param set An optional set, if not supplied a new Set is created. */ /** * Set's the Set for a key. * @param {?} key * @param {?=} set An optional set, if not supplied a new Set is created. * @return {?} */ KeySet.prototype.set = /** * Set's the Set for a key. * @param {?} key * @param {?=} set An optional set, if not supplied a new Set is created. * @return {?} */ function (key, set) { if (!set) { set = new Set(); } this.map.set(key, set); return set; }; /** * @template THIS * @this {THIS} * @param {?} key * @param {?} value * @return {THIS} */ KeySet.prototype.add = /** * @template THIS * @this {THIS} * @param {?} key * @param {?} value * @return {THIS} */ function (key, value) { /** @type {?} */ var t = (/** @type {?} */ (this)).map.get(key) || new Set(); t.add(value); (/** @type {?} */ (this)).map.set(key, t); return (/** @type {?} */ (this)); }; /** * @param {?=} key * @return {?} */ KeySet.prototype.clear = /** * @param {?=} key * @return {?} */ function (key) { if (!key) { this.map.clear(); } else { /** @type {?} */ var t = this.map.get(key); t && t.clear(); } }; /** * @param {?} key * @param {?=} value * @return {?} */ KeySet.prototype.delete = /** * @param {?} key * @param {?=} value * @return {?} */ function (key, value) { if (arguments.length === 1) { return this.delete(key); } else { /** @type {?} */ var t = this.map.get(key); return t ? t.delete(value) : false; } }; /** * @param {?} key * @param {?} callbackfn * @param {?=} thisArg * @return {?} */ KeySet.prototype.forEach = /** * @param {?} key * @param {?} callbackfn * @param {?=} thisArg * @return {?} */ function (key, callbackfn, thisArg) { /** @type {?} */ var t = this.map.get(key); if (t) { t.forEach(callbackfn, thisArg); } }; Object.defineProperty(KeySet.prototype, "size", { /** * Returns the amount of map entries */ get: /** * Returns the amount of map entries * @return {?} */ function () { return this.map.size; }, enumerable: true, configurable: true }); /** * @param {?} key * @return {?} */ KeySet.prototype.sizeOf = /** * @param {?} key * @return {?} */ function (key) { /** @type {?} */ var t = this.map.get(key); return t ? t.size : 0; }; return KeySet; }()); if (false) { /** @type {?} */ KeySet.prototype.map; } /** * @template T */ var /** * @template T */ SetExt = /** @class */ (function (_super) { __extends(SetExt, _super); function SetExt() { return _super !== null && _super.apply(this, arguments) || this; } /** * @return {?} */ SetExt.prototype.first = /** * @return {?} */ function () { return SetExt.first(this); }; /** * @param {?} index * @return {?} */ SetExt.prototype.index = /** * @param {?} index * @return {?} */ function (index) { return SetExt.index(this, index); }; /** * @return {?} */ SetExt.prototype.asArray = /** * @return {?} */ function () { return SetExt.asArray(this); }; /** * @param {?} subset * @return {?} */ SetExt.prototype.isSuperset = /** * @param {?} subset * @return {?} */ function (subset) { return SetExt.isSuperset(this, subset); }; /** * @param {...?} source * @return {?} */ SetExt.prototype.combine = /** * @param {...?} source * @return {?} */ function () { var source = []; for (var _i = 0; _i < arguments.length; _i++) { source[_i] = arguments[_i]; } SetExt.combine.apply(SetExt, __spread([this], source)); }; /** * Deduct all of the sources * @param source * returns the target */ /** * Deduct all of the sources * @param {...?} source * returns the target * @return {?} */ SetExt.prototype.deduct = /** * Deduct all of the sources * @param {...?} source * returns the target * @return {?} */ function () { var source = []; for (var _i = 0; _i < arguments.length; _i++) { source[_i] = arguments[_i]; } SetExt.deduct.apply(SetExt, __spread([this], source)); }; /** * @param {...?} source * @return {?} */ SetExt.prototype.union = /** * @param {...?} source * @return {?} */ function () { var source = []; for (var _i = 0; _i < arguments.length; _i++) { source[_i] = arguments[_i]; } return SetExt.union.apply(SetExt, __spread([(/** @type {?} */ (SetExt)), (/** @type {?} */ (this))], source)); }; /** * Returns all the items that were in this set and the supplied set. * @param setA * @param setB * @param initSetExt */ /** * Returns all the items that were in this set and the supplied set. * @param {?} set * @return {?} */ SetExt.prototype.intersection = /** * Returns all the items that were in this set and the supplied set. * @param {?} set * @return {?} */ function (set) { return SetExt.intersection(this, (/** @type {?} */ (set)), true); }; /** * Returns all the items that are in this set, but not in the target set. * Returns a new SetExt instance. * @param set * @returns */ /** * Returns all the items that are in this set, but not in the target set. * Returns a new SetExt instance. * @param {?} set * @return {?} */ SetExt.prototype.difference = /** * Returns all the items that are in this set, but not in the target set. * Returns a new SetExt instance. * @param {?} set * @return {?} */ function (set) { return SetExt.difference(this, (/** @type {?} */ (set)), true); }; /** * Returns all the items that were not in this set and the supplied set. * Returns a new SetExt instance. * @param set * @returns */ /** * Returns all the items that were not in this set and the supplied set. * Returns a new SetExt instance. * @param {?} set * @return {?} */ SetExt.prototype.negative = /** * Returns all the items that were not in this set and the supplied set. * Returns a new SetExt instance. * @param {?} set * @return {?} */ function (set) { return SetExt.negative(this, (/** @type {?} */ (set)), true); }; /** * @template T * @param {?} set * @return {?} */ SetExt.first = /** * @template T * @param {?} set * @return {?} */ function (set) { return set.values().next().value; }; /** * @template T * @param {?} set * @param {?} index * @return {?} */ SetExt.index = /** * @template T * @param {?} set * @param {?} index * @return {?} */ function (set, index) { /** @type {?} */ var iterator = set.values(); for (var i = 0; i < index; i++) { if (iterator.next().done) { return undefined; } } return iterator.next().value; }; /** * @template T * @param {?} set * @return {?} */ SetExt.asArray = /** * @template T * @param {?} set * @return {?} */ function (set) { return Array.from(set); }; /** * @param {?} set * @param {?} subset * @return {?} */ SetExt.isSuperset = /** * @param {?} set * @param {?} subset * @return {?} */ function (set, subset) { // ohh NGC!!! /** * @param {?} v * @return {?} */ function x(v) { return !set.has(v); } return !SetExt.asArray(subset).some(x); }; /** * @template T * @param {?} target * @param {...?} source * @return {?} */ SetExt.combine = /** * @template T * @param {?} target * @param {...?} source * @return {?} */ function (target) { var source = []; for (var _i = 1; _i < arguments.length; _i++) { source[_i - 1] = arguments[_i]; } for (var i = 0, len = source.length; i < len; i++) { /** @type {?} */ var arr = Array.isArray(source[i]) ? source[i] : SetExt.asArray(source[i]); for (var z = 0, lenZ = arr.length; z < lenZ; z++) { if (!target.has(arr[z])) { target.add(arr[z]); } } } return target; }; /** * Deduct all of the sources from the target. * @param target * @param source * returns the target */ /** * Deduct all of the sources from the target. * @template T * @param {?} target * @param {...?} source * returns the target * @return {?} */ SetExt.deduct = /** * Deduct all of the sources from the target. * @template T * @param {?} target * @param {...?} source * returns the target * @return {?} */ function (target) { var source = []; for (var _i = 1; _i < arguments.length; _i++) { source[_i - 1] = arguments[_i]; } for (var i = 0, len = source.length; i < len; i++) { /** @type {?} */ var arr = SetExt.asArray(source[i]); for (var z = 0, lenZ = arr.length; z < lenZ; z++) { target.delete(arr[z]); } } return target; }; /** * @template T * @param {...?} source * @return {?} */ SetExt.union = /** * @template T * @param {...?} source * @return {?} */ function () { var source = []; for (var _i = 0; _i < arguments.length; _i++) { source[_i] = arguments[_i]; } /** @type {?} */ var union = typeof source[0] === 'function' ? new ((/** @type {?} */ (source.shift())))() : new Set(); SetExt.combine.apply(SetExt, __spread([union], source)); return union; }; /** * Returns all the items that were in both sets. * @param setA * @param setB * @param initSetExt */ /** * Returns all the items that were in both sets. * @template T * @param {?} setA * @param {?} setB * @param {?=} initSetExt * @return {?} */ SetExt.intersection = /** * Returns all the items that were in both sets. * @template T * @param {?} setA * @param {?} setB * @param {?=} initSetExt * @return {?} */ function (setA, setB, initSetExt) { /** @type {?} */ var intersection = initSetExt ? new SetExt() : new Set(); /** @type {?} */ var arr = SetExt.asArray(setB); for (var z = 0, lenZ = arr.length; z < lenZ; z++) { if (setA.has(arr[z])) { intersection.add(arr[z]); } } return (/** @type {?} */ (intersection)); }; /** * Returns all the items that are in source set, but not in the target set. * @param source * @param target * @param initSetExt * @returns */ /** * Returns all the items that are in source set, but not in the target set. * @template T * @param {?} source * @param {?} target * @param {?=} initSetExt * @return {?} */ SetExt.difference = /** * Returns all the items that are in source set, but not in the target set. * @template T * @param {?} source * @param {?} target * @param {?=} initSetExt * @return {?} */ function (source, target, initSetExt) { /** @type {?} */ var difference = initSetExt ? new SetExt(source) : new Set(source); /** @type {?} */ var arr = SetExt.asArray(target); for (var z = 0, lenZ = arr.length; z < lenZ; z++) { difference.delete(arr[z]); } return (/** @type {?} */ (difference)); }; /** * Returns all the items that were not in both sets. * @param source * @param target * @param initSetExt * @returns */ /** * Returns all the items that were not in both sets. * @template T * @param {?} source * @param {?} target * @param {?=} initSetExt * @return {?} */ SetExt.negative = /** * Returns all the items that were not in both sets. * @template T * @param {?} source * @param {?} target * @param {?=} initSetExt * @return {?} */ function (source, target, initSetExt) { /** @type {?} */ var negative = initSetExt ? new SetExt(source) : new Set(source); /** @type {?} */ var arr = SetExt.asArray(target); for (var z = 0, lenZ = arr.length; z < lenZ; z++) { if (negative.has(arr[z])) { negative.delete(arr[z]); } else { negative.add(arr[z]); } } return (/** @type {?} */ (negative)); }; return SetExt; }(Set)); var MapExt = /** @class */ (function () { function MapExt() { } /** * Merge source map into target map. * @param target * @param source * @param diffOnly if true will only merge keys from source that does not exist on target. */ /** * Merge source map into target map. * @template K, V * @param {?} target * @param {?} source * @param {?=} diffOnly if true will only merge keys from source that does not exist on target. * @return {?} */ MapExt.mergeInto = /** * Merge source map into target map. * @template K, V * @param {?} target * @param {?} source * @param {?=} diffOnly if true will only merge keys from source that does not exist on target. * @return {?} */ function (target, source, diffOnly) { /** @type {?} */ var arr = MapExt.asKeyArray(source); for (var i = 0, len = arr.length; i < len; i++) { if (!diffOnly || !target.has(arr[i])) { target.set(arr[i], source.get(arr[i])); } } return target; }; /** * Set the values of an array into a map * @param arr * @param keySelector A function returning the key to be used in the map * @param map The map to set on, optional. If not set a new map is created. * @param diffOnly Set only new values, optional. Valid only if a map is supplied. * @returns */ /** * Set the values of an array into a map * @template K, V * @param {?} arr * @param {?} keySelector A function returning the key to be used in the map * @param {?=} map The map to set on, optional. If not set a new map is created. * @param {?=} diffOnly Set only new values, optional. Valid only if a map is supplied. * @return {?} */ MapExt.fromArray = /** * Set the values of an array into a map * @template K, V * @param {?} arr * @param {?} keySelector A function returning the key to be used in the map * @param {?=} map The map to set on, optional. If not set a new map is created. * @param {?=} diffOnly Set only new values, optional. Valid only if a map is supplied. * @return {?} */ function (arr, keySelector, map, diffOnly) { if (!(map instanceof Map)) { map = new Map(); diffOnly = false; } for (var i = 0, len = arr.length; i < len; i++) { /** @type {?} */ var key = keySelector(arr[i]); if (!diffOnly || !map.has(key)) { map.set(key, arr[i]); } } return map; }; /** * @template K, V * @param {?} map * @return {?} */ MapExt.asKeyValArray = /** * @template K, V * @param {?} map * @return {?} */ function (map) { return Array.from(map.entries()); }; /** * @template K, V * @param {?} map * @return {?} */ MapExt.asKeyArray = /** * @template K, V * @param {?} map * @return {?} */ function (map) { return Array.from(map.keys()); }; /** * @template K, V * @param {?} map * @return {?} */ MapExt.asValArray = /** * @template K, V * @param {?} map * @return {?} */ function (map) { return Array.from(map.values()); }; /** * @template K, V * @param {?} map * @return {?} */ MapExt.asObjectLiteral = /** * @template K, V * @param {?} map * @return {?} */ function (map) { /** * @param {?} prev * @param {?} curr * @return {?} */ function x(prev, curr) { prev[curr.toString()] = map.get(curr); return prev; } ; return MapExt.asKeyArray(map).reduce(x, {}); }; return MapExt; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** @type {?} */ var reflection = { designType: /** * @param {?} target * @param {?} key * @return {?} */ function (target, key) { return ((/** @type {?} */ (Reflect))).getMetadata('design:type', target, key); }, paramTypes: /** * @param {?} target * @param {?} key * @return {?} */ function (target, key) { return ((/** @type {?} */ (Reflect))).getMetadata('design:paramtypes', target, key); } }; /** * @param {?} getter * @return {?} */ function LazyInit(getter) { return (/** * @param {?} target * @param {?} propertyKey * @param {?=} descriptor * @return {?} */ function (target, propertyKey, descriptor) { if (descriptor) { throw new Error('LazyInit can only decorate properties'); } Object.defineProperty(target, propertyKey, { configurable: true, get: /** * @return {?} */ function () { /** @type {?} */ var ret = getter.call(this); Object.defineProperty(this, propertyKey, { value: ret }); return ret; } }); }); } var ɵ0 = /** * @return {?} */ function () { /** @type {?} */ var findRemove = (/** * @template T * @param {?} arr * @param {?} predicate * @param {?=} thisArg * @return {?} */ function (arr, predicate, thisArg) { /** @type {?} */ var idx = arr.findIndex(predicate, thisArg); if (idx > -1) { return arr.splice(idx, 1)[0]; } }); return { findRemove: findRemove }; }; /** * \@pluginApi * @type {?} */ var array = ((ɵ0))(); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @record */ function NamingStrategyFn() { } /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @abstract */ var /** * @abstract */ BaseMetadata = /** @class */ (function () { function BaseMetadata(decoratorInfo) { this.decoratorInfo = decoratorInfo; this.name = decoratorInfo.name; } return BaseMetadata; }()); if (false) { /** * The property name that the decorator wraps, if it wraps a property, member or constructor param. * \@return * @type {?} */ BaseMetadata.prototype.name; /** @type {?} */ BaseMetadata.prototype.decoratorInfo; } /** * @abstract */ var /** * @abstract */ BaseParamMetadata = /** @class */ (function (_super) { __extends(BaseParamMetadata, _super); function BaseParamMetadata(di, target) { var _this = _super.call(this, di) || this; _this.paramType = reflection.paramTypes(target.prototype, _this.name)[di.paramIndex]; return _this; } Object.defineProperty(BaseParamMetadata.prototype, "paramIndex", { get: /** * @return {?} */ function () { return this.decoratorInfo.paramIndex; }, enumerable: true, configurable: true }); return BaseParamMetadata; }(BaseMetadata)); if (false) { /** @type {?} */ BaseParamMetadata.prototype.paramType; } /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @param {?} from * @param {?} fallback * @return {?} */ function propAliasConfig(from, fallback) { /** @type {?} */ var incoming; /** @type {?} */ var outgoing; if (!from) { incoming = outgoing = fallback; } else if (isString(from)) { incoming = outgoing = from; } else { incoming = from.incoming || fallback; outgoing = from.outgoing || fallback; } return { incoming: incoming, outgoing: outgoing }; } /** * @param {?} from * @return {?} */ function propTransformConfig(from) { /** @type {?} */ var incoming; /** @type {?} */ var outgoing; if (isFunction(from)) { incoming = outgoing = from; } else if (from) { if (isFunction(from.incoming)) { incoming = from.incoming; } if (isFunction(from.outgoing)) { outgoing = from.outgoing; } } return { incoming: incoming, outgoing: outgoing }; } /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** @type {?} */ var eventHandlers = new KeySet(); /** @type {?} */ var metaInitHandlers = new KeySet(); /** * Event listeners registration object for lifecycle metadata events on a target. * * \@pluginApi * \@mixable * \@singleton */ var /** * Event listeners registration object for lifecycle metadata events on a target. * * \@pluginApi * \@mixable * \@singleton */ TargetEvents = /** @class */ (function () { function TargetEvents() { // support for post instantiation mixins on the prototype (plugins) - don't use new. TargetEvents.create(this); } /** * @template TMetaArgs, TMetaClass, Z * @param {?} metaClass * @return {?} */ TargetEvents.prototype.metaInit = /** * @template TMetaArgs, TMetaClass, Z * @param {?} metaClass * @return {?} */ function (metaClass) { return { run: /** * @param {?} handler * @return {?} */ function (handler) { metaInitHandlers.add(metaClass, handler); } }; }; /** * Fired when the {@link TargetMetadata} instance is created for the target) * * FireBefore: processType */ /** * Fired when the {\@link TargetMetadata} instance is created for the target) * * FireBefore: processType * @param {?} handler * @return {?} */ TargetEvents.prototype.createMetadata = /** * Fired when the {\@link TargetMetadata} instance is created for the target) * * FireBefore: processType * @param {?} handler * @return {?} */ function (handler) { if (isFunction(handler)) { eventHandlers.add('createMetadata', handler); } }; /** * Fired before the type is processed, after extending all metadata. * This event is not guaranteed to fire, it will fire only if the type is decorated with an appropriate decorator. * * FireAfter: createMetadata * FireBefore: processType */ /** * Fired before the type is processed, after extending all metadata. * This event is not guaranteed to fire, it will fire only if the type is decorated with an appropriate decorator. * * FireAfter: createMetadata * FireBefore: processType * @param {?} handler * @return {?} */ TargetEvents.prototype.beforeProcessType = /** * Fired before the type is processed, after extending all metadata. * This event is not guaranteed to fire, it will fire only if the type is decorated with an appropriate decorator. * * FireAfter: createMetadata * FireBefore: processType * @param {?} handler * @return {?} */ function (handler) { if (isFunction(handler)) { eventHandlers.add('beforeProcessType', handler); } }; /** * Fired when the type is processed, after extending all metadata. * This event is not guaranteed to fire, it will fire only if the type is decorated with an appropriate decorator. * * FireAfter: beforeProcessType */ /** * Fired when the type is processed, after extending all metadata. * This event is not guaranteed to fire, it will fire only if the type is decorated with an appropriate decorator. * * FireAfter: beforeProcessType * @param {?} handler * @return {?} */ TargetEvents.prototype.processType = /** * Fired when the type is processed, after extending all metadata. * This event is not guaranteed to fire, it will fire only if the type is decorated with an appropriate decorator. * * FireAfter: beforeProcessType * @param {?} handler * @return {?} */ function (handler) { if (isFunction(handler)) { eventHandlers.add('processType', handler); } }; /** * @param {?=} instance * @return {?} */ TargetEvents.create = /** * @param {?=} instance * @return {?} */ function (instance) { /** @type {?} */ var targetStore = instance || Object.create(TargetEvents.prototype); targetStore.FIRE = EVENT_FIRE; return targetStore; }; return TargetEvents; }()); if (false) { /** @type {?} */ TargetEvents.prototype.FIRE; } var ɵ0$1 = /** * @param {?} target * @return {?} */ function (target) { return fireTargetEvent('createMetadata', target); }, ɵ1 = /** * @param {?} target * @return {?} */ function (target) { return fireTargetEvent('beforeProcessType', target); }, ɵ2 = /** * @param {?} target * @return {?} */ function (target) { return fireTargetEvent('processType', target); }; /** @type {?} */ var EVENT_FIRE = { metaInit: /** * @template TMetaArgs, TMetaClass, Z * @param {?} metaClass * @param {?} target * @param {?} value * @param {?=} metaArgs * @return {?} */ function (metaClass, target, value, metaArgs) { /** @type {?} */ var eventMap = metaInitHandlers.get(metaClass); if (eventMap) { Array.from(eventMap.values()).forEach((/** * @param {?} handler * @return {?} */ function (handler) { return handler(target, value, metaArgs); })); } }, createMetadata: (ɵ0$1), beforeProcessType: (ɵ1), processType: (ɵ2) }; /** @type {?} */ var targetEvents = TargetEvents.create(); /** * @param {?} event * @param {?} target * @return {?} */ function fireTargetEvent(event, target) { /** @type {?} */ var eventMap = eventHandlers.get(event); if (eventMap) { Array.from(eventMap.values()).forEach((/** * @param {?} handler * @return {?} */ function (handler) { return handler(target); })); } } /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** @type {?} */ var lazyRefKey = Symbol('lazyRef'); /** @type {?} */ var toString = (/** * @return {?} */ function () { return stringify(this()); }); var ɵ0$2 = toString; /** * Allows to refer to references which are not yet defined. * * For instance, `lazyRef` is used when the `token` which we need to refer to for the purposes of * DI is declared, * but not yet defined. It is also used when the `token` which we use when creating a query is not * yet defined. * * ### Example * {\@example core/di/ts/forward_ref/forward_ref_spec.ts region='forward_ref'} * \@experimental * @template T * @param {?} lazyRefFn * @return {?} */ function lazyRef(lazyRefFn) { lazyRefFn[lazyRefKey] = lazyRef; lazyRefFn.toString = toString; return (/** @type {?} */ (lazyRefFn)); } (function (lazyRef) { /** * Lazily retrieves the reference value from a lazyRef. * * Acts as the identity function when given a non-forward-ref value. * * ### Example ([live demo](http://plnkr.co/edit/GU72mJrk1fiodChcmiDR?p=preview)) * * {\@example core/di/ts/forward_ref/forward_ref_spec.ts region='resolve_forward_ref'} * * See: {\@link lazyRef} * \@experimental * @param {?} type * @return {?} */ function resolve(type) { return isFunction(type) && type[lazyRefKey] === lazyRef ? type() : type; } lazyRef.resolve = resolve; })(lazyRef || (lazyRef = {})); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * Proxy definition for the current metadata class on an other metadata class. * * ProxyHost enables syntax sugar, where a user can avoid setting Decorators and set the metadata in one place. * For example: * * ```ts * class MyModel { * \@Prop() name: string; * * \@Prop() age: number; * } * ``` * * Say we want to exclude the property `age`: * * ```ts * class MyModel { * \@Prop() name: string; * * \@Prop() \@Exclude() age: number; * } * ``` * * If `\@Exclude` defines a \@Prop as a ProxyHost we can: * * ```ts * class MyModel { * \@Prop() name: string; * * \@Prop({exclude: true}) age: number; * } * ``` * * While this example doesn't seem to do much it actually does. * * - We can omit the import of `Exclude`, less code. * - We reduced the definition boilerplate, in this example its not much but others can have a big impact. * - The code is more readable, less decorators equals better readability. Prop holds the whole schema. * * * * Note that a property decorators and define a proxy in a class decorator allowing multiple properties * to be set from the root. * * Consider a model that uses multiple extensions (http, ng-dynamic-forms, etc...) having to define all of the * different decorators over and over has an impact, both over the payload and the developer experience. * * @record * @template T */ function ProxyHostMetadataArgs() { } if (false) { /** * The proxy metadata class * @type {?} */ ProxyHostMetadataArgs.prototype.host; /** * The key on the proxy metadata class arguments interface, this key is looked up and if set * the value is taken as the metadata arguments object for the current metadata class. * * > Defining a key on the proxy metadata arguments interface will result in a type error since typescript * will not recognize the key, to solve that a type extension is required. A ProxyHost can not be set without a type * extension * * Example: Creating a type extension to `PropMetadataArgs` * declare module './prop' { * interface PropMetadataArgs { * exclude?: true | ExcludeMetadataArgs; * } * } * @type {?} */ ProxyHostMetadataArgs.prototype.containerKey; /** * When true, treats an array as a collection where each value is a instance of the metadata. * This enables settings multiple metadata values. * @type {?|undefined} */ ProxyHostMetadataArgs.prototype.forEach; /** * An optional transformation function, allows changing the metadata arguments. * @param {?} metaArgs * @return {?} */ ProxyHostMetadataArgs.prototype.before = function (metaArgs) { }; } /** * @record * @template TMetaArgs, TMetaClass */ function MetaClassMetadataArgs() { } if (false) { /** * When true, the metadata is saved under the global key. * * > Global key logic is implemented throughout the library, make sure to follow this logic when * implementing custom behavior (for example, overriding the default factory and/or register methods) * Since most custom implementation are metadata class specific this should be an issue. * * * \@default undefined; * @type {?|undefined} */ MetaClassMetadataArgs.prototype.single; /** * A Metadata class to inherit the MetaClassMetadataArgs from. * * Note that the MetaClassMetadataArgs used to defined the parent are used and not the * MetaClassMetadata instance. * @type {?|undefined} */ MetaClassMetadataArgs.prototype.inherit; /** * Defines a proxy for the current metadata class on an other metadata class. * See {\@link ProxyHostMetadataArgs} * @type {?|undefined} */ MetaClassMetadataArgs.prototype.proxy; /** * Register the metadata instance. * This operation save the instance in the targetStore. * \@param meta * @type {?|undefined} */ MetaClassMetadataArgs.prototype.register; /** * Optional implementation of extend logic FOR non-single metadata, logic that handles 1 type extending another type. * If not set, the Metadata class is not extendable and will not inherit metadata from child types. * If the method returns undefined it will also not extend the Metadata class. * * 'to' can be undefined, if so it means that that Metadata class was never assigned to the type. * * #### You can set on of the predefined extend functions. * - prop: An extending implementation suitable for property decorators. Expecting a `Map<TdmPropertyKey, T>`, it * will merge the source into the target. * * \@param from * \@param to * \@param meta * \@param meta.from the target source * \@param meta.to the target target * \@return the new extended value. * @type {?|undefined} */ MetaClassMetadataArgs.prototype.extend; /** * Optional implementation of extend logic FOR single metadata, logic that handles one type extending another type. * If not set, the Metadata class is not extendable and will not inherit metadata from child types. * If the method returns undefined it will also not extend the Metadata class. * * 'to' can be undefined, if so it means that that Metadata class was never assigned to the type. * * \@param from * \@param to * \@param meta * \@return the new extended value. * @type {?|undefined} */ MetaClassMetadataArgs.prototype.extendSingle; /** * A list of supported decoration targets for a metadata class. * If not set (or empty list) all of the targets are allowed. * @type {?|undefined} */ MetaClassMetadataArgs.prototype.allowOn; /** * An optional function, that is invoked right after the metadata class is created for the meta-class. * Note that this event run ONCE for every meta-class class, which happens when the decorator \@MetaClass is invoked. * @type {?|undefined} */ MetaClassMetadataArgs.prototype.onCreated; /** * Additional decorators to run before the decorator for this meta-class invokes. * Note that the factory function run's before but the actual decorators run after * @type {?|undefined} */ MetaClassMetadataArgs.prototype.decorateBefore; /** * Additional decorators to run after the decorator for this meta-class invokes. * Note that the factory function run's after but the actual decorators run before * @type {?|undefined} */ MetaClassMetadataArgs.prototype.decorateAfter; /** * Create a new metadata instance. * @this {?} * @param {?} metaArgs * @param {?} target * @param {?} info * @param {?=} key * @param {?=} desc * @return {?} */ MetaClassMetadataArgs.prototype.factory = function (metaArgs, target, info, key, desc) { }; } /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @param {...?} args * @return {?} */ function decoratorInfo() { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } if (isFunction(args[0]) && !args[1]) { // target is function and key is not set return { type: 'class' }; } else { /** @type {?} */ var type = args.length === 3 && isNumber(args[2]) ? 'param' : 'member'; /** @type {?} */ var result = { type: type, name: args[1], isStatic: isStaticDecorator(args[0]), hasDescriptor: args.length === 3 && type === 'member' }; if (type === 'param') { result.paramIndex = args[2]; } return result; } } /** @type {?} */ var registerHelpers = (/** @type {?} */ ({})); /** @type {?} */ var extendHelpers = (/** @type {?} */ ({})); /** * @param {?} type * @param {?} name * @param {?} helperFn * @return {?} */ function setMetaHelper(type, name, helperFn) { switch (type) { case 'extend': extendHelpers[nam