diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 423b24c..0000000 --- a/.gitmodules +++ /dev/null @@ -1,4 +0,0 @@ -[submodule "submodules/Type-R"] - path = submodules/Type-R - url = https://github.com/Volicon/Type-R.git - branch = master diff --git a/README.md b/README.md index aa8a71c..a8dcdf1 100644 --- a/README.md +++ b/README.md @@ -1,28 +1,8 @@ -NestedTypes 2.0 is BackboneJS compatibility layer for the [Type-R](https://volicon.github.io/Type-R/Getting_Started.html) data framework. Type-R is Model/Collection core written from the scratch with the TypeScript and has no side dependencies. +NestedTypes v3.0 is BackboneJS compatibility layer for the [Type-R](https://volicon.github.io/Type-R/Getting_Started.html) data framework. NestedTypes adds support for BackboneJS REST API, underscore Model and Collection methods, and the rest of Backbone 1.1 classes (View, Router). -NestedTypes adds support for REST (standard BackboneJS API), Underscore methods, and Backbone 1.1 classes. +Functional-wise, there's no reason to prefer NestedTypes over the Type-R any more. If you don't need BackboneJS backward compatibility, move to the [Type-R](https://volicon.github.io/Type-R) which doesn't have any legacy dependencies like jQuery and underscore. -> If you're upgrading from the version 1.3, *[there are compatibility issues](/docs/compatibility.md)*. -> Mostly due to the fact that the Type-R and NestedTypes 2.0 is built around the concept of [aggregation trees](https://volicon.github.io/Type-R/API_by_feature/Aggregation_tree.html). -> NestedTypes 1.3 code won't work without refactoring. - -# Important Notice - -Staring with v2.0 Type-R includes generic I/O abstraction which is far superior to the legacy BackboneJS I/O. -NestedTypes & NestedReact will be maintained as the BackboneJS compatibility layer as long as Verizon/Volicon systems have legacy Backbone code. Therefore: - -- NestedTypes docs won't be updated. Use [Type-R](https://volicon.github.io/Type-R) documentation as you primary source of documentation. -- Functional-wise, there's no reason to prefer NestedTypes over the Type-R any more. If you don't need BackboneJS backward compatibility, move to the [Type-R](https://volicon.github.io/Type-R) which doesn't have any legacy dependencies like jQuery and underscore. - -# Features - -Post-backbone data framework. 10 times faster, first-class support for nested models and collections and relations by id. - -- ES6 classes support. -- Deeply observable changes. -- First-class support for [aggregation](https://volicon.github.io/Type-R/API_by_feature/Aggregation_tree.html) and [relations by id](https://volicon.github.io/Type-R/API_by_feature/id-references_and_Stores.html). -- Attribute type annotations and dynamic type safety. -- More than 10 times faster than BackboneJS and 2-4 times faster than NestedTypes 1.3 in all browsers. +NestedTypes & NestedReact will be maintained as long as Verizon/Volicon systems have legacy Backbone code. NestedTypes docs won't be updated. Use [Type-R](https://volicon.github.io/Type-R) documentation as a primary source of documentation. # Installation & Requirements diff --git a/dist/index.js b/dist/index.js index 9146234..9416099 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,2 +1,2 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("underscore"),require("jquery")):"function"==typeof define&&define.amd?define(["exports","underscore","jquery"],e):e(t.Nested={},t._,t.$)}(this,function(s,f,t){"use strict";var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function a(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var u=function(){return(u=Object.assign||function(t){for(var e,n=1,r=arguments.length;n").attr(t);this.setElement(e,!1)}}});var or=/\((.*?)\)/g,sr=/(\(\?)?:\w+/g,ar=/\*\w+/g,ur=/[\-{}\[\]+?.,\\\^$|#\s]/g;function cr(){this.handlers=[],this.checkUrl=f.bind(this.checkUrl,this),"undefined"!=typeof window&&(this.location=window.location,this.history=window.history)}f.extend(ir.prototype,{initialize:function(){},route:function(n,r,i){f.isRegExp(n)||(n=this._routeToRegExp(n)),f.isFunction(r)&&(i=r,r=""),i||(i=this[r]);var o=this;return tr.history.route(n,function(t){var e=o._extractParameters(n,t);!1!==o.execute(i,e,r)&&(o.trigger.apply(o,["route:"+r].concat(e)),o.trigger("route",r,e),tr.history.trigger("route",o,r,e))}),this},execute:function(t,e,n){t&&t.apply(this,e)},navigate:function(t,e){return tr.history.navigate(t,e),this},_bindRoutes:function(){if(this.routes){this.routes=f.result(this,"routes");for(var t,e=f.keys(this.routes);null!=(t=e.pop());)this.route(t,this.routes[t])}},_routeToRegExp:function(t){return t=t.replace(ur,"\\$&").replace(or,"(?:$1)?").replace(sr,function(t,e){return e?t:"([^/?]+)"}).replace(ar,"([^?]*?)"),new RegExp("^"+t+"(?:\\?([\\s\\S]*))?$")},_extractParameters:function(t,e){var n=t.exec(e).slice(1);return f.map(n,function(t,e){return e===n.length-1?t||null:t?decodeURIComponent(t):null})}});var hr=/^[#\/]|\s+$/g,lr=/^\/+|\/+$/g,pr=/#.*$/;cr.started=!1,f.extend(cr.prototype,{interval:50,atRoot:function(){return this.location.pathname.replace(/[^\/]$/,"$&/")===this.root&&!this.getSearch()},matchRoot:function(){return this.decodeFragment(this.location.pathname).slice(0,this.root.length-1)+"/"===this.root},decodeFragment:function(t){return decodeURI(t.replace(/%25/g,"%2525"))},getSearch:function(){var t=this.location.href.replace(/#.*/,"").match(/\?.+/);return t?t[0]:""},getHash:function(t){var e=(t||this).location.href.match(/#(.*)$/);return e?e[1]:""},getPath:function(){var t=this.decodeFragment(this.location.pathname+this.getSearch()).slice(this.root.length-1);return"/"===t.charAt(0)?t.slice(1):t},getFragment:function(t){return null==t&&(t=this._usePushState||!this._wantsHashChange?this.getPath():this.getHash()),t.replace(hr,"")},start:function(t){if(cr.started)throw new Error("Backbone.history has already been started");if(cr.started=!0,this.options=f.extend({root:"/"},this.options,t),this.root=this.options.root,this._wantsHashChange=!1!==this.options.hashChange,this._hasHashChange="onhashchange"in window&&(void 0===document.documentMode||7").attr(t);this.setElement(e,!1)}}});var u=/\((.*?)\)/g,c=/(\(\?)?:\w+/g,l=/\*\w+/g,f=/[\-{}\[\]+?.,\\\^$|#\s]/g;function d(){this.handlers=[],this.checkUrl=p.bind(this.checkUrl,this),"undefined"!=typeof window&&(this.location=window.location,this.history=window.history)}p.extend(s.prototype,{initialize:function(){},route:function(r,n,i){p.isRegExp(r)||(r=this._routeToRegExp(r)),p.isFunction(n)&&(i=n,n=""),i||(i=this[n]);var s=this;return h.history.route(r,function(t){var e=s._extractParameters(r,t);!1!==s.execute(i,e,n)&&(s.trigger.apply(s,["route:"+n].concat(e)),s.trigger("route",n,e),h.history.trigger("route",s,n,e))}),this},execute:function(t,e,r){t&&t.apply(this,e)},navigate:function(t,e){return h.history.navigate(t,e),this},_bindRoutes:function(){if(this.routes){this.routes=p.result(this,"routes");for(var t,e=p.keys(this.routes);null!=(t=e.pop());)this.route(t,this.routes[t])}},_routeToRegExp:function(t){return t=t.replace(f,"\\$&").replace(u,"(?:$1)?").replace(c,function(t,e){return e?t:"([^/?]+)"}).replace(l,"([^?]*?)"),new RegExp("^"+t+"(?:\\?([\\s\\S]*))?$")},_extractParameters:function(t,e){var r=t.exec(e).slice(1);return p.map(r,function(t,e){return e===r.length-1?t||null:t?decodeURIComponent(t):null})}});var v=/^[#\/]|\s+$/g,g=/^\/+|\/+$/g,y=/#.*$/;d.started=!1,p.extend(d.prototype,{interval:50,atRoot:function(){return this.location.pathname.replace(/[^\/]$/,"$&/")===this.root&&!this.getSearch()},matchRoot:function(){return this.decodeFragment(this.location.pathname).slice(0,this.root.length-1)+"/"===this.root},decodeFragment:function(t){return decodeURI(t.replace(/%25/g,"%2525"))},getSearch:function(){var t=this.location.href.replace(/#.*/,"").match(/\?.+/);return t?t[0]:""},getHash:function(t){var e=(t||this).location.href.match(/#(.*)$/);return e?e[1]:""},getPath:function(){var t=this.decodeFragment(this.location.pathname+this.getSearch()).slice(this.root.length-1);return"/"===t.charAt(0)?t.slice(1):t},getFragment:function(t){return null==t&&(t=this._usePushState||!this._wantsHashChange?this.getPath():this.getHash()),t.replace(v,"")},start:function(t){if(d.started)throw new Error("Backbone.history has already been started");if(d.started=!0,this.options=p.extend({root:"/"},this.options,t),this.root=this.options.root,this._wantsHashChange=!1!==this.options.hashChange,this._hasHashChange="onhashchange"in window&&(void 0===document.documentMode||7= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport function __exportStar(m, exports) {\r\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\r\n}\r\n\r\nexport function __values(o) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator], i = 0;\r\n if (m) return m.call(o);\r\n return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\r\n result.default = mod;\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n","/**\n * Simple overridable logging stubs, writing to `console` by default.\n * Node.js users might want to redirect logging somewhere.\n * \n * This is the singleton avaliable globally through `Object.log` or \n * exported [[log]] variable.\n */\n\n /** Similar to underscore `_.defaults` */\nexport function defaults< T >( dest : T, ...sources : Object[] ) : T\nexport function defaults< T >( dest : T, source : Object ) : T {\n for( var name in source ) {\n if( source.hasOwnProperty( name ) && !dest.hasOwnProperty( name ) ) {\n dest[ name ] = source[ name ];\n }\n }\n\n if( arguments.length > 2 ){\n for( let i = 2; i < arguments.length; i++ ){\n const other = arguments[ i ];\n other && defaults( dest, other );\n }\n }\n\n return dest;\n}\n\n// Logger is the function.\nexport type Logger = ( level : LogLevel, error : string, props? : object ) => void;\n\nexport type LogLevel = 'none' | 'error' | 'warn' | 'info' | 'debug' | 'log';\n\nconst levelToNumber = {\n none : 0, error : 1, warn : 2, info : 3, log : 4, debug : 5\n}\n\nexport interface Log extends Logger {\n level : number\n throw : number\n stop : number\n logger : Logger\n}\n\nexport const log : Log = function( a_level : LogLevel, a_msg : string, a_props : object ){\n let levelAsNumber = levelToNumber[ a_level ], msg, props, level;\n\n if( levelAsNumber === void 0 && !a_props ){\n levelAsNumber = 4;\n msg = a_level;\n props = a_msg;\n level = 'log';\n }\n else{\n msg = a_msg, level = a_level, props = a_props;\n }\n\n if( levelAsNumber <= log.level ){\n if( levelAsNumber <= log.throw || !log.logger ){\n const error = new Error( msg );\n (error as any).props = props;\n throw error;\n }\n else{\n log.logger( level, msg, props );\n \n if( levelAsNumber <= log.stop ){\n debugger;\n }\n }\n }\n}\n\ndeclare var process: any;\n\nlog.level = typeof process !== 'undefined' && process.env && process.env.NODE_ENV === 'production' ? 1 : 2;\nlog.throw = 0;\nlog.stop = 0;\n\n\nlet toString = typeof window === 'undefined' ? \n function toString( something ){\n if( something && typeof something === 'object' ){\n const value = something.__inner_state__ || something,\n isTransactional = Boolean( something.__inner_state__ ),\n isArray = Array.isArray( value );\n\n const keys = Object.keys( value ).join( ', ' ),\n body = isArray ? `[ length = ${ value.length } ]` : `{ ${ keys } }`;\n\n return something.constructor.name + ' ' + body;\n }\n\n return something;\n } : function toString( x ){ return x; };\n\nif( typeof console !== 'undefined' ) {\n log.logger = function _console( level : LogLevel, error : string, props : object ){\n const args = [ error ];\n for( let name in props ){\n args.push( `\\n\\t${name}:`, toString( props[ name ] ) );\n }\n\n console[ level ].apply( console, args );\n }\n}\n\n/** Check if value is raw JSON */\nexport function isValidJSON( value : any ) : boolean {\n if( value === null ){\n return true;\n }\n\n switch( typeof value ){\n case 'number' :\n case 'string' :\n case 'boolean' :\n return true;\n\n case 'object':\n var proto = Object.getPrototypeOf( value );\n\n if( proto === Object.prototype || proto === Array.prototype ){\n return every( value, isValidJSON );\n }\n }\n\n return false;\n}\n\n/** Get the base class constructor function.\n * @param Class Subclass constructor function.\n * @returns Base class constructor function.\n */\nexport function getBaseClass( Class : Function ) {\n return Object.getPrototypeOf( Class.prototype ).constructor\n}\n\nexport function assignToClassProto( Class, definition : T, ...names : K[] ) : void {\n for( let name of names ){\n const value = definition[ name ];\n value === void 0 || ( Class.prototype[ name ] = value );\n }\n}\n\n/** Checks whenever given object is an empty hash `{}` */\nexport function isEmpty( obj : {} ) : boolean {\n if( obj ){\n for( let key in obj ){\n if( obj.hasOwnProperty( key ) ){\n return false;\n }\n }\n }\n\n return true;\n}\n\nexport type Iteratee = ( value : any, key? : string | number ) => any;\n\n/** @hidden */\nfunction someArray( arr : any[], fun : Iteratee ) : any {\n let result;\n\n for( let i = 0; i < arr.length; i++ ){\n if( result = fun( arr[ i ], i ) ){\n return result;\n }\n }\n}\n\n/** @hidden */\nfunction someObject( obj : {}, fun : Iteratee ) : any {\n let result;\n\n for( let key in obj ){\n if( obj.hasOwnProperty( key ) ){\n if( result = fun( obj[ key ], key ) ){\n return result;\n }\n }\n }\n}\n\n/** Similar to underscore `_.some` */\nexport function some( obj, fun : Iteratee ) : any {\n if( Object.getPrototypeOf( obj ) === ArrayProto ){\n return someArray( obj, fun );\n }\n else{\n return someObject( obj, fun );\n }\n}\n\n/** Similar to underscore `_.every` */\nexport function every( obj : { }, predicate : Iteratee ) : boolean {\n return !some( obj, x => !predicate( x ) );\n}\n\n/** Similar to `getOwnPropertyDescriptor`, but traverse the whole prototype chain. */\nexport function getPropertyDescriptor( obj : {}, prop : string ) : PropertyDescriptor {\n let desc : PropertyDescriptor;\n\n for( let proto = obj; !desc && proto; proto = Object.getPrototypeOf( proto ) ) {\n desc = Object.getOwnPropertyDescriptor( proto, prop );\n }\n\n return desc;\n}\n\n/** Similar to underscore `_.omit` */\nexport function omit( source : {}, ...rest : string[] ) : {}\nexport function omit( source ) : {} {\n const dest = {}, discard = {};\n\n for( let i = 1; i < arguments.length; i ++ ){\n discard[ arguments[ i ] ] = true;\n }\n\n for( var name in source ) {\n if( !discard.hasOwnProperty( name ) && source.hasOwnProperty( name ) ) {\n dest[ name ] = source[ name ];\n }\n }\n\n return dest;\n}\n\n/** map `source` object properties with a given function, and assign the result to the `dest` object.\n * When `fun` returns `undefined`, skip this value. \n */\nexport function transform< A, B >( dest : { [ key : string ] : A }, source : { [ key : string ] : B }, fun : ( value : B, key : string ) => A | void ) : { [ key : string ] : A } {\n for( var name in source ) {\n if( source.hasOwnProperty( name ) ) {\n var value = fun( source[ name ], name );\n value === void 0 || ( dest[ name ] = < A >value );\n }\n }\n\n return dest;\n}\n\n/** @hidden */\nexport function fastAssign< A >( dest : A, source : {} ) : A {\n for( var name in source ) {\n dest[ name ] = source[ name ];\n }\n\n return dest;\n}\n\n/** @hidden */\nexport function fastDefaults< A >( dest : A, source : {} ) : A {\n for( var name in source ) {\n if( dest[ name ] === void 0 ){\n dest[ name ] = source[ name ];\n }\n }\n\n return dest;\n}\n\n/** Similar to underscore `_.extend` and `Object.assign` */\nexport function assign< T >( dest : T, ...sources : Object[] ) : T\nexport function assign< T >( dest : T, source : Object ) : T {\n for( var name in source ) {\n if( source.hasOwnProperty( name ) ) {\n dest[ name ] = source[ name ];\n }\n }\n\n if( arguments.length > 2 ){\n for( let i = 2; i < arguments.length; i++ ){\n const other = arguments[ i ];\n other && assign( dest, other );\n }\n }\n\n return dest;\n}\n\n/** Similar to underscore `_.keys` */\nexport function keys( o : any ) : string[]{\n return o ? Object.keys( o ) : [];\n}\n\n/** Similar to underscore `_.once` */\nexport function once( func : Function ) : Function {\n var memo, first = true;\n return function() {\n if ( first ) {\n first = false;\n memo = func.apply(this, arguments);\n func = null;\n }\n return memo;\n };\n}\n\n/** @hidden */\nconst ArrayProto = Array.prototype,\n DateProto = Date.prototype,\n ObjectProto = Object.prototype;\n\n/**\n * Determine whenever two values are not equal, deeply traversing \n * arrays and plain JS objects (hashes). Dates are compared by enclosed timestamps, all other\n * values are compared with strict comparison.\n */\nexport function notEqual( a : any, b : any) : boolean {\n if( a === b ) return false;\n\n if( a && b && typeof a == 'object' && typeof b == 'object' ) {\n const protoA = Object.getPrototypeOf( a );\n\n if( protoA !== Object.getPrototypeOf( b ) ) return true;\n\n switch( protoA ){\n case DateProto : return +a !== +b;\n case ArrayProto : return arraysNotEqual( a, b );\n case ObjectProto :\n case null:\n return objectsNotEqual( a, b );\n }\n }\n\n return true;\n}\n\n/** @hidden */\nfunction objectsNotEqual( a, b ) {\n const keysA = Object.keys( a );\n\n if( keysA.length !== Object.keys( b ).length ) return true;\n\n for( let i = 0; i < keysA.length; i++ ) {\n const key = keysA[ i ];\n\n if( !b.hasOwnProperty( key ) || notEqual( a[ key ], b[ key ] ) ) {\n return true;\n }\n }\n\n return false;\n}\n\n/** @hidden */\nfunction arraysNotEqual( a, b ) {\n if( a.length !== b.length ) return true;\n\n for( let i = 0; i < a.length; i++ ) {\n if( notEqual( a[ i ], b[ i ] ) ) return true;\n }\n\n return false;\n}\n\n/**\n * Create an object without Object prototype members except hasOwnProperty.\n * @param obj - optional parameter to populate the hash map from.\n */\nconst HashProto = Object.create( null );\nHashProto.hasOwnProperty = ObjectProto.hasOwnProperty;\n\nexport function hashMap( obj? ){\n const hash = Object.create( HashProto );\n return obj ? assign( hash, obj ) : hash;\n}","/*****************************************************************\n * Mixins engine and @define metaprogramming class extensions\n *\n * Vlad Balin & Volicon, (c) 2016-2017\n */\nimport { log, assign, omit, hashMap, getPropertyDescriptor, getBaseClass, defaults, transform } from './tools'\nimport { __extends } from 'tslib'\n\nexport interface Subclass< T > extends MixableConstructor {\n new ( ...args ) : T\n prototype : T\n}\n\nexport interface MixableConstructor extends Function{\n __super__? : object;\n mixins? : MixinsState;\n onExtend? : ( BaseClass : Function ) => void;\n onDefine? : ( definition : object, BaseClass : Function ) => void;\n define? : ( definition? : object, statics? : object ) => MixableConstructor;\n extend? : ( definition? : T, statics? : object ) => Subclass;\n}\n\nexport interface MixableDefinition {\n mixins? : Mixin[]\n}\n\n/**\n * Base class, holding metaprogramming class extensions.\n * Supports mixins and Class.define metaprogramming method.\n */\nexport class Mixable {\n static onExtend : ( BaseClass : Function ) => void;\n static onDefine : ( definition : object, BaseClass : Function ) => object; \n static __super__ : object\n static mixins : MixinsState;\n\n /** \n * Must be called after inheritance and before 'define'.\n */\n static define( protoProps : MixableDefinition = {}, staticProps? : object ) : MixableConstructor {\n const BaseClass : MixableConstructor = getBaseClass( this );\n\n // Assign statics.\n staticProps && assign( this, staticProps );\n\n // Extract and apply mixins from the definition.\n const { mixins, ...defineMixin } = protoProps;\n mixins && this.mixins.merge( mixins );\n\n // Unshift definition to the the prototype.\n this.mixins.mergeObject( this.prototype, defineMixin, true );\n\n // Unshift definition from statics to the prototype.\n this.mixins.mergeObject( this.prototype, this.mixins.getStaticDefinitions( BaseClass ), true );\n\n // Call onDefine hook, if it's present.\n this.onDefine && this.onDefine( this.mixins.definitions, BaseClass );\n \n // Apply merge rules to inherited members. No mixins can be added after this point.\n this.mixins.mergeInheritedMembers( BaseClass );\n\n return this;\n }\n\n /** Backbone-compatible extend method to be used in ES5 and for backward compatibility */\n static extend< T extends object>(spec? : T, statics? : {} ) : Subclass< T > {\n let TheSubclass : Subclass< T >;\n\n // 1. Create the subclass (ES5 compatibility shim).\n // If constructor function is given...\n if( spec && spec.hasOwnProperty( 'constructor' ) ){\n // ...we need to manually call internal TypeScript __extend function. Hack! Hack!\n TheSubclass = spec.constructor as any;\n __extends( TheSubclass, this );\n }\n // Otherwise, create the subclall in usual way.\n else{\n TheSubclass = class Subclass extends this {} as any;\n }\n\n predefine( TheSubclass );\n spec && TheSubclass.define( spec, statics );\n\n return TheSubclass;\n }\n}\n\n/** @decorator `@predefine` for forward definitions. Can be used with [[Mixable]] classes only.\n * Forwards the call to the [[Mixable.predefine]];\n */\nexport function predefine( Constructor : MixableConstructor ) : void {\n const BaseClass : MixableConstructor = getBaseClass( Constructor );\n\n // Legacy systems support\n Constructor.__super__ = BaseClass.prototype;\n \n // Initialize mixins structures...\n Constructor.define || MixinsState.get( Mixable ).populate( Constructor );\n\n // Make sure Ctor.mixins are ready before the callback...\n MixinsState.get( Constructor );\n\n // Call extend hook.\n Constructor.onExtend && Constructor.onExtend( BaseClass );\n}\n\n/** @decorator `@define` for metaprogramming magic. Can be used with [[Mixable]] classes only.\n * Forwards the call to [[Mixable.define]].\n */\nexport function define( ClassOrDefinition : Function ) : void;\nexport function define( ClassOrDefinition : object ) : ClassDecorator;\nexport function define( ClassOrDefinition : object | MixableConstructor ){\n // @define class\n if( typeof ClassOrDefinition === 'function' ){\n predefine( ClassOrDefinition );\n ClassOrDefinition.define();\n }\n // @define({ prop : val, ... }) class\n else{\n return function( Ctor : MixableConstructor ){\n predefine( Ctor );\n Ctor.define( ClassOrDefinition );\n }\n }\n}\n\nexport function definitions( rules : MixinMergeRules ) : ClassDecorator {\n return ( Class : Function ) => {\n const mixins = MixinsState.get( Class );\n mixins.definitionRules = defaults( hashMap(), rules, mixins.definitionRules );\n }\n}\n\n// Create simple property list decorator\nexport function propertyListDecorator( listName: string ) : PropertyDecorator {\n return function propList(proto, name : string) {\n const list = proto.hasOwnProperty( listName ) ?\n proto[ listName ] : (proto[ listName ] = (proto[ listName ] || []).slice()); \n\n list.push(name);\n }\n}\n\nexport function definitionDecorator( definitionKey, value ){\n return ( proto : object, name : string ) => {\n MixinsState\n .get( proto.constructor )\n .mergeObject( proto, {\n [ definitionKey ] : {\n [ name ] : value\n }\n });\n }\n}\n\nexport class MixinsState {\n mergeRules : MixinMergeRules;\n definitionRules : MixinMergeRules;\n definitions : object = {};\n appliedMixins : Mixin[];\n\n // Return mixins state for the class. Initialize if it's not exist.\n static get( Class ) : MixinsState {\n const { mixins } = Class;\n \n return mixins && Class === mixins.Class ? mixins :\n Class.mixins = new MixinsState( Class );\n }\n\n constructor( public Class : MixableConstructor ){\n const { mixins } = getBaseClass( Class );\n\n this.mergeRules = ( mixins && mixins.mergeRules ) || hashMap();\n this.definitionRules = ( mixins && mixins.definitionRules ) || hashMap();\n this.appliedMixins = ( mixins && mixins.appliedMixins ) || [];\n }\n\n getStaticDefinitions( BaseClass : Function ){\n const definitions = hashMap(),\n { Class } = this;\n\n return transform( definitions, this.definitionRules, ( rule, name ) =>{\n if( BaseClass[ name ] !== Class[ name ]){\n return Class[ name ];\n }\n });\n }\n\n merge( mixins : Mixin[] ){\n const proto = this.Class.prototype,\n { mergeRules } = this;\n\n // Copy applied mixins array as it's going to be updated.\n const appliedMixins = this.appliedMixins = this.appliedMixins.slice();\n\n // Apply mixins in sequence...\n for( let mixin of mixins ) {\n // Mixins array should be flattened.\n if( Array.isArray( mixin ) ) {\n this.merge( mixin );\n }\n // Don't apply mixins twice.\n else if( appliedMixins.indexOf( mixin ) < 0 ){\n appliedMixins.push( mixin );\n\n // For constructors, merge _both_ static and prototype members.\n if( typeof mixin === 'function' ){\n // Merge static members\n this.mergeObject( this.Class, mixin );\n\n // merge definitionRules and mergeRules\n const sourceMixins = ( mixin as any ).mixins;\n if( sourceMixins ){\n this.mergeRules = defaults( hashMap(), this.mergeRules, sourceMixins.mergeRules );\n this.definitionRules = defaults( hashMap(), this.definitionRules, sourceMixins.definitionRules );\n this.appliedMixins = this.appliedMixins.concat( sourceMixins.appliedMixins );\n }\n\n // Prototypes are merged according with rules.\n this.mergeObject( proto, mixin.prototype );\n }\n // Handle plain object mixins.\n else {\n this.mergeObject( proto, mixin );\n }\n }\n }\n }\n\n populate( ...ctors : Function[] ){\n for( let Ctor of ctors ) {\n MixinsState.get( Ctor ).merge([ this.Class ]);\n }\n }\n\n mergeObject( dest : object, source : object, unshift? : boolean ) {\n forEachOwnProp( source, name => {\n const sourceProp = Object.getOwnPropertyDescriptor( source, name );\n let rule : MixinMergeRule;\n\n if( rule = this.definitionRules[ name ] ){\n assignProperty( this.definitions, name, sourceProp, rule, unshift );\n }\n\n if( !rule || rule === mixinRules.protoValue ){\n assignProperty( dest, name, sourceProp, this.mergeRules[ name ], unshift );\n }\n });\n }\n\n mergeInheritedMembers( BaseClass : Function ){\n const { mergeRules, Class } = this;\n\n if( mergeRules ){\n const proto = Class.prototype,\n baseProto = BaseClass.prototype;\n\n for( let name in mergeRules ) {\n const rule = mergeRules[ name ];\n\n if( proto.hasOwnProperty( name ) && name in baseProto ){\n proto[ name ] = resolveRule( proto[ name ], baseProto[ name ], rule );\n }\n }\n }\n }\n}\n\nconst dontMix = {\n function : hashMap({\n length : true,\n prototype : true,\n caller : true,\n arguments : true,\n name : true,\n __super__ : true\n }),\n \n object : hashMap({\n constructor : true\n }) \n}\n\nfunction forEachOwnProp( object : object, fun : ( name : string ) => void ){\n const ignore = dontMix[ typeof object ];\n\n for( let name of Object.keys( object ) ) {\n ignore[ name ] || fun( name );\n }\n}\n\nexport interface MixinMergeRules {\n [ name : string ] : MixinMergeRule\n}\n\nexport type MixinMergeRule = ( a : any, b : any ) => any\nexport type Mixin = { [ key : string ] : any } | Function\n\n// @mixins( A, B, ... ) decorator.\nexport interface MixinRulesDecorator {\n ( rules : MixinMergeRules ) : ClassDecorator\n value( a : object, b : object) : object;\n protoValue( a : object, b : object) : object;\n merge( a : object, b : object ) : object;\n pipe( a: Function, b : Function ) : Function;\n defaults( a: Function, b : Function ) : Function;\n classFirst( a: Function, b : Function ) : Function;\n classLast( a: Function, b : Function ) : Function;\n every( a: Function, b : Function ) : Function;\n some( a: Function, b : Function ) : Function;\n}\n\nexport const mixins = ( ...list : Mixin[] ) => (\n ( Class : Function ) => MixinsState.get( Class ).merge( list )\n);\n\n// @mixinRules({ name : rule, ... }) decorator.\nexport const mixinRules = ( ( rules : MixinMergeRules ) => (\n ( Class : Function ) => {\n const mixins = MixinsState.get( Class );\n mixins.mergeRules = defaults( rules, mixins.mergeRules );\n }\n) ) as MixinRulesDecorator;\n\n// Pre-defined mixin merge rules\n\nmixinRules.value = ( a, b ) => a;\n\nmixinRules.protoValue = ( a, b ) => a;\n\n// Recursively merge members\nmixinRules.merge = ( a, b ) => defaults( {}, a, b );\n\n // Execute methods in pipe, with the class method executed last.\nmixinRules.pipe = ( a, b ) => (\n function( x : any ) : any {\n return a.call( this, b.call( this, x ) );\n }\n);\n\n // Assume methods return an object, and merge results with defaults (class method executed first)\nmixinRules.defaults = ( a : Function, b : Function ) => (\n function() : object {\n return defaults( a.apply( this, arguments ), b.apply( this, arguments ) );\n }\n);\n\n// Execute methods in sequence staring with the class method.\nmixinRules.classFirst = ( a : Function, b : Function ) => (\n function() : void {\n a.apply( this, arguments );\n b.apply( this, arguments );\n }\n);\n\n // Execute methods in sequence ending with the class method.\nmixinRules.classLast = ( a : Function, b : Function ) => (\n function() : void {\n b.apply( this, arguments );\n a.apply( this, arguments );\n }\n)\n\n // Execute methods in sequence returning the first falsy result.\nmixinRules.every = ( a : Function, b : Function ) =>(\n function() : any {\n return a.apply( this, arguments ) && b.apply( this, arguments );\n }\n);\n // Execute methods in sequence returning the first truthy result.\nmixinRules.some = ( a : Function, b : Function ) =>(\n function() : any {\n return a.apply( this, arguments ) || b.apply( this, arguments );\n }\n);\n\n/**\n * Helpers\n */\n\nfunction assignProperty( dest : object, name : string, sourceProp : PropertyDescriptor, rule : MixinMergeRule, unshift? : boolean ){\n// Destination prop is defined, thus the merge rules must be applied.\n if( dest.hasOwnProperty( name ) ){\n const destProp = Object.getOwnPropertyDescriptor( dest, name );\n\n if( destProp.configurable && 'value' in destProp ){\n dest[ name ] = unshift ?\n resolveRule( sourceProp.value, destProp.value, rule ) :\n resolveRule( destProp.value, sourceProp.value, rule ) ;\n }\n }\n // If destination is empty, just copy the prop over.\n else{\n Object.defineProperty( dest, name, sourceProp );\n }\n}\n\nfunction resolveRule( dest, source, rule : MixinMergeRule ){\n // When destination is empty, take the source.\n if( dest === void 0 ) return source;\n\n // In these cases we take non-empty destination:\n if( !rule || source === void 0 ) return dest;\n\n // In other cases we must merge values.\n return rule( dest, source );\n}","import { once as _once } from './tools'\n\n/*******************\n * Prebuilt events map, used for optimized bulk event subscriptions.\n *\n * const events = new EventMap({\n * 'change' : true, // Resend this event from self as it is.\n * 'change:attr' : 'localTargetFunction',\n * 'executedInTargetContext' : function(){ ... }\n * 'executedInNativeContext' : '^props.handler'\n * })\n */\n/** @hidden */\nexport interface EventsDefinition {\n [ events : string ] : Function | string | boolean\n}\n\n/** @hidden */\nexport class EventMap {\n handlers : EventDescriptor[] = [];\n\n constructor( map? : EventsDefinition | EventMap ){\n if( map ){\n if( map instanceof EventMap ){\n this.handlers = map.handlers.slice();\n }\n else{\n map && this.addEventsMap( map );\n }\n }\n }\n\n merge( map : EventMap ){\n this.handlers = this.handlers.concat( map.handlers );\n }\n\n addEventsMap( map : EventsDefinition ){\n for( let names in map ){\n this.addEvent( names, map[ names ] )\n }\n }\n\n bubbleEvents( names : string ){\n for( let name of names.split( eventSplitter ) ){\n this.addEvent( name, getBubblingHandler( name ) );\n }\n }\n\n addEvent( names : string, callback : Function | string | boolean ){\n const { handlers } = this;\n\n for( let name of names.split( eventSplitter ) ){\n handlers.push( new EventDescriptor( name, callback ) );\n }\n }\n\n subscribe( target : {}, source : EventSource ){\n for( let event of this.handlers ){\n on( source, event.name, event.callback, target );\n }\n }\n\n unsubscribe( target : {}, source : EventSource ){\n for( let event of this.handlers ){\n off( source, event.name, event.callback, target );\n }\n }\n}\n\n/** @hidden */\nexport class EventDescriptor {\n callback : Function\n\n constructor(\n public name : string,\n callback : Function | string | boolean\n ){\n if( callback === true ){\n this.callback = getBubblingHandler( name );\n }\n else if( typeof callback === 'string' ){\n this.callback =\n function localCallback(){\n const handler = this[ callback ];\n handler && handler.apply( this, arguments );\n };\n }\n else{\n this.callback = callback;\n }\n }\n}\n\n/** @hidden */\nconst _bubblingHandlers = {};\n\n/** @hidden */\nfunction getBubblingHandler( event : string ){\n return _bubblingHandlers[ event ] || (\n _bubblingHandlers[ event ] = function( a?, b?, c?, d?, e? ){\n if( d !== void 0 || e !== void 0 ) trigger5( this, event, a, b, c, d, e );\n if( c !== void 0 ) trigger3( this, event, a, b, c );\n else trigger2( this, event, a, b );\n }\n );\n}\n\n/** @hidden */\nexport interface HandlersByEvent {\n [ name : string ] : EventHandler\n}\n\n/** @hidden */\nexport class EventHandler {\n constructor( public callback : Callback, public context : any, public next = null ){}\n}\n\n/** @hidden */\nfunction listOff( _events : HandlersByEvent, name : string, callback : Callback, context : any ){\n const head = _events[ name ];\n\n let filteredHead, prev;\n\n for( let ev = head; ev; ev = ev.next ){\n // Element must be kept\n if( ( callback && callback !== ev.callback && callback !== ev.callback._callback ) ||\n ( context && context !== ev.context ) ){\n \n prev = ev;\n filteredHead || ( filteredHead = ev );\n }\n // Element must be skipped\n else{\n if( prev ) prev.next = ev.next;\n }\n }\n\n if( head !== filteredHead ) _events[ name ] = filteredHead;\n}\n\n/** @hidden */\nfunction listSend2( head : EventHandler, a, b ){\n for( let ev = head; ev; ev = ev.next ) ev.callback.call( ev.context, a, b );\n}\n\n/** @hidden */\nfunction listSend3( head : EventHandler, a, b, c ){\n for( let ev = head; ev; ev = ev.next ) ev.callback.call( ev.context, a, b, c );\n}\n\n/** @hidden */\nfunction listSend4( head : EventHandler, a, b, c, d ){\n for( let ev = head; ev; ev = ev.next ) ev.callback.call( ev.context, a, b, c, d );\n}\n\n/** @hidden */\nfunction listSend5( head : EventHandler, a, b, c, d, e ){\n for( let ev = head; ev; ev = ev.next ) ev.callback.call( ev.context, a, b, c, d, e );\n}\n\n/** @hidden */\nfunction listSend6( head : EventHandler, a, b, c, d, e, f ){\n for( let ev = head; ev; ev = ev.next ) ev.callback.call( ev.context, a, b, c, d, e, f );\n}\n\n/** @hidden */\nexport interface Callback extends Function {\n _callback? : Function\n}\n\n/** @hidden */\nexport function on( source : EventSource, name : string, callback : Callback, context? : any ) : void {\n if( callback ){\n const _events = source._events || ( source._events = Object.create( null ) );\n _events[ name ] = new EventHandler( callback, context, _events[ name ] );\n }\n}\n\n/** @hidden */\nexport function once( source : EventSource, name : string, callback : Callback, context? : any ) : void {\n if( callback ){\n const once : Callback = _once( function(){\n off( source, name, once );\n callback.apply(this, arguments);\n });\n\n once._callback = callback;\n on( source, name, once, context );\n }\n}\n\n/** @hidden */\nexport function off( source : EventSource, name? : string, callback? : Callback, context? : any ) : void {\n const { _events } = source;\n if( _events ){\n if( callback || context ) {\n if( name ){\n listOff( _events, name, callback, context );\n }\n else{\n for( let name in _events ){\n listOff( _events, name, callback, context );\n }\n }\n }\n else if( name ){\n _events[ name ] = void 0;\n }\n else{\n source._events = void 0;\n }\n }\n}\n\n/** @hidden */\nexport interface EventSource {\n _events : HandlersByEvent\n}\n\n/** @hidden */\nconst eventSplitter = /\\s+/;\n\n/** @hidden */\nexport function strings( api : ApiEntry, source : EventSource, events : string, callback : Callback, context ){\n if( eventSplitter.test( events ) ){\n const names = events.split( eventSplitter );\n for( let name of names ) api( source, name, callback, context );\n }\n else api( source, events, callback, context );\n}\n\n/** @hidden */\nexport type ApiEntry = ( source : EventSource, event : string, callback : Callback, context? : any ) => void\n\n/*********************************\n * Event-triggering API\n */\n\n/** @hidden */\nexport function trigger2( self : EventSource, name : string, a, b ) : void {\n const { _events } = self;\n if( _events ){\n const queue = _events[ name ],\n { all } = _events;\n\n listSend2( queue, a, b );\n listSend3( all, name, a, b );\n }\n};\n\n/** @hidden */\nexport function trigger3( self : EventSource, name : string, a, b, c ) : void{\n const { _events } = self;\n if( _events ){\n const queue = _events[ name ],\n { all } = _events;\n\n listSend3( queue, a, b, c );\n listSend4( all, name, a, b, c );\n }\n};\n\n/** @hidden */\nexport function trigger5( self : EventSource, name : string, a, b, c, d, e ) : void{\n const { _events } = self;\n if( _events ){\n const queue = _events[ name ],\n { all } = _events;\n\n listSend5( queue, a, b, c, d, e );\n listSend6( all, name, a, b, c, d, e );\n }\n};","import { define, mixins, Mixable, Mixin, MixableConstructor, MixinsState, mixinRules, definitions, MixinMergeRules } from './mixins'\nimport { omit, transform } from './tools'\nimport { EventMap, EventsDefinition, EventSource, HandlersByEvent } from './eventsource'\nimport * as _eventsApi from './eventsource'\n\nconst { EventHandler, strings, on, off, once, trigger5, trigger2, trigger3 } = _eventsApi;\n\n/** @hidden */\nconst eventSplitter = /\\s+/;\n\n/** @hidden */\nlet _idCount = 0;\n\n/** @hidden */\nfunction uniqueId() : string {\n return 'l' + _idCount++;\n}\n\nexport { EventMap, EventsDefinition }\n\nexport interface MessengerDefinition {\n _localEvents? : EventMap\n localEvents? : EventsDefinition\n properties? : PropertyMap\n [ name : string ] : any\n}\n\nexport interface PropertyMap {\n [ name : string ] : Property\n}\n\nexport type Property = PropertyDescriptor | ( () => any )\n\n/** @hidden */\nexport interface MessengersByCid {\n [ cid : string ] : Messenger\n}\n\n/** @hidden */\nexport type CallbacksByEvents = { [ events : string ] : Function }\n\n/*************************\n * Messenger is mixable class with capabilities of sending and receiving synchronous events.\n * This class itself can serve as both mixin and base class.\n */\n\n@define\n@definitions({\n properties : mixinRules.merge,\n localEvents : mixinRules.merge\n})\nexport abstract class Messenger implements Mixable, EventSource {\n // Define extendable mixin static properties.\n static __super__ : object;\n static mixins : MixinsState;\n static onExtend : ( BaseClass : Function ) => void;\n static define : ( definition? : MessengerDefinition, statics? : object ) => MixableConstructor;\n static extend : ( definition? : MessengerDefinition, statics? : object ) => MixableConstructor;\n static onDefine({ localEvents, _localEvents, properties } : MessengerDefinition, BaseClass? : typeof Mixable ){\n // Handle localEvents definition\n if( localEvents || _localEvents ){\n const eventsMap = new EventMap( this.prototype._localEvents );\n\n localEvents && eventsMap.addEventsMap( localEvents );\n _localEvents && eventsMap.merge( _localEvents );\n \n this.prototype._localEvents = eventsMap;\n }\n\n // Handle properties definitions...\n if( properties ){\n Object.defineProperties( this.prototype, transform( {}, properties, toPropertyDescriptor ) );\n }\n }\n\n /** @hidden */ \n _events : HandlersByEvent = void 0;\n\n /** @hidden */ \n _listeningTo : MessengersByCid = void 0\n\n /** Unique client-only id. */\n cid : string\n\n /** @hidden Prototype-only property to manage automatic local events subscription */ \n _localEvents : EventMap\n\n /** @hidden */ \n constructor(){\n this.cid = uniqueId();\n this.initialize.apply( this, arguments );\n\n // TODO: local events subscribe?\n }\n\n /** Method is called at the end of the constructor */\n initialize() : void {}\n \n on( events : string | CallbacksByEvents, callback, context? ) : this {\n if( typeof events === 'string' ) strings( on, this, events, callback, context );\n else for( let name in events ) strings( on, this, name, events[ name ], context || callback );\n\n return this;\n }\n\n once( events : string | CallbacksByEvents, callback, context? ) : this {\n if( typeof events === 'string' ) strings( once, this, events, callback, context );\n else for( let name in events ) strings( once, this, name, events[ name ], context || callback );\n\n return this;\n }\n\n off( events? : string | CallbacksByEvents, callback?, context? ) : this {\n if( !events ) off( this, void 0, callback, context );\n else if( typeof events === 'string' ) strings( off, this, events, callback, context );\n else for( let name in events ) strings( off, this, name, events[ name ], context || callback );\n\n return this;\n }\n\n // Trigger one or many events, firing all bound callbacks. Callbacks are\n // passed the same arguments as `trigger` is, apart from the event name\n // (unless you're listening on `\"all\"`, which will cause your callback to\n // receive the true name of the event as the first argument).\n trigger(name : string, a?, b?, c?, d?, e? ) : this {\n if( d !== void 0 || e !== void 0 ) trigger5( this, name, a, b, c, d, e );\n else if( c !== void 0 ) trigger3( this, name, a, b, c );\n else trigger2( this, name, a, b );\n return this;\n }\n\n listenTo( source : Messenger, a : string | CallbacksByEvents, b? : Function ) : this {\n if( source ){\n addReference( this, source );\n source.on( a, !b && typeof a === 'object' ? this : b, this );\n }\n\n return this;\n }\n\n listenToOnce( source : Messenger, a : string | CallbacksByEvents, b? : Function ) : this {\n if( source ){\n addReference( this, source );\n source.once( a, !b && typeof a === 'object' ? this : b, this );\n }\n\n return this;\n }\n\n stopListening( a_source? : Messenger, a? : string | CallbacksByEvents, b? : Function ) : this {\n const { _listeningTo } = this;\n if( _listeningTo ){\n const removeAll = !( a || b ),\n second = !b && typeof a === 'object' ? this : b;\n\n if( a_source ){\n const source = _listeningTo[ a_source.cid ];\n if( source ){\n if( removeAll ) delete _listeningTo[ a_source.cid ];\n source.off( a, second, this );\n }\n }\n else if( a_source == null ){\n for( let cid in _listeningTo ) _listeningTo[ cid ].off( a, second, this );\n\n if( removeAll ) ( this._listeningTo = void 0 );\n }\n }\n\n return this;\n }\n\n /**\n * Destructor. Stops messenger from listening to all objects,\n * and stop others from listening to the messenger. \n */\n _disposed : boolean\n\n dispose() : void {\n if( this._disposed ) return;\n\n this.stopListening();\n this.off();\n\n this._disposed = true;\n }\n}\n\n/**\n * Backbone 1.2 API conformant Events mixin.\n */\nexport const Events : Messenger = omit( Messenger.prototype, 'constructor', 'initialize' );\n\n/**\n * Messenger Private Helpers \n */\n\nfunction toPropertyDescriptor( x : Property ) : PropertyDescriptor {\n if( x ){\n return typeof x === 'function' ? { get : < () => any >x } : x;\n }\n}\n\n/** @hidden */\nfunction addReference( listener : Messenger, source : Messenger ){\n const listeningTo = listener._listeningTo || (listener._listeningTo = Object.create( null ) ),\n cid = source.cid || ( source.cid = uniqueId() );\n\n listeningTo[ cid ] = source;\n}","// (c) 2016 Vlad Balin and Volicon\n// MixtureJS may be freely distributed under the MIT license. \n\nimport * as tools from './tools'\nexport { tools }\nexport * from './mixins'\nexport * from './events'\nimport * as eventsApi from './eventsource'\nexport { eventsApi }\n\nimport { Mixable, MixableConstructor } from './mixins'\n\ndeclare global {\n interface ObjectConstructor {\n /** Polyfill for Object.assign */\n assign< T >( dest : T, ...sources : Object[] ) : T\n\n /** Global logging interface, for console debugging. */\n log : tools.Log\n\n /** ES5 Object.extend */\n extend( protoProps : {}, staticProps : {} ) : MixableConstructor\n }\n}\n\nObject.extend = ( protoProps, staticProps ) => Mixable.extend( protoProps, staticProps );\nObject.assign || ( Object.assign = tools.assign );\nObject.log = tools.log;","export interface ChildrenErrors {\n [ key : string ] : ValidationError | any\n} \n\nexport interface Validatable {\n _validateNested( errors : ChildrenErrors ) : number;\n validate( self : any ) : any\n get( key : string ) : any\n}\n\n// Validation error object.\nexport class ValidationError {\n // Invalid nested object keys \n nested : ChildrenErrors \n length : number\n\n // Local error\n error : any\n\n constructor( obj : Validatable ){\n this.length = obj._validateNested( this.nested = {} );\n\n if( this.error = obj.validate( obj ) ){\n this.length++;\n }\n }\n\n each( iteratee : ( value : any, key : string ) => void ) : void {\n const { error, nested } = this;\n\n if( error ) iteratee( error, null );\n\n for( const key in nested ){\n iteratee( nested[ key ], key );\n }\n }\n\n eachError( iteratee : ( error : any, key : string, object : Validatable ) => void, object : Validatable ) : void {\n this.each( ( value : any, key : string ) => {\n if( value instanceof ValidationError ){\n (value).eachError( iteratee, object.get( key ) );\n }\n else{\n iteratee( value, key, object );\n }\n });\n }\n}","/**\n * Some sketches for reference resolution.\n *\n * \n * a : Model.from( '~collection' )\n * \n * We need two functions. One for get, and one for compile. \n */\nexport interface Traversable {\n getStore() : Traversable\n getOwner() : Traversable\n get( key : string ) : any \n}\n\nconst referenceMask = /\\^|(store\\.[^.]+)|([^.]+)/g;\n\n// Compile reference to function\nexport type ResolveReference = ( root : Traversable ) => any; \n\nexport class CompiledReference {\n resolve : ResolveReference\n tail : string\n local : boolean\n\n constructor( reference : string, splitTail : boolean = false ){\n const path = reference\n .match( referenceMask )\n .map( key => {\n if( key === '^' || key === 'owner' ) return 'getOwner()';\n\n if( key[ 0 ] === '~' ) return `getStore().get(\"${ key.substr( 1 ) }\")`;\n\n if( key.indexOf( 'store.' ) === 0 ) return `getStore().get(\"${ key.substr( 6 ) }\")`;\n \n return key;\n } );\n \n this.tail = splitTail && path.pop();\n this.local = !path.length;\n \n this.resolve = new Function( 'self', `\n var v = self.${ path.shift() };\n \n ${ path.map( x => `\n v = v && v.${ x };\n `).join('')}\n\n return v;\n ` );\n }\n}\n\nexport function resolveReference( root : Traversable, reference : string, action : ( object, key : string ) => any ) : any {\n const path = reference.match( referenceMask ),\n skip = path.length - 1;\n \n let self = root;\n\n for( var i = 0; i < skip; i++ ){\n const key = path[ i ];\n switch( key ){\n case '~' : self = self.getStore(); break;\n case '^' : self = self.getOwner(); break;\n default : self = self.get( key );\n }\n\n // Do nothing if object on the path doesn't exist.\n if( !self ) return;\n }\n\n return action( self, path[ skip ] );\n}","export interface IONode {\n _endpoint : IOEndpoint\n _ioPromise : IOPromise< this >\n}\n\nexport interface IOPromise extends Promise {\n abort? : () => void\n}\n\nexport interface IOEndpoint {\n list( options : IOOptions, collection? ) : IOPromise\n create( json : any, options : IOOptions, record? ) : IOPromise\n update( id : string | number, json :any, options : IOOptions, record? ) : IOPromise\n read( id : string | number, options : IOOptions, record? ) : IOPromise\n destroy( id : string | number, options : IOOptions, record? ) : IOPromise\n subscribe( events : IOEvents, collection? ) : IOPromise\n unsubscribe( events : IOEvents, collection? ) : void\n}\n\nexport interface IOOptions {\n ioUpdate? : boolean\n}\n\nexport interface IOEvents {\n updated? : ( json : any ) => void\n removed? : ( json : any ) => void\n}\n\nexport function getOwnerEndpoint( self ) : IOEndpoint {\n // Check if we are the member of the collection...\n const { collection } = self;\n if( collection ){\n return getOwnerEndpoint( collection );\n }\n\n // Now, if we're the member of the model...\n if( self._owner ){\n const { _endpoints } = self._owner;\n return _endpoints && _endpoints[ self._ownerKey ];\n }\n}\n\n/**\n * Create abortable promise.\n * Adds `promise.abort()` function which rejects the promise by default\n * initialize() function takes third optional argument `abort : ( resolve, reject ) => void`,\n * which can be used to add custom abort handling.\n */\ndeclare var Promise: PromiseConstructorLike;\n\nexport function createIOPromise( initialize : InitIOPromise ) : IOPromise{\n let resolve, reject, onAbort;\n\n function abort( fn ){\n onAbort = fn;\n }\n\n const promise : IOPromise = new Promise( ( a_resolve, a_reject ) =>{\n reject = a_reject;\n resolve = a_resolve;\n initialize( resolve, reject, abort );\n }) as IOPromise;\n\n promise.abort = () => {\n onAbort ? onAbort( resolve, reject ) : reject( new Error( \"I/O Aborted\" ) );\n }\n\n return promise;\n}\n\nexport type InitIOPromise = ( resolve : ( x? : any ) => void, reject : ( x? : any ) => void, abort? : ( fn : Function ) => void ) => void;\n\nexport function startIO( self : IONode, promise : IOPromise, options : IOOptions, thenDo : ( json : any ) => any ) : IOPromise {\n // Stop pending I/O first...\n abortIO( self );\n\n // Mark future update transaction as IO transaction.\n options.ioUpdate = true;\n\n self._ioPromise = promise\n .then( resp => {\n self._ioPromise = null;\n \n const result = thenDo ? thenDo( resp ) : resp;\n \n triggerAndBubble( self, 'sync', self, resp, options );\n \n return result;\n } ) \n .catch( err => {\n self._ioPromise = null;\n\n console.error( err );\n \n triggerAndBubble( self, 'error', self, err, options );\n \n throw err;\n } ) as IOPromise;\n\n self._ioPromise.abort = promise.abort;\n\n return self._ioPromise;\n}\n\nexport function abortIO( self : IONode ){\n if( self._ioPromise && self._ioPromise.abort ){\n self._ioPromise.abort();\n self._ioPromise = null;\n }\n}\n\nexport function triggerAndBubble( eventSource, ...args ){\n eventSource.trigger.apply( eventSource, args );\n const { collection } = eventSource;\n collection && collection.trigger.apply( collection, args ); \n}","import { Messenger, CallbacksByEvents, MessengersByCid, MixinsState, MixinMergeRules, MessengerDefinition, tools, mixins, mixinRules, definitions, eventsApi, define, Subclass } from './object-plus'\nimport { ValidationError, Validatable, ChildrenErrors } from './validation'\nimport { Traversable, resolveReference } from './traversable'\nimport { IOEndpoint, IOPromise, IONode, abortIO } from './io-tools'\n\nconst { assign } = tools,\n { trigger2, trigger3, on, off } = eventsApi;\n/***\n * Abstract class implementing ownership tree, tho-phase transactions, and validation. \n * 1. createTransaction() - apply changes to an object tree, and if there are some events to send, transaction object is created.\n * 2. transaction.commit() - send and process all change events, and close transaction.\n */\n\n/** @private */\nexport interface TransactionalDefinition extends MessengerDefinition {\n endpoint? : IOEndpoint\n}\n\nexport enum ItemsBehavior {\n share = 0b0001,\n listen = 0b0010,\n persistent = 0b0100\n}\n\n// Transactional object interface\n@define\n@definitions({\n endpoint : mixinRules.value\n})\n@mixins( Messenger )\nexport abstract class Transactional implements Messenger, IONode, Validatable, Traversable {\n // Mixins are hard in TypeScript. We need to copy type signatures over...\n // Here goes 'Mixable' mixin.\n static endpoint : IOEndpoint;\n static __super__ : object;\n static mixins : MixinsState;\n static define : ( definition? : TransactionalDefinition, statics? : object ) => typeof Transactional;\n static extend : ( definition? : T, statics? : object ) => any;\n\n static onDefine( definitions : TransactionalDefinition, BaseClass : typeof Transactional ){\n if( definitions.endpoint ) this.prototype._endpoint = definitions.endpoint;\n Messenger.onDefine.call( this, definitions, BaseClass );\n };\n\n static onExtend( BaseClass : typeof Transactional ) : void {\n // Make sure we don't inherit class factories.\n if( BaseClass.create === this.create ) {\n this.create = Transactional.create;\n }\n }\n\n // Define extendable mixin static properties.\n static create( a : any, b? : any ) : Transactional {\n return new (this as any)( a, b );\n }\n\n /** Generic class factory. May be overridden for abstract classes. Not inherited. */\n on : ( events : string | CallbacksByEvents, callback, context? ) => this\n once : ( events : string | CallbacksByEvents, callback, context? ) => this\n off : ( events? : string | CallbacksByEvents, callback?, context? ) => this\n trigger : (name : string, a?, b?, c?, d?, e? ) => this\n\n stopListening : ( source? : Messenger, a? : string | CallbacksByEvents, b? : Function ) => this\n listenTo : ( source : Messenger, a : string | CallbacksByEvents, b? : Function ) => this\n listenToOnce : ( source : Messenger, a : string | CallbacksByEvents, b? : Function ) => this\n \n _disposed : boolean;\n\n // State accessor. \n readonly __inner_state__ : any;\n\n // Shared modifier (used by collections of shared models)\n _shared? : number; \n \n dispose() : void {\n if( this._disposed ) return;\n \n abortIO( this );\n this._owner = void 0;\n this._ownerKey = void 0;\n this.off();\n this.stopListening();\n this._disposed = true;\n }\n\n // Must be called at the end of the constructor in the subclass.\n initialize() : void {}\n\n /** @private */\n _events : eventsApi.HandlersByEvent = void 0;\n\n /** @private */\n _listeningTo : MessengersByCid\n\n /** @private */\n _localEvents : eventsApi.EventMap\n\n cid : string\n cidPrefix : string\n\n static shared : any;\n\n // Unique version token replaced on change\n /** @private */\n _changeToken : {} = {}\n\n // true while inside of the transaction\n /** @private */\n _transaction : boolean = false;\n\n // Holds current transaction's options, when in the middle of transaction and there're changes but is an unsent change event\n /** @private */\n _isDirty : TransactionOptions = null;\n\n // Backreference set by owner (Record, Collection, or other object)\n /** @private */\n _owner : Owner = void 0;\n\n // Key supplied by owner. Used by record to identify attribute key.\n // Only collections doesn't set the key, which is used to distinguish collections.\n /** @private */ \n _ownerKey : string = void 0;\n\n // Name of the change event\n /** @private */\n _changeEventName : string\n\n /**\n * Subsribe for the changes.\n */\n onChanges( handler : Function, target? : Messenger ){\n on( this, this._changeEventName, handler, target );\n }\n\n /**\n * Unsubscribe from changes.\n */\n offChanges( handler? : Function, target? : Messenger ){\n off( this, this._changeEventName, handler, target );\n }\n\n /**\n * Listen to changes event. \n */\n listenToChanges( target : Transactional, handler ){\n this.listenTo( target, target._changeEventName, handler );\n }\n\n constructor( cid : string | number ){\n this.cid = this.cidPrefix + cid;\n }\n\n // Deeply clone ownership subtree\n abstract clone( options? : CloneOptions ) : this\n \n // Execute given function in the scope of ad-hoc transaction.\n transaction( fun : ( self : this ) => void, options : TransactionOptions = {} ) : void{\n const isRoot = transactionApi.begin( this );\n const update = fun.call( this, this );\n update && this.set( update );\n isRoot && transactionApi.commit( this );\n }\n\n // Loop through the members in the scope of transaction.\n // Transactional version of each()\n updateEach( iteratee : ( val : any, key : string | number ) => void, options? : TransactionOptions ){\n const isRoot = transactionApi.begin( this );\n this.each( iteratee );\n isRoot && transactionApi.commit( this );\n }\n\n // Apply bulk in-place object update in scope of ad-hoc transaction \n set( values : any, options? : TransactionOptions ) : this {\n if( values ){ \n const transaction = this._createTransaction( values, options );\n transaction && transaction.commit();\n } \n\n return this;\n }\n\n // Assign transactional object \"by value\", copying aggregated items.\n assignFrom( source : Transactional | Object ) : this {\n // Need to delay change events until change token willl by synced.\n this.transaction( () =>{\n this.set( ( source ).__inner_state__ || source, { merge : true } );\n\n // Synchronize change tokens\n const { _changeToken } = source as any;\n \n if( _changeToken ){\n this._changeToken = _changeToken;\n } \n });\n\n return this;\n }\n\n // Apply bulk object update without any notifications, and return open transaction.\n // Used internally to implement two-phase commit.\n // Returns null if there are no any changes.\n /** @private */ \n abstract _createTransaction( values : any, options? : TransactionOptions ) : Transaction | void\n \n // Parse function applied when 'parse' option is set for transaction.\n parse( data : any, options? : TransactionOptions ) : any { return data }\n\n // Convert object to the serializable JSON structure\n abstract toJSON( options? : object ) : {}\n\n /*******************\n * Traversals and member access\n */\n \n // Get object member by its key.\n abstract get( key : string ) : any\n\n // Get object member by symbolic reference.\n deepGet( reference : string ) : any {\n return resolveReference( this, reference, ( object, key ) => object.get ? object.get( key ) : object[ key ] );\n }\n\n //_isCollection : boolean\n\n // Return owner skipping collections.\n getOwner() : Owner {\n return this._owner;\n }\n\n // Store used when owner chain store lookup failed. Static value in the prototype. \n /** @private */\n _defaultStore : Transactional\n\n // Locate the closest store. Store object stops traversal by overriding this method. \n getStore() : Transactional {\n const { _owner } = this;\n return _owner ? _owner.getStore() : this._defaultStore;\n }\n\n\n /***************************************************\n * Iteration API\n */\n\n // Loop through the members. Must be efficiently implemented in container class.\n abstract each( iteratee : ( val : any, key : string | number ) => void, context? : any )\n\n // Map members to an array\n map( iteratee : ( val : any, key : string | number ) => T, context? : any ) : T[]{\n const arr : T[] = [],\n fun = context !== void 0 ? ( v, k ) => iteratee.call( context, v, k ) : iteratee;\n \n this.each( ( val, key ) => {\n const result = fun( val, key );\n if( result !== void 0 ) arr.push( result );\n } );\n\n return arr;\n }\n\n _endpoint : IOEndpoint\n _ioPromise : IOPromise\n\n hasPendingIO() : IOPromise { return this._ioPromise; }\n\n fetch( options? : object ) : IOPromise { throw new Error( \"Not implemented\" ); }\n\n getEndpoint() : IOEndpoint {\n return getOwnerEndpoint( this ) || this._endpoint;\n }\n\n // Map members to an object\n mapObject( iteratee : ( val : any, key : string | number ) => T, context? : any ) : { [ key : string ] : T }{\n const obj : { [ key : string ] : T } = {},\n fun = context !== void 0 ? ( v, k ) => iteratee.call( context, v, k ) : iteratee;\n \n this.each( ( val, key ) => {\n const result = iteratee( val, key );\n if( result !== void 0 ) obj[ key ] = result;\n } );\n\n return obj;\n }\n \n /*********************************\n * Validation API\n */\n\n // Lazily evaluated validation error\n /** @private */\n _validationError : ValidationError = void 0\n\n // Validate ownership tree and return valudation error \n get validationError() : ValidationError {\n const error = this._validationError || ( this._validationError = new ValidationError( this ) );\n return error.length ? error : null; \n }\n\n // Validate nested members. Returns errors count.\n /** @private */\n abstract _validateNested( errors : ChildrenErrors ) : number\n\n // Object-level validator. Returns validation error.\n validate( obj? : Transactional ) : any {}\n\n // Return validation error (or undefined) for nested object with the given key. \n getValidationError( key : string ) : any {\n var error = this.validationError;\n return ( key ? error && error.nested[ key ] : error ) || null;\n }\n\n // Get validation error for the given symbolic reference.\n deepValidationError( reference : string ) : any {\n return resolveReference( this, reference, ( object, key ) => object.getValidationError( key ) );\n }\n\n // Iterate through all validation errors across the ownership tree.\n eachValidationError( iteratee : ( error : any, key : string, object : Transactional ) => void ) : void {\n const { validationError } = this;\n validationError && validationError.eachError( iteratee, this );\n }\n\n // Check whenever member with a given key is valid. \n isValid( key : string ) : boolean {\n return !this.getValidationError( key );\n }\n\n valueOf() : Object { return this.cid; }\n toString(){ return this.cid; }\n\n // Get class name for an object instance. Works fine with ES6 classes definitions (not in IE).\n getClassName() : string {\n const { name } = this.constructor;\n if( name !== 'Subclass' ) return name;\n }\n\n // Logging interface for run time errors and warnings.\n abstract _log( level : string, text : string, value : any ) : void;\n}\n\nexport interface CloneOptions {\n // 'Pin store' shall assign this._defaultStore = this.getStore();\n pinStore? : boolean\n}\n\n// Owner must accept children update events. It's an only way children communicates with an owner.\n/** @private */\nexport interface Owner extends Traversable, Messenger {\n _onChildrenChange( child : Transactional, options : TransactionOptions ) : void;\n getOwner() : Owner\n getStore() : Transactional\n}\n\n// Transaction object used for two-phase commit protocol.\n// Must be implemented by subclasses.\n// Transaction must be created if there are actual changes and when markIsDirty returns true.\n/** @private */ \nexport interface Transaction {\n // Object transaction is being made on.\n object : Transactional\n\n // Send out change events, process update triggers, and close transaction.\n // Nested transactions must be marked with isNested flag (it suppress owner notification).\n commit( initiator? : Transactional )\n}\n\n// Options for distributed transaction \nexport interface TransactionOptions {\n // Invoke parsing \n parse? : boolean\n\n // Suppress change notifications and update triggers\n silent? : boolean\n\n // Update existing transactional members in place, or skip the update (ignored by models)\n merge? : boolean // =true\n\n // Should collections remove elements in set (ignored by models) \n remove? : boolean // =true\n\n // Always replace enclosed objects with new instances\n reset? : boolean // = false\n\n // Do not dispose aggregated members\n unset? : boolean\n\n validate? : boolean\n\n // `true` if the transaction is initiated as a result of IO operation\n ioUpdate? : boolean\n\n // The hint for IOEndpoint\n // If `true`, `record.save()` will behave as \"upsert\" operation for the records having id.\n upsert? : boolean\n}\n\n/**\n * Low-level transactions API. Must be used like this:\n * const isRoot = begin( record );\n * ...\n * isRoot && commit( record, options );\n * \n * When committing nested transaction, the flag must be set to true. \n * commit( object, options, isNested ) \n */\n\nexport const transactionApi = {\n // Start transaction. Return true if it's the root one.\n /** @private */\n begin( object : Transactional ) : boolean {\n return object._transaction ? false : ( object._transaction = true ); \n },\n\n // Mark object having changes inside of the current transaction.\n // Returns true whenever there notifications are required.\n /** @private */\n markAsDirty( object : Transactional, options : TransactionOptions ) : boolean {\n // If silent option is in effect, don't set isDirty flag.\n const dirty = !options.silent;\n if( dirty ) object._isDirty = options;\n \n // Reset version token.\n object._changeToken = {};\n\n // Object is changed, so validation must happen again. Clear the cache.\n object._validationError = void 0;\n\n return dirty;\n },\n\n // Commit transaction. Send out change event and notify owner. Returns true if there were changes.\n // Must be executed for the root transaction only.\n /** @private */\n commit( object : Transactional, initiator? : Transactional ){\n let originalOptions = object._isDirty;\n\n if( originalOptions ){\n // Send the sequence of change events, handling chained handlers.\n while( object._isDirty ){\n const options = object._isDirty;\n object._isDirty = null; \n trigger3( object, object._changeEventName, object, options, initiator );\n }\n \n // Mark transaction as closed.\n object._transaction = false;\n\n // Notify owner on changes out of transaction scope. \n const { _owner } = object; \n if( _owner && _owner !== initiator ){ // If it's the nested transaction, owner is already aware there are some changes.\n _owner._onChildrenChange( object, originalOptions );\n }\n }\n else{\n // No changes. Silently close transaction.\n object._isDirty = null;\n object._transaction = false;\n }\n },\n\n /************************************\n * Ownership management\n */\n\n // Add reference to the record.\n /** @private */\n aquire( owner : Owner, child : Transactional, key? : string ) : boolean {\n if( !child._owner ){\n child._owner = owner;\n child._ownerKey = key;\n return true;\n }\n\n return child._owner === owner;\n },\n\n // Remove reference to the record.\n /** @private */\n free( owner : Owner, child : Transactional ) : void {\n if( owner === child._owner ){\n child._owner = void 0;\n child._ownerKey = void 0;\n }\n }\n}\n\nfunction getOwnerEndpoint( self : Transactional ) : IOEndpoint {\n // Check if we are the member of the collection...\n const { collection } = self as any;\n if( collection ){\n return getOwnerEndpoint( collection );\n }\n\n // Now, if we're the member of the model...\n if( self._owner ){\n const { _endpoints } = self._owner as any;\n return _endpoints && _endpoints[ self._ownerKey ];\n }\n}\n","import { Transactional, Transaction, TransactionOptions, Owner, transactionApi } from \"../../transactions\"\nconst { begin : _begin, markAsDirty : _markAsDirty, commit } = transactionApi;\n\nimport { eventsApi } from '../../object-plus'\nconst { trigger3 } = eventsApi;\n\nexport interface ConstructorsMixin {\n Attributes : AttributesConstructor\n AttributesCopy : AttributesCopyConstructor\n}\n\nexport interface ConstructorOptions extends TransactionOptions{\n clone? : boolean\n}\n\nexport type AttributesConstructor = new ( record : AttributesContainer, values : object, options : TransactionOptions ) => AttributesValues;\nexport type AttributesCopyConstructor = new ( values : object ) => AttributesValues;\n\nexport interface AttributesContainer extends Transactional, Owner, ConstructorsMixin {\n // Attribute descriptors.\n _attributes : AttributesDescriptors\n\n // Attribute values.\n attributes : AttributesValues\n\n // Previous attribute values.\n _previousAttributes : AttributesValues\n\n // Changed attributes cache. \n _changedAttributes : AttributesValues\n}\n\nexport interface AttributesValues {\n [ name : string ] : any\n}\n\nexport interface AttributesDescriptors {\n [ name : string ] : AttributeUpdatePipeline\n}\n\nexport interface AttributeUpdatePipeline{\n doUpdate( value, record : AttributesContainer, options : TransactionOptions, nested? : Transaction[] ) : boolean\n}\n\n // Optimized single attribute transactional update. To be called from attributes setters\n // options.silent === false, parse === false. \nexport function setAttribute( record : AttributesContainer, name : string, value : any ) : void {\n // Open the transaction.\n const isRoot = begin( record ),\n options = {};\n\n // Update attribute. \n if( record._attributes[ name ].doUpdate( value, record, options ) ){\n // Notify listeners on changes.\n markAsDirty( record, options );\n trigger3( record, 'change:' + name, record, record.attributes[ name ], options );\n }\n\n // Close the transaction.\n isRoot && commit( record );\n}\n\nfunction begin( record : AttributesContainer ){\n if( _begin( record ) ){\n record._previousAttributes = new record.AttributesCopy( record.attributes );\n record._changedAttributes = null;\n return true;\n }\n \n return false;\n}\n\nfunction markAsDirty( record : AttributesContainer, options : TransactionOptions ){\n // Need to recalculate changed attributes, when we have nested set in change:attr handler\n if( record._changedAttributes ){\n record._changedAttributes = null;\n }\n\n return _markAsDirty( record, options );\n}\n\n/**\n * TODO: There's an opportunity to create an optimized pipeline for primitive types and Date, which makes the majority\n * of attributes. It might create the major speedup.\n * \n * Create the dedicated pipeline for owned and shared attributes as well.\n * \n * Three elements of the pipeline:\n * - from constructor\n * - from assignment\n * - from `set`\n */\n\nexport const UpdateRecordMixin = {\n// Need to override it here, since begin/end transaction brackets are overriden. \n transaction( this : AttributesContainer, fun : ( self : AttributesContainer ) => void, options : TransactionOptions = {} ) : void{\n const isRoot = begin( this );\n fun.call( this, this );\n isRoot && commit( this );\n },\n \n // Handle nested changes. TODO: propagateChanges == false, same in transaction.\n _onChildrenChange( child : Transactional, options : TransactionOptions ) : void {\n const { _ownerKey } = child,\n attribute = this._attributes[ _ownerKey ];\n\n if( !attribute /* TODO: Must be an opposite, likely the bug */ || attribute.propagateChanges ) this.forceAttributeChange( _ownerKey, options );\n },\n\n // Simulate attribute change \n forceAttributeChange( key : string, options : TransactionOptions = {} ){\n // Touch an attribute in bounds of transaction\n const isRoot = begin( this );\n\n if( markAsDirty( this, options ) ){\n trigger3( this, 'change:' + key, this, this.attributes[ key ], options );\n }\n \n isRoot && commit( this );\n },\n\n _createTransaction( this : AttributesContainer, a_values : {}, options : TransactionOptions = {} ) : Transaction {\n const isRoot = begin( this ),\n changes : string[] = [],\n nested : RecordTransaction[]= [],\n { _attributes } = this,\n values = options.parse ? this.parse( a_values, options ) : a_values;\n\n let unknown;\n\n if( shouldBeAnObject( this, values ) ){\n for( let name in values ){\n const spec = _attributes[ name ];\n\n if( spec ){\n if( spec.doUpdate( values[ name ], this, options, nested ) ){\n changes.push( name );\n }\n }\n else{\n unknown || ( unknown = [] );\n unknown.push( `'${ name }'` );\n }\n }\n\n if( unknown ){\n // this._log( 'warn', `Undefined attributes ${ unknown.join(', ')} are ignored!`, values );\n }\n }\n \n if( changes.length && markAsDirty( this, options ) ){\n return new RecordTransaction( this, isRoot, nested, changes );\n }\n \n // No changes, but there might be silent attributes with open transactions.\n for( let pendingTransaction of nested ){\n pendingTransaction.commit( this );\n }\n\n isRoot && commit( this );\n }\n};\n\n// One of the main performance tricks of Type-R.\n// Create loop unrolled constructors for internal attribute hash,\n// so the hidden class JIT optimization will be engaged and they will become static structs.\n// It dramatically improves record performance.\nexport function constructorsMixin( attrDefs : AttributesDescriptors ) : ConstructorsMixin {\n const attrs = Object.keys( attrDefs );\n\n const AttributesCopy : AttributesCopyConstructor = new Function( 'values', `\n ${ attrs.map( attr =>`\n this.${ attr } = values.${ attr };\n `).join( '' ) }\n `) as any;\n\n AttributesCopy.prototype = Object.prototype;\n\n const Attributes : AttributesConstructor = new Function( 'record', 'values', 'options', `\n var _attrs = record._attributes;\n\n ${ attrs.map( attr =>`\n this.${ attr } = _attrs.${ attr }.doInit( values.${ attr }, record, options );\n `).join( '' ) }\n `) as any;\n\n Attributes.prototype = Object.prototype;\n\n return { Attributes, AttributesCopy };\n}\n\nexport function shouldBeAnObject( record : AttributesContainer, values : object ){\n if( values && values.constructor === Object ) return true;\n\n record._log( 'warn', 'update with non-object is ignored!', { values } );\n return false;\n}\n\n// Transaction class. Implements two-phase transactions on object's tree. \n// Transaction must be created if there are actual changes and when markIsDirty returns true. \nexport class RecordTransaction implements Transaction {\n // open transaction\n constructor( public object : AttributesContainer,\n public isRoot : boolean,\n public nested : Transaction[],\n public changes : string[] ){}\n\n // commit transaction\n commit( initiator? : AttributesContainer ) : void {\n const { nested, object, changes } = this;\n\n // Commit all pending nested transactions...\n for( let transaction of nested ){ \n transaction.commit( object );\n }\n\n // Notify listeners on attribute changes...\n // Transaction is never created when silent option is set, so just send events out.\n const { attributes, _isDirty } = object;\n for( let key of changes ){\n trigger3( object, 'change:' + key, object, attributes[ key ], _isDirty );\n }\n\n this.isRoot && commit( object, initiator );\n }\n}","import { setAttribute, AttributesContainer, AttributeUpdatePipeline, RecordTransaction } from './updates'\nimport { tools } from '../../object-plus'\nimport { Owner, Transactional, TransactionOptions } from '../../transactions'\nimport { IOEndpoint } from '../../io-tools'\n\nconst { notEqual, assign} = tools;\n\ndeclare global {\n interface Function {\n _attribute : typeof AnyType\n }\n}\n\nexport type Transform = ( this : AnyType, next : any, prev : any, record : AttributesContainer, options : TransactionOptions ) => any;\nexport type ChangeHandler = ( this : AnyType, next : any, prev : any, record : AttributesContainer, options : TransactionOptions ) => void;\n\nexport interface AttributeOptions {\n _attribute? : typeof AnyType\n validate? : ( record : AttributesContainer, value : any, key : string ) => any\n isRequired? : boolean\n changeEvents? : boolean\n\n endpoint? : IOEndpoint\n\n type? : Function\n value? : any\n hasCustomDefault? : boolean\n\n parse? : Parse\n toJSON? : AttributeToJSON\n \n getHooks? : GetHook[]\n transforms? : Transform[]\n changeHandlers? : ChangeHandler[]\n\n _onChange? : ChangeAttrHandler\n}\n\nexport type Parse = ( value : any, key : string ) => any;\nexport type GetHook = ( value : any, key : string ) => any;\nexport type AttributeToJSON = ( value : any, key : string ) => any\nexport type AttributeParse = ( value : any, key : string ) => any\nexport type ChangeAttrHandler = ( ( value : any, attr : string ) => void ) | string;\n\n// TODO: interface differs from options, do something obout it\nconst emptyOptions : TransactionOptions = {};\n\n/**\n * Typeless attribute. Is the base class for all other attributes.\n */\nexport class AnyType implements AttributeUpdatePipeline {\n // Factory method to create attribute from options \n static create( options : AttributeOptions, name : string ) : AnyType {\n const type = options.type,\n AttributeCtor = options._attribute || ( type ? type._attribute : AnyType );\n\n return new AttributeCtor( name, options );\n }\n /**\n * Update pipeline functions\n * =========================\n *\n * Stage 0. canBeUpdated( value )\n * - presence of this function implies attribute's ability to update in place.\n */\n canBeUpdated( prev, next, options : TransactionOptions ) : any {}\n\n /**\n * Stage 1. Transform stage\n */\n transform( next : any, prev : any, model : AttributesContainer, options : TransactionOptions ) : any { return next; }\n\n // convert attribute type to `this.type`.\n convert( next : any, prev : any, model : AttributesContainer, options : TransactionOptions ) : any { return next; }\n\n /**\n * Stage 2. Check if attr value is changed\n */\n isChanged( a : any, b : any ) : boolean {\n return notEqual( a, b );\n }\n\n /**\n * Stage 3. Handle attribute change\n */\n handleChange( next : any, prev : any, model : AttributesContainer, options : TransactionOptions ) {}\n\n /**\n * End update pipeline definitions.\n */\n\n // create empty object passing backbone options to constructor...\n create() { return void 0; }\n\n // generic clone function for typeless attributes\n // Must be overriden in sublass\n clone( value : any, record : AttributesContainer ) {\n return value;\n }\n\n dispose( record : AttributesContainer, value : any ) : void {\n this.handleChange( void 0, value, record, emptyOptions );\n }\n\n validate( record : AttributesContainer, value : any, key : string ){}\n\n toJSON( value, key, options? : object ) {\n return value && value.toJSON ? value.toJSON( options ) : value;\n }\n\n createPropertyDescriptor() : PropertyDescriptor | void {\n const { name, getHook } = this;\n\n if( name !== 'id' ){\n return {\n // call to optimized set function for single argument.\n set( value ){\n setAttribute( this, name, value );\n },\n\n // attach get hook to the getter function, if it present\n get : (\n getHook ?\n function() {\n return getHook.call( this, this.attributes[ name ], name );\n } :\n function() { return this.attributes[ name ]; }\n )\n }\n }\n }\n\n value : any\n\n // Used as global default value for the given metatype\n static defaultValue : any;\n\n type : Function\n\n initialize( name : string, options : TransactionOptions ){}\n\n options : AttributeOptions\n\n doInit( value, record : AttributesContainer, options : TransactionOptions ){\n const v = value === void 0 ? this.defaultValue() : value,\n x = this.transform( v, void 0, record, options );\n \n this.handleChange( x, void 0, record, options );\n return x;\n }\n\n doUpdate( value, record : AttributesContainer, options : TransactionOptions, nested? : RecordTransaction[] ){\n const { name } = this,\n { attributes } = record,\n prev = attributes[ name ];\n\n const next = this.transform( value, prev, record, options );\n attributes[ name ] = next;\n\n if( this.isChanged( next, prev ) ) {\n // Do the rest of the job after assignment\n this.handleChange( next, prev, record, options );\n return true;\n }\n\n return false;\n }\n\n propagateChanges : boolean\n\n _log( level : tools.LogLevel, text : string, value, record : AttributesContainer ){\n tools.log( level, `[Attribute Update Error] ${ record.getClassName() }.${ this.name }: ` + text, {\n 'Record' : record,\n 'Attribute definition' : this,\n 'Prev. value' : record.attributes[ this.name ],\n 'New value' : value\n });\n }\n\n defaultValue(){\n return this.value;\n }\n\n constructor( public name : string, a_options : AttributeOptions ) { \n // Save original options...\n this.options = a_options;\n\n // Clone options.\n const options : AttributeOptions = assign( { getHooks : [], transforms : [], changeHandlers : [] }, a_options );\n options.getHooks = options.getHooks.slice();\n options.transforms = options.transforms.slice();\n options.changeHandlers = options.changeHandlers.slice();\n\n const {\n value, type, parse, toJSON, changeEvents,\n validate, getHooks, transforms, changeHandlers\n } = options;\n\n // Initialize default value...\n this.value = value;\n this.type = type;\n\n // TODO: An opportunity to optimize for attribute subtype.\n if( !options.hasCustomDefault && type ){\n this.defaultValue = this.create;\n }\n else if( tools.isValidJSON( value ) ){ \n // JSON literals must be deep copied.\n this.defaultValue = new Function( `return ${ JSON.stringify( value ) };` ) as any;\n }\n else{\n this.defaultValue = this.defaultValue;\n }\n\n // Changes must be bubbled when they are not disabled for an attribute and transactional object.\n this.propagateChanges = changeEvents !== false;\n\n this.toJSON = toJSON === void 0 ? this.toJSON : toJSON;\n\n this.validate = validate || this.validate;\n \n if( options.isRequired ){\n this.validate = wrapIsRequired( this.validate );\n }\n\n /**\n * Assemble pipelines...\n */\n\n // `convert` is default transform, which is always present...\n transforms.unshift( this.convert );\n\n // Get hook from the attribute will be used first...\n if( this.get ) getHooks.unshift( this.get );\n\n // let subclasses configure the pipeline...\n this.initialize.call( this, options );\n\n // let attribute spec configure the pipeline...\n if( getHooks.length ){\n const getHook = this.getHook = getHooks.reduce( chainGetHooks );\n\n const { validate } = this;\n this.validate = function( record : AttributesContainer, value : any, key : string ){\n return validate.call( this, record, getHook.call( record, value, key ), key );\n }\n }\n \n this.transform = transforms.length ? transforms.reduce( chainTransforms ) : this.transform;\n \n this.handleChange = changeHandlers.length ? changeHandlers.reduce( chainChangeHandlers ) : this.handleChange;\n\n // Attribute-level parse transform are attached as update hooks modifiers...\n const { doInit, doUpdate } = this;\n this.doInit = parse ? function( value, record : AttributesContainer, options : TransactionOptions ){\n return doInit.call( this, options.parse && value !== void 0 ? parse.call( record, value, this.name ) : value, record, options );\n } : doInit;\n\n this.doUpdate = parse ? function( value, record : AttributesContainer, options : TransactionOptions, nested? : RecordTransaction[] ){\n return doUpdate.call( this, options.parse && value !== void 0 ? parse.call( record, value, this.name ) : value, record, options, nested );\n } : doUpdate;\n }\n\n getHook : ( value, key : string ) => any = null\n get : ( value, key : string ) => any\n}\n\n\nfunction chainGetHooks( prevHook : GetHook, nextHook : GetHook ) : GetHook {\n return function( value, name ) {\n return nextHook.call( this, prevHook.call( this, value, name ), name );\n }\n}\n\nfunction chainTransforms( prevTransform : Transform, nextTransform : Transform ) : Transform {\n return function( next, prev, record, options ) {\n return nextTransform.call( this, prevTransform.call( this, next, prev, record, options ), prev, record, options );\n }\n}\n\nfunction chainChangeHandlers( prevHandler : ChangeHandler, nextHandler : ChangeHandler ) : ChangeHandler {\n return function( next, prev, record, options ) {\n prevHandler.call( this, next, prev, record, options );\n nextHandler.call( this, next, prev, record, options );\n }\n}\n\nfunction wrapIsRequired( validate ){\n return function( record : AttributesContainer, value : any, key : string ){\n return value ? validate.call( this, record, value, key ) : 'Required';\n }\n}","import { AnyType } from './any'\nimport { Owner, transactionApi, Transactional, ItemsBehavior, TransactionOptions } from '../../transactions'\nimport { tools } from '../../object-plus'\nimport { AttributesContainer, ConstructorOptions } from './updates'\nimport { ValidationError } from '../../validation'\n\nconst { free, aquire } = transactionApi;\n\nexport class AggregatedType extends AnyType {\n type : typeof Transactional\n\n clone( value : Transactional ) : Transactional {\n return value ? value.clone() : value;\n }\n\n toJSON( x, key : string, options : object ){ return x && x.toJSON( options ); }\n\n doInit( value, record : AttributesContainer, options : ConstructorOptions ){\n const v = options.clone ? this.clone( value ) : (\n value === void 0 ? this.defaultValue() : value\n );\n\n const x = this.transform( v, void 0, record, options );\n this.handleChange( x, void 0, record, options );\n return x;\n }\n\n doUpdate( value, record, options, nested : any[] ){ // Last to things can be wrapped to an object, either transaction or ad-hoc\n const key = this.name, { attributes } = record; \n const prev = attributes[ key ];\n let update;\n\n // This can be moved to transactional attribute. And chained with the rest.\n if( update = this.canBeUpdated( prev, value, options ) ) { // todo - skip empty updates.\n const nestedTransaction = prev._createTransaction( update, options );\n if( nestedTransaction ){\n if( nested ){\n nested.push( nestedTransaction );\n }\n else{\n nestedTransaction.commit( record );\n }\n\n if( this.propagateChanges ) return true;\n }\n\n return false;\n }\n\n const next = this.transform( value, prev, record, options );\n attributes[ key ] = next;\n\n if( this.isChanged( next, prev ) ) { // Primitives and nested comparison can be inlined.\n // Do the rest of the job after assignment\n this.handleChange( next, prev, record, options );\n\n return true;\n }\n\n return false;\n }\n\n canBeUpdated( prev : Transactional, next : any, options : TransactionOptions ) : any {\n // If an object already exists, and new value is of incompatible type, let object handle the update.\n if( prev && next != null ){\n if( next instanceof this.type ){\n // In case if merge option explicitly specified, force merge.\n if( options.merge ) return next.__inner_state__;\n }\n else{\n return next;\n }\n }\n }\n\n convert( next : any, prev : any, record : AttributesContainer, options : TransactionOptions ) : Transactional {\n // Invoke class factory to handle abstract classes\n if( next == null ) return next;\n \n if( next instanceof this.type ){\n if( next._shared && !( next._shared & ItemsBehavior.persistent ) ) { // TODO: think more about shared types assignment compatibility. \n this._log( 'error', 'aggregated collection attribute is assigned with shared collection', next, record );\n }\n\n // With explicit 'merge' option we need to clone an object if its previous value was 'null'.\n // This is an only case we could be here when merge === true.\n return options.merge ? next.clone() : next;\n }\n\n return this.type.create( next, options );\n }\n\n dispose ( record : AttributesContainer, value : Transactional ){\n if( value ){\n this.handleChange( void 0, value, record, {} );\n }\n }\n\n validate( record : AttributesContainer, value : Transactional ) : ValidationError {\n var error = value && value.validationError;\n if( error ) return error;\n }\n\n create() : Transactional {\n return (this.type).create(); // this the subclass of Transactional here.\n }\n\n initialize( options ){\n options.changeHandlers.unshift( this._handleChange );\n }\n\n _handleChange( next : Transactional, prev : Transactional, record : AttributesContainer, options : TransactionOptions ){\n if( prev ){\n free( record, prev );\n options.unset || prev.dispose();\n } \n \n if( next && !aquire( record, next, this.name ) ){\n this._log( 'error', 'aggregated attribute assigned with object already having an owner', next, record );\n }\n }\n}","/**\n * Type spec engine. Declare attributes using chainable syntax,\n * and returns object with spec.\n */\nimport { Transactional } from '../../transactions'\nimport { ChangeAttrHandler, AttributeOptions, Parse } from './any'\nimport { AttributesContainer } from './updates'\nimport { EventMap, EventsDefinition, definitionDecorator, tools } from '../../object-plus'\nimport { IOEndpoint } from '../../io-tools'\n\nconst { assign } = tools;\n\nexport interface AttributeCheck {\n ( value : any, key : string ) : boolean\n error? : any\n}\n\nexport class ChainableAttributeSpec {\n options : AttributeOptions;\n\n constructor( options : AttributeOptions ) {\n // Shallow copy options, fill it with defaults.\n this.options = { getHooks : [], transforms : [], changeHandlers : []};\n if( options ) assign( this.options, options );\n }\n\n check( check : AttributeCheck, error : any ) : ChainableAttributeSpec {\n function validate( model, value, name ){\n if( !check.call( model, value, name ) ){\n const msg = error || check.error || name + ' is not valid';\n return typeof msg === 'function' ? msg.call( model, name ) : msg;\n }\n }\n\n const prev = this.options.validate;\n\n return this.metadata({\n validate : prev ? (\n function( model, value, name ){\n return prev( model, value, name ) || validate( model, value, name );\n }\n ) : validate\n });\n }\n\n get asProp(){\n return definitionDecorator( 'attributes', this );\n }\n\n get as(){ return this.asProp; }\n\n get isRequired() : ChainableAttributeSpec {\n return this.metadata({ isRequired : true }); \n }\n\n endpoint( endpoint : IOEndpoint ){\n return this.metadata({ endpoint });\n }\n\n watcher( ref : string | ( ( value : any, key : string ) => void ) ) : ChainableAttributeSpec {\n return this.metadata({ _onChange : ref });\n }\n\n // Attribute-specific parse transform\n parse( fun : Parse ) : ChainableAttributeSpec {\n return this.metadata({ parse : fun });\n }\n\n toJSON( fun ) : ChainableAttributeSpec {\n return this.metadata({\n toJSON : typeof fun === 'function' ? fun : ( fun ? ( x, k, o ) => x && x.toJSON( o ) : emptyFunction ) \n });\n }\n\n // Attribute get hook.\n get( fun ) : ChainableAttributeSpec {\n return this.metadata({\n getHooks : this.options.getHooks.concat( fun )\n });\n }\n\n // Attribute set hook.\n set( fun ) : ChainableAttributeSpec {\n function handleSetHook( next, prev, record : AttributesContainer, options ) {\n if( this.isChanged( next, prev ) ) {\n const changed = fun.call( record, next, this.name );\n return changed === void 0 ? prev : this.convert( changed, prev, record, options );\n }\n\n return prev;\n }\n\n return this.metadata({\n transforms : this.options.transforms.concat( handleSetHook )\n });\n }\n\n changeEvents( events : boolean ) : ChainableAttributeSpec {\n return this.metadata({ changeEvents : events });\n }\n\n // Subsribe to events from an attribute.\n events( map : EventsDefinition ) : ChainableAttributeSpec {\n const eventMap = new EventMap( map );\n\n function handleEventsSubscribtion( next, prev, record : AttributesContainer ){\n prev && prev.trigger && eventMap.unsubscribe( record, prev );\n\n next && next.trigger && eventMap.subscribe( record, next );\n }\n\n return this.metadata({\n changeHandlers : this.options.changeHandlers.concat( handleEventsSubscribtion )\n });\n }\n\n // Creates a copy of the spec.\n get has() : ChainableAttributeSpec {\n return this;\n }\n\n metadata( options : AttributeOptions ) : ChainableAttributeSpec {\n const cloned = new ChainableAttributeSpec( this.options );\n assign( cloned.options, options );\n return cloned;\n }\n\n value( x ) : ChainableAttributeSpec {\n return this.metadata({ value : x, hasCustomDefault : true });\n }\n\n static from( spec : any ) : ChainableAttributeSpec {\n let attrSpec : ChainableAttributeSpec;\n\n if( typeof spec === 'function' ) {\n attrSpec = spec.has;\n }\n else if( spec && spec instanceof ChainableAttributeSpec ) {\n attrSpec = spec;\n }\n else{\n // Infer type from value.\n const type = inferType( spec );\n \n // Transactional types inferred from values must have shared type. \n if( type && type.prototype instanceof Transactional ){\n attrSpec = (type).shared.value( spec );\n }\n // All others will be created in regular way.\n else{\n attrSpec = new ChainableAttributeSpec({ type : type, value : spec, hasCustomDefault : true });\n }\n }\n \n return attrSpec;\n }\n}\n\nfunction emptyFunction(){}\n\nexport function type( this : void, spec : ChainableAttributeSpec | Function ) : ChainableAttributeSpec {\n return spec instanceof ChainableAttributeSpec ? spec : new ChainableAttributeSpec( {\n type : spec,\n value : spec._attribute.defaultValue,\n hasCustomDefault : spec._attribute.defaultValue !== void 0\n } );;\n}\n\ndeclare global {\n interface Function{\n value : ( x : any ) => ChainableAttributeSpec;\n isRequired : ChainableAttributeSpec;\n asProp : PropertyDecorator\n has : ChainableAttributeSpec;\n }\n}\n\nFunction.prototype.value = function( x ) {\n return new ChainableAttributeSpec( { type : this, value : x, hasCustomDefault : true } );\n};\n\nObject.defineProperty( Function.prototype, 'isRequired', {\n get() { return this._isRequired || this.has.isRequired; },\n set( x ){ this._isRequired = x; }\n});\n\nObject.defineProperty( Function.prototype, 'asProp', {\n get() { return this.has.asProp; },\n});\n\nObject.defineProperty( Function.prototype, 'has', {\n get() {\n // workaround for sinon.js and other libraries overriding 'has'\n return this._has || type( this );\n },\n\n set( value ) { this._has = value; }\n} );\n\nfunction inferType( value : {} ) : Function {\n switch( typeof value ) {\n case 'number' :\n return Number;\n case 'string' :\n return String;\n case 'boolean' :\n return Boolean;\n case 'undefined' :\n return void 0;\n case 'object' :\n return value ? value.constructor : void 0;\n }\n}\n","/**\n * Date attribute type.\n * \n * Implements validation, cross-browser compatibility fixes, variety of Date serialization formats,\n * and optimized update pipeline.\n */\nimport { AnyType } from './any'\nimport { tools } from '../../object-plus'\nimport { AttributesContainer } from './updates'\nimport { TransactionOptions } from '../../transactions'\nimport { ChainableAttributeSpec } from './attrDef'\n\nconst DateProto = Date.prototype;\n\n// Date Attribute\n/** @private */\nexport class DateType extends AnyType {\n create(){\n return new Date();\n }\n \n convert( next : any, a, record ){\n if( next == null || next instanceof Date ) return next;\n\n const date = new Date( next ),\n timestamp = date.getTime();\n\n if( timestamp !== timestamp ){\n this._log( 'warn', 'assigned with Invalid Date', next, record );\n }\n\n return date;\n }\n\n validate( model, value, name ) {\n if( value != null ){\n const timestamp = value.getTime(); \n if( timestamp !== timestamp ) return name + ' is Invalid Date';\n }\n }\n\n toJSON( value ) { return value && value.toISOString(); }\n\n isChanged( a, b ) { return ( a && a.getTime() ) !== ( b && b.getTime() ); }\n\n doInit( value, record : AttributesContainer, options : TransactionOptions ){\n // Date don't have handleChanges step.\n return this.transform( value === void 0 ? this.defaultValue() : value, void 0, record, options );\n }\n\n doUpdate( value, record, options, nested ){\n const { name } = this,\n { attributes } = record,\n prev = attributes[ name ];\n \n // Date don't have handleChanges step.\n return this.isChanged( prev , attributes[ name ] = this.transform( value, prev, record, options ) );\n }\n\n clone( value ) { return value && new Date( value.getTime() ); }\n dispose(){}\n}\n\nDate._attribute = DateType;\n\nconst msDatePattern = /\\/Date\\(([0-9]+)\\)\\//;\n\nexport class MSDateType extends DateType {\n convert( next ) {\n if( typeof next === 'string' ){\n const msDate = msDatePattern.exec( next );\n if( msDate ){\n return new Date( Number( msDate[ 1 ] ) );\n }\n }\n\n return DateType.prototype.convert.apply( this, arguments );\n }\n\n toJSON( value ) { return value && `/Date(${ value.getTime() })/`; }\n}\n\nexport class TimestampType extends DateType {\n toJSON( value ) { return value && value.getTime(); }\n}\n\ndeclare global {\n interface DateConstructor {\n microsoft : ChainableAttributeSpec\n timestamp : ChainableAttributeSpec\n }\n}\n\nObject.defineProperties( Date, {\n microsoft : {\n get(){\n return new ChainableAttributeSpec({\n type : Date,\n _attribute : MSDateType\n })\n }\n },\n\n timestamp : {\n get(){\n return new ChainableAttributeSpec({\n type : Date,\n _attribute : TimestampType\n })\n }\n }\n});\n\n// If ISO date is not supported by date constructor (such as in Safari), polyfill it.\nfunction supportsDate( date ){\n return !isNaN( ( new Date( date ) ).getTime() );\n}\n\nif( !supportsDate('2011-11-29T15:52:30.5') ||\n !supportsDate('2011-11-29T15:52:30.52') ||\n !supportsDate('2011-11-29T15:52:18.867') ||\n !supportsDate('2011-11-29T15:52:18.867Z') ||\n !supportsDate('2011-11-29T15:52:18.867-03:30') ){\n\n DateType.prototype.convert = function( value ){\n return value == null || value instanceof Date ? value : new Date( safeParseDate( value ) );\n }\n}\n\nconst numericKeys = [ 1, 4, 5, 6, 7, 10, 11 ],\n isoDatePattern = /^(\\d{4}|[+\\-]\\d{6})(?:-(\\d{2})(?:-(\\d{2}))?)?(?:T(\\d{2}):(\\d{2})(?::(\\d{2})(?:\\.(\\d{3}))?)?(?:(Z)|([+\\-])(\\d{2})(?::(\\d{2}))?)?)?$/;\n\nfunction safeParseDate( date : string ) : number {\n var timestamp, struct : any[], minutesOffset = 0;\n\n if( ( struct = isoDatePattern.exec( date )) ) {\n // avoid NaN timestamps caused by undefined values being passed to Date.UTC\n for( var i = 0, k; ( k = numericKeys[ i ] ); ++i ) {\n struct[ k ] = +struct[ k ] || 0;\n }\n\n // allow undefined days and months\n struct[ 2 ] = (+struct[ 2 ] || 1) - 1;\n struct[ 3 ] = +struct[ 3 ] || 1;\n\n if( struct[ 8 ] !== 'Z' && struct[ 9 ] !== undefined ) {\n minutesOffset = struct[ 10 ] * 60 + struct[ 11 ];\n\n if( struct[ 9 ] === '+' ) {\n minutesOffset = 0 - minutesOffset;\n }\n }\n\n timestamp =\n Date.UTC( struct[ 1 ], struct[ 2 ], struct[ 3 ], struct[ 4 ], struct[ 5 ] + minutesOffset, struct[ 6 ],\n struct[ 7 ] );\n }\n else {\n timestamp = Date.parse( date );\n }\n\n return timestamp;\n}","/**\n * Built-in JSON types attributes: Object, Array, Number, String, Boolean, and immutable class.\n * \n * Adds type assertions, default validation, and optimized update pipeline.\n */\n\nimport { AnyType } from './any'\nimport { tools } from '../../object-plus'\nimport { AttributesContainer } from './updates'\nimport { TransactionOptions } from '../../transactions'\n\n/**\n * Custom class must be immutable class which implements toJSON() method\n * with a constructor taking json.\n */\nclass ImmutableClassType extends AnyType {\n type : new ( value? : any ) => {}\n\n create(){\n return new this.type();\n }\n\n convert( next : any ) : any {\n return next == null || next instanceof this.type ? next : new this.type( next );\n }\n\n toJSON( value, key? : string, options? : object ){\n return value && value.toJSON ? value.toJSON( options ) : value;\n }\n\n clone( value ) {\n return new this.type( this.toJSON( value ) );\n }\n\n isChanged( a, b ){\n return a !== b;\n }\n}\n\nFunction.prototype._attribute = ImmutableClassType;\n\n/**\n * Optimized attribute of primitive type.\n * \n * Primitives has specialized simplified pipeline.\n */\nexport class PrimitiveType extends AnyType {\n type : NumberConstructor | StringConstructor | BooleanConstructor\n\n dispose(){}\n create() { return this.type(); }\n\n toJSON( value ) { return value; }\n\n convert( next ) { return next == null ? next : this.type( next ); }\n\n isChanged( a, b ) { return a !== b; }\n\n clone( value ) { return value; }\n\n doInit( value, record : AttributesContainer, options : TransactionOptions ){\n return this.transform( value === void 0 ? this.value : value, void 0, record, options );\n }\n\n doUpdate( value, record, options, nested ){\n const { name } = this,\n { attributes } = record,\n prev = attributes[ name ];\n \n return prev !== ( attributes[ name ] = this.transform( value, prev, record, options ) );\n }\n\n initialize(){\n if( !this.options.hasCustomDefault ){\n this.value = this.type();\n }\n }\n}\n\nBoolean._attribute = String._attribute = PrimitiveType;\n\n// Number type with special validation algothim.\n/** @private */ \nexport class NumericType extends PrimitiveType {\n type : NumberConstructor\n\n create(){\n return 0;\n }\n\n convert( next, prev?, record? ) {\n const num = next == null ? next : this.type( next );\n\n if( num !== num ){\n this._log( 'warn', 'assigned with Invalid Number', next, record );\n }\n \n return num;\n }\n\n validate( model, value, name ) {\n // Whatever is not symmetrically serializable to JSON, is not valid by default.\n if( value != null && !isFinite( value ) ) {\n return name + ' is not valid number';\n }\n }\n}\n\nNumber._attribute = NumericType;\n\n/**\n * Add Number.integer attrubute type\n */\ndeclare global {\n interface NumberConstructor {\n integer : Function\n }\n\n interface Window {\n Integer : Function;\n }\n}\n\nfunction Integer( x ){\n return x ? Math.round( x ) : 0;\n}\nInteger._attribute = NumericType;\nNumber.integer = Integer;\n\n\nif( typeof window !== 'undefined' ){\n window.Integer = Number.integer;\n}\n\n/**\n * Compatibility wrapper for Array type.\n * @private\n */ \nexport class ArrayType extends AnyType {\n toJSON( value ) { return value; }\n dispose(){}\n create(){ return []; }\n\n convert( next, prev, record ) {\n // Fix incompatible constructor behaviour of Array...\n if( next == null || Array.isArray( next ) ) return next;\n\n this._log( 'warn', 'assignment of non-array to Array attribute is ignored', next, record );\n\n return [];\n }\n\n clone( value ){\n return value && value.slice();\n }\n}\n\nArray._attribute = ArrayType;\n\nexport class ObjectType extends AnyType {\n create(){ return {}; }\n\n convert( next, prev, record ) {\n if( next == null || typeof next === 'object' ) return next;\n \n this._log( 'warn', 'assignment of non-object to Object attribute is ignored', next, record );\n return {};\n }\n}\n\nObject._attribute = ObjectType;\n\nexport function doNothing(){}\n\nexport class FunctionType extends AnyType {\n // Functions are not serialized.\n toJSON( value ) { return void 0; }\n create(){ return doNothing; }\n dispose(){}\n\n convert( next, prev, record ) {\n // Fix incompatible constructor behaviour of Function...\n if( next == null || typeof next === 'function' ) return next;\n\n this._log( 'warn', 'assigned with non-function', next, record );\n\n return doNothing;\n }\n\n // Functions are not cloned.\n clone( value ){ return value; }\n}\n\nFunction._attribute = FunctionType;","import { AnyType } from './any'\nimport { AttributesContainer, ConstructorOptions } from './updates'\nimport { ItemsBehavior, Owner, transactionApi, Transactional, TransactionOptions } from '../../transactions' \nimport { tools, eventsApi } from '../../object-plus'\n\nconst { on, off } = eventsApi,\n { free, aquire } = transactionApi;\n\n/************************\n * Shared attribute definition.\n * - Not serialized.\n * - Listening to the changes.\n * - Doesn't take ownership when assigned with object of proper type.\n * - Takes ownership on objects which are converted.\n */\n\nconst shareAndListen = ItemsBehavior.listen | ItemsBehavior.share;\n\n/** @private */\nexport class SharedType extends AnyType {\n type : typeof Transactional\n\n doInit( value, record : AttributesContainer, options : ConstructorOptions ){\n const v = options.clone ? this.clone( value, record ) : (\n value === void 0 ? this.defaultValue() : value\n );\n\n const x = this.transform( v, void 0, record, options );\n this.handleChange( x, void 0, record, options );\n return x;\n }\n\n doUpdate( value, record, options, nested : any[] ){ // Last to things can be wrapped to an object, either transaction or ad-hoc\n const key = this.name, { attributes } = record; \n const prev = attributes[ key ];\n let update;\n\n // This can be moved to transactional attribute. And chained with the rest.\n if( update = this.canBeUpdated( prev, value, options ) ) { // todo - skip empty updates.\n const nestedTransaction = prev._createTransaction( update, options );\n if( nestedTransaction ){\n if( nested ){\n nested.push( nestedTransaction );\n }\n else{\n nestedTransaction.commit( record );\n }\n\n if( this.propagateChanges ) return true;\n }\n\n return false;\n }\n\n const next = this.transform( value, prev, record, options );\n attributes[ key ] = next;\n\n if( this.isChanged( next, prev ) ) { // Primitives and nested comparison can be inlined.\n // Do the rest of the job after assignment\n this.handleChange( next, prev, record, options );\n\n return true;\n }\n\n return false;\n }\n\n clone( value : Transactional, record : AttributesContainer ) : Transactional {\n // References are not cloned.\n if( !value || value._owner !== record ) return value;\n\n // Implicitly created objects are cloned.\n const clone = value.clone();\n aquire( record, clone, this.name );\n return clone;\n }\n\n // Do not serialize by default.\n toJSON(){}\n\n canBeUpdated( prev : Transactional, next : any, options : TransactionOptions ) : any {\n // If an object already exists, and new value is of incompatible type, let object handle the update.\n if( prev && next != null && !( next instanceof this.type ) ){\n return next;\n }\n }\n\n convert( next : any, prev : any, record : AttributesContainer, options : TransactionOptions ) : Transactional {\n if( next == null || next instanceof this.type ) return next;\n\n // Convert type using implicitly created rtransactional object.\n const implicitObject = new ( this.type as any )( next, options, shareAndListen );\n\n // To prevent a leak, we need to take an ownership on it.\n aquire( record, implicitObject, this.name );\n\n return implicitObject;\n }\n\n // Refs are always valid.\n validate( model, value, name ){}\n\n // They are always created as null.\n create() : Transactional {\n return null;\n }\n\n // Listening to the change events\n _handleChange( next : Transactional, prev : Transactional, record : AttributesContainer, options ){\n if( prev ){\n // If there was an implicitly created object, remove an ownership.\n if( prev._owner === record ){\n free( record, prev );\n options.unset || prev.dispose();\n }\n else{\n off( prev, prev._changeEventName, this._onChange, record );\n }\n } \n \n if( next ){\n // No need to take an ownership for an implicit object - already done in convert or clone.\n if( next._owner !== record ){\n on( next, next._changeEventName, this._onChange, record );\n }\n } \n }\n\n dispose( record : AttributesContainer, value : Transactional ){\n if( value ){\n this.handleChange( void 0, value, record, {} );\n }\n }\n\n _onChange : ( child : Transactional, options : TransactionOptions, initiator : Transactional ) => void \n\n initialize( options ){\n // Create change event handler which knows current attribute name. \n const attribute = this;\n this._onChange = this.propagateChanges ? function( child, options, initiator ){\n this === initiator || this.forceAttributeChange( attribute.name, options );\n } : ignore;\n\n options.changeHandlers.unshift( this._handleChange );\n }\n}\n\nfunction ignore(){}","import { tools as _, eventsApi } from '../../object-plus'\n\nexport * from './any'\nexport * from './owned'\nexport * from './date'\nexport * from './basic'\nexport * from './shared'\nexport * from './updates'\nexport * from './attrDef'\n\nimport { AnyType } from './any'\nimport { ConstructorsMixin, constructorsMixin } from './updates'\nimport { ChainableAttributeSpec } from './attrDef'\nimport { CompiledReference } from '../../traversable'\nimport { IOEndpoint } from '../../io-tools'\n\nexport interface RecordAttributesMixin extends ConstructorsMixin {\n // Attributes descriptors\n _attributes : AttributeDescriptors\n _attributesArray : AnyType[]\n \n // Attribute's property descriptors\n properties : PropertyDescriptorMap\n\n // Event map for record's local events.\n _localEvents? : eventsApi.EventMap,\n\n _endpoints : { [ name : string ] : IOEndpoint }\n}\n\nexport interface AttributeDescriptors {\n [ name : string ] : AnyType\n}\n\n// Create record mixin from the given record's attributes definition\nexport default function( attributesDefinition : object, baseClassAttributes : AttributeDescriptors ) : RecordAttributesMixin {\n const myAttributes = _.transform( {} as AttributeDescriptors, attributesDefinition, createAttribute ),\n allAttributes = _.defaults( {} as AttributeDescriptors, myAttributes, baseClassAttributes );\n\n const ConstructorsMixin = constructorsMixin( allAttributes );\n\n return {\n ...ConstructorsMixin,\n _attributes : new ConstructorsMixin.AttributesCopy( allAttributes ),\n _attributesArray : Object.keys( allAttributes ).map( key => allAttributes[ key ] ),\n properties : _.transform( {}, myAttributes, x => x.createPropertyDescriptor() ),\n ...localEventsMixin( myAttributes ),\n _endpoints : _.transform( {}, allAttributes, attrDef => attrDef.options.endpoint )\n } \n}\n\n// Create attribute from the type spec.\nexport function createAttribute( spec : any, name : string ) : AnyType {\n return AnyType.create( ChainableAttributeSpec.from( spec ).options, name );\n}\n\nexport function createSharedTypeSpec( Constructor : Function, Attribute : typeof AnyType ){\n if( !Constructor.hasOwnProperty( 'shared' ) ){\n Object.defineProperty( Constructor, 'shared', {\n get(){\n return new ChainableAttributeSpec({\n value : null,\n type : Constructor,\n _attribute : Attribute\n });\n }\n });\n }\n}\n\ninterface LocalEventsMixin {\n _localEvents? : eventsApi.EventMap\n}\n\nfunction localEventsMixin( attrSpecs : AttributeDescriptors ) : LocalEventsMixin {\n let _localEvents : eventsApi.EventMap;\n\n for( var key in attrSpecs ){\n const attribute = attrSpecs[ key ],\n { _onChange } = attribute.options; \n\n if( _onChange ){\n _localEvents || ( _localEvents = new eventsApi.EventMap() );\n\n _localEvents.addEvent( 'change:' + key,\n typeof _onChange === 'string' ?\n createWatcherFromRef( _onChange, key ) : \n wrapWatcher( _onChange, key ) );\n }\n }\n\n return _localEvents ? { _localEvents } : {};\n}\n\nfunction wrapWatcher( watcher, key ){\n return function( record, value ){\n watcher.call( record, value, key );\n } \n}\n\nfunction createWatcherFromRef( ref : string, key : string ){\n const { local, resolve, tail } = new CompiledReference( ref, true );\n return local ?\n function( record, value ){\n record[ tail ]( value, key );\n } :\n function( record, value ){\n resolve( record )[ tail ]( value, key );\n }\n}","import { getOwnerEndpoint, startIO, IOOptions, IOEndpoint, IOPromise, IONode } from '../io-tools'\n\nexport interface IORecord extends IONode {\n getEndpoint() : IOEndpoint\n save( options? : IOOptions ) : IOPromise\n fetch( options? : IOOptions ) : IOPromise\n destroy( options? : IOOptions ) : IOPromise\n toJSON( options? : object ) : any\n isNew() : boolean\n id : string | number\n set( json : object, options : object )\n}\n\nexport const IORecordMixin = {\n save( this : IORecord, options : IOOptions = {} ){\n const endpoint = this.getEndpoint(),\n json = this.toJSON( options );\n\n return startIO(\n this,\n this.isNew() ?\n endpoint.create( json, options, this ) :\n endpoint.update( this.id, json, options, this ),\n options,\n\n update => {\n this.set( update, { parse : true, ...options } );\n }\n );\n },\n\n fetch( options : IOOptions = {} ){\n return startIO(\n this,\n this.getEndpoint().read( this.id, options, this ),\n options,\n\n json => this.set( json, { parse : true, ...options } )\n );\n },\n\n destroy( options : IOOptions = {} ){ \n return startIO(\n this,\n this.getEndpoint().destroy( this.id, options, this ),\n options,\n\n () => {\n const { collection } = this;\n if( collection ){\n collection.remove( this, options );\n }\n else{\n this.dispose();\n }\n\n return this;\n }\n )\n }\n}","/**\n * Record core implementing transactional updates.\n * The root of all definitions. \n */\n\nimport { tools, eventsApi, Mixable, definitions, mixins, mixinRules, define } from '../object-plus'\n\nimport { CloneOptions, Transactional, TransactionalDefinition, Transaction, TransactionOptions, Owner } from '../transactions'\nimport { ChildrenErrors } from '../validation'\n\nimport { Collection } from '../collection'\n\nimport { AnyType, AggregatedType, setAttribute, UpdateRecordMixin, \n AttributesValues, AttributesContainer,\n ConstructorsMixin, AttributesConstructor, AttributesCopyConstructor } from './attributes'\n\nimport { IORecord, IORecordMixin } from './io-mixin'\nimport { IOPromise, IOEndpoint } from '../io-tools'\n\nconst { assign, isEmpty, log } = tools;\n\n/*******************************************************\n * Record core implementation\n */\n\nexport interface ConstructorOptions extends TransactionOptions{\n clone? : boolean\n}\n\n// Client unique id counter\nlet _cidCounter : number = 0;\n\n/***************************************************************\n * Record Definition as accepted by Record.define( definition )\n */\nexport interface RecordDefinition extends TransactionalDefinition {\n idAttribute? : string\n attributes? : AttributesValues\n collection? : object\n Collection? : typeof Transactional\n}\n\n@define({\n // Default client id prefix \n cidPrefix : 'm',\n\n // Name of the change event\n _changeEventName : 'change',\n\n // Default id attribute name\n idAttribute : 'id'\n})\n@definitions({\n defaults : mixinRules.merge,\n attributes : mixinRules.merge,\n collection : mixinRules.merge,\n Collection : mixinRules.value,\n idAttribute : mixinRules.protoValue\n})\nexport class Record extends Transactional implements IORecord, AttributesContainer {\n // Hack\n static onDefine( definition, BaseClass ){}\n\n static Collection : typeof Collection;\n static DefaultCollection : typeof Collection;\n\n static from : ( collectionReference : any ) => any;\n \n static defaults( attrs : AttributesValues ) : typeof Record {\n return this.extend({ attributes : attrs });\n }\n \n static attributes : AttributesValues\n\n /********************\n * IO Methods\n */\n _endpoints : { [ name : string ] : IOEndpoint }\n\n // Save record\n save( options? : object ) : IOPromise { throw new Error( 'Implemented by mixin' ); }\n\n // Destroy record\n destroy( options? : object ) : IOPromise { throw new Error( 'Implemented by mixin' ); }\n\n /***********************************\n * Core Members\n */\n // Previous attributes\n _previousAttributes : {}\n\n previousAttributes(){ return new this.AttributesCopy( this._previousAttributes ); } \n\n // Current attributes \n attributes : AttributesValues\n\n // Polymorphic accessor for aggregated attribute's canBeUpdated().\n get __inner_state__(){ return this.attributes; }\n\n // Lazily evaluated changed attributes hash\n _changedAttributes : AttributesValues\n\n get changed(){\n let changed = this._changedAttributes;\n\n if( !changed ){\n const prev = this._previousAttributes;\n changed = {};\n\n const { _attributes, attributes } = this;\n\n for( let attr of this._attributesArray ){\n const key = attr.name,\n value = attributes[ key ];\n\n if( attr.isChanged( value, prev[ key ] ) ){\n changed[ key ] = value;\n }\n }\n\n this._changedAttributes = changed;\n }\n\n return changed; \n }\n\n changedAttributes( diff? : {} ) : boolean | {} {\n if( !diff ) return this.hasChanged() ? assign( {}, this.changed ) : false;\n\n var val, changed : {} | boolean = false,\n old = this._transaction ? this._previousAttributes : this.attributes,\n attrSpecs = this._attributes;\n\n for( var attr in diff ){\n if( !attrSpecs[ attr ].isChanged( old[ attr ], ( val = diff[ attr ] ) ) ) continue;\n (changed || (changed = {}))[ attr ] = val;\n }\n\n return changed; \n }\n\n hasChanged( key? : string ) : boolean {\n const { _previousAttributes } = this;\n if( !_previousAttributes ) return false;\n\n return key ?\n this._attributes[ key ].isChanged( this.attributes[ key ], _previousAttributes[ key ] ) :\n !isEmpty( this.changed );\n }\n\n previous( key : string ) : any {\n if( key ){\n const { _previousAttributes } = this;\n if( _previousAttributes ) return _previousAttributes[ key ];\n }\n \n return null;\n }\n\n isNew() : boolean {\n return this.id == null;\n }\n\n has( key : string ) : boolean {\n return this[ key ] != void 0;\n }\n\n // Return attribute value, setting an attribute to undefined.\n // TODO: If attribute was aggregated, don't dispose it.\n unset( key : string, options? ) : any {\n const value = this[ key ];\n this.set({ [ key ] : void 0 }, { unset : true, ...options });\n return value;\n }\n\n // Undocumented. Move to NestedTypes?\n clear( options? ) : this {\n const nullify = options && options.nullify;\n\n this.transaction( () =>{\n this.forEachAttr( this.attributes, ( value, key ) => this[ key ] = nullify ? null : void 0 );\n }, options );\n\n return this;\n }\n\n // Returns Record owner skipping collections. TODO: Move out\n getOwner() : Owner {\n const owner : any = this._owner;\n\n // If there are no key, owner must be transactional object, and it's the collection.\n // We don't expect that collection can be the member of collection, so we're skipping just one level up. An optimization.\n return this._ownerKey ? owner : owner && owner._owner;\n }\n\n /***********************************\n * Identity managements\n */\n\n // Id attribute name ('id' by default)\n idAttribute : string;\n\n // Fixed 'id' property pointing to id attribute\n get id() : string | number { return this.attributes[ this.idAttribute ]; }\n set id( x : string | number ){ setAttribute( this, this.idAttribute, x ); }\n\n /***********************************\n * Dynamically compiled stuff\n */\n\n // Attributes specifications \n _attributes : { [ key : string ] : AnyType }\n _attributesArray : AnyType[]\n\n // Attributes object copy constructor\n Attributes : AttributesConstructor\n AttributesCopy : AttributesCopyConstructor\n\n // forEach function for traversing through attributes, with protective default implementation\n // Overriden by dynamically compiled loop unrolled function in define.ts\n forEachAttr( attrs : {}, iteratee : ( value : any, key? : string, spec? : AnyType ) => void ) : void {\n const { _attributes } = this;\n let unknown : string[];\n\n for( let name in attrs ){\n const spec = _attributes[ name ];\n\n if( spec ){\n iteratee( attrs[ name ], name, spec );\n }\n else{\n unknown || ( unknown = [] );\n unknown.push( `'${ name }'` );\n }\n }\n\n if( unknown ){\n this._log( 'warn', `attributes ${ unknown.join(', ')} are not defined`,{\n attributes : attrs\n } );\n }\n }\n\n each( iteratee : ( value? : any, key? : string ) => void, context? : any ){\n const fun = context !== void 0 ? ( v, k ) => iteratee.call( context, v, k ) : iteratee,\n { attributes } = this;\n\n for( const key in this.attributes ){\n const value = attributes[ key ];\n if( value !== void 0 ) fun( value, key );\n }\n }\n\n // Get array of attribute keys (Record) or record ids (Collection) \n keys() : string[] {\n const keys : string[] = [];\n\n this.each( ( value, key ) => value === void 0 || keys.push( key ) );\n\n return keys;\n }\n\n // Get array of attribute values (Record) or records (Collection)\n values() : any[] {\n return this.map( value => value );\n }\n\n // Create record default values, optionally augmenting given values.\n defaults( values = {} ){\n const defaults = {},\n { _attributesArray } = this;\n\n for( let attr of _attributesArray ){\n const key = attr.name,\n value = values[ key ];\n\n defaults[ key ] = value === void 0 ? attr.defaultValue() : value;\n }\n\n return defaults;\n }\n\n /***************************************************\n * Record construction\n */\n // Create record, optionally setting an owner\n constructor( a_values? : {}, a_options? : ConstructorOptions ){\n super( _cidCounter++ );\n this.attributes = {};\n \n const options = a_options || {},\n values = ( options.parse ? this.parse( a_values, options ) : a_values ) || {};\n\n if( log.level > 1 ) typeCheck( this, values );\n\n this._previousAttributes = this.attributes = new this.Attributes( this, values, options );\n\n this.initialize( a_values, a_options );\n\n if( this._localEvents ) this._localEvents.subscribe( this, this );\n }\n\n // Initialization callback, to be overriden by the subclasses \n initialize( values?, options? ){}\n\n // Deeply clone record, optionally setting new owner.\n clone( options : CloneOptions = {} ) : this {\n const copy : this = new (this.constructor)( this.attributes, { clone : true } );\n \n if( options.pinStore ) copy._defaultStore = this.getStore();\n\n return copy;\n }\n\n // Deprecated, every clone is the deep one now.\n deepClone() : this { return this.clone() };\n\n // Validate attributes.\n _validateNested( errors : ChildrenErrors ) : number {\n var length = 0;\n\n this.forEachAttr( this.attributes, ( value, name, attribute ) => {\n const error = attribute.validate( this, value, name );\n\n if( error ){\n errors[ name ] = error;\n length++;\n }\n } );\n\n return length;\n }\n\n // Get attribute by key\n get( key : string ) : any {\n return this[ key ];\n }\n\n /**\n * Serialization control\n */\n\n // Default record-level serializer, to be overriden by subclasses \n toJSON( options? : object ) : any {\n const json = {};\n\n this.forEachAttr( this.attributes, ( value, key : string, { toJSON } ) =>{\n // If attribute serialization is not disabled, and its value is not undefined...\n if( value !== void 0 ){\n // ...serialize it according to its spec.\n const asJson = toJSON.call( this, value, key, options );\n\n // ...skipping undefined values. Such an attributes are excluded.\n if( asJson !== void 0 ) json[ key ] = asJson; \n }\n });\n\n return json;\n }\n \n // Default record-level parser, to be overriden by the subclasses.\n parse( data, options? : TransactionOptions ){\n return data;\n }\n\n // DEPRECATED: Attributes-level parse. Is moved to attribute descriptors.\n _parse( data ){ return data; }\n\n /**\n * Transactional control\n */\n\n deepSet( name : string, value : any, options? ){\n // Operation might involve series of nested object updates, thus it's wrapped in transaction.\n this.transaction( () => {\n const path = name.split( '.' ),\n l = path.length - 1,\n attr = path[ l ];\n\n let model = this;\n\n // Locate the model, traversing the path.\n for( let i = 0; i < l; i++ ){\n const key = path[ i ];\n\n // There might be collections in path, so use `get`.\n let next = model.get ? model.get( key ) : model[ key ];\n\n // Create models, if they are not exist.\n if( !next ){\n const attrSpecs = model._attributes;\n if( attrSpecs ){\n // If current object is model, create default attribute\n var newModel = attrSpecs[ key ].create();\n\n // If created object is model, nullify attributes when requested\n if( options && options.nullify && newModel._attributes ){\n newModel.clear( options );\n }\n\n model[ key ] = next = newModel;\n }\n // Silently fail in other case.\n else return;\n }\n \n model = next;\n }\n\n // Set model attribute.\n if( model.set ){\n model.set({ [ attr ] : value }, options );\n }\n else{\n model[ attr ] = value;\n }\n });\n\n return this;\n }\n \n // Returns owner without the key (usually it's collection)\n get collection() : any {\n return this._ownerKey ? null : this._owner;\n }\n\n // Dispose object and all childrens\n dispose(){\n if( this._disposed ) return;\n \n this.forEachAttr( this.attributes, ( value, key, attribute ) => {\n attribute.dispose( this, value );\n });\n\n super.dispose();\n }\n\n _log( level : tools.LogLevel, text : string, props : object ) : void {\n tools.log( level, '[Record] ' + text, {\n 'Record' : this,\n 'Attributes definition:' : this._attributes,\n ...props\n });\n }\n\n getClassName() : string {\n return super.getClassName() || 'Record';\n }\n\n // Dummies to \n _createTransaction( values : object, options : TransactionOptions ) : Transaction { return void 0; }\n // Simulate attribute change \n forceAttributeChange : ( key : string, options : TransactionOptions ) => void\n _onChildrenChange : ( child : Transactional, options : TransactionOptions ) => void\n};\n\nassign( Record.prototype, UpdateRecordMixin, IORecordMixin );\n\n/***********************************************\n * Helper functions\n */\n\nclass BaseRecordAttributes {\n id : string | number\n\n constructor( record : Record, x : AttributesValues, options : TransactionOptions ) {\n this.id = x.id;\n }\n}\n\nRecord.prototype.Attributes = BaseRecordAttributes;\n\nclass BaseRecordAttributesCopy {\n id : string | number\n\n constructor( x : AttributesValues ) {\n this.id = x.id;\n }\n}\n\nRecord.prototype.AttributesCopy = BaseRecordAttributesCopy;\n\nconst IdAttribute = AnyType.create({ value : void 0 }, 'id' );\nRecord.prototype._attributes = { id : IdAttribute };\nRecord.prototype._attributesArray = [ IdAttribute ];\nRecord._attribute = AggregatedType;\n\nimport { shouldBeAnObject } from './attributes'\n\nfunction typeCheck( record : Record, values : object ){\n if( shouldBeAnObject( record, values ) ){\n const { _attributes } = record;\n let unknown : string[];\n\n for( let name in values ){\n if( !_attributes[ name ] ){\n unknown || ( unknown = [] );\n unknown.push( `'${ name }'` );\n }\n }\n\n if( unknown ){\n record._log( 'warn', `undefined attributes ${ unknown.join(', ')} are ignored.`, { values } );\n }\n }\n}","import { Record, RecordDefinition } from './record'\nimport { Mixable, tools, predefine, define, MixinsState } from '../object-plus'\nimport compile, { ChainableAttributeSpec } from './attributes'\nimport { Transactional } from '../transactions'\n\nimport { createSharedTypeSpec, AggregatedType, MSDateType, TimestampType, NumericType, SharedType } from './attributes'\n\nexport * from './attributes'\nexport { Record }\n\nconst { assign, defaults, omit, getBaseClass } = tools;\n\nRecord.onExtend = function( this : typeof Record, BaseClass : typeof Record ){\n Transactional.onExtend.call( this, BaseClass );\n\n // Create the default collection\n const Class = this;\n\n @predefine class DefaultCollection extends BaseClass.Collection {\n static model = Class;\n }\n\n this.DefaultCollection = DefaultCollection;\n\n // If there are no collection defined in statics, use the default collection.\n // It will appear in onDefine's definition, overriding all other settings.\n if( Class.Collection === BaseClass.Collection ){\n this.Collection = DefaultCollection;\n }\n\n // Create Class.shared modifier\n createSharedTypeSpec( this, SharedType );\n}\n\nRecord.onDefine = function( definition : RecordDefinition, BaseClass : typeof Record ){\n const baseProto : Record = BaseClass.prototype;\n\n // Compile attributes spec, creating definition mixin.\n const { properties, _localEvents, ...dynamicMixin } = compile( this.attributes = getAttributes( definition ), baseProto._attributes );\n assign( this.prototype, dynamicMixin );\n \n definition.properties = defaults( definition.properties || {}, properties );\n definition._localEvents = _localEvents;\n \n Transactional.onDefine.call( this, definition, BaseClass );\n\n // Finalize the definition of the default collection.\n this.DefaultCollection.define( definition.collection || {} );\n\n // assign collection from the definition.\n this.Collection = definition.Collection;\n this.Collection.prototype.model = this;\n\n if( definition.endpoint ) this.Collection.prototype._endpoint = definition.endpoint; \n}\n\nRecord._attribute = AggregatedType;\ncreateSharedTypeSpec( Record, SharedType );\n\nfunction getAttributes({ defaults, attributes, idAttribute } : RecordDefinition ) {\n const definition = attributes || defaults || {};\n \n // If there is an undeclared idAttribute, add its definition as untyped generic attribute.\n if( idAttribute && !( idAttribute in definition ) ){\n definition[ idAttribute ] = void 0;\n }\n\n return definition;\n}\n\ndeclare var Reflect;\n\nexport function attr( proto : object, attrName : string ) : void;\nexport function attr( spec : any ) : PropertyDecorator;\nexport function attr( proto, attrName? : string ) : any {\n if( attrName ){\n // Called without the spec. Extract the type.\n if( typeof Reflect !== 'undefined' && Reflect.getMetadata ){\n Reflect\n .getMetadata( \"design:type\", proto, attrName )\n .asProp( proto, attrName );\n }\n else{\n proto._log( 'error', 'Add import \"reflect-metadata\"; as the first line of your app.' );\n }\n }\n else{\n return ChainableAttributeSpec.from( proto ).asProp;\n }\n}\n\nexport function prop( spec ) : any {\n return spec.asProp;\n}","import { Record } from '../record'\nimport { Owner, Transaction, ItemsBehavior,\n TransactionOptions, Transactional, transactionApi } from '../transactions'\n\nimport { eventsApi, tools } from '../object-plus'\n\nconst { EventMap, trigger2, trigger3, on, off } = eventsApi,\n { commit, markAsDirty } = transactionApi,\n _aquire = transactionApi.aquire, _free = transactionApi.free;\n\n/** @private */\nexport interface CollectionCore extends Transactional, Owner {\n _byId : IdIndex\n models : Record[]\n model : typeof Record\n idAttribute : string // TODO: Refactor inconsistent idAttribute usage\n _comparator : Comparator\n get( objOrId : string | Record | Object ) : Record \n _itemEvents? : eventsApi.EventMap\n _shared : number\n _aggregationError : Record[]\n\n _log( level : string, text : string, value : any ) : void\n}\n\n// Collection's manipulation methods elements\nexport type Elements = ( Object | Record )[];\n\nexport interface CollectionOptions extends TransactionOptions {\n sort? : boolean\n}\n\nexport type Comparator = ( a : Record, b : Record ) => number; \n\n/** @private */\nexport function dispose( collection : CollectionCore ) : Record[]{\n const { models } = collection;\n\n collection.models = [];\n collection._byId = {};\n\n freeAll( collection, models );\n return models;\n}\n\n/** @private */\nexport function convertAndAquire( collection : CollectionCore, attrs : {} | Record, options : CollectionOptions ){\n const { model } = collection;\n \n let record : Record;\n\n if( collection._shared ){\n record = attrs instanceof model ? attrs : model.create( attrs, options );\n\n if( collection._shared & ItemsBehavior.listen ){\n on( record, record._changeEventName, collection._onChildrenChange, collection );\n }\n }\n else{\n record = attrs instanceof model ? ( options.merge ? attrs.clone() : attrs ) : model.create( attrs, options );\n\n if( !_aquire( collection, record ) ){\n const errors = collection._aggregationError || ( collection._aggregationError = [] );\n errors.push( record );\n }\n } \n\n // Subscribe for events...\n const { _itemEvents } = collection;\n _itemEvents && _itemEvents.subscribe( collection, record );\n\n return record;\n}\n\n/** @private */\nexport function free( owner : CollectionCore, child : Record, unset? : boolean ) : void {\n if( owner._shared ){\n if( owner._shared & ItemsBehavior.listen ){\n off( child, child._changeEventName, owner._onChildrenChange, owner );\n }\n }\n else{\n _free( owner, child );\n unset || child.dispose();\n }\n\n const { _itemEvents } = owner;\n _itemEvents && _itemEvents.unsubscribe( owner, child );\n}\n\n/** @private */\nexport function freeAll( collection : CollectionCore, children : Record[] ) : Record[] {\n for( let child of children ){\n free( collection, child );\n }\n\n return children;\n}\n\n/**\n * Silently sort collection, if its required. Returns true if sort happened.\n * @private\n */ \nexport function sortElements( collection : CollectionCore, options : CollectionOptions ) : boolean {\n let { _comparator } = collection;\n if( _comparator && options.sort !== false ){\n collection.models.sort( _comparator );\n return true;\n }\n\n return false;\n}\n\n/**********************************\n * Collection Index\n * @private \n */\nexport interface IdIndex {\n [ id : string ] : Record\n}\n\n/** @private Add record */ \nexport function addIndex( index : IdIndex, model : Record ) : void {\n index[ model.cid ] = model;\n var id = model.id;\n \n if( id || id === 0 ){\n index[ id ] = model;\n }\n}\n\n/** @private Remove record */ \nexport function removeIndex( index : IdIndex, model : Record ) : void {\n delete index[ model.cid ];\n var id = model.id;\n if( id || id === 0 ){\n delete index[ id ];\n }\n}\n\nexport function updateIndex( index : IdIndex, model : Record ){\n delete index[ model.previous( model.idAttribute ) ];\n\n const { id } = model;\n id == null || ( index[ id ] = model );\n}\n\n/***\n * In Collections, transactions appears only when\n * add remove or change events might be emitted.\n * reset doesn't require transaction.\n * \n * Transaction holds information regarding events, and knows how to emit them.\n * \n * Two major optimization cases.\n * 1) Population of an empty collection\n * 2) Update of the collection (no or little changes) - it's crucial to reject empty transactions.\n */\n\n\n// Transaction class. Implements two-phase transactions on object's tree.\n/** @private */ \nexport class CollectionTransaction implements Transaction {\n // open transaction\n constructor( public object : CollectionCore,\n public isRoot : boolean,\n public added : Record[],\n public removed : Record[],\n public nested : Transaction[],\n public sorted : boolean ){}\n\n // commit transaction\n commit( initiator? : Transactional ){\n const { nested, object } = this,\n { _isDirty } = object;\n\n // Commit all nested transactions...\n for( let transaction of nested ){\n transaction.commit( object );\n }\n\n if( object._aggregationError ){\n logAggregationError( object );\n }\n\n // Just trigger 'change' on collection, it must be already triggered for models during nested commits.\n // ??? TODO: do it in nested transactions loop? This way appears to be more correct. \n for( let transaction of nested ){\n trigger2( object, 'change', transaction.object, _isDirty );\n }\n\n // Notify listeners on attribute changes...\n const { added, removed } = this;\n\n // Trigger `add` events for both model and collection.\n for( let record of added ){\n trigger3( record, 'add', record, object, _isDirty );\n trigger3( object, 'add', record, object, _isDirty );\n }\n\n // Trigger `remove` events for both model and collection.\n for( let record of removed ){\n trigger3( record, 'remove', record, object, _isDirty );\n trigger3( object, 'remove', record, object, _isDirty );\n }\n\n if( this.sorted ){\n trigger2( object, 'sort', object, _isDirty );\n }\n\n if( added.length || removed.length ){\n trigger2( object, 'update', object, _isDirty );\n }\n\n this.isRoot && commit( object, initiator );\n }\n}\n\nexport function logAggregationError( collection : CollectionCore ){\n collection._log( 'error', 'added records already have an owner', collection._aggregationError );\n collection._aggregationError = void 0;\n}","import { Transaction, transactionApi } from '../transactions'\nimport { CollectionTransaction, logAggregationError, sortElements, convertAndAquire, free, CollectionOptions, addIndex, updateIndex, CollectionCore } from './commons'\nimport { Record } from '../record'\n\nconst { begin, commit, markAsDirty } = transactionApi;\n\nexport interface AddOptions extends CollectionOptions {\n at? : number \n}\n\n/** @private */\nexport function addTransaction( collection : CollectionCore, items : any[], options : AddOptions, merge? : boolean ){\n const isRoot = begin( collection ),\n nested : Transaction[]= [];\n\n var added = appendElements( collection, items, nested, options, merge );\n\n if( added.length || nested.length ){\n let needSort = sortOrMoveElements( collection, added, options );\n if( markAsDirty( collection, options ) ){\n return new CollectionTransaction( collection, isRoot, added, [], nested, needSort );\n }\n\n if( collection._aggregationError ) logAggregationError( collection );\n }\n\n // No changes...\n isRoot && commit( collection );\n};\n\n// Handle sort or insert at options for add operation. Reurns true if sort happened.\n/** @private */ \nfunction sortOrMoveElements( collection : CollectionCore, added : Record[], options : AddOptions ) : boolean {\n let at = options.at;\n\n // if `at` option is given, it overrides sorting option...\n if( at != null ){\n // Take an original collection's length. \n const length = collection.models.length - added.length;\n\n // Crazy Backbone rules about `at` index. I don't know what that guys smoke.\n at = Number( at );\n if( at < 0 ) at += length + 1;\n if( at < 0 ) at = 0;\n if( at > length ) at = length;\n\n // Move added elements to desired position. In place.\n moveElements( collection.models, at, added );\n return false;\n }\n\n return sortElements( collection, options );\n}\n\n/** @private */\nfunction moveElements( source : any[], at : number, added : any[] ) : void {\n for( var j = source.length - 1, i = j - added.length; i >= at; i--, j-- ){\n source[ j ] = source[ i ];\n }\n\n for( i = 0, j = at; i < added.length; i++, j++ ){\n source[ j ] = added[ i ];\n }\n}\n\n// append data to model and index\n/** @private */\nfunction appendElements( collection : CollectionCore, a_items : any[], nested : Transaction[], a_options : AddOptions, forceMerge : boolean ){\n var { _byId, models } = collection,\n merge = ( forceMerge || a_options.merge ) && !collection._shared,\n parse = a_options.parse,\n idAttribute = collection.model.prototype.idAttribute,\n prevLength = models.length;\n\n for( const item of a_items ){\n let model = item ? _byId[ item[ idAttribute ] ] || _byId[ item.cid ] : null;\n\n if( model ){\n if( merge && item !== model ){\n var attrs = item.attributes || item;\n const transaction = model._createTransaction( attrs, a_options );\n transaction && nested.push( transaction );\n\n if( model.hasChanged( idAttribute ) ){\n updateIndex( _byId, model );\n }\n }\n }\n else{\n model = convertAndAquire( collection, item, a_options );\n models.push( model );\n addIndex( _byId, model );\n }\n }\n\n return models.slice( prevLength );\n}\n","import { Transaction, transactionApi } from '../transactions'\nimport { CollectionTransaction, logAggregationError, IdIndex, convertAndAquire, free, sortElements, CollectionOptions, addIndex, CollectionCore, Elements, freeAll } from './commons'\nimport { Record } from '../record'\n\nconst { begin, commit, markAsDirty } = transactionApi;\n\n/** @private */\nconst silentOptions = { silent : true };\n\n/** @private */\nexport function emptySetTransaction( collection : CollectionCore, items : Elements, options : CollectionOptions, silent? : boolean ){\n const isRoot = begin( collection );\n\n const added = _reallocateEmpty( collection, items, options );\n\n if( added.length ){\n const needSort = sortElements( collection, options );\n\n if( markAsDirty( collection, silent ? silentOptions : options ) ){\n // 'added' is the reference to this.models. Need to copy it.\n return new CollectionTransaction( collection, isRoot, added.slice(), [], [], needSort );\n }\n\n if( collection._aggregationError ) logAggregationError( collection );\n }\n\n // No changes...\n isRoot && commit( collection );\n};\n\n/** @private */\nexport function setTransaction( collection, items, options ){\n const isRoot = begin( collection ),\n nested = [];\n\n var previous = collection.models,\n added = _reallocate( collection, items, nested, options );\n\n const reusedCount = collection.models.length - added.length,\n removed = reusedCount < previous.length ? (\n reusedCount ? _garbageCollect( collection, previous ) :\n freeAll( collection, previous )\n ) : []; \n \n const addedOrChanged = nested.length || added.length,\n // As we are reallocating models array, it needs to be sorted even if there are no changes.\n sorted = ( sortElements( collection, options ) && addedOrChanged ) || added.length || options.sorted;\n\n if( addedOrChanged || removed.length || sorted ){\n if( markAsDirty( collection, options ) ){ \n return new CollectionTransaction( collection, isRoot, added, removed, nested, sorted );\n }\n\n if( collection._aggregationError ) logAggregationError( collection );\n }\n\n isRoot && commit( collection );\n};\n\n// Remove references to all previous elements, which are not present in collection.\n// Returns an array with removed elements.\n/** @private */\nfunction _garbageCollect( collection : CollectionCore, previous : Record[] ) : Record[]{\n const { _byId } = collection,\n removed = [];\n\n // Filter out removed models and remove them from the index...\n for( let record of previous ){\n if( !_byId[ record.cid ] ){\n removed.push( record );\n free( collection, record );\n }\n }\n\n return removed;\n}\n\n// reallocate model and index\n/** @private */\nfunction _reallocate( collection : CollectionCore, source : any[], nested : Transaction[], options ){\n var models = Array( source.length ),\n _byId : IdIndex = {},\n merge = ( options.merge == null ? true : options.merge ) && !collection._shared,\n _prevById = collection._byId,\n prevModels = collection.models, \n idAttribute = collection.model.prototype.idAttribute,\n toAdd = [],\n orderKept = true;\n\n // for each item in source set...\n for( var i = 0, j = 0; i < source.length; i++ ){\n var item = source[ i ],\n model : Record = null;\n\n if( item ){\n var id = item[ idAttribute ],\n cid = item.cid;\n\n if( _byId[ id ] || _byId[ cid ] ) continue;\n\n model = _prevById[ id ] || _prevById[ cid ];\n }\n\n if( model ){\n if( merge && item !== model ){\n if( orderKept && prevModels[ j ] !== model ) orderKept = false;\n\n var attrs = item.attributes || item;\n const transaction = model._createTransaction( attrs, options );\n transaction && nested.push( transaction );\n }\n }\n else{\n model = convertAndAquire( collection, item, options );\n toAdd.push( model );\n }\n\n models[ j++ ] = model;\n addIndex( _byId, model );\n }\n\n models.length = j;\n collection.models = models;\n collection._byId = _byId;\n\n if( !orderKept ) options.sorted = true;\n\n return toAdd;\n}\n\n/** @private */\nfunction _reallocateEmpty( self, source, options ){\n var len = source ? source.length : 0,\n models = Array( len ),\n _byId : IdIndex = {},\n idAttribute = self.model.prototype.idAttribute;\n\n for( var i = 0, j = 0; i < len; i++ ){\n var src = source[ i ];\n\n if( src && ( _byId[ src[ idAttribute ] ] || _byId[ src.cid ] ) ){\n continue;\n }\n\n var model = convertAndAquire( self, src, options );\n models[ j++ ] = model;\n addIndex( _byId, model );\n }\n\n models.length = j;\n self._byId = _byId;\n\n return self.models = models;\n}","/*************\n * Remove items from collections.\n * \n * Cannot be a part of two-phase transaction on object tree.\n * Can be executed in the scope of ad-hoc transaction or from the trigger, though.\n *\n * Implemented with low-level API. \n * Most frequent operation - single element remove. Thus, it have the fast-path.\n */\n\nimport { Record } from '../record'\nimport { free, CollectionCore, CollectionTransaction, removeIndex } from './commons'\nimport { eventsApi } from '../object-plus'\nimport { TransactionOptions, transactionApi } from '../transactions' \n\nconst { trigger2, trigger3 } = eventsApi,\n { markAsDirty, begin, commit } = transactionApi;\n\n/** @private */\nexport function removeOne( collection : CollectionCore, el : Record | {} | string, options : TransactionOptions ) : Record {\n var model : Record = collection.get( el );\n\n if( model ){\n const isRoot = begin( collection ),\n models = collection.models;\n\n // Remove model form the collection. \n models.splice( models.indexOf( model ), 1 );\n removeIndex( collection._byId, model );\n \n // Mark transaction as dirty. \n const notify = markAsDirty( collection, options );\n\n // Send out events.\n if( notify ){\n trigger3( model, 'remove', model, collection, options );\n trigger3( collection, 'remove', model, collection, options );\n } \n\n free( collection, model, options.unset );\n\n notify && trigger2( collection, 'update', collection, options );\n\n // Commit transaction.\n isRoot && commit( collection );\n\n return model;\n }\n};\n\n/** Optimized for removing many elements\n * 1. Remove elements from the index, checking for duplicates\n * 2. Create new models array matching index\n * 3. Send notifications and remove references\n */\n\n/** @private */\nexport function removeMany( collection : CollectionCore, toRemove : any[], options ){\n const removed = _removeFromIndex( collection, toRemove, options.unset );\n if( removed.length ){\n const isRoot = begin( collection );\n\n _reallocate( collection, removed.length );\n\n if( markAsDirty( collection, options ) ){\n const transaction = new CollectionTransaction( collection, isRoot, [], removed, [], false );\n transaction.commit();\n }\n else{\n // Commit transaction.\n isRoot && commit( collection );\n }\n }\n\n return removed;\n};\n\n// remove models from the index...\n/** @private */\nfunction _removeFromIndex( collection, toRemove, unset : boolean ){\n var removed = Array( toRemove.length ),\n _byId = collection._byId;\n\n for( var i = 0, j = 0; i < toRemove.length; i++ ){\n var model = collection.get( toRemove[ i ] );\n if( model ){\n removed[ j++ ] = model;\n removeIndex( _byId, model );\n free( collection, model, unset );\n }\n }\n\n removed.length = j;\n\n return removed;\n}\n\n// Allocate new models array removing models not present in the index.\n/** @private */\nfunction _reallocate( collection, removed ){\n var prev = collection.models,\n models = collection.models = Array( prev.length - removed ),\n _byId = collection._byId;\n\n for( var i = 0, j = 0; i < prev.length; i++ ){\n var model = prev[ i ];\n\n if( _byId[ model.cid ] ){\n models[ j++ ] = model;\n }\n }\n\n models.length = j;\n}","import { define, tools, eventsApi, EventMap, definitions, mixinRules, EventsDefinition, Mixable } from '../object-plus'\nimport { ItemsBehavior, transactionApi, Transactional, CloneOptions, Transaction, TransactionOptions, TransactionalDefinition, Owner } from '../transactions'\nimport { Record, SharedType, AggregatedType, createSharedTypeSpec } from '../record'\n\nimport { IdIndex, free, sortElements, dispose, Elements, CollectionCore, addIndex, removeIndex, updateIndex, Comparator, CollectionTransaction } from './commons'\nimport { addTransaction, AddOptions } from './add'\nimport { setTransaction, emptySetTransaction } from './set'\nimport { removeOne, removeMany } from './remove'\nimport { IOPromise, startIO } from '../io-tools'\n\nconst { trigger2, on, off } = eventsApi,\n { begin, commit, markAsDirty } = transactionApi,\n { omit, log, assign, defaults, assignToClassProto } = tools;\n\nlet _count = 0;\n\nexport type GenericComparator = string | ( ( x : Record ) => number ) | ( ( a : Record, b : Record ) => number ); \n\nexport interface CollectionOptions extends TransactionOptions {\n comparator? : GenericComparator\n model? : typeof Record\n}\n\nexport type Predicate = ( val : R, key : number ) => boolean | object;\n\nexport interface CollectionDefinition extends TransactionalDefinition {\n model? : typeof Record,\n itemEvents? : EventsDefinition\n _itemEvents? : EventMap\n}\n\nconst slice = Array.prototype.slice;\n\nclass CollectionRefsType extends SharedType {\n static defaultValue = [];\n}\n\n@define({\n // Default client id prefix \n cidPrefix : 'c',\n model : Record,\n _changeEventName : 'changes',\n _aggregationError : null\n})\n@definitions({\n comparator : mixinRules.value,\n model : mixinRules.protoValue,\n itemEvents : mixinRules.merge\n})\nexport class Collection< R extends Record = Record> extends Transactional implements CollectionCore {\n _shared : number\n _aggregationError : R[]\n\n static Subset : typeof Collection\n static Refs : typeof Collection\n static _SubsetOf : typeof Collection\n \n createSubset( models : ElementsArg, options ){\n const SubsetOf = (this.constructor).subsetOf( this ).options.type,\n subset = new SubsetOf( models, options );\n \n subset.resolve( this );\n return subset;\n }\n\n static onExtend( BaseClass : typeof Transactional ){\n // Cached subset collection must not be inherited.\n const Ctor = this;\n this._SubsetOf = null;\n\n function RefsCollection( a, b, listen? ){\n Ctor.call( this, a, b, ItemsBehavior.share | ( listen ? ItemsBehavior.listen : 0 ) );\n }\n\n Mixable.mixins.populate( RefsCollection );\n \n RefsCollection.prototype = this.prototype;\n RefsCollection._attribute = CollectionRefsType;\n\n this.Refs = this.Subset = RefsCollection;\n\n Transactional.onExtend.call( this, BaseClass );\n createSharedTypeSpec( this, SharedType );\n }\n \n static onDefine( definition : CollectionDefinition, BaseClass : any ){\n if( definition.itemEvents ){\n const eventsMap = new EventMap( BaseClass.prototype._itemEvents );\n eventsMap.addEventsMap( definition.itemEvents );\n this.prototype._itemEvents = eventsMap;\n }\n\n if( definition.comparator !== void 0 ) this.prototype.comparator = definition.comparator;\n\n Transactional.onDefine.call( this, definition );\n }\n\n static subsetOf : ( collectionReference : any ) => any;\n \n _itemEvents : EventMap\n\n /***********************************\n * Core Members\n */\n // Array of the records\n models : R[]\n\n // Polymorphic accessor for aggregated attribute's canBeUpdated().\n get __inner_state__(){ return this.models; }\n\n // Index by id and cid\n _byId : { [ id : string ] : R }\n\n set comparator( x : GenericComparator ){\n let compare;\n\n switch( typeof x ){\n case 'string' :\n this._comparator = ( a, b ) => {\n const aa = a[ x ], bb = b[ x ];\n if( aa === bb ) return 0;\n return aa < bb ? -1 : + 1;\n } \n break;\n case 'function' :\n if( x.length === 1 ){\n this._comparator = ( a, b ) => {\n const aa = (x).call( this, a ), bb = (x).call( this, b );\n if( aa === bb ) return 0;\n return aa < bb ? -1 : + 1;\n }\n }\n else{\n this._comparator = ( a, b ) => (x).call( this, a, b );\n }\n break;\n \n default :\n this._comparator = null;\n }\n }\n \n // TODO: Improve typing\n getStore() : Transactional {\n return this._store || ( this._store = this._owner ? this._owner.getStore() : this._defaultStore );\n }\n\n _store : Transactional\n\n get comparator(){ return this._comparator; }\n _comparator : ( a : R, b : R ) => number\n\n _onChildrenChange( record : R, options : TransactionOptions = {}, initiator? : Transactional ){\n // Ignore updates from nested transactions.\n if( initiator === this ) return;\n\n const { idAttribute } = this;\n\n if( record.hasChanged( idAttribute ) ){\n updateIndex( this._byId, record );\n }\n\n const isRoot = begin( this );\n\n if( markAsDirty( this, options ) ){\n // Forward change event from the record.\n trigger2( this, 'change', record, options )\n }\n\n isRoot && commit( this );\n }\n\n get( objOrId : string | R | Object ) : R {\n if( objOrId == null ) return;\n\n if( typeof objOrId === 'object' ){\n const id = objOrId[ this.idAttribute ];\n return ( id !== void 0 && this._byId[ id ] ) || this._byId[ (objOrId).cid ];\n }\n else{\n return this._byId[ objOrId ];\n } \n }\n\n each( iteratee : ( val : R, key : number ) => void, context? : any ){\n const fun = bindContext( iteratee, context ),\n { models } = this;\n\n for( let i = 0; i < models.length; i++ ){\n fun( models[ i ], i ); \n }\n }\n\n forEach( iteratee : ( val : R, key? : number ) => void, context? : any ){\n return this.each( iteratee, context );\n }\n\n every( iteratee : Predicate, context? : any ) : boolean {\n const fun = toPredicateFunction( iteratee, context ),\n { models } = this;\n\n for( let i = 0; i < models.length; i++ ){\n if( !fun( models[ i ], i ) ) return false;\n }\n\n return true;\n }\n\n filter( iteratee : Predicate, context? : any ) : R[] {\n const fun = toPredicateFunction( iteratee, context ),\n { models } = this;\n\n return this.map( ( x, i ) => fun( x, i ) ? x : void 0 );\n }\n\n find( iteratee : Predicate, context? : any ) : R {\n const fun = toPredicateFunction( iteratee, context ),\n { models } = this;\n\n for( let i = 0; i < models.length; i++ ){\n if( fun( models[ i ], i ) ) return models[ i ];\n }\n\n return null;\n }\n\n some( iteratee : Predicate, context? : any ) : boolean {\n return Boolean( this.find( iteratee, context ) );\n }\n\n map< T >( iteratee : ( val : R, key : number ) => T, context? : any ) : T[]{\n const fun = bindContext( iteratee, context ),\n { models } = this,\n mapped = Array( models.length );\n\n let j = 0;\n\n for( let i = 0; i < models.length; i++ ){\n const x = fun( models[ i ], i );\n x === void 0 || ( mapped[ j++ ] = x ); \n }\n\n mapped.length = j;\n\n return mapped;\n }\n\n _validateNested( errors : {} ) : number {\n // Don't validate if not aggregated.\n if( this._shared ) return 0;\n\n let count = 0;\n\n this.each( record => {\n const error = record.validationError;\n if( error ){\n errors[ record.cid ] = error;\n count++;\n }\n });\n\n return count;\n }\n\n model : typeof Record\n\n // idAttribute extracted from the model type.\n idAttribute : string\n\n constructor( records? : ( R | {} )[], options : CollectionOptions = {}, shared? : number ){\n super( _count++ );\n this.models = [];\n this._byId = {};\n \n this.comparator = this.comparator;\n\n if( options.comparator !== void 0 ){\n this.comparator = options.comparator;\n options.comparator = void 0;\n }\n \n this.model = this.model;\n \n if( options.model ){\n this.model = options.model;\n options.model = void 0;\n }\n\n this.idAttribute = this.model.prototype.idAttribute; //TODO: Remove?\n\n this._shared = shared || 0;\n\n if( records ){\n const elements = toElements( this, records, options );\n emptySetTransaction( this, elements, options, true );\n }\n\n this.initialize.apply( this, arguments );\n\n if( this._localEvents ) this._localEvents.subscribe( this, this );\n }\n\n initialize(){}\n\n get length() : number { return this.models.length; }\n first() : R { return this.models[ 0 ]; }\n last() : R { return this.models[ this.models.length - 1 ]; }\n at( a_index : number ) : R {\n const index = a_index < 0 ? a_index + this.models.length : a_index; \n return this.models[ index ];\n }\n\n // Deeply clone collection, optionally setting new owner.\n clone( options : CloneOptions = {} ) : this {\n const models = this._shared & ItemsBehavior.share ? this.models : this.map( model => model.clone() ),\n copy : this = new (this.constructor)( models, { model : this.model, comparator : this.comparator }, this._shared );\n \n if( options.pinStore ) copy._defaultStore = this.getStore();\n \n return copy;\n }\n\n toJSON( options? : object ) : any {\n return this.models.map( model => model.toJSON( options ) );\n }\n\n // Apply bulk in-place object update in scope of ad-hoc transaction \n set( elements : ElementsArg = [], options : TransactionOptions = {} ) : this {\n if( (options).add !== void 0 ){\n this._log( 'warn', \"Collection.set doesn't support 'add' option, behaving as if options.add === true.\", options );\n }\n\n // Handle reset option here - no way it will be populated from the top as nested transaction.\n if( options.reset ){\n this.reset( elements, options )\n }\n else{\n const transaction = this._createTransaction( elements, options );\n transaction && transaction.commit();\n } \n\n return this; \n }\n\n /**\n * Enable or disable live updates.\n * \n * `true` enables full collection synchronization.\n * `false` cancel live updates.\n * `json => true | false` - filter updates\n */\n liveUpdates( enabled : LiveUpdatesOption ) : IOPromise {\n if( enabled ){\n this.liveUpdates( false );\n\n const filter = typeof enabled === 'function' ? enabled : () => true;\n\n this._liveUpdates = {\n updated : json => {\n filter( json ) && this.add( json, { parse : true, merge : true } );\n },\n\n removed : id => this.remove( id )\n };\n\n return this.getEndpoint().subscribe( this._liveUpdates, this ).then( () => this );\n }\n else{\n if( this._liveUpdates ){\n this.getEndpoint().unsubscribe( this._liveUpdates, this );\n this._liveUpdates = null;\n }\n }\n }\n\n _liveUpdates : object\n\n fetch( a_options : { liveUpdates? : LiveUpdatesOption } & TransactionOptions = {} ) : IOPromise {\n const options = { parse : true, ...a_options },\n endpoint = this.getEndpoint();\n\n return startIO(\n this,\n endpoint.list( options, this ),\n options,\n\n json => {\n let result : any = this.set( json, { parse : true, ...options } as TransactionOptions );\n \n if( options.liveUpdates ){\n result = this.liveUpdates( options.liveUpdates );\n }\n\n return result;\n }\n );\n }\n\n dispose() : void {\n if( this._disposed ) return;\n\n const aggregated = !this._shared;\n\n for( let record of this.models ){\n free( this, record );\n\n if( aggregated ) record.dispose();\n }\n\n this.liveUpdates( false );\n\n super.dispose();\n }\n\n reset( a_elements? : ElementsArg, options : TransactionOptions = {} ) : R[] {\n const isRoot = begin( this ),\n previousModels = this.models;\n\n // Make all changes required, but be silent.\n if( a_elements ){ \n emptySetTransaction( this, toElements( this, a_elements, options ), options, true );\n }\n else{\n this._byId = {};\n this.models = [];\n }\n\n markAsDirty( this, options );\n\n options.silent || trigger2( this, 'reset', this, defaults( { previousModels : previousModels }, options ) );\n\n // Dispose models which are not in the updated collection.\n const { _byId } = this;\n \n for( let toDispose of previousModels ){\n _byId[ toDispose.cid ] || free( this, toDispose );\n }\n\n isRoot && commit( this );\n return this.models;\n }\n\n // Add elements to collection.\n add( a_elements : ElementsArg , options : AddOptions = {} ){\n const elements = toElements( this, a_elements, options ),\n transaction = this.models.length ?\n addTransaction( this, elements, options ) :\n emptySetTransaction( this, elements, options );\n\n if( transaction ){\n transaction.commit();\n return transaction.added;\n }\n }\n\n // Remove elements. \n remove( recordsOrIds : any, options : CollectionOptions = {} ) : R[] | R {\n if( recordsOrIds ){\n return Array.isArray( recordsOrIds ) ?\n removeMany( this, recordsOrIds, options ) as R[]:\n removeOne( this, recordsOrIds, options ) as R;\n }\n\n return [];\n }\n\n // Apply bulk object update without any notifications, and return open transaction.\n // Used internally to implement two-phase commit. \n _createTransaction( a_elements : ElementsArg, options : TransactionOptions = {} ) : CollectionTransaction | void {\n const elements = toElements( this, a_elements, options );\n\n if( this.models.length ){\n return options.remove === false ?\n addTransaction( this, elements, options, true ) :\n setTransaction( this, elements, options );\n }\n else{\n return emptySetTransaction( this, elements, options );\n }\n }\n\n static _attribute = AggregatedType;\n\n /***********************************\n * Collection manipulation methods\n */\n\n pluck( key : keyof R ) : any[] {\n return this.models.map( model => model[ key ] );\n }\n\n sort( options : TransactionOptions = {} ) : this {\n if( sortElements( this, options ) ){\n const isRoot = begin( this );\n \n if( markAsDirty( this, options ) ){\n trigger2( this, 'sort', this, options );\n }\n\n isRoot && commit( this );\n }\n\n return this;\n }\n\n // Add a model to the end of the collection.\n push(model : ElementsArg, options : CollectionOptions ) {\n return this.add(model, assign({at: this.length}, options));\n }\n\n // Remove a model from the end of the collection.\n pop( options : CollectionOptions ) : R {\n var model = this.at(this.length - 1);\n this.remove(model, { unset : true, ...options });\n return model;\n }\n\n // Remove and return given model.\n // TODO: do not dispose the model for aggregated collection.\n unset( modelOrId : R | string, options? ) : R {\n const value = this.get( modelOrId );\n this.remove( modelOrId, { unset : true, ...options } );\n return value;\n }\n\n // Add a model to the beginning of the collection.\n unshift(model : ElementsArg, options : CollectionOptions ) {\n return this.add(model, assign({at: 0}, options));\n }\n\n // Remove a model from the beginning of the collection.\n shift( options? : CollectionOptions ) : R {\n var model = this.at(0);\n this.remove( model, { unset : true, ...options } );\n return model;\n }\n\n // Slice out a sub-array of models from the collection.\n slice() : R[] {\n return slice.apply(this.models, arguments);\n }\n\n indexOf( modelOrId : any ) : number {\n const record = this.get( modelOrId );\n return this.models.indexOf( record );\n }\n\n modelId( attrs : {} ) : any {\n return attrs[ this.model.prototype.idAttribute ];\n }\n\n // Toggle model in collection.\n toggle( model : R, a_next? : boolean ) : boolean {\n var prev = Boolean( this.get( model ) ),\n next = a_next === void 0 ? !prev : Boolean( a_next );\n\n if( prev !== next ){\n if( prev ){\n this.remove( model );\n }\n else{\n this.add( model );\n }\n }\n\n return next;\n }\n\n _log( level : tools.LogLevel, text : string, value ) : void {\n tools.log( level, `[Collection Update] ${ this.model.prototype.getClassName() }.${ this.getClassName() }: ` + text, {\n Argument : value,\n 'Attributes spec' : this.model.prototype._attributes\n });\n }\n\n getClassName() : string {\n return super.getClassName() || 'Collection';\n }\n}\n\nexport type LiveUpdatesOption = boolean | ( ( x : any ) => boolean );\n\nexport type ElementsArg = Object | Record | Object[] | Record[];\n\n// TODO: make is safe for parse to return null (?)\nfunction toElements( collection : Collection, elements : ElementsArg, options : CollectionOptions ) : Elements {\n const parsed = options.parse ? collection.parse( elements, options ) : elements; \n return Array.isArray( parsed ) ? parsed : [ parsed ];\n}\n\ncreateSharedTypeSpec( Collection, SharedType );\n\nRecord.Collection = Collection;\n\nfunction bindContext( fun : Function, context? : any ){\n return context !== void 0 ? ( v, k ) => fun.call( context, v, k ) : fun;\n}\n\nfunction toPredicateFunction( iteratee : Predicate, context : any ){\n if( typeof iteratee === 'object' ){\n // Wrap object to the predicate...\n return x => {\n for( let key in iteratee as any ){\n if( iteratee[ key ] !== x[ key ] )\n return false;\n }\n\n return true;\n }\n }\n \n return bindContext( iteratee, context );\n\n}","import { Collection } from '../collection'\nimport { Record } from '../record'\nimport { CompiledReference } from '../traversable'\n\nexport type CollectionReference = ( () => Collection ) | Collection | string; \n\n/** @private */\nexport function parseReference( collectionRef : CollectionReference ) : ( root : Record ) => Collection {\n switch( typeof collectionRef ){\n case 'function' :\n return root => (collectionRef).call( root );\n case 'object' :\n return () => collectionRef;\n case 'string' :\n const { resolve } = new CompiledReference( collectionRef );\n return resolve;\n }\n}","import { AnyType, AttributeOptions } from '../record'\nimport { parseReference, CollectionReference } from './commons'\nimport { Collection } from '../collection'\nimport { Record } from '../record'\n\nimport { ChainableAttributeSpec } from '../record'\n\n/********\n * Reference to model by id.\n * \n * Untyped attribute. Holds model id, when unresolved. When resolved, is substituted\n * with a real model.\n * \n * No model changes are detected and counted as owner's change. That's intentional.\n */\n\n/** @private */\ntype RecordRefValue = Record | string;\n\n/** @private */\nclass RecordRefType extends AnyType {\n // It is always serialized as an id, whenever it's resolved or not. \n toJSON( value : RecordRefValue ){\n return value && typeof value === 'object' ? value.id : value;\n }\n\n // Wne \n clone( value : RecordRefValue ){\n return value && typeof value === 'object' ? value.id : value;\n }\n\n // Model refs by id are equal when their ids are equal.\n isChanged( a : RecordRefValue, b : RecordRefValue){\n var aId = a && ( (a).id == null ? a : (a).id ),\n bId = b && ( (b).id == null ? b : (b).id );\n\n return aId !== bId;\n }\n\n // Refs are always valid.\n validate( model, value, name ){}\n}\n\nRecord.from = function from( masterCollection : CollectionReference ) : ChainableAttributeSpec {\n const getMasterCollection = parseReference( masterCollection );\n\n const typeSpec = new ChainableAttributeSpec({\n value : null,\n _attribute : RecordRefType\n });\n \n return typeSpec\n .get( function( objOrId : RecordRefValue, name : string ) : Record {\n if( typeof objOrId === 'object' ) return objOrId;\n\n // So, we're dealing with an id reference. Resolve it.\n const collection = getMasterCollection( this );\n let record : Record = null;\n\n // If master collection exists and is not empty...\n if( collection && collection.length ){\n // Silently update attribute with record from this collection.\n record = collection.get( objOrId ) || null;\n this.attributes[ name ] = record;\n\n // Subscribe for events manually. delegateEvents won't be invoked.\n record && this._attributes[ name ].handleChange( record, null, this, {} );\n }\n\n return record;\n });\n};","import { Collection, CollectionOptions } from '../collection'\nimport { tools, eventsApi, define } from '../object-plus'\nimport { Record, AggregatedType } from '../record'\nimport { parseReference, CollectionReference } from './commons'\nimport { ChainableAttributeSpec } from '../record'\nimport { Transactional, ItemsBehavior, TransactionOptions, transactionApi } from '../transactions'\n\nconst { fastDefaults } = tools;\n\ntype RecordsIds = ( string | number )[];\n\nCollection.subsetOf = function subsetOf( masterCollection : CollectionReference ) : ChainableAttributeSpec {\n const SubsetOf = this._SubsetOf || ( this._SubsetOf = defineSubsetCollection( this ) ),\n getMasterCollection = parseReference( masterCollection ),\n typeSpec = new ChainableAttributeSpec({\n type : SubsetOf\n });\n\n return typeSpec.get(\n function( refs ){\n !refs || refs.resolvedWith || refs.resolve( getMasterCollection( this ) );\n return refs;\n }\n );\n};\n\nconst subsetOfBehavior = ItemsBehavior.share | ItemsBehavior.persistent;\n\nfunction defineSubsetCollection( CollectionConstructor : typeof Collection ) {\n @define class SubsetOfCollection extends CollectionConstructor {\n refs : any[];\n resolvedWith : Collection = null;\n\n _attribute : AggregatedType\n\n get __inner_state__(){ return this.refs || this.models; }\n\n constructor( recordsOrIds?, options? ){\n super( [], options, subsetOfBehavior );\n this.refs = toArray( recordsOrIds );\n }\n\n // Remove should work fine as it already accepts ids. Add won't...\n add( a_elements, options = {} ){\n const { resolvedWith } = this,\n toAdd = toArray( a_elements );\n \n if( resolvedWith ){\n // If the collection is resolved already, everything is simple.\n return super.add( resolveRefs( resolvedWith, toAdd ), options );\n }\n else{\n // Collection is not resolved yet. So, we prepare the delayed computation.\n if( toAdd.length ){\n const isRoot = transactionApi.begin( this );\n\n // Save elements to resolve in future...\n this.refs = this.refs ? this.refs.concat( toAdd ) : toAdd.slice();\n\n transactionApi.markAsDirty( this, options );\n\n // And throw the 'changes' event.\n isRoot && transactionApi.commit( this );\n }\n }\n }\n\n reset( a_elements?, options = {} ){\n const { resolvedWith } = this,\n elements = toArray( a_elements );\n \n return resolvedWith ?\n // Collection is resolved, so parse ids and forward the call to set.\n super.reset( resolveRefs( resolvedWith, elements ), options ) :\n // Collection is not resolved yet. So, we prepare the delayed computation.\n delaySet( this, elements, options ) || [];\n }\n\n _createTransaction( a_elements, options? ){\n const { resolvedWith } = this,\n elements = toArray( a_elements );\n \n return resolvedWith ?\n // Collection is resolved, so parse ids and forward the call to set.\n super._createTransaction( resolveRefs( resolvedWith, elements ), options ) :\n // Collection is not resolved yet. So, we prepare the delayed computation.\n delaySet( this, elements, options );\n }\n\n // Serialized as an array of model ids.\n toJSON() : RecordsIds {\n return this.refs ?\n this.refs.map( objOrId => objOrId.id || objOrId ) :\n this.models.map( model => model.id );\n }\n\n // Subset is always valid.\n _validateNested(){ return 0; }\n\n get length() : number {\n return this.models.length || ( this.refs ? this.refs.length : 0 );\n }\n\n // Must be shallow copied on clone.\n clone( owner? ){\n var Ctor = (this).constructor,\n copy = new Ctor( [], {\n model : this.model,\n comparator : this.comparator\n });\n\n if( this.resolvedWith ){\n // TODO: bug here. \n copy.resolvedWith = this.resolvedWith;\n copy.refs = null;\n copy.reset( this.models, { silent : true } );\n }\n else{\n copy.refs = this.refs.slice();\n }\n\n return copy;\n }\n\n // Clean up the custom parse method possibly defined in the base class.\n parse( raw : any ) : Record[] {\n return raw;\n }\n\n resolve( collection : Collection ) : this {\n if( collection && collection.length ){\n this.resolvedWith = collection;\n\n if( this.refs ){\n this.reset( this.refs, { silent : true } );\n this.refs = null;\n }\n }\n\n return this;\n }\n\n getModelIds() : RecordsIds { return this.toJSON(); }\n\n toggle( modelOrId : any, val : boolean ) : boolean {\n return super.toggle( this.resolvedWith.get( modelOrId ), val );\n }\n\n addAll() : Record[] {\n if( this.resolvedWith ){\n this.set( this.resolvedWith.models );\n return this.models;\n }\n\n throw new Error( \"Cannot add elemens because the subset collection is not resolved yet.\" );\n }\n\n toggleAll() : Record[] {\n return this.length ? this.reset() : this.addAll();\n }\n }\n\n // Clean up all custom item events to prevent memory leaks.\n SubsetOfCollection.prototype._itemEvents = void 0;\n\n return SubsetOfCollection;\n}\n\nfunction resolveRefs( master, elements ){\n const records = [];\n \n for( let el of elements ){\n const record = master.get( el );\n if( record ) records.push( record );\n }\n\n return records;\n}\n\nfunction delaySet( collection, elements, options ) : void {\n if( tools.notEqual( collection.refs, elements ) ){\n const isRoot = transactionApi.begin( collection );\n\n // Save elements to resolve in future...\n collection.refs = elements.slice();\n\n transactionApi.markAsDirty( collection, options );\n \n // And throw the 'changes' event.\n isRoot && transactionApi.commit( collection );\n }\n}\n\nfunction toArray( elements ){\n return elements ? ( \n Array.isArray( elements ) ? elements : [ elements ]\n ) : [];\n}","import { Record } from '../record'\nimport { Transactional } from '../transactions'\nimport { startIO, IOPromise } from '../io-tools'\n\nlet _store : Store = null;\n\nexport class Store extends Record {\n getStore() : Store { return this; }\n \n // delegate item lookup to owner, and to the global store if undefined\n get( name : string ) : any {\n // Lookup for resource in the current store. \n let local = this[ name ];\n\n // If something is found or it's the global store, return result.\n if( local || this === this._defaultStore ) return local;\n\n // Forward failed lookup to owner or global store.\n return this._owner ? this._owner.get( name ) : this._defaultStore.get( name ); \n }\n\n static get global(){ return _store; }\n static set global( store : Store ){\n if( _store ){\n _store.dispose();\n }\n\n Transactional.prototype._defaultStore = _store = store;\n }\n}\n\nStore.global = new Store();","// Polyfill for IE10. Should fix problems with babel and statics inheritance.\nimport { tools } from './object-plus'\n\ndeclare global {\n interface ObjectConstructor {\n setPrototypeOf( target : Object, proto : Object );\n }\n}\n\nObject.setPrototypeOf || ( Object.setPrototypeOf = tools.defaults );\n\n/**\n * Export everything \n */\n\nexport * from './object-plus'\nexport * from './collection'\nexport * from './relations'\nexport * from './record'\nexport * from './transactions'\n\nexport * from './io-tools'\n\n// Exported module itself is the global event bus.\nimport { Events } from './object-plus/'\nexport const { on, off, trigger, once, listenTo, stopListening, listenToOnce } = Events;\n\nimport { Collection } from './collection'\n\n// Define synonims for NestedTypes backward compatibility.\nimport { Record as Model } from './record' \nimport { define, Mixable as Class } from './object-plus/'\nexport { Model, Class };\n\nexport function attributes( attrDefs ) : typeof Model {\n @define class DefaultRecord extends Model {\n static attributes = attrDefs;\n }\n\n return DefaultRecord;\n}\n\nimport { ChainableAttributeSpec } from './record'\n\n/** Typeless attribute declaration with default value. */ \nexport function value( x : any ) : ChainableAttributeSpec {\n return new ChainableAttributeSpec({ value : x });\n}\n\n/** Wrap model or collection method in transaction. */\nexport function transaction< F extends Function >( method : F ) : F {\n return function( ...args ){\n let result;\n \n this.transaction( () => {\n result = method.apply( this, args );\n });\n \n return result;\n }\n}","/*******\n * Backbone Backward compatibility shim for View, Router, and History.\n * Based on 1.2.3, converted to browser-only ES6 modules thing. \n */\n\n// Backbone.js 1.2.3\n// (c) 2010-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\n// Backbone may be freely distributed under the MIT license.\nimport * as _ from 'underscore'\nimport * as jQuery from 'jquery'\n\n// Initial Setup\n// -------------\ndeclare global {\n interface Window {\n Backbone : any\n }\n\n function attachEvent( a, b );\n function detachEvent( a, b );\n}\n\n// Save the previous value of the `Backbone` variable, so that it can be\n// restored later on, if `noConflict` is used.\nconst previousBackbone = window.Backbone;\n\n// Create a local reference to a common array method we'll want to use later.\nconst slice = Array.prototype.slice;\n\n// For Backbone's purposes, jQuery, Zepto, Ender, or My Library (kidding) owns\n// the `$` variable.\nconst exported = {\n $ : jQuery,\n history : null,\n VERSION : '1.2.3',\n View, History, Router, noConflict\n}\n\nexport default exported;\n\n// Runs Backbone.js in *noConflict* mode, returning the `Backbone` variable\n// to its previous owner. Returns a reference to this Backbone object.\nfunction noConflict() {\n window.Backbone = previousBackbone;\n return this;\n};\n\n// Backbone.View\n// -------------\n\n// Backbone Views are almost more convention than they are actual code. A View\n// is simply a JavaScript object that represents a logical chunk of UI in the\n// DOM. This might be a single item, an entire list, a sidebar or panel, or\n// even the surrounding frame which wraps your whole app. Defining a chunk of\n// UI as a **View** allows you to define your DOM events declaratively, without\n// having to worry about render order ... and makes it easy for the view to\n// react to specific changes in the state of your models.\n\n// Creating a Backbone.View creates its initial element outside of the DOM,\n// if an existing element is not provided...\nexport function View(options) {\n this.cid = _.uniqueId('view');\n options || (options = {});\n _.extend(this, _.pick(options, viewOptions));\n this._ensureElement();\n this.initialize.apply(this, arguments);\n this.delegateEvents();\n};\n\n// Cached regex to split keys for `delegate`.\nvar delegateEventSplitter = /^(\\S+)\\s*(.*)$/;\n\n// List of view options to be merged as properties.\nvar viewOptions = ['model', 'collection', 'el', 'id', 'attributes', 'className', 'tagName', 'events'];\n\n// Set up all inheritable **Backbone.View** properties and methods.\n_.extend(View.prototype, {\n\n // The default `tagName` of a View's element is `\"div\"`.\n tagName: 'div',\n\n // jQuery delegate for element lookup, scoped to DOM elements within the\n // current view. This should be preferred to global lookups where possible.\n $: function (selector) {\n return this.$el.find(selector);\n },\n\n // Initialize is an empty function by default. Override it with your own\n // initialization logic.\n initialize: function () { },\n\n // **render** is the core function that your view should override, in order\n // to populate its element (`this.el`), with the appropriate HTML. The\n // convention is for **render** to always return `this`.\n render: function () {\n return this;\n },\n\n // Remove this view by taking the element out of the DOM, and removing any\n // applicable Backbone.Events listeners.\n remove: function () {\n this.$el.remove();\n this.stopListening();\n return this;\n },\n\n // Change the view's element (`this.el` property), including event\n // re-delegation.\n setElement: function (element, delegate) {\n if (this.$el) this.undelegateEvents();\n this.$el = element instanceof exported.$ ? element : exported.$(element);\n this.el = this.$el[0];\n if (delegate !== false) this.delegateEvents();\n return this;\n },\n\n // Set callbacks, where `this.events` is a hash of\n //\n // *{\"event selector\": \"callback\"}*\n //\n // {\n // 'mousedown .title': 'edit',\n // 'click .button': 'save',\n // 'click .open': function(e) { ... }\n // }\n //\n // pairs. Callbacks will be bound to the view, with `this` set properly.\n // Uses event delegation for efficiency.\n // Omitting the selector binds the event to `this.el`.\n // This only works for delegate-able events: not `focus`, `blur`, and\n // not `change`, `submit`, and `reset` in Internet Explorer.\n delegateEvents: function (events) {\n if (!(events || (events = _.result(this, 'events')))) return this;\n this.undelegateEvents();\n for (var key in events) {\n var method = events[key];\n if (!_.isFunction(method)) method = this[events[key]];\n if (!method) continue;\n\n var match = key.match(delegateEventSplitter);\n var eventName = match[1], selector = match[2];\n method = _.bind(method, this);\n eventName += '.delegateEvents' + this.cid;\n if (selector === '') {\n this.$el.on(eventName, method);\n } else {\n this.$el.on(eventName, selector, method);\n }\n }\n return this;\n },\n\n // Clears all callbacks previously bound to the view with `delegateEvents`.\n // You usually don't need to use this, but may wish to if you have multiple\n // Backbone views attached to the same DOM element.\n undelegateEvents: function () {\n this.$el.off('.delegateEvents' + this.cid);\n return this;\n },\n\n // Ensure that the View has a DOM element to render into.\n // If `this.el` is a string, pass it through `$()`, take the first\n // matching element, and re-assign it to `el`. Otherwise, create\n // an element from the `id`, `className` and `tagName` properties.\n _ensureElement: function () {\n if (!this.el) {\n var attrs = _.extend({}, _.result(this, 'attributes'));\n if (this.id) attrs.id = _.result(this, 'id');\n if (this.className) attrs['class'] = _.result(this, 'className');\n var $el = exported.$('<' + _.result(this, 'tagName') + '>').attr(attrs);\n this.setElement($el, false);\n } else {\n this.setElement(_.result(this, 'el'), false);\n }\n }\n\n});\n\n// Backbone.Router\n// ---------------\n\n// Routers map faux-URLs to actions, and fire events when routes are\n// matched. Creating a new one sets its `routes` hash, if not set statically.\nexport function Router(options) {\n options || (options = {});\n if (options.routes) this.routes = options.routes;\n this._bindRoutes();\n this.initialize.apply(this, arguments);\n}\n\n// Cached regular expressions for matching named param parts and splatted\n// parts of route strings.\nvar optionalParam = /\\((.*?)\\)/g;\nvar namedParam = /(\\(\\?)?:\\w+/g;\nvar splatParam = /\\*\\w+/g;\nvar escapeRegExp = /[\\-{}\\[\\]+?.,\\\\\\^$|#\\s]/g;\n\n// Set up all inheritable **Backbone.Router** properties and methods.\n_.extend(Router.prototype, {\n\n // Initialize is an empty function by default. Override it with your own\n // initialization logic.\n initialize: function () { },\n\n // Manually bind a single named route to a callback. For example:\n //\n // this.route('search/:query/p:num', 'search', function(query, num) {\n // ...\n // });\n //\n route: function (route, name, callback) {\n if (!_.isRegExp(route)) route = this._routeToRegExp(route);\n if (_.isFunction(name)) {\n callback = name;\n name = '';\n }\n if (!callback) callback = this[name];\n var router = this;\n exported.history.route(route, function (fragment) {\n var args = router._extractParameters(route, fragment);\n if (router.execute(callback, args, name) !== false) {\n router.trigger.apply(router, ['route:' + name].concat(args));\n router.trigger('route', name, args);\n exported.history.trigger('route', router, name, args);\n }\n });\n return this;\n },\n\n // Execute a route handler with the provided parameters. This is an\n // excellent place to do pre-route setup or post-route cleanup.\n execute: function (callback, args, name) {\n if (callback) callback.apply(this, args);\n },\n\n // Simple proxy to `Backbone.history` to save a fragment into the history.\n navigate: function (fragment, options) {\n exported.history.navigate(fragment, options);\n return this;\n },\n\n // Bind all defined routes to `Backbone.history`. We have to reverse the\n // order of the routes here to support behavior where the most general\n // routes can be defined at the bottom of the route map.\n _bindRoutes: function () {\n if (!this.routes) return;\n this.routes = _.result(this, 'routes');\n var route, routes = _.keys(this.routes);\n while ((route = routes.pop()) != null) {\n this.route(route, this.routes[route]);\n }\n },\n\n // Convert a route string into a regular expression, suitable for matching\n // against the current location hash.\n _routeToRegExp: function (route) {\n route = route.replace(escapeRegExp, '\\\\$&')\n .replace(optionalParam, '(?:$1)?')\n .replace(namedParam, function (match, optional) {\n return optional ? match : '([^/?]+)';\n })\n .replace(splatParam, '([^?]*?)');\n return new RegExp('^' + route + '(?:\\\\?([\\\\s\\\\S]*))?$');\n },\n\n // Given a route, and a URL fragment that it matches, return the array of\n // extracted decoded parameters. Empty or unmatched parameters will be\n // treated as `null` to normalize cross-browser behavior.\n _extractParameters: function (route, fragment) {\n var params = route.exec(fragment).slice(1);\n return _.map(params, function (param, i) {\n // Don't decode the search params.\n if (i === params.length - 1) return param || null;\n return param ? decodeURIComponent(param) : null;\n });\n }\n\n});\n\n// Backbone.History\n// ----------------\n\n// Handles cross-browser history management, based on either\n// [pushState](http://diveintohtml5.info/history.html) and real URLs, or\n// [onhashchange](https://developer.mozilla.org/en-US/docs/DOM/window.onhashchange)\n// and URL fragments. If the browser supports neither (old IE, natch),\n// falls back to polling.\nexport function History() {\n this.handlers = [];\n this.checkUrl = _.bind(this.checkUrl, this);\n\n // Ensure that `History` can be used outside of the browser.\n if (typeof window !== 'undefined') {\n this.location = window.location;\n this.history = window.history;\n }\n};\n\n// Cached regex for stripping a leading hash/slash and trailing space.\nvar routeStripper = /^[#\\/]|\\s+$/g;\n\n// Cached regex for stripping leading and trailing slashes.\nvar rootStripper = /^\\/+|\\/+$/g;\n\n// Cached regex for stripping urls of hash.\nvar pathStripper = /#.*$/;\n\n// Has the history handling already been started?\n(History as any).started = false;\n\n// Set up all inheritable **Backbone.History** properties and methods.\n_.extend(History.prototype, {\n\n // The default interval to poll for hash changes, if necessary, is\n // twenty times a second.\n interval: 50,\n\n // Are we at the app root?\n atRoot: function () {\n var path = this.location.pathname.replace(/[^\\/]$/, '$&/');\n return path === this.root && !this.getSearch();\n },\n\n // Does the pathname match the root?\n matchRoot: function () {\n var path = this.decodeFragment(this.location.pathname);\n var root = path.slice(0, this.root.length - 1) + '/';\n return root === this.root;\n },\n // Unicode characters in `location.pathname` are percent encoded so they're\n // decoded for comparison. `%25` should not be decoded since it may be part\n // of an encoded parameter.\n decodeFragment: function (fragment) {\n return decodeURI(fragment.replace(/%25/g, '%2525'));\n },\n // In IE6, the hash fragment and search params are incorrect if the\n // fragment contains `?`.\n getSearch: function () {\n var match = this.location.href.replace(/#.*/, '').match(/\\?.+/);\n return match ? match[0] : '';\n },\n // Gets the true hash value. Cannot use location.hash directly due to bug\n // in Firefox where location.hash will always be decoded.\n getHash: function (window) {\n var match = (window || this).location.href.match(/#(.*)$/);\n return match ? match[1] : '';\n },\n\n // Get the pathname and search params, without the root.\n getPath: function () {\n var path = this.decodeFragment(\n this.location.pathname + this.getSearch()\n ).slice(this.root.length - 1);\n return path.charAt(0) === '/' ? path.slice(1) : path;\n },\n\n // Get the cross-browser normalized URL fragment from the path or hash.\n getFragment: function (fragment) {\n if (fragment == null) {\n if (this._usePushState || !this._wantsHashChange) {\n fragment = this.getPath();\n } else {\n fragment = this.getHash();\n }\n }\n return fragment.replace(routeStripper, '');\n },\n\n // Start the hash change handling, returning `true` if the current URL matches\n // an existing route, and `false` otherwise.\n start: function (options) {\n if ((History as any).started) throw new Error('Backbone.history has already been started');\n (History as any).started = true;\n\n // Figure out the initial configuration. Do we need an iframe?\n // Is pushState desired ... is it available?\n this.options = _.extend({ root: '/' }, this.options, options);\n this.root = this.options.root;\n this._wantsHashChange = this.options.hashChange !== false;\n this._hasHashChange = 'onhashchange' in window && ((document as any).documentMode === void 0 || (document as any).documentMode > 7);\n this._useHashChange = this._wantsHashChange && this._hasHashChange;\n this._wantsPushState = !!this.options.pushState;\n this._hasPushState = !!(this.history && this.history.pushState);\n this._usePushState = this._wantsPushState && this._hasPushState;\n this.fragment = this.getFragment();\n\n // Normalize root to always include a leading and trailing slash.\n this.root = ('/' + this.root + '/').replace(rootStripper, '/');\n\n\n\n\n // Transition from hashChange to pushState or vice versa if both are\n // requested.\n if (this._wantsHashChange && this._wantsPushState) {\n\n // If we've started off with a route from a `pushState`-enabled\n // browser, but we're currently in a browser that doesn't support it...\n if (!this._hasPushState && !this.atRoot()) {\n var root = this.root.slice(0, -1) || '/';\n this.location.replace(root + '#' + this.getPath());\n // Return immediately as browser will do redirect to new url\n return true;\n\n // Or if we've started out with a hash-based route, but we're currently\n // in a browser where it could be `pushState`-based instead...\n } else if (this._hasPushState && this.atRoot()) {\n this.navigate(this.getHash(), { replace: true });\n }\n\n }\n\n // Proxy an iframe to handle location events if the browser doesn't\n // support the `hashchange` event, HTML5 history, or the user wants\n // `hashChange` but not `pushState`.\n if (!this._hasHashChange && this._wantsHashChange && !this._usePushState) {\n this.iframe = document.createElement('iframe');\n this.iframe.src = 'javascript:0';\n this.iframe.style.display = 'none';\n this.iframe.tabIndex = -1;\n var body = document.body;\n // Using `appendChild` will throw on IE < 9 if the document is not ready.\n var iWindow = body.insertBefore(this.iframe, body.firstChild).contentWindow;\n iWindow.document.open();\n iWindow.document.close();\n iWindow.location.hash = '#' + this.fragment;\n }\n\n // Add a cross-platform `addEventListener` shim for older browsers.\n var addEventListener = window.addEventListener || function (eventName, listener) {\n return attachEvent('on' + eventName, listener);\n };\n // Depending on whether we're using pushState or hashes, and whether\n // 'onhashchange' is supported, determine how we check the URL state.\n if (this._usePushState) {\n addEventListener('popstate', this.checkUrl, false);\n } else if (this._useHashChange && !this.iframe) {\n addEventListener('hashchange', this.checkUrl, false);\n } else if (this._wantsHashChange) {\n this._checkUrlInterval = setInterval(this.checkUrl, this.interval);\n }\n if (!this.options.silent) return this.loadUrl();\n },\n\n // Disable Backbone.history, perhaps temporarily. Not useful in a real app,\n // but possibly useful for unit testing Routers.\n stop: function () {\n // Add a cross-platform `removeEventListener` shim for older browsers.\n var removeEventListener = window.removeEventListener || function (eventName, listener) {\n return detachEvent('on' + eventName, listener);\n };\n // Remove window listeners.\n if (this._usePushState) {\n removeEventListener('popstate', this.checkUrl, false);\n } else if (this._useHashChange && !this.iframe) {\n removeEventListener('hashchange', this.checkUrl, false);\n }\n // Clean up the iframe if necessary.\n if (this.iframe) {\n document.body.removeChild(this.iframe);\n this.iframe = null;\n }\n // Some environments will throw when clearing an undefined interval.\n if (this._checkUrlInterval) clearInterval(this._checkUrlInterval);\n (History as any).started = false;\n },\n\n // Add a route to be tested when the fragment changes. Routes added later\n // may override previous routes.\n route: function (route, callback) {\n this.handlers.unshift({ route: route, callback: callback });\n },\n\n // Checks the current URL to see if it has changed, and if it has,\n // calls `loadUrl`, normalizing across the hidden iframe.\n checkUrl: function (e) {\n var current = this.getFragment();\n // If the user pressed the back button, the iframe's hash will have\n // changed and we should use that for comparison.\n if (current === this.fragment && this.iframe) {\n current = this.getHash(this.iframe.contentWindow);\n }\n if (current === this.fragment) return false;\n if (this.iframe) this.navigate(current);\n this.loadUrl();\n },\n\n // Attempt to load the current URL fragment. If a route succeeds with a\n // match, returns `true`. If no defined routes matches the fragment,\n // returns `false`.\n loadUrl: function (fragment) {\n // If the root doesn't match, no routes can match either.\n if (!this.matchRoot()) return false;\n fragment = this.fragment = this.getFragment(fragment);\n return _.some(this.handlers, function (handler) {\n if (handler.route.test(fragment)) {\n handler.callback(fragment);\n return true;\n }\n });\n },\n\n // Save a fragment into the hash history, or replace the URL state if the\n // 'replace' option is passed. You are responsible for properly URL-encoding\n // the fragment in advance.\n //\n // The options object can contain `trigger: true` if you wish to have the\n // route callback be fired (not usually desirable), or `replace: true`, if\n // you wish to modify the current URL without adding an entry to the history.\n navigate: function (fragment, options) {\n if (!(History as any).started) return false;\n if (!options || options === true) options = { trigger: !!options };\n\n // Normalize the fragment.\n fragment = this.getFragment(fragment || '');\n\n // Don't include a trailing slash on the root.\n var root = this.root;\n if (fragment === '' || fragment.charAt(0) === '?') {\n root = root.slice(0, -1) || '/';\n }\n var url = root + fragment;\n // Strip the hash and decode for matching.\n fragment = this.decodeFragment(fragment.replace(pathStripper, ''));\n\n if (this.fragment === fragment) return;\n this.fragment = fragment;\n\n\n // If pushState is available, we use it to set the fragment as a real URL.\n if (this._usePushState) {\n this.history[options.replace ? 'replaceState' : 'pushState']({}, document.title, url);\n\n // If hash changes haven't been explicitly disabled, update the hash\n // fragment to store history.\n } else if (this._wantsHashChange) {\n this._updateHash(this.location, fragment, options.replace);\n if (this.iframe && (fragment !== this.getHash(this.iframe.contentWindow))) {\n var iWindow = this.iframe.contentWindow;\n // Opening and closing the iframe tricks IE7 and earlier to push a\n // history entry on hash-tag change. When replace is true, we don't\n // want this.\n if (!options.replace) {\n iWindow.document.open();\n iWindow.document.close();\n }\n\n this._updateHash(iWindow.location, fragment, options.replace);\n }\n\n // If you've told us that you explicitly don't want fallback hashchange-\n // based history, then `navigate` becomes a page refresh.\n } else {\n return this.location.assign(url);\n }\n if (options.trigger) return this.loadUrl(fragment);\n },\n\n // Update the hash location, either replacing the current entry, or adding\n // a new one to the browser history.\n _updateHash: function (location, fragment, replace) {\n if (replace) {\n var href = location.href.replace(/(javascript:|#).*$/, '');\n location.replace(href + '#' + fragment);\n } else {\n // Some browsers require that `hash` contains a leading #.\n location.hash = '#' + fragment;\n }\n }\n\n});\n\n// Create the default Backbone.history.\nexported.history = new History;\n\n","/**\n * Backbone.js 1.2.3 REST implementation\n * (c) 2010-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\n * Backbone may be freely distributed under the MIT license.\n *\n * With validation patches - NestedTypes validation semantic is applied. (c) Vlad Balin, 2015.\n */\nimport * as _ from 'underscore'\nimport Backbone from './backbone'\n\nimport { tools } from './type-r'\nconst { defaults } = tools;\n\nexport type LazyValue< T > = () => T | T;\n\n// Map from CRUD to HTTP for our default `Backbone.sync` implementation.\nexport type Method = 'create' | 'update' | 'patch' | 'delete' | 'read' \n\nexport interface Restful {\n trigger( event : string, model, xhr, options )\n collection? : { trigger( event : string, model, xhr, options ) }\n toJSON( options : any ) : {}\n _xhr : JQueryXHR\n sync( method : string, object : Restful, options : SyncOptions )\n}\n\nexport interface SyncOptions {\n url? : LazyValue< string >\n data? : any\n attrs? : {}\n beforeSend? : ( xhr ) => any\n\n success? : ( resp : any ) => void\n error? : ( xhr?, textStatus?, errorThrown? ) => void\n\n textStatus? : string\n errorThrown? : any\n xhr? : any\n context? : {}\n}\n\nconst methodMap = {\n 'create' : 'POST',\n 'update' : 'PUT',\n 'patch' : 'PATCH',\n 'delete' : 'DELETE',\n 'read' : 'GET'\n};\n\nconst exported = {\n $ : Backbone.$,\n \n errorPromise : error => {\n var x = $.Deferred();\n x.reject( error );\n return x;\n },\n\n // Set the default implementation of `Backbone.ajax` to proxy through to `$`.\n // Override this if you'd like to use a different library.\n ajax : function( options : {} ){\n return $.ajax.apply( $, arguments );\n },\n\n sync,\n\n // Throw an error when a URL is needed, and none is supplied.\n urlError : function(){\n throw new Error( 'A \"url\" property or function must be specified' );\n }\n};\n\nexport default exported;\n\n // Backbone.sync\n // -------------\n\n // Override this function to change the manner in which Backbone persists\n // models to the server. You will be passed the type of request, and the\n // model in question. By default, makes a RESTful Ajax request\n // to the model's `url()`. Some possible customizations could be:\n //\n // * Use `setTimeout` to batch rapid-fire updates into a single request.\n // * Send up the models as XML instead of JSON.\n // * Persist models via WebSockets instead of Ajax.\n\nfunction sync( method : Method, model : Restful, options : SyncOptions = {} ) : JQueryXHR{\n var type = methodMap[ method ];\n\n // Default JSON-request options.\n var params : any = { type : type, dataType : 'json' };\n\n // Ensure that we have a URL.\n if( !options.url ){\n params.url = _.result( model, 'url' ) || exported.urlError();\n }\n\n // Ensure that we have the appropriate request data.\n if( options.data == null && model && (method === 'create' || method === 'update' || method === 'patch') ){\n params.contentType = 'application/json';\n params.data = JSON.stringify( options.attrs || model.toJSON( options ) );\n }\n\n // Don't process data on a non-GET request.\n if( params.type !== 'GET' ){\n params.processData = false;\n }\n\n // Pass along `textStatus` and `errorThrown` from jQuery.\n var error = options.error;\n options.error = function( xhr, textStatus, errorThrown ){\n options.textStatus = textStatus;\n options.errorThrown = errorThrown;\n if( error ) error.call( options.context, xhr, textStatus, errorThrown );\n };\n\n // Make the request, allowing the user to override any Ajax options.\n var xhr = options.xhr = exported.ajax( _.extend( params, options ) );\n model.trigger( 'request', model, xhr, options );\n model.collection && model.collection.trigger( 'request', model, xhr, options );\n return xhr;\n}","import Sync, { SyncOptions, Restful, LazyValue } from './sync'\n\nimport * as _ from 'underscore'\nimport * as Backbone from './backbone'\n\nimport { define, Model, Collection, tools, definitions, mixinRules } from './type-r'\nconst { defaults } = tools;\n\nconst transactionalProto = tools.getBaseClass( Model ).prototype;\n\nexport interface RestOptions extends SyncOptions {\n wait? : boolean\n patch? : boolean\n reset? : boolean\n validate? : boolean\n}\n\n@define({\n itemEvents : {\n destroy( model ){ this.remove( model ); }\n } \n})\nexport class RestCollection extends Collection implements Restful {\n _xhr : JQueryXHR\n\n dispose(){\n if( this._xhr && this._xhr.abort ) this._xhr.abort();\n super.dispose();\n }\n\n model : typeof RestModel\n url() : string { return this.model.prototype.urlRoot || ''; }\n\n _invalidate( options : { validate? : boolean } ) : boolean {\n var error;\n if( options.validate && ( error = this.validationError ) ){\n this.trigger( 'invalid', this, error, _.extend( { validationError : error }, options ) );\n return true;\n }\n }\n\n // Fetch the default set of models for this collection, resetting the\n // collection when they arrive. If `reset: true` is passed, the response\n // data will be passed through the `reset` method instead of `set`.\n fetch( options : RestOptions ) : any {\n options = _.extend( { parse : true }, options );\n var success = options.success;\n var collection = this;\n options.success = function( resp ){\n var method = options.reset ? 'reset' : 'set';\n collection[ method ]( resp, options );\n if( collection._invalidate( options ) ) return false;\n\n if( success ) success.call( options.context, collection, resp, options );\n collection.trigger( 'sync', collection, resp, options );\n };\n\n wrapError( this, options );\n return _sync( 'read', this, options );\n }\n\n create( a_model, options : any = {} ) : RestModel {\n const model : RestModel = a_model instanceof RestModel ?\n a_model :\n this.model.create( a_model, options );\n\n // Hack! For the situation when model instance is given, aquire it. \n model._owner || ( model._owner = this );\n\n options.wait || this.add([ model ], options );\n\n var collection = this;\n var success = options.success;\n options.success = ( model, resp, callbackOpts ) =>{\n if( options.wait ) this.add( [ model ], defaults({ parse : false }, callbackOpts ) );\n if( success ) success.call( callbackOpts.context, model, resp, callbackOpts );\n };\n\n model.save( null, options );\n return model;\n }\n\n // Proxy `Backbone.sync` by default -- but override this if you need\n // custom syncing semantics for *this* particular model.\n sync(){\n return Sync.sync.apply( this, arguments );\n }\n};\n\n@define({\n urlRoot : ''\n})\n@definitions({\n urlRoot : mixinRules.protoValue\n})\nexport class RestModel extends Model implements Restful {\n static Collection : typeof Collection = RestCollection as any;\n \n _xhr : JQueryXHR\n\n urlRoot : string\n\n /** @private */\n _invalidate( options : { validate? : boolean } ) : boolean {\n var error;\n if( options.validate && ( error = this.validationError ) ){\n triggerAndBubble( this, 'invalid', this, error, _.extend( { validationError : error }, options ) );\n return true;\n }\n }\n\n dispose(){\n if( this._xhr && this._xhr.abort ) this._xhr.abort();\n super.dispose();\n }\n\n // Fetch the model from the server, merging the response with the model's\n // local attributes. Any changed attributes will trigger a \"change\" event.\n fetch( options? : RestOptions ) : any {\n options = _.extend( { parse : true }, options );\n var model = this;\n var success = options.success;\n options.success = function( serverAttrs ){\n model.set( serverAttrs, options );\n if( model._invalidate( options ) ) return false;\n\n if( success ) success.call( options.context, model, serverAttrs, options );\n triggerAndBubble( model, 'sync', model, serverAttrs, options );\n };\n\n wrapError( this, options );\n return _sync( 'read', this, options );\n }\n\n // Proxy `Backbone.sync` by default -- but override this if you need\n // custom syncing semantics for *this* particular model.\n sync( method : string, self : this, options : SyncOptions ) : any\n sync() : JQueryXHR {\n return Sync.sync.apply( this, arguments );\n }\n\n // Set a hash of model attributes, and sync the model to the server.\n // If the server returns an attributes hash that differs, the model's\n // state will be `set` again.\n save( attrs? : {}, options? : RestOptions ) : any\n save( key : string, value : any, options? : RestOptions ) : any\n save( key, val, a_options? : RestOptions ) : any {\n // Handle both `\"key\", value` and `{key: value}` -style arguments.\n let attrs, originalOptions;\n\n if( key == null || typeof key === 'object' ){\n attrs = key;\n originalOptions = val || {};\n }\n else{\n (attrs = {})[ key ] = val;\n originalOptions = a_options || {};\n }\n\n const options = _.extend( { validate : true, parse : true }, originalOptions ),\n wait = options.wait;\n\n // If we're not waiting and attributes exist, save acts as\n // `set(attr).save(null, opts)` with validation. Otherwise, check if\n // the model will be valid when the attributes, if any, are set.\n if( attrs && !wait ){\n this.set( attrs, originalOptions );\n }\n\n if( this._invalidate( options ) ){\n if( attrs && wait ) this.set( attrs, originalOptions );\n return Sync.errorPromise( this.validationError );\n }\n\n // After a successful server-side save, the client is (optionally)\n // updated with the server-side state.\n var model = this;\n var success = options.success;\n var attributes = this.attributes;\n options.success = serverAttrs => {\n // Ensure attributes are restored during synchronous saves.\n model.attributes = attributes;\n if( wait ) serverAttrs = _.extend( {}, attrs, serverAttrs );\n\n if( serverAttrs ){\n // When server sends string, polimorphyc Model set screws up.\n transactionalProto.set.call( this, serverAttrs, options );\n if( model._invalidate( options ) ) return false;\n }\n\n if( success ) success.call( options.context, model, serverAttrs, options );\n triggerAndBubble( model, 'sync', model, serverAttrs, options );\n };\n\n wrapError( this, options );\n\n // Set temporary attributes if `{wait: true}` to properly find new ids.\n if( attrs && wait ) this.attributes = _.extend( {}, attributes, attrs );\n\n var method = this.isNew() ? 'create' : (options.patch ? 'patch' : 'update');\n if( method === 'patch' && !options.attrs ) options.attrs = attrs;\n var xhr = _sync( method, this, options );\n\n // Restore attributes.\n this.attributes = attributes;\n\n return xhr;\n }\n\n // Destroy this model on the server if it was already persisted.\n // Optimistically removes the model from its collection, if it has one.\n // If `wait: true` is passed, waits for the server to respond before removal.\n destroy( options : RestOptions ) : any {\n options = options ? _.clone( options ) : {};\n var model = this;\n var success = options.success;\n var wait = options.wait;\n\n var destroy = function(){\n model.stopListening(); // TBD: figure out whenever we need to dispose the model.\n model.trigger( 'destroy', model, model.collection, options );\n };\n\n options.success = function( resp ){\n if( wait ) destroy();\n if( success ) success.call( options.context, model, resp, options );\n if( !model.isNew() ) triggerAndBubble( model, 'sync', model, resp, options );\n };\n\n var xhr : JQueryXHR;\n\n if( this.isNew() ){\n _.defer( options.success );\n }\n else{\n wrapError( this, options );\n xhr = _sync( 'delete', this, options );\n }\n\n if( !wait ) destroy();\n \n return xhr || false;\n }\n\n // Default URL for the model's representation on the server -- if you're\n // using Backbone's restful methods, override this to change the endpoint\n // that will be called.\n url() : string {\n var base =\n _.result( this, 'urlRoot' ) ||\n _.result( this.collection, 'url' ) ||\n Sync.urlError();\n\n if( this.isNew() ) return base;\n\n var id = this.get( this.idAttribute );\n\n return base.replace( /[^\\/]$/, '$&/' ) + encodeURIComponent( id );\n }\n\n set( key : string, value : any, options? : object ) : this\n set( attrs : {}, options? : object ) : this\n set( a, b?, c? ) : this {\n if( typeof a === 'string' ){\n if( c ){\n return super.set({ [ a ] : b }, c );\n }\n else{\n this[ a ] = b;\n return this;\n } \n }\n else{\n return super.set( a, b );\n }\n }\n}\n\nfunction _sync( method : string, _this : Restful, options ) : JQueryXHR {\n // Abort and pending IO request. Just one is allowed at the time.\n _this._xhr && _this._xhr.abort && _this._xhr.abort();\n const xhr = _this._xhr = _this.sync( method, _this, options );\n xhr && xhr.always && xhr.always( function(){ _this._xhr = void 0; });\n return xhr;\n}\n\n// Wrap an optional error callback with a fallback error event.\nfunction wrapError( model : any, options : RestOptions ){\n var error = options.error;\n options.error = function( resp ){\n if( error ) error.call( options.context, model, resp, options );\n triggerAndBubble( model, 'error', model, resp, options );\n };\n}\n\nfunction triggerAndBubble( model : any, ...args : any[] ){\n model.trigger.apply( model, args );\n const { collection } = model;\n collection && collection.trigger.apply( collection, args ); \n}","import * as _ from 'underscore'\n\nexport const ModelMixin = {\n pick( ...args : any[] ){\n return _.pick( this, args );\n },\n\n escape( attr ){\n return _.escape( this[ attr ] );\n },\n\n matches( attrs ){\n return !!_.iteratee( attrs, this )( this );\n },\n\n omit( ...keys : string[] ) : {} {\n return this.mapObject( ( value, key ) => {\n if( keys.indexOf( key ) < 0 ){\n return value;\n }\n });\n },\n\n invert(){\n const inverted = {};\n this.each( ( value, key ) => inverted[ value ] = key );\n return inverted;\n },\n\n pairs(){\n return this.map( ( value, key ) => [ key, value ] );\n },\n\n isEmpty(){\n return !this.values().length;\n },\n\n chain(){\n return _.chain( this.mapObject( x => x ) );\n }\n};\n\nexport const CollectionMixin = {\n where(attrs, first) {\n return this[first ? 'find' : 'filter'](attrs);\n },\n\n findWhere(attrs) {\n return this.where(attrs, true);\n }\n};\n\naddUnderscoreMethods( CollectionMixin, 'models', {\n forEach : 3, each : 3, map : 3, collect : 3, reduce : 4,\n foldl : 4, inject : 4, reduceRight : 4, foldr : 4, find : 3, findIndex : 3, findLastIndex : 3, detect : 3, filter : 3,\n select : 3, reject : 3, every : 3, all : 3, some : 3, any : 3, include : 3, includes : 3,\n contains : 3, invoke : 0, max : 3, min : 3, toArray : 1, size : 1, first : 3,\n head : 3, take : 3, initial : 3, rest : 3, tail : 3, drop : 3, last : 3,\n without : 0, difference : 0, indexOf : 3, shuffle : 1, lastIndexOf : 3,\n isEmpty : 1, chain : 1, sample : 3, partition : 3, groupBy : 3, countBy : 3,\n sortBy : 3, indexBy : 3\n});\n\nfunction addUnderscoreMethods(Mixin, attribute, methods ) {\n _.each(methods, function(length, method) {\n if (_[method]) Mixin[method] = addMethod(length, method, attribute);\n });\n}\n\n// Proxy Backbone class methods to Underscore functions, wrapping the model's\n// `attributes` object or collection's `models` array behind the scenes.\n//\n// collection.filter(function(model) { return model.get('age') > 10 });\n// collection.each(this.addView);\n//\n// `Function#apply` can be slow so we use the method's arg count, if we know it.\nfunction addMethod(length, method, attribute) {\n switch (length) {\n case 1: return function() {\n return _[method](this[attribute]);\n };\n case 2: return function(value) {\n return _[method](this[attribute], value);\n };\n case 3: return function(iteratee, context) {\n var value = this[ attribute ],\n callback = cb(iteratee, this);\n\n return arguments.length > 1 ?\n _[method]( value, callback, context)\n : _[method]( value, callback );\n };\n case 4: return function(iteratee, defaultVal, context) {\n var value = this[ attribute ],\n callback = cb(iteratee, this);\n\n return arguments.length > 1 ?\n _[method]( value, callback, defaultVal, context )\n : _[method](value, callback );\n };\n default: return function( ...args : any[] ) {\n args.unshift(this[attribute]);\n return _[method].apply(_, args);\n };\n }\n}\n\n// Support `collection.sortBy('attr')` and `collection.findWhere({id: 1})`.\nfunction cb(iteratee, instance) {\n switch( typeof iteratee ){\n case 'function' : return iteratee;\n case 'string' : return model => model.get( iteratee );\n case 'object' :\n if( !(iteratee instanceof instance.model )) return _.matches( iteratee ); \n }\n\n return iteratee;\n}","import Backbone from './backbone'\nimport * as _ from 'underscore'\nimport { mixins, mixinRules, define, Store } from './type-r'\nimport { RestModel, RestCollection } from './rest'\n\n@define({\n getStore : Store.prototype.getStore,\n get : Store.prototype.get,\n})\nexport class RestStore extends RestModel {}\n\n@define\nexport class LazyStore extends RestStore {\n _resolved : {} = {}\n\n initialize(){\n this.each( ( element, name ) => {\n if( !element ) return;\n\n element.store = this;\n\n var fetch = element.fetch;\n\n if( fetch ){\n const self = this;\n element.fetch = function() {\n return self._resolved[ name ] = fetch.apply( this, arguments );\n }\n }\n\n if( element instanceof RestCollection && element.length ){\n this._resolved[name] = true;\n }\n });\n }\n\n // fetch specified items, or all items if called without arguments.\n // returns jquery promise\n fetch( ...args : any[] /* hack, inheritance here violates LSP */) : any {\n var xhr = [],\n objsToFetch = args.length ? args : this.keys();\n\n for( let name of objsToFetch ){\n var attr = this.attributes[name];\n attr && attr.fetch && xhr.push( attr.fetch() );\n }\n\n const { $ } = Backbone;\n return $ && $.when && $.when.apply( $, xhr );\n }\n\n // fetch specified items, or all items if called without arguments.\n // returns first jquery promise.\n fetchOnce( ...args : string[] ) : JQueryXHR {\n var xhr = [],\n self = this,\n objsToFetch = args.length ? args : this.keys();\n\n for( let name of objsToFetch ){\n var attr = self.attributes[ name ];\n xhr.push( self._resolved[ name ] || attr && attr.fetch && attr.fetch());\n }\n\n const { $ } = Backbone;\n return $ && $.when && $.when.apply( $, xhr );\n }\n\n clear( ...args : string[] ) : this {\n var objsToClear = args.length ? args : this.keys();\n\n for( let name of objsToClear ){\n var element = this.attributes[ name ];\n\n if( element instanceof RestCollection ){\n element.reset();\n }\n else if( element instanceof Store ){\n element.clear();\n }\n else if( element instanceof RestModel ){\n element.set( element.defaults() )\n }\n\n this._resolved[ name ] = false;\n }\n\n return this;\n }\n\n static onDefine( definitions, BaseClass ){\n var attributes = definitions.defaults || definitions.attributes;\n\n // add automatic fetching on first element's access\n _.each( attributes, ( Type : Function, name ) => {\n if( Type.has ){\n attributes[name] = Type.has\n .set( function( value ){\n if( !value || !value.length ){\n const resolved = this._resolved || ( this._resolved = {} ); \n resolved[name] = false;\n }\n \n return value;\n })\n } \n });\n\n RestModel.onDefine.call( this, definitions, BaseClass );\n }\n} \n ","/**\n * Extend Type-R namespace\n */\nimport * as TypeR from './type-r'\nexport * from './type-r'\n\n/**\n * Prepare backbone View, Router, History, and Events. \n */\nimport Backbone from './backbone'\nimport { RestCollection, RestModel } from './rest'\nimport { Store as BaseStore, tools, MixinsState } from './type-r'\nimport Sync from './sync'\n\nimport { ModelMixin, CollectionMixin } from './underscore-mixin'\nimport { RestStore, LazyStore } from './rest-store'\n\n/**\n * Prepare \n */\n\nexport const Class : typeof TypeR.Messenger = TypeR.Messenger;\n\nconst Nested : typeof TypeR & typeof Backbone = Object.create( TypeR, tools.defaults({\n 'sync' : linkProperty( Sync, 'sync' ),\n 'errorPromise' : linkProperty( Sync, 'errorPromise' ),\n 'ajax' : linkProperty( Sync, 'ajax' ),\n 'history' : linkProperty( Backbone, 'history' ),\n 'store' : linkProperty( BaseStore, 'global' ),\n '$' : {\n get(){ return Backbone.$; },\n set( value ){ (Backbone).$ = (Sync).$ = value; }\n }\n },\n toProps( { Backbone, Class, Model : RestModel, Collection : RestCollection, LazyStore, Store : RestStore, defaults } ),\n toProps( Backbone )\n));\n\nexport default Nested;\n\nexport { Backbone, RestStore, LazyStore, RestCollection as Collection, RestModel as Model };\n\nexport function defaults( x ) : typeof Nested.Record {\n return Nested.Model.defaults( x );\n}\n\nexport * from './backbone';\n\nMixinsState.get( Nested.Mixable ).merge([ Nested.Events ]);\nNested.Messenger.mixins.populate( Backbone.View, Backbone.Router, Backbone.History );\nNested.Record.mixins.merge([ ModelMixin ]);\nNested.Record.Collection.mixins.merge([ CollectionMixin ]);\n\n/**\n * Local utilities\n */\nfunction linkProperty( Namespace, name ){\n return {\n get(){ return Namespace[ name ]; },\n set( value ){ Namespace[ name ] = value; }\n };\n}\n\nfunction toProps( obj ){\n return tools.transform({}, obj, x => ({ value : x }) );\n} "],"names":["extendStatics","d","b","Object","setPrototypeOf","__proto__","Array","p","hasOwnProperty","__extends","__","this","constructor","prototype","create","__assign","assign","t","s","i","n","arguments","length","call","apply","__rest","e","indexOf","getOwnPropertySymbols","__decorate","decorators","target","key","desc","c","r","getOwnPropertyDescriptor","Reflect","decorate","defineProperty","defaults","dest","source","name","other","levelToNumber","none","error","warn","info","log","debug","a_level","a_msg","a_props","msg","props","level","levelAsNumber","throw","logger","Error","stop","process","env","NODE_ENV","toString","window","something","value","__inner_state__","isArray","Boolean","keys_1","keys","join","body","x","isValidJSON","proto","getPrototypeOf","every","getBaseClass","Class","isEmpty","obj","some","fun","ArrayProto","arr","result","someArray","someObject","predicate","omit","discard","transform","once","func","memo","first","console","args","name_1","push","DateProto","Date","ObjectProto","notEqual","a","protoA","arraysNotEqual","keysA","objectsNotEqual","HashProto","hashMap","hash","definition","_i","names","names_1","_a","name_2","prop","o","Mixable","protoProps","staticProps","BaseClass","mixins","defineMixin","merge","mergeObject","getStaticDefinitions","onDefine","definitions","mergeInheritedMembers","spec","statics","TheSubclass","tslib_1.__extends","predefine","define","Constructor","__super__","MixinsState","get","populate","onExtend","ClassOrDefinition","Ctor","rules","definitionRules","propertyListDecorator","listName","slice","definitionDecorator","definitionKey","mergeRules","appliedMixins","rule","mixins_1","mixin","sourceMixins","concat","ctors","ctors_1","unshift","object","ignore","dontMix","forEachOwnProp","sourceProp","_this","assignProperty","mixinRules","protoValue","baseProto","resolveRule","function","caller","list","destProp","configurable","pipe","classFirst","classLast","map","EventMap","handlers","addEventsMap","addEvent","split","eventSplitter","getBubblingHandler","callback","EventDescriptor","event_1","on","event_2","off","handler","_bubblingHandlers","event","trigger5","trigger3","trigger2","context","next","listOff","_events","filteredHead","prev","head","ev","_callback","listSend3","EventHandler","once_1","_once","name_3","strings","api","events","test","self","queue","all","listSend2","listSend4","listSend5","f","listSend6","_idCount","uniqueId","cid","initialize","Messenger","localEvents","_localEvents","properties","eventsMap","defineProperties","toPropertyDescriptor","addReference","a_source","_listeningTo","removeAll","second","_disposed","stopListening","Events","listener","extend","tools.assign","tools.log","_validateNested","nested","validate","ValidationError","iteratee","each","eachError","referenceMask","reference","splitTail","path","match","substr","tail","pop","local","resolve","Function","shift","resolveReference","root","action","skip","getStore","getOwner","getOwnerEndpoint","collection","_owner","_endpoints","_ownerKey","createIOPromise","reject","onAbort","abort","fn","promise","Promise","a_resolve","a_reject","startIO","options","thenDo","abortIO","ioUpdate","_ioPromise","then","resp","triggerAndBubble","catch","err","eventSource","trigger","ItemsBehavior","cidPrefix","Transactional","endpoint","_endpoint","Transactional_1","_changeEventName","listenTo","isRoot","transactionApi","begin","update","set","commit","values","transaction","_createTransaction","_changeToken","data","_defaultStore","v","k","val","_validationError","validationError","getValidationError","_transaction","markAsDirty","dirty","silent","_isDirty","initiator","originalOptions","_onChildrenChange","aquire","owner","child","free","_begin","_markAsDirty","setAttribute","record","_attributes","doUpdate","attributes","_previousAttributes","AttributesCopy","_changedAttributes","UpdateRecordMixin","attribute","propagateChanges","forceAttributeChange","a_values","unknown","changes","parse","shouldBeAnObject","RecordTransaction","nested_1","constructorsMixin","attrDefs","attrs","attr","Attributes","_log","nested_2","changes_1","_b","emptyOptions","a_options","getHooks","transforms","changeHandlers","type","toJSON","changeEvents","hasCustomDefault","defaultValue","tools.isValidJSON","JSON","stringify","isRequired","convert","getHook_1","getHook","reduce","chainGetHooks","validate_1","chainTransforms","handleChange","chainChangeHandlers","doInit","AnyType","_attribute","model","isChanged","text","getClassName","Record","Attribute definition","Prev. value","New value","prevHook","nextHook","prevTransform","nextTransform","prevHandler","nextHandler","AggregatedType","clone","canBeUpdated","nestedTransaction","_shared","persistent","_handleChange","unset","dispose","ChainableAttributeSpec","check","metadata","asProp","ref","_onChange","emptyFunction","changed","eventMap","unsubscribe","subscribe","cloned","attrSpec","has","type_1","Number","String","inferType","shared","_isRequired","_has","DateType","date","timestamp","getTime","toISOString","msDatePattern","MSDateType","msDate","exec","TimestampType","supportsDate","isNaN","microsoft","struct","minutesOffset","isoDatePattern","numericKeys","undefined","UTC","safeParseDate","ImmutableClassType","PrimitiveType","NumericType","num","isFinite","Integer","Math","round","integer","ArrayType","ObjectType","doNothing","FunctionType","shareAndListen","listen","share","SharedType","implicitObject","attributesDefinition","baseClassAttributes","myAttributes","_.transform","createAttribute","allAttributes","_.defaults","ConstructorsMixin","_attributesArray","createPropertyDescriptor","attrSpecs","eventsApi.EventMap","createWatcherFromRef","wrapWatcher","localEventsMixin","attrDef","from","createSharedTypeSpec","Attribute","watcher","IORecordMixin","save","getEndpoint","json","isNew","id","fetch","read","destroy","remove","_cidCounter","_super","typeCheck","diff","hasChanged","old","nullify","forEachAttr","idAttribute","_attributesArray_1","copy","pinStore","errors","asJson","l","newModel","clear","Attributes definition:","Collection","BaseRecordAttributes","BaseRecordAttributesCopy","IdAttribute","attrName","getMetadata","DefaultCollection","dynamicMixin","_aquire","_free","convertAndAquire","_aggregationError","_itemEvents","sortElements","_comparator","sort","models","addIndex","index","removeIndex","updateIndex","previous","added","removed","sorted","CollectionTransaction","logAggregationError","added_1","_d","removed_1","_e","addTransaction","items","a_items","forceMerge","_byId","prevLength","a_items_1","item","appendElements","needSort","at","length_1","j","moveElements","sortOrMoveElements","silentOptions","emptySetTransaction","len","src","_reallocateEmpty","setTransaction","_prevById","prevModels","toAdd","orderKept","_reallocate","reusedCount","previous_1","_garbageCollect","children","children_1","freeAll","addedOrChanged","removeMany","toRemove","_removeFromIndex","begin$4","_count","CollectionRefsType","records","comparator","toElements","subset","subsetOf","RefsCollection","_SubsetOf","Refs","Subset","itemEvents","aa","bb","_store","objOrId","bindContext","toPredicateFunction","find","mapped","count","a_index","elements","add","reset","enabled","liveUpdates","filter_1","_liveUpdates","updated","tslib_1.__assign","aggregated","a_elements","previousModels","previousModels_1","toDispose","recordsOrIds","el","splice","notify","removeOne","modelOrId","a_next","Argument","Attributes spec","parsed","parseReference","collectionRef","RecordRefType","masterCollection","getMasterCollection","SubsetOf","subsetOfBehavior","refs","toArray","SubsetOfCollection","resolvedWith","resolveRefs","delaySet","raw","toggle","addAll","master","elements_1","tools.notEqual","Store","store","global","tools.defaults","listenToOnce","DefaultRecord","Model","method","previousBackbone","Backbone","exported","$","jQuery","history","VERSION","View","History","Router","noConflict","_.uniqueId","_.extend","_.pick","viewOptions","_ensureElement","delegateEvents","delegateEventSplitter","routes","_bindRoutes","tagName","selector","$el","render","setElement","element","delegate","undelegateEvents","_.result","_.isFunction","eventName","_.bind","className","optionalParam","namedParam","splatParam","escapeRegExp","checkUrl","location","route","_.isRegExp","_routeToRegExp","router","fragment","_extractParameters","execute","navigate","_.keys","replace","optional","RegExp","params","_.map","param","decodeURIComponent","routeStripper","rootStripper","pathStripper","started","interval","atRoot","pathname","getSearch","matchRoot","decodeFragment","decodeURI","href","getHash","getPath","charAt","getFragment","_usePushState","_wantsHashChange","start","hashChange","_hasHashChange","document","documentMode","_useHashChange","_wantsPushState","pushState","_hasPushState","iframe","createElement","style","display","tabIndex","iWindow","insertBefore","firstChild","contentWindow","open","close","addEventListener","attachEvent","_checkUrlInterval","setInterval","loadUrl","removeEventListener","detachEvent","removeChild","clearInterval","current","_.some","url","title","_updateHash","methodMap","patch","delete","errorPromise","Deferred","ajax","sync","dataType","urlError","contentType","processData","xhr","textStatus","errorThrown","transactionalProto","tools.getBaseClass","RestCollection","_xhr","urlRoot","success","_invalidate","wrapError","_sync","a_model","RestModel","wait","callbackOpts","_this_1","Sync","serverAttrs","_.clone","_.defer","base","encodeURIComponent","always","Mixin","methods","ModelMixin","pick","escape","_.escape","matches","_.iteratee","mapObject","invert","inverted","pairs","chain","_.chain","CollectionMixin","where","findWhere","cb","instance","_.matches","forEach","collect","foldl","inject","reduceRight","foldr","findIndex","findLastIndex","detect","filter","select","any","include","includes","contains","invoke","max","min","size","take","initial","rest","drop","last","without","difference","shuffle","lastIndexOf","sample","partition","groupBy","countBy","sortBy","indexBy","_.each","_","defaultVal","addMethod","RestStore","LazyStore","self_1","_resolved","objsToFetch_1","when","objsToFetch_2","objsToClear_1","Type","TypeR.Messenger","Nested","TypeR","linkProperty","BaseStore","toProps","Namespace","tools.transform"],"mappings":"mQAgBA,IAAIA,EAAgB,SAASC,EAAGC,GAI5B,OAHAF,EAAgBG,OAAOC,gBAClB,CAAEC,UAAW,cAAgBC,OAAS,SAAUL,EAAGC,GAAKD,EAAEI,UAAYH,IACvE,SAAUD,EAAGC,GAAK,IAAK,IAAIK,KAAKL,EAAOA,EAAEM,eAAeD,KAAIN,EAAEM,GAAKL,EAAEK,MACpDN,EAAGC,IAGrB,SAASO,EAAUR,EAAGC,GAEzB,SAASQ,IAAOC,KAAKC,YAAcX,EADnCD,EAAcC,EAAGC,GAEjBD,EAAEY,UAAkB,OAANX,EAAaC,OAAOW,OAAOZ,IAAMQ,EAAGG,UAAYX,EAAEW,UAAW,IAAIH,GAG5E,IAAIK,EAAW,WAQlB,OAPAA,EAAWZ,OAAOa,QAAU,SAAkBC,GAC1C,IAAK,IAAIC,EAAGC,EAAI,EAAGC,EAAIC,UAAUC,OAAQH,EAAIC,EAAGD,IAE5C,IAAK,IAAIZ,KADTW,EAAIG,UAAUF,GACOhB,OAAOU,UAAUL,eAAee,KAAKL,EAAGX,KAAIU,EAAEV,GAAKW,EAAEX,IAE9E,OAAOU,IAEKO,MAAMb,KAAMU,YAGzB,SAASI,EAAOP,EAAGQ,GACtB,IAAIT,EAAI,GACR,IAAK,IAAIV,KAAKW,EAAOf,OAAOU,UAAUL,eAAee,KAAKL,EAAGX,IAAMmB,EAAEC,QAAQpB,GAAK,IAC9EU,EAAEV,GAAKW,EAAEX,IACb,GAAS,MAALW,GAAqD,mBAAjCf,OAAOyB,sBACtB,CAAA,IAAIT,EAAI,EAAb,IAAgBZ,EAAIJ,OAAOyB,sBAAsBV,GAAIC,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":["../src/backbone.ts","../node_modules/tslib/tslib.es6.js","../src/sync.ts","../src/rest.ts","../node_modules/type-r/ext-types/src/dates.ts","../node_modules/type-r/ext-types/src/integer.ts","../node_modules/type-r/ext-types/src/url.ts","../node_modules/type-r/ext-types/src/ip.ts","../node_modules/type-r/ext-types/src/email.ts","../node_modules/type-r/globals/src/index.ts","../src/rest-store.ts","../src/underscore-mixin.ts","../src/index.ts"],"sourcesContent":["/*******\n * Backbone Backward compatibility shim for View, Router, and History.\n * Based on 1.2.3, converted to browser-only ES6 modules thing. \n */\n\n// Backbone.js 1.2.3\n// (c) 2010-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\n// Backbone may be freely distributed under the MIT license.\nimport * as jQuery from 'jquery';\nimport * as _ from 'underscore';\n\n// Initial Setup\n// -------------\ndeclare global {\n interface Window {\n Backbone : any\n }\n\n function attachEvent( a, b );\n function detachEvent( a, b );\n}\n\n// Save the previous value of the `Backbone` variable, so that it can be\n// restored later on, if `noConflict` is used.\nconst previousBackbone = window.Backbone;\n\n// Create a local reference to a common array method we'll want to use later.\nconst slice = Array.prototype.slice;\n\n// For Backbone's purposes, jQuery, Zepto, Ender, or My Library (kidding) owns\n// the `$` variable.\nconst exported = {\n $ : jQuery,\n history : null,\n VERSION : '1.2.3',\n View, History, Router, noConflict\n}\n\nexport default exported;\n\n// Runs Backbone.js in *noConflict* mode, returning the `Backbone` variable\n// to its previous owner. Returns a reference to this Backbone object.\nfunction noConflict() {\n window.Backbone = previousBackbone;\n return this;\n};\n\n// Backbone.View\n// -------------\n\n// Backbone Views are almost more convention than they are actual code. A View\n// is simply a JavaScript object that represents a logical chunk of UI in the\n// DOM. This might be a single item, an entire list, a sidebar or panel, or\n// even the surrounding frame which wraps your whole app. Defining a chunk of\n// UI as a **View** allows you to define your DOM events declaratively, without\n// having to worry about render order ... and makes it easy for the view to\n// react to specific changes in the state of your models.\n\n// Creating a Backbone.View creates its initial element outside of the DOM,\n// if an existing element is not provided...\nexport function View(options) {\n this.cid = _.uniqueId('view');\n options || (options = {});\n _.extend(this, _.pick(options, viewOptions));\n this._ensureElement();\n this.initialize.apply(this, arguments);\n this.delegateEvents();\n};\n\n// Cached regex to split keys for `delegate`.\nvar delegateEventSplitter = /^(\\S+)\\s*(.*)$/;\n\n// List of view options to be merged as properties.\nvar viewOptions = ['model', 'collection', 'el', 'id', 'attributes', 'className', 'tagName', 'events'];\n\n// Set up all inheritable **Backbone.View** properties and methods.\n_.extend(View.prototype, {\n\n // The default `tagName` of a View's element is `\"div\"`.\n tagName: 'div',\n\n // jQuery delegate for element lookup, scoped to DOM elements within the\n // current view. This should be preferred to global lookups where possible.\n $: function (selector) {\n return this.$el.find(selector);\n },\n\n // Initialize is an empty function by default. Override it with your own\n // initialization logic.\n initialize: function () { },\n\n // **render** is the core function that your view should override, in order\n // to populate its element (`this.el`), with the appropriate HTML. The\n // convention is for **render** to always return `this`.\n render: function () {\n return this;\n },\n\n // Remove this view by taking the element out of the DOM, and removing any\n // applicable Backbone.Events listeners.\n remove: function () {\n this.$el.remove();\n this.stopListening();\n return this;\n },\n\n // Change the view's element (`this.el` property), including event\n // re-delegation.\n setElement: function (element, delegate) {\n if (this.$el) this.undelegateEvents();\n this.$el = element instanceof exported.$ ? element : exported.$(element);\n this.el = this.$el[0];\n if (delegate !== false) this.delegateEvents();\n return this;\n },\n\n // Set callbacks, where `this.events` is a hash of\n //\n // *{\"event selector\": \"callback\"}*\n //\n // {\n // 'mousedown .title': 'edit',\n // 'click .button': 'save',\n // 'click .open': function(e) { ... }\n // }\n //\n // pairs. Callbacks will be bound to the view, with `this` set properly.\n // Uses event delegation for efficiency.\n // Omitting the selector binds the event to `this.el`.\n // This only works for delegate-able events: not `focus`, `blur`, and\n // not `change`, `submit`, and `reset` in Internet Explorer.\n delegateEvents: function (events) {\n if (!(events || (events = _.result(this, 'events')))) return this;\n this.undelegateEvents();\n for (var key in events) {\n var method = events[key];\n if (!_.isFunction(method)) method = this[events[key]];\n if (!method) continue;\n\n var match = key.match(delegateEventSplitter);\n var eventName = match[1], selector = match[2];\n method = _.bind(method, this);\n eventName += '.delegateEvents' + this.cid;\n if (selector === '') {\n this.$el.on(eventName, method);\n } else {\n this.$el.on(eventName, selector, method);\n }\n }\n return this;\n },\n\n // Clears all callbacks previously bound to the view with `delegateEvents`.\n // You usually don't need to use this, but may wish to if you have multiple\n // Backbone views attached to the same DOM element.\n undelegateEvents: function () {\n this.$el.off('.delegateEvents' + this.cid);\n return this;\n },\n\n // Ensure that the View has a DOM element to render into.\n // If `this.el` is a string, pass it through `$()`, take the first\n // matching element, and re-assign it to `el`. Otherwise, create\n // an element from the `id`, `className` and `tagName` properties.\n _ensureElement: function () {\n if (!this.el) {\n var attrs = _.extend({}, _.result(this, 'attributes'));\n if (this.id) attrs.id = _.result(this, 'id');\n if (this.className) attrs['class'] = _.result(this, 'className');\n var $el = exported.$('<' + _.result(this, 'tagName') + '>').attr(attrs);\n this.setElement($el, false);\n } else {\n this.setElement(_.result(this, 'el'), false);\n }\n }\n\n});\n\n// Backbone.Router\n// ---------------\n\n// Routers map faux-URLs to actions, and fire events when routes are\n// matched. Creating a new one sets its `routes` hash, if not set statically.\nexport function Router(options) {\n options || (options = {});\n if (options.routes) this.routes = options.routes;\n this._bindRoutes();\n this.initialize.apply(this, arguments);\n}\n\n// Cached regular expressions for matching named param parts and splatted\n// parts of route strings.\nvar optionalParam = /\\((.*?)\\)/g;\nvar namedParam = /(\\(\\?)?:\\w+/g;\nvar splatParam = /\\*\\w+/g;\nvar escapeRegExp = /[\\-{}\\[\\]+?.,\\\\\\^$|#\\s]/g;\n\n// Set up all inheritable **Backbone.Router** properties and methods.\n_.extend(Router.prototype, {\n\n // Initialize is an empty function by default. Override it with your own\n // initialization logic.\n initialize: function () { },\n\n // Manually bind a single named route to a callback. For example:\n //\n // this.route('search/:query/p:num', 'search', function(query, num) {\n // ...\n // });\n //\n route: function (route, name, callback) {\n if (!_.isRegExp(route)) route = this._routeToRegExp(route);\n if (_.isFunction(name)) {\n callback = name;\n name = '';\n }\n if (!callback) callback = this[name];\n var router = this;\n exported.history.route(route, function (fragment) {\n var args = router._extractParameters(route, fragment);\n if (router.execute(callback, args, name) !== false) {\n router.trigger.apply(router, ['route:' + name].concat(args));\n router.trigger('route', name, args);\n exported.history.trigger('route', router, name, args);\n }\n });\n return this;\n },\n\n // Execute a route handler with the provided parameters. This is an\n // excellent place to do pre-route setup or post-route cleanup.\n execute: function (callback, args, name) {\n if (callback) callback.apply(this, args);\n },\n\n // Simple proxy to `Backbone.history` to save a fragment into the history.\n navigate: function (fragment, options) {\n exported.history.navigate(fragment, options);\n return this;\n },\n\n // Bind all defined routes to `Backbone.history`. We have to reverse the\n // order of the routes here to support behavior where the most general\n // routes can be defined at the bottom of the route map.\n _bindRoutes: function () {\n if (!this.routes) return;\n this.routes = _.result(this, 'routes');\n var route, routes = _.keys(this.routes);\n while ((route = routes.pop()) != null) {\n this.route(route, this.routes[route]);\n }\n },\n\n // Convert a route string into a regular expression, suitable for matching\n // against the current location hash.\n _routeToRegExp: function (route) {\n route = route.replace(escapeRegExp, '\\\\$&')\n .replace(optionalParam, '(?:$1)?')\n .replace(namedParam, function (match, optional) {\n return optional ? match : '([^/?]+)';\n })\n .replace(splatParam, '([^?]*?)');\n return new RegExp('^' + route + '(?:\\\\?([\\\\s\\\\S]*))?$');\n },\n\n // Given a route, and a URL fragment that it matches, return the array of\n // extracted decoded parameters. Empty or unmatched parameters will be\n // treated as `null` to normalize cross-browser behavior.\n _extractParameters: function (route, fragment) {\n var params = route.exec(fragment).slice(1);\n return _.map(params, function (param, i) {\n // Don't decode the search params.\n if (i === params.length - 1) return param || null;\n return param ? decodeURIComponent(param) : null;\n });\n }\n\n});\n\n// Backbone.History\n// ----------------\n\n// Handles cross-browser history management, based on either\n// [pushState](http://diveintohtml5.info/history.html) and real URLs, or\n// [onhashchange](https://developer.mozilla.org/en-US/docs/DOM/window.onhashchange)\n// and URL fragments. If the browser supports neither (old IE, natch),\n// falls back to polling.\nexport function History() {\n this.handlers = [];\n this.checkUrl = _.bind(this.checkUrl, this);\n\n // Ensure that `History` can be used outside of the browser.\n if (typeof window !== 'undefined') {\n this.location = window.location;\n this.history = window.history;\n }\n};\n\n// Cached regex for stripping a leading hash/slash and trailing space.\nvar routeStripper = /^[#\\/]|\\s+$/g;\n\n// Cached regex for stripping leading and trailing slashes.\nvar rootStripper = /^\\/+|\\/+$/g;\n\n// Cached regex for stripping urls of hash.\nvar pathStripper = /#.*$/;\n\n// Has the history handling already been started?\n(History as any).started = false;\n\n// Set up all inheritable **Backbone.History** properties and methods.\n_.extend(History.prototype, {\n\n // The default interval to poll for hash changes, if necessary, is\n // twenty times a second.\n interval: 50,\n\n // Are we at the app root?\n atRoot: function () {\n var path = this.location.pathname.replace(/[^\\/]$/, '$&/');\n return path === this.root && !this.getSearch();\n },\n\n // Does the pathname match the root?\n matchRoot: function () {\n var path = this.decodeFragment(this.location.pathname);\n var root = path.slice(0, this.root.length - 1) + '/';\n return root === this.root;\n },\n // Unicode characters in `location.pathname` are percent encoded so they're\n // decoded for comparison. `%25` should not be decoded since it may be part\n // of an encoded parameter.\n decodeFragment: function (fragment) {\n return decodeURI(fragment.replace(/%25/g, '%2525'));\n },\n // In IE6, the hash fragment and search params are incorrect if the\n // fragment contains `?`.\n getSearch: function () {\n var match = this.location.href.replace(/#.*/, '').match(/\\?.+/);\n return match ? match[0] : '';\n },\n // Gets the true hash value. Cannot use location.hash directly due to bug\n // in Firefox where location.hash will always be decoded.\n getHash: function (window) {\n var match = (window || this).location.href.match(/#(.*)$/);\n return match ? match[1] : '';\n },\n\n // Get the pathname and search params, without the root.\n getPath: function () {\n var path = this.decodeFragment(\n this.location.pathname + this.getSearch()\n ).slice(this.root.length - 1);\n return path.charAt(0) === '/' ? path.slice(1) : path;\n },\n\n // Get the cross-browser normalized URL fragment from the path or hash.\n getFragment: function (fragment) {\n if (fragment == null) {\n if (this._usePushState || !this._wantsHashChange) {\n fragment = this.getPath();\n } else {\n fragment = this.getHash();\n }\n }\n return fragment.replace(routeStripper, '');\n },\n\n // Start the hash change handling, returning `true` if the current URL matches\n // an existing route, and `false` otherwise.\n start: function (options) {\n if ((History as any).started) throw new Error('Backbone.history has already been started');\n (History as any).started = true;\n\n // Figure out the initial configuration. Do we need an iframe?\n // Is pushState desired ... is it available?\n this.options = _.extend({ root: '/' }, this.options, options);\n this.root = this.options.root;\n this._wantsHashChange = this.options.hashChange !== false;\n this._hasHashChange = 'onhashchange' in window && ((document as any).documentMode === void 0 || (document as any).documentMode > 7);\n this._useHashChange = this._wantsHashChange && this._hasHashChange;\n this._wantsPushState = !!this.options.pushState;\n this._hasPushState = !!(this.history && this.history.pushState);\n this._usePushState = this._wantsPushState && this._hasPushState;\n this.fragment = this.getFragment();\n\n // Normalize root to always include a leading and trailing slash.\n this.root = ('/' + this.root + '/').replace(rootStripper, '/');\n\n\n\n\n // Transition from hashChange to pushState or vice versa if both are\n // requested.\n if (this._wantsHashChange && this._wantsPushState) {\n\n // If we've started off with a route from a `pushState`-enabled\n // browser, but we're currently in a browser that doesn't support it...\n if (!this._hasPushState && !this.atRoot()) {\n var root = this.root.slice(0, -1) || '/';\n this.location.replace(root + '#' + this.getPath());\n // Return immediately as browser will do redirect to new url\n return true;\n\n // Or if we've started out with a hash-based route, but we're currently\n // in a browser where it could be `pushState`-based instead...\n } else if (this._hasPushState && this.atRoot()) {\n this.navigate(this.getHash(), { replace: true });\n }\n\n }\n\n // Proxy an iframe to handle location events if the browser doesn't\n // support the `hashchange` event, HTML5 history, or the user wants\n // `hashChange` but not `pushState`.\n if (!this._hasHashChange && this._wantsHashChange && !this._usePushState) {\n this.iframe = document.createElement('iframe');\n this.iframe.src = 'javascript:0';\n this.iframe.style.display = 'none';\n this.iframe.tabIndex = -1;\n var body = document.body;\n // Using `appendChild` will throw on IE < 9 if the document is not ready.\n var iWindow = body.insertBefore(this.iframe, body.firstChild).contentWindow;\n iWindow.document.open();\n iWindow.document.close();\n iWindow.location.hash = '#' + this.fragment;\n }\n\n // Add a cross-platform `addEventListener` shim for older browsers.\n var addEventListener = window.addEventListener || function (eventName, listener) {\n return attachEvent('on' + eventName, listener);\n };\n // Depending on whether we're using pushState or hashes, and whether\n // 'onhashchange' is supported, determine how we check the URL state.\n if (this._usePushState) {\n addEventListener('popstate', this.checkUrl, false);\n } else if (this._useHashChange && !this.iframe) {\n addEventListener('hashchange', this.checkUrl, false);\n } else if (this._wantsHashChange) {\n this._checkUrlInterval = setInterval(this.checkUrl, this.interval);\n }\n if (!this.options.silent) return this.loadUrl();\n },\n\n // Disable Backbone.history, perhaps temporarily. Not useful in a real app,\n // but possibly useful for unit testing Routers.\n stop: function () {\n // Add a cross-platform `removeEventListener` shim for older browsers.\n var removeEventListener = window.removeEventListener || function (eventName, listener) {\n return detachEvent('on' + eventName, listener);\n };\n // Remove window listeners.\n if (this._usePushState) {\n removeEventListener('popstate', this.checkUrl, false);\n } else if (this._useHashChange && !this.iframe) {\n removeEventListener('hashchange', this.checkUrl, false);\n }\n // Clean up the iframe if necessary.\n if (this.iframe) {\n document.body.removeChild(this.iframe);\n this.iframe = null;\n }\n // Some environments will throw when clearing an undefined interval.\n if (this._checkUrlInterval) clearInterval(this._checkUrlInterval);\n (History as any).started = false;\n },\n\n // Add a route to be tested when the fragment changes. Routes added later\n // may override previous routes.\n route: function (route, callback) {\n this.handlers.unshift({ route: route, callback: callback });\n },\n\n // Checks the current URL to see if it has changed, and if it has,\n // calls `loadUrl`, normalizing across the hidden iframe.\n checkUrl: function (e) {\n var current = this.getFragment();\n // If the user pressed the back button, the iframe's hash will have\n // changed and we should use that for comparison.\n if (current === this.fragment && this.iframe) {\n current = this.getHash(this.iframe.contentWindow);\n }\n if (current === this.fragment) return false;\n if (this.iframe) this.navigate(current);\n this.loadUrl();\n },\n\n // Attempt to load the current URL fragment. If a route succeeds with a\n // match, returns `true`. If no defined routes matches the fragment,\n // returns `false`.\n loadUrl: function (fragment) {\n // If the root doesn't match, no routes can match either.\n if (!this.matchRoot()) return false;\n fragment = this.fragment = this.getFragment(fragment);\n return _.some(this.handlers, function (handler) {\n if (handler.route.test(fragment)) {\n handler.callback(fragment);\n return true;\n }\n });\n },\n\n // Save a fragment into the hash history, or replace the URL state if the\n // 'replace' option is passed. You are responsible for properly URL-encoding\n // the fragment in advance.\n //\n // The options object can contain `trigger: true` if you wish to have the\n // route callback be fired (not usually desirable), or `replace: true`, if\n // you wish to modify the current URL without adding an entry to the history.\n navigate: function (fragment, options) {\n if (!(History as any).started) return false;\n if (!options || options === true) options = { trigger: !!options };\n\n // Normalize the fragment.\n fragment = this.getFragment(fragment || '');\n\n // Don't include a trailing slash on the root.\n var root = this.root;\n if (fragment === '' || fragment.charAt(0) === '?') {\n root = root.slice(0, -1) || '/';\n }\n var url = root + fragment;\n // Strip the hash and decode for matching.\n fragment = this.decodeFragment(fragment.replace(pathStripper, ''));\n\n if (this.fragment === fragment) return;\n this.fragment = fragment;\n\n\n // If pushState is available, we use it to set the fragment as a real URL.\n if (this._usePushState) {\n this.history[options.replace ? 'replaceState' : 'pushState']({}, document.title, url);\n\n // If hash changes haven't been explicitly disabled, update the hash\n // fragment to store history.\n } else if (this._wantsHashChange) {\n this._updateHash(this.location, fragment, options.replace);\n if (this.iframe && (fragment !== this.getHash(this.iframe.contentWindow))) {\n var iWindow = this.iframe.contentWindow;\n // Opening and closing the iframe tricks IE7 and earlier to push a\n // history entry on hash-tag change. When replace is true, we don't\n // want this.\n if (!options.replace) {\n iWindow.document.open();\n iWindow.document.close();\n }\n\n this._updateHash(iWindow.location, fragment, options.replace);\n }\n\n // If you've told us that you explicitly don't want fallback hashchange-\n // based history, then `navigate` becomes a page refresh.\n } else {\n return this.location.assign(url);\n }\n if (options.trigger) return this.loadUrl(fragment);\n },\n\n // Update the hash location, either replacing the current entry, or adding\n // a new one to the browser history.\n _updateHash: function (location, fragment, replace) {\n if (replace) {\n var href = location.href.replace(/(javascript:|#).*$/, '');\n location.replace(href + '#' + fragment);\n } else {\n // Some browsers require that `hash` contains a leading #.\n location.hash = '#' + fragment;\n }\n }\n\n});\n\n// Create the default Backbone.history.\nexported.history = new History;\n\n","/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation. All rights reserved.\r\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\r\nthis file except in compliance with the License. You may obtain a copy of the\r\nLicense at http://www.apache.org/licenses/LICENSE-2.0\r\n\r\nTHIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r\nKIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED\r\nWARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,\r\nMERCHANTABLITY OR NON-INFRINGEMENT.\r\n\r\nSee the Apache Version 2.0 License for specific language governing permissions\r\nand limitations under the License.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)\r\n t[p[i]] = s[p[i]];\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport function __exportStar(m, exports) {\r\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\r\n}\r\n\r\nexport function __values(o) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator], i = 0;\r\n if (m) return m.call(o);\r\n return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\r\n result.default = mod;\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n","/**\n * Backbone.js 1.2.3 REST implementation\n * (c) 2010-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\n * Backbone may be freely distributed under the MIT license.\n *\n * With validation patches - NestedTypes validation semantic is applied. (c) Vlad Balin, 2015.\n */\nimport * as _ from 'underscore';\nimport Backbone from './backbone';\n\nexport type LazyValue< T > = () => T | T;\n\n// Map from CRUD to HTTP for our default `Backbone.sync` implementation.\nexport type Method = 'create' | 'update' | 'patch' | 'delete' | 'read' \n\nexport interface Restful {\n trigger( event : string, model, xhr, options )\n collection? : { trigger( event : string, model, xhr, options ) }\n toJSON( options : any ) : {}\n _xhr : JQueryXHR\n sync( method : string, object : Restful, options : SyncOptions )\n}\n\nexport interface SyncOptions {\n url? : LazyValue< string >\n data? : any\n attrs? : {}\n beforeSend? : ( xhr ) => any\n\n success? : ( resp : any ) => void\n error? : ( xhr?, textStatus?, errorThrown? ) => void\n\n textStatus? : string\n errorThrown? : any\n xhr? : any\n context? : {}\n}\n\nconst methodMap = {\n 'create' : 'POST',\n 'update' : 'PUT',\n 'patch' : 'PATCH',\n 'delete' : 'DELETE',\n 'read' : 'GET'\n};\n\nconst exported = {\n $ : Backbone.$,\n \n errorPromise : error => {\n var x = $.Deferred();\n x.reject( error );\n return x;\n },\n\n // Set the default implementation of `Backbone.ajax` to proxy through to `$`.\n // Override this if you'd like to use a different library.\n ajax : function( options : {} ){\n return $.ajax.apply( $, arguments );\n },\n\n sync,\n\n // Throw an error when a URL is needed, and none is supplied.\n urlError : function(){\n throw new Error( 'A \"url\" property or function must be specified' );\n }\n};\n\nexport default exported;\n\n // Backbone.sync\n // -------------\n\n // Override this function to change the manner in which Backbone persists\n // models to the server. You will be passed the type of request, and the\n // model in question. By default, makes a RESTful Ajax request\n // to the model's `url()`. Some possible customizations could be:\n //\n // * Use `setTimeout` to batch rapid-fire updates into a single request.\n // * Send up the models as XML instead of JSON.\n // * Persist models via WebSockets instead of Ajax.\n\nfunction sync( method : Method, model : Restful, options : SyncOptions = {} ) : JQueryXHR{\n var type = methodMap[ method ];\n\n // Default JSON-request options.\n var params : any = { type : type, dataType : 'json' };\n\n // Ensure that we have a URL.\n if( !options.url ){\n params.url = _.result( model, 'url' ) || exported.urlError();\n }\n\n // Ensure that we have the appropriate request data.\n if( options.data == null && model && (method === 'create' || method === 'update' || method === 'patch') ){\n params.contentType = 'application/json';\n params.data = JSON.stringify( options.attrs || model.toJSON( options ) );\n }\n\n // Don't process data on a non-GET request.\n if( params.type !== 'GET' ){\n params.processData = false;\n }\n\n // Pass along `textStatus` and `errorThrown` from jQuery.\n var error = options.error;\n options.error = function( xhr, textStatus, errorThrown ){\n options.textStatus = textStatus;\n options.errorThrown = errorThrown;\n if( error ) error.call( options.context, xhr, textStatus, errorThrown );\n };\n\n // Make the request, allowing the user to override any Ajax options.\n var xhr = options.xhr = exported.ajax( _.extend( params, options ) );\n model.trigger( 'request', model, xhr, options );\n model.collection && model.collection.trigger( 'request', model, xhr, options );\n return xhr;\n}","import { Collection, define, definitions, mixinRules, Model, tools } from 'type-r';\nimport * as _ from 'underscore';\nimport Sync, { Restful, SyncOptions } from './sync';\n\nconst { defaults } = tools;\n\nexport interface RestOptions extends SyncOptions {\n wait? : boolean\n patch? : boolean\n reset? : boolean\n validate? : boolean\n}\n\n@define({\n itemEvents : {\n destroy( model ){ this.remove( model ); }\n } \n})\nexport class RestCollection extends Collection implements Restful {\n _xhr : JQueryXHR\n\n dispose(){\n if( this._xhr && this._xhr.abort ) this._xhr.abort();\n super.dispose();\n }\n\n model : typeof RestModel\n url() : string { return this.model.prototype.urlRoot || ''; }\n\n _invalidate( options : { validate? : boolean } ) : boolean {\n var error;\n if( options.validate && ( error = this.validationError ) ){\n this.trigger( 'invalid', this, error, _.extend( { validationError : error }, options ) );\n return true;\n }\n }\n\n // Fetch the default set of models for this collection, resetting the\n // collection when they arrive. If `reset: true` is passed, the response\n // data will be passed through the `reset` method instead of `set`.\n fetch( options : RestOptions ) : any {\n options = _.extend( { parse : true }, options );\n var success = options.success;\n var collection = this;\n options.success = function( resp ){\n var method = options.reset ? 'reset' : 'set';\n collection[ method ]( resp, options );\n if( collection._invalidate( options ) ) return false;\n\n if( success ) success.call( options.context, collection, resp, options );\n collection.trigger( 'sync', collection, resp, options );\n };\n\n wrapError( this, options );\n return _sync( 'read', this, options );\n }\n\n create( a_model, options : any = {} ) : RestModel {\n const model : RestModel = a_model instanceof RestModel ?\n a_model :\n this.model.create( a_model, options );\n\n // Hack! For the situation when model instance is given, aquire it. \n model._owner || ( model._owner = this );\n\n options.wait || this.add([ model ], options );\n\n var collection = this;\n var success = options.success;\n options.success = ( model, resp, callbackOpts ) =>{\n if( options.wait ) this.add( [ model ], defaults({ parse : false }, callbackOpts ) );\n if( success ) success.call( callbackOpts.context, model, resp, callbackOpts );\n };\n\n model.save( null, options );\n return model;\n }\n\n // Proxy `Backbone.sync` by default -- but override this if you need\n // custom syncing semantics for *this* particular model.\n sync(){\n return Sync.sync.apply( this, arguments );\n }\n};\n\nconst modelProto = Model.prototype;\n\n@define({\n urlRoot : ''\n})\n@definitions({\n urlRoot : mixinRules.protoValue\n})\nexport class RestModel extends Model implements Restful {\n static Collection : typeof Collection = RestCollection as any;\n \n _xhr : JQueryXHR\n\n urlRoot : string\n\n /** @private */\n _invalidate( options : { validate? : boolean } ) : boolean {\n var error;\n if( options.validate && ( error = this.validationError ) ){\n triggerAndBubble( this, 'invalid', this, error, _.extend( { validationError : error }, options ) );\n return true;\n }\n }\n\n dispose(){\n if( this._xhr && this._xhr.abort ) this._xhr.abort();\n super.dispose();\n }\n\n // Fetch the model from the server, merging the response with the model's\n // local attributes. Any changed attributes will trigger a \"change\" event.\n fetch( options? : RestOptions ) : any {\n options = _.extend( { parse : true }, options );\n var model = this;\n var success = options.success;\n options.success = function( serverAttrs ){\n model.set( serverAttrs, options );\n if( model._invalidate( options ) ) return false;\n\n if( success ) success.call( options.context, model, serverAttrs, options );\n triggerAndBubble( model, 'sync', model, serverAttrs, options );\n };\n\n wrapError( this, options );\n return _sync( 'read', this, options );\n }\n\n // Proxy `Backbone.sync` by default -- but override this if you need\n // custom syncing semantics for *this* particular model.\n sync( method : string, self : this, options : SyncOptions ) : any\n sync() : JQueryXHR {\n return Sync.sync.apply( this, arguments );\n }\n\n // Set a hash of model attributes, and sync the model to the server.\n // If the server returns an attributes hash that differs, the model's\n // state will be `set` again.\n save( attrs? : {}, options? : RestOptions ) : any\n save( key : string, value : any, options? : RestOptions ) : any\n save( key, val, a_options? : RestOptions ) : any {\n // Handle both `\"key\", value` and `{key: value}` -style arguments.\n let attrs, originalOptions;\n\n if( key == null || typeof key === 'object' ){\n attrs = key;\n originalOptions = val || {};\n }\n else{\n (attrs = {})[ key ] = val;\n originalOptions = a_options || {};\n }\n\n const options = _.extend( { validate : true, parse : true }, originalOptions ),\n wait = options.wait;\n\n // If we're not waiting and attributes exist, save acts as\n // `set(attr).save(null, opts)` with validation. Otherwise, check if\n // the model will be valid when the attributes, if any, are set.\n if( attrs && !wait ){\n this.set( attrs, originalOptions );\n }\n\n if( this._invalidate( options ) ){\n if( attrs && wait ) this.set( attrs, originalOptions );\n return Sync.errorPromise( this.validationError );\n }\n\n // After a successful server-side save, the client is (optionally)\n // updated with the server-side state.\n var model = this;\n var success = options.success;\n var attributes = this.attributes;\n options.success = serverAttrs => {\n // Ensure attributes are restored during synchronous saves.\n model.attributes = attributes;\n if( wait ) serverAttrs = _.extend( {}, attrs, serverAttrs );\n\n if( serverAttrs ){\n // When server sends string, polimorphyc Model set screws up.\n modelProto.set.call( this, serverAttrs, options );\n if( model._invalidate( options ) ) return false;\n }\n\n if( success ) success.call( options.context, model, serverAttrs, options );\n triggerAndBubble( model, 'sync', model, serverAttrs, options );\n };\n\n wrapError( this, options );\n\n // Set temporary attributes if `{wait: true}` to properly find new ids.\n if( attrs && wait ) this.attributes = _.extend( {}, attributes, attrs );\n\n var method = this.isNew() ? 'create' : (options.patch ? 'patch' : 'update');\n if( method === 'patch' && !options.attrs ) options.attrs = attrs;\n var xhr = _sync( method, this, options );\n\n // Restore attributes.\n this.attributes = attributes;\n\n return xhr;\n }\n\n // Destroy this model on the server if it was already persisted.\n // Optimistically removes the model from its collection, if it has one.\n // If `wait: true` is passed, waits for the server to respond before removal.\n destroy( options : RestOptions ) : any {\n options = options ? _.clone( options ) : {};\n var model = this;\n var success = options.success;\n var wait = options.wait;\n\n var destroy = function(){\n model.stopListening(); // TBD: figure out whenever we need to dispose the model.\n model.trigger( 'destroy', model, model.collection, options );\n };\n\n options.success = function( resp ){\n if( wait ) destroy();\n if( success ) success.call( options.context, model, resp, options );\n if( !model.isNew() ) triggerAndBubble( model, 'sync', model, resp, options );\n };\n\n var xhr : JQueryXHR;\n\n if( this.isNew() ){\n _.defer( options.success );\n }\n else{\n wrapError( this, options );\n xhr = _sync( 'delete', this, options );\n }\n\n if( !wait ) destroy();\n \n return xhr || false;\n }\n\n // Default URL for the model's representation on the server -- if you're\n // using Backbone's restful methods, override this to change the endpoint\n // that will be called.\n url() : string {\n var base =\n _.result( this, 'urlRoot' ) ||\n _.result( this.collection, 'url' ) ||\n Sync.urlError();\n\n if( this.isNew() ) return base;\n\n var id = this.get( this.idAttribute );\n\n return base.replace( /[^\\/]$/, '$&/' ) + encodeURIComponent( id );\n }\n\n set( key : string, value : any, options? : object ) : this\n set( attrs : {}, options? : object ) : this\n set( a, b?, c? ) : this {\n if( typeof a === 'string' ){\n if( c ){\n return super.set({ [ a ] : b }, c );\n }\n else{\n this[ a ] = b;\n return this;\n } \n }\n else{\n return super.set( a, b );\n }\n }\n}\n\nfunction _sync( method : string, _this : Restful, options ) : JQueryXHR {\n // Abort and pending IO request. Just one is allowed at the time.\n _this._xhr && _this._xhr.abort && _this._xhr.abort();\n const xhr = _this._xhr = _this.sync( method, _this, options );\n xhr && xhr.always && xhr.always( function(){ _this._xhr = void 0; });\n return xhr;\n}\n\n// Wrap an optional error callback with a fallback error event.\nfunction wrapError( model : any, options : RestOptions ){\n var error = options.error;\n options.error = function( resp ){\n if( error ) error.call( options.context, model, resp, options );\n triggerAndBubble( model, 'error', model, resp, options );\n };\n}\n\nfunction triggerAndBubble( model : any, ...args : any[] ){\n model.trigger.apply( model, args );\n const { collection } = model;\n collection && collection.trigger.apply( collection, args ); \n}","import {DateType, ChainableAttributeSpec, type} from \"type-r\";\n\nconst msDatePattern = /\\/Date\\(([0-9]+)\\)\\//;\n\nexport class MicrosoftDateType extends DateType {\n convert( next ) {\n if( typeof next === 'string' ){\n const msDate = msDatePattern.exec( next );\n if( msDate ){\n return new Date( Number( msDate[ 1 ] ) );\n }\n }\n\n return DateType.prototype.convert.apply( this, arguments );\n }\n\n toJSON( value ) { return value && `/Date(${ value.getTime() })/`; }\n}\n\nexport const MicrosoftDate = new ChainableAttributeSpec({\n type : Date,\n _metatype: MicrosoftDateType\n})\n\nexport const Timestamp = type( Date ).toJSON( x => x && x.getTime() );","import {NumericType} from \"type-r\";\n\nexport function Integer( x ) {\n return x ? Math.round( x ) : 0;\n}\n\n(Integer as any)._metatype = NumericType;\n","import { AttributeCheck, ChainableAttributeSpec, type } from 'type-r';\n\nconst urlPattern = /^(?:(?:https?|ftp):\\/\\/)(?:\\S+(?::\\S*)?@)?(?:(?!(?:10|127)(?:\\.\\d{1,3}){3})(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))\\.?)(?::\\d{2,5})?(?:[/?#]\\S*)?$/i;\n\nexport function isUrl( x : string ) {\n return !x || urlPattern.test( x );\n}\n\n(isUrl as AttributeCheck).error = 'Not valid URL'\n\nexport const Url : ChainableAttributeSpec = type( String ).check( isUrl );","import {type, ChainableAttributeSpec, AttributeCheck} from 'type-r'\n\nconst ipPattern = /^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/;\n\nexport function isIPAddress( x : string ) {\n return !x || ipPattern.test( x );\n}\n\n(isIPAddress as AttributeCheck).error = 'Not valid IP address'\n\nexport const IPAddress : ChainableAttributeSpec = type( String ).check( isIPAddress );","import { AttributeCheck, type } from 'type-r';\n\nconst emailPattern = /^[-a-z0-9~!$%^&*_=+}{\\'?]+(\\.[-a-z0-9~!$%^&*_=+}{\\'?]+)*@([a-z0-9_][-a-z0-9_]*(\\.[-a-z0-9_]+)*\\.(aero|arpa|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|pro|travel|mobi|[a-z][a-z])|([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}))(:[0-9]{1,5})?$/i;\n\nexport function isEmail( x : string ) {\n return !x || !!x.match( emailPattern );\n}\n\n(isEmail as AttributeCheck).error = 'Not valid email';\n\nexport const Email = type( String ).check( isEmail );","import { Integer, MicrosoftDate, Timestamp } from \"type-r/ext-types\";\nimport { type, ChainableAttributeSpec } from \"type-r\";\n\n/*\n * dates\n */\ndeclare global {\n // Legacy has-notation\n interface Function{\n value : ( x : any ) => ChainableAttributeSpec;\n isRequired : ChainableAttributeSpec;\n asProp : PropertyDecorator\n has : ChainableAttributeSpec;\n }\n\n // Date type extensions\n interface DateConstructor {\n microsoft : ChainableAttributeSpec\n timestamp : ChainableAttributeSpec\n }\n\n // Integer type\n interface Window {\n Integer : Function;\n }\n\n interface NumberConstructor {\n integer : typeof Integer\n }\n}\n\nFunction.prototype.value = function( x ) {\n return new ChainableAttributeSpec( { type : this, value : x, hasCustomDefault : true } );\n};\n\nObject.defineProperty( Function.prototype, 'isRequired', {\n get() { return this._isRequired || this.has.isRequired; },\n set( x ){ this._isRequired = x; }\n});\n\nObject.defineProperty( Function.prototype, 'asProp', {\n get() { return this.has.asProp; },\n});\n\nObject.defineProperty( Function.prototype, 'has', {\n get() {\n // workaround for sinon.js and other libraries overriding 'has'\n return this._has || type( this );\n },\n\n set( value ) { this._has = value; }\n} );\n\n\nObject.defineProperties( Date, {\n microsoft: {\n value: MicrosoftDate\n },\n\n timestamp: {\n value: Timestamp\n }\n} );\n\n\n/*\n * integer\n */\n\nNumber.integer = Integer;\n\nif( typeof window !== 'undefined' ) {\n window.Integer = Integer;\n}","import { define, Store } from 'type-r';\nimport \"type-r/globals\";\nimport * as _ from 'underscore';\nimport Backbone from './backbone';\nimport { RestCollection, RestModel } from './rest';\n\n@define({\n getStore : Store.prototype.getStore,\n get : Store.prototype.get,\n})\nexport class RestStore extends RestModel {}\n\n@define\nexport class LazyStore extends RestStore {\n _resolved : {} = {}\n\n initialize(){\n this.forEach( ( element, name ) => {\n if( !element ) return;\n\n element.store = this;\n\n var fetch = element.fetch;\n\n if( fetch ){\n const self = this;\n element.fetch = function() {\n return self._resolved[ name ] = fetch.apply( this, arguments );\n }\n }\n\n if( element instanceof RestCollection && element.length ){\n this._resolved[name] = true;\n }\n });\n }\n\n // fetch specified items, or all items if called without arguments.\n // returns jquery promise\n fetch( ...args : any[] /* hack, inheritance here violates LSP */) : any {\n var xhr = [],\n objsToFetch = args.length ? args : this.keys();\n\n for( let name of objsToFetch ){\n var attr = this.attributes[name];\n attr && attr.fetch && xhr.push( attr.fetch() );\n }\n\n const { $ } = Backbone;\n return $ && $.when && $.when.apply( $, xhr );\n }\n\n // fetch specified items, or all items if called without arguments.\n // returns first jquery promise.\n fetchOnce( ...args : string[] ) : JQueryXHR {\n var xhr = [],\n self = this,\n objsToFetch = args.length ? args : this.keys();\n\n for( let name of objsToFetch ){\n var attr = self.attributes[ name ];\n xhr.push( self._resolved[ name ] || attr && attr.fetch && attr.fetch());\n }\n\n const { $ } = Backbone;\n return $ && $.when && $.when.apply( $, xhr );\n }\n\n clear( ...args : string[] ) : this {\n var objsToClear = args.length ? args : this.keys();\n\n for( let name of objsToClear ){\n var element = this.attributes[ name ];\n\n if( element instanceof RestCollection ){\n element.reset();\n }\n else if( element instanceof Store ){\n element.clear();\n }\n else if( element instanceof RestModel ){\n element.set( element.defaults() )\n }\n\n this._resolved[ name ] = false;\n }\n\n return this;\n }\n\n static onDefine( definitions, BaseClass ){\n var attributes = definitions.defaults || definitions.attributes;\n\n // add automatic fetching on first element's access\n _.each( attributes, ( Type : Function, name ) => {\n if( Type.has ){\n attributes[name] = Type.has\n .set( function( value ){\n if( !value || !value.length ){\n const resolved = this._resolved || ( this._resolved = {} ); \n resolved[name] = false;\n }\n \n return value;\n })\n } \n });\n\n RestModel.onDefine.call( this, definitions, BaseClass );\n }\n} \n ","import * as _ from 'underscore'\nimport { Model, tools } from 'type-r'\n\nexport const ModelMixin = {\n pick( ...args : any[] ){\n return _.pick( this, args );\n },\n\n values( this : Model ){\n return this.keys().map( name => this[ name ] );\n },\n\n each: Model.prototype.forEach,\n\n escape( attr ){\n return _.escape( this[ attr ] );\n },\n\n matches( attrs ){\n return !!_.iteratee( attrs, this )( this );\n },\n\n omit( ...keys : string[] ) : {} {\n return this.mapObject( ( value, key ) => {\n if( keys.indexOf( key ) < 0 ){\n return value;\n }\n });\n },\n\n invert(){\n const inverted = {};\n this.each( ( value, key ) => inverted[ value ] = key );\n return inverted;\n },\n\n pairs(){\n return this.map( ( value, key ) => [ key, value ] );\n },\n\n isEmpty(){\n return !this.values().length;\n },\n\n chain(){\n return _.chain( this.mapObject( x => x ) );\n }\n};\n\nexport const CollectionMixin = {\n where(attrs, first) {\n return this[first ? 'find' : 'filter'](attrs);\n },\n\n findWhere(attrs) {\n return this.where(attrs, true);\n }\n};\n\naddUnderscoreMethods( CollectionMixin, 'models', {\n forEach : 3, each : 3, map : 3, collect : 3, reduce : 4,\n foldl : 4, inject : 4, reduceRight : 4, foldr : 4, find : 3, findIndex : 3, findLastIndex : 3, detect : 3, filter : 3,\n select : 3, reject : 3, every : 3, all : 3, some : 3, any : 3, include : 3, includes : 3,\n contains : 3, invoke : 0, max : 3, min : 3, toArray : 1, size : 1, first : 3,\n head : 3, take : 3, initial : 3, rest : 3, tail : 3, drop : 3, last : 3,\n without : 0, difference : 0, indexOf : 3, shuffle : 1, lastIndexOf : 3,\n isEmpty : 1, chain : 1, sample : 3, partition : 3, groupBy : 3, countBy : 3,\n sortBy : 3, indexBy : 3\n});\n\nfunction addUnderscoreMethods(Mixin, attribute, methods ) {\n _.each(methods, function(length, method) {\n if (_[method]) Mixin[method] = addMethod(length, method, attribute);\n });\n}\n\n// Proxy Backbone class methods to Underscore functions, wrapping the model's\n// `attributes` object or collection's `models` array behind the scenes.\n//\n// collection.filter(function(model) { return model.get('age') > 10 });\n// collection.each(this.addView);\n//\n// `Function#apply` can be slow so we use the method's arg count, if we know it.\nfunction addMethod(length, method, attribute) {\n switch (length) {\n case 1: return function() {\n return _[method](this[attribute]);\n };\n case 2: return function(value) {\n return _[method](this[attribute], value);\n };\n case 3: return function(iteratee, context) {\n var value = this[ attribute ],\n callback = cb(iteratee, this);\n\n return arguments.length > 1 ?\n _[method]( value, callback, context)\n : _[method]( value, callback );\n };\n case 4: return function(iteratee, defaultVal, context) {\n var value = this[ attribute ],\n callback = cb(iteratee, this);\n\n return arguments.length > 1 ?\n _[method]( value, callback, defaultVal, context )\n : _[method](value, callback );\n };\n default: return function( ...args : any[] ) {\n args.unshift(this[attribute]);\n return _[method].apply(_, args);\n };\n }\n}\n\n// Support `collection.sortBy('attr')` and `collection.findWhere({id: 1})`.\nfunction cb(iteratee, instance) {\n switch( typeof iteratee ){\n case 'function' : return iteratee;\n case 'string' : return model => model.get( iteratee );\n case 'object' :\n if( !(iteratee instanceof instance.model )) return _.matches( iteratee ); \n }\n\n return iteratee;\n}","/**\n * Extend Type-R namespace\n */\nimport * as TypeR from 'type-r';\nimport { MixinsState, Store as BaseStore, tools } from 'type-r';\n/**\n * Prepare backbone View, Router, History, and Events.\n */\nimport Backbone from './backbone';\nimport { RestCollection, RestModel } from './rest';\nimport { LazyStore, RestStore } from './rest-store';\nimport Sync from './sync';\nimport { CollectionMixin, ModelMixin } from './underscore-mixin';\nexport * from 'type-r';\nexport * from './backbone';\nexport { Backbone, RestStore, LazyStore, RestCollection as Collection, RestModel as Model };\n\n/**\n * Prepare \n */\n\nexport const Class : typeof TypeR.Messenger = TypeR.Messenger;\n\nconst Nested : typeof TypeR & typeof Backbone = Object.create( TypeR, tools.defaults({\n 'sync' : linkProperty( Sync, 'sync' ),\n 'errorPromise' : linkProperty( Sync, 'errorPromise' ),\n 'ajax' : linkProperty( Sync, 'ajax' ),\n 'history' : linkProperty( Backbone, 'history' ),\n 'store' : linkProperty( BaseStore, 'global' ),\n '$' : {\n get(){ return Backbone.$; },\n set( value ){ (Backbone).$ = (Sync).$ = value; }\n }\n },\n toProps( { Backbone, Class, Model : RestModel, Collection : RestCollection, LazyStore, Store : RestStore, defaults } ),\n toProps( Backbone )\n));\n\nexport default Nested;\n\n\nexport function defaults( x ) : typeof Nested.Record {\n return Nested.Model.defaults( x );\n}\n\n\nMixinsState.get( Nested.Mixable ).merge([ Nested.Events ]);\nNested.Messenger.mixins.populate( Backbone.View, Backbone.Router, Backbone.History );\nNested.Record.mixins.merge([ ModelMixin ]);\nNested.Record.Collection.mixins.merge([ CollectionMixin ]);\n\n/**\n * Local utilities\n */\nfunction linkProperty( Namespace, name ){\n return {\n get(){ return Namespace[ name ]; },\n set( value ){ Namespace[ name ] = value; }\n };\n}\n\nfunction toProps( obj ){\n return tools.transform({}, obj, x => ({ value : x }) );\n} "],"names":["previousBackbone","window","Backbone","exported","$","jQuery","history","VERSION","View","History","Router","noConflict","this","options","cid","_.uniqueId","_.extend","_.pick","viewOptions","_ensureElement","initialize","apply","arguments","delegateEvents","delegateEventSplitter","routes","_bindRoutes","prototype","tagName","selector","$el","find","render","remove","stopListening","setElement","element","delegate","undelegateEvents","el","events","_.result","key","method","_.isFunction","match","eventName","_.bind","on","off","attrs","id","className","attr","optionalParam","namedParam","splatParam","escapeRegExp","handlers","checkUrl","location","route","name","callback","_.isRegExp","_routeToRegExp","router","fragment","args","_extractParameters","execute","trigger","concat","navigate","_.keys","pop","replace","optional","RegExp","params","exec","slice","_.map","param","i","length","decodeURIComponent","routeStripper","rootStripper","pathStripper","started","interval","atRoot","pathname","root","getSearch","matchRoot","decodeFragment","decodeURI","href","getHash","getPath","path","charAt","getFragment","_usePushState","_wantsHashChange","start","Error","hashChange","_hasHashChange","document","documentMode","_useHashChange","_wantsPushState","pushState","_hasPushState","iframe","createElement","src","style","display","tabIndex","body","iWindow","insertBefore","firstChild","contentWindow","open","close","hash","addEventListener","listener","attachEvent","_checkUrlInterval","setInterval","silent","loadUrl","stop","removeEventListener","detachEvent","removeChild","clearInterval","unshift","e","current","_.some","handler","test","url","title","assign","_updateHash","extendStatics","d","b","Object","setPrototypeOf","__proto__","Array","p","hasOwnProperty","__extends","__","constructor","create","__decorate","decorators","target","desc","c","r","getOwnPropertyDescriptor","Reflect","decorate","defineProperty","methodMap","update","patch","delete","read","errorPromise","error","x","Deferred","reject","ajax","sync","model","type","dataType","urlError","data","contentType","JSON","stringify","toJSON","processData","xhr","textStatus","errorThrown","call","context","collection","defaults","tslib_1.__extends","RestCollection","_xhr","abort","_super","dispose","urlRoot","validate","validationError","success","parse","resp","reset","_invalidate","wrapError","_sync","a_model","RestModel","_owner","wait","add","callbackOpts","_this_1","save","Sync","define","itemEvents","destroy","Collection","modelProto","Model","triggerAndBubble","serverAttrs","set","val","a_options","originalOptions","attributes","isNew","_.clone","_.defer","base","get","idAttribute","encodeURIComponent","a","definitions","mixinRules","protoValue","_this","always","_i","msDatePattern","MicrosoftDateType","next","msDate","Date","Number","DateType","convert","value","getTime","MicrosoftDate","ChainableAttributeSpec","_metatype","Timestamp","Integer","Math","round","NumericType","urlPattern","isUrl","String","check","ipPattern","isIPAddress","emailPattern","isEmail","Function","hasCustomDefault","_isRequired","has","isRequired","asProp","_has","defineProperties","microsoft","timestamp","integer","Mixin","attribute","methods","RestStore","getStore","Store","LazyStore","forEach","store","fetch","self_1","_resolved","objsToFetch_1","keys","_a","name_1","push","when","objsToFetch_2","name_2","objsToClear_1","name_3","clear","BaseClass","_.each","Type","onDefine","ModelMixin","pick","values","map","each","escape","_.escape","matches","_.iteratee","omit","mapObject","indexOf","invert","inverted","pairs","isEmpty","chain","_.chain","CollectionMixin","where","first","findWhere","cb","iteratee","instance","_.matches","collect","reduce","foldl","inject","reduceRight","foldr","findIndex","findLastIndex","detect","filter","select","every","all","some","any","include","includes","contains","invoke","max","min","toArray","size","head","take","initial","rest","tail","drop","last","without","difference","shuffle","lastIndexOf","sample","partition","groupBy","countBy","sortBy","indexBy","_","defaultVal","addMethod","Class","TypeR.Messenger","Nested","TypeR","tools","linkProperty","BaseStore","toProps","Namespace","obj","transform","MixinsState","Mixable","merge","Events","Messenger","mixins","populate","Record"],"mappings":"ySAwBA,IAAMA,EAAmBC,OAAOC,SAO1BC,EAAW,CACfC,EAAIC,EACJC,QAAU,KACVC,QAAU,QACVC,OAAMC,UAASC,SAAQC,WAGzB,WAME,OADAV,OAAOC,SAAWF,EACXY,OAgBT,SAAgBJ,EAAKK,GACnBD,KAAKE,IAAMC,WAAW,QACtBF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,OAAGkF,MAAQlF,KAhBpD0N,cAAY1J,IAAKiJ,EAAOU,SAAUC,MAAM,CAAEX,EAAOY,SACjDZ,EAAOa,UAAUC,OAAOC,SAAUrZ,EAASM,KAAMN,EAASQ,OAAQR,EAASO,SAC3E+X,EAAOgB,OAAOF,OAAOH,MAAM,CAAElF,IAC7BuE,EAAOgB,OAAO/K,WAAW6K,OAAOH,MAAM,CAAEhE"} \ No newline at end of file diff --git a/endpoints/attributes/dist/index.js b/endpoints/attributes/dist/index.js deleted file mode 100644 index e773bce..0000000 --- a/endpoints/attributes/dist/index.js +++ /dev/null @@ -1,2 +0,0 @@ -!function(t,o){"object"==typeof exports&&"undefined"!=typeof module?o(exports):"function"==typeof define&&define.amd?define(["exports"],o):o(t.attributesIO={})}(this,function(t){"use strict";function o(){return new e}var e=function(){function t(){}return t.prototype.create=function(t,o){throw new Error("Method is not supported.")},t.prototype.update=function(t,o,e){throw new Error("Method is not supported.")},t.prototype.read=function(t,o,e){var r=e.keys().filter(function(t){return e[t]&&e[t].fetch}).map(function(t){return e[t].fetch(o)}),n=Promise.all(r).then(function(){});return n.abort=function(){r.forEach(function(t){return t.abort&&t.abort()})},n},t.prototype.destroy=function(t,o){throw new Error("Method is not supported.")},t.prototype.list=function(t){throw new Error("Method is not supported.")},t.prototype.subscribe=function(t){},t.prototype.unsubscribe=function(t){},t}();t.create=o,t.attributesIO=o,t.AttributesEndpoint=e,Object.defineProperty(t,"__esModule",{value:!0})}); -//# sourceMappingURL=index.js.map diff --git a/endpoints/attributes/dist/index.js.map b/endpoints/attributes/dist/index.js.map deleted file mode 100644 index 42998ae..0000000 --- a/endpoints/attributes/dist/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { IOEndpoint, IOOptions, IOPromise } from 'type-r'\n\nexport function create(){\n return new AttributesEndpoint();\n}\n\nexport { create as attributesIO };\n\nexport class AttributesEndpoint implements IOEndpoint {\n create( json, options : IOOptions ) : IOPromise {\n throw new Error( 'Method is not supported.' ); \n }\n\n update( id, json, options : IOOptions ) : IOPromise {\n throw new Error( 'Method is not supported.' ); \n }\n\n read( id, options : IOOptions, record ) : IOPromise {\n const names = record.keys().filter( name => record[ name ] && record[ name ].fetch ),\n promises = names.map( name => record[ name ].fetch( options ) ),\n promise : IOPromise = Promise.all( promises ).then( () => {} );\n\n promise.abort = function(){\n promises.forEach( x => x.abort && x.abort() );\n }\n\n return promise;\n }\n\n destroy( id, options : IOOptions ) : IOPromise {\n throw new Error( 'Method is not supported.' ); \n }\n\n list( options? : IOOptions ) : IOPromise {\n throw new Error( 'Method is not supported.' );\n }\n\n subscribe( events ) : any {}\n unsubscribe( events) : any {}\n}\n\ndeclare var Promise;"],"names":["create","AttributesEndpoint","json","options","Error","id","record","promises","keys","filter","name","fetch","map","promise","Promise","all","then","abort","forEach","x","events"],"mappings":"wMAEgBA,IACZ,OAAO,IAAIC,mBAKf,cA+BA,OA9BIA,mBAAA,SAAQC,EAAMC,GACV,MAAM,IAAIC,MAAO,6BAGrBH,mBAAA,SAAQI,EAAIH,EAAMC,GACd,MAAM,IAAIC,MAAO,6BAGrBH,iBAAA,SAAMI,EAAIF,EAAqBG,GAC3B,IACIC,EADUD,EAAOE,OAAOC,OAAQ,SAAAC,GAAQ,OAAAJ,EAAQI,IAAUJ,EAAQI,GAAOC,QACxDC,IAAK,SAAAF,GAAQ,OAAAJ,EAAQI,GAAOC,MAAOR,KACpDU,EAA2BC,QAAQC,IAAKR,GAAWS,KAAM,cAM7D,OAJAH,EAAQI,MAAQ,WACZV,EAASW,QAAS,SAAAC,GAAK,OAAAA,EAAEF,OAASE,EAAEF,WAGjCJ,GAGXZ,oBAAA,SAASI,EAAIF,GACT,MAAM,IAAIC,MAAO,6BAGrBH,iBAAA,SAAME,GACF,MAAM,IAAIC,MAAO,6BAGrBH,sBAAA,SAAWmB,KACXnB,wBAAA,SAAamB"} \ No newline at end of file diff --git a/endpoints/attributes/lib/index.d.ts b/endpoints/attributes/lib/index.d.ts deleted file mode 100644 index b609a30..0000000 --- a/endpoints/attributes/lib/index.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { IOEndpoint, IOOptions, IOPromise } from 'type-r'; -export declare function create(): AttributesEndpoint; -export { create as attributesIO }; -export declare class AttributesEndpoint implements IOEndpoint { - create(json: any, options: IOOptions): IOPromise; - update(id: any, json: any, options: IOOptions): IOPromise; - read(id: any, options: IOOptions, record: any): IOPromise; - destroy(id: any, options: IOOptions): IOPromise; - list(options?: IOOptions): IOPromise; - subscribe(events: any): any; - unsubscribe(events: any): any; -} diff --git a/endpoints/attributes/lib/index.js b/endpoints/attributes/lib/index.js deleted file mode 100644 index ffe324e..0000000 --- a/endpoints/attributes/lib/index.js +++ /dev/null @@ -1,32 +0,0 @@ -export function create() { - return new AttributesEndpoint(); -} -export { create as attributesIO }; -var AttributesEndpoint = (function () { - function AttributesEndpoint() { - } - AttributesEndpoint.prototype.create = function (json, options) { - throw new Error('Method is not supported.'); - }; - AttributesEndpoint.prototype.update = function (id, json, options) { - throw new Error('Method is not supported.'); - }; - AttributesEndpoint.prototype.read = function (id, options, record) { - var names = record.keys().filter(function (name) { return record[name] && record[name].fetch; }), promises = names.map(function (name) { return record[name].fetch(options); }), promise = Promise.all(promises).then(function () { }); - promise.abort = function () { - promises.forEach(function (x) { return x.abort && x.abort(); }); - }; - return promise; - }; - AttributesEndpoint.prototype.destroy = function (id, options) { - throw new Error('Method is not supported.'); - }; - AttributesEndpoint.prototype.list = function (options) { - throw new Error('Method is not supported.'); - }; - AttributesEndpoint.prototype.subscribe = function (events) { }; - AttributesEndpoint.prototype.unsubscribe = function (events) { }; - return AttributesEndpoint; -}()); -export { AttributesEndpoint }; -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/endpoints/attributes/lib/index.js.map b/endpoints/attributes/lib/index.js.map deleted file mode 100644 index 808ca6c..0000000 --- a/endpoints/attributes/lib/index.js.map +++ /dev/null @@ -1 +0,0 @@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,iCAAI,GAAJ,UAAM,OAAoB;QACtB,MAAM,IAAI,KAAK,CAAE,0BAA0B,CAAE,CAAC;IAClD,CAAC;IAED,sCAAS,GAAT,UAAW,MAAM,IAAU,CAAC;IAC5B,wCAAW,GAAX,UAAa,MAAM,IAAS,CAAC;IACjC,yBAAC;AAAD,CAAC,AA/BD,IA+BC"} \ No newline at end of file diff --git a/endpoints/attributes/package.json b/endpoints/attributes/package.json deleted file mode 100644 index a4874da..0000000 --- a/endpoints/attributes/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "attributesIO", - "main": "./dist/index.js", - "jsnext:main": "./lib/index.js", - "module": "./lib/index.js", - "types": "./lib/index.d.ts", - "scripts": { - "build":"../../node_modules/.bin/tsc && ../../node_modules/.bin/rollup --config" - }, - "author": "Vlad Balin", - "license": "MIT" -} - \ No newline at end of file diff --git a/endpoints/attributes/rollup.config.js b/endpoints/attributes/rollup.config.js deleted file mode 100644 index 7d925d1..0000000 --- a/endpoints/attributes/rollup.config.js +++ /dev/null @@ -1,19 +0,0 @@ -import resolve from 'rollup-plugin-node-resolve'; -import { uglify } from 'rollup-plugin-uglify'; -import sourcemaps from 'rollup-plugin-sourcemaps'; - -export default { - input : 'lib/index.js', - - output : { - file : 'dist/index.js', - format : 'umd', - name : 'attributesIO', - sourcemap: true - }, - plugins: [ - resolve(), //for support of `import X from "directory"` rather than verbose `import X from "directory/index"` - sourcemaps(), - uglify() - ] -}; \ No newline at end of file diff --git a/endpoints/attributes/src/index.ts b/endpoints/attributes/src/index.ts deleted file mode 100644 index 3fce12e..0000000 --- a/endpoints/attributes/src/index.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { IOEndpoint, IOOptions, IOPromise } from 'type-r' - -export function create(){ - return new AttributesEndpoint(); -} - -export { create as attributesIO }; - -export class AttributesEndpoint implements IOEndpoint { - create( json, options : IOOptions ) : IOPromise { - throw new Error( 'Method is not supported.' ); - } - - update( id, json, options : IOOptions ) : IOPromise { - throw new Error( 'Method is not supported.' ); - } - - read( id, options : IOOptions, record ) : IOPromise { - const names = record.keys().filter( name => record[ name ] && record[ name ].fetch ), - promises = names.map( name => record[ name ].fetch( options ) ), - promise : IOPromise = Promise.all( promises ).then( () => {} ); - - promise.abort = function(){ - promises.forEach( x => x.abort && x.abort() ); - } - - return promise; - } - - destroy( id, options : IOOptions ) : IOPromise { - throw new Error( 'Method is not supported.' ); - } - - list( options? : IOOptions ) : IOPromise { - throw new Error( 'Method is not supported.' ); - } - - subscribe( events ) : any {} - unsubscribe( events) : any {} -} - -declare var Promise; \ No newline at end of file diff --git a/endpoints/attributes/tsconfig.json b/endpoints/attributes/tsconfig.json deleted file mode 100644 index 671840d..0000000 --- a/endpoints/attributes/tsconfig.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "compilerOptions": { - "target": "es5", - "module":"es6", - "declaration": true, - "importHelpers": true, - "moduleResolution": "node", - "sourceMap": true, - "outDir": "./lib", - "noImplicitAny": false, - "removeComments":true, - "experimentalDecorators": true, - "baseUrl": ".", - "paths" : { - "type-r":[ "../../lib" ] - } - }, - "files":[ - "./src/index.ts" - ] - } \ No newline at end of file diff --git a/endpoints/localStorage/dist/index.js b/endpoints/localStorage/dist/index.js deleted file mode 100644 index 05713f3..0000000 --- a/endpoints/localStorage/dist/index.js +++ /dev/null @@ -1,2 +0,0 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("type-r")):"function"==typeof define&&define.amd?define(["exports","type-r"],e):e(t.localStorageIO={},t.Nested)}(this,function(t,e){"use strict";function o(t){return new r(t)}var r=function(){function t(t){this.key=t}return t.prototype.resolve=function(o){return e.createIOPromise(function(t,e){setTimeout(function(){t(o)},0)})},t.prototype.reject=function(o){return e.createIOPromise(function(t,e){setTimeout(function(){return e(o)},0)})},t.prototype.create=function(t,e){var o=this.index;return o.push(t.id=String(o[0]++)),this.index=o,this.set(t),this.resolve({id:t.id})},t.prototype.set=function(t){localStorage.setItem(this.key+"#"+t.id,JSON.stringify(t))},t.prototype.get=function(t){return JSON.parse(localStorage.getItem(this.key+"#"+t))},t.prototype.update=function(t,e,o){return e.id=t,this.set(e),this.resolve({})},t.prototype.read=function(t,e){var o=this.get(t);return o?this.resolve(o):this.reject("Not found")},t.prototype.destroy=function(e,t){return this.get(e)?(localStorage.removeItem(this.key+"#"+e),this.index=this.index.filter(function(t){return t!==e}),this.resolve({})):this.reject("Not found")},Object.defineProperty(t.prototype,"index",{get:function(){return JSON.parse(localStorage.getItem(this.key))||[0]},set:function(t){localStorage.setItem(this.key,JSON.stringify(t))},enumerable:!0,configurable:!0}),t.prototype.list=function(t){var e=this;this.index;return this.resolve(this.index.slice(1).map(function(t){return e.get(t)}))},t.prototype.subscribe=function(t){},t.prototype.unsubscribe=function(t){},t}();t.create=o,t.localStorageIO=o,t.LocalStorageEndpoint=r,Object.defineProperty(t,"__esModule",{value:!0})}); -//# sourceMappingURL=index.js.map diff --git a/endpoints/localStorage/dist/index.js.map b/endpoints/localStorage/dist/index.js.map deleted file mode 100644 index 47128c4..0000000 --- a/endpoints/localStorage/dist/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { IOEndpoint, IOOptions, IOPromise, createIOPromise } from 'type-r'\n\nexport type Index = number[];\n\nexport function create( key : string ){\n return new LocalStorageEndpoint( key );\n}\n\nexport { create as localStorageIO }\n\nexport class LocalStorageEndpoint implements IOEndpoint {\n constructor( public key : string ){\n }\n\n resolve( value ){\n return createIOPromise( ( resolve, reject ) => {\n setTimeout( () =>{\n resolve( value )\n }, 0 );\n });\n }\n \n reject( value ){\n return createIOPromise( ( resolve, reject ) => {\n setTimeout( () => reject( value ), 0 );\n });\n }\n\n create( json, options : IOOptions ) {\n const { index } = this;\n index.push( json.id = String( ( index[ 0 ] as number )++ ) );\n this.index = index;\n this.set( json );\n return this.resolve({ id : json.id });\n }\n\n set( json ){\n localStorage.setItem( this.key + '#' + json.id, JSON.stringify( json ) );\n }\n\n get( id ){\n return JSON.parse( localStorage.getItem( this.key + '#' + id ) );\n }\n\n update( id, json, options : IOOptions ) {\n json.id = id;\n this.set( json );\n return this.resolve( {} );\n }\n\n read( id, options : IOOptions ){\n const existing = this.get( id );\n return existing ?\n this.resolve( existing ) : \n this.reject( \"Not found\" );\n }\n\n destroy( id, options : IOOptions ){\n const existing = this.get( id );\n if( existing ){\n localStorage.removeItem( this.key + '#' + id );\n this.index = this.index.filter( x => x !== id );\n return this.resolve( {} );\n }\n else{\n return this.reject( \"Not found\" );\n }\n }\n\n get index() : ( string | number )[]{\n return JSON.parse( localStorage.getItem( this.key ) ) || [ 0 ];\n }\n\n set index( x ){\n localStorage.setItem( this.key, JSON.stringify( x ) );\n }\n\n list( options? : IOOptions ) {\n const { index } = this; \n return this.resolve( this.index.slice( 1 ).map( id => this.get( id ) ) );\n }\n\n subscribe( events ) : any {}\n unsubscribe( events) : any {}\n}"],"names":["create","key","LocalStorageEndpoint","this","value","createIOPromise","resolve","reject","setTimeout","json","options","index","push","id","String","set","localStorage","setItem","JSON","stringify","parse","getItem","existing","get","removeItem","filter","x","Object","slice","map","_this","events"],"mappings":"gPAIgBA,EAAQC,GACpB,OAAO,IAAIC,EAAsBD,oBAMjC,WAAoBA,GAAAE,SAAAF,EAyExB,OAtEIC,oBAAA,SAASE,GACL,OAAOC,kBAAiB,SAAEC,EAASC,GAC/BC,WAAY,WACRF,EAASF,IACV,MAIXF,mBAAA,SAAQE,GACJ,OAAOC,kBAAiB,SAAEC,EAASC,GAC/BC,WAAY,WAAM,OAAAD,EAAQH,IAAS,MAI3CF,mBAAA,SAAQO,EAAMC,GACF,IAAAC,aAIR,OAHAA,EAAMC,KAAMH,EAAKI,GAAKC,OAAUH,EAAO,OACvCR,KAAKQ,MAAQA,EACbR,KAAKY,IAAKN,GACHN,KAAKG,QAAQ,CAAEO,GAAKJ,EAAKI,MAGpCX,gBAAA,SAAKO,GACDO,aAAaC,QAASd,KAAKF,IAAM,IAAMQ,EAAKI,GAAIK,KAAKC,UAAWV,KAGpEP,gBAAA,SAAKW,GACD,OAAOK,KAAKE,MAAOJ,aAAaK,QAASlB,KAAKF,IAAM,IAAMY,KAG9DX,mBAAA,SAAQW,EAAIJ,EAAMC,GAGd,OAFAD,EAAKI,GAAKA,EACVV,KAAKY,IAAKN,GACHN,KAAKG,QAAS,KAGzBJ,iBAAA,SAAMW,EAAIH,GACN,IAAMY,EAAWnB,KAAKoB,IAAKV,GAC3B,OAAOS,EACHnB,KAAKG,QAASgB,GACdnB,KAAKI,OAAQ,cAGrBL,oBAAA,SAASW,EAAIH,GAET,OADiBP,KAAKoB,IAAKV,IAEvBG,aAAaQ,WAAYrB,KAAKF,IAAM,IAAMY,GAC1CV,KAAKQ,MAAQR,KAAKQ,MAAMc,OAAQ,SAAAC,GAAK,OAAAA,IAAMb,IACpCV,KAAKG,QAAS,KAGdH,KAAKI,OAAQ,cAI5BoB,sBAAIzB,yBAAJ,WACI,OAAOgB,KAAKE,MAAOJ,aAAaK,QAASlB,KAAKF,OAAW,CAAE,QAG/D,SAAWyB,GACPV,aAAaC,QAASd,KAAKF,IAAKiB,KAAKC,UAAWO,qCAGpDxB,iBAAA,SAAMQ,GAAN,sBAEI,OAAOP,KAAKG,QAASH,KAAKQ,MAAMiB,MAAO,GAAIC,IAAK,SAAAhB,GAAM,OAAAiB,EAAKP,IAAKV,OAGpEX,sBAAA,SAAW6B,KACX7B,wBAAA,SAAa6B"} \ No newline at end of file diff --git a/endpoints/localStorage/lib/index.d.ts b/endpoints/localStorage/lib/index.d.ts deleted file mode 100644 index fc903e4..0000000 --- a/endpoints/localStorage/lib/index.d.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { IOEndpoint, IOOptions, IOPromise } from 'type-r'; -export declare type Index = number[]; -export declare function create(key: string): LocalStorageEndpoint; -export { create as localStorageIO }; -export declare class LocalStorageEndpoint implements IOEndpoint { - key: string; - constructor(key: string); - resolve(value: any): IOPromise; - reject(value: any): IOPromise; - create(json: any, options: IOOptions): IOPromise; - set(json: any): void; - get(id: any): any; - update(id: any, json: any, options: IOOptions): IOPromise; - read(id: any, options: IOOptions): IOPromise; - destroy(id: any, options: IOOptions): IOPromise; - index: (string | number)[]; - list(options?: IOOptions): IOPromise; - subscribe(events: any): any; - unsubscribe(events: any): any; -} diff --git a/endpoints/localStorage/lib/index.js b/endpoints/localStorage/lib/index.js deleted file mode 100644 index be38960..0000000 --- a/endpoints/localStorage/lib/index.js +++ /dev/null @@ -1,77 +0,0 @@ -import { createIOPromise } from 'type-r'; -export function create(key) { - return new LocalStorageEndpoint(key); -} -export { create as localStorageIO }; -var LocalStorageEndpoint = (function () { - function LocalStorageEndpoint(key) { - this.key = key; - } - LocalStorageEndpoint.prototype.resolve = function (value) { - return createIOPromise(function (resolve, reject) { - setTimeout(function () { - resolve(value); - }, 0); - }); - }; - LocalStorageEndpoint.prototype.reject = function (value) { - return createIOPromise(function (resolve, reject) { - setTimeout(function () { return reject(value); }, 0); - }); - }; - LocalStorageEndpoint.prototype.create = function (json, options) { - var index = this.index; - index.push(json.id = String(index[0]++)); - this.index = index; - this.set(json); - return this.resolve({ id: json.id }); - }; - LocalStorageEndpoint.prototype.set = function (json) { - localStorage.setItem(this.key + '#' + json.id, JSON.stringify(json)); - }; - LocalStorageEndpoint.prototype.get = function (id) { - return JSON.parse(localStorage.getItem(this.key + '#' + id)); - }; - LocalStorageEndpoint.prototype.update = function (id, json, options) { - json.id = id; - this.set(json); - return this.resolve({}); - }; - LocalStorageEndpoint.prototype.read = function (id, options) { - var existing = this.get(id); - return existing ? - this.resolve(existing) : - this.reject("Not found"); - }; - LocalStorageEndpoint.prototype.destroy = function (id, options) { - var existing = this.get(id); - if (existing) { - localStorage.removeItem(this.key + '#' + id); - this.index = this.index.filter(function (x) { return x !== id; }); - return this.resolve({}); - } - else { - return this.reject("Not found"); - } - }; - Object.defineProperty(LocalStorageEndpoint.prototype, "index", { - get: function () { - return JSON.parse(localStorage.getItem(this.key)) || [0]; - }, - set: function (x) { - localStorage.setItem(this.key, JSON.stringify(x)); - }, - enumerable: true, - configurable: true - }); - LocalStorageEndpoint.prototype.list = function (options) { - var _this = this; - var index = this.index; - return this.resolve(this.index.slice(1).map(function (id) { return _this.get(id); })); - }; - LocalStorageEndpoint.prototype.subscribe = function (events) { }; - LocalStorageEndpoint.prototype.unsubscribe = function (events) { }; - return LocalStorageEndpoint; -}()); -export { LocalStorageEndpoint }; -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/endpoints/localStorage/lib/index.js.map b/endpoints/localStorage/lib/index.js.map deleted file mode 100644 index c59ee9f..0000000 --- a/endpoints/localStorage/lib/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,eAAe,EAAE,MAAM,QAAQ,CAAA;AAI1E,MAAM,UAAU,MAAM,CAAE,GAAY;IAChC,OAAO,IAAI,oBAAoB,CAAE,GAAG,CAAE,CAAC;AAC3C,CAAC;AAED,OAAO,EAAE,MAAM,IAAI,cAAc,EAAE,CAAA;AAEnC;IACI,8BAAoB,GAAY;QAAZ,QAAG,GAAH,GAAG,CAAS;IAChC,CAAC;IAED,sCAAO,GAAP,UAAS,KAAK;QACV,OAAO,eAAe,CAAE,UAAE,OAAO,EAAE,MAAM;YACrC,UAAU,CAAE;gBACR,OAAO,CAAE,KAAK,CAAE,CAAA;YACpB,CAAC,EAAE,CAAC,CAAE,CAAC;QACX,CAAC,CAAC,CAAC;IACP,CAAC;IAED,qCAAM,GAAN,UAAQ,KAAK;QACT,OAAO,eAAe,CAAE,UAAE,OAAO,EAAE,MAAM;YACrC,UAAU,CAAE,cAAM,OAAA,MAAM,CAAE,KAAK,CAAE,EAAf,CAAe,EAAE,CAAC,CAAE,CAAC;QAC3C,CAAC,CAAC,CAAC;IACP,CAAC;IAED,qCAAM,GAAN,UAAQ,IAAI,EAAE,OAAmB;QACrB,IAAA,kBAAK,CAAU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AC;QAChC,IAAI,QAAQ,EAAE;YACV,YAAY,CAAC,UAAU,CAAE,IAAI,CAAC,GAAG,GAAG,GAAG,GAAG,EAAE,CAAE,CAAC;YAC/C,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAE,UAAA,CAAC,IAAI,OAAA,CAAC,KAAK,EAAE,EAAR,CAAQ,CAAE,CAAC;YAChD,OAAO,IAAI,CAAC,OAAO,CAAE,EAAE,CAAE,CAAC;SAC7B;aACG;YACA,OAAO,IAAI,CAAC,MAAM,CAAE,WAAW,CAAE,CAAC;SACrC;IACL,CAAC;IAED,sBAAI,uCAAK;aAAT;YACI,OAAO,IAAI,CAAC,KAAK,CAAE,YAAY,CAAC,OAAO,CAAE,IAAI,CAAC,GAAG,CAAE,CAAE,IAAI,CAAE,CAAC,CAAE,CAAC;QACnE,CAAC;aAED,UAAW,CAAC;YACR,YAAY,CAAC,OAAO,CAAE,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAE,CAAC,CAAE,CAAE,CAAC;QAC1D,CAAC;;;OAJA;IAMD,mCAAI,GAAJ,UAAM,OAAoB;QAA1B,iBAGC;QAFW,IAAA,kBAAK,CAAU;QACvB,OAAO,IAAI,CAAC,OAAO,CAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAE,CAAC,CAAE,CAAC,GAAG,CAAE,UAAA,EAAE,IAAI,OAAA,KAAI,CAAC,GAAG,CAAE,EAAE,CAAE,EAAd,CAAc,CAAE,CAAE,CAAC;IAC7E,CAAC;IAED,wCAAS,GAAT,UAAW,MAAM,IAAU,CAAC;IAC5B,0CAAW,GAAX,UAAa,MAAM,IAAS,CAAC;IACjC,2BAAC;AAAD,CAAC,AA1ED,IA0EC"} \ No newline at end of file diff --git a/endpoints/localStorage/package.json b/endpoints/localStorage/package.json deleted file mode 100644 index 1d5d208..0000000 --- a/endpoints/localStorage/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "localStorageIO", - "main": "./dist/index.js", - "jsnext:main": "./lib/index.js", - "module": "./lib/index.js", - "types": "./lib/index.d.ts", - "scripts": { - "build":"../../node_modules/.bin/tsc && ../../node_modules/.bin/rollup --config" - }, - "author": "Vlad Balin", - "license": "MIT" -} - \ No newline at end of file diff --git a/endpoints/localStorage/rollup.config.js b/endpoints/localStorage/rollup.config.js deleted file mode 100644 index 5d87a27..0000000 --- a/endpoints/localStorage/rollup.config.js +++ /dev/null @@ -1,23 +0,0 @@ -import resolve from 'rollup-plugin-node-resolve'; -import { uglify } from 'rollup-plugin-uglify'; -import sourcemaps from 'rollup-plugin-sourcemaps'; - -export default { - input : 'lib/index.js', - external : "type-r", - - output : { - file : 'dist/index.js', - format : 'umd', - name : 'localStorageIO', - sourcemap: true, - globals : { - "type-r":"Nested" - } - }, - plugins: [ - resolve(), //for support of `import X from "directory"` rather than verbose `import X from "directory/index"` - sourcemaps(), - uglify() - ] -}; \ No newline at end of file diff --git a/endpoints/localStorage/src/index.ts b/endpoints/localStorage/src/index.ts deleted file mode 100644 index d024c3c..0000000 --- a/endpoints/localStorage/src/index.ts +++ /dev/null @@ -1,85 +0,0 @@ -import { IOEndpoint, IOOptions, IOPromise, createIOPromise } from 'type-r' - -export type Index = number[]; - -export function create( key : string ){ - return new LocalStorageEndpoint( key ); -} - -export { create as localStorageIO } - -export class LocalStorageEndpoint implements IOEndpoint { - constructor( public key : string ){ - } - - resolve( value ){ - return createIOPromise( ( resolve, reject ) => { - setTimeout( () =>{ - resolve( value ) - }, 0 ); - }); - } - - reject( value ){ - return createIOPromise( ( resolve, reject ) => { - setTimeout( () => reject( value ), 0 ); - }); - } - - create( json, options : IOOptions ) { - const { index } = this; - index.push( json.id = String( ( index[ 0 ] as number )++ ) ); - this.index = index; - this.set( json ); - return this.resolve({ id : json.id }); - } - - set( json ){ - localStorage.setItem( this.key + '#' + json.id, JSON.stringify( json ) ); - } - - get( id ){ - return JSON.parse( localStorage.getItem( this.key + '#' + id ) ); - } - - update( id, json, options : IOOptions ) { - json.id = id; - this.set( json ); - return this.resolve( {} ); - } - - read( id, options : IOOptions ){ - const existing = this.get( id ); - return existing ? - this.resolve( existing ) : - this.reject( "Not found" ); - } - - destroy( id, options : IOOptions ){ - const existing = this.get( id ); - if( existing ){ - localStorage.removeItem( this.key + '#' + id ); - this.index = this.index.filter( x => x !== id ); - return this.resolve( {} ); - } - else{ - return this.reject( "Not found" ); - } - } - - get index() : ( string | number )[]{ - return JSON.parse( localStorage.getItem( this.key ) ) || [ 0 ]; - } - - set index( x ){ - localStorage.setItem( this.key, JSON.stringify( x ) ); - } - - list( options? : IOOptions ) { - const { index } = this; - return this.resolve( this.index.slice( 1 ).map( id => this.get( id ) ) ); - } - - subscribe( events ) : any {} - unsubscribe( events) : any {} -} \ No newline at end of file diff --git a/endpoints/localStorage/tsconfig.json b/endpoints/localStorage/tsconfig.json deleted file mode 100644 index 671840d..0000000 --- a/endpoints/localStorage/tsconfig.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "compilerOptions": { - "target": "es5", - "module":"es6", - "declaration": true, - "importHelpers": true, - "moduleResolution": "node", - "sourceMap": true, - "outDir": "./lib", - "noImplicitAny": false, - "removeComments":true, - "experimentalDecorators": true, - "baseUrl": ".", - "paths" : { - "type-r":[ "../../lib" ] - } - }, - "files":[ - "./src/index.ts" - ] - } \ No newline at end of file diff --git a/endpoints/memory/dist/index.js b/endpoints/memory/dist/index.js deleted file mode 100644 index 0deb6e0..0000000 --- a/endpoints/memory/dist/index.js +++ /dev/null @@ -1,2 +0,0 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("type-r")):"function"==typeof define&&define.amd?define(["exports","type-r"],e):e(t.memoryIO={},t.Nested)}(this,function(t,e){"use strict";function i(t,e){return void 0===t&&(t=[]),void 0===e&&(e=50),new r(t,e)}var r=function(){function t(t,e){this.delay=e,this.index=[0],this.items={};for(var i=0,r=t;i {\n setTimeout( () => resolve( value ), this.delay );\n });\n }\n \n reject( value ){\n return createIOPromise( ( resolve, reject ) => {\n setTimeout( () => reject( value ), this.delay );\n });\n }\n\n constructor( init : object[], public delay : number ){\n for( let obj of init ){\n this.create( obj, {} );\n }\n }\n\n index : Index = [ 0 ];\n items = {};\n\n generateId( a_id ){\n // Update index counter...\n const id = Number( a_id );\n if( !isNaN( id ) ){\n this.index[ 0 ] = Math.max( this.index[ 0 ] as number, id );\n }\n\n // Return id...\n return a_id || String( ( this.index[ 0 ] as number ) ++ );\n }\n\n create( json, options ) {\n const id = json.id = this.generateId( json.id );\n this.index.push( id );\n this.items[ id ] = json;\n return this.resolve({ id });\n }\n\n update( id, json, options ) {\n this.items[ id ] = json;\n return this.resolve( {} );\n }\n\n read( id, options ){\n const existing = this.items[ id ];\n return existing ?\n this.resolve( existing ) : \n this.reject( \"Not found\" );\n }\n\n destroy( id, options ){\n const existing = this.items[ id ];\n if( existing ){\n delete this.items[ id ];\n this.index = this.index.filter( x => x !== id );\n return this.resolve( {} );\n }\n else{\n return this.reject( \"Not found\" );\n }\n }\n\n list( options? : object ) {\n return this.resolve( this.index.slice( 1 ).map( id => this.items[ id ]) );\n }\n\n subscribe( events ) : any {}\n unsubscribe( events) : any {}\n}"],"names":["create","init","delay","MemoryEndpoint","this","init_1","_i","obj","value","createIOPromise","resolve","reject","setTimeout","_this","a_id","id","Number","isNaN","index","Math","max","String","json","options","generateId","push","items","existing","filter","x","slice","map","events"],"mappings":"0OAIgBA,EAAQC,EAAWC,GAC/B,oBADoBD,mBAAWC,MACxB,IAAIC,EAAgBF,EAAMC,oBAkBjC,WAAaD,EAAwBC,GAAAE,WAAAF,EAMrCE,WAAgB,CAAE,GAClBA,WAAQ,GANJ,IAAgB,QAAAC,IAAAC,WAAAA,IAAM,CAAjB,IAAIC,OACLH,KAAKJ,OAAQO,EAAK,KAuD9B,OArEIJ,oBAAA,SAASK,GAAT,WACI,OAAOC,kBAAiB,SAAEC,EAASC,GAC/BC,WAAY,WAAM,OAAAF,EAASF,IAASK,EAAKX,UAIjDC,mBAAA,SAAQK,GAAR,WACI,OAAOC,kBAAiB,SAAEC,EAASC,GAC/BC,WAAY,WAAM,OAAAD,EAAQH,IAASK,EAAKX,UAahDC,uBAAA,SAAYW,GAER,IAAMC,EAAKC,OAAQF,GAMnB,OALKG,MAAOF,KACRX,KAAKc,MAAO,GAAMC,KAAKC,IAAKhB,KAAKc,MAAO,GAAeH,IAIpDD,GAAQO,OAAUjB,KAAKc,MAAO,OAGzCf,mBAAA,SAAQmB,EAAMC,GACV,IAAMR,EAAKO,EAAKP,GAAKX,KAAKoB,WAAYF,EAAKP,IAG3C,OAFAX,KAAKc,MAAMO,KAAMV,GACjBX,KAAKsB,MAAOX,GAAOO,EACZlB,KAAKM,QAAQ,CAAEK,QAG1BZ,mBAAA,SAAQY,EAAIO,EAAMC,GAEd,OADAnB,KAAKsB,MAAOX,GAAOO,EACZlB,KAAKM,QAAS,KAGzBP,iBAAA,SAAMY,EAAIQ,GACN,IAAMI,EAAWvB,KAAKsB,MAAOX,GAC7B,OAAOY,EACHvB,KAAKM,QAASiB,GACdvB,KAAKO,OAAQ,cAGrBR,oBAAA,SAASY,EAAIQ,GAET,OADiBnB,KAAKsB,MAAOX,WAElBX,KAAKsB,MAAOX,GACnBX,KAAKc,MAAQd,KAAKc,MAAMU,OAAQ,SAAAC,GAAK,OAAAA,IAAMd,IACpCX,KAAKM,QAAS,KAGdN,KAAKO,OAAQ,cAI5BR,iBAAA,SAAMoB,GAAN,WACI,OAAOnB,KAAKM,QAASN,KAAKc,MAAMY,MAAO,GAAIC,IAAK,SAAAhB,GAAM,OAAAF,EAAKa,MAAOX,OAGtEZ,sBAAA,SAAW6B,KACX7B,wBAAA,SAAa6B"} \ No newline at end of file diff --git a/endpoints/memory/lib/index.d.ts b/endpoints/memory/lib/index.d.ts deleted file mode 100644 index 70233f1..0000000 --- a/endpoints/memory/lib/index.d.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { IOEndpoint, IOPromise } from 'type-r'; -export declare type Index = (number | string)[]; -export declare function create(init?: any[], delay?: number): MemoryEndpoint; -export { create as memoryIO }; -export declare class MemoryEndpoint implements IOEndpoint { - delay: number; - resolve(value: any): IOPromise; - reject(value: any): IOPromise; - constructor(init: object[], delay: number); - index: Index; - items: {}; - generateId(a_id: any): any; - create(json: any, options: any): IOPromise; - update(id: any, json: any, options: any): IOPromise; - read(id: any, options: any): IOPromise; - destroy(id: any, options: any): IOPromise; - list(options?: object): IOPromise; - subscribe(events: any): any; - unsubscribe(events: any): any; -} diff --git a/endpoints/memory/lib/index.js b/endpoints/memory/lib/index.js deleted file mode 100644 index 6576c3b..0000000 --- a/endpoints/memory/lib/index.js +++ /dev/null @@ -1,73 +0,0 @@ -import { createIOPromise } from 'type-r'; -export function create(init, delay) { - if (init === void 0) { init = []; } - if (delay === void 0) { delay = 50; } - return new MemoryEndpoint(init, delay); -} -export { create as memoryIO }; -var MemoryEndpoint = (function () { - function MemoryEndpoint(init, delay) { - this.delay = delay; - this.index = [0]; - this.items = {}; - for (var _i = 0, init_1 = init; _i < init_1.length; _i++) { - var obj = init_1[_i]; - this.create(obj, {}); - } - } - MemoryEndpoint.prototype.resolve = function (value) { - var _this = this; - return createIOPromise(function (resolve, reject) { - setTimeout(function () { return resolve(value); }, _this.delay); - }); - }; - MemoryEndpoint.prototype.reject = function (value) { - var _this = this; - return createIOPromise(function (resolve, reject) { - setTimeout(function () { return reject(value); }, _this.delay); - }); - }; - MemoryEndpoint.prototype.generateId = function (a_id) { - var id = Number(a_id); - if (!isNaN(id)) { - this.index[0] = Math.max(this.index[0], id); - } - return a_id || String(this.index[0]++); - }; - MemoryEndpoint.prototype.create = function (json, options) { - var id = json.id = this.generateId(json.id); - this.index.push(id); - this.items[id] = json; - return this.resolve({ id: id }); - }; - MemoryEndpoint.prototype.update = function (id, json, options) { - this.items[id] = json; - return this.resolve({}); - }; - MemoryEndpoint.prototype.read = function (id, options) { - var existing = this.items[id]; - return existing ? - this.resolve(existing) : - this.reject("Not found"); - }; - MemoryEndpoint.prototype.destroy = function (id, options) { - var existing = this.items[id]; - if (existing) { - delete this.items[id]; - this.index = this.index.filter(function (x) { return x !== id; }); - return this.resolve({}); - } - else { - return this.reject("Not found"); - } - }; - MemoryEndpoint.prototype.list = function (options) { - var _this = this; - return this.resolve(this.index.slice(1).map(function (id) { return _this.items[id]; })); - }; - MemoryEndpoint.prototype.subscribe = function (events) { }; - MemoryEndpoint.prototype.unsubscribe = function (events) { }; - return MemoryEndpoint; -}()); -export { MemoryEndpoint }; -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/endpoints/memory/lib/index.js.map b/endpoints/memory/lib/index.js.map deleted file mode 100644 index 9722c43..0000000 --- a/endpoints/memory/lib/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,eAAe,EAAE,MAAM,QAAQ,CAAA;AAI/D,MAAM,UAAU,MAAM,CAAE,IAAS,EAAE,KAAU;IAArB,qBAAA,EAAA,SAAS;IAAE,sBAAA,EAAA,UAAU;IACzC,OAAO,IAAI,cAAc,CAAE,IAAI,EAAE,KAAK,CAAE,CAAC;AAC7C,CAAC;AAED,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,CAAC;AAE9B;IAaI,wBAAa,IAAe,EAAS,KAAc;QAAd,UAAK,GAAL,KAAK,CAAS;QAMnD,UAAK,GAAW,CAAE,CAAC,CAAE,CAAC;QACtB,UAAK,GAAG,EAAE,CAAC;QANP,KAAgB,UAAI,EAAJ,aAAI,EAAJ,kBAAI,EAAJ,IAAI,EAAE;YAAjB,IAAI,GAAG,aAAA;YACR,IAAI,CAAC,MAAM,CAAE,GAAG,EAAE,EAAE,CAAE,CAAC;SAC1B;IACL,CAAC;IAhBD,gCAAO,GAAP,UAAS,KAAK;QAAd,iBAIC;QAHG,OAAO,eAAe,CAAE,UAAE,OAAO,EAAE,MAAM;YACrC,UAAU,CAAE,cAAM,OAA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,CAAC;IAC9B,CAAC;IAED,6BAAI,GAAJ,UAAM,EAAE,EAAE,OAAO;QACb,IAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAE,EAAE,CAAE,CAAC;QAClC,OAAO,QAAQ,CAAC,CAAC;YACb,IAAI,CAAC,OAAO,CAAE,QAAQ,CAAE,CAAC,CAAC;YAC1B,IAAI,CAAC,MAAM,CAAE,WAAW,CAAE,CAAC;IACnC,CAAC;IAED,gCAAO,GAAP,UAAS,EAAE,EAAE,OAAO;QAChB,IAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAE,EAAE,CAAE,CAAC;QAClC,IAAI,QAAQ,EAAE;YACV,OAAO,IAAI,CAAC,KAAK,CAAE,EAAE,CAAE,CAAC;YACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAE,UAAA,CAAC,IAAI,OAAA,CAAC,KAAK,EAAE,EAAR,CAAQ,CAAE,CAAC;YAChD,OAAO,IAAI,CAAC,OAAO,CAAE,EAAE,CAAE,CAAC;SAC7B;aACG;YACA,OAAO,IAAI,CAAC,MAAM,CAAE,WAAW,CAAE,CAAC;SACrC;IACL,CAAC;IAED,6BAAI,GAAJ,UAAM,OAAiB;QAAvB,iBAEC;QADG,OAAO,IAAI,CAAC,OAAO,CAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAE,CAAC,CAAE,CAAC,GAAG,CAAE,UAAA,EAAE,IAAI,OAAA,KAAI,CAAC,KAAK,CAAE,EAAE,CAAE,EAAhB,CAAgB,CAAC,CAAE,CAAC;IAC9E,CAAC;IAED,kCAAS,GAAT,UAAW,MAAM,IAAU,CAAC;IAC5B,oCAAW,GAAX,UAAa,MAAM,IAAS,CAAC;IACjC,qBAAC;AAAD,CAAC,AAtED,IAsEC"} \ No newline at end of file diff --git a/endpoints/memory/package.json b/endpoints/memory/package.json deleted file mode 100644 index 4696909..0000000 --- a/endpoints/memory/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "memoryIO", - "main": "./dist/index.js", - "jsnext:main": "./lib/index.js", - "module": "./lib/index.js", - "types": "./lib/index.d.ts", - "scripts": { - "build":"../../node_modules/.bin/tsc && ../../node_modules/.bin/rollup --config" - }, - "author": "Vlad Balin", - "license": "MIT" -} - \ No newline at end of file diff --git a/endpoints/memory/rollup.config.js b/endpoints/memory/rollup.config.js deleted file mode 100644 index 12452a1..0000000 --- a/endpoints/memory/rollup.config.js +++ /dev/null @@ -1,23 +0,0 @@ -import resolve from 'rollup-plugin-node-resolve'; -import { uglify } from 'rollup-plugin-uglify'; -import sourcemaps from 'rollup-plugin-sourcemaps'; - -export default { - input : 'lib/index.js', - external : "type-r", - - output : { - file : 'dist/index.js', - format : 'umd', - name : 'memoryIO', - sourcemap: true, - globals : { - "type-r":"Nested" - } - }, - plugins: [ - resolve(), //for support of `import X from "directory"` rather than verbose `import X from "directory/index"` - sourcemaps(), - uglify() - ] -}; \ No newline at end of file diff --git a/endpoints/memory/src/index.ts b/endpoints/memory/src/index.ts deleted file mode 100644 index f898f80..0000000 --- a/endpoints/memory/src/index.ts +++ /dev/null @@ -1,81 +0,0 @@ -import { IOEndpoint, IOPromise, createIOPromise } from 'type-r' - -export type Index = ( number | string )[]; - -export function create( init = [], delay = 50 ){ - return new MemoryEndpoint( init, delay ); -} - -export { create as memoryIO }; - -export class MemoryEndpoint implements IOEndpoint { - resolve( value ){ - return createIOPromise( ( resolve, reject ) => { - setTimeout( () => resolve( value ), this.delay ); - }); - } - - reject( value ){ - return createIOPromise( ( resolve, reject ) => { - setTimeout( () => reject( value ), this.delay ); - }); - } - - constructor( init : object[], public delay : number ){ - for( let obj of init ){ - this.create( obj, {} ); - } - } - - index : Index = [ 0 ]; - items = {}; - - generateId( a_id ){ - // Update index counter... - const id = Number( a_id ); - if( !isNaN( id ) ){ - this.index[ 0 ] = Math.max( this.index[ 0 ] as number, id ); - } - - // Return id... - return a_id || String( ( this.index[ 0 ] as number ) ++ ); - } - - create( json, options ) { - const id = json.id = this.generateId( json.id ); - this.index.push( id ); - this.items[ id ] = json; - return this.resolve({ id }); - } - - update( id, json, options ) { - this.items[ id ] = json; - return this.resolve( {} ); - } - - read( id, options ){ - const existing = this.items[ id ]; - return existing ? - this.resolve( existing ) : - this.reject( "Not found" ); - } - - destroy( id, options ){ - const existing = this.items[ id ]; - if( existing ){ - delete this.items[ id ]; - this.index = this.index.filter( x => x !== id ); - return this.resolve( {} ); - } - else{ - return this.reject( "Not found" ); - } - } - - list( options? : object ) { - return this.resolve( this.index.slice( 1 ).map( id => this.items[ id ]) ); - } - - subscribe( events ) : any {} - unsubscribe( events) : any {} -} \ No newline at end of file diff --git a/endpoints/memory/tsconfig.json b/endpoints/memory/tsconfig.json deleted file mode 100644 index 671840d..0000000 --- a/endpoints/memory/tsconfig.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "compilerOptions": { - "target": "es5", - "module":"es6", - "declaration": true, - "importHelpers": true, - "moduleResolution": "node", - "sourceMap": true, - "outDir": "./lib", - "noImplicitAny": false, - "removeComments":true, - "experimentalDecorators": true, - "baseUrl": ".", - "paths" : { - "type-r":[ "../../lib" ] - } - }, - "files":[ - "./src/index.ts" - ] - } \ No newline at end of file diff --git a/endpoints/proxy/README.md b/endpoints/proxy/README.md deleted file mode 100644 index 2553a4a..0000000 --- a/endpoints/proxy/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Proxy Endpoint - -Create IO endpoint from the Record class. This endpoint is designed for use on the server side data layer managed by Type-R. - -Assuming that you have Type-R records with endpoints working with the database, you can create an endpoint which will use -Record subclass as a transport. - - import { proxyIO } from 'type-r/endpoint/proxy' - - ... - - const usersIO = proxyIO( User ); - -This endpoint can be connected to the RESTful endpoint API on the server side which will serve JSON to the restfulIO endpoint on the client. -An advantage of this approach is that JSON schema will be transparently validated on the server side by the Type-R. \ No newline at end of file diff --git a/endpoints/proxy/dist/index.js b/endpoints/proxy/dist/index.js deleted file mode 100644 index f246141..0000000 --- a/endpoints/proxy/dist/index.js +++ /dev/null @@ -1,2 +0,0 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.proxyIO={})}(this,function(t){"use strict";function i(i,u,c,s){return new(c||(c=Promise))(function(t,e){function n(t){try{o(s.next(t))}catch(t){e(t)}}function r(t){try{o(s.throw(t))}catch(t){e(t)}}function o(e){e.done?t(e.value):new c(function(t){t(e.value)}).then(n,r)}o((s=s.apply(i,u||[])).next())})}function u(n,r){var o,i,u,t,c={label:0,sent:function(){if(1&u[0])throw u[1];return u[1]},trys:[],ops:[]};return t={next:e(0),throw:e(1),return:e(2)},"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(e){return function(t){return function(e){if(o)throw new TypeError("Generator is already executing.");for(;c;)try{if(o=1,i&&(u=2&e[0]?i.return:e[0]?i.throw||((u=i.return)&&u.call(i),0):i.next)&&!(u=u.call(i,e[1])).done)return u;switch(i=0,u&&(e=[2&e[0],u.value]),e[0]){case 0:case 1:u=e;break;case 4:return c.label++,{value:e[1],done:!1};case 5:c.label++,i=e[1],e=[0];continue;case 7:e=c.ops.pop(),c.trys.pop();continue;default:if(!(u=0<(u=c.trys).length&&u[u.length-1])&&(6===e[0]||2===e[0])){c=0;continue}if(3===e[0]&&(!u||e[1]>u[0]&&e[1]= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport function __exportStar(m, exports) {\r\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\r\n}\r\n\r\nexport function __values(o) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator], i = 0;\r\n if (m) return m.call(o);\r\n return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\r\n result.default = mod;\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n","import { IOEndpoint, IOOptions, IOPromise, createIOPromise, Record } from 'type-r'\n\nexport function proxyIO( record : typeof Record ){\n return new ProxyEndpoint( record );\n}\n\nexport class ProxyEndpoint implements IOEndpoint {\n Record : typeof Record\n \n get endpoint(){\n return this.Record.prototype._endpoint;\n }\n\n constructor( record : typeof Record ){\n this.Record = record;\n\n // Create proxy methods...\n const source = Object.getPrototypeOf( this.endpoint );\n\n Object.keys( source ).forEach( key => {\n if( !this[ key ] && typeof source[ key ] === 'function' ){\n this[ key ] = function(){\n return source[ key ].apply( this.endpoint, arguments );\n }\n }\n });\n }\n\n async subscribe( events, target ){\n return this.endpoint.subscribe( events, target );\n }\n\n unsubscribe( events, target ){\n this.endpoint.unsubscribe( events, target );\n }\n\n async list( options ){\n const coll = new this.Record.Collection();\n await coll.fetch( options );\n return coll.toJSON();\n }\n\n async update( id, json, options ){\n json.id = id;\n const doc : any = new this.Record( json, { parse : true });\n await doc.save( options );\n return { _cas : doc._cas };\n }\n\n async create( json, options ){\n const doc : any = new this.Record( json, { parse : true });\n await doc.save( options );\n return { id : doc.id, _cas : doc._cas, _type : doc._type };\n }\n\n async read( id, options : object ){\n const doc = new this.Record({ id });\n await doc.fetch( options );\n return doc.toJSON();\n }\n\n async destroy( id : string, options : object ){\n await this.endpoint.destroy( id, options );\n return {};\n }\n}\n"],"names":["__awaiter","thisArg","_arguments","P","generator","Promise","resolve","reject","fulfilled","value","step","next","e","rejected","result","done","then","apply","__generator","body","f","y","t","g","_","label","sent","trys","ops","verb","throw","return","Symbol","iterator","this","n","v","op","TypeError","call","pop","length","push","record","Record","source","Object","getPrototypeOf","endpoint","keys","forEach","key","_this","arguments","ProxyEndpoint","prototype","_endpoint","events","target","subscribe","unsubscribe","options","coll","Collection","fetch","_a","toJSON","id","json","doc","parse","save","_cas","_type","destroy"],"mappings":"0LAiEO,SAASA,EAAUC,EAASC,EAAYC,EAAGC,GAC9C,OAAO,IAAKD,IAAMA,EAAIE,UAAU,SAAUC,EAASC,GAC/C,SAASC,EAAUC,GAAS,IAAMC,EAAKN,EAAUO,KAAKF,IAAW,MAAOG,GAAKL,EAAOK,IACpF,SAASC,EAASJ,GAAS,IAAMC,EAAKN,EAAiB,MAAEK,IAAW,MAAOG,GAAKL,EAAOK,IACvF,SAASF,EAAKI,GAAUA,EAAOC,KAAOT,EAAQQ,EAAOL,OAAS,IAAIN,EAAE,SAAUG,GAAWA,EAAQQ,EAAOL,SAAWO,KAAKR,EAAWK,GACnIH,GAAMN,EAAYA,E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N,SAAca,EAAIC,EAAMP,iGAGpB,OAFAO,EAAKD,GAAKA,MACJE,EAAY,IAAInC,KAAKU,OAAQwB,EAAM,CAAEE,OAAQ,KACzCC,KAAMV,WAChB,OADAI,YACO,CAAEO,KAAOH,EAAIG,aAGlBlB,mBAAN,SAAcc,EAAMP,iGAEhB,UADMQ,EAAY,IAAInC,KAAKU,OAAQwB,EAAM,CAAEE,OAAQ,KACzCC,KAAMV,WAChB,OADAI,YACO,CAAEE,GAAKE,EAAIF,GAAIK,KAAOH,EAAIG,KAAMC,MAAQJ,EAAII,cAGjDnB,iBAAN,SAAYa,EAAIN,iGAEZ,UADMQ,EAAM,IAAInC,KAAKU,OAAO,CAAEuB,QACpBH,MAAOH,WACjB,OADAI,YACOI,EAAIH,gBAGTZ,oBAAN,SAAea,EAAaN,2FACxB,SAAM3B,KAAKc,SAAS0B,QAASP,EAAIN,WACjC,OADAI,YACO,kCA7DUtB,GACrB,OAAO,IAAIW,EAAeX"} \ No newline at end of file diff --git a/endpoints/proxy/lib/index.d.ts b/endpoints/proxy/lib/index.d.ts deleted file mode 100644 index 9da8245..0000000 --- a/endpoints/proxy/lib/index.d.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { IOEndpoint, Record } from 'type-r'; -export declare function proxyIO(record: typeof Record): ProxyEndpoint; -export declare class ProxyEndpoint implements IOEndpoint { - Record: typeof Record; - readonly endpoint: IOEndpoint; - constructor(record: typeof Record); - subscribe(events: any, target: any): Promise; - unsubscribe(events: any, target: any): void; - list(options: any): Promise; - update(id: any, json: any, options: any): Promise<{ - _cas: any; - }>; - create(json: any, options: any): Promise<{ - id: any; - _cas: any; - _type: any; - }>; - read(id: any, options: object): Promise; - destroy(id: string, options: object): Promise<{}>; -} diff --git a/endpoints/proxy/lib/index.js b/endpoints/proxy/lib/index.js deleted file mode 100644 index c64d416..0000000 --- a/endpoints/proxy/lib/index.js +++ /dev/null @@ -1,111 +0,0 @@ -import * as tslib_1 from "tslib"; -export function proxyIO(record) { - return new ProxyEndpoint(record); -} -var ProxyEndpoint = (function () { - function ProxyEndpoint(record) { - var _this = this; - this.Record = record; - var source = Object.getPrototypeOf(this.endpoint); - Object.keys(source).forEach(function (key) { - if (!_this[key] && typeof source[key] === 'function') { - _this[key] = function () { - return source[key].apply(this.endpoint, arguments); - }; - } - }); - } - Object.defineProperty(ProxyEndpoint.prototype, "endpoint", { - get: function () { - return this.Record.prototype._endpoint; - }, - enumerable: true, - configurable: true - }); - ProxyEndpoint.prototype.subscribe = function (events, target) { - return tslib_1.__awaiter(this, void 0, void 0, function () { - return tslib_1.__generator(this, function (_a) { - return [2, this.endpoint.subscribe(events, target)]; - }); - }); - }; - ProxyEndpoint.prototype.unsubscribe = function (events, target) { - this.endpoint.unsubscribe(events, target); - }; - ProxyEndpoint.prototype.list = function (options) { - return tslib_1.__awaiter(this, void 0, void 0, function () { - var coll; - return tslib_1.__generator(this, function (_a) { - switch (_a.label) { - case 0: - coll = new this.Record.Collection(); - return [4, coll.fetch(options)]; - case 1: - _a.sent(); - return [2, coll.toJSON()]; - } - }); - }); - }; - ProxyEndpoint.prototype.update = function (id, json, options) { - return tslib_1.__awaiter(this, void 0, void 0, function () { - var doc; - return tslib_1.__generator(this, function (_a) { - switch (_a.label) { - case 0: - json.id = id; - doc = new this.Record(json, { parse: true }); - return [4, doc.save(options)]; - case 1: - _a.sent(); - return [2, { _cas: doc._cas }]; - } - }); - }); - }; - ProxyEndpoint.prototype.create = function (json, options) { - return tslib_1.__awaiter(this, void 0, void 0, function () { - var doc; - return tslib_1.__generator(this, function (_a) { - switch (_a.label) { - case 0: - doc = new this.Record(json, { parse: true }); - return [4, doc.save(options)]; - case 1: - _a.sent(); - return [2, { id: doc.id, _cas: doc._cas, _type: doc._type }]; - } - }); - }); - }; - ProxyEndpoint.prototype.read = function (id, options) { - return tslib_1.__awaiter(this, void 0, void 0, function () { - var doc; - return tslib_1.__generator(this, function (_a) { - switch (_a.label) { - case 0: - doc = new this.Record({ id: id }); - return [4, doc.fetch(options)]; - case 1: - _a.sent(); - return [2, doc.toJSON()]; - } - }); - }); - }; - ProxyEndpoint.prototype.destroy = function (id, options) { - return tslib_1.__awaiter(this, void 0, void 0, function () { - return tslib_1.__generator(this, function (_a) { - switch (_a.label) { - case 0: return [4, this.endpoint.destroy(id, options)]; - case 1: - _a.sent(); - return [2, {}]; - } - }); - }); - }; - return ProxyEndpoint; -}()); -export { ProxyEndpoint }; -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/endpoints/proxy/lib/index.js.map b/endpoints/proxy/lib/index.js.map deleted file mode 100644 index 8e8919f..0000000 --- a/endpoints/proxy/lib/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,MAAM,UAAU,OAAO,CAAE,MAAsB;IAC3C,OAAO,IAAI,aAAa,CAAE,MAAM,CAAE,CAAC;AACvC,CAAC;AAED;IAOI,uBAAa,MAAsB;QAAnC,iBAaC;QAZG,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAGrB,IAAM,MAAM,GAAG,MAAM,CAAC,cAAc,CAAE,IAAI,CAAC,QAAQ,CAAE,CAAC;QAEtD,MAAM,CAAC,IAAI,CAAE,MAAM,CAAE,CAAC,OAAO,CAAE,UAAA,GAAG;YAC9B,IAAI,CAAC,KAAI,CAAE,GAAG,CAAE,IAAI,OAAO,MAAM,CAAE,GAAG,CAAE,KAAK,UAAU,EAAE;gBACrD,KAAI,CAAE,GAAG,CAAE,GAAG;oBACV,OAAO,MAAM,CAAE,GAAG,CAAE,CAAC,KAAK,CAAE,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAE,CAAC;gBAC3D,CAAC,CAAA;aACJ;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IAjBD,sBAAI,mCAAQ;aAAZ;YACI,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC;QAC3C,CAAC;;;OAAA;IAiBK,iC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D;IAEK,4BAAI,GAAV,UAAY,EAAE,EAAE,OAAgB;;;;;;wBACtB,GAAG,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,IAAA,EAAE,CAAC,CAAC;wBACpC,WAAM,GAAG,CAAC,KAAK,CAAE,OAAO,CAAE,EAAA;;wBAA1B,SAA0B,CAAC;wBAC3B,WAAO,GAAG,CAAC,MAAM,EAAE,EAAC;;;;KACvB;IAEK,+BAAO,GAAb,UAAe,EAAW,EAAE,OAAgB;;;;4BACxC,WAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAE,EAAE,EAAE,OAAO,CAAE,EAAA;;wBAA1C,SAA0C,CAAC;wBAC3C,WAAO,EAAE,EAAC;;;;KACb;IACL,oBAAC;AAAD,CAAC,AA3DD,IA2DC"} \ No newline at end of file diff --git a/endpoints/proxy/package.json b/endpoints/proxy/package.json deleted file mode 100644 index dd09c6c..0000000 --- a/endpoints/proxy/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "proxyIO", - "main": "./dist/index.js", - "jsnext:main": "./lib/index.js", - "module": "./lib/index.js", - "types": "./lib/index.d.ts", - "scripts": { - "build":"../../node_modules/.bin/tsc && ../../node_modules/.bin/rollup --config" - }, - "author": "Vlad Balin", - "license": "MIT" -} - \ No newline at end of file diff --git a/endpoints/proxy/rollup.config.js b/endpoints/proxy/rollup.config.js deleted file mode 100644 index 79c1e75..0000000 --- a/endpoints/proxy/rollup.config.js +++ /dev/null @@ -1,23 +0,0 @@ -import resolve from 'rollup-plugin-node-resolve'; -import { uglify } from 'rollup-plugin-uglify'; -import sourcemaps from 'rollup-plugin-sourcemaps'; - -export default { - input : 'lib/index.js', - external : "type-r", - - output : { - file : 'dist/index.js', - format : 'umd', - name : 'proxyIO', - sourcemap: true, - globals : { - "type-r":"Nested" - } - }, - plugins: [ - resolve(), //for support of `import X from "directory"` rather than verbose `import X from "directory/index"` - sourcemaps(), - uglify() - ] -}; \ No newline at end of file diff --git a/endpoints/proxy/src/index.ts b/endpoints/proxy/src/index.ts deleted file mode 100644 index a748997..0000000 --- a/endpoints/proxy/src/index.ts +++ /dev/null @@ -1,66 +0,0 @@ -import { IOEndpoint, IOOptions, IOPromise, createIOPromise, Record } from 'type-r' - -export function proxyIO( record : typeof Record ){ - return new ProxyEndpoint( record ); -} - -export class ProxyEndpoint implements IOEndpoint { - Record : typeof Record - - get endpoint(){ - return this.Record.prototype._endpoint; - } - - constructor( record : typeof Record ){ - this.Record = record; - - // Create proxy methods... - const source = Object.getPrototypeOf( this.endpoint ); - - Object.keys( source ).forEach( key => { - if( !this[ key ] && typeof source[ key ] === 'function' ){ - this[ key ] = function(){ - return source[ key ].apply( this.endpoint, arguments ); - } - } - }); - } - - async subscribe( events, target ){ - return this.endpoint.subscribe( events, target ); - } - - unsubscribe( events, target ){ - this.endpoint.unsubscribe( events, target ); - } - - async list( options ){ - const coll = new this.Record.Collection(); - await coll.fetch( options ); - return coll.toJSON(); - } - - async update( id, json, options ){ - json.id = id; - const doc : any = new this.Record( json, { parse : true }); - await doc.save( options ); - return { _cas : doc._cas }; - } - - async create( json, options ){ - const doc : any = new this.Record( json, { parse : true }); - await doc.save( options ); - return { id : doc.id, _cas : doc._cas, _type : doc._type }; - } - - async read( id, options : object ){ - const doc = new this.Record({ id }); - await doc.fetch( options ); - return doc.toJSON(); - } - - async destroy( id : string, options : object ){ - await this.endpoint.destroy( id, options ); - return {}; - } -} diff --git a/endpoints/proxy/tsconfig.json b/endpoints/proxy/tsconfig.json deleted file mode 100644 index 671840d..0000000 --- a/endpoints/proxy/tsconfig.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "compilerOptions": { - "target": "es5", - "module":"es6", - "declaration": true, - "importHelpers": true, - "moduleResolution": "node", - "sourceMap": true, - "outDir": "./lib", - "noImplicitAny": false, - "removeComments":true, - "experimentalDecorators": true, - "baseUrl": ".", - "paths" : { - "type-r":[ "../../lib" ] - } - }, - "files":[ - "./src/index.ts" - ] - } \ No newline at end of file diff --git a/endpoints/restful/dist/index.js b/endpoints/restful/dist/index.js deleted file mode 100644 index 0cb26e1..0000000 --- a/endpoints/restful/dist/index.js +++ /dev/null @@ -1,2 +0,0 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.restfulIO={})}(this,function(t){"use strict";var c=function(){return(c=Object.assign||function(t){for(var e,r=1,n=arguments.length;r= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport function __exportStar(m, exports) {\r\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\r\n}\r\n\r\nexport function __values(o) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator], i = 0;\r\n if (m) return m.call(o);\r\n return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\r\n result.default = mod;\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n","import { IOEndpoint, IOOptions, IOPromise, createIOPromise } from 'type-r'\n\nexport function create( url : string, fetchOptions? : Partial ){\n return new RestfulEndpoint( url, fetchOptions );\n}\n\nexport { create as restfulIO }\n\nexport interface RestfulIOOptions extends IOOptions {\n params? : object,\n options? : RequestInit\n}\n\nexport type RestfulFetchOptions = /* subset of RequestInit */{\n cache?: RequestCache;\n credentials?: RequestCredentials;\n mode?: RequestMode;\n redirect?: RequestRedirect;\n referrerPolicy?: ReferrerPolicy;\n}\n\nexport class RestfulEndpoint implements IOEndpoint {\n\n constructor( public url : string, public fetchOptions? : Partial ) {\n }\n\n public static defaultFetchOptions : RestfulFetchOptions = {\n cache: \"no-cache\",\n credentials: \"same-origin\",\n mode: \"cors\",\n redirect: \"error\",\n }\n\n create( json, options : RestfulIOOptions, record ) {\n return this.request( 'POST', this.collectionUrl( record, options ), options, json );\n }\n\n update( id, json, options : RestfulIOOptions, record ) {\n return this.request( 'PUT', this.objectUrl( record, id, options ), options, json );\n }\n\n read( id, options : IOOptions, record ){\n return this.request( 'GET', this.objectUrl( record, id, options ), options );\n }\n\n destroy( id, options : RestfulIOOptions, record ){\n return this.request( 'DELETE', this.objectUrl( record, id, options ), options );\n }\n\n list( options : RestfulIOOptions, collection ) {\n return this.request( 'GET', this.collectionUrl( collection, options ), options );\n }\n\n subscribe( events ) : any {}\n unsubscribe( events ) : any {}\n\n\n protected isRelativeUrl( url ) {\n return url.indexOf( './' ) === 0;\n }\n\n protected removeTrailingSlash( url : string ) {\n const endsWithSlash = url.charAt( url.length - 1 ) === '/';\n return endsWithSlash ? url.substr( 0, url.length - 1 ) : url;\n }\n\n protected getRootUrl( recordOrCollection ) {\n const { url } = this\n if( this.isRelativeUrl( url ) ) {\n const owner = recordOrCollection.getOwner(),\n ownerUrl = owner.getEndpoint().getUrl( owner );\n\n return this.removeTrailingSlash( ownerUrl ) + '/' + url.substr( 2 )\n } else {\n return url;\n }\n }\n\n protected getUrl( record ) {\n const url = this.getRootUrl( record );\n return record.isNew()\n ? url\n : this.removeTrailingSlash( url ) + '/' + record.id\n }\n\n protected objectUrl( record, id, options ){\n return appendParams( this.getUrl( record ), options.params );\n }\n\n protected collectionUrl( collection, options ){\n return appendParams( this.getRootUrl( collection ), options.params );\n }\n\n protected buildRequestOptions( method : string, options? : RequestInit, body? ) : RequestInit {\n const mergedOptions : RequestInit = Object.assign( {},\n RestfulEndpoint.defaultFetchOptions,\n this.fetchOptions,\n options\n );\n\n const {headers, ...rest} = mergedOptions,\n resultOptions : RequestInit = {\n method,\n headers: {\n 'Content-Type': 'application/json',\n ...headers\n },\n ...rest\n };\n\n if( body ) {\n resultOptions.body = JSON.stringify( body );\n }\n return resultOptions;\n }\n\n protected request( method : string, url : string, {options} : RestfulIOOptions, body? ) : Promise {\n\n return fetch( url, this.buildRequestOptions( method, options, body ) )\n .then( response => {\n if( response.ok ) {\n return response.json()\n } else {\n throw new Error( response.statusText )\n }\n } );\n }\n}\n\nfunction appendParams( url, params? ) {\n var esc = encodeURIComponent;\n return params\n ? url + '?' + Object.keys( params )\n .map( k => esc( k ) + '=' + esc( params[ k ] ) )\n .join( '&' )\n : url;\n}\n\n\n"],"names":["__assign","Object","assign","t","s","i","n","arguments","length","p","prototype","hasOwnProperty","call","apply","this","create","url","fetchOptions","RestfulEndpoint","json","options","record","request","collectionUrl","id","objectUrl","collection","events","indexOf","charAt","substr","recordOrCollection","isRelativeUrl","owner","getOwner","ownerUrl","getEndpoint","getUrl","removeTrailingSlash","getRootUrl","isNew","appendParams","params","method","body","mergedOptions","defaultFetchOptions","headers","rest","e","getOwnPropertySymbols","resultOptions","Content-Type","JSON","stringify","_a","fetch","buildRequestOptions","then","response","ok","Error","statusText","cache","credentials","mode","redirect","esc","encodeURIComponent","keys","map","k","join"],"mappings":"4LA6BO,IAAIA,EAAW,WAQlB,OAPAA,EAAWC,OAAOC,QAAU,SAAkBC,GAC1C,IAAK,IAAIC,EAAGC,EAAI,EAAGC,EAAIC,UAAUC,OAAQH,EAAIC,EAAGD,IAE5C,IAAK,IAAII,KADTL,EAAIG,UAAUF,GACOJ,OAAOS,UAAUC,eAAeC,KAAKR,EAAGK,KAAIN,EAAEM,GAAKL,EAAEK,IAE9E,OAAON,IAEKU,MAAMC,KAAMP,qBCnChBQ,EAAQC,EAAcC,GAClC,OAAO,IAAIC,EAAiBF,EAAKC,oBAoBjC,WAAoBD,EAAqBC,GAArBH,SAAAE,EAAqBF,kBAAAG,EAwG7C,OA9FIC,mBAAA,SAAQC,EAAMC,EAA4BC,GACtC,OAAOP,KAAKQ,QAAS,OAAQR,KAAKS,cAAeF,EAAQD,GAAWA,EAASD,IAGjFD,mBAAA,SAAQM,EAAIL,EAAMC,EAA4BC,GAC1C,OAAOP,KAAKQ,QAAS,MAAOR,KAAKW,UAAWJ,EAAQG,EAAIJ,GAAWA,EAASD,IAGhFD,iBAAA,SAAMM,EAAIJ,EAAqBC,GAC3B,OAAOP,KAAKQ,QAAS,MAAOR,KAAKW,UAAWJ,EAAQG,EAAIJ,GAAWA,IAGvEF,oBAAA,SAASM,EAAIJ,EAA4BC,GACrC,OAAOP,KAAKQ,QAAS,SAAUR,KAAKW,UAAWJ,EAAQG,EAAIJ,GAAWA,IAG1EF,iBAAA,SAAME,EAA4BM,GAC9B,OAAOZ,KAAKQ,QAAS,MAAOR,KAAKS,cAAeG,EAAYN,GAAWA,IAG3EF,sBAAA,SAAWS,KACXT,wBAA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,EAAEJ,IAAMD,EAAEK,EAAEJ,KACtB,OAAOF,kBCsDGgD,KACIR,SACAI,WACIK,eAAgB,oBACbL,IAEJC,GAMb,OAHIJ,IACAO,EAAcP,KAAOS,KAAKC,UAAWV,IAElCO,GAGDjC,oBAAV,SAAmByB,EAAiB3B,EAAcuC,EAA8BX,OAA7BxB,YAE/C,OAAOoC,MAAOxC,EAAKF,KAAK2C,oBAAqBd,EAAQvB,EAASwB,IACzDc,KAAM,SAAAC,GACH,GAAIA,EAASC,GACT,OAAOD,EAASxC,OAEhB,MAAM,IAAI0C,MAAOF,EAASG,eAjG5B5C,sBAA4C,CACtD6C,MAAO,WACPC,YAAa,cACbC,KAAM,OACNC,SAAU,cAmGlB,SAASzB,EAAczB,EAAK0B,GACxB,IAAIyB,EAAMC,mBACV,OAAO1B,EACD1B,EAAM,IAAMf,OAAOoE,KAAM3B,GACR4B,IAAK,SAAAC,GAAK,OAAAJ,EAAKI,GAAM,IAAMJ,EAAKzB,EAAQ6B,MACxCC,KAAM,KACvBxD"} \ No newline at end of file diff --git a/endpoints/restful/lib/index.d.ts b/endpoints/restful/lib/index.d.ts deleted file mode 100644 index efc1284..0000000 --- a/endpoints/restful/lib/index.d.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { IOEndpoint, IOOptions } from 'type-r'; -export declare function create(url: string, fetchOptions?: Partial): RestfulEndpoint; -export { create as restfulIO }; -export interface RestfulIOOptions extends IOOptions { - params?: object; - options?: RequestInit; -} -export declare type RestfulFetchOptions = { - cache?: RequestCache; - credentials?: RequestCredentials; - mode?: RequestMode; - redirect?: RequestRedirect; - referrerPolicy?: ReferrerPolicy; -}; -export declare class RestfulEndpoint implements IOEndpoint { - url: string; - fetchOptions?: Partial; - constructor(url: string, fetchOptions?: Partial); - static defaultFetchOptions: RestfulFetchOptions; - create(json: any, options: RestfulIOOptions, record: any): Promise; - update(id: any, json: any, options: RestfulIOOptions, record: any): Promise; - read(id: any, options: IOOptions, record: any): Promise; - destroy(id: any, options: RestfulIOOptions, record: any): Promise; - list(options: RestfulIOOptions, collection: any): Promise; - subscribe(events: any): any; - unsubscribe(events: any): any; - protected isRelativeUrl(url: any): boolean; - protected removeTrailingSlash(url: string): string; - protected getRootUrl(recordOrCollection: any): string; - protected getUrl(record: any): string; - protected objectUrl(record: any, id: any, options: any): any; - protected collectionUrl(collection: any, options: any): any; - protected buildRequestOptions(method: string, options?: RequestInit, body?: any): RequestInit; - protected request(method: string, url: string, { options }: RestfulIOOptions, body?: any): Promise; -} diff --git a/endpoints/restful/lib/index.js b/endpoints/restful/lib/index.js deleted file mode 100644 index 2326cba..0000000 --- a/endpoints/restful/lib/index.js +++ /dev/null @@ -1,94 +0,0 @@ -import * as tslib_1 from "tslib"; -export function create(url, fetchOptions) { - return new RestfulEndpoint(url, fetchOptions); -} -export { create as restfulIO }; -var RestfulEndpoint = (function () { - function RestfulEndpoint(url, fetchOptions) { - this.url = url; - this.fetchOptions = fetchOptions; - } - RestfulEndpoint.prototype.create = function (json, options, record) { - return this.request('POST', this.collectionUrl(record, options), options, json); - }; - RestfulEndpoint.prototype.update = function (id, json, options, record) { - return this.request('PUT', this.objectUrl(record, id, options), options, json); - }; - RestfulEndpoint.prototype.read = function (id, options, record) { - return this.request('GET', this.objectUrl(record, id, options), options); - }; - RestfulEndpoint.prototype.destroy = function (id, options, record) { - return this.request('DELETE', this.objectUrl(record, id, options), options); - }; - RestfulEndpoint.prototype.list = function (options, collection) { - return this.request('GET', this.collectionUrl(collection, options), options); - }; - RestfulEndpoint.prototype.subscribe = function (events) { }; - RestfulEndpoint.prototype.unsubscribe = function (events) { }; - RestfulEndpoint.prototype.isRelativeUrl = function (url) { - return url.indexOf('./') === 0; - }; - RestfulEndpoint.prototype.removeTrailingSlash = function (url) { - var endsWithSlash = url.charAt(url.length - 1) === '/'; - return endsWithSlash ? url.substr(0, url.length - 1) : url; - }; - RestfulEndpoint.prototype.getRootUrl = function (recordOrCollection) { - var url = this.url; - if (this.isRelativeUrl(url)) { - var owner = recordOrCollection.getOwner(), ownerUrl = owner.getEndpoint().getUrl(owner); - return this.removeTrailingSlash(ownerUrl) + '/' + url.substr(2); - } - else { - return url; - } - }; - RestfulEndpoint.prototype.getUrl = function (record) { - var url = this.getRootUrl(record); - return record.isNew() - ? url - : this.removeTrailingSlash(url) + '/' + record.id; - }; - RestfulEndpoint.prototype.objectUrl = function (record, id, options) { - return appendParams(this.getUrl(record), options.params); - }; - RestfulEndpoint.prototype.collectionUrl = function (collection, options) { - return appendParams(this.getRootUrl(collection), options.params); - }; - RestfulEndpoint.prototype.buildRequestOptions = function (method, options, body) { - var mergedOptions = Object.assign({}, RestfulEndpoint.defaultFetchOptions, this.fetchOptions, options); - var headers = mergedOptions.headers, rest = tslib_1.__rest(mergedOptions, ["headers"]), resultOptions = tslib_1.__assign({ method: method, headers: tslib_1.__assign({ 'Content-Type': 'application/json' }, headers) }, rest); - if (body) { - resultOptions.body = JSON.stringify(body); - } - return resultOptions; - }; - RestfulEndpoint.prototype.request = function (method, url, _a, body) { - var options = _a.options; - return fetch(url, this.buildRequestOptions(method, options, body)) - .then(function (response) { - if (response.ok) { - return response.json(); - } - else { - throw new Error(response.statusText); - } - }); - }; - RestfulEndpoint.defaultFetchOptions = { - cache: "no-cache", - credentials: "same-origin", - mode: "cors", - redirect: "error", - }; - return RestfulEndpoint; -}()); -export { RestfulEndpoint }; -function appendParams(url, params) { - var esc = encodeURIComponent; - return params - ? url + '?' + Object.keys(params) - .map(function (k) { return esc(k) + '=' + esc(params[k]); }) - .join('&') - : url; -} -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/endpoints/restful/lib/index.js.map b/endpoints/restful/lib/index.js.map deleted file mode 100644 index 5b7705d..0000000 --- a/endpoints/restful/lib/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,MAAM,UAAU,MAAM,CAAE,GAAY,EAAE,YAA4C;IAC9E,OAA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,QAAQ,EAAE,OAAO;KACpB,CAAA;IAgGL,sBAAC;CAAA,AA1GD,IA0GC;SA1GY,eAAe;AA4G5B,SAAS,YAAY,CAAE,GAAG,EAAE,MAAO;IAC/B,IAAI,GAAG,GAAG,kBAAkB,CAAC;IAC7B,OAAO,MAAM;QACT,CAAC,CAAC,GAAG,GAAG,GAAG,GAAG,MAAM,CAAC,IAAI,CAAE,MAAM,CAAE;aAChB,GAAG,CAAE,UAAA,CAAC,IAAI,OAAA,GAAG,CAAE,CAAC,CAAE,GAAG,GAAG,GAAG,GAAG,CAAE,MAAM,CAAE,CAAC,CAAE,CAAE,EAAnC,CAAmC,CAAE;aAC/C,IAAI,CAAE,GAAG,CAAE;QAC9B,CAAC,CAAC,GAAG,CAAC;AACd,CAAC"} \ No newline at end of file diff --git a/endpoints/restful/package.json b/endpoints/restful/package.json deleted file mode 100644 index 39ed8d4..0000000 --- a/endpoints/restful/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "restfulIO", - "main": "./dist/index.js", - "jsnext:main": "./lib/index.js", - "module": "./lib/index.js", - "types": "./lib/index.d.ts", - "scripts": { - "build":"../../node_modules/.bin/tsc && ../../node_modules/.bin/rollup --config" - }, - "author": "Ivan Terpugov", - "license": "MIT" -} - \ No newline at end of file diff --git a/endpoints/restful/rollup.config.js b/endpoints/restful/rollup.config.js deleted file mode 100644 index 5789d78..0000000 --- a/endpoints/restful/rollup.config.js +++ /dev/null @@ -1,23 +0,0 @@ -import resolve from 'rollup-plugin-node-resolve'; -import { uglify } from 'rollup-plugin-uglify'; -import sourcemaps from 'rollup-plugin-sourcemaps'; - -export default { - input : 'lib/index.js', - external : "type-r", - - output : { - file : 'dist/index.js', - format : 'umd', - name : 'restfulIO', - sourcemap: true, - globals : { - "type-r":"Nested" - } - }, - plugins: [ - resolve(), //for support of `import X from "directory"` rather than verbose `import X from "directory/index"` - sourcemaps(), - uglify() - ] -}; \ No newline at end of file diff --git a/endpoints/restful/src/index.ts b/endpoints/restful/src/index.ts deleted file mode 100644 index 653513a..0000000 --- a/endpoints/restful/src/index.ts +++ /dev/null @@ -1,139 +0,0 @@ -import { IOEndpoint, IOOptions, IOPromise, createIOPromise } from 'type-r' - -export function create( url : string, fetchOptions? : Partial ){ - return new RestfulEndpoint( url, fetchOptions ); -} - -export { create as restfulIO } - -export interface RestfulIOOptions extends IOOptions { - params? : object, - options? : RequestInit -} - -export type RestfulFetchOptions = /* subset of RequestInit */{ - cache?: RequestCache; - credentials?: RequestCredentials; - mode?: RequestMode; - redirect?: RequestRedirect; - referrerPolicy?: ReferrerPolicy; -} - -export class RestfulEndpoint implements IOEndpoint { - - constructor( public url : string, public fetchOptions? : Partial ) { - } - - public static defaultFetchOptions : RestfulFetchOptions = { - cache: "no-cache", - credentials: "same-origin", - mode: "cors", - redirect: "error", - } - - create( json, options : RestfulIOOptions, record ) { - return this.request( 'POST', this.collectionUrl( record, options ), options, json ); - } - - update( id, json, options : RestfulIOOptions, record ) { - return this.request( 'PUT', this.objectUrl( record, id, options ), options, json ); - } - - read( id, options : IOOptions, record ){ - return this.request( 'GET', this.objectUrl( record, id, options ), options ); - } - - destroy( id, options : RestfulIOOptions, record ){ - return this.request( 'DELETE', this.objectUrl( record, id, options ), options ); - } - - list( options : RestfulIOOptions, collection ) { - return this.request( 'GET', this.collectionUrl( collection, options ), options ); - } - - subscribe( events ) : any {} - unsubscribe( events ) : any {} - - - protected isRelativeUrl( url ) { - return url.indexOf( './' ) === 0; - } - - protected removeTrailingSlash( url : string ) { - const endsWithSlash = url.charAt( url.length - 1 ) === '/'; - return endsWithSlash ? url.substr( 0, url.length - 1 ) : url; - } - - protected getRootUrl( recordOrCollection ) { - const { url } = this - if( this.isRelativeUrl( url ) ) { - const owner = recordOrCollection.getOwner(), - ownerUrl = owner.getEndpoint().getUrl( owner ); - - return this.removeTrailingSlash( ownerUrl ) + '/' + url.substr( 2 ) - } else { - return url; - } - } - - protected getUrl( record ) { - const url = this.getRootUrl( record ); - return record.isNew() - ? url - : this.removeTrailingSlash( url ) + '/' + record.id - } - - protected objectUrl( record, id, options ){ - return appendParams( this.getUrl( record ), options.params ); - } - - protected collectionUrl( collection, options ){ - return appendParams( this.getRootUrl( collection ), options.params ); - } - - protected buildRequestOptions( method : string, options? : RequestInit, body? ) : RequestInit { - const mergedOptions : RequestInit = Object.assign( {}, - RestfulEndpoint.defaultFetchOptions, - this.fetchOptions, - options - ); - - const {headers, ...rest} = mergedOptions, - resultOptions : RequestInit = { - method, - headers: { - 'Content-Type': 'application/json', - ...headers - }, - ...rest - }; - - if( body ) { - resultOptions.body = JSON.stringify( body ); - } - return resultOptions; - } - - protected request( method : string, url : string, {options} : RestfulIOOptions, body? ) : Promise { - - return fetch( url, this.buildRequestOptions( method, options, body ) ) - .then( response => { - if( response.ok ) { - return response.json() - } else { - throw new Error( response.statusText ) - } - } ); - } -} - -function appendParams( url, params? ) { - var esc = encodeURIComponent; - return params - ? url + '?' + Object.keys( params ) - .map( k => esc( k ) + '=' + esc( params[ k ] ) ) - .join( '&' ) - : url; -} - - diff --git a/endpoints/restful/tsconfig.json b/endpoints/restful/tsconfig.json deleted file mode 100644 index 671840d..0000000 --- a/endpoints/restful/tsconfig.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "compilerOptions": { - "target": "es5", - "module":"es6", - "declaration": true, - "importHelpers": true, - "moduleResolution": "node", - "sourceMap": true, - "outDir": "./lib", - "noImplicitAny": false, - "removeComments":true, - "experimentalDecorators": true, - "baseUrl": ".", - "paths" : { - "type-r":[ "../../lib" ] - } - }, - "files":[ - "./src/index.ts" - ] - } \ No newline at end of file diff --git a/lib/backbone.js b/lib/backbone.js index a9a2d5b..1759bb3 100644 --- a/lib/backbone.js +++ b/lib/backbone.js @@ -1,5 +1,5 @@ -import * as _ from 'underscore'; import * as jQuery from 'jquery'; +import * as _ from 'underscore'; var previousBackbone = window.Backbone; var slice = Array.prototype.slice; var exported = { diff --git a/lib/backbone.js.map b/lib/backbone.js.map index f7aab9c..f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,CAAC;SAChC;IACH,CAAC;CAEF,CAAC,CAAC;AAGH,QAAQ,CAAC,OAAO,GAAG,IAAI,OAAO,CAAC"} \ No newline at end of file diff --git a/lib/index.d.ts b/lib/index.d.ts index 9413514..b40e2d4 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -1,11 +1,11 @@ -import * as TypeR from './type-r'; -export * from './type-r'; +import * as TypeR from 'type-r'; import Backbone from './backbone'; import { RestCollection, RestModel } from './rest'; -import { RestStore, LazyStore } from './rest-store'; +import { LazyStore, RestStore } from './rest-store'; +export * from 'type-r'; +export * from './backbone'; +export { Backbone, RestStore, LazyStore, RestCollection as Collection, RestModel as Model }; export declare const Class: typeof TypeR.Messenger; declare const Nested: typeof TypeR & typeof Backbone; export default Nested; -export { Backbone, RestStore, LazyStore, RestCollection as Collection, RestModel as Model }; export declare function defaults(x: any): typeof Nested.Record; -export * from './backbone'; diff --git a/lib/index.js b/lib/index.js index 34670b7..98370f2 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,11 +1,13 @@ -import * as TypeR from './type-r'; -export * from './type-r'; +import * as TypeR from 'type-r'; +import { MixinsState, Store as BaseStore, tools } from 'type-r'; import Backbone from './backbone'; import { RestCollection, RestModel } from './rest'; -import { Store as BaseStore, tools, MixinsState } from './type-r'; +import { LazyStore, RestStore } from './rest-store'; import Sync from './sync'; -import { ModelMixin, CollectionMixin } from './underscore-mixin'; -import { RestStore, LazyStore } from './rest-store'; +import { CollectionMixin, ModelMixin } from './underscore-mixin'; +export * from 'type-r'; +export * from './backbone'; +export { Backbone, RestStore, LazyStore, RestCollection as Collection, RestModel as Model }; export var Class = TypeR.Messenger; var Nested = Object.create(TypeR, tools.defaults({ 'sync': linkProperty(Sync, 'sync'), @@ -19,11 +21,9 @@ var Nested = Object.create(TypeR, tools.defaults({ } }, toProps({ Backbone: Backbone, Class: Class, Model: RestModel, Collection: RestCollection, LazyStore: LazyStore, Store: RestStore, defaults: defaults }), toProps(Backbone))); export default Nested; -export { Backbone, RestStore, LazyStore, RestCollection as Collection, RestModel as Model }; export function defaults(x) { return Nested.Model.defaults(x); } -export * from './backbone'; MixinsState.get(Nested.Mixable).merge([Nested.Events]); Nested.Messenger.mixins.populate(Backbone.View, Backbone.Router, Backbone.History); Nested.Record.mixins.merge([ModelMixin]); diff --git a/lib/index.js.map b/lib/index.js.map index 8e163b2..5758402 100644 --- a/lib/index.js.map +++ b/lib/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,UAAU,CAAA;AACjC,cAAc,UAAU,CAAA;AAKxB,OAAO,QAAQ,MAAM,YAAY,CAAA;AACjC,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAClD,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACjE,OAAO,IAAI,MAAM,QAAQ,CAAA;AAEzB,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAChE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAMnD,MAAM,CAAC,IAAM,KAAK,GAA4B,KAAK,CAAC,SAAS,CAAC;AAE9D,IAAM,MAAM,GAAoC,MAAM,CAAC,MAAM,CAAE,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC;IAC7E,MAAM,EAAW,YAAY,CAAE,IAAI,EAAE,MAAM,CAAE;IAC7C,cAAc,EAAG,YAAY,CAAE,IAAI,EAAE,cAAc,CAAE;IACrD,MAAM,EAAW,YAAY,CAAE,IAAI,EAAE,MAAM,CAAE;IAC7C,SAAS,EAAQ,YAAY,CAAE,QAAQ,EAAE,SAAS,CAAE;IACpD,OAAO,EAAU,YAAY,CAAE,SAAS,EAAE,QAAQ,CAAE;IACpD,GAAG,EAAG;QACF,GAAG,gBAAI,OAAO,QAAQ,CAA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I,SAAS,CAAE,IAAI,CAAE,GAAG,KAAK,CAAC,CAAC,CAAC;KAC7C,CAAC;AACN,CAAC;AAED,SAAS,OAAO,CAAE,GAAG;IACjB,OAAO,KAAK,CAAC,SAAS,CAAC,EAAE,EAAE,GAAG,EAAE,UAAA,CAAC,IAAI,OAAA,CAAC,EAAE,KAAK,EAAG,CAAC,EAAE,CAAC,EAAf,CAAe,CAAE,CAAC;AAC3D,CAAC"} \ No newline at end of file diff --git a/lib/rest-store.d.ts b/lib/rest-store.d.ts index e8ddb1b..82395f4 100644 --- a/lib/rest-store.d.ts +++ b/lib/rest-store.d.ts @@ -1,4 +1,5 @@ /// +import "type-r/globals"; import { RestModel } from './rest'; export declare class RestStore extends RestModel { } diff --git a/lib/rest-store.js b/lib/rest-store.js index 8fe2e1b..0d3e77f 100644 --- a/lib/rest-store.js +++ b/lib/rest-store.js @@ -1,8 +1,9 @@ import * as tslib_1 from "tslib"; -import Backbone from './backbone'; +import { define, Store } from 'type-r'; +import "type-r/globals"; import * as _ from 'underscore'; -import { define, Store } from './type-r'; -import { RestModel, RestCollection } from './rest'; +import Backbone from './backbone'; +import { RestCollection, RestModel } from './rest'; var RestStore = (function (_super) { tslib_1.__extends(RestStore, _super); function RestStore() { @@ -26,7 +27,7 @@ var LazyStore = (function (_super) { } LazyStore.prototype.initialize = function () { var _this = this; - this.each(function (element, name) { + this.forEach(function (element, name) { if (!element) return; element.store = _this; diff --git a/lib/rest-store.js.map b/lib/rest-store.js.map index a788631..f7e78d2 100644 --- a/lib/rest-store.js.map +++ b/lib/rest-store.js.map @@ -1 +1 @@ -{"version":3,"file":"rest-store.js","sourceRoot":"","sources":["../src/rest-store.ts"],"names":[],"mappings":";AAAA,OAAO,QAAQ,MAAM,YAAY,CAAA;AACjC,OAAO,KAAK,CAAC,MAAM,YAAY,CAAA;AAC/B,OAAO,EAAsB,MAAM,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAC5D,OAAO,EAAE,SAAS,EAAE,cAA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AAE,UAAE,IAAe,EAAE,IAAI;YACvC,IAAI,IAAI,CAAC,GAAG,EAAE;gBACV,UAAU,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG;qBACtB,GAAG,CAAE,UAAU,KAAK;oBACjB,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;wBACzB,IAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,IAAI,CAAE,IAAI,CAAC,SAAS,GAAG,EAAE,CAAE,CAAC;wBAC3D,QAAQ,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;qBAC1B;oBAED,OAAO,KAAK,CAAC;gBACjB,CAAC,CAAC,CAAA;aACT;QACL,CAAC,CAAC,CAAC;QAEH,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAE,IAAI,EAAE,WAAW,EAAE,SAAS,CAAE,CAAC;IAC5D,CAAC;IAhGQ,SAAS;QADrB,MAAM;OACM,SAAS,CAiGrB;IAAD,gBAAC;CAAA,AAjGD,CAA+B,SAAS,GAiGvC;SAjGY,SAAS"} \ No newline at end of file diff --git a/lib/rest.d.ts b/lib/rest.d.ts index 9fa9219..2f1e6ed 100644 --- a/lib/rest.d.ts +++ b/lib/rest.d.ts @@ -1,6 +1,6 @@ /// -import { SyncOptions, Restful } from './sync'; -import { Model, Collection } from './type-r'; +import { Collection, Model } from 'type-r'; +import { Restful, SyncOptions } from './sync'; export interface RestOptions extends SyncOptions { wait?: boolean; patch?: boolean; diff --git a/lib/rest.js b/lib/rest.js index 2fa428f..624e099 100644 --- a/lib/rest.js +++ b/lib/rest.js @@ -1,9 +1,8 @@ import * as tslib_1 from "tslib"; -import Sync from './sync'; +import { Collection, define, definitions, mixinRules, Model, tools } from 'type-r'; import * as _ from 'underscore'; -import { define, Model, Collection, tools, definitions, mixinRules } from './type-r'; +import Sync from './sync'; var defaults = tools.defaults; -var transactionalProto = tools.getBaseClass(Model).prototype; var RestCollection = (function (_super) { tslib_1.__extends(RestCollection, _super); function RestCollection() { @@ -71,6 +70,7 @@ var RestCollection = (function (_super) { }(Collection)); export { RestCollection }; ; +var modelProto = Model.prototype; var RestModel = (function (_super) { tslib_1.__extends(RestModel, _super); function RestModel() { @@ -134,7 +134,7 @@ var RestModel = (function (_super) { if (wait) serverAttrs = _.extend({}, attrs, serverAttrs); if (serverAttrs) { - transactionalProto.set.call(_this_1, serverAttrs, options); + modelProto.set.call(_this_1, serverAttrs, options); if (model._invalidate(options)) return false; } diff --git a/lib/rest.js.map b/lib/rest.js.map index 5aeb5c1..88af1c5 100644 --- a/lib/rest.js.map +++ b/lib/rest.js.map @@ -1 +1 @@ -{"version":3,"file":"rest.js","sourceRoot":"","sources":["../src/rest.ts"],"names":[],"mappings":";AAAA,OAAO,IAAyC,MAAM,QAAQ,CAAA;AAE9D,OAAO,KAAK,CAAC,MAAM,YAAY,CAAA;AAG/B,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAC5E,IAAA,yBAAQ,CAAW;AAE3B,IAAM,kBAAkB,GAAG,KAAK,CAAC,YAAY,CAAE,KAAK,CAAE,CAAC,SAAS,CAAC;AAcjE;IAAoC,0CAAqB;IAAzD;;IAiEA,CAAC;IA9DG,gCAAO,GAAP;QACI,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK;YAAG,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;QACrD,iBAAM,OAAO,WAAE,CAAC;IACpB,CAAC;IAGD,4BAAG,GAAH,cAAiB,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC;IAE7D,oCAAW,GAAX,UAAa,OAAiC;QAC1C,IAAI,KAAK,CAAC;QACV,IAAI,OAAO,CAAC,QAAQ,IAAI,CAAE,KAAK,GAAG,IAAI,CAAC,eAAe,CAAE,EAAE;YACtD,IAAI,CAA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GAAG,GAAG,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAE,CAAC;IAC9D,GAAG,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,MAAM,CAAE,cAAY,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACrE,OAAO,GAAG,CAAC;AACf,CAAC;AAGD,SAAS,SAAS,CAAE,KAAW,EAAE,OAAqB;IAClD,IAAI,KAAK,GAAO,OAAO,CAAC,KAAK,CAAC;IAC9B,OAAO,CAAC,KAAK,GAAG,UAAU,IAAI;QAC1B,IAAI,KAAK;YAAG,KAAK,CAAC,IAAI,CAAE,OAAO,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,CAAE,CAAC;QAChE,gBAAgB,CAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,CAAE,CAAC;IAC7D,CAAC,CAAC;AACN,CAAC;AAED,SAAS,gBAAgB,CAAE,KAAW;IAAE,cAAe;SAAf,UAAe,EAAf,qBAAe,EAAf,IAAe;QAAf,6BAAe;;IACnD,KAAK,CAAC,OAAO,CAAC,KAAK,CAAE,KAAK,EAAE,IAAI,CAAE,CAAC;IAC3B,IAAA,6BAAU,CAAW;IAC7B,UAAU,IAAI,UAAU,CAAC,OAAO,CAAC,KAAK,CAAE,UAAU,EAAE,IAAI,CAAE,CAAC;AAC/D,CAAC"} \ No newline at end of file diff --git a/lib/sync.js b/lib/sync.js index 80dc21d..e7e72e9 100644 --- a/lib/sync.js +++ b/lib/sync.js @@ -1,7 +1,5 @@ import * as _ from 'underscore'; import Backbone from './backbone'; -import { tools } from './type-r'; -var defaults = tools.defaults; var methodMap = { 'create': 'POST', 'update': 'PUT', diff --git a/lib/sync.js.map b/lib/sync.js.map index 186b85d..c385c0a 100644 --- a/lib/sync.js.map +++ b/lib/sync.js.map @@ -1 +1 @@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AAK,OAAO,CAAC,EAAE;QACrG,MAAM,CAAC,WAAW,GAAG,kBAAkB,CAAC;QACxC,MAAM,CAAC,IAAI,GAAU,IAAI,CAAC,SAAS,CAAE,OAAO,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,CAAE,OAAO,CAAE,CAAE,CAAC;KACnF;IAGD,IAAI,MAAM,CAAC,IAAI,KAAK,KAAK,EAAE;QACvB,MAAM,CAAC,WAAW,GAAG,KAAK,CAAC;KAC9B;IAGD,IAAI,KAAK,GAAO,OAAO,CAAC,KAAK,CAAC;IAC9B,OAAO,CAAC,KAAK,GAAG,UAAU,GAAG,EAAE,UAAU,EAAE,WAAW;QAClD,OAAO,CAAC,UAAU,GAAI,UAAU,CAAC;QACjC,OAAO,CAAC,WAAW,GAAG,WAAW,CAAC;QAClC,IAAI,KAAK;YAAG,KAAK,CAAC,IAAI,CAAE,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,WAAW,CAAE,CAAC;IAC5E,CAAC,CAAC;IAGF,IAAI,GAAG,GAAG,OAAO,CAAC,GAAG,GAAG,QAAQ,CAAC,IAAI,CAAE,CAAC,CAAC,MAAM,CAAE,MAAM,EAAE,OAAO,CAAE,CAAE,CAAC;IACrE,KAAK,CAAC,OAAO,CAAE,SAAS,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,CAAE,CAAC;IAChD,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,UAAU,CAAC,OAAO,CAAE,SAAS,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,CAAE,CAAC;IAC/E,OAAO,GAAG,CAAC;AACf,CAAC"} \ No newline at end of file diff --git a/lib/type-r/collection/add.d.ts b/lib/type-r/collection/add.d.ts deleted file mode 100644 index 8f60a13..0000000 --- a/lib/type-r/collection/add.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { CollectionTransaction, CollectionOptions, CollectionCore } from './commons'; -export interface AddOptions extends CollectionOptions { - at?: number; -} -export declare function addTransaction(collection: CollectionCore, items: any[], options: AddOptions, merge?: boolean): CollectionTransaction; diff --git a/lib/type-r/collection/add.js b/lib/type-r/collection/add.js deleted file mode 100644 index 0593299..0000000 --- a/lib/type-r/collection/add.js +++ /dev/null @@ -1,65 +0,0 @@ -import { transactionApi } from '../transactions'; -import { CollectionTransaction, logAggregationError, sortElements, convertAndAquire, addIndex, updateIndex } from './commons'; -var begin = transactionApi.begin, commit = transactionApi.commit, markAsDirty = transactionApi.markAsDirty; -export function addTransaction(collection, items, options, merge) { - var isRoot = begin(collection), nested = []; - var added = appendElements(collection, items, nested, options, merge); - if (added.length || nested.length) { - var needSort = sortOrMoveElements(collection, added, options); - if (markAsDirty(collection, options)) { - return new CollectionTransaction(collection, isRoot, added, [], nested, needSort); - } - if (collection._aggregationError) - logAggregationError(collection); - } - isRoot && commit(collection); -} -; -function sortOrMoveElements(collection, added, options) { - var at = options.at; - if (at != null) { - var length_1 = collection.models.length - added.length; - at = Number(at); - if (at < 0) - at += length_1 + 1; - if (at < 0) - at = 0; - if (at > length_1) - at = length_1; - moveElements(collection.models, at, added); - return false; - } - return sortElements(collection, options); -} -function moveElements(source, at, added) { - for (var j = source.length - 1, i = j - added.length; i >= at; i--, j--) { - source[j] = source[i]; - } - for (i = 0, j = at; i < added.length; i++, j++) { - source[j] = added[i]; - } -} -function appendElements(collection, a_items, nested, a_options, forceMerge) { - var _byId = collection._byId, models = collection.models, merge = (forceMerge || a_options.merge) && !collection._shared, parse = a_options.parse, idAttribute = collection.model.prototype.idAttribute, prevLength = models.length; - for (var _i = 0, a_items_1 = a_items; _i < a_items_1.length; _i++) { - var item = a_items_1[_i]; - var model = item ? _byId[item[idAttribute]] || _byId[item.cid] : null; - if (model) { - if (merge && item !== model) { - var attrs = item.attributes || item; - var transaction = model._createTransaction(attrs, a_options); - transaction && nested.push(transaction); - if (model.hasChanged(idAttribute)) { - updateIndex(_byId, model); - } - } - } - else { - model = convertAndAquire(collection, item, a_options); - models.push(model); - addIndex(_byId, model); - } - } - return models.slice(prevLength); -} -//# sourceMappingURL=add.js.map \ No newline at end of file diff --git a/lib/type-r/collection/add.js.map b/lib/type-r/collection/add.js.map deleted file mode 100644 index e35a823..0000000 --- a/lib/type-r/collection/add.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"add.js","sourceRoot":"","sources":["../../../src/type-r/collection/add.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAC7D,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,YAAY,EAAE,gBAAgB,EAA2B,QAAQ,EAAE,WAAW,EAAkB,MAAM,WAAW,CAAA;AAG9J,IAAA,4BAAK,EAAE,8BAAM,EAAE,wCAAW,CAAoB;AAOtD,MAAM,UAAU,cAAc,CAAE,UAA2B,EAAE,KAAa,EAAE,OAAoB,EAAE,KAAgB;IAC9G,IAAM,MAAM,GAAG,KAAK,CAAE,UAAU,CAAE,EAC5B,MAAM,GAAkB,EAAE,CAAC;IAEjC,IAAI,KAAK,GAAG,cAAc,CAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAE,CAAC;IAExE,IAAI,KAAK,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE;QAC/B,IAAI,QAAQ,GAAG,kBAAkB,CAAE,UAAU,EAAE,KAAK,EAAE,OAAO,CAAE,CAAC;QAChE,IAAI,WAAW,CAAE,UAAU,EAAE,OAAO,CAAE,EAAE;YACpC,OAAO,IAAI,qBAAqB,CAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAE,CAAC;SACvF;QAED,IAAI,UAAU,CAAC,iBAAiB;YAAG,mBAAmB,CAAE,UAAU,CAAE,CAAC;KACxE;IAGD,MAAM,IAAI,MAAM,CAAE,UAAU,CAAE,CAAC;AACnC,CAAC;AAAA,CAAC;AAIF,SAAS,kBAAkB,CAAE,UAA2B,EAAE,KAA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AAM,EACf,KAAK,GAAS,CAAE,UAAU,IAAI,SAAS,CAAC,KAAK,CAAE,IAAI,CAAC,UAAU,CAAC,OAAO,EACtE,KAAK,GAAS,SAAS,CAAC,KAAK,EAC7B,WAAW,GAAG,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC,WAAW,EACpD,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC;IAE/B,KAAmB,UAAO,EAAP,mBAAO,EAAP,qBAAO,EAAP,IAAO,EAAE;QAAvB,IAAM,IAAI,gBAAA;QACX,IAAI,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,KAAK,CAAE,IAAI,CAAE,WAAW,CAAE,CAAE,IAAI,KAAK,CAAE,IAAI,CAAC,GAAG,CAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QAE5E,IAAI,KAAK,EAAE;YACP,IAAI,KAAK,IAAI,IAAI,KAAK,KAAK,EAAE;gBACzB,IAAI,KAAK,GAAG,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC;gBACpC,IAAM,WAAW,GAAG,KAAK,CAAC,kBAAkB,CAAE,KAAK,EAAE,SAAS,CAAE,CAAC;gBACjE,WAAW,IAAI,MAAM,CAAC,IAAI,CAAE,WAAW,CAAE,CAAC;gBAE1C,IAAI,KAAK,CAAC,UAAU,CAAE,WAAW,CAAE,EAAE;oBACjC,WAAW,CAAE,KAAK,EAAE,KAAK,CAAE,CAAC;iBAC/B;aACJ;SACJ;aACG;YACA,KAAK,GAAG,gBAAgB,CAAE,UAAU,EAAE,IAAI,EAAE,SAAS,CAAE,CAAC;YACxD,MAAM,CAAC,IAAI,CAAE,KAAK,CAAE,CAAC;YACrB,QAAQ,CAAE,KAAK,EAAE,KAAK,CAAE,CAAC;SAC5B;KACJ;IAED,OAAO,MAAM,CAAC,KAAK,CAAE,UAAU,CAAE,CAAC;AACtC,CAAC"} \ No newline at end of file diff --git a/lib/type-r/collection/commons.d.ts b/lib/type-r/collection/commons.d.ts deleted file mode 100644 index cde26ca..0000000 --- a/lib/type-r/collection/commons.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { Record } from '../record'; -import { Owner, Transaction, TransactionOptions, Transactional } from '../transactions'; -import { eventsApi } from '../object-plus'; -export interface CollectionCore extends Transactional, Owner { - _byId: IdIndex; - models: Record[]; - model: typeof Record; - idAttribute: string; - _comparator: Comparator; - get(objOrId: string | Record | Object): Record; - _itemEvents?: eventsApi.EventMap; - _shared: number; - _aggregationError: Record[]; - _log(level: string, text: string, value: any): void; -} -export declare type Elements = (Object | Record)[]; -export interface CollectionOptions extends TransactionOptions { - sort?: boolean; -} -export declare type Comparator = (a: Record, b: Record) => number; -export declare function dispose(collection: CollectionCore): Record[]; -export declare function convertAndAquire(collection: CollectionCore, attrs: {} | Record, options: CollectionOptions): Record; -export declare function free(owner: CollectionCore, child: Record, unset?: boolean): void; -export declare function freeAll(collection: CollectionCore, children: Record[]): Record[]; -export declare function sortElements(collection: CollectionCore, options: CollectionOptions): boolean; -export interface IdIndex { - [id: string]: Record; -} -export declare function addIndex(index: IdIndex, model: Record): void; -export declare function removeIndex(index: IdIndex, model: Record): void; -export declare function updateIndex(index: IdIndex, model: Record): void; -export declare class CollectionTransaction implements Transaction { - object: CollectionCore; - isRoot: boolean; - added: Record[]; - removed: Record[]; - nested: Transaction[]; - sorted: boolean; - constructor(object: CollectionCore, isRoot: boolean, added: Record[], removed: Record[], nested: Transaction[], sorted: boolean); - commit(initiator?: Transactional): void; -} -export declare function logAggregationError(collection: CollectionCore): void; diff --git a/lib/type-r/collection/commons.js b/lib/type-r/collection/commons.js deleted file mode 100644 index 19816a2..0000000 --- a/lib/type-r/collection/commons.js +++ /dev/null @@ -1,126 +0,0 @@ -import { ItemsBehavior, transactionApi } from '../transactions'; -import { eventsApi } from '../object-plus'; -var EventMap = eventsApi.EventMap, trigger2 = eventsApi.trigger2, trigger3 = eventsApi.trigger3, on = eventsApi.on, off = eventsApi.off, commit = transactionApi.commit, markAsDirty = transactionApi.markAsDirty, _aquire = transactionApi.aquire, _free = transactionApi.free; -export function dispose(collection) { - var models = collection.models; - collection.models = []; - collection._byId = {}; - freeAll(collection, models); - return models; -} -export function convertAndAquire(collection, attrs, options) { - var model = collection.model; - var record; - if (collection._shared) { - record = attrs instanceof model ? attrs : model.create(attrs, options); - if (collection._shared & ItemsBehavior.listen) { - on(record, record._changeEventName, collection._onChildrenChange, collection); - } - } - else { - record = attrs instanceof model ? (options.merge ? attrs.clone() : attrs) : model.create(attrs, options); - if (!_aquire(collection, record)) { - var errors = collection._aggregationError || (collection._aggregationError = []); - errors.push(record); - } - } - var _itemEvents = collection._itemEvents; - _itemEvents && _itemEvents.subscribe(collection, record); - return record; -} -export function free(owner, child, unset) { - if (owner._shared) { - if (owner._shared & ItemsBehavior.listen) { - off(child, child._changeEventName, owner._onChildrenChange, owner); - } - } - else { - _free(owner, child); - unset || child.dispose(); - } - var _itemEvents = owner._itemEvents; - _itemEvents && _itemEvents.unsubscribe(owner, child); -} -export function freeAll(collection, children) { - for (var _i = 0, children_1 = children; _i < children_1.length; _i++) { - var child = children_1[_i]; - free(collection, child); - } - return children; -} -export function sortElements(collection, options) { - var _comparator = collection._comparator; - if (_comparator && options.sort !== false) { - collection.models.sort(_comparator); - return true; - } - return false; -} -export function addIndex(index, model) { - index[model.cid] = model; - var id = model.id; - if (id || id === 0) { - index[id] = model; - } -} -export function removeIndex(index, model) { - delete index[model.cid]; - var id = model.id; - if (id || id === 0) { - delete index[id]; - } -} -export function updateIndex(index, model) { - delete index[model.previous(model.idAttribute)]; - var id = model.id; - id == null || (index[id] = model); -} -var CollectionTransaction = (function () { - function CollectionTransaction(object, isRoot, added, removed, nested, sorted) { - this.object = object; - this.isRoot = isRoot; - this.added = added; - this.removed = removed; - this.nested = nested; - this.sorted = sorted; - } - CollectionTransaction.prototype.commit = function (initiator) { - var _a = this, nested = _a.nested, object = _a.object, _isDirty = object._isDirty; - for (var _i = 0, nested_1 = nested; _i < nested_1.length; _i++) { - var transaction = nested_1[_i]; - transaction.commit(object); - } - if (object._aggregationError) { - logAggregationError(object); - } - for (var _b = 0, nested_2 = nested; _b < nested_2.length; _b++) { - var transaction = nested_2[_b]; - trigger2(object, 'change', transaction.object, _isDirty); - } - var _c = this, added = _c.added, removed = _c.removed; - for (var _d = 0, added_1 = added; _d < added_1.length; _d++) { - var record = added_1[_d]; - trigger3(record, 'add', record, object, _isDirty); - trigger3(object, 'add', record, object, _isDirty); - } - for (var _e = 0, removed_1 = removed; _e < removed_1.length; _e++) { - var record = removed_1[_e]; - trigger3(record, 'remove', record, object, _isDirty); - trigger3(object, 'remove', record, object, _isDirty); - } - if (this.sorted) { - trigger2(object, 'sort', object, _isDirty); - } - if (added.length || removed.length) { - trigger2(object, 'update', object, _isDirty); - } - this.isRoot && commit(object, initiator); - }; - return CollectionTransaction; -}()); -export { CollectionTransaction }; -export function logAggregationError(collection) { - collection._log('error', 'added records already have an owner', collection._aggregationError); - collection._aggregationError = void 0; -} -//# sourceMappingURL=commons.js.map \ No newline at end of file diff --git a/lib/type-r/collection/commons.js.map b/lib/type-r/collection/commons.js.map deleted file mode 100644 index 4ad1a34..0000000 --- a/lib/type-r/collection/commons.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"commons.js","sourceRoot":"","sources":["../../../src/type-r/collection/commons.ts"],"names":[],"mappings":"AACA,OAAO,EAAsB,aAAa,EACC,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAElF,OAAO,EAAE,SAAS,EAAS,MAAM,gBAAgB,CAAA;AAEzC,IAAA,6BAAQ,EAAE,6BAAQ,EAAE,6BAAQ,EAAE,iBAAE,EAAE,mBAAG,EACrC,8BAAM,EAAE,wCAAW,EACrB,OAAO,GAAG,cAAc,CAAC,MAAM,EAAE,KAAK,GAAG,cAAc,CAAC,IAAI,CAAC;AA2BnE,MAAM,UAAU,OAAO,CAAE,UAA2B;IACxC,IAAA,0BAAM,CAAgB;IAE9B,UAAU,CAAC,MAAM,GAAG,EAAE,CAAC;IACvB,UAAU,C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/collection/index.d.ts b/lib/type-r/collection/index.d.ts deleted file mode 100644 index b347d6d..0000000 --- a/lib/type-r/collection/index.d.ts +++ /dev/null @@ -1,85 +0,0 @@ -import { tools, EventMap, EventsDefinition } from '../object-plus'; -import { Transactional, CloneOptions, TransactionOptions, TransactionalDefinition } from '../transactions'; -import { Record, AggregatedType } from '../record'; -import { CollectionCore, CollectionTransaction } from './commons'; -import { AddOptions } from './add'; -import { IOPromise } from '../io-tools'; -export declare type GenericComparator = string | ((x: Record) => number) | ((a: Record, b: Record) => number); -export interface CollectionOptions extends TransactionOptions { - comparator?: GenericComparator; - model?: typeof Record; -} -export declare type Predicate = (val: R, key: number) => boolean | object; -export interface CollectionDefinition extends TransactionalDefinition { - model?: typeof Record; - itemEvents?: EventsDefinition; - _itemEvents?: EventMap; -} -export declare class Collection extends Transactional implements CollectionCore { - _shared: number; - _aggregationError: R[]; - static Subset: typeof Collection; - static Refs: typeof Collection; - static _SubsetOf: typeof Collection; - createSubset(models: ElementsArg, options: any): any; - static onExtend(BaseClass: typeof Transactional): void; - static onDefine(definition: CollectionDefinition, BaseClass: any): void; - static subsetOf: (collectionReference: any) => any; - _itemEvents: EventMap; - models: R[]; - readonly __inner_state__: R[]; - _byId: { - [id: string]: R; - }; - comparator: GenericComparator; - getStore(): Transactional; - _store: Transactional; - _comparator: (a: R, b: R) => number; - _onChildrenChange(record: R, options?: TransactionOptions, initiator?: Transactional): void; - get(objOrId: string | R | Object): R; - each(iteratee: (val: R, key: number) => void, context?: any): void; - forEach(iteratee: (val: R, key?: number) => void, context?: any): void; - every(iteratee: Predicate, context?: any): boolean; - filter(iteratee: Predicate, context?: any): R[]; - find(iteratee: Predicate, context?: any): R; - some(iteratee: Predicate, context?: any): boolean; - map(iteratee: (val: R, key: number) => T, context?: any): T[]; - _validateNested(errors: {}): number; - model: typeof Record; - idAttribute: string; - constructor(records?: (R | {})[], options?: CollectionOptions, shared?: number); - initialize(): void; - readonly length: number; - first(): R; - last(): R; - at(a_index: number): R; - clone(options?: CloneOptions): this; - toJSON(options?: object): any; - set(elements?: ElementsArg, options?: TransactionOptions): this; - liveUpdates(enabled: LiveUpdatesOption): IOPromise; - _liveUpdates: object; - fetch(a_options?: { - liveUpdates?: LiveUpdatesOption; - } & TransactionOptions): IOPromise; - dispose(): void; - reset(a_elements?: ElementsArg, options?: TransactionOptions): R[]; - add(a_elements: ElementsArg, options?: AddOptions): Record[]; - remove(recordsOrIds: any, options?: CollectionOptions): R[] | R; - _createTransaction(a_elements: ElementsArg, options?: TransactionOptions): CollectionTransaction | void; - static _attribute: typeof AggregatedType; - pluck(key: keyof R): any[]; - sort(options?: TransactionOptions): this; - push(model: ElementsArg, options: CollectionOptions): Record[]; - pop(options: CollectionOptions): R; - unset(modelOrId: R | string, options?: any): R; - unshift(model: ElementsArg, options: CollectionOptions): Record[]; - shift(options?: CollectionOptions): R; - slice(): R[]; - indexOf(modelOrId: any): number; - modelId(attrs: {}): any; - toggle(model: R, a_next?: boolean): boolean; - _log(level: tools.LogLevel, text: string, value: any): void; - getClassName(): string; -} -export declare type LiveUpdatesOption = boolean | ((x: any) => boolean); -export declare type ElementsArg = Object | Record | Object[] | Record[]; diff --git a/lib/type-r/collection/index.js b/lib/type-r/collection/index.js deleted file mode 100644 index 7cbebb6..0000000 --- a/lib/type-r/collection/index.js +++ /dev/null @@ -1,438 +0,0 @@ -import * as tslib_1 from "tslib"; -import { define, tools, eventsApi, EventMap, definitions, mixinRules, Mixable } from '../object-plus'; -import { ItemsBehavior, transactionApi, Transactional } from '../transactions'; -import { Record, SharedType, AggregatedType, createSharedTypeSpec } from '../record'; -import { free, sortElements, updateIndex } from './commons'; -import { addTransaction } from './add'; -import { setTransaction, emptySetTransaction } from './set'; -import { removeOne, removeMany } from './remove'; -import { startIO } from '../io-tools'; -var trigger2 = eventsApi.trigger2, on = eventsApi.on, off = eventsApi.off, begin = transactionApi.begin, commit = transactionApi.commit, markAsDirty = transactionApi.markAsDirty, omit = tools.omit, log = tools.log, assign = tools.assign, defaults = tools.defaults, assignToClassProto = tools.assignToClassProto; -var _count = 0; -var slice = Array.prototype.slice; -var CollectionRefsType = (function (_super) { - tslib_1.__extends(CollectionRefsType, _super); - function CollectionRefsType() { - return _super !== null && _super.apply(this, arguments) || this; - } - CollectionRefsType.defaultValue = []; - return CollectionRefsType; -}(SharedType)); -var Collection = (function (_super) { - tslib_1.__extends(Collection, _super); - function Collection(records, options, shared) { - if (options === void 0) { options = {}; } - var _this = _super.call(this, _count++) || this; - _this.models = []; - _this._byId = {}; - _this.comparator = _this.comparator; - if (options.comparator !== void 0) { - _this.comparator = options.comparator; - options.comparator = void 0; - } - _this.model = _this.model; - if (options.model) { - _this.model = options.model; - options.model = void 0; - } - _this.idAttribute = _this.model.prototype.idAttribute; - _this._shared = shared || 0; - if (records) { - var elements = toElements(_this, records, options); - emptySetTransaction(_this, elements, options, true); - } - _this.initialize.apply(_this, arguments); - if (_this._localEvents) - _this._localEvents.subscribe(_this, _this); - return _this; - } - Collection_1 = Collection; - Collection.prototype.createSubset = function (models, options) { - var SubsetOf = this.constructor.subsetOf(this).options.type, subset = new SubsetOf(models, options); - subset.resolve(this); - return subset; - }; - Collection.onExtend = function (BaseClass) { - var Ctor = this; - this._SubsetOf = null; - function RefsCollection(a, b, listen) { - Ctor.call(this, a, b, ItemsBehavior.share | (listen ? ItemsBehavior.listen : 0)); - } - Mixable.mixins.populate(RefsCollection); - RefsCollection.prototype = this.prototype; - RefsCollection._attribute = CollectionRefsType; - this.Refs = this.Subset = RefsCollection; - Transactional.onExtend.call(this, BaseClass); - createSharedTypeSpec(this, SharedType); - }; - Collection.onDefine = function (definition, BaseClass) { - if (definition.itemEvents) { - var eventsMap = new EventMap(BaseClass.prototype._itemEvents); - eventsMap.addEventsMap(definition.itemEvents); - this.prototype._itemEvents = eventsMap; - } - if (definition.comparator !== void 0) - this.prototype.comparator = definition.comparator; - Transactional.onDefine.call(this, definition); - }; - Object.defineProperty(Collection.prototype, "__inner_state__", { - get: function () { return this.models; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Collection.prototype, "comparator", { - get: function () { return this._comparator; }, - set: function (x) { - var _this = this; - var compare; - switch (typeof x) { - case 'string': - this._comparator = function (a, b) { - var aa = a[x], bb = b[x]; - if (aa === bb) - return 0; - return aa < bb ? -1 : +1; - }; - break; - case 'function': - if (x.length === 1) { - this._comparator = function (a, b) { - var aa = x.call(_this, a), bb = x.call(_this, b); - if (aa === bb) - return 0; - return aa < bb ? -1 : +1; - }; - } - else { - this._comparator = function (a, b) { return x.call(_this, a, b); }; - } - break; - default: - this._comparator = null; - } - }, - enumerable: true, - configurable: true - }); - Collection.prototype.getStore = function () { - return this._store || (this._store = this._owner ? this._owner.getStore() : this._defaultStore); - }; - Collection.prototype._onChildrenChange = function (record, options, initiator) { - if (options === void 0) { options = {}; } - if (initiator === this) - return; - var idAttribute = this.idAttribute; - if (record.hasChanged(idAttribute)) { - updateIndex(this._byId, record); - } - var isRoot = begin(this); - if (markAsDirty(this, options)) { - trigger2(this, 'change', record, options); - } - isRoot && commit(this); - }; - Collection.prototype.get = function (objOrId) { - if (objOrId == null) - return; - if (typeof objOrId === 'object') { - var id = objOrId[this.idAttribute]; - return (id !== void 0 && this._byId[id]) || this._byId[objOrId.cid]; - } - else { - return this._byId[objOrId]; - } - }; - Collection.prototype.each = function (iteratee, context) { - var fun = bindContext(iteratee, context), models = this.models; - for (var i = 0; i < models.length; i++) { - fun(models[i], i); - } - }; - Collection.prototype.forEach = function (iteratee, context) { - return this.each(iteratee, context); - }; - Collection.prototype.every = function (iteratee, context) { - var fun = toPredicateFunction(iteratee, context), models = this.models; - for (var i = 0; i < models.length; i++) { - if (!fun(models[i], i)) - return false; - } - return true; - }; - Collection.prototype.filter = function (iteratee, context) { - var fun = toPredicateFunction(iteratee, context), models = this.models; - return this.map(function (x, i) { return fun(x, i) ? x : void 0; }); - }; - Collection.prototype.find = function (iteratee, context) { - var fun = toPredicateFunction(iteratee, context), models = this.models; - for (var i = 0; i < models.length; i++) { - if (fun(models[i], i)) - return models[i]; - } - return null; - }; - Collection.prototype.some = function (iteratee, context) { - return Boolean(this.find(iteratee, context)); - }; - Collection.prototype.map = function (iteratee, context) { - var fun = bindContext(iteratee, context), models = this.models, mapped = Array(models.length); - var j = 0; - for (var i = 0; i < models.length; i++) { - var x = fun(models[i], i); - x === void 0 || (mapped[j++] = x); - } - mapped.length = j; - return mapped; - }; - Collection.prototype._validateNested = function (errors) { - if (this._shared) - return 0; - var count = 0; - this.each(function (record) { - var error = record.validationError; - if (error) { - errors[record.cid] = error; - count++; - } - }); - return count; - }; - Collection.prototype.initialize = function () { }; - Object.defineProperty(Collection.prototype, "length", { - get: function () { return this.models.length; }, - enumerable: true, - configurable: true - }); - Collection.prototype.first = function () { return this.models[0]; }; - Collection.prototype.last = function () { return this.models[this.models.length - 1]; }; - Collection.prototype.at = function (a_index) { - var index = a_index < 0 ? a_index + this.models.length : a_index; - return this.models[index]; - }; - Collection.prototype.clone = function (options) { - if (options === void 0) { options = {}; } - var models = this._shared & ItemsBehavior.share ? this.models : this.map(function (model) { return model.clone(); }), copy = new this.constructor(models, { model: this.model, comparator: this.comparator }, this._shared); - if (options.pinStore) - copy._defaultStore = this.getStore(); - return copy; - }; - Collection.prototype.toJSON = function (options) { - return this.models.map(function (model) { return model.toJSON(options); }); - }; - Collection.prototype.set = function (elements, options) { - if (elements === void 0) { elements = []; } - if (options === void 0) { options = {}; } - if (options.add !== void 0) { - this._log('warn', "Collection.set doesn't support 'add' option, behaving as if options.add === true.", options); - } - if (options.reset) { - this.reset(elements, options); - } - else { - var transaction = this._createTransaction(elements, options); - transaction && transaction.commit(); - } - return this; - }; - Collection.prototype.liveUpdates = function (enabled) { - var _this = this; - if (enabled) { - this.liveUpdates(false); - var filter_1 = typeof enabled === 'function' ? enabled : function () { return true; }; - this._liveUpdates = { - updated: function (json) { - filter_1(json) && _this.add(json, { parse: true, merge: true }); - }, - removed: function (id) { return _this.remove(id); } - }; - return this.getEndpoint().subscribe(this._liveUpdates, this).then(function () { return _this; }); - } - else { - if (this._liveUpdates) { - this.getEndpoint().unsubscribe(this._liveUpdates, this); - this._liveUpdates = null; - } - } - }; - Collection.prototype.fetch = function (a_options) { - var _this = this; - if (a_options === void 0) { a_options = {}; } - var options = tslib_1.__assign({ parse: true }, a_options), endpoint = this.getEndpoint(); - return startIO(this, endpoint.list(options, this), options, function (json) { - var result = _this.set(json, tslib_1.__assign({ parse: true }, options)); - if (options.liveUpdates) { - result = _this.liveUpdates(options.liveUpdates); - } - return result; - }); - }; - Collection.prototype.dispose = function () { - if (this._disposed) - return; - var aggregated = !this._shared; - for (var _i = 0, _a = this.models; _i < _a.length; _i++) { - var record = _a[_i]; - free(this, record); - if (aggregated) - record.dispose(); - } - this.liveUpdates(false); - _super.prototype.dispose.call(this); - }; - Collection.prototype.reset = function (a_elements, options) { - if (options === void 0) { options = {}; } - var isRoot = begin(this), previousModels = this.models; - if (a_elements) { - emptySetTransaction(this, toElements(this, a_elements, options), options, true); - } - else { - this._byId = {}; - this.models = []; - } - markAsDirty(this, options); - options.silent || trigger2(this, 'reset', this, defaults({ previousModels: previousModels }, options)); - var _byId = this._byId; - for (var _i = 0, previousModels_1 = previousModels; _i < previousModels_1.length; _i++) { - var toDispose = previousModels_1[_i]; - _byId[toDispose.cid] || free(this, toDispose); - } - isRoot && commit(this); - return this.models; - }; - Collection.prototype.add = function (a_elements, options) { - if (options === void 0) { options = {}; } - var elements = toElements(this, a_elements, options), transaction = this.models.length ? - addTransaction(this, elements, options) : - emptySetTransaction(this, elements, options); - if (transaction) { - transaction.commit(); - return transaction.added; - } - }; - Collection.prototype.remove = function (recordsOrIds, options) { - if (options === void 0) { options = {}; } - if (recordsOrIds) { - return Array.isArray(recordsOrIds) ? - removeMany(this, recordsOrIds, options) : - removeOne(this, recordsOrIds, options); - } - return []; - }; - Collection.prototype._createTransaction = function (a_elements, options) { - if (options === void 0) { options = {}; } - var elements = toElements(this, a_elements, options); - if (this.models.length) { - return options.remove === false ? - addTransaction(this, elements, options, true) : - setTransaction(this, elements, options); - } - else { - return emptySetTransaction(this, elements, options); - } - }; - Collection.prototype.pluck = function (key) { - return this.models.map(function (model) { return model[key]; }); - }; - Collection.prototype.sort = function (options) { - if (options === void 0) { options = {}; } - if (sortElements(this, options)) { - var isRoot = begin(this); - if (markAsDirty(this, options)) { - trigger2(this, 'sort', this, options); - } - isRoot && commit(this); - } - return this; - }; - Collection.prototype.push = function (model, options) { - return this.add(model, assign({ at: this.length }, options)); - }; - Collection.prototype.pop = function (options) { - var model = this.at(this.length - 1); - this.remove(model, tslib_1.__assign({ unset: true }, options)); - return model; - }; - Collection.prototype.unset = function (modelOrId, options) { - var value = this.get(modelOrId); - this.remove(modelOrId, tslib_1.__assign({ unset: true }, options)); - return value; - }; - Collection.prototype.unshift = function (model, options) { - return this.add(model, assign({ at: 0 }, options)); - }; - Collection.prototype.shift = function (options) { - var model = this.at(0); - this.remove(model, tslib_1.__assign({ unset: true }, options)); - return model; - }; - Collection.prototype.slice = function () { - return slice.apply(this.models, arguments); - }; - Collection.prototype.indexOf = function (modelOrId) { - var record = this.get(modelOrId); - return this.models.indexOf(record); - }; - Collection.prototype.modelId = function (attrs) { - return attrs[this.model.prototype.idAttribute]; - }; - Collection.prototype.toggle = function (model, a_next) { - var prev = Boolean(this.get(model)), next = a_next === void 0 ? !prev : Boolean(a_next); - if (prev !== next) { - if (prev) { - this.remove(model); - } - else { - this.add(model); - } - } - return next; - }; - Collection.prototype._log = function (level, text, value) { - tools.log(level, "[Collection Update] " + this.model.prototype.getClassName() + "." + this.getClassName() + ": " + text, { - Argument: value, - 'Attributes spec': this.model.prototype._attributes - }); - }; - Collection.prototype.getClassName = function () { - return _super.prototype.getClassName.call(this) || 'Collection'; - }; - var Collection_1; - Collection._attribute = AggregatedType; - Collection = Collection_1 = tslib_1.__decorate([ - define({ - cidPrefix: 'c', - model: Record, - _changeEventName: 'changes', - _aggregationError: null - }), - definitions({ - comparator: mixinRules.value, - model: mixinRules.protoValue, - itemEvents: mixinRules.merge - }) - ], Collection); - return Collection; -}(Transactional)); -export { Collection }; -function toElements(collection, elements, options) { - var parsed = options.parse ? collection.parse(elements, options) : elements; - return Array.isArray(parsed) ? parsed : [parsed]; -} -createSharedTypeSpec(Collection, SharedType); -Record.Collection = Collection; -function bindContext(fun, context) { - return context !== void 0 ? function (v, k) { return fun.call(context, v, k); } : fun; -} -function toPredicateFunction(iteratee, context) { - if (typeof iteratee === 'object') { - return function (x) { - for (var key in iteratee) { - if (iteratee[key] !== x[key]) - return false; - } - return true; - }; - } - return bindContext(iteratee, context); -} -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/lib/type-r/collection/index.js.map b/lib/type-r/collection/index.js.map deleted file mode 100644 index 0834f87..0000000 --- a/lib/type-r/collection/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/type-r/collection/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAoB,OAAO,EAAE,MAAM,gBAAgB,CAAA;AACvH,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,EAAiF,MAAM,iBAAiB,CAAA;AAC7J,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAEpF,OAAO,EAAW,IAAI,EAAE,YAAY,EAA4D,WAAW,EAAqC,MAAM,WAAW,CAAA;AACjK,OAAO,EAAE,cAAc,EAAc,MAAM,OAAO,CAAA;AAClD,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAA;AAC3D,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAChD,OAAO,EAAa,OAAO,EAAE,MAAM,aAAa,CAAA;AAExC,IAAA,6BAAQ,EAAE,iBAAE,EAAE,mBAAG,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-r/collection/remove.d.ts deleted file mode 100644 index ffaa6b4..0000000 --- a/lib/type-r/collection/remove.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { Record } from '../record'; -import { CollectionCore } from './commons'; -import { TransactionOptions } from '../transactions'; -export declare function removeOne(collection: CollectionCore, el: Record | {} | string, options: TransactionOptions): Record; -export declare function removeMany(collection: CollectionCore, toRemove: any[], options: any): any[]; diff --git a/lib/type-r/collection/remove.js b/lib/type-r/collection/remove.js deleted file mode 100644 index c17aa4f..0000000 --- a/lib/type-r/collection/remove.js +++ /dev/null @@ -1,62 +0,0 @@ -import { free, CollectionTransaction, removeIndex } from './commons'; -import { eventsApi } from '../object-plus'; -import { transactionApi } from '../transactions'; -var trigger2 = eventsApi.trigger2, trigger3 = eventsApi.trigger3, markAsDirty = transactionApi.markAsDirty, begin = transactionApi.begin, commit = transactionApi.commit; -export function removeOne(collection, el, options) { - var model = collection.get(el); - if (model) { - var isRoot = begin(collection), models = collection.models; - models.splice(models.indexOf(model), 1); - removeIndex(collection._byId, model); - var notify = markAsDirty(collection, options); - if (notify) { - trigger3(model, 'remove', model, collection, options); - trigger3(collection, 'remove', model, collection, options); - } - free(collection, model, options.unset); - notify && trigger2(collection, 'update', collection, options); - isRoot && commit(collection); - return model; - } -} -; -export function removeMany(collection, toRemove, options) { - var removed = _removeFromIndex(collection, toRemove, options.unset); - if (removed.length) { - var isRoot = begin(collection); - _reallocate(collection, removed.length); - if (markAsDirty(collection, options)) { - var transaction = new CollectionTransaction(collection, isRoot, [], removed, [], false); - transaction.commit(); - } - else { - isRoot && commit(collection); - } - } - return removed; -} -; -function _removeFromIndex(collection, toRemove, unset) { - var removed = Array(toRemove.length), _byId = collection._byId; - for (var i = 0, j = 0; i < toRemove.length; i++) { - var model = collection.get(toRemove[i]); - if (model) { - removed[j++] = model; - removeIndex(_byId, model); - free(collection, model, unset); - } - } - removed.length = j; - return removed; -} -function _reallocate(collection, removed) { - var prev = collection.models, models = collection.models = Array(prev.length - removed), _byId = collection._byId; - for (var i = 0, j = 0; i < prev.length; i++) { - var model = prev[i]; - if (_byId[model.cid]) { - models[j++] = model; - } - } - models.length = j; -} -//# sourceMappingURL=remove.js.map \ No newline at end of file diff --git a/lib/type-r/collection/remove.js.map b/lib/type-r/collection/remove.js.map deleted file mode 100644 index 5744a0a..0000000 --- a/lib/type-r/collection/remove.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"remove.js","sourceRoot":"","sources":["../../../src/type-r/collection/remove.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,IAAI,EAAkB,qBAAqB,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AACpF,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAsB,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAE5D,IAAA,6BAAQ,EAAE,6BAAQ,EACpB,wCAAW,EAAE,4BAAK,EAAE,8BAAM,CAAoB;AAGpD,MAAM,UAAU,SAAS,CAAE,UAA2B,EAAE,EAAyB,EAAE,OAA4B;IAC3G,IAAI,KAAK,GAAY,UAAU,CAAC,GAAG,CAAE,EAAE,CAAE,CAAC;IAE1C,IAAI,KAAK,EAAE;QACP,IAAM,MAAM,GAAG,KAAK,CAAE,UAAU,CAAE,EAC5B,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;QAGjC,MAAM,CAAC,MAAM,CAAE,MAAM,CAAC,OAAO,CAAE,KAAK,CAAE,EAAE,CAAC,CAAE,CAAC;QAC5C,WAAW,CAAE,UAAU,CAAC,KAAK,EAAE,KAAK,CAAE,CAAC;QAGvC,IAAM,MAAM,GAAG,WAAW,CAAE,UAAU,EAAE,OAAO,CAAE,CAAC;QAGlD,IAAI,MAAM,EAAE;YACR,QAAQ,CAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,CAAE,CAAC;YACxD,QAAQ,CAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAA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K,GAAG,UAAU,CAAC,GAAG,CAAE,QAAQ,CAAE,CAAC,CAAE,CAAE,CAAC;QAC5C,IAAI,KAAK,EAAE;YACP,OAAO,CAAE,CAAC,EAAE,CAAE,GAAG,KAAK,CAAC;YACvB,WAAW,CAAE,KAAK,EAAE,KAAK,CAAE,CAAC;YAC5B,IAAI,CAAE,UAAU,EAAE,KAAK,EAAE,KAAK,CAAE,CAAC;SACpC;KACJ;IAED,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;IAEnB,OAAO,OAAO,CAAC;AACnB,CAAC;AAID,SAAS,WAAW,CAAE,UAAU,EAAE,OAAO;IACrC,IAAI,IAAI,GAAK,UAAU,CAAC,MAAM,EAC1B,MAAM,GAAG,UAAU,CAAC,MAAM,GAAG,KAAK,CAAE,IAAI,CAAC,MAAM,GAAG,OAAO,CAAE,EAC3D,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC;IAE7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACzC,IAAI,KAAK,GAAG,IAAI,CAAE,CAAC,CAAE,CAAC;QAEtB,IAAI,KAAK,CAAE,KAAK,CAAC,GAAG,CAAE,EAAE;YACpB,MAAM,CAAE,CAAC,EAAE,CAAE,GAAG,KAAK,CAAC;SACzB;KACJ;IAED,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;AACtB,CAAC"} \ No newline at end of file diff --git a/lib/type-r/collection/set.d.ts b/lib/type-r/collection/set.d.ts deleted file mode 100644 index eb0830a..0000000 --- a/lib/type-r/collection/set.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { CollectionTransaction, CollectionOptions, CollectionCore, Elements } from './commons'; -export declare function emptySetTransaction(collection: CollectionCore, items: Elements, options: CollectionOptions, silent?: boolean): CollectionTransaction; -export declare function setTransaction(collection: any, items: any, options: any): CollectionTransaction; diff --git a/lib/type-r/collection/set.js b/lib/type-r/collection/set.js deleted file mode 100644 index 99efd26..0000000 --- a/lib/type-r/collection/set.js +++ /dev/null @@ -1,94 +0,0 @@ -import { transactionApi } from '../transactions'; -import { CollectionTransaction, logAggregationError, convertAndAquire, free, sortElements, addIndex, freeAll } from './commons'; -var begin = transactionApi.begin, commit = transactionApi.commit, markAsDirty = transactionApi.markAsDirty; -var silentOptions = { silent: true }; -export function emptySetTransaction(collection, items, options, silent) { - var isRoot = begin(collection); - var added = _reallocateEmpty(collection, items, options); - if (added.length) { - var needSort = sortElements(collection, options); - if (markAsDirty(collection, silent ? silentOptions : options)) { - return new CollectionTransaction(collection, isRoot, added.slice(), [], [], needSort); - } - if (collection._aggregationError) - logAggregationError(collection); - } - isRoot && commit(collection); -} -; -export function setTransaction(collection, items, options) { - var isRoot = begin(collection), nested = []; - var previous = collection.models, added = _reallocate(collection, items, nested, options); - var reusedCount = collection.models.length - added.length, removed = reusedCount < previous.length ? (reusedCount ? _garbageCollect(collection, previous) : - freeAll(collection, previous)) : []; - var addedOrChanged = nested.length || added.length, sorted = (sortElements(collection, options) && addedOrChanged) || added.length || options.sorted; - if (addedOrChanged || removed.length || sorted) { - if (markAsDirty(collection, options)) { - return new CollectionTransaction(collection, isRoot, added, removed, nested, sorted); - } - if (collection._aggregationError) - logAggregationError(collection); - } - isRoot && commit(collection); -} -; -function _garbageCollect(collection, previous) { - var _byId = collection._byId, removed = []; - for (var _i = 0, previous_1 = previous; _i < previous_1.length; _i++) { - var record = previous_1[_i]; - if (!_byId[record.cid]) { - removed.push(record); - free(collection, record); - } - } - return removed; -} -function _reallocate(collection, source, nested, options) { - var models = Array(source.length), _byId = {}, merge = (options.merge == null ? true : options.merge) && !collection._shared, _prevById = collection._byId, prevModels = collection.models, idAttribute = collection.model.prototype.idAttribute, toAdd = [], orderKept = true; - for (var i = 0, j = 0; i < source.length; i++) { - var item = source[i], model = null; - if (item) { - var id = item[idAttribute], cid = item.cid; - if (_byId[id] || _byId[cid]) - continue; - model = _prevById[id] || _prevById[cid]; - } - if (model) { - if (merge && item !== model) { - if (orderKept && prevModels[j] !== model) - orderKept = false; - var attrs = item.attributes || item; - var transaction = model._createTransaction(attrs, options); - transaction && nested.push(transaction); - } - } - else { - model = convertAndAquire(collection, item, options); - toAdd.push(model); - } - models[j++] = model; - addIndex(_byId, model); - } - models.length = j; - collection.models = models; - collection._byId = _byId; - if (!orderKept) - options.sorted = true; - return toAdd; -} -function _reallocateEmpty(self, source, options) { - var len = source ? source.length : 0, models = Array(len), _byId = {}, idAttribute = self.model.prototype.idAttribute; - for (var i = 0, j = 0; i < len; i++) { - var src = source[i]; - if (src && (_byId[src[idAttribute]] || _byId[src.cid])) { - continue; - } - var model = convertAndAquire(self, src, options); - models[j++] = model; - addIndex(_byId, model); - } - models.length = j; - self._byId = _byId; - return self.models = models; -} -//# sourceMappingURL=set.js.map \ No newline at end of file diff --git a/lib/type-r/collection/set.js.map b/lib/type-r/collection/set.js.map deleted file mode 100644 index 7da33d2..0000000 --- a/lib/type-r/collection/set.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"set.js","sourceRoot":"","sources":["../../../src/type-r/collection/set.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAC7D,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAW,gBAAgB,EAAE,IAAI,EAAE,YAAY,EAAqB,QAAQ,EAA4B,OAAO,EAAE,MAAM,WAAW,CAAA;AAG7K,IAAA,4BAAK,EAAE,8BAAM,EAAE,wCAAW,CAAoB;AAGtD,IAAM,aAAa,GAAG,EAAE,MAAM,EAAG,IAAI,EAAE,CAAC;AAGxC,MAAM,UAAU,mBAAmB,CAAE,UAA2B,EAAE,KAAgB,EAAE,OAA2B,EAAE,MAAiB;IAC9H,IAAM,MAAM,GAAG,KAAK,CAAE,UAAU,CAAE,CAAC;IAEnC,IAAM,KAAK,GAAG,gBAAgB,CAAE,UAAU,EAAE,KAAK,EAAE,O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/null @@ -1,19 +0,0 @@ -declare global { - interface ObjectConstructor { - setPrototypeOf(target: Object, proto: Object): any; - } -} -export * from './object-plus'; -export * from './collection'; -export * from './relations'; -export * from './record'; -export * from './transactions'; -export * from './io-tools'; -export declare const on: any, off: any, trigger: any, once: any, listenTo: any, stopListening: any, listenToOnce: any; -import { Record as Model } from './record'; -import { Mixable as Class } from './object-plus/'; -export { Model, Class }; -export declare function attributes(attrDefs: any): typeof Model; -import { ChainableAttributeSpec } from './record'; -export declare function value(x: any): ChainableAttributeSpec; -export declare function transaction(method: F): F; diff --git a/lib/type-r/index.js b/lib/type-r/index.js deleted file mode 100644 index 57d167b..0000000 --- a/lib/type-r/index.js +++ /dev/null @@ -1,48 +0,0 @@ -import * as tslib_1 from "tslib"; -var _a; -import { tools } from './object-plus'; -Object.setPrototypeOf || (Object.setPrototypeOf = tools.defaults); -export * from './object-plus'; -export * from './collection'; -export * from './relations'; -export * from './record'; -export * from './transactions'; -export * from './io-tools'; -import { Events } from './object-plus/'; -export var on = (_a = Events, _a.on), off = _a.off, trigger = _a.trigger, once = _a.once, listenTo = _a.listenTo, stopListening = _a.stopListening, listenToOnce = _a.listenToOnce; -import { Record as Model } from './record'; -import { define, Mixable as Class } from './object-plus/'; -export { Model, Class }; -export function attributes(attrDefs) { - var DefaultRecord = (function (_super) { - tslib_1.__extends(DefaultRecord, _super); - function DefaultRecord() { - return _super !== null && _super.apply(this, arguments) || this; - } - DefaultRecord.attributes = attrDefs; - DefaultRecord = tslib_1.__decorate([ - define - ], DefaultRecord); - return DefaultRecord; - }(Model)); - return DefaultRecord; -} -import { ChainableAttributeSpec } from './record'; -export function value(x) { - return new ChainableAttributeSpec({ value: x }); -} -export function transaction(method) { - return function () { - var _this = this; - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - var result; - this.transaction(function () { - result = method.apply(_this, args); - }); - return result; - }; -} -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/lib/type-r/index.js.map b/lib/type-r/index.js.map deleted file mode 100644 index e88cf93..0000000 --- a/lib/type-r/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/type-r/index.ts"],"names":[],"mappings":";;AACA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAQrC,MAAM,CAAC,cAAc,IAAI,CAAE,MAAM,CAAC,cAAc,GAAG,KAAK,CAAC,QAAQ,CAAE,CAAC;AAMpE,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,UAAU,CAAA;AACxB,cAAc,gBAAgB,CAAA;AAE9B,cAAc,YAAY,CAAA;AAG1B,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,MAAM,CAAS,IAAA,yBAAE,EAAE,YAAG,EAAE,oBAAO,EAAE,cAAI,EAAE,sBAAQ,EAAE,gCAAa,EAAE,8BAAY,CAAiB;AAK7F,OAAO,EAAE,MAAM,IAAI,KAAK,EAAE,MAAM,UAAU,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,gBAAgB,CAAA;AACzD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AAExB,MAAM,UAAU,UAAU,CAAE,QAAQ;IACxB;QAA4B,yCAAK;QAAjC;;QAER,CAAC;QADU,wBAAU,GAAG,QAAQ,CAAC;QADnB,aAAa;YAA1B,MAAM;WAAO,aAAa,CAE1B;QAAD,oBAAC;KAAA,AAFO,CAA4B,KAAK,GAExC;IAED,OAAO,aAAa,CAAC;AACzB,CAAC;AAED,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAGjD,MAAM,UAAU,KAAK,CAAE,CAAO;IAC1B,OAAO,IAAI,sBAAsB,CAAC,EAAE,KAAK,EAAG,CAAC,EAAE,CAAC,CAAC;AACrD,CAAC;AAGD,MAAM,UAAU,WAAW,CAAwB,MAAU;IACzD,OAAY;QAAA,iBAQX;QARqB,cAAO;aAAP,UAAO,EAAP,qBAAO,EAAP,IAAO;YAAP,yBAAO;;QACzB,IAAI,MAAM,CAAC;QAEX,IAAI,CAAC,WAAW,CAAE;YACd,MAAM,GAAG,MAAM,CAAC,KAAK,CAAE,KAAI,EAAE,IAAI,CAAE,CAAC;QACxC,CAAC,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC;IAClB,CAAC,CAAA;AACL,CAAC"} \ No newline at end of file diff --git a/lib/type-r/io-tools.d.ts b/lib/type-r/io-tools.d.ts deleted file mode 100644 index 9e6c5c2..0000000 --- a/lib/type-r/io-tools.d.ts +++ /dev/null @@ -1,29 +0,0 @@ -export interface IONode { - _endpoint: IOEndpoint; - _ioPromise: IOPromise; -} -export interface IOPromise extends Promise { - abort?: () => void; -} -export interface IOEndpoint { - list(options: IOOptions, collection?: any): IOPromise; - create(json: any, options: IOOptions, record?: any): IOPromise; - update(id: string | number, json: any, options: IOOptions, record?: any): IOPromise; - read(id: string | number, options: IOOptions, record?: any): IOPromise; - destroy(id: string | number, options: IOOptions, record?: any): IOPromise; - subscribe(events: IOEvents, collection?: any): IOPromise; - unsubscribe(events: IOEvents, collection?: any): void; -} -export interface IOOptions { - ioUpdate?: boolean; -} -export interface IOEvents { - updated?: (json: any) => void; - removed?: (json: any) => void; -} -export declare function getOwnerEndpoint(self: any): IOEndpoint; -export declare function createIOPromise(initialize: InitIOPromise): IOPromise; -export declare type InitIOPromise = (resolve: (x?: any) => void, reject: (x?: any) => void, abort?: (fn: Function) => void) => void; -export declare function startIO(self: IONode, promise: IOPromise, options: IOOptions, thenDo: (json: any) => any): IOPromise; -export declare function abortIO(self: IONode): void; -export declare function triggerAndBubble(eventSource: any, ...args: any[]): void; diff --git a/lib/type-r/io-tools.js b/lib/type-r/io-tools.js deleted file mode 100644 index ae0d2b4..0000000 --- a/lib/type-r/io-tools.js +++ /dev/null @@ -1,60 +0,0 @@ -export function getOwnerEndpoint(self) { - var collection = self.collection; - if (collection) { - return getOwnerEndpoint(collection); - } - if (self._owner) { - var _endpoints = self._owner._endpoints; - return _endpoints && _endpoints[self._ownerKey]; - } -} -export function createIOPromise(initialize) { - var resolve, reject, onAbort; - function abort(fn) { - onAbort = fn; - } - var promise = new Promise(function (a_resolve, a_reject) { - reject = a_reject; - resolve = a_resolve; - initialize(resolve, reject, abort); - }); - promise.abort = function () { - onAbort ? onAbort(resolve, reject) : reject(new Error("I/O Aborted")); - }; - return promise; -} -export function startIO(self, promise, options, thenDo) { - abortIO(self); - options.ioUpdate = true; - self._ioPromise = promise - .then(function (resp) { - self._ioPromise = null; - var result = thenDo ? thenDo(resp) : resp; - triggerAndBubble(self, 'sync', self, resp, options); - return result; - }) - .catch(function (err) { - self._ioPromise = null; - console.error(err); - triggerAndBubble(self, 'error', self, err, options); - throw err; - }); - self._ioPromise.abort = promise.abort; - return self._ioPromise; -} -export function abortIO(self) { - if (self._ioPromise && self._ioPromise.abort) { - self._ioPromise.abort(); - self._ioPromise = null; - } -} -export function triggerAndBubble(eventSource) { - var args = []; - for (var _i = 1; _i < arguments.length; _i++) { - args[_i - 1] = arguments[_i]; - } - eventSource.trigger.apply(eventSource, args); - var collection = eventSource.collection; - collection && collection.trigger.apply(collection, args); -} -//# sourceMappingURL=io-tools.js.map \ No newline at end of file diff --git a/lib/type-r/io-tools.js.map b/lib/type-r/io-tools.js.map deleted file mode 100644 index 634522b..0000000 --- a/lib/type-r/io-tools.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"io-tools.js","sourceRoot":"","sources":["../../src/type-r/io-tools.ts"],"names":[],"mappings":"AA4BA,MAAM,UAAU,gBAAgB,CAAE,IAAI;IAE1B,IAAA,4BAAU,CAAU;IAC5B,IAAI,UAAU,EAAE;QACZ,OAAO,gBAAgB,CAAE,UAAU,CAAE,CAAC;KACzC;IAGD,IAAI,IAAI,CAAC,MAAM,EAAE;QACL,IAAA,mCAAU,CAAiB;QACnC,OAAO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C;QAEvB,OAAO,CAAC,KAAK,CAAE,GAAG,CAAE,CAAC;QAErB,gBAAgB,CAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,CAAE,CAAC;QAEtD,MAAM,GAAG,CAAC;IACd,CAAC,CAAoB,CAAC;IAE1B,IAAI,CAAC,UAAU,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAEtC,OAAO,IAAI,CAAC,UAAU,CAAC;AAC3B,CAAC;AAED,MAAM,UAAU,OAAO,CAAE,IAAa;IAClC,IAAI,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE;QAC1C,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;QACxB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;KAC1B;AACL,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAE,WAAW;IAAE,cAAO;SAAP,UAAO,EAAP,qBAAO,EAAP,IAAO;QAAP,6BAAO;;IAClD,WAAW,CAAC,OAAO,CAAC,KAAK,CAAE,WAAW,EAAE,IAAI,CAAE,CAAC;IACvC,IAAA,mCAAU,CAAiB;IACnC,UAAU,IAAI,UAAU,CAAC,OAAO,CAAC,KAAK,CAAE,UAAU,EAAE,IAAI,CAAE,CAAC;AAC/D,CAAC"} \ No newline at end of file diff --git a/lib/type-r/object-plus/events.d.ts b/lib/type-r/object-plus/events.d.ts deleted file mode 100644 index 1b5a5d8..0000000 --- a/lib/type-r/object-plus/events.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { Mixable, MixableConstructor, MixinsState } from './mixins'; -import { EventMap, EventsDefinition, EventSource, HandlersByEvent } from './eventsource'; -export { EventMap, EventsDefinition }; -export interface MessengerDefinition { - _localEvents?: EventMap; - localEvents?: EventsDefinition; - properties?: PropertyMap; - [name: string]: any; -} -export interface PropertyMap { - [name: string]: Property; -} -export declare type Property = PropertyDescriptor | (() => any); -export interface MessengersByCid { - [cid: string]: Messenger; -} -export declare type CallbacksByEvents = { - [events: string]: Function; -}; -export declare abstract class Messenger implements Mixable, EventSource { - static __super__: object; - static mixins: MixinsState; - static onExtend: (BaseClass: Function) => void; - static define: (definition?: MessengerDefinition, statics?: object) => MixableConstructor; - static extend: (definition?: MessengerDefinition, statics?: object) => MixableConstructor; - static onDefine({ localEvents, _localEvents, properties }: MessengerDefinition, BaseClass?: typeof Mixable): void; - _events: HandlersByEvent; - _listeningTo: MessengersByCid; - cid: string; - _localEvents: EventMap; - constructor(); - initialize(): void; - on(events: string | CallbacksByEvents, callback: any, context?: any): this; - once(events: string | CallbacksByEvents, callback: any, context?: any): this; - off(events?: string | CallbacksByEvents, callback?: any, context?: any): this; - trigger(name: string, a?: any, b?: any, c?: any, d?: any, e?: any): this; - listenTo(source: Messenger, a: string | CallbacksByEvents, b?: Function): this; - listenToOnce(source: Messenger, a: string | CallbacksByEvents, b?: Function): this; - stopListening(a_source?: Messenger, a?: string | CallbacksByEvents, b?: Function): this; - _disposed: boolean; - dispose(): void; -} -export declare const Events: Messenger; diff --git a/lib/type-r/object-plus/events.js b/lib/type-r/object-plus/events.js deleted file mode 100644 index 221066c..0000000 --- a/lib/type-r/object-plus/events.js +++ /dev/null @@ -1,130 +0,0 @@ -import * as tslib_1 from "tslib"; -import { define, mixinRules, definitions } from './mixins'; -import { omit, transform } from './tools'; -import { EventMap } from './eventsource'; -import * as _eventsApi from './eventsource'; -var EventHandler = _eventsApi.EventHandler, strings = _eventsApi.strings, on = _eventsApi.on, off = _eventsApi.off, once = _eventsApi.once, trigger5 = _eventsApi.trigger5, trigger2 = _eventsApi.trigger2, trigger3 = _eventsApi.trigger3; -var eventSplitter = /\s+/; -var _idCount = 0; -function uniqueId() { - return 'l' + _idCount++; -} -export { EventMap }; -var Messenger = (function () { - function Messenger() { - this._events = void 0; - this._listeningTo = void 0; - this.cid = uniqueId(); - this.initialize.apply(this, arguments); - } - Messenger.onDefine = function (_a, BaseClass) { - var localEvents = _a.localEvents, _localEvents = _a._localEvents, properties = _a.properties; - if (localEvents || _localEvents) { - var eventsMap = new EventMap(this.prototype._localEvents); - localEvents && eventsMap.addEventsMap(localEvents); - _localEvents && eventsMap.merge(_localEvents); - this.prototype._localEvents = eventsMap; - } - if (properties) { - Object.defineProperties(this.prototype, transform({}, properties, toPropertyDescriptor)); - } - }; - Messenger.prototype.initialize = function () { }; - Messenger.prototype.on = function (events, callback, context) { - if (typeof events === 'string') - strings(on, this, events, callback, context); - else - for (var name_1 in events) - strings(on, this, name_1, events[name_1], context || callback); - return this; - }; - Messenger.prototype.once = function (events, callback, context) { - if (typeof events === 'string') - strings(once, this, events, callback, context); - else - for (var name_2 in events) - strings(once, this, name_2, events[name_2], context || callback); - return this; - }; - Messenger.prototype.off = function (events, callback, context) { - if (!events) - off(this, void 0, callback, context); - else if (typeof events === 'string') - strings(off, this, events, callback, context); - else - for (var name_3 in events) - strings(off, this, name_3, events[name_3], context || callback); - return this; - }; - Messenger.prototype.trigger = function (name, a, b, c, d, e) { - if (d !== void 0 || e !== void 0) - trigger5(this, name, a, b, c, d, e); - else if (c !== void 0) - trigger3(this, name, a, b, c); - else - trigger2(this, name, a, b); - return this; - }; - Messenger.prototype.listenTo = function (source, a, b) { - if (source) { - addReference(this, source); - source.on(a, !b && typeof a === 'object' ? this : b, this); - } - return this; - }; - Messenger.prototype.listenToOnce = function (source, a, b) { - if (source) { - addReference(this, source); - source.once(a, !b && typeof a === 'object' ? this : b, this); - } - return this; - }; - Messenger.prototype.stopListening = function (a_source, a, b) { - var _listeningTo = this._listeningTo; - if (_listeningTo) { - var removeAll = !(a || b), second = !b && typeof a === 'object' ? this : b; - if (a_source) { - var source = _listeningTo[a_source.cid]; - if (source) { - if (removeAll) - delete _listeningTo[a_source.cid]; - source.off(a, second, this); - } - } - else if (a_source == null) { - for (var cid in _listeningTo) - _listeningTo[cid].off(a, second, this); - if (removeAll) - (this._listeningTo = void 0); - } - } - return this; - }; - Messenger.prototype.dispose = function () { - if (this._disposed) - return; - this.stopListening(); - this.off(); - this._disposed = true; - }; - Messenger = tslib_1.__decorate([ - define, - definitions({ - properties: mixinRules.merge, - localEvents: mixinRules.merge - }) - ], Messenger); - return Messenger; -}()); -export { Messenger }; -export var Events = omit(Messenger.prototype, 'constructor', 'initialize'); -function toPropertyDescriptor(x) { - if (x) { - return typeof x === 'function' ? { get: x } : x; - } -} -function addReference(listener, source) { - var listeningTo = listener._listeningTo || (listener._listeningTo = Object.create(null)), cid = source.cid || (source.cid = uniqueId()); - listeningTo[cid] = source; -} -//# sourceMappingURL=events.js.map \ No newline at end of file diff --git a/lib/type-r/object-plus/events.js.map b/lib/type-r/object-plus/events.js.map deleted file mode 100644 index 728985f..0000000 --- a/lib/type-r/object-plus/events.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"events.js","sourceRoot":"","sources":["../../../src/type-r/object-plus/events.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAA2D,UAAU,EAAE,WAAW,EAAmB,MAAM,UAAU,CAAA;AACpI,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAkD,MAAM,eAAe,CAAA;AACxF,OAAO,KAAK,UAAU,MAAM,eAAe,CAAA;AAEnC,IAAA,sCAAY,EAAE,4BAAO,EAAE,kBAAE,EAAE,oBAAG,EAAE,sBAAI,EAAE,8BAAQ,EAAE,8BAAQ,EAAE,8BAAQ,CAAgB;AAG1F,IAAM,aAAa,GAAG,KAAK,CAAC;AAG5B,IAAI,QAAQ,GAAG,CAAC,CAAC;AAGjB,SAAS,QAAQ;IACb,OAAO,GAAG,GAAG,QAAQ,EAAE,CAAC;AAC5B,CAAC;AAED,OAAO,EAAE,QAAQ,EAAoB,CAAA;AAiCrC;IAqCI;QAZA,YAAO,GAAqB,KAAK,CAAC,CAAC;QAGnC,iBAAY,GAAqB,KAAK,CAAC,CAAA;QAUnC,IAAI,CAAC,GAAG,GAAG,QAAQ,EAA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,CAAC"} \ No newline at end of file diff --git a/lib/type-r/object-plus/eventsource.d.ts b/lib/type-r/object-plus/eventsource.d.ts deleted file mode 100644 index 9f5b1a3..0000000 --- a/lib/type-r/object-plus/eventsource.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -export interface EventsDefinition { - [events: string]: Function | string | boolean; -} -export declare class EventMap { - handlers: EventDescriptor[]; - constructor(map?: EventsDefinition | EventMap); - merge(map: EventMap): void; - addEventsMap(map: EventsDefinition): void; - bubbleEvents(names: string): void; - addEvent(names: string, callback: Function | string | boolean): void; - subscribe(target: {}, source: EventSource): void; - unsubscribe(target: {}, source: EventSource): void; -} -export declare class EventDescriptor { - name: string; - callback: Function; - constructor(name: string, callback: Function | string | boolean); -} -export interface HandlersByEvent { - [name: string]: EventHandler; -} -export declare class EventHandler { - callback: Callback; - context: any; - next: any; - constructor(callback: Callback, context: any, next?: any); -} -export interface Callback extends Function { - _callback?: Function; -} -export declare function on(source: EventSource, name: string, callback: Callback, context?: any): void; -export declare function once(source: EventSource, name: string, callback: Callback, context?: any): void; -export declare function off(source: EventSource, name?: string, callback?: Callback, context?: any): void; -export interface EventSource { - _events: HandlersByEvent; -} -export declare function strings(api: ApiEntry, source: EventSource, events: string, callback: Callback, context: any): void; -export declare type ApiEntry = (source: EventSource, event: string, callback: Callback, context?: any) => void; -export declare function trigger2(self: EventSource, name: string, a: any, b: any): void; -export declare function trigger3(self: EventSource, name: string, a: any, b: any, c: any): void; -export declare function trigger5(self: EventSource, name: string, a: any, b: any, c: any, d: any, e: any): void; diff --git a/lib/type-r/object-plus/eventsource.js b/lib/type-r/object-plus/eventsource.js deleted file mode 100644 index ed39014..0000000 --- a/lib/type-r/object-plus/eventsource.js +++ /dev/null @@ -1,204 +0,0 @@ -import { once as _once } from './tools'; -var EventMap = (function () { - function EventMap(map) { - this.handlers = []; - if (map) { - if (map instanceof EventMap) { - this.handlers = map.handlers.slice(); - } - else { - map && this.addEventsMap(map); - } - } - } - EventMap.prototype.merge = function (map) { - this.handlers = this.handlers.concat(map.handlers); - }; - EventMap.prototype.addEventsMap = function (map) { - for (var names in map) { - this.addEvent(names, map[names]); - } - }; - EventMap.prototype.bubbleEvents = function (names) { - for (var _i = 0, _a = names.split(eventSplitter); _i < _a.length; _i++) { - var name_1 = _a[_i]; - this.addEvent(name_1, getBubblingHandler(name_1)); - } - }; - EventMap.prototype.addEvent = function (names, callback) { - var handlers = this.handlers; - for (var _i = 0, _a = names.split(eventSplitter); _i < _a.length; _i++) { - var name_2 = _a[_i]; - handlers.push(new EventDescriptor(name_2, callback)); - } - }; - EventMap.prototype.subscribe = function (target, source) { - for (var _i = 0, _a = this.handlers; _i < _a.length; _i++) { - var event_1 = _a[_i]; - on(source, event_1.name, event_1.callback, target); - } - }; - EventMap.prototype.unsubscribe = function (target, source) { - for (var _i = 0, _a = this.handlers; _i < _a.length; _i++) { - var event_2 = _a[_i]; - off(source, event_2.name, event_2.callback, target); - } - }; - return EventMap; -}()); -export { EventMap }; -var EventDescriptor = (function () { - function EventDescriptor(name, callback) { - this.name = name; - if (callback === true) { - this.callback = getBubblingHandler(name); - } - else if (typeof callback === 'string') { - this.callback = - function localCallback() { - var handler = this[callback]; - handler && handler.apply(this, arguments); - }; - } - else { - this.callback = callback; - } - } - return EventDescriptor; -}()); -export { EventDescriptor }; -var _bubblingHandlers = {}; -function getBubblingHandler(event) { - return _bubblingHandlers[event] || (_bubblingHandlers[event] = function (a, b, c, d, e) { - if (d !== void 0 || e !== void 0) - trigger5(this, event, a, b, c, d, e); - if (c !== void 0) - trigger3(this, event, a, b, c); - else - trigger2(this, event, a, b); - }); -} -var EventHandler = (function () { - function EventHandler(callback, context, next) { - if (next === void 0) { next = null; } - this.callback = callback; - this.context = context; - this.next = next; - } - return EventHandler; -}()); -export { EventHandler }; -function listOff(_events, name, callback, context) { - var head = _events[name]; - var filteredHead, prev; - for (var ev = head; ev; ev = ev.next) { - if ((callback && callback !== ev.callback && callback !== ev.callback._callback) || - (context && context !== ev.context)) { - prev = ev; - filteredHead || (filteredHead = ev); - } - else { - if (prev) - prev.next = ev.next; - } - } - if (head !== filteredHead) - _events[name] = filteredHead; -} -function listSend2(head, a, b) { - for (var ev = head; ev; ev = ev.next) - ev.callback.call(ev.context, a, b); -} -function listSend3(head, a, b, c) { - for (var ev = head; ev; ev = ev.next) - ev.callback.call(ev.context, a, b, c); -} -function listSend4(head, a, b, c, d) { - for (var ev = head; ev; ev = ev.next) - ev.callback.call(ev.context, a, b, c, d); -} -function listSend5(head, a, b, c, d, e) { - for (var ev = head; ev; ev = ev.next) - ev.callback.call(ev.context, a, b, c, d, e); -} -function listSend6(head, a, b, c, d, e, f) { - for (var ev = head; ev; ev = ev.next) - ev.callback.call(ev.context, a, b, c, d, e, f); -} -export function on(source, name, callback, context) { - if (callback) { - var _events = source._events || (source._events = Object.create(null)); - _events[name] = new EventHandler(callback, context, _events[name]); - } -} -export function once(source, name, callback, context) { - if (callback) { - var once_1 = _once(function () { - off(source, name, once_1); - callback.apply(this, arguments); - }); - once_1._callback = callback; - on(source, name, once_1, context); - } -} -export function off(source, name, callback, context) { - var _events = source._events; - if (_events) { - if (callback || context) { - if (name) { - listOff(_events, name, callback, context); - } - else { - for (var name_3 in _events) { - listOff(_events, name_3, callback, context); - } - } - } - else if (name) { - _events[name] = void 0; - } - else { - source._events = void 0; - } - } -} -var eventSplitter = /\s+/; -export function strings(api, source, events, callback, context) { - if (eventSplitter.test(events)) { - var names = events.split(eventSplitter); - for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_4 = names_1[_i]; - api(source, name_4, callback, context); - } - } - else - api(source, events, callback, context); -} -export function trigger2(self, name, a, b) { - var _events = self._events; - if (_events) { - var queue = _events[name], all = _events.all; - listSend2(queue, a, b); - listSend3(all, name, a, b); - } -} -; -export function trigger3(self, name, a, b, c) { - var _events = self._events; - if (_events) { - var queue = _events[name], all = _events.all; - listSend3(queue, a, b, c); - listSend4(all, name, a, b, c); - } -} -; -export function trigger5(self, name, a, b, c, d, e) { - var _events = self._events; - if (_events) { - var queue = _events[name], all = _events.all; - listSend5(queue, a, b, c, d, e); - listSend6(all, name, a, b, c, d, e); - } -} -; -//# sourceMappingURL=eventsource.js.map \ No newline at end of file diff --git a/lib/type-r/object-plus/eventsource.js.map b/lib/type-r/object-plus/eventsource.js.map deleted file mode 100644 index 521a46e..0000000 --- a/lib/type-r/object-plus/eventsource.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"eventsource.js","sourceRoot":"","sources":["../../../src/type-r/object-plus/eventsource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,KAAK,EAAE,MAAM,SAAS,CAAA;AAkBvC;IAGI,kBAAa,GAAkC;QAF/C,aAAQ,GAAuB,EAAE,CAAC;QAG9B,IAAI,GAAG,EAAE;YACL,IAAI,GAAG,YAAY,QAAQ,EAAE;gBACzB,IAAI,CAAC,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;aACxC;iBACG;gBACA,GAAG,IAAI,IAAI,CAAC,YAAY,CAAE,GAAG,CAAE,CAAC;aACnC;SACJ;IACL,CAAC;IAED,wBAAK,GAAL,UAAO,GAAc;QACjB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAE,GAAG,CAAC,QAAQ,CAAE,CAAC;IACzD,CAAC;IAED,+BAAY,GAAZ,UAAc,GAAsB;QAChC,KAAK,IAAI,KAAK,IAAI,GAAG,EAAE;YACnB,IAAI,CAAC,QAAQ,CAAE,KAAK,EAAE,GAAG,CAAE,KAAK,CAAE,CAAE,CAAA;SACvC;IACL,CAAC;IAED,+BAAY,GAAZ,UAAc,KAAc;QACxB,KAAiB,UAA4B,EAA5B,KAAA,KAAK,CAAC,KAAK,CAAE,aAAa,CAAE,EAA5B,cAA4B,EAA5B,IAA4B,EAAE;YAA1C,IAAI,MAAI,SAAA;YACT,IAAI,CAAC,QAAQ,CAAE,MAAI,EAAE,kBAAkB,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CAAC;QAClC,SAAS,CAAE,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAE,CAAC;KACzC;AACL,CAAC;AAAA,CAAC"} \ No newline at end of file diff --git a/lib/type-r/object-plus/index.d.ts b/lib/type-r/object-plus/index.d.ts deleted file mode 100644 index e45e6bd..0000000 --- a/lib/type-r/object-plus/index.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -import * as tools from './tools'; -export { tools }; -export * from './mixins'; -export * from './events'; -import * as eventsApi from './eventsource'; -export { eventsApi }; -import { MixableConstructor } from './mixins'; -declare global { - interface ObjectConstructor { - assign(dest: T, ...sources: Object[]): T; - log: tools.Log; - extend(protoProps: {}, staticProps: {}): MixableConstructor; - } -} diff --git a/lib/type-r/object-plus/index.js b/lib/type-r/object-plus/index.js deleted file mode 100644 index a5fc26a..0000000 --- a/lib/type-r/object-plus/index.js +++ /dev/null @@ -1,11 +0,0 @@ -import * as tools from './tools'; -export { tools }; -export * from './mixins'; -export * from './events'; -import * as eventsApi from './eventsource'; -export { eventsApi }; -import { Mixable } from './mixins'; -Object.extend = function (protoProps, staticProps) { return Mixable.extend(protoProps, staticProps); }; -Object.assign || (Object.assign = tools.assign); -Object.log = tools.log; -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/lib/type-r/object-plus/index.js.map b/lib/type-r/object-plus/index.js.map deleted file mode 100644 index 2f40fa1..0000000 --- a/lib/type-r/object-plus/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/type-r/object-plus/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,SAAS,CAAA;AAChC,OAAO,EAAE,KAAK,EAAE,CAAA;AAChB,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,OAAO,KAAK,SAAS,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,SAAS,EAAE,CAAA;AAEpB,OAAO,EAAE,OAAO,EAAsB,MAAM,UAAU,CAAA;AAetD,MAAM,CAAC,MAAM,GAAG,UAAE,UAAU,EAAE,WAAW,IAAM,OAAA,OAAO,CAAC,MAAM,CAAE,UAAU,EAAE,WAAW,CAAE,EAAzC,CAAyC,CAAC;AACzF,MAAM,CAAC,MAAM,IAAI,CAAE,MAAM,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAE,CAAC;AAClD,MAAM,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC"} \ No newline at end of file diff --git a/lib/type-r/object-plus/mixins.d.ts b/lib/type-r/object-plus/mixins.d.ts deleted file mode 100644 index aa9c750..0000000 --- a/lib/type-r/object-plus/mixins.d.ts +++ /dev/null @@ -1,66 +0,0 @@ -export interface Subclass extends MixableConstructor { - new (...args: any[]): T; - prototype: T; -} -export interface MixableConstructor extends Function { - __super__?: object; - mixins?: MixinsState; - onExtend?: (BaseClass: Function) => void; - onDefine?: (definition: object, BaseClass: Function) => void; - define?: (definition?: object, statics?: object) => MixableConstructor; - extend?: (definition?: T, statics?: object) => Subclass; -} -export interface MixableDefinition { - mixins?: Mixin[]; -} -export declare class Mixable { - static onExtend: (BaseClass: Function) => void; - static onDefine: (definition: object, BaseClass: Function) => object; - static __super__: object; - static mixins: MixinsState; - static define(protoProps?: MixableDefinition, staticProps?: object): MixableConstructor; - static extend(spec?: T, statics?: {}): Subclass; -} -export declare function predefine(Constructor: MixableConstructor): void; -export declare function define(ClassOrDefinition: Function): void; -export declare function define(ClassOrDefinition: object): ClassDecorator; -export declare function definitions(rules: MixinMergeRules): ClassDecorator; -export declare function propertyListDecorator(listName: string): PropertyDecorator; -export declare function definitionDecorator(definitionKey: any, value: any): (proto: object, name: string) => void; -export declare class MixinsState { - Class: MixableConstructor; - mergeRules: MixinMergeRules; - definitionRules: MixinMergeRules; - definitions: object; - appliedMixins: Mixin[]; - static get(Class: any): MixinsState; - constructor(Class: MixableConstructor); - getStaticDefinitions(BaseClass: Function): { - [key: string]: any; - }; - merge(mixins: Mixin[]): void; - populate(...ctors: Function[]): void; - mergeObject(dest: object, source: object, unshift?: boolean): void; - mergeInheritedMembers(BaseClass: Function): void; -} -export interface MixinMergeRules { - [name: string]: MixinMergeRule; -} -export declare type MixinMergeRule = (a: any, b: any) => any; -export declare type Mixin = { - [key: string]: any; -} | Function; -export interface MixinRulesDecorator { - (rules: MixinMergeRules): ClassDecorator; - value(a: object, b: object): object; - protoValue(a: object, b: object): object; - merge(a: object, b: object): object; - pipe(a: Function, b: Function): Function; - defaults(a: Function, b: Function): Function; - classFirst(a: Function, b: Function): Function; - classLast(a: Function, b: Function): Function; - every(a: Function, b: Function): Function; - some(a: Function, b: Function): Function; -} -export declare const mixins: (...list: Mixin[]) => (Class: Function) => void; -export declare const mixinRules: MixinRulesDecorator; diff --git a/lib/type-r/object-plus/mixins.js b/lib/type-r/object-plus/mixins.js deleted file mode 100644 index 83e5980..0000000 --- a/lib/type-r/object-plus/mixins.js +++ /dev/null @@ -1,245 +0,0 @@ -import * as tslib_1 from "tslib"; -import { assign, hashMap, getBaseClass, defaults, transform } from './tools'; -import { __extends } from 'tslib'; -var Mixable = (function () { - function Mixable() { - } - Mixable.define = function (protoProps, staticProps) { - if (protoProps === void 0) { protoProps = {}; } - var BaseClass = getBaseClass(this); - staticProps && assign(this, staticProps); - var mixins = protoProps.mixins, defineMixin = tslib_1.__rest(protoProps, ["mixins"]); - mixins && this.mixins.merge(mixins); - this.mixins.mergeObject(this.prototype, defineMixin, true); - this.mixins.mergeObject(this.prototype, this.mixins.getStaticDefinitions(BaseClass), true); - this.onDefine && this.onDefine(this.mixins.definitions, BaseClass); - this.mixins.mergeInheritedMembers(BaseClass); - return this; - }; - Mixable.extend = function (spec, statics) { - var TheSubclass; - if (spec && spec.hasOwnProperty('constructor')) { - TheSubclass = spec.constructor; - __extends(TheSubclass, this); - } - else { - TheSubclass = (function (_super) { - tslib_1.__extends(Subclass, _super); - function Subclass() { - return _super !== null && _super.apply(this, arguments) || this; - } - return Subclass; - }(this)); - } - predefine(TheSubclass); - spec && TheSubclass.define(spec, statics); - return TheSubclass; - }; - return Mixable; -}()); -export { Mixable }; -export function predefine(Constructor) { - var BaseClass = getBaseClass(Constructor); - Constructor.__super__ = BaseClass.prototype; - Constructor.define || MixinsState.get(Mixable).populate(Constructor); - MixinsState.get(Constructor); - Constructor.onExtend && Constructor.onExtend(BaseClass); -} -export function define(ClassOrDefinition) { - if (typeof ClassOrDefinition === 'function') { - predefine(ClassOrDefinition); - ClassOrDefinition.define(); - } - else { - return function (Ctor) { - predefine(Ctor); - Ctor.define(ClassOrDefinition); - }; - } -} -export function definitions(rules) { - return function (Class) { - var mixins = MixinsState.get(Class); - mixins.definitionRules = defaults(hashMap(), rules, mixins.definitionRules); - }; -} -export function propertyListDecorator(listName) { - return function propList(proto, name) { - var list = proto.hasOwnProperty(listName) ? - proto[listName] : (proto[listName] = (proto[listName] || []).slice()); - list.push(name); - }; -} -export function definitionDecorator(definitionKey, value) { - return function (proto, name) { - var _a, _b; - MixinsState - .get(proto.constructor) - .mergeObject(proto, (_a = {}, - _a[definitionKey] = (_b = {}, - _b[name] = value, - _b), - _a)); - }; -} -var MixinsState = (function () { - function MixinsState(Class) { - this.Class = Class; - this.definitions = {}; - var mixins = getBaseClass(Class).mixins; - this.mergeRules = (mixins && mixins.mergeRules) || hashMap(); - this.definitionRules = (mixins && mixins.definitionRules) || hashMap(); - this.appliedMixins = (mixins && mixins.appliedMixins) || []; - } - MixinsState.get = function (Class) { - var mixins = Class.mixins; - return mixins && Class === mixins.Class ? mixins : - Class.mixins = new MixinsState(Class); - }; - MixinsState.prototype.getStaticDefinitions = function (BaseClass) { - var definitions = hashMap(), Class = this.Class; - return transform(definitions, this.definitionRules, function (rule, name) { - if (BaseClass[name] !== Class[name]) { - return Class[name]; - } - }); - }; - MixinsState.prototype.merge = function (mixins) { - var proto = this.Class.prototype, mergeRules = this.mergeRules; - var appliedMixins = this.appliedMixins = this.appliedMixins.slice(); - for (var _i = 0, mixins_1 = mixins; _i < mixins_1.length; _i++) { - var mixin = mixins_1[_i]; - if (Array.isArray(mixin)) { - this.merge(mixin); - } - else if (appliedMixins.indexOf(mixin) < 0) { - appliedMixins.push(mixin); - if (typeof mixin === 'function') { - this.mergeObject(this.Class, mixin); - var sourceMixins = mixin.mixins; - if (sourceMixins) { - this.mergeRules = defaults(hashMap(), this.mergeRules, sourceMixins.mergeRules); - this.definitionRules = defaults(hashMap(), this.definitionRules, sourceMixins.definitionRules); - this.appliedMixins = this.appliedMixins.concat(sourceMixins.appliedMixins); - } - this.mergeObject(proto, mixin.prototype); - } - else { - this.mergeObject(proto, mixin); - } - } - } - }; - MixinsState.prototype.populate = function () { - var ctors = []; - for (var _i = 0; _i < arguments.length; _i++) { - ctors[_i] = arguments[_i]; - } - for (var _a = 0, ctors_1 = ctors; _a < ctors_1.length; _a++) { - var Ctor = ctors_1[_a]; - MixinsState.get(Ctor).merge([this.Class]); - } - }; - MixinsState.prototype.mergeObject = function (dest, source, unshift) { - var _this = this; - forEachOwnProp(source, function (name) { - var sourceProp = Object.getOwnPropertyDescriptor(source, name); - var rule; - if (rule = _this.definitionRules[name]) { - assignProperty(_this.definitions, name, sourceProp, rule, unshift); - } - if (!rule || rule === mixinRules.protoValue) { - assignProperty(dest, name, sourceProp, _this.mergeRules[name], unshift); - } - }); - }; - MixinsState.prototype.mergeInheritedMembers = function (BaseClass) { - var _a = this, mergeRules = _a.mergeRules, Class = _a.Class; - if (mergeRules) { - var proto = Class.prototype, baseProto = BaseClass.prototype; - for (var name_1 in mergeRules) { - var rule = mergeRules[name_1]; - if (proto.hasOwnProperty(name_1) && name_1 in baseProto) { - proto[name_1] = resolveRule(proto[name_1], baseProto[name_1], rule); - } - } - } - }; - return MixinsState; -}()); -export { MixinsState }; -var dontMix = { - function: hashMap({ - length: true, - prototype: true, - caller: true, - arguments: true, - name: true, - __super__: true - }), - object: hashMap({ - constructor: true - }) -}; -function forEachOwnProp(object, fun) { - var ignore = dontMix[typeof object]; - for (var _i = 0, _a = Object.keys(object); _i < _a.length; _i++) { - var name_2 = _a[_i]; - ignore[name_2] || fun(name_2); - } -} -export var mixins = function () { - var list = []; - for (var _i = 0; _i < arguments.length; _i++) { - list[_i] = arguments[_i]; - } - return (function (Class) { return MixinsState.get(Class).merge(list); }); -}; -export var mixinRules = (function (rules) { return (function (Class) { - var mixins = MixinsState.get(Class); - mixins.mergeRules = defaults(rules, mixins.mergeRules); -}); }); -mixinRules.value = function (a, b) { return a; }; -mixinRules.protoValue = function (a, b) { return a; }; -mixinRules.merge = function (a, b) { return defaults({}, a, b); }; -mixinRules.pipe = function (a, b) { return (function (x) { - return a.call(this, b.call(this, x)); -}); }; -mixinRules.defaults = function (a, b) { return (function () { - return defaults(a.apply(this, arguments), b.apply(this, arguments)); -}); }; -mixinRules.classFirst = function (a, b) { return (function () { - a.apply(this, arguments); - b.apply(this, arguments); -}); }; -mixinRules.classLast = function (a, b) { return (function () { - b.apply(this, arguments); - a.apply(this, arguments); -}); }; -mixinRules.every = function (a, b) { return (function () { - return a.apply(this, arguments) && b.apply(this, arguments); -}); }; -mixinRules.some = function (a, b) { return (function () { - return a.apply(this, arguments) || b.apply(this, arguments); -}); }; -function assignProperty(dest, name, sourceProp, rule, unshift) { - if (dest.hasOwnProperty(name)) { - var destProp = Object.getOwnPropertyDescriptor(dest, name); - if (destProp.configurable && 'value' in destProp) { - dest[name] = unshift ? - resolveRule(sourceProp.value, destProp.value, rule) : - resolveRule(destProp.value, sourceProp.value, rule); - } - } - else { - Object.defineProperty(dest, name, sourceProp); - } -} -function resolveRule(dest, source, rule) { - if (dest === void 0) - return source; - if (!rule || source === void 0) - return dest; - return rule(dest, source); -} -//# sourceMappingURL=mixins.js.map \ No newline at end of file diff --git a/lib/type-r/object-plus/mixins.js.map b/lib/type-r/object-plus/mixins.js.map deleted file mode 100644 index d592232..0000000 --- a/lib/type-r/object-plus/mixins.js.map +++ /dev/null @@ -1 +0,0 @@ -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CAAE,EAAE;QAC7B,IAAM,QAAQ,GAAG,MAAM,CAAC,wBAAwB,CAAE,IAAI,EAAE,IAAI,CAAE,CAAC;QAE/D,IAAI,QAAQ,CAAC,YAAY,IAAI,OAAO,IAAI,QAAQ,EAAE;YAC9C,IAAI,CAAE,IAAI,CAAE,GAAG,OAAO,CAAC,CAAC;gBACpB,WAAW,CAAE,UAAU,CAAC,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAE,CAAC,CAAC;gBACvD,WAAW,CAAE,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC,KAAK,EAAE,IAAI,CAAE,CAAE;SAC9D;KACJ;SAEG;QACA,MAAM,CAAC,cAAc,CAAE,IAAI,EAAE,IAAI,EAAE,UAAU,CAAE,CAAC;KACnD;AACL,CAAC;AAED,SAAS,WAAW,CAAE,IAAI,EAAE,MAAM,EAAE,IAAqB;IAErD,IAAI,IAAI,KAAK,KAAK,CAAC;QAAG,OAAO,MAAM,CAAC;IAGpC,IAAI,CAAC,IAAI,IAAI,MAAM,KAAK,KAAK,CAAC;QAAG,OAAO,IAAI,CAAC;IAG7C,OAAO,IAAI,CAAE,IAAI,EAAE,MAAM,CAAE,CAAC;AAChC,CAAC"} \ No newline at end of file diff --git a/lib/type-r/object-plus/tools.d.ts b/lib/type-r/object-plus/tools.d.ts deleted file mode 100644 index 0600e13..0000000 --- a/lib/type-r/object-plus/tools.d.ts +++ /dev/null @@ -1,33 +0,0 @@ -export declare function defaults(dest: T, ...sources: Object[]): T; -export declare type Logger = (level: LogLevel, error: string, props?: object) => void; -export declare type LogLevel = 'none' | 'error' | 'warn' | 'info' | 'debug' | 'log'; -export interface Log extends Logger { - level: number; - throw: number; - stop: number; - logger: Logger; -} -export declare const log: Log; -export declare function isValidJSON(value: any): boolean; -export declare function getBaseClass(Class: Function): any; -export declare function assignToClassProto(Class: any, definition: T, ...names: K[]): void; -export declare function isEmpty(obj: {}): boolean; -export declare type Iteratee = (value: any, key?: string | number) => any; -export declare function some(obj: any, fun: Iteratee): any; -export declare function every(obj: {}, predicate: Iteratee): boolean; -export declare function getPropertyDescriptor(obj: {}, prop: string): PropertyDescriptor; -export declare function omit(source: {}, ...rest: string[]): {}; -export declare function transform(dest: { - [key: string]: A; -}, source: { - [key: string]: B; -}, fun: (value: B, key: string) => A | void): { - [key: string]: A; -}; -export declare function fastAssign(dest: A, source: {}): A; -export declare function fastDefaults(dest: A, source: {}): A; -export declare function assign(dest: T, ...sources: Object[]): T; -export declare function keys(o: any): string[]; -export declare function once(func: Function): Function; -export declare function notEqual(a: any, b: any): boolean; -export declare function hashMap(obj?: any): any; diff --git a/lib/type-r/object-plus/tools.js b/lib/type-r/object-plus/tools.js deleted file mode 100644 index 2330693..0000000 --- a/lib/type-r/object-plus/tools.js +++ /dev/null @@ -1,249 +0,0 @@ -export function defaults(dest, source) { - for (var name in source) { - if (source.hasOwnProperty(name) && !dest.hasOwnProperty(name)) { - dest[name] = source[name]; - } - } - if (arguments.length > 2) { - for (var i = 2; i < arguments.length; i++) { - var other = arguments[i]; - other && defaults(dest, other); - } - } - return dest; -} -var levelToNumber = { - none: 0, error: 1, warn: 2, info: 3, log: 4, debug: 5 -}; -export var log = function (a_level, a_msg, a_props) { - var levelAsNumber = levelToNumber[a_level], msg, props, level; - if (levelAsNumber === void 0 && !a_props) { - levelAsNumber = 4; - msg = a_level; - props = a_msg; - level = 'log'; - } - else { - msg = a_msg, level = a_level, props = a_props; - } - if (levelAsNumber <= log.level) { - if (levelAsNumber <= log.throw || !log.logger) { - var error = new Error(msg); - error.props = props; - throw error; - } - else { - log.logger(level, msg, props); - if (levelAsNumber <= log.stop) { - debugger; - } - } - } -}; -log.level = typeof process !== 'undefined' && process.env && process.env.NODE_ENV === 'production' ? 1 : 2; -log.throw = 0; -log.stop = 0; -var toString = typeof window === 'undefined' ? - function toString(something) { - if (something && typeof something === 'object') { - var value = something.__inner_state__ || something, isTransactional = Boolean(something.__inner_state__), isArray = Array.isArray(value); - var keys_1 = Object.keys(value).join(', '), body = isArray ? "[ length = " + value.length + " ]" : "{ " + keys_1 + " }"; - return something.constructor.name + ' ' + body; - } - return something; - } : function toString(x) { return x; }; -if (typeof console !== 'undefined') { - log.logger = function _console(level, error, props) { - var args = [error]; - for (var name_1 in props) { - args.push("\n\t" + name_1 + ":", toString(props[name_1])); - } - console[level].apply(console, args); - }; -} -export function isValidJSON(value) { - if (value === null) { - return true; - } - switch (typeof value) { - case 'number': - case 'string': - case 'boolean': - return true; - case 'object': - var proto = Object.getPrototypeOf(value); - if (proto === Object.prototype || proto === Array.prototype) { - return every(value, isValidJSON); - } - } - return false; -} -export function getBaseClass(Class) { - return Object.getPrototypeOf(Class.prototype).constructor; -} -export function assignToClassProto(Class, definition) { - var names = []; - for (var _i = 2; _i < arguments.length; _i++) { - names[_i - 2] = arguments[_i]; - } - for (var _a = 0, names_1 = names; _a < names_1.length; _a++) { - var name_2 = names_1[_a]; - var value = definition[name_2]; - value === void 0 || (Class.prototype[name_2] = value); - } -} -export function isEmpty(obj) { - if (obj) { - for (var key in obj) { - if (obj.hasOwnProperty(key)) { - return false; - } - } - } - return true; -} -function someArray(arr, fun) { - var result; - for (var i = 0; i < arr.length; i++) { - if (result = fun(arr[i], i)) { - return result; - } - } -} -function someObject(obj, fun) { - var result; - for (var key in obj) { - if (obj.hasOwnProperty(key)) { - if (result = fun(obj[key], key)) { - return result; - } - } - } -} -export function some(obj, fun) { - if (Object.getPrototypeOf(obj) === ArrayProto) { - return someArray(obj, fun); - } - else { - return someObject(obj, fun); - } -} -export function every(obj, predicate) { - return !some(obj, function (x) { return !predicate(x); }); -} -export function getPropertyDescriptor(obj, prop) { - var desc; - for (var proto = obj; !desc && proto; proto = Object.getPrototypeOf(proto)) { - desc = Object.getOwnPropertyDescriptor(proto, prop); - } - return desc; -} -export function omit(source) { - var dest = {}, discard = {}; - for (var i = 1; i < arguments.length; i++) { - discard[arguments[i]] = true; - } - for (var name in source) { - if (!discard.hasOwnProperty(name) && source.hasOwnProperty(name)) { - dest[name] = source[name]; - } - } - return dest; -} -export function transform(dest, source, fun) { - for (var name in source) { - if (source.hasOwnProperty(name)) { - var value = fun(source[name], name); - value === void 0 || (dest[name] = value); - } - } - return dest; -} -export function fastAssign(dest, source) { - for (var name in source) { - dest[name] = source[name]; - } - return dest; -} -export function fastDefaults(dest, source) { - for (var name in source) { - if (dest[name] === void 0) { - dest[name] = source[name]; - } - } - return dest; -} -export function assign(dest, source) { - for (var name in source) { - if (source.hasOwnProperty(name)) { - dest[name] = source[name]; - } - } - if (arguments.length > 2) { - for (var i = 2; i < arguments.length; i++) { - var other = arguments[i]; - other && assign(dest, other); - } - } - return dest; -} -export function keys(o) { - return o ? Object.keys(o) : []; -} -export function once(func) { - var memo, first = true; - return function () { - if (first) { - first = false; - memo = func.apply(this, arguments); - func = null; - } - return memo; - }; -} -var ArrayProto = Array.prototype, DateProto = Date.prototype, ObjectProto = Object.prototype; -export function notEqual(a, b) { - if (a === b) - return false; - if (a && b && typeof a == 'object' && typeof b == 'object') { - var protoA = Object.getPrototypeOf(a); - if (protoA !== Object.getPrototypeOf(b)) - return true; - switch (protoA) { - case DateProto: return +a !== +b; - case ArrayProto: return arraysNotEqual(a, b); - case ObjectProto: - case null: - return objectsNotEqual(a, b); - } - } - return true; -} -function objectsNotEqual(a, b) { - var keysA = Object.keys(a); - if (keysA.length !== Object.keys(b).length) - return true; - for (var i = 0; i < keysA.length; i++) { - var key = keysA[i]; - if (!b.hasOwnProperty(key) || notEqual(a[key], b[key])) { - return true; - } - } - return false; -} -function arraysNotEqual(a, b) { - if (a.length !== b.length) - return true; - for (var i = 0; i < a.length; i++) { - if (notEqual(a[i], b[i])) - return true; - } - return false; -} -var HashProto = Object.create(null); -HashProto.hasOwnProperty = ObjectProto.hasOwnProperty; -export function hashMap(obj) { - var hash = Object.create(HashProto); - return obj ? assign(hash, obj) : hash; -} -//# sourceMappingURL=tools.js.map \ No newline at end of file diff --git a/lib/type-r/object-plus/tools.js.map b/lib/type-r/object-plus/tools.js.map deleted file mode 100644 index 60ddc54..0000000 --- a/lib/type-r/object-plus/tools.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../../src/type-r/object-plus/tools.ts"],"names":[],"mappings":"AAUA,MAAM,UAAU,QAAQ,CAAO,IAAQ,EAAE,MAAe;IACpD,KAAK,IAAI,IAAI,IAAI,MAAM,EAAG;QACtB,IAAI,MAAM,CAAC,cAAc,CAAE,IAAI,CAAE,IAAI,CAAC,IAAI,CAAC,cAAc,CAAE,IAAI,CAAE,EAAG;YAChE,IAAI,CAAE,IAAI,CAAE,GAAG,MAAM,CAAE,IAAI,CAAE,CAAC;SACjC;KACJ;IAED,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE;QACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACvC,IAAM,KAAK,GAAG,SAAS,CAAE,CAAC,CAAE,CAAC;YAC7B,KAAK,IAAI,QAAQ,CAAE,IAAI,EAAE,KAAK,CAAE,CAAC;SACpC;KACJ;IAED,OAAO,IAAI,CAAC;AAChB,CAAC;AAOD,IAAM,aAAa,GAAG;IAClB,IAAI,EAAG,CAAC,EAAE,KAAK,EAAG,CAAC,EAAE,IAAI,EAAG,CAAC,EAAE,IAAI,EAAG,CAAC,EAAE,GAAG,EAAG,CAAC,EAAE,KAAK,EAAG,CAAC;CAC9D,CAAA;AASD,MAAM,CAAC,IAAM,GAAG,GAAc,UAAU,OAAkB,EAAE,KAAc,EAAE,OAAgB;IACxF,IAAI,aAAa,GAAG,aAAa,CAAE,OAAO,CAAE,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC;IAEhE,IAAI,aAAa,KAAK,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE;QACtC,aAAa,GAAG,CAAC,CAAC;QAClB,GAAG,GAAG,OAAO,CAAC;QACd,KAAK,G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,CAAE;YAAG,OAAO,IAAI,CAAC;KAChD;IAED,OAAO,KAAK,CAAC;AACjB,CAAC;AAMD,IAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAE,IAAI,CAAE,CAAC;AACxC,SAAS,CAAC,cAAc,GAAG,WAAW,CAAC,cAAc,CAAC;AAEtD,MAAM,UAAU,OAAO,CAAE,GAAI;IACzB,IAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAE,SAAS,CAAE,CAAC;IACxC,OAAO,GAAG,CAAC,CAAC,CAAC,MAAM,CAAE,IAAI,EAAE,GAAG,CAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAC5C,CAAC"} \ No newline at end of file diff --git a/lib/type-r/record/attributes/any.d.ts b/lib/type-r/record/attributes/any.d.ts deleted file mode 100644 index 97bfb5b..0000000 --- a/lib/type-r/record/attributes/any.d.ts +++ /dev/null @@ -1,60 +0,0 @@ -import { AttributesContainer, AttributeUpdatePipeline, RecordTransaction } from './updates'; -import { tools } from '../../object-plus'; -import { TransactionOptions } from '../../transactions'; -import { IOEndpoint } from '../../io-tools'; -declare global { - interface Function { - _attribute: typeof AnyType; - } -} -export declare type Transform = (this: AnyType, next: any, prev: any, record: AttributesContainer, options: TransactionOptions) => any; -export declare type ChangeHandler = (this: AnyType, next: any, prev: any, record: AttributesContainer, options: TransactionOptions) => void; -export interface AttributeOptions { - _attribute?: typeof AnyType; - validate?: (record: AttributesContainer, value: any, key: string) => any; - isRequired?: boolean; - changeEvents?: boolean; - endpoint?: IOEndpoint; - type?: Function; - value?: any; - hasCustomDefault?: boolean; - parse?: Parse; - toJSON?: AttributeToJSON; - getHooks?: GetHook[]; - transforms?: Transform[]; - changeHandlers?: ChangeHandler[]; - _onChange?: ChangeAttrHandler; -} -export declare type Parse = (value: any, key: string) => any; -export declare type GetHook = (value: any, key: string) => any; -export declare type AttributeToJSON = (value: any, key: string) => any; -export declare type AttributeParse = (value: any, key: string) => any; -export declare type ChangeAttrHandler = ((value: any, attr: string) => void) | string; -export declare class AnyType implements AttributeUpdatePipeline { - name: string; - static create(options: AttributeOptions, name: string): AnyType; - canBeUpdated(prev: any, next: any, options: TransactionOptions): any; - transform(next: any, prev: any, model: AttributesContainer, options: TransactionOptions): any; - convert(next: any, prev: any, model: AttributesContainer, options: TransactionOptions): any; - isChanged(a: any, b: any): boolean; - handleChange(next: any, prev: any, model: AttributesContainer, options: TransactionOptions): void; - create(): any; - clone(value: any, record: AttributesContainer): any; - dispose(record: AttributesContainer, value: any): void; - validate(record: AttributesContainer, value: any, key: string): void; - toJSON(value: any, key: any, options?: object): any; - createPropertyDescriptor(): PropertyDescriptor | void; - value: any; - static defaultValue: any; - type: Function; - initialize(name: string, options: TransactionOptions): void; - options: AttributeOptions; - doInit(value: any, record: AttributesContainer, options: TransactionOptions): any; - doUpdate(value: any, record: AttributesContainer, options: TransactionOptions, nested?: RecordTransaction[]): boolean; - propagateChanges: boolean; - _log(level: tools.LogLevel, text: string, value: any, record: AttributesContainer): void; - defaultValue(): any; - constructor(name: string, a_options: AttributeOptions); - getHook: (value: any, key: string) => any; - get: (value: any, key: string) => any; -} diff --git a/lib/type-r/record/attributes/any.js b/lib/type-r/record/attributes/any.js deleted file mode 100644 index afecd90..0000000 --- a/lib/type-r/record/attributes/any.js +++ /dev/null @@ -1,141 +0,0 @@ -import { setAttribute } from './updates'; -import { tools } from '../../object-plus'; -var notEqual = tools.notEqual, assign = tools.assign; -var emptyOptions = {}; -var AnyType = (function () { - function AnyType(name, a_options) { - this.name = name; - this.getHook = null; - this.options = a_options; - var options = assign({ getHooks: [], transforms: [], changeHandlers: [] }, a_options); - options.getHooks = options.getHooks.slice(); - options.transforms = options.transforms.slice(); - options.changeHandlers = options.changeHandlers.slice(); - var value = options.value, type = options.type, parse = options.parse, toJSON = options.toJSON, changeEvents = options.changeEvents, validate = options.validate, getHooks = options.getHooks, transforms = options.transforms, changeHandlers = options.changeHandlers; - this.value = value; - this.type = type; - if (!options.hasCustomDefault && type) { - this.defaultValue = this.create; - } - else if (tools.isValidJSON(value)) { - this.defaultValue = new Function("return " + JSON.stringify(value) + ";"); - } - else { - this.defaultValue = this.defaultValue; - } - this.propagateChanges = changeEvents !== false; - this.toJSON = toJSON === void 0 ? this.toJSON : toJSON; - this.validate = validate || this.validate; - if (options.isRequired) { - this.validate = wrapIsRequired(this.validate); - } - transforms.unshift(this.convert); - if (this.get) - getHooks.unshift(this.get); - this.initialize.call(this, options); - if (getHooks.length) { - var getHook_1 = this.getHook = getHooks.reduce(chainGetHooks); - var validate_1 = this.validate; - this.validate = function (record, value, key) { - return validate_1.call(this, record, getHook_1.call(record, value, key), key); - }; - } - this.transform = transforms.length ? transforms.reduce(chainTransforms) : this.transform; - this.handleChange = changeHandlers.length ? changeHandlers.reduce(chainChangeHandlers) : this.handleChange; - var _a = this, doInit = _a.doInit, doUpdate = _a.doUpdate; - this.doInit = parse ? function (value, record, options) { - return doInit.call(this, options.parse && value !== void 0 ? parse.call(record, value, this.name) : value, record, options); - } : doInit; - this.doUpdate = parse ? function (value, record, options, nested) { - return doUpdate.call(this, options.parse && value !== void 0 ? parse.call(record, value, this.name) : value, record, options, nested); - } : doUpdate; - } - AnyType.create = function (options, name) { - var type = options.type, AttributeCtor = options._attribute || (type ? type._attribute : AnyType); - return new AttributeCtor(name, options); - }; - AnyType.prototype.canBeUpdated = function (prev, next, options) { }; - AnyType.prototype.transform = function (next, prev, model, options) { return next; }; - AnyType.prototype.convert = function (next, prev, model, options) { return next; }; - AnyType.prototype.isChanged = function (a, b) { - return notEqual(a, b); - }; - AnyType.prototype.handleChange = function (next, prev, model, options) { }; - AnyType.prototype.create = function () { return void 0; }; - AnyType.prototype.clone = function (value, record) { - return value; - }; - AnyType.prototype.dispose = function (record, value) { - this.handleChange(void 0, value, record, emptyOptions); - }; - AnyType.prototype.validate = function (record, value, key) { }; - AnyType.prototype.toJSON = function (value, key, options) { - return value && value.toJSON ? value.toJSON(options) : value; - }; - AnyType.prototype.createPropertyDescriptor = function () { - var _a = this, name = _a.name, getHook = _a.getHook; - if (name !== 'id') { - return { - set: function (value) { - setAttribute(this, name, value); - }, - get: (getHook ? - function () { - return getHook.call(this, this.attributes[name], name); - } : - function () { return this.attributes[name]; }) - }; - } - }; - AnyType.prototype.initialize = function (name, options) { }; - AnyType.prototype.doInit = function (value, record, options) { - var v = value === void 0 ? this.defaultValue() : value, x = this.transform(v, void 0, record, options); - this.handleChange(x, void 0, record, options); - return x; - }; - AnyType.prototype.doUpdate = function (value, record, options, nested) { - var name = this.name, attributes = record.attributes, prev = attributes[name]; - var next = this.transform(value, prev, record, options); - attributes[name] = next; - if (this.isChanged(next, prev)) { - this.handleChange(next, prev, record, options); - return true; - } - return false; - }; - AnyType.prototype._log = function (level, text, value, record) { - tools.log(level, "[Attribute Update Error] " + record.getClassName() + "." + this.name + ": " + text, { - 'Record': record, - 'Attribute definition': this, - 'Prev. value': record.attributes[this.name], - 'New value': value - }); - }; - AnyType.prototype.defaultValue = function () { - return this.value; - }; - return AnyType; -}()); -export { AnyType }; -function chainGetHooks(prevHook, nextHook) { - return function (value, name) { - return nextHook.call(this, prevHook.call(this, value, name), name); - }; -} -function chainTransforms(prevTransform, nextTransform) { - return function (next, prev, record, options) { - return nextTransform.call(this, prevTransform.call(this, next, prev, record, options), prev, record, options); - }; -} -function chainChangeHandlers(prevHandler, nextHandler) { - return function (next, prev, record, options) { - prevHandler.call(this, next, prev, record, options); - nextHandler.call(this, next, prev, record, options); - }; -} -function wrapIsRequired(validate) { - return function (record, value, key) { - return value ? validate.call(this, record, value, key) : 'Required'; - }; -} -//# sourceMappingURL=any.js.map \ No newline at end of file diff --git a/lib/type-r/record/attributes/any.js.map b/lib/type-r/record/attributes/any.js.map deleted file mode 100644 index f423035..0000000 --- a/lib/type-r/record/attributes/any.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"any.js","sourceRoot":"","sources":["../../../../src/type-r/record/attributes/any.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EA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I,EAAE,MAAM,EAAE,OAAO,CAAE,CAAC;QACtD,WAAW,CAAC,IAAI,CAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAE,CAAC;IAC1D,CAAC,CAAA;AACL,CAAC;AAED,SAAS,cAAc,CAAE,QAAQ;IAC7B,OAAO,UAAU,MAA4B,EAAE,KAAW,EAAE,GAAY;QACpE,OAAO,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,CAAE,CAAC,CAAC,CAAC,UAAU,CAAC;IAC1E,CAAC,CAAA;AACL,CAAC"} \ No newline at end of file diff --git a/lib/type-r/record/attributes/attrDef.d.ts b/lib/type-r/record/attributes/attrDef.d.ts deleted file mode 100644 index 23a59ff..0000000 --- a/lib/type-r/record/attributes/attrDef.d.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { AttributeOptions, Parse } from './any'; -import { EventsDefinition } from '../../object-plus'; -import { IOEndpoint } from '../../io-tools'; -export interface AttributeCheck { - (value: any, key: string): boolean; - error?: any; -} -export declare class ChainableAttributeSpec { - options: AttributeOptions; - constructor(options: AttributeOptions); - check(check: AttributeCheck, error: any): ChainableAttributeSpec; - readonly asProp: (proto: object, name: string) => void; - readonly as: (proto: object, name: string) => void; - readonly isRequired: ChainableAttributeSpec; - endpoint(endpoint: IOEndpoint): ChainableAttributeSpec; - watcher(ref: string | ((value: any, key: string) => void)): ChainableAttributeSpec; - parse(fun: Parse): ChainableAttributeSpec; - toJSON(fun: any): ChainableAttributeSpec; - get(fun: any): ChainableAttributeSpec; - set(fun: any): ChainableAttributeSpec; - changeEvents(events: boolean): ChainableAttributeSpec; - events(map: EventsDefinition): ChainableAttributeSpec; - readonly has: ChainableAttributeSpec; - metadata(options: AttributeOptions): ChainableAttributeSpec; - value(x: any): ChainableAttributeSpec; - static from(spec: any): ChainableAttributeSpec; -} -export declare function type(this: void, spec: ChainableAttributeSpec | Function): ChainableAttributeSpec; -declare global { - interface Function { - value: (x: any) => ChainableAttributeSpec; - isRequired: ChainableAttributeSpec; - asProp: PropertyDecorator; - has: ChainableAttributeSpec; - } -} diff --git a/lib/type-r/record/attributes/attrDef.js b/lib/type-r/record/attributes/attrDef.js deleted file mode 100644 index df6595f..0000000 --- a/lib/type-r/record/attributes/attrDef.js +++ /dev/null @@ -1,163 +0,0 @@ -import { Transactional } from '../../transactions'; -import { EventMap, definitionDecorator, tools } from '../../object-plus'; -var assign = tools.assign; -var ChainableAttributeSpec = (function () { - function ChainableAttributeSpec(options) { - this.options = { getHooks: [], transforms: [], changeHandlers: [] }; - if (options) - assign(this.options, options); - } - ChainableAttributeSpec.prototype.check = function (check, error) { - function validate(model, value, name) { - if (!check.call(model, value, name)) { - var msg = error || check.error || name + ' is not valid'; - return typeof msg === 'function' ? msg.call(model, name) : msg; - } - } - var prev = this.options.validate; - return this.metadata({ - validate: prev ? (function (model, value, name) { - return prev(model, value, name) || validate(model, value, name); - }) : validate - }); - }; - Object.defineProperty(ChainableAttributeSpec.prototype, "asProp", { - get: function () { - return definitionDecorator('attributes', this); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ChainableAttributeSpec.prototype, "as", { - get: function () { return this.asProp; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ChainableAttributeSpec.prototype, "isRequired", { - get: function () { - return this.metadata({ isRequired: true }); - }, - enumerable: true, - configurable: true - }); - ChainableAttributeSpec.prototype.endpoint = function (endpoint) { - return this.metadata({ endpoint: endpoint }); - }; - ChainableAttributeSpec.prototype.watcher = function (ref) { - return this.metadata({ _onChange: ref }); - }; - ChainableAttributeSpec.prototype.parse = function (fun) { - return this.metadata({ parse: fun }); - }; - ChainableAttributeSpec.prototype.toJSON = function (fun) { - return this.metadata({ - toJSON: typeof fun === 'function' ? fun : (fun ? function (x, k, o) { return x && x.toJSON(o); } : emptyFunction) - }); - }; - ChainableAttributeSpec.prototype.get = function (fun) { - return this.metadata({ - getHooks: this.options.getHooks.concat(fun) - }); - }; - ChainableAttributeSpec.prototype.set = function (fun) { - function handleSetHook(next, prev, record, options) { - if (this.isChanged(next, prev)) { - var changed = fun.call(record, next, this.name); - return changed === void 0 ? prev : this.convert(changed, prev, record, options); - } - return prev; - } - return this.metadata({ - transforms: this.options.transforms.concat(handleSetHook) - }); - }; - ChainableAttributeSpec.prototype.changeEvents = function (events) { - return this.metadata({ changeEvents: events }); - }; - ChainableAttributeSpec.prototype.events = function (map) { - var eventMap = new EventMap(map); - function handleEventsSubscribtion(next, prev, record) { - prev && prev.trigger && eventMap.unsubscribe(record, prev); - next && next.trigger && eventMap.subscribe(record, next); - } - return this.metadata({ - changeHandlers: this.options.changeHandlers.concat(handleEventsSubscribtion) - }); - }; - Object.defineProperty(ChainableAttributeSpec.prototype, "has", { - get: function () { - return this; - }, - enumerable: true, - configurable: true - }); - ChainableAttributeSpec.prototype.metadata = function (options) { - var cloned = new ChainableAttributeSpec(this.options); - assign(cloned.options, options); - return cloned; - }; - ChainableAttributeSpec.prototype.value = function (x) { - return this.metadata({ value: x, hasCustomDefault: true }); - }; - ChainableAttributeSpec.from = function (spec) { - var attrSpec; - if (typeof spec === 'function') { - attrSpec = spec.has; - } - else if (spec && spec instanceof ChainableAttributeSpec) { - attrSpec = spec; - } - else { - var type_1 = inferType(spec); - if (type_1 && type_1.prototype instanceof Transactional) { - attrSpec = type_1.shared.value(spec); - } - else { - attrSpec = new ChainableAttributeSpec({ type: type_1, value: spec, hasCustomDefault: true }); - } - } - return attrSpec; - }; - return ChainableAttributeSpec; -}()); -export { ChainableAttributeSpec }; -function emptyFunction() { } -export function type(spec) { - return spec instanceof ChainableAttributeSpec ? spec : new ChainableAttributeSpec({ - type: spec, - value: spec._attribute.defaultValue, - hasCustomDefault: spec._attribute.defaultValue !== void 0 - }); - ; -} -Function.prototype.value = function (x) { - return new ChainableAttributeSpec({ type: this, value: x, hasCustomDefault: true }); -}; -Object.defineProperty(Function.prototype, 'isRequired', { - get: function () { return this._isRequired || this.has.isRequired; }, - set: function (x) { this._isRequired = x; } -}); -Object.defineProperty(Function.prototype, 'asProp', { - get: function () { return this.has.asProp; }, -}); -Object.defineProperty(Function.prototype, 'has', { - get: function () { - return this._has || type(this); - }, - set: function (value) { this._has = value; } -}); -function inferType(value) { - switch (typeof value) { - case 'number': - return Number; - case 'string': - return String; - case 'boolean': - return Boolean; - case 'undefined': - return void 0; - case 'object': - return value ? value.constructor : void 0; - } -} -//# sourceMappingURL=attrDef.js.map \ No newline at end of file diff --git a/lib/type-r/record/attributes/attrDef.js.map b/lib/type-r/record/attributes/attrDef.js.map deleted file mode 100644 index c7347d9..0000000 --- a/lib/type-r/record/attributes/attrDef.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"attrDef.js","sourceRoot":"","sources":["../../../../src/type-r/record/attributes/attrDef.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAGlD,OAAO,EAAE,QAAQ,EAAoB,mBAAmB,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAGlF,IAAA,qBAAM,CAAW;AAOzB;IAGI,gCAAa,OAA0B;QAEnC,IAAI,CAAC,OAAO,GAAG,EAAE,QAAQ,EAAG,EAAE,EAAE,UAAU,EAAG,EAAE,EAAE,cAAc,EAAG,EAAE,EAAC,CAAC;QACtE,IAAI,OAAO;YAAG,MAAM,CAAE,IAAI,CAAC,OAAO,EAAE,OAAO,CAAE,CAAC;IAClD,CAAC;IAED,sCAAK,GAAL,UAAO,KAAsB,EAAE,KAAW;QACtC,SAAS,QAAQ,CAAE,KAAK,EAAE,KAAK,EAAE,IAAI;YACjC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAE,KAAK,EAAE,KAAK,EAAE,IAAI,CAAE,EAAE;gBACnC,IAAM,GAAG,GAAG,KAAK,IAAI,KAAK,CAAC,KAAK,IAAI,IAAI,GAAG,eAAe,CAAC;gBAC3D,OAAO,OAAO,GAAG,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AAG,gBAAK,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;CACpC,CAAC,CAAC;AAEH,MAAM,CAAC,cAAc,CAAE,QAAQ,CAAC,SAAS,EAAE,KAAK,EAAE;IAC9C,GAAG;QAEC,OAAO,IAAI,CAAC,IAAI,IAAI,IAAI,CAAE,IAAI,CAAE,CAAC;IACrC,CAAC;IAED,GAAG,YAAE,KAAK,IAAK,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC;CACtC,CAAE,CAAC;AAEJ,SAAS,SAAS,CAAE,KAAU;IAC1B,QAAQ,OAAO,KAAK,EAAG;QACnB,KAAK,QAAQ;YACT,OAAO,MAAM,CAAC;QAClB,KAAK,QAAQ;YACT,OAAO,MAAM,CAAC;QAClB,KAAK,SAAS;YACV,OAAO,OAAO,CAAC;QACnB,KAAK,WAAW;YACZ,OAAO,KAAK,CAAC,CAAC;QAClB,KAAK,QAAQ;YACT,OAAO,KAAK,CAAC,CAAC,CAAO,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;KACvD;AACL,CAAC"} \ No newline at end of file diff --git a/lib/type-r/record/attributes/basic.d.ts b/lib/type-r/record/attributes/basic.d.ts deleted file mode 100644 index d47677a..0000000 --- a/lib/type-r/record/attributes/basic.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { AnyType } from './any'; -import { AttributesContainer } from './updates'; -import { TransactionOptions } from '../../transactions'; -export declare class PrimitiveType extends AnyType { - type: NumberConstructor | StringConstructor | BooleanConstructor; - dispose(): void; - create(): string | number | boolean; - toJSON(value: any): any; - convert(next: any): any; - isChanged(a: any, b: any): boolean; - clone(value: any): any; - doInit(value: any, record: AttributesContainer, options: TransactionOptions): any; - doUpdate(value: any, record: any, options: any, nested: any): boolean; - initialize(): void; -} -export declare class NumericType extends PrimitiveType { - type: NumberConstructor; - create(): number; - convert(next: any, prev?: any, record?: any): any; - validate(model: any, value: any, name: any): string; -} -declare global { - interface NumberConstructor { - integer: Function; - } - interface Window { - Integer: Function; - } -} -export declare class ArrayType extends AnyType { - toJSON(value: any): any; - dispose(): void; - create(): any[]; - convert(next: any, prev: any, record: any): any; - clone(value: any): any; -} -export declare class ObjectType extends AnyType { - create(): {}; - convert(next: any, prev: any, record: any): any; -} -export declare function doNothing(): void; -export declare class FunctionType extends AnyType { - toJSON(value: any): any; - create(): typeof doNothing; - dispose(): void; - convert(next: any, prev: any, record: any): any; - clone(value: any): any; -} diff --git a/lib/type-r/record/attributes/basic.js b/lib/type-r/record/attributes/basic.js deleted file mode 100644 index f802b0c..0000000 --- a/lib/type-r/record/attributes/basic.js +++ /dev/null @@ -1,142 +0,0 @@ -import * as tslib_1 from "tslib"; -import { AnyType } from './any'; -var ImmutableClassType = (function (_super) { - tslib_1.__extends(ImmutableClassType, _super); - function ImmutableClassType() { - return _super !== null && _super.apply(this, arguments) || this; - } - ImmutableClassType.prototype.create = function () { - return new this.type(); - }; - ImmutableClassType.prototype.convert = function (next) { - return next == null || next instanceof this.type ? next : new this.type(next); - }; - ImmutableClassType.prototype.toJSON = function (value, key, options) { - return value && value.toJSON ? value.toJSON(options) : value; - }; - ImmutableClassType.prototype.clone = function (value) { - return new this.type(this.toJSON(value)); - }; - ImmutableClassType.prototype.isChanged = function (a, b) { - return a !== b; - }; - return ImmutableClassType; -}(AnyType)); -Function.prototype._attribute = ImmutableClassType; -var PrimitiveType = (function (_super) { - tslib_1.__extends(PrimitiveType, _super); - function PrimitiveType() { - return _super !== null && _super.apply(this, arguments) || this; - } - PrimitiveType.prototype.dispose = function () { }; - PrimitiveType.prototype.create = function () { return this.type(); }; - PrimitiveType.prototype.toJSON = function (value) { return value; }; - PrimitiveType.prototype.convert = function (next) { return next == null ? next : this.type(next); }; - PrimitiveType.prototype.isChanged = function (a, b) { return a !== b; }; - PrimitiveType.prototype.clone = function (value) { return value; }; - PrimitiveType.prototype.doInit = function (value, record, options) { - return this.transform(value === void 0 ? this.value : value, void 0, record, options); - }; - PrimitiveType.prototype.doUpdate = function (value, record, options, nested) { - var name = this.name, attributes = record.attributes, prev = attributes[name]; - return prev !== (attributes[name] = this.transform(value, prev, record, options)); - }; - PrimitiveType.prototype.initialize = function () { - if (!this.options.hasCustomDefault) { - this.value = this.type(); - } - }; - return PrimitiveType; -}(AnyType)); -export { PrimitiveType }; -Boolean._attribute = String._attribute = PrimitiveType; -var NumericType = (function (_super) { - tslib_1.__extends(NumericType, _super); - function NumericType() { - return _super !== null && _super.apply(this, arguments) || this; - } - NumericType.prototype.create = function () { - return 0; - }; - NumericType.prototype.convert = function (next, prev, record) { - var num = next == null ? next : this.type(next); - if (num !== num) { - this._log('warn', 'assigned with Invalid Number', next, record); - } - return num; - }; - NumericType.prototype.validate = function (model, value, name) { - if (value != null && !isFinite(value)) { - return name + ' is not valid number'; - } - }; - return NumericType; -}(PrimitiveType)); -export { NumericType }; -Number._attribute = NumericType; -function Integer(x) { - return x ? Math.round(x) : 0; -} -Integer._attribute = NumericType; -Number.integer = Integer; -if (typeof window !== 'undefined') { - window.Integer = Number.integer; -} -var ArrayType = (function (_super) { - tslib_1.__extends(ArrayType, _super); - function ArrayType() { - return _super !== null && _super.apply(this, arguments) || this; - } - ArrayType.prototype.toJSON = function (value) { return value; }; - ArrayType.prototype.dispose = function () { }; - ArrayType.prototype.create = function () { return []; }; - ArrayType.prototype.convert = function (next, prev, record) { - if (next == null || Array.isArray(next)) - return next; - this._log('warn', 'assignment of non-array to Array attribute is ignored', next, record); - return []; - }; - ArrayType.prototype.clone = function (value) { - return value && value.slice(); - }; - return ArrayType; -}(AnyType)); -export { ArrayType }; -Array._attribute = ArrayType; -var ObjectType = (function (_super) { - tslib_1.__extends(ObjectType, _super); - function ObjectType() { - return _super !== null && _super.apply(this, arguments) || this; - } - ObjectType.prototype.create = function () { return {}; }; - ObjectType.prototype.convert = function (next, prev, record) { - if (next == null || typeof next === 'object') - return next; - this._log('warn', 'assignment of non-object to Object attribute is ignored', next, record); - return {}; - }; - return ObjectType; -}(AnyType)); -export { ObjectType }; -Object._attribute = ObjectType; -export function doNothing() { } -var FunctionType = (function (_super) { - tslib_1.__extends(FunctionType, _super); - function FunctionType() { - return _super !== null && _super.apply(this, arguments) || this; - } - FunctionType.prototype.toJSON = function (value) { return void 0; }; - FunctionType.prototype.create = function () { return doNothing; }; - FunctionType.prototype.dispose = function () { }; - FunctionType.prototype.convert = function (next, prev, record) { - if (next == null || typeof next === 'function') - return next; - this._log('warn', 'assigned with non-function', next, record); - return doNothing; - }; - FunctionType.prototype.clone = function (value) { return value; }; - return FunctionType; -}(AnyType)); -export { FunctionType }; -Function._attribute = FunctionType; -//# sourceMappingURL=basic.js.map \ No newline at end of file diff --git a/lib/type-r/record/attributes/basic.js.map b/lib/type-r/record/attributes/basic.js.map deleted file mode 100644 index 5452804..0000000 --- a/lib/type-r/record/attributes/basic.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"basic.js","sourceRoot":"","sources":["../../../../src/type-r/record/attributes/basic.ts"],"names":[],"mappings":";AAMA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAS/B;IAAiC,8CAAO;IAAxC;;IAsBA,CAAC;IAnBG,mCAAM,GAAN;QACI,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;IAC3B,CAAC;IAED,oCAAO,GAAP,UAAS,IAAU;QACf,OAAO,IAAI,IAAI,IAAI,IAAI,IAAI,YAAY,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;IACpF,CAAC;IAED,mCAAM,GAAN,UAAQ,KAAK,EAAE,GAAa,EAAE,OAAiB;QAC3C,OAAO,KAAK,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAE,OAAO,CAAE,CAAC,CAAC,CAAC,KAAK,CAAC;IACnE,CAAC;IAED,kCAAK,GAAL,UAAO,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AE,CAAC;QAC7F,OAAO,EAAE,CAAC;IACd,CAAC;IACL,iBAAC;AAAD,CAAC,AATD,CAAgC,OAAO,GAStC;;AAED,MAAM,CAAC,UAAU,GAAG,UAAU,CAAC;AAE/B,MAAM,UAAU,SAAS,KAAG,CAAC;AAE7B;IAAkC,wCAAO;IAAzC;;IAiBA,CAAC;IAfG,6BAAM,GAAN,UAAQ,KAAK,IAAK,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;IAClC,6BAAM,GAAN,cAAU,OAAO,SAAS,CAAC,CAAC,CAAC;IAC7B,8BAAO,GAAP,cAAU,CAAC;IAEX,8BAAO,GAAP,UAAS,IAAI,EAAE,IAAI,EAAE,MAAM;QAEvB,IAAI,IAAI,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,UAAU;YAAG,OAAO,IAAI,CAAC;QAE7D,IAAI,CAAC,IAAI,CAAE,MAAM,EAAE,4BAA4B,EAAE,IAAI,EAAE,MAAM,CAAE,CAAC;QAEhE,OAAO,SAAS,CAAC;IACrB,CAAC;IAGD,4BAAK,GAAL,UAAO,KAAK,IAAI,OAAO,KAAK,CAAC,CAAC,CAAC;IACnC,mBAAC;AAAD,CAAC,AAjBD,CAAkC,OAAO,GAiBxC;;AAED,QAAQ,CAAC,UAAU,GAAG,YAAY,CAAC"} \ No newline at end of file diff --git a/lib/type-r/record/attributes/date.d.ts b/lib/type-r/record/attributes/date.d.ts deleted file mode 100644 index 3d82bfb..0000000 --- a/lib/type-r/record/attributes/date.d.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { AnyType } from './any'; -import { AttributesContainer } from './updates'; -import { TransactionOptions } from '../../transactions'; -import { ChainableAttributeSpec } from './attrDef'; -export declare class DateType extends AnyType { - create(): Date; - convert(next: any, a: any, record: any): any; - validate(model: any, value: any, name: any): string; - toJSON(value: any): any; - isChanged(a: any, b: any): boolean; - doInit(value: any, record: AttributesContainer, options: TransactionOptions): any; - doUpdate(value: any, record: any, options: any, nested: any): boolean; - clone(value: any): Date; - dispose(): void; -} -export declare class MSDateType extends DateType { - convert(next: any): any; - toJSON(value: any): string; -} -export declare class TimestampType extends DateType { - toJSON(value: any): any; -} -declare global { - interface DateConstructor { - microsoft: ChainableAttributeSpec; - timestamp: ChainableAttributeSpec; - } -} diff --git a/lib/type-r/record/attributes/date.js b/lib/type-r/record/attributes/date.js deleted file mode 100644 index d0b6a7d..0000000 --- a/lib/type-r/record/attributes/date.js +++ /dev/null @@ -1,125 +0,0 @@ -import * as tslib_1 from "tslib"; -import { AnyType } from './any'; -import { ChainableAttributeSpec } from './attrDef'; -var DateProto = Date.prototype; -var DateType = (function (_super) { - tslib_1.__extends(DateType, _super); - function DateType() { - return _super !== null && _super.apply(this, arguments) || this; - } - DateType.prototype.create = function () { - return new Date(); - }; - DateType.prototype.convert = function (next, a, record) { - if (next == null || next instanceof Date) - return next; - var date = new Date(next), timestamp = date.getTime(); - if (timestamp !== timestamp) { - this._log('warn', 'assigned with Invalid Date', next, record); - } - return date; - }; - DateType.prototype.validate = function (model, value, name) { - if (value != null) { - var timestamp = value.getTime(); - if (timestamp !== timestamp) - return name + ' is Invalid Date'; - } - }; - DateType.prototype.toJSON = function (value) { return value && value.toISOString(); }; - DateType.prototype.isChanged = function (a, b) { return (a && a.getTime()) !== (b && b.getTime()); }; - DateType.prototype.doInit = function (value, record, options) { - return this.transform(value === void 0 ? this.defaultValue() : value, void 0, record, options); - }; - DateType.prototype.doUpdate = function (value, record, options, nested) { - var name = this.name, attributes = record.attributes, prev = attributes[name]; - return this.isChanged(prev, attributes[name] = this.transform(value, prev, record, options)); - }; - DateType.prototype.clone = function (value) { return value && new Date(value.getTime()); }; - DateType.prototype.dispose = function () { }; - return DateType; -}(AnyType)); -export { DateType }; -Date._attribute = DateType; -var msDatePattern = /\/Date\(([0-9]+)\)\//; -var MSDateType = (function (_super) { - tslib_1.__extends(MSDateType, _super); - function MSDateType() { - return _super !== null && _super.apply(this, arguments) || this; - } - MSDateType.prototype.convert = function (next) { - if (typeof next === 'string') { - var msDate = msDatePattern.exec(next); - if (msDate) { - return new Date(Number(msDate[1])); - } - } - return DateType.prototype.convert.apply(this, arguments); - }; - MSDateType.prototype.toJSON = function (value) { return value && "/Date(" + value.getTime() + ")/"; }; - return MSDateType; -}(DateType)); -export { MSDateType }; -var TimestampType = (function (_super) { - tslib_1.__extends(TimestampType, _super); - function TimestampType() { - return _super !== null && _super.apply(this, arguments) || this; - } - TimestampType.prototype.toJSON = function (value) { return value && value.getTime(); }; - return TimestampType; -}(DateType)); -export { TimestampType }; -Object.defineProperties(Date, { - microsoft: { - get: function () { - return new ChainableAttributeSpec({ - type: Date, - _attribute: MSDateType - }); - } - }, - timestamp: { - get: function () { - return new ChainableAttributeSpec({ - type: Date, - _attribute: TimestampType - }); - } - } -}); -function supportsDate(date) { - return !isNaN((new Date(date)).getTime()); -} -if (!supportsDate('2011-11-29T15:52:30.5') || - !supportsDate('2011-11-29T15:52:30.52') || - !supportsDate('2011-11-29T15:52:18.867') || - !supportsDate('2011-11-29T15:52:18.867Z') || - !supportsDate('2011-11-29T15:52:18.867-03:30')) { - DateType.prototype.convert = function (value) { - return value == null || value instanceof Date ? value : new Date(safeParseDate(value)); - }; -} -var numericKeys = [1, 4, 5, 6, 7, 10, 11], isoDatePattern = /^(\d{4}|[+\-]\d{6})(?:-(\d{2})(?:-(\d{2}))?)?(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?(?:(Z)|([+\-])(\d{2})(?::(\d{2}))?)?)?$/; -function safeParseDate(date) { - var timestamp, struct, minutesOffset = 0; - if ((struct = isoDatePattern.exec(date))) { - for (var i = 0, k; (k = numericKeys[i]); ++i) { - struct[k] = +struct[k] || 0; - } - struct[2] = (+struct[2] || 1) - 1; - struct[3] = +struct[3] || 1; - if (struct[8] !== 'Z' && struct[9] !== undefined) { - minutesOffset = struct[10] * 60 + struct[11]; - if (struct[9] === '+') { - minutesOffset = 0 - minutesOffset; - } - } - timestamp = - Date.UTC(struct[1], struct[2], struct[3], struct[4], struct[5] + minutesOffset, struct[6], struct[7]); - } - else { - timestamp = Date.parse(date); - } - return timestamp; -} -//# sourceMappingURL=date.js.map \ No newline at end of file diff --git a/lib/type-r/record/attributes/date.js.map b/lib/type-r/record/attributes/date.js.map deleted file mode 100644 index 2c2b09a..0000000 --- a/lib/type-r/record/attributes/date.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"date.js","sourceRoot":"","sources":["../../../../src/type-r/record/attributes/date.ts"],"names":[],"mappings":";AAMA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAI/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAA;AAElD,IAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;AAIjC;IAA8B,oCAAO;IAArC;;IA6CA,CAAC;IA5CG,yBAAM,GAAN;QACI,OAAO,IAAI,IAAI,EAAE,CAAC;IACtB,CAAC;IAED,0BAAO,GAAP,UAAS,IAAU,EAAE,CAAC,EAAE,MAAM;QAC1B,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,YAAY,IAAI;YAAG,OAAO,IAAI,CAAC;QAEvD,IAAM,IAAI,GAAG,IAAI,IAAI,CAAE,IAAI,CAAE,EACvB,SAAS,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QAEjC,IAAI,SAAS,KAAK,SAAS,EAAE;YACzB,IAAI,CAAC,IAAI,CAAE,MAAM,EAAE,4BAA4B,EAAE,IAAI,EAAE,MAAM,CAAE,CAAC;SACnE;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,2BAAQ,GAAR,UAAU,KAAK,EAAE,KAAK,EAAE,IAAI;QACxB,IAAI,KAAK,IAAI,IAAI,EAAE;YACf,IAAM,SAAS,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC;YAClC,IAAI,SAAS,KAAK,SAAS;gBAAG,OAAO,IAAI,GAAG,kBAAkB,CAAC;SAClE;IACL,CAAC;IAED,yBAAM,GAAN,UA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E,GAAG,MAAM,CAAE,EAAE,CAAE,CAAC;YAEjD,IAAI,MAAM,CAAE,CAAC,CAAE,KAAK,GAAG,EAAG;gBACtB,aAAa,GAAG,CAAC,GAAG,aAAa,CAAC;aACrC;SACJ;QAED,SAAS;YACL,IAAI,CAAC,GAAG,CAAE,MAAM,CAAE,CAAC,CAAE,EAAE,MAAM,CAAE,CAAC,CAAE,EAAE,MAAM,CAAE,CAAC,CAAE,EAAE,MAAM,CAAE,CAAC,CAAE,EAAE,MAAM,CAAE,CAAC,CAAE,GAAG,aAAa,EAAE,MAAM,CAAE,CAAC,CAAE,EAC9F,MAAM,CAAE,CAAC,CAAE,CAAE,CAAC;KAC7B;SACI;QACD,SAAS,GAAG,IAAI,CAAC,KAAK,CAAE,IAAI,CAAE,CAAC;KAClC;IAED,OAAO,SAAS,CAAC;AACrB,CAAC"} \ No newline at end of file diff --git a/lib/type-r/record/attributes/index.d.ts b/lib/type-r/record/attributes/index.d.ts deleted file mode 100644 index 256e999..0000000 --- a/lib/type-r/record/attributes/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { eventsApi } from '../../object-plus'; -export * from './any'; -export * from './owned'; -export * from './date'; -export * from './basic'; -export * from './shared'; -export * from './updates'; -export * from './attrDef'; -import { AnyType } from './any'; -import { ConstructorsMixin } from './updates'; -import { IOEndpoint } from '../../io-tools'; -export interface RecordAttributesMixin extends ConstructorsMixin { - _attributes: AttributeDescriptors; - _attributesArray: AnyType[]; - properties: PropertyDescriptorMap; - _localEvents?: eventsApi.EventMap; - _endpoints: { - [name: string]: IOEndpoint; - }; -} -export interface AttributeDescriptors { - [name: string]: AnyType; -} -export default function (attributesDefinition: object, baseClassAttributes: AttributeDescriptors): RecordAttributesMixin; -export declare function createAttribute(spec: any, name: string): AnyType; -export declare function createSharedTypeSpec(Constructor: Function, Attribute: typeof AnyType): void; diff --git a/lib/type-r/record/attributes/index.js b/lib/type-r/record/attributes/index.js deleted file mode 100644 index c43ff9d..0000000 --- a/lib/type-r/record/attributes/index.js +++ /dev/null @@ -1,63 +0,0 @@ -import * as tslib_1 from "tslib"; -import { tools as _, eventsApi } from '../../object-plus'; -export * from './any'; -export * from './owned'; -export * from './date'; -export * from './basic'; -export * from './shared'; -export * from './updates'; -export * from './attrDef'; -import { AnyType } from './any'; -import { constructorsMixin } from './updates'; -import { ChainableAttributeSpec } from './attrDef'; -import { CompiledReference } from '../../traversable'; -export default function (attributesDefinition, baseClassAttributes) { - var myAttributes = _.transform({}, attributesDefinition, createAttribute), allAttributes = _.defaults({}, myAttributes, baseClassAttributes); - var ConstructorsMixin = constructorsMixin(allAttributes); - return tslib_1.__assign({}, ConstructorsMixin, { _attributes: new ConstructorsMixin.AttributesCopy(allAttributes), _attributesArray: Object.keys(allAttributes).map(function (key) { return allAttributes[key]; }), properties: _.transform({}, myAttributes, function (x) { return x.createPropertyDescriptor(); }) }, localEventsMixin(myAttributes), { _endpoints: _.transform({}, allAttributes, function (attrDef) { return attrDef.options.endpoint; }) }); -} -export function createAttribute(spec, name) { - return AnyType.create(ChainableAttributeSpec.from(spec).options, name); -} -export function createSharedTypeSpec(Constructor, Attribute) { - if (!Constructor.hasOwnProperty('shared')) { - Object.defineProperty(Constructor, 'shared', { - get: function () { - return new ChainableAttributeSpec({ - value: null, - type: Constructor, - _attribute: Attribute - }); - } - }); - } -} -function localEventsMixin(attrSpecs) { - var _localEvents; - for (var key in attrSpecs) { - var attribute = attrSpecs[key], _onChange = attribute.options._onChange; - if (_onChange) { - _localEvents || (_localEvents = new eventsApi.EventMap()); - _localEvents.addEvent('change:' + key, typeof _onChange === 'string' ? - createWatcherFromRef(_onChange, key) : - wrapWatcher(_onChange, key)); - } - } - return _localEvents ? { _localEvents: _localEvents } : {}; -} -function wrapWatcher(watcher, key) { - return function (record, value) { - watcher.call(record, value, key); - }; -} -function createWatcherFromRef(ref, key) { - var _a = new CompiledReference(ref, true), local = _a.local, resolve = _a.resolve, tail = _a.tail; - return local ? - function (record, value) { - record[tail](value, key); - } : - function (record, value) { - resolve(record)[tail](value, key); - }; -} -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/lib/type-r/record/attributes/index.js.map b/lib/type-r/record/attributes/index.js.map deleted file mode 100644 index 4047447..0000000 --- a/lib/type-r/record/attributes/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/type-r/record/attributes/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,IAAI,CAAC,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAEzD,cAAc,OAAO,CAAA;AACrB,cAAc,SAAS,CAAA;AACvB,cAAc,QAAQ,CAAA;AACtB,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AAEzB,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,EAAqB,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAsBrD,MAAM,CAAC,OAAO,WAAW,oBAA6B,EAAE,mBAA0C;IAC9F,IAAM,YAAY,GAAG,CAAC,CAAC,SAAS,CAAE,EAA0B,EAAE,oBAAoB,EAAE,eAAe,CAAE,EAC/F,aAAa,GAAG,CAAC,CAAC,QAAQ,CAAE,EAA0B,EAAE,YAAY,EAAE,mBAAmB,CAAE,CAAC;IAElG,IAAM,iBAAiB,GAAG,iBAAiB,CAAE,aAAa,CAAE,CAAC;IAE7D,4BACO,iBAAiB,IACpB,WAAW,EAAG,IAAI,iBAAiB,CAAC,cAAc,CAAE,aAAa,CAAE,EACnE,gBAAgB,EAAG,MAAM,CAAC,IAAI,CAAE,aAAa,CAAE,CAAC,GAAG,CAAE,UAAA,GAAG,IAAI,OAAA,aAAa,CAAE,GAAG,CAAE,EAApB,CA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AAC;gBAC3B,oBAAoB,CAAE,SAAS,EAAE,GAAG,CAAE,CAAC,CAAC;gBACxC,WAAW,CAAE,SAAS,EAAE,GAAG,CAAE,CAAE,CAAC;SAC3C;KACJ;IAED,OAAO,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,cAAA,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AAChD,CAAC;AAED,SAAS,WAAW,CAAE,OAAO,EAAE,GAAG;IAC9B,OAAO,UAAU,MAAM,EAAE,KAAK;QAC1B,OAAO,CAAC,IAAI,CAAE,MAAM,EAAE,KAAK,EAAE,GAAG,CAAE,CAAC;IACvC,CAAC,CAAA;AACL,CAAC;AAED,SAAS,oBAAoB,CAAE,GAAY,EAAE,GAAY;IAC/C,IAAA,qCAA6D,EAA3D,gBAAK,EAAE,oBAAO,EAAE,cAAI,CAAwC;IACpE,OAAO,KAAK,CAAC,CAAC;QACV,UAAU,MAAM,EAAE,KAAK;YACnB,MAAM,CAAE,IAAI,CAAE,CAAE,KAAK,EAAE,GAAG,CAAE,CAAC;QACjC,CAAC,CAAC,CAAC;QACH,UAAU,MAAM,EAAE,KAAK;YACnB,OAAO,CAAE,MAAM,CAAE,CAAE,IAAI,CAAE,CAAE,KAAK,EAAE,GAAG,CAAE,CAAC;QAC5C,CAAC,CAAA;AACT,CAAC"} \ No newline at end of file diff --git a/lib/type-r/record/attributes/owned.d.ts b/lib/type-r/record/attributes/owned.d.ts deleted file mode 100644 index 78bd0c7..0000000 --- a/lib/type-r/record/attributes/owned.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { AnyType } from './any'; -import { Transactional, TransactionOptions } from '../../transactions'; -import { AttributesContainer, ConstructorOptions } from './updates'; -import { ValidationError } from '../../validation'; -export declare class AggregatedType extends AnyType { - type: typeof Transactional; - clone(value: Transactional): Transactional; - toJSON(x: any, key: string, options: object): any; - doInit(value: any, record: AttributesContainer, options: ConstructorOptions): any; - doUpdate(value: any, record: any, options: any, nested: any[]): boolean; - canBeUpdated(prev: Transactional, next: any, options: TransactionOptions): any; - convert(next: any, prev: any, record: AttributesContainer, options: TransactionOptions): Transactional; - dispose(record: AttributesContainer, value: Transactional): void; - validate(record: AttributesContainer, value: Transactional): ValidationError; - create(): Transactional; - initialize(options: any): void; - _handleChange(next: Transactional, prev: Transactional, record: AttributesContainer, options: TransactionOptions): void; -} diff --git a/lib/type-r/record/attributes/owned.js b/lib/type-r/record/attributes/owned.js deleted file mode 100644 index ac7b8c5..0000000 --- a/lib/type-r/record/attributes/owned.js +++ /dev/null @@ -1,96 +0,0 @@ -import * as tslib_1 from "tslib"; -import { AnyType } from './any'; -import { transactionApi, ItemsBehavior } from '../../transactions'; -var free = transactionApi.free, aquire = transactionApi.aquire; -var AggregatedType = (function (_super) { - tslib_1.__extends(AggregatedType, _super); - function AggregatedType() { - return _super !== null && _super.apply(this, arguments) || this; - } - AggregatedType.prototype.clone = function (value) { - return value ? value.clone() : value; - }; - AggregatedType.prototype.toJSON = function (x, key, options) { return x && x.toJSON(options); }; - AggregatedType.prototype.doInit = function (value, record, options) { - var v = options.clone ? this.clone(value) : (value === void 0 ? this.defaultValue() : value); - var x = this.transform(v, void 0, record, options); - this.handleChange(x, void 0, record, options); - return x; - }; - AggregatedType.prototype.doUpdate = function (value, record, options, nested) { - var key = this.name, attributes = record.attributes; - var prev = attributes[key]; - var update; - if (update = this.canBeUpdated(prev, value, options)) { - var nestedTransaction = prev._createTransaction(update, options); - if (nestedTransaction) { - if (nested) { - nested.push(nestedTransaction); - } - else { - nestedTransaction.commit(record); - } - if (this.propagateChanges) - return true; - } - return false; - } - var next = this.transform(value, prev, record, options); - attributes[key] = next; - if (this.isChanged(next, prev)) { - this.handleChange(next, prev, record, options); - return true; - } - return false; - }; - AggregatedType.prototype.canBeUpdated = function (prev, next, options) { - if (prev && next != null) { - if (next instanceof this.type) { - if (options.merge) - return next.__inner_state__; - } - else { - return next; - } - } - }; - AggregatedType.prototype.convert = function (next, prev, record, options) { - if (next == null) - return next; - if (next instanceof this.type) { - if (next._shared && !(next._shared & ItemsBehavior.persistent)) { - this._log('error', 'aggregated collection attribute is assigned with shared collection', next, record); - } - return options.merge ? next.clone() : next; - } - return this.type.create(next, options); - }; - AggregatedType.prototype.dispose = function (record, value) { - if (value) { - this.handleChange(void 0, value, record, {}); - } - }; - AggregatedType.prototype.validate = function (record, value) { - var error = value && value.validationError; - if (error) - return error; - }; - AggregatedType.prototype.create = function () { - return this.type.create(); - }; - AggregatedType.prototype.initialize = function (options) { - options.changeHandlers.unshift(this._handleChange); - }; - AggregatedType.prototype._handleChange = function (next, prev, record, options) { - if (prev) { - free(record, prev); - options.unset || prev.dispose(); - } - if (next && !aquire(record, next, this.name)) { - this._log('error', 'aggregated attribute assigned with object already having an owner', next, record); - } - }; - return AggregatedType; -}(AnyType)); -export { AggregatedType }; -//# sourceMappingURL=owned.js.map \ No newline at end of file diff --git a/lib/type-r/record/attributes/owned.js.map b/lib/type-r/record/attributes/owned.js.map deleted file mode 100644 index f194824..0000000 --- a/lib/type-r/record/attributes/owned.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"owned.js","sourceRoot":"","sources":["../../../../src/type-r/record/attributes/owned.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,EAAS,cAAc,EAAiB,aAAa,EAAsB,MAAM,oBAAoB,CAAA;AAKpG,IAAA,0BAAI,EAAE,8BAAM,CAAoB;AAExC;IAAoC,0CAAO;IAA3C;;IAiHA,CAAC;IA9GG,8BAAK,GAAL,UAAO,KAAqB;QACxB,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;IACzC,CAAC;IAED,+BAAM,GAAN,UAAQ,CAAC,EAAE,GAAY,EAAE,OAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,CAAE,OAAO,CAAE,CAAC,CAAC,CAAC;IAE/E,+BAAM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,CAAE,KAAK,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,CAAE,CAAC;SAClD;IACL,CAAC;IAED,iCAAQ,GAAR,UAAU,MAA4B,EAAE,KAAqB;QACzD,IAAI,KAAK,GAAG,KAAK,IAAI,KAAK,CAAC,eAAe,CAAC;QAC3C,IAAI,KAAK;YAAG,OAAO,KAAK,CAAC;IAC7B,CAAC;IAED,+BAAM,GAAN;QACI,OAAa,IAAI,CAAC,IAAK,CAAC,MAAM,EAAE,CAAC;IACrC,CAAC;IAED,mCAAU,GAAV,UAAY,OAAO;QACf,OAAO,CAAC,cAAc,CAAC,OAAO,CAAE,IAAI,CAAC,aAAa,CAAE,CAAC;IACzD,CAAC;IAED,sCAAa,GAAb,UAAe,IAAoB,EAAE,IAAoB,EAAE,MAA4B,EAAE,OAA4B;QACjH,IAAI,IAAI,EAAE;YACN,IAAI,CAAE,MAAM,EAAE,IAAI,CAAE,CAAC;YACrB,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;SACnC;QAED,IAAI,IAAI,IAAI,CAAC,MAAM,CAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAE,EAAE;YAC5C,IAAI,CAAC,IAAI,CAAE,OAAO,EAAE,mEAAmE,EAAE,IAAI,EAAE,MAAM,CAAE,CAAC;SAC3G;IACL,CAAC;IACL,qBAAC;AAAD,CAAC,AAjHD,CAAoC,OAAO,GAiH1C"} \ No newline at end of file diff --git a/lib/type-r/record/attributes/shared.d.ts b/lib/type-r/record/attributes/shared.d.ts deleted file mode 100644 index 2632212..0000000 --- a/lib/type-r/record/attributes/shared.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { AnyType } from './any'; -import { AttributesContainer, ConstructorOptions } from './updates'; -import { Transactional, TransactionOptions } from '../../transactions'; -export declare class SharedType extends AnyType { - type: typeof Transactional; - doInit(value: any, record: AttributesContainer, options: ConstructorOptions): any; - doUpdate(value: any, record: any, options: any, nested: any[]): boolean; - clone(value: Transactional, record: AttributesContainer): Transactional; - toJSON(): void; - canBeUpdated(prev: Transactional, next: any, options: TransactionOptions): any; - convert(next: any, prev: any, record: AttributesContainer, options: TransactionOptions): Transactional; - validate(model: any, value: any, name: any): void; - create(): Transactional; - _handleChange(next: Transactional, prev: Transactional, record: AttributesContainer, options: any): void; - dispose(record: AttributesContainer, value: Transactional): void; - _onChange: (child: Transactional, options: TransactionOptions, initiator: Transactional) => void; - initialize(options: any): void; -} diff --git a/lib/type-r/record/attributes/shared.js b/lib/type-r/record/attributes/shared.js deleted file mode 100644 index db297e6..0000000 --- a/lib/type-r/record/attributes/shared.js +++ /dev/null @@ -1,100 +0,0 @@ -import * as tslib_1 from "tslib"; -import { AnyType } from './any'; -import { ItemsBehavior, transactionApi } from '../../transactions'; -import { eventsApi } from '../../object-plus'; -var on = eventsApi.on, off = eventsApi.off, free = transactionApi.free, aquire = transactionApi.aquire; -var shareAndListen = ItemsBehavior.listen | ItemsBehavior.share; -var SharedType = (function (_super) { - tslib_1.__extends(SharedType, _super); - function SharedType() { - return _super !== null && _super.apply(this, arguments) || this; - } - SharedType.prototype.doInit = function (value, record, options) { - var v = options.clone ? this.clone(value, record) : (value === void 0 ? this.defaultValue() : value); - var x = this.transform(v, void 0, record, options); - this.handleChange(x, void 0, record, options); - return x; - }; - SharedType.prototype.doUpdate = function (value, record, options, nested) { - var key = this.name, attributes = record.attributes; - var prev = attributes[key]; - var update; - if (update = this.canBeUpdated(prev, value, options)) { - var nestedTransaction = prev._createTransaction(update, options); - if (nestedTransaction) { - if (nested) { - nested.push(nestedTransaction); - } - else { - nestedTransaction.commit(record); - } - if (this.propagateChanges) - return true; - } - return false; - } - var next = this.transform(value, prev, record, options); - attributes[key] = next; - if (this.isChanged(next, prev)) { - this.handleChange(next, prev, record, options); - return true; - } - return false; - }; - SharedType.prototype.clone = function (value, record) { - if (!value || value._owner !== record) - return value; - var clone = value.clone(); - aquire(record, clone, this.name); - return clone; - }; - SharedType.prototype.toJSON = function () { }; - SharedType.prototype.canBeUpdated = function (prev, next, options) { - if (prev && next != null && !(next instanceof this.type)) { - return next; - } - }; - SharedType.prototype.convert = function (next, prev, record, options) { - if (next == null || next instanceof this.type) - return next; - var implicitObject = new this.type(next, options, shareAndListen); - aquire(record, implicitObject, this.name); - return implicitObject; - }; - SharedType.prototype.validate = function (model, value, name) { }; - SharedType.prototype.create = function () { - return null; - }; - SharedType.prototype._handleChange = function (next, prev, record, options) { - if (prev) { - if (prev._owner === record) { - free(record, prev); - options.unset || prev.dispose(); - } - else { - off(prev, prev._changeEventName, this._onChange, record); - } - } - if (next) { - if (next._owner !== record) { - on(next, next._changeEventName, this._onChange, record); - } - } - }; - SharedType.prototype.dispose = function (record, value) { - if (value) { - this.handleChange(void 0, value, record, {}); - } - }; - SharedType.prototype.initialize = function (options) { - var attribute = this; - this._onChange = this.propagateChanges ? function (child, options, initiator) { - this === initiator || this.forceAttributeChange(attribute.name, options); - } : ignore; - options.changeHandlers.unshift(this._handleChange); - }; - return SharedType; -}(AnyType)); -export { SharedType }; -function ignore() { } -//# sourceMappingURL=shared.js.map \ No newline at end of file diff --git a/lib/type-r/record/attributes/shared.js.map b/lib/type-r/record/attributes/shared.js.map deleted file mode 100644 index ef248a5..0000000 --- a/lib/type-r/record/attributes/shared.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../src/type-r/record/attributes/shared.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAE/B,OAAO,EAAE,aAAa,EAAS,cAAc,EAAqC,MAAM,oBAAoB,CAAA;AAC5G,OAAO,EAAS,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAE5C,IAAA,iBAAE,EAAE,mBAAG,EACT,0BAAI,EAAE,8BAAM,CAAoB;AAUtC,IAAM,cAAc,GAAG,aAAa,CAAC,MAAM,GAAG,aAAa,CAAC,KAAK,CAAC;AAGlE;IAAg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AE,IAAI,CAAC,aAAa,CAAE,CAAC;IACzD,CAAC;IACL,iBAAC;AAAD,CAAC,AA9HD,CAAgC,OAAO,GA8HtC;;AAED,SAAS,MAAM,KAAG,CAAC"} \ No newline at end of file diff --git a/lib/type-r/record/attributes/updates.d.ts b/lib/type-r/record/attributes/updates.d.ts deleted file mode 100644 index 739f95d..0000000 --- a/lib/type-r/record/attributes/updates.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { Transactional, Transaction, TransactionOptions, Owner } from "../../transactions"; -export interface ConstructorsMixin { - Attributes: AttributesConstructor; - AttributesCopy: AttributesCopyConstructor; -} -export interface ConstructorOptions extends TransactionOptions { - clone?: boolean; -} -export declare type AttributesConstructor = new (record: AttributesContainer, values: object, options: TransactionOptions) => AttributesValues; -export declare type AttributesCopyConstructor = new (values: object) => AttributesValues; -export interface AttributesContainer extends Transactional, Owner, ConstructorsMixin { - _attributes: AttributesDescriptors; - attributes: AttributesValues; - _previousAttributes: AttributesValues; - _changedAttributes: AttributesValues; -} -export interface AttributesValues { - [name: string]: any; -} -export interface AttributesDescriptors { - [name: string]: AttributeUpdatePipeline; -} -export interface AttributeUpdatePipeline { - doUpdate(value: any, record: AttributesContainer, options: TransactionOptions, nested?: Transaction[]): boolean; -} -export declare function setAttribute(record: AttributesContainer, name: string, value: any): void; -export declare const UpdateRecordMixin: { - transaction(this: AttributesContainer, fun: (self: AttributesContainer) => void, options?: TransactionOptions): void; - _onChildrenChange(child: Transactional, options: TransactionOptions): void; - forceAttributeChange(key: string, options?: TransactionOptions): void; - _createTransaction(this: AttributesContainer, a_values: {}, options?: TransactionOptions): Transaction; -}; -export declare function constructorsMixin(attrDefs: AttributesDescriptors): ConstructorsMixin; -export declare function shouldBeAnObject(record: AttributesContainer, values: object): boolean; -export declare class RecordTransaction implements Transaction { - object: AttributesContainer; - isRoot: boolean; - nested: Transaction[]; - changes: string[]; - constructor(object: AttributesContainer, isRoot: boolean, nested: Transaction[], changes: string[]); - commit(initiator?: AttributesContainer): void; -} diff --git a/lib/type-r/record/attributes/updates.js b/lib/type-r/record/attributes/updates.js deleted file mode 100644 index 492d465..0000000 --- a/lib/type-r/record/attributes/updates.js +++ /dev/null @@ -1,114 +0,0 @@ -import { transactionApi } from "../../transactions"; -var _begin = transactionApi.begin, _markAsDirty = transactionApi.markAsDirty, commit = transactionApi.commit; -import { eventsApi } from '../../object-plus'; -var trigger3 = eventsApi.trigger3; -export function setAttribute(record, name, value) { - var isRoot = begin(record), options = {}; - if (record._attributes[name].doUpdate(value, record, options)) { - markAsDirty(record, options); - trigger3(record, 'change:' + name, record, record.attributes[name], options); - } - isRoot && commit(record); -} -function begin(record) { - if (_begin(record)) { - record._previousAttributes = new record.AttributesCopy(record.attributes); - record._changedAttributes = null; - return true; - } - return false; -} -function markAsDirty(record, options) { - if (record._changedAttributes) { - record._changedAttributes = null; - } - return _markAsDirty(record, options); -} -export var UpdateRecordMixin = { - transaction: function (fun, options) { - if (options === void 0) { options = {}; } - var isRoot = begin(this); - fun.call(this, this); - isRoot && commit(this); - }, - _onChildrenChange: function (child, options) { - var _ownerKey = child._ownerKey, attribute = this._attributes[_ownerKey]; - if (!attribute || attribute.propagateChanges) - this.forceAttributeChange(_ownerKey, options); - }, - forceAttributeChange: function (key, options) { - if (options === void 0) { options = {}; } - var isRoot = begin(this); - if (markAsDirty(this, options)) { - trigger3(this, 'change:' + key, this, this.attributes[key], options); - } - isRoot && commit(this); - }, - _createTransaction: function (a_values, options) { - if (options === void 0) { options = {}; } - var isRoot = begin(this), changes = [], nested = [], _attributes = this._attributes, values = options.parse ? this.parse(a_values, options) : a_values; - var unknown; - if (shouldBeAnObject(this, values)) { - for (var name_1 in values) { - var spec = _attributes[name_1]; - if (spec) { - if (spec.doUpdate(values[name_1], this, options, nested)) { - changes.push(name_1); - } - } - else { - unknown || (unknown = []); - unknown.push("'" + name_1 + "'"); - } - } - if (unknown) { - } - } - if (changes.length && markAsDirty(this, options)) { - return new RecordTransaction(this, isRoot, nested, changes); - } - for (var _i = 0, nested_1 = nested; _i < nested_1.length; _i++) { - var pendingTransaction = nested_1[_i]; - pendingTransaction.commit(this); - } - isRoot && commit(this); - } -}; -export function constructorsMixin(attrDefs) { - var attrs = Object.keys(attrDefs); - var AttributesCopy = new Function('values', "\n " + attrs.map(function (attr) { return "\n this." + attr + " = values." + attr + ";\n "; }).join('') + "\n "); - AttributesCopy.prototype = Object.prototype; - var Attributes = new Function('record', 'values', 'options', "\n var _attrs = record._attributes;\n\n " + attrs.map(function (attr) { return "\n this." + attr + " = _attrs." + attr + ".doInit( values." + attr + ", record, options );\n "; }).join('') + "\n "); - Attributes.prototype = Object.prototype; - return { Attributes: Attributes, AttributesCopy: AttributesCopy }; -} -export function shouldBeAnObject(record, values) { - if (values && values.constructor === Object) - return true; - record._log('warn', 'update with non-object is ignored!', { values: values }); - return false; -} -var RecordTransaction = (function () { - function RecordTransaction(object, isRoot, nested, changes) { - this.object = object; - this.isRoot = isRoot; - this.nested = nested; - this.changes = changes; - } - RecordTransaction.prototype.commit = function (initiator) { - var _a = this, nested = _a.nested, object = _a.object, changes = _a.changes; - for (var _i = 0, nested_2 = nested; _i < nested_2.length; _i++) { - var transaction = nested_2[_i]; - transaction.commit(object); - } - var attributes = object.attributes, _isDirty = object._isDirty; - for (var _b = 0, changes_1 = changes; _b < changes_1.length; _b++) { - var key = changes_1[_b]; - trigger3(object, 'change:' + key, object, attributes[key], _isDirty); - } - this.isRoot && commit(object, initiator); - }; - return RecordTransaction; -}()); -export { RecordTransaction }; -//# sourceMappingURL=updates.js.map \ No newline at end of file diff --git a/lib/type-r/record/attributes/updates.js.map b/lib/type-r/record/attributes/updates.js.map deleted file mode 100644 index 36937e2..0000000 --- a/lib/type-r/record/attributes/updates.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"updates.js","sourceRoot":"","sources":["../../../../src/type-r/record/attributes/updates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyD,cAAc,EAAE,MAAM,oBAAoB,C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E,SAAS,GAAG,GAAG,EAAE,MAAM,EAAE,UAAU,CAAE,GAAG,CAAE,EAAE,QAAQ,CAAE,CAAC;SAC5E;QAED,IAAI,CAAC,MAAM,IAAI,MAAM,CAAE,MAAM,EAAE,SAAS,CAAE,CAAC;IAC/C,CAAC;IACL,wBAAC;AAAD,CAAC,AAzBD,IAyBC"} \ No newline at end of file diff --git a/lib/type-r/record/index.d.ts b/lib/type-r/record/index.d.ts deleted file mode 100644 index 33f3a15..0000000 --- a/lib/type-r/record/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { Record } from './record'; -export * from './attributes'; -export { Record }; -export declare function attr(proto: object, attrName: string): void; -export declare function attr(spec: any): PropertyDecorator; -export declare function prop(spec: any): any; diff --git a/lib/type-r/record/index.js b/lib/type-r/record/index.js deleted file mode 100644 index 84b886e..0000000 --- a/lib/type-r/record/index.js +++ /dev/null @@ -1,71 +0,0 @@ -import * as tslib_1 from "tslib"; -import { Record } from './record'; -import { tools, predefine } from '../object-plus'; -import compile, { ChainableAttributeSpec } from './attributes'; -import { Transactional } from '../transactions'; -import { createSharedTypeSpec, AggregatedType, SharedType } from './attributes'; -export * from './attributes'; -export { Record }; -var assign = tools.assign, defaults = tools.defaults, omit = tools.omit, getBaseClass = tools.getBaseClass; -Record.onExtend = function (BaseClass) { - Transactional.onExtend.call(this, BaseClass); - var Class = this; - var DefaultCollection = (function (_super) { - tslib_1.__extends(DefaultCollection, _super); - function DefaultCollection() { - return _super !== null && _super.apply(this, arguments) || this; - } - DefaultCollection.model = Class; - DefaultCollection = tslib_1.__decorate([ - predefine - ], DefaultCollection); - return DefaultCollection; - }(BaseClass.Collection)); - this.DefaultCollection = DefaultCollection; - if (Class.Collection === BaseClass.Collection) { - this.Collection = DefaultCollection; - } - createSharedTypeSpec(this, SharedType); -}; -Record.onDefine = function (definition, BaseClass) { - var baseProto = BaseClass.prototype; - var _a = compile(this.attributes = getAttributes(definition), baseProto._attributes), properties = _a.properties, _localEvents = _a._localEvents, dynamicMixin = tslib_1.__rest(_a, ["properties", "_localEvents"]); - assign(this.prototype, dynamicMixin); - definition.properties = defaults(definition.properties || {}, properties); - definition._localEvents = _localEvents; - Transactional.onDefine.call(this, definition, BaseClass); - this.DefaultCollection.define(definition.collection || {}); - this.Collection = definition.Collection; - this.Collection.prototype.model = this; - if (definition.endpoint) - this.Collection.prototype._endpoint = definition.endpoint; -}; -Record._attribute = AggregatedType; -createSharedTypeSpec(Record, SharedType); -function getAttributes(_a) { - var defaults = _a.defaults, attributes = _a.attributes, idAttribute = _a.idAttribute; - var definition = attributes || defaults || {}; - if (idAttribute && !(idAttribute in definition)) { - definition[idAttribute] = void 0; - } - return definition; -} -export function attr(proto, attrName) { - if (attrName) { - if (typeof Reflect !== 'undefined' && Reflect.getMetadata) { - Reflect - .getMetadata("design:type", proto, attrName) - .asProp(proto, attrName); - } - else { - proto._log('error', 'Add import "reflect-metadata"; as the first line of your app.'); - } - } - else { - return ChainableAttributeSpec.from(proto).asProp; - } -} -export function prop(spec) { - return spec.asProp; -} -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/lib/type-r/record/index.js.map b/lib/type-r/record/index.js.map deleted file mode 100644 index 6c07e74..0000000 --- a/lib/type-r/record/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/type-r/record/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAoB,MAAM,UAAU,CAAA;AACnD,OAAO,EAAW,KAAK,EAAE,SAAS,EAAuB,MAAM,gBAAgB,CAAA;AAC/E,OAAO,OAAO,EAAE,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAA;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE/C,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAA0C,UAAU,EAAE,MAAM,cAAc,CAAA;AAEvH,cAAc,cAAc,CAAA;AAC5B,OAAO,EAAE,MAAM,EAAE,CAAA;A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;IACxC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,KAAK,GAAG,IAAI,CAAC;IAEvC,IAAI,UAAU,CAAC,QAAQ;QAAG,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,SAAS,GAAG,UAAU,CAAC,QAAQ,CAAC;AACxF,CAAC,CAAA;AAED,MAAM,CAAC,UAAU,GAAG,cAAc,CAAC;AACnC,oBAAoB,CAAE,MAAM,EAAE,UAAU,CAAE,CAAC;AAE3C,SAAS,aAAa,CAAC,EAAwD;QAAtD,sBAAQ,EAAE,0BAAU,EAAE,4BAAW;IACtD,IAAM,UAAU,GAAG,UAAU,IAAI,QAAQ,IAAI,EAAE,CAAC;IAGhD,IAAI,WAAW,IAAI,CAAC,CAAE,WAAW,IAAI,UAAU,CAAE,EAAE;QAC/C,UAAU,CAAE,WAAW,CAAE,GAAG,KAAK,CAAC,CAAC;KACtC;IAED,OAAO,UAAU,CAAC;AACtB,CAAC;AAMD,MAAM,UAAU,IAAI,CAAE,KAAK,EAAE,QAAkB;IAC3C,IAAI,QAAQ,EAAE;QAEV,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,WAAW,EAAE;YACvD,OAAO;iBACF,WAAW,CAAE,aAAa,EAAE,KAAK,EAAE,QAAQ,CAAE;iBAC7C,MAAM,CAAE,KAAK,EAAE,QAAQ,CAAE,CAAC;SAClC;aACG;YACA,KAAK,CAAC,IAAI,CAAE,OAAO,EAAE,+DAA+D,CAAE,CAAC;SAC1F;KACJ;SACG;QACA,OAAO,sBAAsB,CAAC,IAAI,CAAE,KAAK,CAAE,CAAC,MAAM,CAAC;KACtD;AACL,CAAC;AAED,MAAM,UAAU,IAAI,CAAE,IAAI;IACtB,OAAO,IAAI,CAAC,MAAM,CAAC;AACvB,CAAC"} \ No newline at end of file diff --git a/lib/type-r/record/io-mixin.d.ts b/lib/type-r/record/io-mixin.d.ts deleted file mode 100644 index 5bf8351..0000000 --- a/lib/type-r/record/io-mixin.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { IOOptions, IOEndpoint, IOPromise, IONode } from '../io-tools'; -export interface IORecord extends IONode { - getEndpoint(): IOEndpoint; - save(options?: IOOptions): IOPromise; - fetch(options?: IOOptions): IOPromise; - destroy(options?: IOOptions): IOPromise; - toJSON(options?: object): any; - isNew(): boolean; - id: string | number; - set(json: object, options: object): any; -} -export declare const IORecordMixin: { - save(this: IORecord, options?: IOOptions): IOPromise; - fetch(options?: IOOptions): IOPromise; - destroy(options?: IOOptions): IOPromise; -}; diff --git a/lib/type-r/record/io-mixin.js b/lib/type-r/record/io-mixin.js deleted file mode 100644 index 513fc83..0000000 --- a/lib/type-r/record/io-mixin.js +++ /dev/null @@ -1,34 +0,0 @@ -import * as tslib_1 from "tslib"; -import { startIO } from '../io-tools'; -export var IORecordMixin = { - save: function (options) { - var _this = this; - if (options === void 0) { options = {}; } - var endpoint = this.getEndpoint(), json = this.toJSON(options); - return startIO(this, this.isNew() ? - endpoint.create(json, options, this) : - endpoint.update(this.id, json, options, this), options, function (update) { - _this.set(update, tslib_1.__assign({ parse: true }, options)); - }); - }, - fetch: function (options) { - var _this = this; - if (options === void 0) { options = {}; } - return startIO(this, this.getEndpoint().read(this.id, options, this), options, function (json) { return _this.set(json, tslib_1.__assign({ parse: true }, options)); }); - }, - destroy: function (options) { - var _this = this; - if (options === void 0) { options = {}; } - return startIO(this, this.getEndpoint().destroy(this.id, options, this), options, function () { - var collection = _this.collection; - if (collection) { - collection.remove(_this, options); - } - else { - _this.dispose(); - } - return _this; - }); - } -}; -//# sourceMappingURL=io-mixin.js.map \ No newline at end of file diff --git a/lib/type-r/record/io-mixin.js.map b/lib/type-r/record/io-mixin.js.map deleted file mode 100644 index d9f0a9d..0000000 --- a/lib/type-r/record/io-mixin.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"io-mixin.js","sourceRoot":"","sources":["../../../src/type-r/record/io-mixin.ts"],"names":[],"mappings":";AAAA,OAAO,EAAoB,OAAO,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EAAE;gBACZ,UAAU,CAAC,MAAM,CAAE,KAAI,EAAE,OAAO,CAAE,CAAC;aACtC;iBACG;gBACA,KAAI,CAAC,OAAO,EAAE,CAAC;aAClB;YAED,OAAO,KAAI,CAAC;QAChB,CAAC,CACJ,CAAA;IACL,CAAC;CACJ,CAAA"} \ No newline at end of file diff --git a/lib/type-r/record/record.d.ts b/lib/type-r/record/record.d.ts deleted file mode 100644 index f59ea42..0000000 --- a/lib/type-r/record/record.d.ts +++ /dev/null @@ -1,73 +0,0 @@ -import { tools } from '../object-plus'; -import { CloneOptions, Transactional, TransactionalDefinition, Transaction, TransactionOptions, Owner } from '../transactions'; -import { ChildrenErrors } from '../validation'; -import { Collection } from '../collection'; -import { AnyType, AttributesValues, AttributesContainer, AttributesConstructor, AttributesCopyConstructor } from './attributes'; -import { IORecord } from './io-mixin'; -import { IOPromise, IOEndpoint } from '../io-tools'; -export interface ConstructorOptions extends TransactionOptions { - clone?: boolean; -} -export interface RecordDefinition extends TransactionalDefinition { - idAttribute?: string; - attributes?: AttributesValues; - collection?: object; - Collection?: typeof Transactional; -} -export declare class Record extends Transactional implements IORecord, AttributesContainer { - static onDefine(definition: any, BaseClass: any): void; - static Collection: typeof Collection; - static DefaultCollection: typeof Collection; - static from: (collectionReference: any) => any; - static defaults(attrs: AttributesValues): typeof Record; - static attributes: AttributesValues; - _endpoints: { - [name: string]: IOEndpoint; - }; - save(options?: object): IOPromise; - destroy(options?: object): IOPromise; - _previousAttributes: {}; - previousAttributes(): AttributesValues; - attributes: AttributesValues; - readonly __inner_state__: AttributesValues; - _changedAttributes: AttributesValues; - readonly changed: AttributesValues; - changedAttributes(diff?: {}): boolean | {}; - hasChanged(key?: string): boolean; - previous(key: string): any; - isNew(): boolean; - has(key: string): boolean; - unset(key: string, options?: any): any; - clear(options?: any): this; - getOwner(): Owner; - idAttribute: string; - id: string | number; - _attributes: { - [key: string]: AnyType; - }; - _attributesArray: AnyType[]; - Attributes: AttributesConstructor; - AttributesCopy: AttributesCopyConstructor; - forEachAttr(attrs: {}, iteratee: (value: any, key?: string, spec?: AnyType) => void): void; - each(iteratee: (value?: any, key?: string) => void, context?: any): void; - keys(): string[]; - values(): any[]; - defaults(values?: {}): {}; - constructor(a_values?: {}, a_options?: ConstructorOptions); - initialize(values?: any, options?: any): void; - clone(options?: CloneOptions): this; - deepClone(): this; - _validateNested(errors: ChildrenErrors): number; - get(key: string): any; - toJSON(options?: object): any; - parse(data: any, options?: TransactionOptions): any; - _parse(data: any): any; - deepSet(name: string, value: any, options?: any): this; - readonly collection: any; - dispose(): void; - _log(level: tools.LogLevel, text: string, props: object): void; - getClassName(): string; - _createTransaction(values: object, options: TransactionOptions): Transaction; - forceAttributeChange: (key: string, options: TransactionOptions) => void; - _onChildrenChange: (child: Transactional, options: TransactionOptions) => void; -} diff --git a/lib/type-r/record/record.js b/lib/type-r/record/record.js deleted file mode 100644 index e96e9b7..0000000 --- a/lib/type-r/record/record.js +++ /dev/null @@ -1,309 +0,0 @@ -import * as tslib_1 from "tslib"; -import { tools, definitions, mixinRules, define } from '../object-plus'; -import { Transactional } from '../transactions'; -import { AnyType, AggregatedType, setAttribute, UpdateRecordMixin } from './attributes'; -import { IORecordMixin } from './io-mixin'; -var assign = tools.assign, isEmpty = tools.isEmpty, log = tools.log; -var _cidCounter = 0; -var Record = (function (_super) { - tslib_1.__extends(Record, _super); - function Record(a_values, a_options) { - var _this = _super.call(this, _cidCounter++) || this; - _this.attributes = {}; - var options = a_options || {}, values = (options.parse ? _this.parse(a_values, options) : a_values) || {}; - if (log.level > 1) - typeCheck(_this, values); - _this._previousAttributes = _this.attributes = new _this.Attributes(_this, values, options); - _this.initialize(a_values, a_options); - if (_this._localEvents) - _this._localEvents.subscribe(_this, _this); - return _this; - } - Record_1 = Record; - Record.onDefine = function (definition, BaseClass) { }; - Record.defaults = function (attrs) { - return this.extend({ attributes: attrs }); - }; - Record.prototype.save = function (options) { throw new Error('Implemented by mixin'); }; - Record.prototype.destroy = function (options) { throw new Error('Implemented by mixin'); }; - Record.prototype.previousAttributes = function () { return new this.AttributesCopy(this._previousAttributes); }; - Object.defineProperty(Record.prototype, "__inner_state__", { - get: function () { return this.attributes; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Record.prototype, "changed", { - get: function () { - var changed = this._changedAttributes; - if (!changed) { - var prev = this._previousAttributes; - changed = {}; - var _a = this, _attributes = _a._attributes, attributes = _a.attributes; - for (var _i = 0, _b = this._attributesArray; _i < _b.length; _i++) { - var attr = _b[_i]; - var key = attr.name, value = attributes[key]; - if (attr.isChanged(value, prev[key])) { - changed[key] = value; - } - } - this._changedAttributes = changed; - } - return changed; - }, - enumerable: true, - configurable: true - }); - Record.prototype.changedAttributes = function (diff) { - if (!diff) - return this.hasChanged() ? assign({}, this.changed) : false; - var val, changed = false, old = this._transaction ? this._previousAttributes : this.attributes, attrSpecs = this._attributes; - for (var attr in diff) { - if (!attrSpecs[attr].isChanged(old[attr], (val = diff[attr]))) - continue; - (changed || (changed = {}))[attr] = val; - } - return changed; - }; - Record.prototype.hasChanged = function (key) { - var _previousAttributes = this._previousAttributes; - if (!_previousAttributes) - return false; - return key ? - this._attributes[key].isChanged(this.attributes[key], _previousAttributes[key]) : - !isEmpty(this.changed); - }; - Record.prototype.previous = function (key) { - if (key) { - var _previousAttributes = this._previousAttributes; - if (_previousAttributes) - return _previousAttributes[key]; - } - return null; - }; - Record.prototype.isNew = function () { - return this.id == null; - }; - Record.prototype.has = function (key) { - return this[key] != void 0; - }; - Record.prototype.unset = function (key, options) { - var _a; - var value = this[key]; - this.set((_a = {}, _a[key] = void 0, _a), tslib_1.__assign({ unset: true }, options)); - return value; - }; - Record.prototype.clear = function (options) { - var _this = this; - var nullify = options && options.nullify; - this.transaction(function () { - _this.forEachAttr(_this.attributes, function (value, key) { return _this[key] = nullify ? null : void 0; }); - }, options); - return this; - }; - Record.prototype.getOwner = function () { - var owner = this._owner; - return this._ownerKey ? owner : owner && owner._owner; - }; - Object.defineProperty(Record.prototype, "id", { - get: function () { return this.attributes[this.idAttribute]; }, - set: function (x) { setAttribute(this, this.idAttribute, x); }, - enumerable: true, - configurable: true - }); - Record.prototype.forEachAttr = function (attrs, iteratee) { - var _attributes = this._attributes; - var unknown; - for (var name_1 in attrs) { - var spec = _attributes[name_1]; - if (spec) { - iteratee(attrs[name_1], name_1, spec); - } - else { - unknown || (unknown = []); - unknown.push("'" + name_1 + "'"); - } - } - if (unknown) { - this._log('warn', "attributes " + unknown.join(', ') + " are not defined", { - attributes: attrs - }); - } - }; - Record.prototype.each = function (iteratee, context) { - var fun = context !== void 0 ? function (v, k) { return iteratee.call(context, v, k); } : iteratee, attributes = this.attributes; - for (var key in this.attributes) { - var value = attributes[key]; - if (value !== void 0) - fun(value, key); - } - }; - Record.prototype.keys = function () { - var keys = []; - this.each(function (value, key) { return value === void 0 || keys.push(key); }); - return keys; - }; - Record.prototype.values = function () { - return this.map(function (value) { return value; }); - }; - Record.prototype.defaults = function (values) { - if (values === void 0) { values = {}; } - var defaults = {}, _attributesArray = this._attributesArray; - for (var _i = 0, _attributesArray_1 = _attributesArray; _i < _attributesArray_1.length; _i++) { - var attr = _attributesArray_1[_i]; - var key = attr.name, value = values[key]; - defaults[key] = value === void 0 ? attr.defaultValue() : value; - } - return defaults; - }; - Record.prototype.initialize = function (values, options) { }; - Record.prototype.clone = function (options) { - if (options === void 0) { options = {}; } - var copy = new this.constructor(this.attributes, { clone: true }); - if (options.pinStore) - copy._defaultStore = this.getStore(); - return copy; - }; - Record.prototype.deepClone = function () { return this.clone(); }; - ; - Record.prototype._validateNested = function (errors) { - var _this = this; - var length = 0; - this.forEachAttr(this.attributes, function (value, name, attribute) { - var error = attribute.validate(_this, value, name); - if (error) { - errors[name] = error; - length++; - } - }); - return length; - }; - Record.prototype.get = function (key) { - return this[key]; - }; - Record.prototype.toJSON = function (options) { - var _this = this; - var json = {}; - this.forEachAttr(this.attributes, function (value, key, _a) { - var toJSON = _a.toJSON; - if (value !== void 0) { - var asJson = toJSON.call(_this, value, key, options); - if (asJson !== void 0) - json[key] = asJson; - } - }); - return json; - }; - Record.prototype.parse = function (data, options) { - return data; - }; - Record.prototype._parse = function (data) { return data; }; - Record.prototype.deepSet = function (name, value, options) { - var _this = this; - this.transaction(function () { - var _a; - var path = name.split('.'), l = path.length - 1, attr = path[l]; - var model = _this; - for (var i = 0; i < l; i++) { - var key = path[i]; - var next = model.get ? model.get(key) : model[key]; - if (!next) { - var attrSpecs = model._attributes; - if (attrSpecs) { - var newModel = attrSpecs[key].create(); - if (options && options.nullify && newModel._attributes) { - newModel.clear(options); - } - model[key] = next = newModel; - } - else - return; - } - model = next; - } - if (model.set) { - model.set((_a = {}, _a[attr] = value, _a), options); - } - else { - model[attr] = value; - } - }); - return this; - }; - Object.defineProperty(Record.prototype, "collection", { - get: function () { - return this._ownerKey ? null : this._owner; - }, - enumerable: true, - configurable: true - }); - Record.prototype.dispose = function () { - var _this = this; - if (this._disposed) - return; - this.forEachAttr(this.attributes, function (value, key, attribute) { - attribute.dispose(_this, value); - }); - _super.prototype.dispose.call(this); - }; - Record.prototype._log = function (level, text, props) { - tools.log(level, '[Record] ' + text, tslib_1.__assign({ 'Record': this, 'Attributes definition:': this._attributes }, props)); - }; - Record.prototype.getClassName = function () { - return _super.prototype.getClassName.call(this) || 'Record'; - }; - Record.prototype._createTransaction = function (values, options) { return void 0; }; - var Record_1; - Record = Record_1 = tslib_1.__decorate([ - define({ - cidPrefix: 'm', - _changeEventName: 'change', - idAttribute: 'id' - }), - definitions({ - defaults: mixinRules.merge, - attributes: mixinRules.merge, - collection: mixinRules.merge, - Collection: mixinRules.value, - idAttribute: mixinRules.protoValue - }) - ], Record); - return Record; -}(Transactional)); -export { Record }; -; -assign(Record.prototype, UpdateRecordMixin, IORecordMixin); -var BaseRecordAttributes = (function () { - function BaseRecordAttributes(record, x, options) { - this.id = x.id; - } - return BaseRecordAttributes; -}()); -Record.prototype.Attributes = BaseRecordAttributes; -var BaseRecordAttributesCopy = (function () { - function BaseRecordAttributesCopy(x) { - this.id = x.id; - } - return BaseRecordAttributesCopy; -}()); -Record.prototype.AttributesCopy = BaseRecordAttributesCopy; -var IdAttribute = AnyType.create({ value: void 0 }, 'id'); -Record.prototype._attributes = { id: IdAttribute }; -Record.prototype._attributesArray = [IdAttribute]; -Record._attribute = AggregatedType; -import { shouldBeAnObject } from './attributes'; -function typeCheck(record, values) { - if (shouldBeAnObject(record, values)) { - var _attributes = record._attributes; - var unknown = void 0; - for (var name_2 in values) { - if (!_attributes[name_2]) { - unknown || (unknown = []); - unknown.push("'" + name_2 + "'"); - } - } - if (unknown) { - record._log('warn', "undefined attributes " + unknown.join(', ') + " are ignored.", { values: values }); - } - } -} -//# sourceMappingURL=record.js.map \ No newline at end of file diff --git a/lib/type-r/record/record.js.map b/lib/type-r/record/record.js.map deleted file mode 100644 index 0091207..0000000 --- a/lib/type-r/record/record.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"record.js","sourceRoot":"","sources":["../../../src/type-r/record/record.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,KAAK,EAAsB,WAAW,EAAW,UAAU,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAEpG,OAAO,EAAgB,aAAa,EAAmE,MAAM,iBAAiB,CAAA;AAK9H,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,iBAAiB,EAEQ,MAAM,cAAc,CAAA;AAE7F,OAAO,EAAY,aAAa,EAAE,MAAM,YAAY,CAAA;AAG5C,IAAA,qBAAM,EAAE,uBAAO,EAAE,eAAG,CAAW;AAWvC,IAAI,WAAW,GAAY,CAAC,CAAC;AA6B7B;IAA4B,kCAAa;IAmOrC,gBAAa,QAAc,EAAE,SAA+B;QAA5D,YACI,kBAAO,WAAW,EAAE,CAAE,SAazB;QAZG,KAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QAErB,IAAM,OAAO,GAAG,SAAS,IAAI,EAAE,EACzB,MAAM,GAAG,CAAE,OAA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CAAC,SAAS,CAAC,gBAAgB,GAAG,CAAE,WAAW,CAAE,CAAC;AACpD,MAAM,CAAC,UAAU,GAAG,cAAc,CAAC;AAEnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAE/C,SAAS,SAAS,CAAE,MAAe,EAAE,MAAe;IAChD,IAAI,gBAAgB,CAAE,MAAM,EAAE,MAAM,CAAE,EAAE;QAC5B,IAAA,gCAAW,CAAY;QAC/B,IAAI,OAAO,SAAW,CAAC;QAEvB,KAAK,IAAI,MAAI,IAAI,MAAM,EAAE;YACrB,IAAI,CAAC,WAAW,CAAE,MAAI,CAAE,EAAE;gBACtB,OAAO,IAAI,CAAE,OAAO,GAAG,EAAE,CAAE,CAAC;gBAC5B,OAAO,CAAC,IAAI,CAAE,MAAK,MAAI,MAAI,CAAE,CAAC;aACjC;SACJ;QAED,IAAI,OAAO,EAAE;YACT,MAAM,CAAC,IAAI,CAAE,MAAM,EAAE,0BAAyB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAe,EAAE,EAAE,MAAM,QAAA,EAAE,CAAE,CAAC;SACjG;KACJ;AACL,CAAC"} \ No newline at end of file diff --git a/lib/type-r/relations/commons.d.ts b/lib/type-r/relations/commons.d.ts deleted file mode 100644 index d084b9f..0000000 --- a/lib/type-r/relations/commons.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { Collection } from '../collection'; -import { Record } from '../record'; -export declare type CollectionReference = (() => Collection) | Collection | string; -export declare function parseReference(collectionRef: CollectionReference): (root: Record) => Collection; diff --git a/lib/type-r/relations/commons.js b/lib/type-r/relations/commons.js deleted file mode 100644 index 98a9ef8..0000000 --- a/lib/type-r/relations/commons.js +++ /dev/null @@ -1,13 +0,0 @@ -import { CompiledReference } from '../traversable'; -export function parseReference(collectionRef) { - switch (typeof collectionRef) { - case 'function': - return function (root) { return collectionRef.call(root); }; - case 'object': - return function () { return collectionRef; }; - case 'string': - var resolve = new CompiledReference(collectionRef).resolve; - return resolve; - } -} -//# sourceMappingURL=commons.js.map \ No newline at end of file diff --git a/lib/type-r/relations/commons.js.map b/lib/type-r/relations/commons.js.map deleted file mode 100644 index b2349ff..0000000 --- a/lib/type-r/relations/commons.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"commons.js","sourceRoot":"","sources":["../../../src/type-r/relations/commons.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAKlD,MAAM,UAAU,cAAc,CAAE,aAAmC;IAC/D,QAAQ,OAAO,aAAa,EAAE;QAC1B,KAAK,UAAU;YACX,OAAO,UAAA,IAAI,IAAI,OAAM,aAAc,CAAC,IAAI,CAAE,IAAI,CAAE,EAAjC,CAAiC,CAAC;QACrD,KAAK,QAAQ;YACT,OAAO,cAAM,OAAY,aAAa,EAAzB,CAAyB,CAAC;QAC3C,KAAK,QAAQ;YACD,IAAA,sDAAO,CAAoD;YACnE,OAAO,OAAO,CAAC;KACtB;AACL,CAAC"} \ No newline at end of file diff --git a/lib/type-r/relations/from.d.ts b/lib/type-r/relations/from.d.ts deleted file mode 100644 index cb0ff5c..0000000 --- a/lib/type-r/relations/from.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/lib/type-r/relations/from.js b/lib/type-r/relations/from.js deleted file mode 100644 index 81f3d21..0000000 --- a/lib/type-r/relations/from.js +++ /dev/null @@ -1,44 +0,0 @@ -import * as tslib_1 from "tslib"; -import { AnyType } from '../record'; -import { parseReference } from './commons'; -import { Record } from '../record'; -import { ChainableAttributeSpec } from '../record'; -var RecordRefType = (function (_super) { - tslib_1.__extends(RecordRefType, _super); - function RecordRefType() { - return _super !== null && _super.apply(this, arguments) || this; - } - RecordRefType.prototype.toJSON = function (value) { - return value && typeof value === 'object' ? value.id : value; - }; - RecordRefType.prototype.clone = function (value) { - return value && typeof value === 'object' ? value.id : value; - }; - RecordRefType.prototype.isChanged = function (a, b) { - var aId = a && (a.id == null ? a : a.id), bId = b && (b.id == null ? b : b.id); - return aId !== bId; - }; - RecordRefType.prototype.validate = function (model, value, name) { }; - return RecordRefType; -}(AnyType)); -Record.from = function from(masterCollection) { - var getMasterCollection = parseReference(masterCollection); - var typeSpec = new ChainableAttributeSpec({ - value: null, - _attribute: RecordRefType - }); - return typeSpec - .get(function (objOrId, name) { - if (typeof objOrId === 'object') - return objOrId; - var collection = getMasterCollection(this); - var record = null; - if (collection && collection.length) { - record = collection.get(objOrId) || null; - this.attributes[name] = record; - record && this._attributes[name].handleChange(record, null, this, {}); - } - return record; - }); -}; -//# sourceMappingURL=from.js.map \ No newline at end of file diff --git a/lib/type-r/relations/from.js.map b/lib/type-r/relations/from.js.map deleted file mode 100644 index 9826c37..0000000 --- a/lib/type-r/relations/from.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"from.js","sourceRoot":"","sources":["../../../src/type-r/relations/from.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAoB,MAAM,WAAW,CAAA;AACrD,OAAO,EAAE,cAAc,EAAuB,MAAM,WAAW,CAAA;AAE/D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAElC,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAA;AAelD;IAA4B,yCAAO;IAAnC;;IAqBA,CAAC;IAnBG,8BAAM,GAAN,UAAQ,KAAsB;QAC1B,OAAO,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;IACjE,CAAC;IAGD,6BAAK,GAAL,UAAO,KAAsB;QACzB,OAAO,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;IACjE,CAAC;IAGD,iCAAS,GAAT,UAAW,CAAkB,EAAE,CAAkB;QAC7C,IAAI,GAAG,GAAG,CAAC,IAAI,CAAW,CAAE,CAA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newline at end of file diff --git a/lib/type-r/relations/index.d.ts b/lib/type-r/relations/index.d.ts deleted file mode 100644 index 343753e..0000000 --- a/lib/type-r/relations/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import './from'; -import './subsetOf'; -export * from './store'; diff --git a/lib/type-r/relations/index.js b/lib/type-r/relations/index.js deleted file mode 100644 index acc8e13..0000000 --- a/lib/type-r/relations/index.js +++ /dev/null @@ -1,4 +0,0 @@ -import './from'; -import './subsetOf'; -export * from './store'; -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/lib/type-r/relations/index.js.map b/lib/type-r/relations/index.js.map deleted file mode 100644 index 5981e4b..0000000 --- a/lib/type-r/relations/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/type-r/relations/index.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,CAAA;AACf,OAAO,YAAY,CAAA;AAEnB,cAAc,SAAS,CAAA"} \ No newline at end of file diff --git a/lib/type-r/relations/store.d.ts b/lib/type-r/relations/store.d.ts deleted file mode 100644 index 5f854c2..0000000 --- a/lib/type-r/relations/store.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { Record } from '../record'; -export declare class Store extends Record { - getStore(): Store; - get(name: string): any; - static global: Store; -} diff --git a/lib/type-r/relations/store.js b/lib/type-r/relations/store.js deleted file mode 100644 index 916cce1..0000000 --- a/lib/type-r/relations/store.js +++ /dev/null @@ -1,32 +0,0 @@ -import * as tslib_1 from "tslib"; -import { Record } from '../record'; -import { Transactional } from '../transactions'; -var _store = null; -var Store = (function (_super) { - tslib_1.__extends(Store, _super); - function Store() { - return _super !== null && _super.apply(this, arguments) || this; - } - Store.prototype.getStore = function () { return this; }; - Store.prototype.get = function (name) { - var local = this[name]; - if (local || this === this._defaultStore) - return local; - return this._owner ? this._owner.get(name) : this._defaultStore.get(name); - }; - Object.defineProperty(Store, "global", { - get: function () { return _store; }, - set: function (store) { - if (_store) { - _store.dispose(); - } - Transactional.prototype._defaultStore = _store = store; - }, - enumerable: true, - configurable: true - }); - return Store; -}(Record)); -export { Store }; -Store.global = new Store(); -//# sourceMappingURL=store.js.map \ No newline at end of file diff --git a/lib/type-r/relations/store.js.map b/lib/type-r/relations/store.js.map deleted file mode 100644 index b5ac480..0000000 --- a/lib/type-r/relations/store.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"store.js","sourceRoot":"","sources":["../../../src/type-r/relations/store.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAG/C,IAAI,MAAM,GAAW,IAAI,CAAC;AAE1B;IAA2B,iCAAM;IAAjC;;IAuBA,CAAC;IAtBG,wBAAQ,GAAR,cAAqB,OAAO,IAAI,CAAC,CAAC,CAAC;IAGnC,mBAAG,GAAH,UAAK,IAAa;QAEd,IAAI,KAAK,GAAG,IAAI,CAAE,IAAI,CAAE,CAAC;QAGzB,IAAI,KAAK,IAAI,IAAI,KAAK,IAAI,CAAC,aAAa;YAAG,OAAO,KAAK,CAAC;QAGxD,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAE,IAAI,CAAE,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAE,IAAI,CAAE,CAAC;IAClF,CAAC;IAED,sBAAW,eAAM;aAAjB,cAAqB,OAAO,MAAM,CAAC,CAAC,CAAC;aACrC,UAAmB,KAAa;YAC5B,IAAI,MAAM,EAAE;gBACV,MAAM,CAAC,OAAO,EAAE,CAAC;aAClB;YAED,aAAa,CAAC,SAAS,CAAC,aAAa,GAAG,MAAM,GAAG,KAAK,CAAC;QAC3D,CAAC;;;OAPoC;IAQzC,YAAC;AAAD,CAAC,AAvBD,CAA2B,MAAM,GAuBhC;;AAED,KAAK,CAAC,MAAM,GAAG,IAAI,KAAK,EAAE,CAAC"} \ No newline at end of file diff --git a/lib/type-r/relations/subsetOf.d.ts b/lib/type-r/relations/subsetOf.d.ts deleted file mode 100644 index cb0ff5c..0000000 --- a/lib/type-r/relations/subsetOf.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/lib/type-r/relations/subsetOf.js b/lib/type-r/relations/subsetOf.js deleted file mode 100644 index 1c6f15b..0000000 --- a/lib/type-r/relations/subsetOf.js +++ /dev/null @@ -1,144 +0,0 @@ -import * as tslib_1 from "tslib"; -import { Collection } from '../collection'; -import { tools, define } from '../object-plus'; -import { parseReference } from './commons'; -import { ChainableAttributeSpec } from '../record'; -import { ItemsBehavior, transactionApi } from '../transactions'; -var fastDefaults = tools.fastDefaults; -Collection.subsetOf = function subsetOf(masterCollection) { - var SubsetOf = this._SubsetOf || (this._SubsetOf = defineSubsetCollection(this)), getMasterCollection = parseReference(masterCollection), typeSpec = new ChainableAttributeSpec({ - type: SubsetOf - }); - return typeSpec.get(function (refs) { - !refs || refs.resolvedWith || refs.resolve(getMasterCollection(this)); - return refs; - }); -}; -var subsetOfBehavior = ItemsBehavior.share | ItemsBehavior.persistent; -function defineSubsetCollection(CollectionConstructor) { - var SubsetOfCollection = (function (_super) { - tslib_1.__extends(SubsetOfCollection, _super); - function SubsetOfCollection(recordsOrIds, options) { - var _this = _super.call(this, [], options, subsetOfBehavior) || this; - _this.resolvedWith = null; - _this.refs = toArray(recordsOrIds); - return _this; - } - Object.defineProperty(SubsetOfCollection.prototype, "__inner_state__", { - get: function () { return this.refs || this.models; }, - enumerable: true, - configurable: true - }); - SubsetOfCollection.prototype.add = function (a_elements, options) { - if (options === void 0) { options = {}; } - var resolvedWith = this.resolvedWith, toAdd = toArray(a_elements); - if (resolvedWith) { - return _super.prototype.add.call(this, resolveRefs(resolvedWith, toAdd), options); - } - else { - if (toAdd.length) { - var isRoot = transactionApi.begin(this); - this.refs = this.refs ? this.refs.concat(toAdd) : toAdd.slice(); - transactionApi.markAsDirty(this, options); - isRoot && transactionApi.commit(this); - } - } - }; - SubsetOfCollection.prototype.reset = function (a_elements, options) { - if (options === void 0) { options = {}; } - var resolvedWith = this.resolvedWith, elements = toArray(a_elements); - return resolvedWith ? - _super.prototype.reset.call(this, resolveRefs(resolvedWith, elements), options) : - delaySet(this, elements, options) || []; - }; - SubsetOfCollection.prototype._createTransaction = function (a_elements, options) { - var resolvedWith = this.resolvedWith, elements = toArray(a_elements); - return resolvedWith ? - _super.prototype._createTransaction.call(this, resolveRefs(resolvedWith, elements), options) : - delaySet(this, elements, options); - }; - SubsetOfCollection.prototype.toJSON = function () { - return this.refs ? - this.refs.map(function (objOrId) { return objOrId.id || objOrId; }) : - this.models.map(function (model) { return model.id; }); - }; - SubsetOfCollection.prototype._validateNested = function () { return 0; }; - Object.defineProperty(SubsetOfCollection.prototype, "length", { - get: function () { - return this.models.length || (this.refs ? this.refs.length : 0); - }, - enumerable: true, - configurable: true - }); - SubsetOfCollection.prototype.clone = function (owner) { - var Ctor = this.constructor, copy = new Ctor([], { - model: this.model, - comparator: this.comparator - }); - if (this.resolvedWith) { - copy.resolvedWith = this.resolvedWith; - copy.refs = null; - copy.reset(this.models, { silent: true }); - } - else { - copy.refs = this.refs.slice(); - } - return copy; - }; - SubsetOfCollection.prototype.parse = function (raw) { - return raw; - }; - SubsetOfCollection.prototype.resolve = function (collection) { - if (collection && collection.length) { - this.resolvedWith = collection; - if (this.refs) { - this.reset(this.refs, { silent: true }); - this.refs = null; - } - } - return this; - }; - SubsetOfCollection.prototype.getModelIds = function () { return this.toJSON(); }; - SubsetOfCollection.prototype.toggle = function (modelOrId, val) { - return _super.prototype.toggle.call(this, this.resolvedWith.get(modelOrId), val); - }; - SubsetOfCollection.prototype.addAll = function () { - if (this.resolvedWith) { - this.set(this.resolvedWith.models); - return this.models; - } - throw new Error("Cannot add elemens because the subset collection is not resolved yet."); - }; - SubsetOfCollection.prototype.toggleAll = function () { - return this.length ? this.reset() : this.addAll(); - }; - SubsetOfCollection = tslib_1.__decorate([ - define - ], SubsetOfCollection); - return SubsetOfCollection; - }(CollectionConstructor)); - SubsetOfCollection.prototype._itemEvents = void 0; - return SubsetOfCollection; -} -function resolveRefs(master, elements) { - var records = []; - for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { - var el = elements_1[_i]; - var record = master.get(el); - if (record) - records.push(record); - } - return records; -} -function delaySet(collection, elements, options) { - if (tools.notEqual(collection.refs, elements)) { - var isRoot = transactionApi.begin(collection); - collection.refs = elements.slice(); - transactionApi.markAsDirty(collection, options); - isRoot && transactionApi.commit(collection); - } -} -function toArray(elements) { - return elements ? (Array.isArray(elements) ? elements : [elements]) : []; -} -//# sourceMappingURL=subsetOf.js.map \ No newline at end of file diff --git a/lib/type-r/relations/subsetOf.js.map b/lib/type-r/relations/subsetOf.js.map deleted file mode 100644 index 2b164d9..0000000 --- a/lib/type-r/relations/subsetOf.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"subsetOf.js","sourceRoot":"","sources":["../../../src/type-r/relations/subsetOf.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAqB,MAAM,eAAe,CAAA;AAC7D,OAAO,EAAE,KAAK,EAAa,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAEzD,OAAO,EAAE,cAAc,EAAuB,MAAM,WAAW,CAAA;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAA;AAClD,OAAO,EAAiB,aAAa,EAAsB,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAE1F,IAAA,iCAAY,CAAW;AAI/B,UAAU,CAAC,QAAQ,GAAG,SAAS,QAAQ,CAAE,gBAAsC;IAC3E,IAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,IAAI,CAAE,IAAI,CAAC,SAAS,GAAG,sBAAsB,CAAE,IAAI,CAAE,CAAE,EAClF,mBAAmB,GAAG,cAAc,CAAE,gBAAgB,CAAE,EACxD,QAAQ,GAAG,IAAI,sBAAsB,CAAC;QAClC,IAA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AE;QAC7C,IAAM,MAAM,GAAG,cAAc,CAAC,KAAK,CAAE,UAAU,CAAE,CAAC;QAGlD,UAAU,CAAC,IAAI,GAAG,QAAQ,CAAC,KAAK,EAAE,CAAC;QAEnC,cAAc,CAAC,WAAW,CAAE,UAAU,EAAE,OAAO,CAAE,CAAC;QAGlD,MAAM,IAAI,cAAc,CAAC,MAAM,CAAE,UAAU,CAAE,CAAC;KACjD;AACL,CAAC;AAED,SAAS,OAAO,CAAE,QAAQ;IACtB,OAAO,QAAQ,CAAC,CAAC,CAAC,CACd,KAAK,CAAC,OAAO,CAAE,QAAQ,CAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAE,QAAQ,CAAE,CACtD,CAAC,CAAC,CAAC,EAAE,CAAC;AACX,CAAC"} \ No newline at end of file diff --git a/lib/type-r/transactions.d.ts b/lib/type-r/transactions.d.ts deleted file mode 100644 index ebfc800..0000000 --- a/lib/type-r/transactions.d.ts +++ /dev/null @@ -1,115 +0,0 @@ -import { Messenger, CallbacksByEvents, MessengersByCid, MixinsState, MessengerDefinition, eventsApi } from './object-plus'; -import { ValidationError, Validatable, ChildrenErrors } from './validation'; -import { Traversable } from './traversable'; -import { IOEndpoint, IOPromise, IONode } from './io-tools'; -export interface TransactionalDefinition extends MessengerDefinition { - endpoint?: IOEndpoint; -} -export declare enum ItemsBehavior { - share = 1, - listen = 2, - persistent = 4 -} -export declare abstract class Transactional implements Messenger, IONode, Validatable, Traversable { - static endpoint: IOEndpoint; - static __super__: object; - static mixins: MixinsState; - static define: (definition?: TransactionalDefinition, statics?: object) => typeof Transactional; - static extend: (definition?: T, statics?: object) => any; - static onDefine(definitions: TransactionalDefinition, BaseClass: typeof Transactional): void; - static onExtend(BaseClass: typeof Transactional): void; - static create(a: any, b?: any): Transactional; - on: (events: string | CallbacksByEvents, callback: any, context?: any) => this; - once: (events: string | CallbacksByEvents, callback: any, context?: any) => this; - off: (events?: string | CallbacksByEvents, callback?: any, context?: any) => this; - trigger: (name: string, a?: any, b?: any, c?: any, d?: any, e?: any) => this; - stopListening: (source?: Messenger, a?: string | CallbacksByEvents, b?: Function) => this; - listenTo: (source: Messenger, a: string | CallbacksByEvents, b?: Function) => this; - listenToOnce: (source: Messenger, a: string | CallbacksByEvents, b?: Function) => this; - _disposed: boolean; - readonly __inner_state__: any; - _shared?: number; - dispose(): void; - initialize(): void; - _events: eventsApi.HandlersByEvent; - _listeningTo: MessengersByCid; - _localEvents: eventsApi.EventMap; - cid: string; - cidPrefix: string; - static shared: any; - _changeToken: {}; - _transaction: boolean; - _isDirty: TransactionOptions; - _owner: Owner; - _ownerKey: string; - _changeEventName: string; - onChanges(handler: Function, target?: Messenger): void; - offChanges(handler?: Function, target?: Messenger): void; - listenToChanges(target: Transactional, handler: any): void; - constructor(cid: string | number); - abstract clone(options?: CloneOptions): this; - transaction(fun: (self: this) => void, options?: TransactionOptions): void; - updateEach(iteratee: (val: any, key: string | number) => void, options?: TransactionOptions): void; - set(values: any, options?: TransactionOptions): this; - assignFrom(source: Transactional | Object): this; - abstract _createTransaction(values: any, options?: TransactionOptions): Transaction | void; - parse(data: any, options?: TransactionOptions): any; - abstract toJSON(options?: object): {}; - abstract get(key: string): any; - deepGet(reference: string): any; - getOwner(): Owner; - _defaultStore: Transactional; - getStore(): Transactional; - abstract each(iteratee: (val: any, key: string | number) => void, context?: any): any; - map(iteratee: (val: any, key: string | number) => T, context?: any): T[]; - _endpoint: IOEndpoint; - _ioPromise: IOPromise; - hasPendingIO(): IOPromise; - fetch(options?: object): IOPromise; - getEndpoint(): IOEndpoint; - mapObject(iteratee: (val: any, key: string | number) => T, context?: any): { - [key: string]: T; - }; - _validationError: ValidationError; - readonly validationError: ValidationError; - abstract _validateNested(errors: ChildrenErrors): number; - validate(obj?: Transactional): any; - getValidationError(key: string): any; - deepValidationError(reference: string): any; - eachValidationError(iteratee: (error: any, key: string, object: Transactional) => void): void; - isValid(key: string): boolean; - valueOf(): Object; - toString(): string; - getClassName(): string; - abstract _log(level: string, text: string, value: any): void; -} -export interface CloneOptions { - pinStore?: boolean; -} -export interface Owner extends Traversable, Messenger { - _onChildrenChange(child: Transactional, options: TransactionOptions): void; - getOwner(): Owner; - getStore(): Transactional; -} -export interface Transaction { - object: Transactional; - commit(initiator?: Transactional): any; -} -export interface TransactionOptions { - parse?: boolean; - silent?: boolean; - merge?: boolean; - remove?: boolean; - reset?: boolean; - unset?: boolean; - validate?: boolean; - ioUpdate?: boolean; - upsert?: boolean; -} -export declare const transactionApi: { - begin(object: Transactional): boolean; - markAsDirty(object: Transactional, options: TransactionOptions): boolean; - commit(object: Transactional, initiator?: Transactional): void; - aquire(owner: Owner, child: Transactional, key?: string): boolean; - free(owner: Owner, child: Transactional): void; -}; diff --git a/lib/type-r/transactions.js b/lib/type-r/transactions.js deleted file mode 100644 index 6dacfe9..0000000 --- a/lib/type-r/transactions.js +++ /dev/null @@ -1,220 +0,0 @@ -import * as tslib_1 from "tslib"; -import { Messenger, tools, mixins, mixinRules, definitions, eventsApi, define } from './object-plus'; -import { ValidationError } from './validation'; -import { resolveReference } from './traversable'; -import { abortIO } from './io-tools'; -var assign = tools.assign, trigger2 = eventsApi.trigger2, trigger3 = eventsApi.trigger3, on = eventsApi.on, off = eventsApi.off; -export var ItemsBehavior; -(function (ItemsBehavior) { - ItemsBehavior[ItemsBehavior["share"] = 1] = "share"; - ItemsBehavior[ItemsBehavior["listen"] = 2] = "listen"; - ItemsBehavior[ItemsBehavior["persistent"] = 4] = "persistent"; -})(ItemsBehavior || (ItemsBehavior = {})); -var Transactional = (function () { - function Transactional(cid) { - this._events = void 0; - this._changeToken = {}; - this._transaction = false; - this._isDirty = null; - this._owner = void 0; - this._ownerKey = void 0; - this._validationError = void 0; - this.cid = this.cidPrefix + cid; - } - Transactional_1 = Transactional; - Transactional.onDefine = function (definitions, BaseClass) { - if (definitions.endpoint) - this.prototype._endpoint = definitions.endpoint; - Messenger.onDefine.call(this, definitions, BaseClass); - }; - ; - Transactional.onExtend = function (BaseClass) { - if (BaseClass.create === this.create) { - this.create = Transactional_1.create; - } - }; - Transactional.create = function (a, b) { - return new this(a, b); - }; - Transactional.prototype.dispose = function () { - if (this._disposed) - return; - abortIO(this); - this._owner = void 0; - this._ownerKey = void 0; - this.off(); - this.stopListening(); - this._disposed = true; - }; - Transactional.prototype.initialize = function () { }; - Transactional.prototype.onChanges = function (handler, target) { - on(this, this._changeEventName, handler, target); - }; - Transactional.prototype.offChanges = function (handler, target) { - off(this, this._changeEventName, handler, target); - }; - Transactional.prototype.listenToChanges = function (target, handler) { - this.listenTo(target, target._changeEventName, handler); - }; - Transactional.prototype.transaction = function (fun, options) { - if (options === void 0) { options = {}; } - var isRoot = transactionApi.begin(this); - var update = fun.call(this, this); - update && this.set(update); - isRoot && transactionApi.commit(this); - }; - Transactional.prototype.updateEach = function (iteratee, options) { - var isRoot = transactionApi.begin(this); - this.each(iteratee); - isRoot && transactionApi.commit(this); - }; - Transactional.prototype.set = function (values, options) { - if (values) { - var transaction = this._createTransaction(values, options); - transaction && transaction.commit(); - } - return this; - }; - Transactional.prototype.assignFrom = function (source) { - var _this = this; - this.transaction(function () { - _this.set(source.__inner_state__ || source, { merge: true }); - var _changeToken = source._changeToken; - if (_changeToken) { - _this._changeToken = _changeToken; - } - }); - return this; - }; - Transactional.prototype.parse = function (data, options) { return data; }; - Transactional.prototype.deepGet = function (reference) { - return resolveReference(this, reference, function (object, key) { return object.get ? object.get(key) : object[key]; }); - }; - Transactional.prototype.getOwner = function () { - return this._owner; - }; - Transactional.prototype.getStore = function () { - var _owner = this._owner; - return _owner ? _owner.getStore() : this._defaultStore; - }; - Transactional.prototype.map = function (iteratee, context) { - var arr = [], fun = context !== void 0 ? function (v, k) { return iteratee.call(context, v, k); } : iteratee; - this.each(function (val, key) { - var result = fun(val, key); - if (result !== void 0) - arr.push(result); - }); - return arr; - }; - Transactional.prototype.hasPendingIO = function () { return this._ioPromise; }; - Transactional.prototype.fetch = function (options) { throw new Error("Not implemented"); }; - Transactional.prototype.getEndpoint = function () { - return getOwnerEndpoint(this) || this._endpoint; - }; - Transactional.prototype.mapObject = function (iteratee, context) { - var obj = {}, fun = context !== void 0 ? function (v, k) { return iteratee.call(context, v, k); } : iteratee; - this.each(function (val, key) { - var result = iteratee(val, key); - if (result !== void 0) - obj[key] = result; - }); - return obj; - }; - Object.defineProperty(Transactional.prototype, "validationError", { - get: function () { - var error = this._validationError || (this._validationError = new ValidationError(this)); - return error.length ? error : null; - }, - enumerable: true, - configurable: true - }); - Transactional.prototype.validate = function (obj) { }; - Transactional.prototype.getValidationError = function (key) { - var error = this.validationError; - return (key ? error && error.nested[key] : error) || null; - }; - Transactional.prototype.deepValidationError = function (reference) { - return resolveReference(this, reference, function (object, key) { return object.getValidationError(key); }); - }; - Transactional.prototype.eachValidationError = function (iteratee) { - var validationError = this.validationError; - validationError && validationError.eachError(iteratee, this); - }; - Transactional.prototype.isValid = function (key) { - return !this.getValidationError(key); - }; - Transactional.prototype.valueOf = function () { return this.cid; }; - Transactional.prototype.toString = function () { return this.cid; }; - Transactional.prototype.getClassName = function () { - var name = this.constructor.name; - if (name !== 'Subclass') - return name; - }; - var Transactional_1; - Transactional = Transactional_1 = tslib_1.__decorate([ - define, - definitions({ - endpoint: mixinRules.value - }), - mixins(Messenger) - ], Transactional); - return Transactional; -}()); -export { Transactional }; -export var transactionApi = { - begin: function (object) { - return object._transaction ? false : (object._transaction = true); - }, - markAsDirty: function (object, options) { - var dirty = !options.silent; - if (dirty) - object._isDirty = options; - object._changeToken = {}; - object._validationError = void 0; - return dirty; - }, - commit: function (object, initiator) { - var originalOptions = object._isDirty; - if (originalOptions) { - while (object._isDirty) { - var options = object._isDirty; - object._isDirty = null; - trigger3(object, object._changeEventName, object, options, initiator); - } - object._transaction = false; - var _owner = object._owner; - if (_owner && _owner !== initiator) { - _owner._onChildrenChange(object, originalOptions); - } - } - else { - object._isDirty = null; - object._transaction = false; - } - }, - aquire: function (owner, child, key) { - if (!child._owner) { - child._owner = owner; - child._ownerKey = key; - return true; - } - return child._owner === owner; - }, - free: function (owner, child) { - if (owner === child._owner) { - child._owner = void 0; - child._ownerKey = void 0; - } - } -}; -function getOwnerEndpoint(self) { - var collection = self.collection; - if (collection) { - return getOwnerEndpoint(collection); - } - if (self._owner) { - var _endpoints = self._owner._endpoints; - return _endpoints && _endpoints[self._ownerKey]; - } -} -//# sourceMappingURL=transactions.js.map \ No newline at end of file diff --git a/lib/type-r/transactions.js.map b/lib/type-r/transactions.js.map deleted file mode 100644 index 33482af..0000000 --- a/lib/type-r/transactions.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"transactions.js","sourceRoot":"","sources":["../../src/type-r/transactions.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAyF,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAY,MAAM,eAAe,CAAA;AACrM,OAAO,EAAE,eAAe,EAA+B,MAAM,cAAc,CAAA;AAC3E,OAAO,EAAe,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAC7D,OAAO,EAAiC,OAAO,EAAE,MAAM,YAAY,CAAA;AAE3D,IAAA,qBAAM,EACN,6BAAQ,EAAE,6BAAQ,EAAE,iBAAE,EAAE,mBAAG,CAAe;AAYlD,MAAM,CAAN,IAAY,aAIX;AAJD,WAAY,aAAa;IACrB,mDAAoB,CAAA;IACpB,qDAAoB,CAAA;IACpB,6DAAoB,CAAA;AACxB,CAAC,EAJW,aAAa,KAAb,aAAa,QAIxB;AAQD;IAsHI,uBAAa,GAAqB;QA3DlC,YAAO,GAA+B,KAAK,CAAC,CAAC;QAe7C,iBAAY,GAAQ,EAAE,CAAA;QAItB,iBAAY,GAAa,KAAK,CAAC;QAI/B,aAAQ,GAAyB,IAAI,CAAC;QAItC,WAAM,GAAW,KAAK,CAAC,CAAC;QAKxB,cAAS,GAAY,KAAK,CAAC,CAAC;QAyK5B,qBAAgB,GAAqB,KAAK,CAA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KAAK,CAAC;IAClC,CAAC;IAID,IAAI,EAAJ,UAAM,KAAa,EAAE,KAAqB;QACtC,IAAI,KAAK,KAAK,KAAK,CAAC,MAAM,EAAE;YACxB,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC;YACtB,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,CAAC;SAC5B;IACL,CAAC;CACJ,CAAA;AAED,SAAS,gBAAgB,CAAE,IAAoB;IAEnC,IAAA,4BAAU,CAAiB;IACnC,IAAI,UAAU,EAAE;QACZ,OAAO,gBAAgB,CAAE,UAAU,CAAE,CAAC;KACzC;IAGD,IAAI,IAAI,CAAC,MAAM,EAAE;QACL,IAAA,mCAAU,CAAwB;QAC1C,OAAO,UAAU,IAAI,UAAU,CAAE,IAAI,CAAC,SAAS,CAAE,CAAC;KACrD;AACL,CAAC"} \ No newline at end of file diff --git a/lib/type-r/traversable.d.ts b/lib/type-r/traversable.d.ts deleted file mode 100644 index 88d38eb..0000000 --- a/lib/type-r/traversable.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -export interface Traversable { - getStore(): Traversable; - getOwner(): Traversable; - get(key: string): any; -} -export declare type ResolveReference = (root: Traversable) => any; -export declare class CompiledReference { - resolve: ResolveReference; - tail: string; - local: boolean; - constructor(reference: string, splitTail?: boolean); -} -export declare function resolveReference(root: Traversable, reference: string, action: (object: any, key: string) => any): any; diff --git a/lib/type-r/traversable.js b/lib/type-r/traversable.js deleted file mode 100644 index 8dda18b..0000000 --- a/lib/type-r/traversable.js +++ /dev/null @@ -1,42 +0,0 @@ -var referenceMask = /\^|(store\.[^.]+)|([^.]+)/g; -var CompiledReference = (function () { - function CompiledReference(reference, splitTail) { - if (splitTail === void 0) { splitTail = false; } - var path = reference - .match(referenceMask) - .map(function (key) { - if (key === '^' || key === 'owner') - return 'getOwner()'; - if (key[0] === '~') - return "getStore().get(\"" + key.substr(1) + "\")"; - if (key.indexOf('store.') === 0) - return "getStore().get(\"" + key.substr(6) + "\")"; - return key; - }); - this.tail = splitTail && path.pop(); - this.local = !path.length; - this.resolve = new Function('self', "\n var v = self." + path.shift() + ";\n \n " + path.map(function (x) { return "\n v = v && v." + x + ";\n "; }).join('') + "\n\n return v;\n "); - } - return CompiledReference; -}()); -export { CompiledReference }; -export function resolveReference(root, reference, action) { - var path = reference.match(referenceMask), skip = path.length - 1; - var self = root; - for (var i = 0; i < skip; i++) { - var key = path[i]; - switch (key) { - case '~': - self = self.getStore(); - break; - case '^': - self = self.getOwner(); - break; - default: self = self.get(key); - } - if (!self) - return; - } - return action(self, path[skip]); -} -//# sourceMappingURL=traversable.js.map \ No newline at end of file diff --git a/lib/type-r/traversable.js.map b/lib/type-r/traversable.js.map deleted file mode 100644 index a1e5492..0000000 --- a/lib/type-r/traversable.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"traversable.js","sourceRoot":"","sources":["../../src/type-r/traversable.ts"],"names":[],"mappings":"AAcA,IAAM,aAAa,GAAI,4BAA4B,CAAC;AAKpD;IAKI,2BAAa,SAAkB,EAAE,SAA2B;QAA3B,0BAAA,EAAA,iBAA2B;QACxD,IAAM,IAAI,GAAG,SAAS;aACL,KAAK,CAAE,aAAa,CAAE;aACtB,GAAG,CAAE,UAAA,GAAG;YACL,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,OAAO;gBAAG,OAAO,YAAY,CAAC;YAEzD,IAAI,GAAG,CAAE,CAAC,CAAE,KAAK,GAAG;gBAAG,OAAO,sBAAoB,GAAG,CAAC,MAAM,CAAE,CAAC,CAAE,QAAK,CAAC;YAEvE,IAAI,GAAG,CAAC,OAAO,CAAE,QAAQ,CAAE,KAAK,CAAC;gBAAG,OAAO,sBAAoB,GAAG,CAAC,MAAM,CAAE,CAAC,CAAE,QAAK,CAAC;YAEpF,OAAO,GAAG,CAAC;QACf,CAAC,CAAE,CAAC;QAEpB,IAAI,CAAC,IAAI,GAAG,SAAS,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;QACpC,IAAI,CAAC,KAAK,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC;QAE1B,IAAI,CAAC,OAAO,GAAS,IAAI,QAAQ,CAAE,MAAM,EAAE,gCACvB,IAAI,CAAC,KAAK,EAAE,oDAEzB,IAAI,CAAC,GAAG,CAAE,UAAA,CAAC,IAAI,OAAA,kCACA,CAAC,oBAClB,EAFiB,CAEjB,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,wCAGd,CAAE,CAAC;IACR,CAAC;IACL,wBAAC;AAAD,CAAC,AA/BD,IA+BC;;AAED,MAAM,UAAU,gBAAgB,CAAE,IAAkB,EAAE,SAAkB,EAAE,MAAwC;IAC9G,IAAM,IAAI,GAAG,SAAS,CAAC,KAAK,CAAE,aAAa,CAAE,EACvC,IAAI,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAE7B,IAAI,IAAI,GAAG,IAAI,CAAC;IAEhB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,EAAE;QAC3B,IAAM,GAAG,GAAG,IAAI,CAAE,CAAC,CAAE,CAAC;QACtB,QAAQ,GAAG,EAAE;YACT,KAAK,GAAG;gBAAG,IAAI,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAAC,MAAM;YACzC,KAAK,GAAG;gBAAG,IAAI,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAAC,MAAM;YACzC,OAAS,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAE,GAAG,CAAE,CAAC;SACrC;QAGD,IAAI,CAAC,IAAI;YAAG,OAAO;KACtB;IAED,OAAO,MAAM,CAAE,IAAI,EAAE,IAAI,CAAE,IAAI,CAAE,CAAE,CAAC;AACxC,CAAC"} \ No newline at end of file diff --git a/lib/type-r/validation.d.ts b/lib/type-r/validation.d.ts deleted file mode 100644 index 01ffb2f..0000000 --- a/lib/type-r/validation.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -export interface ChildrenErrors { - [key: string]: ValidationError | any; -} -export interface Validatable { - _validateNested(errors: ChildrenErrors): number; - validate(self: any): any; - get(key: string): any; -} -export declare class ValidationError { - nested: ChildrenErrors; - length: number; - error: any; - constructor(obj: Validatable); - each(iteratee: (value: any, key: string) => void): void; - eachError(iteratee: (error: any, key: string, object: Validatable) => void, object: Validatable): void; -} diff --git a/lib/type-r/validation.js b/lib/type-r/validation.js deleted file mode 100644 index 20f6e3f..0000000 --- a/lib/type-r/validation.js +++ /dev/null @@ -1,29 +0,0 @@ -var ValidationError = (function () { - function ValidationError(obj) { - this.length = obj._validateNested(this.nested = {}); - if (this.error = obj.validate(obj)) { - this.length++; - } - } - ValidationError.prototype.each = function (iteratee) { - var _a = this, error = _a.error, nested = _a.nested; - if (error) - iteratee(error, null); - for (var key in nested) { - iteratee(nested[key], key); - } - }; - ValidationError.prototype.eachError = function (iteratee, object) { - this.each(function (value, key) { - if (value instanceof ValidationError) { - value.eachError(iteratee, object.get(key)); - } - else { - iteratee(value, key, object); - } - }); - }; - return ValidationError; -}()); -export { ValidationError }; -//# sourceMappingURL=validation.js.map \ No newline at end of file diff --git a/lib/type-r/validation.js.map b/lib/type-r/validation.js.map deleted file mode 100644 index b930f72..0000000 --- a/lib/type-r/validation.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/type-r/validation.ts"],"names":[],"mappings":"AAWA;IAQI,yBAAa,GAAiB;QAC1B,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,eAAe,CAAE,IAAI,CAAC,MAAM,GAAG,EAAE,CAAE,CAAC;QAEtD,IAAI,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,QAAQ,CAAE,GAAG,CAAE,EAAE;YAClC,IAAI,CAAC,MAAM,EAAE,CAAC;SACjB;IACL,CAAC;IAED,8BAAI,GAAJ,UAAM,QAAgD;QAC5C,IAAA,SAAwB,EAAtB,gBAAK,EAAE,kBAAM,CAAU;QAE/B,IAAI,KAAK;YAAG,QAAQ,CAAE,KAAK,EAAE,IAAI,CAAE,CAAC;QAEpC,KAAK,IAAM,GAAG,IAAI,MAAM,EAAE;YACtB,QAAQ,CAAE,MAAM,CAAE,GAAG,CAAE,EAAE,GAAG,CAAE,CAAC;SAClC;IACL,CAAC;IAED,mCAAS,GAAT,UAAW,QAAsE,EAAE,MAAoB;QACnG,IAAI,CAAC,IAAI,CAAE,UAAE,KAAW,EAAE,GAAY;YAClC,IAAI,KAAK,YAAY,eAAe,EAAE;gBAChB,KAAM,CAAC,SAAS,CAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,CAAE,GAAG,CAAE,CAAE,CAAC;aACrE;iBACG;gBACA,QAAQ,CAAE,KAAK,EAAE,GAAG,EAAE,MAAM,CAAE,CAAC;aAClC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IACL,sBAAC;AAAD,CAAC,AApCD,IAoCC"} \ No newline at end of file diff --git a/lib/underscore-mixin.d.ts b/lib/underscore-mixin.d.ts index 1491893..abac31e 100644 --- a/lib/underscore-mixin.d.ts +++ b/lib/underscore-mixin.d.ts @@ -1,5 +1,8 @@ +import { Model } from 'type-r'; export declare const ModelMixin: { pick(...args: any[]): any; + values(this: Model): any[]; + each: (iteratee: (value?: any, key?: string) => void, context?: any) => void; escape(attr: any): any; matches(attrs: any): boolean; omit(...keys: string[]): {}; diff --git a/lib/underscore-mixin.js b/lib/underscore-mixin.js index 44440b5..face695 100644 --- a/lib/underscore-mixin.js +++ b/lib/underscore-mixin.js @@ -1,4 +1,5 @@ import * as _ from 'underscore'; +import { Model } from 'type-r'; export var ModelMixin = { pick: function () { var args = []; @@ -7,6 +8,11 @@ export var ModelMixin = { } return _.pick(this, args); }, + values: function () { + var _this = this; + return this.keys().map(function (name) { return _this[name]; }); + }, + each: Model.prototype.forEach, escape: function (attr) { return _.escape(this[attr]); }, diff --git a/lib/underscore-mixin.js.map b/lib/underscore-mixin.js.map index 9c30642..cde633c 100644 --- a/lib/underscore-mixin.js.map +++ b/lib/underscore-mixin.js.map @@ -1 +1 @@ -{"version":3,"file":"underscore-mixin.js","sourceRoot":"","sources":["../src/underscore-mixin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,YAAY,CAAA;AAE/B,MAAM,CAAC,IAAM,UAAU,GAAG;IACtB,IAAI;QAAE,cAAe;aAAf,UAAe,EAAf,qBAAe,EAAf,IAAe;YAAf,yBAAe;;QACjB,OAAO,CAAC,CAAC,IAAI,CAAE,IAAI,EAAE,IAAI,CAAE,CAAC;IAChC,CAAC;IAED,MAAM,YAAE,IAAI;QACR,OAAO,CAAC,CAAC,MAAM,CAAE,IAAI,CAAE,IAAI,CAAE,CAAE,CAAC;IACpC,CAAC;IAED,OAAO,YAAE,KAAK;QACV,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAE,KAAK,EAAE,IAAI,CAAE,CAAE,IAAI,CAAE,CAAC;IAC/C,CAAC;IAED,IAAI,EAAJ;QAAM,cAAkB;aAAlB,UAAkB,EAAlB,qBAAkB,EAAlB,IAAkB;YAAlB,yBAAkB;;QACpB,OAAO,IAAI,CAAC,SAAS,CAAE,UAAE,KAAK,EAAE,GAAG;YAC/B,IAAI,IAAI,CAAC,OAAO,CAAE,GAAG,CAAE,GAAG,CAAC,EAAE;gBACzB,OAAO,KAAK,CAAC;aAChB;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IAED,MAAM;QACF,IAAM,QAAQ,GAAG,EAAE,CAAC;QACpB,IAAI,CAAC,IAAI,CAAE,UAAE,KAAK,EAAE,GAAG,IAAM,OAAA,QAAQ,CAAE,KAAK,CAAE,GAAG,GAAG,EAAvB,CAAuB,CAAE,CAAC;QACvD,OAAO,QAAQ,CAAC;IACpB,CAAC;IAED,KAAK;QACD,OAAO,IAAI,CAAC,GAAG,CAAE,UAAE,KAAK,EAAE,GAAG,IAAM,OAAA,CAAE,GAAG,EAAE,KAAK,CAAE,EAAd,CAAc,CAAE,CAAC;IACx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AC,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,QAAQ,CAAE,CAAC;QACtC,CAAC,CAAC;QACF,OAAO,CAAC,CAAC,OAAO;YAAU,cAAe;iBAAf,UAAe,EAAf,qBAAe,EAAf,IAAe;gBAAf,yBAAe;;YACrC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;YAC9B,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;QACpC,CAAC,CAAC;KACL;AACL,CAAC;AAGD,SAAS,EAAE,CAAC,QAAQ,EAAE,QAAQ;IAC1B,QAAQ,OAAO,QAAQ,EAAE;QACrB,KAAK,UAAW,CAAC,CAAC,OAAO,QAAQ,CAAC;QAClC,KAAK,QAAS,CAAC,CAAC,OAAO,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,GAAG,CAAE,QAAQ,CAAE,EAArB,CAAqB,CAAC;QACtD,KAAK,QAAQ;YACT,IAAI,CAAC,CAAC,QAAQ,YAAY,QAAQ,CAAC,KAAK,CAAE;gBAAE,OAAO,CAAC,CAAC,OAAO,CAAE,QAAQ,CAAE,CAAC;KAChF;IAED,OAAO,QAAQ,CAAC;AACpB,CAAC"} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 94305df..ab61956 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,63 +1,22 @@ { "name": "nestedtypes", - "version": "2.1.4", + "version": "3.0.0-a00", "lockfileVersion": 1, "requires": true, "dependencies": { - "@babel/code-frame": { - "version": "7.0.0-rc.1", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0-rc.1.tgz", - "integrity": "sha512-qhQo3GqwqMUv03SxxjcEkWtlkEDvFYrBKbJUn4Dtd9amC2cLkJ3me4iYUVSBbVXWbfbVRalEeVBHzX4aQYKnBg==", - "dev": true, - "requires": { - "@babel/highlight": "7.0.0-rc.1" - } - }, - "@babel/highlight": { - "version": "7.0.0-rc.1", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0-rc.1.tgz", - "integrity": "sha512-5PgPDV6F5s69XNznTcP0za3qH7qgBkr9DVQTXfZtpF+3iEyuIZB1Mjxu52F5CFxgzQUQJoBYHVxtH4Itdb5MgA==", - "dev": true, - "requires": { - "chalk": "2.4.1", - "esutils": "2.0.2", - "js-tokens": "3.0.2" - } - }, - "@types/estree": { - "version": "0.0.39", - "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz", - "integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==", - "dev": true - }, "@types/jquery": { - "version": "2.0.49", - "resolved": "https://registry.npmjs.org/@types/jquery/-/jquery-2.0.49.tgz", - "integrity": "sha512-/9xLnYmohN/vD2gDnLS4cym8TUmrJu7DvZa/LELKzZjdPsvWVJiedsdu2SXNtb/DA7FGimqL2g0IoyhbNKLl8g==", - "dev": true - }, - "@types/node": { - "version": "10.7.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.7.0.tgz", - "integrity": "sha512-dmYIvoQEZWnyQfgrwPCoxztv/93NYQGEiOoQhuI56rJahv9de6Q2apZl3bufV46YJ0OAXdaktIuw4RIRl4DTeA==", + "version": "2.0.51", + "resolved": "https://registry.npmjs.org/@types/jquery/-/jquery-2.0.51.tgz", + "integrity": "sha512-+vtCjz+pzr5KkaX/GMnVF0YtQqkm+oVcdBH0Q7zCxdwk42c71xJ9hT1b6Mbn4Kf7CAxSHvkWF1LRdpYwUM+pcg==", "dev": true }, - "ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, - "requires": { - "color-convert": "1.9.2" - } - }, "arr-diff": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-2.0.0.tgz", "integrity": "sha1-jzuCf5Vai9ZpaX5KQlasPOrjVs8=", "dev": true, "requires": { - "arr-flatten": "1.1.0" + "arr-flatten": "^1.0.1" } }, "arr-flatten": { @@ -73,9 +32,9 @@ "dev": true }, "atob": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/atob/-/atob-2.0.3.tgz", - "integrity": "sha1-GcenYEc3dEaPILLS0DNyrX1Mv10=", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", + "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==", "dev": true }, "braces": { @@ -84,9 +43,9 @@ "integrity": "sha1-uneWLhLf+WnWt2cR6RS3N4V79qc=", "dev": true, "requires": { - "expand-range": "1.8.2", - "preserve": "0.2.0", - "repeat-element": "1.1.2" + "expand-range": "^1.8.1", + "preserve": "^0.2.0", + "repeat-element": "^1.1.2" } }, "builtin-modules": { @@ -95,60 +54,16 @@ "integrity": "sha512-3U5kUA5VPsRUA3nofm/BXX7GVHKfxz0hOBAPxXrIvHzlDRkQVqEn6yi8QJegxl4LzOHLdvb7XF5dVawa/VVYBg==", "dev": true }, - "chalk": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", - "integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==", - "dev": true, - "requires": { - "ansi-styles": "3.2.1", - "escape-string-regexp": "1.0.5", - "supports-color": "5.4.0" - } - }, - "color-convert": { - "version": "1.9.2", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.2.tgz", - "integrity": "sha512-3NUJZdhMhcdPn8vJ9v2UQJoH0qqoGUkYTgFEPZaPjEtwmmKUfNV46zZmgB2M5M4DCEQHMaCfWHCxiBflLm04Tg==", - "dev": true, - "requires": { - "color-name": "1.1.1" - } - }, - "color-name": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.1.tgz", - "integrity": "sha1-SxQVMEz1ACjqgWQ2Q72C6gWANok=", - "dev": true - }, - "commander": { - "version": "2.16.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.16.0.tgz", - "integrity": "sha512-sVXqklSaotK9at437sFlFpyOcJonxe0yST/AG9DkQKUdIE6IqGIMv4SfAQSKaJbSdVEJYItASCrBiVQHq1HQew==", - "dev": true - }, "decode-uri-component": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=", "dev": true }, - "escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", - "dev": true - }, "estree-walker": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.3.1.tgz", - "integrity": "sha1-5rGlHPcpJSTnI3wxLl/mZgwc4ao=", - "dev": true - }, - "esutils": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", - "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.5.2.tgz", + "integrity": "sha512-XpCnW/AE10ws/kDAs37cngSkvgIR8aN3G0MS85m7dUpuK2EREo9VJ00uvw6Dg/hXEpfsE1I1TvJOJr+Z+TL+ig==", "dev": true }, "expand-brackets": { @@ -157,7 +72,7 @@ "integrity": "sha1-3wcoTjQqgHzXM6xa9yQR5YHRF3s=", "dev": true, "requires": { - "is-posix-bracket": "0.1.1" + "is-posix-bracket": "^0.1.0" } }, "expand-range": { @@ -166,7 +81,7 @@ "integrity": "sha1-opnv/TNf4nIeuujiV+x5ZE/IUzc=", "dev": true, "requires": { - "fill-range": "2.2.3" + "fill-range": "^2.1.0" } }, "extglob": { @@ -175,7 +90,7 @@ "integrity": "sha1-Lhj/PS9JqydlzskCPwEdqo2DSaE=", "dev": true, "requires": { - "is-extglob": "1.0.0" + "is-extglob": "^1.0.0" } }, "filename-regex": { @@ -185,16 +100,16 @@ "dev": true }, "fill-range": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-2.2.3.tgz", - "integrity": "sha1-ULd9/X5Gm8dJJHCWNpn+eoSFpyM=", + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-2.2.4.tgz", + "integrity": "sha512-cnrcCbj01+j2gTG921VZPnHbjmdAf8oQV/iGeV2kZxGSyfYjjTyY79ErsK1WJWMpw6DaApEX72binqJE+/d+5Q==", "dev": true, "requires": { - "is-number": "2.1.0", - "isobject": "2.1.0", - "randomatic": "1.1.7", - "repeat-element": "1.1.2", - "repeat-string": "1.6.1" + "is-number": "^2.1.0", + "isobject": "^2.0.0", + "randomatic": "^3.0.0", + "repeat-element": "^1.1.2", + "repeat-string": "^1.5.2" } }, "for-in": { @@ -209,7 +124,7 @@ "integrity": "sha1-UmXGgaTylNq78XyVCbZ2OqhFEM4=", "dev": true, "requires": { - "for-in": "1.0.2" + "for-in": "^1.0.1" } }, "glob-base": { @@ -218,8 +133,8 @@ "integrity": "sha1-27Fk9iIbHAscz4Kuoyi0l98Oo8Q=", "dev": true, "requires": { - "glob-parent": "2.0.0", - "is-glob": "2.0.1" + "glob-parent": "^2.0.0", + "is-glob": "^2.0.0" } }, "glob-parent": { @@ -228,15 +143,9 @@ "integrity": "sha1-gTg9ctsFT8zPUzbaqQLxgvbtuyg=", "dev": true, "requires": { - "is-glob": "2.0.1" + "is-glob": "^2.0.0" } }, - "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true - }, "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", @@ -255,7 +164,7 @@ "integrity": "sha1-IjgJj8Ih3gvPpdnqxMRdY4qhxTQ=", "dev": true, "requires": { - "is-primitive": "2.0.0" + "is-primitive": "^2.0.0" } }, "is-extendable": { @@ -276,7 +185,7 @@ "integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=", "dev": true, "requires": { - "is-extglob": "1.0.0" + "is-extglob": "^1.0.0" } }, "is-module": { @@ -291,7 +200,7 @@ "integrity": "sha1-Afy7s5NGOlSPL0ZszhbezknbkI8=", "dev": true, "requires": { - "kind-of": "3.2.2" + "kind-of": "^3.0.2" } }, "is-posix-bracket": { @@ -327,40 +236,40 @@ "integrity": "sha512-Ubldcmxp5np52/ENotGxlLe6aGMvmF4R8S6tZjsP6Knsaxd/xp3Zrh50cG93lR6nPXyUFwzN3ZSOQI0wRJNdGg==", "dev": true }, - "js-tokens": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", - "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=", - "dev": true - }, "kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "is-buffer": "1.1.6" + "is-buffer": "^1.1.5" } }, + "math-random": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/math-random/-/math-random-1.0.1.tgz", + "integrity": "sha1-izqsWIuKZuSXXjzepn97sylgH6w=", + "dev": true + }, "micromatch": { "version": "2.3.11", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-2.3.11.tgz", "integrity": "sha1-hmd8l9FyCzY0MdBNDRUpO9OMFWU=", "dev": true, "requires": { - "arr-diff": "2.0.0", - "array-unique": "0.2.1", - "braces": "1.8.5", - "expand-brackets": "0.1.5", - "extglob": "0.3.2", - "filename-regex": "2.0.1", - "is-extglob": "1.0.0", - "is-glob": "2.0.1", - "kind-of": "3.2.2", - "normalize-path": "2.1.1", - "object.omit": "2.0.1", - "parse-glob": "3.0.4", - "regex-cache": "0.4.4" + "arr-diff": "^2.0.0", + "array-unique": "^0.2.1", + "braces": "^1.8.2", + "expand-brackets": "^0.1.4", + "extglob": "^0.3.1", + "filename-regex": "^2.0.0", + "is-extglob": "^1.0.0", + "is-glob": "^2.0.1", + "kind-of": "^3.0.2", + "normalize-path": "^2.0.1", + "object.omit": "^2.0.0", + "parse-glob": "^3.0.4", + "regex-cache": "^0.4.2" } }, "normalize-path": { @@ -369,7 +278,7 @@ "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", "dev": true, "requires": { - "remove-trailing-separator": "1.1.0" + "remove-trailing-separator": "^1.0.1" } }, "object.omit": { @@ -378,8 +287,8 @@ "integrity": "sha1-Gpx0SCnznbuFjHbKNXmuKlTr0fo=", "dev": true, "requires": { - "for-own": "0.1.5", - "is-extendable": "0.1.1" + "for-own": "^0.1.4", + "is-extendable": "^0.1.1" } }, "parse-glob": { @@ -388,16 +297,16 @@ "integrity": "sha1-ssN2z7EfNVE7rdFz7wu246OIORw=", "dev": true, "requires": { - "glob-base": "0.3.0", - "is-dotfile": "1.0.3", - "is-extglob": "1.0.0", - "is-glob": "2.0.1" + "glob-base": "^0.3.0", + "is-dotfile": "^1.0.0", + "is-extglob": "^1.0.0", + "is-glob": "^2.0.0" } }, "path-parse": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.5.tgz", - "integrity": "sha1-PBrfhx6pzWyUMbbqK9dKD/BVxME=", + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", "dev": true }, "preserve": { @@ -407,43 +316,27 @@ "dev": true }, "randomatic": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", - "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-3.1.1.tgz", + "integrity": "sha512-TuDE5KxZ0J461RVjrJZCJc+J+zCkTb1MbH9AQUq68sMhOMcy9jLcb3BrZKgp9q9Ncltdg4QVqWrH02W2EFFVYw==", "dev": true, "requires": { - "is-number": "3.0.0", - "kind-of": "4.0.0" + "is-number": "^4.0.0", + "kind-of": "^6.0.0", + "math-random": "^1.0.1" }, "dependencies": { "is-number": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", - "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", - "dev": true, - "requires": { - "kind-of": "3.2.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "1.1.6" - } - } - } + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-4.0.0.tgz", + "integrity": "sha512-rSklcAIlf1OmFdyAqbnWTLVelsQ58uvZ66S/ZyawjWqIviTWCjg2PzVGw8WUA+nNuPTqb4wgA+NszrJ+08LlgQ==", + "dev": true }, "kind-of": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", - "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", - "dev": true, - "requires": { - "is-buffer": "1.1.6" - } + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", + "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", + "dev": true } } }, @@ -453,7 +346,7 @@ "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", "dev": true, "requires": { - "is-equal-shallow": "0.1.3" + "is-equal-shallow": "^0.1.3" } }, "remove-trailing-separator": { @@ -463,9 +356,9 @@ "dev": true }, "repeat-element": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.2.tgz", - "integrity": "sha1-7wiaF40Ug7quTZPrmLT55OEdmQo=", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.3.tgz", + "integrity": "sha512-ahGq0ZnV5m5XtZLMb+vP76kcAM5nkLqk0lpqAuojSKGgQtn4eRi4ZZGm2olo2zKFH+sMsWaqOCW1dqAnOru72g==", "dev": true }, "repeat-string": { @@ -475,12 +368,12 @@ "dev": true }, "resolve": { - "version": "1.7.1", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.7.1.tgz", - "integrity": "sha512-c7rwLofp8g1U+h1KNyHL/jicrKg1Ek4q+Lr33AL65uZTinUZHe30D5HlyN5V9NW0JX1D5dXQ4jqW5l7Sy/kGfw==", + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.8.1.tgz", + "integrity": "sha512-AicPrAC7Qu1JxPCZ9ZgCZlY35QgFnNqc+0LtbRNxnVw4TXvjQ72wnuL9JQcEBgXkI9JM8MsT9kaQoHcpCRJOYA==", "dev": true, "requires": { - "path-parse": "1.0.5" + "path-parse": "^1.0.5" } }, "resolve-url": { @@ -490,24 +383,20 @@ "dev": true }, "rollup": { - "version": "0.64.1", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-0.64.1.tgz", - "integrity": "sha512-+ThdVXrvonJdOTzyybMBipP0uz605Z8AnzWVY3rf+cSGnLO7uNkJBlN+9jXqWOomkvumXfm/esmBpA5d53qm7g==", - "dev": true, - "requires": { - "@types/estree": "0.0.39", - "@types/node": "10.7.0" - } + "version": "0.50.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-0.50.1.tgz", + "integrity": "sha512-XwrnqjSTk+yR8GbP6hiJuVe83MVmBw/gm4P3qP34A10fRXvv6ppl0ZUg1+Pj1tIZSR/aw5ZaILLEiVxwXIAdAw==", + "dev": true }, "rollup-plugin-node-resolve": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/rollup-plugin-node-resolve/-/rollup-plugin-node-resolve-3.3.0.tgz", - "integrity": "sha512-9zHGr3oUJq6G+X0oRMYlzid9fXicBdiydhwGChdyeNRGPcN/majtegApRKHLR5drboUvEWU+QeUmGTyEZQs3WA==", + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/rollup-plugin-node-resolve/-/rollup-plugin-node-resolve-3.4.0.tgz", + "integrity": "sha512-PJcd85dxfSBWih84ozRtBkB731OjXk0KnzN0oGp7WOWcarAFkVa71cV5hTJg2qpVsV2U8EUwrzHP3tvy9vS3qg==", "dev": true, "requires": { - "builtin-modules": "2.0.0", - "is-module": "1.0.0", - "resolve": "1.7.1" + "builtin-modules": "^2.0.0", + "is-module": "^1.0.0", + "resolve": "^1.1.6" } }, "rollup-plugin-sourcemaps": { @@ -516,28 +405,27 @@ "integrity": "sha1-YhJaqUCHqt97g+9N+vYptHMTXoc=", "dev": true, "requires": { - "rollup-pluginutils": "2.0.1", - "source-map-resolve": "0.5.1" + "rollup-pluginutils": "^2.0.1", + "source-map-resolve": "^0.5.0" } }, "rollup-plugin-uglify": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/rollup-plugin-uglify/-/rollup-plugin-uglify-4.0.0.tgz", - "integrity": "sha512-f6W31EQLzxSEYfN3x6/lyljHqXSoCjXKcTsnwz3evQvHgU1+qTzU2SE0SIG7tbAvaCewp2UaZ5x3k6nYsxOP9A==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/rollup-plugin-uglify/-/rollup-plugin-uglify-2.0.1.tgz", + "integrity": "sha1-Z7N60e/a+9g69MNrQMGJ7khmyWk=", "dev": true, "requires": { - "@babel/code-frame": "7.0.0-rc.1", - "uglify-js": "3.4.7" + "uglify-js": "^3.0.9" } }, "rollup-pluginutils": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.0.1.tgz", - "integrity": "sha1-fslbNXP2VDpGpkYb2afFRFJdD8A=", + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.3.3.tgz", + "integrity": "sha512-2XZwja7b6P5q4RZ5FhyX1+f46xi1Z3qBKigLRZ6VTZjwbN0K1IFGMlwm06Uu0Emcre2Z63l77nq/pzn+KxIEoA==", "dev": true, "requires": { - "estree-walker": "0.3.1", - "micromatch": "2.3.11" + "estree-walker": "^0.5.2", + "micromatch": "^2.3.11" } }, "source-map": { @@ -547,16 +435,16 @@ "dev": true }, "source-map-resolve": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.1.tgz", - "integrity": "sha512-0KW2wvzfxm8NCTb30z0LMNyPqWCdDGE2viwzUaucqJdkTRXtZiSY3I+2A6nVAjmdOy0I4gU8DwnVVGsk9jvP2A==", + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.2.tgz", + "integrity": "sha512-MjqsvNwyz1s0k81Goz/9vRBe9SZdB09Bdw+/zYyO+3CuPk6fouTaxscHkgtE8jKvf01kVfl8riHzERQ/kefaSA==", "dev": true, "requires": { - "atob": "2.0.3", - "decode-uri-component": "0.2.0", - "resolve-url": "0.2.1", - "source-map-url": "0.4.0", - "urix": "0.1.0" + "atob": "^2.1.1", + "decode-uri-component": "^0.2.0", + "resolve-url": "^0.2.1", + "source-map-url": "^0.4.0", + "urix": "^0.1.0" } }, "source-map-url": { @@ -565,34 +453,42 @@ "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=", "dev": true }, - "supports-color": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", - "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", - "dev": true, - "requires": { - "has-flag": "3.0.0" - } - }, "tslib": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==" }, + "type-r": { + "version": "3.0.0-a05", + "resolved": "https://registry.npmjs.org/type-r/-/type-r-3.0.0-a05.tgz", + "integrity": "sha512-Pnf8vjO+WEoC5M0HpKEpnT3TaDfup5typTDthUmR0rvYzGqFTYa734Xq1XSyBQtAgaxfmNPGEA9QjJBkjU6rUQ==", + "dev": true, + "requires": { + "tslib": "*" + } + }, "typescript": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.0.1.tgz", - "integrity": "sha512-zQIMOmC+372pC/CCVLqnQ0zSBiY7HHodU7mpQdjiZddek4GMj31I3dUJ7gAs9o65X7mnRma6OokOkc6f9jjfBg==", + "version": "3.1.6", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.1.6.tgz", + "integrity": "sha512-tDMYfVtvpb96msS1lDX9MEdHrW4yOuZ4Kdc4Him9oU796XldPYF/t2+uKoX0BBa0hXXwDlqYQbXY5Rzjzc5hBA==", "dev": true }, "uglify-js": { - "version": "3.4.7", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.4.7.tgz", - "integrity": "sha512-J0M2i1mQA+ze3EdN9SBi751DNdAXmeFLfJrd/MDIkRc3G3Gbb9OPVSx7GIQvVwfWxQARcYV2DTxIkMyDAk3o9Q==", + "version": "3.4.9", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.4.9.tgz", + "integrity": "sha512-8CJsbKOtEbnJsTyv6LE6m6ZKniqMiFWmm9sRbopbkGs3gMPPfd3Fh8iIA4Ykv5MgaTbqHr4BaoGLJLZNhsrW1Q==", "dev": true, "requires": { - "commander": "2.16.0", - "source-map": "0.6.1" + "commander": "~2.17.1", + "source-map": "~0.6.1" + }, + "dependencies": { + "commander": { + "version": "2.17.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.17.1.tgz", + "integrity": "sha512-wPMUt6FnH2yzG95SA6mzjQOEKUU3aLaDEmzs1ti+1E9h+CsrZghRlqEM/EJ4KscsQVG8uNN4uVreUeT8+drlgg==", + "dev": true + } } }, "underscore": { diff --git a/package.json b/package.json index 1800194..968f7d0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nestedtypes", - "version": "2.1.4", + "version": "3.0.0-a00", "main": "./dist/index.js", "module": "./lib/index.js", "types": "./lib/index.d.ts", @@ -25,13 +25,14 @@ "underscore": "*" }, "devDependencies": { - "@types/jquery": "^2.0.49", - "jquery": "^3.3.1", - "rollup": "*", - "rollup-plugin-node-resolve": "*", - "rollup-plugin-sourcemaps": "*", - "rollup-plugin-uglify": "*", - "typescript": "^3.0.1", + "@types/jquery": "^2.0.51", + "jquery": "*", + "rollup": "^0.50.0", + "rollup-plugin-node-resolve": "^3.4.0", + "rollup-plugin-sourcemaps": "^0.4.2", + "rollup-plugin-uglify": "^2.0.1", + "type-r": "alpha", + "typescript": "^3.1.6", "underscore": "*" }, "files": [ @@ -42,12 +43,8 @@ ], "license": "MIT", "scripts": { - "build": "npm run pull && npm run compile && npm run build:endpoints", - "pull": "git submodule update --remote && cp -R ./submodules/Type-R/src/* ./src/type-r && cp -R ./submodules/Type-R/endpoints/* ./endpoints", - "compile": "node_modules/.bin/tsc && ./node_modules/.bin/rollup --config", - "deploy": "cp ./dist/* ../observer-frontend/htdocs/js/lib/nested", - "build:endpoints": "cd endpoints/attributes && npm run build && cd ../localStorage && npm run build && cd ../memory && npm run build && cd ../restful && npm run build && cd ../proxy && npm run build", - "all": "npm run pull && npm run build && npm run deploy" + "build": "npm run compile", + "compile": "node_modules/.bin/tsc && ./node_modules/.bin/rollup --config" }, "dependencies": { "tslib": "^1.9.3" diff --git a/rollup.config.js b/rollup.config.js index 2393773..0e5d031 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,5 +1,5 @@ import resolve from 'rollup-plugin-node-resolve'; -import { uglify } from 'rollup-plugin-uglify'; +import uglify from 'rollup-plugin-uglify'; import sourcemaps from 'rollup-plugin-sourcemaps'; export default { @@ -12,7 +12,8 @@ export default { exports: 'named', globals: { jquery: '$', - underscore: '_' + underscore: '_', + 'type-r' : 'Nested' }, sourcemap: true }, @@ -24,6 +25,7 @@ export default { external: [ 'jquery', - 'underscore' + 'underscore', + 'type-r' ] }; \ No newline at end of file diff --git a/src/backbone.ts b/src/backbone.ts index c5894a5..2a88fe7 100644 --- a/src/backbone.ts +++ b/src/backbone.ts @@ -6,8 +6,8 @@ // Backbone.js 1.2.3 // (c) 2010-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors // Backbone may be freely distributed under the MIT license. -import * as _ from 'underscore' -import * as jQuery from 'jquery' +import * as jQuery from 'jquery'; +import * as _ from 'underscore'; // Initial Setup // ------------- diff --git a/src/index.ts b/src/index.ts index f48125c..23d7c82 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,19 +1,19 @@ /** * Extend Type-R namespace */ -import * as TypeR from './type-r' -export * from './type-r' - +import * as TypeR from 'type-r'; +import { MixinsState, Store as BaseStore, tools } from 'type-r'; /** - * Prepare backbone View, Router, History, and Events. + * Prepare backbone View, Router, History, and Events. */ -import Backbone from './backbone' -import { RestCollection, RestModel } from './rest' -import { Store as BaseStore, tools, MixinsState } from './type-r' -import Sync from './sync' - -import { ModelMixin, CollectionMixin } from './underscore-mixin' -import { RestStore, LazyStore } from './rest-store' +import Backbone from './backbone'; +import { RestCollection, RestModel } from './rest'; +import { LazyStore, RestStore } from './rest-store'; +import Sync from './sync'; +import { CollectionMixin, ModelMixin } from './underscore-mixin'; +export * from 'type-r'; +export * from './backbone'; +export { Backbone, RestStore, LazyStore, RestCollection as Collection, RestModel as Model }; /** * Prepare @@ -38,13 +38,11 @@ const Nested : typeof TypeR & typeof Backbone = Object.create( TypeR, tools.defa export default Nested; -export { Backbone, RestStore, LazyStore, RestCollection as Collection, RestModel as Model }; export function defaults( x ) : typeof Nested.Record { return Nested.Model.defaults( x ); } -export * from './backbone'; MixinsState.get( Nested.Mixable ).merge([ Nested.Events ]); Nested.Messenger.mixins.populate( Backbone.View, Backbone.Router, Backbone.History ); diff --git a/src/rest-store.ts b/src/rest-store.ts index ff51aa9..0cd723b 100644 --- a/src/rest-store.ts +++ b/src/rest-store.ts @@ -1,7 +1,8 @@ -import Backbone from './backbone' -import * as _ from 'underscore' -import { mixins, mixinRules, define, Store } from './type-r' -import { RestModel, RestCollection } from './rest' +import { define, Store } from 'type-r'; +import "type-r/globals"; +import * as _ from 'underscore'; +import Backbone from './backbone'; +import { RestCollection, RestModel } from './rest'; @define({ getStore : Store.prototype.getStore, @@ -14,7 +15,7 @@ export class LazyStore extends RestStore { _resolved : {} = {} initialize(){ - this.each( ( element, name ) => { + this.forEach( ( element, name ) => { if( !element ) return; element.store = this; diff --git a/src/rest.ts b/src/rest.ts index b1dde00..088ed4c 100644 --- a/src/rest.ts +++ b/src/rest.ts @@ -1,13 +1,9 @@ -import Sync, { SyncOptions, Restful, LazyValue } from './sync' +import { Collection, define, definitions, mixinRules, Model, tools } from 'type-r'; +import * as _ from 'underscore'; +import Sync, { Restful, SyncOptions } from './sync'; -import * as _ from 'underscore' -import * as Backbone from './backbone' - -import { define, Model, Collection, tools, definitions, mixinRules } from './type-r' const { defaults } = tools; -const transactionalProto = tools.getBaseClass( Model ).prototype; - export interface RestOptions extends SyncOptions { wait? : boolean patch? : boolean @@ -87,6 +83,8 @@ export class RestCollection extends Collection implements Restful { } }; +const modelProto = Model.prototype; + @define({ urlRoot : '' }) @@ -184,7 +182,7 @@ export class RestModel extends Model implements Restful { if( serverAttrs ){ // When server sends string, polimorphyc Model set screws up. - transactionalProto.set.call( this, serverAttrs, options ); + modelProto.set.call( this, serverAttrs, options ); if( model._invalidate( options ) ) return false; } diff --git a/src/sync.ts b/src/sync.ts index 879e5f5..097048d 100644 --- a/src/sync.ts +++ b/src/sync.ts @@ -5,11 +5,8 @@ * * With validation patches - NestedTypes validation semantic is applied. (c) Vlad Balin, 2015. */ -import * as _ from 'underscore' -import Backbone from './backbone' - -import { tools } from './type-r' -const { defaults } = tools; +import * as _ from 'underscore'; +import Backbone from './backbone'; export type LazyValue< T > = () => T | T; diff --git a/src/type-r/collection/README.md b/src/type-r/collection/README.md deleted file mode 100644 index ca5c306..0000000 --- a/src/type-r/collection/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# Transactional collections core implementation - -Collection implements two-phase commit transactions, -and core manipulation methods. - -## Folder structure and dependencies - - index.ts - ↗ ↑ ↖ - add.ts remove.ts set.ts - ↖ ↑ ↗ - commons.ts - ↑ - ../record/index.ts - - diff --git a/src/type-r/collection/add.ts b/src/type-r/collection/add.ts deleted file mode 100644 index ab435f8..0000000 --- a/src/type-r/collection/add.ts +++ /dev/null @@ -1,97 +0,0 @@ -import { Transaction, transactionApi } from '../transactions' -import { CollectionTransaction, logAggregationError, sortElements, convertAndAquire, free, CollectionOptions, addIndex, updateIndex, CollectionCore } from './commons' -import { Record } from '../record' - -const { begin, commit, markAsDirty } = transactionApi; - -export interface AddOptions extends CollectionOptions { - at? : number -} - -/** @private */ -export function addTransaction( collection : CollectionCore, items : any[], options : AddOptions, merge? : boolean ){ - const isRoot = begin( collection ), - nested : Transaction[]= []; - - var added = appendElements( collection, items, nested, options, merge ); - - if( added.length || nested.length ){ - let needSort = sortOrMoveElements( collection, added, options ); - if( markAsDirty( collection, options ) ){ - return new CollectionTransaction( collection, isRoot, added, [], nested, needSort ); - } - - if( collection._aggregationError ) logAggregationError( collection ); - } - - // No changes... - isRoot && commit( collection ); -}; - -// Handle sort or insert at options for add operation. Reurns true if sort happened. -/** @private */ -function sortOrMoveElements( collection : CollectionCore, added : Record[], options : AddOptions ) : boolean { - let at = options.at; - - // if `at` option is given, it overrides sorting option... - if( at != null ){ - // Take an original collection's length. - const length = collection.models.length - added.length; - - // Crazy Backbone rules about `at` index. I don't know what that guys smoke. - at = Number( at ); - if( at < 0 ) at += length + 1; - if( at < 0 ) at = 0; - if( at > length ) at = length; - - // Move added elements to desired position. In place. - moveElements( collection.models, at, added ); - return false; - } - - return sortElements( collection, options ); -} - -/** @private */ -function moveElements( source : any[], at : number, added : any[] ) : void { - for( var j = source.length - 1, i = j - added.length; i >= at; i--, j-- ){ - source[ j ] = source[ i ]; - } - - for( i = 0, j = at; i < added.length; i++, j++ ){ - source[ j ] = added[ i ]; - } -} - -// append data to model and index -/** @private */ -function appendElements( collection : CollectionCore, a_items : any[], nested : Transaction[], a_options : AddOptions, forceMerge : boolean ){ - var { _byId, models } = collection, - merge = ( forceMerge || a_options.merge ) && !collection._shared, - parse = a_options.parse, - idAttribute = collection.model.prototype.idAttribute, - prevLength = models.length; - - for( const item of a_items ){ - let model = item ? _byId[ item[ idAttribute ] ] || _byId[ item.cid ] : null; - - if( model ){ - if( merge && item !== model ){ - var attrs = item.attributes || item; - const transaction = model._createTransaction( attrs, a_options ); - transaction && nested.push( transaction ); - - if( model.hasChanged( idAttribute ) ){ - updateIndex( _byId, model ); - } - } - } - else{ - model = convertAndAquire( collection, item, a_options ); - models.push( model ); - addIndex( _byId, model ); - } - } - - return models.slice( prevLength ); -} diff --git a/src/type-r/collection/commons.ts b/src/type-r/collection/commons.ts deleted file mode 100644 index b9239d1..0000000 --- a/src/type-r/collection/commons.ts +++ /dev/null @@ -1,222 +0,0 @@ -import { Record } from '../record' -import { Owner, Transaction, ItemsBehavior, - TransactionOptions, Transactional, transactionApi } from '../transactions' - -import { eventsApi, tools } from '../object-plus' - -const { EventMap, trigger2, trigger3, on, off } = eventsApi, - { commit, markAsDirty } = transactionApi, - _aquire = transactionApi.aquire, _free = transactionApi.free; - -/** @private */ -export interface CollectionCore extends Transactional, Owner { - _byId : IdIndex - models : Record[] - model : typeof Record - idAttribute : string // TODO: Refactor inconsistent idAttribute usage - _comparator : Comparator - get( objOrId : string | Record | Object ) : Record - _itemEvents? : eventsApi.EventMap - _shared : number - _aggregationError : Record[] - - _log( level : string, text : string, value : any ) : void -} - -// Collection's manipulation methods elements -export type Elements = ( Object | Record )[]; - -export interface CollectionOptions extends TransactionOptions { - sort? : boolean -} - -export type Comparator = ( a : Record, b : Record ) => number; - -/** @private */ -export function dispose( collection : CollectionCore ) : Record[]{ - const { models } = collection; - - collection.models = []; - collection._byId = {}; - - freeAll( collection, models ); - return models; -} - -/** @private */ -export function convertAndAquire( collection : CollectionCore, attrs : {} | Record, options : CollectionOptions ){ - const { model } = collection; - - let record : Record; - - if( collection._shared ){ - record = attrs instanceof model ? attrs : model.create( attrs, options ); - - if( collection._shared & ItemsBehavior.listen ){ - on( record, record._changeEventName, collection._onChildrenChange, collection ); - } - } - else{ - record = attrs instanceof model ? ( options.merge ? attrs.clone() : attrs ) : model.create( attrs, options ); - - if( !_aquire( collection, record ) ){ - const errors = collection._aggregationError || ( collection._aggregationError = [] ); - errors.push( record ); - } - } - - // Subscribe for events... - const { _itemEvents } = collection; - _itemEvents && _itemEvents.subscribe( collection, record ); - - return record; -} - -/** @private */ -export function free( owner : CollectionCore, child : Record, unset? : boolean ) : void { - if( owner._shared ){ - if( owner._shared & ItemsBehavior.listen ){ - off( child, child._changeEventName, owner._onChildrenChange, owner ); - } - } - else{ - _free( owner, child ); - unset || child.dispose(); - } - - const { _itemEvents } = owner; - _itemEvents && _itemEvents.unsubscribe( owner, child ); -} - -/** @private */ -export function freeAll( collection : CollectionCore, children : Record[] ) : Record[] { - for( let child of children ){ - free( collection, child ); - } - - return children; -} - -/** - * Silently sort collection, if its required. Returns true if sort happened. - * @private - */ -export function sortElements( collection : CollectionCore, options : CollectionOptions ) : boolean { - let { _comparator } = collection; - if( _comparator && options.sort !== false ){ - collection.models.sort( _comparator ); - return true; - } - - return false; -} - -/********************************** - * Collection Index - * @private - */ -export interface IdIndex { - [ id : string ] : Record -} - -/** @private Add record */ -export function addIndex( index : IdIndex, model : Record ) : void { - index[ model.cid ] = model; - var id = model.id; - - if( id || id === 0 ){ - index[ id ] = model; - } -} - -/** @private Remove record */ -export function removeIndex( index : IdIndex, model : Record ) : void { - delete index[ model.cid ]; - var id = model.id; - if( id || id === 0 ){ - delete index[ id ]; - } -} - -export function updateIndex( index : IdIndex, model : Record ){ - delete index[ model.previous( model.idAttribute ) ]; - - const { id } = model; - id == null || ( index[ id ] = model ); -} - -/*** - * In Collections, transactions appears only when - * add remove or change events might be emitted. - * reset doesn't require transaction. - * - * Transaction holds information regarding events, and knows how to emit them. - * - * Two major optimization cases. - * 1) Population of an empty collection - * 2) Update of the collection (no or little changes) - it's crucial to reject empty transactions. - */ - - -// Transaction class. Implements two-phase transactions on object's tree. -/** @private */ -export class CollectionTransaction implements Transaction { - // open transaction - constructor( public object : CollectionCore, - public isRoot : boolean, - public added : Record[], - public removed : Record[], - public nested : Transaction[], - public sorted : boolean ){} - - // commit transaction - commit( initiator? : Transactional ){ - const { nested, object } = this, - { _isDirty } = object; - - // Commit all nested transactions... - for( let transaction of nested ){ - transaction.commit( object ); - } - - if( object._aggregationError ){ - logAggregationError( object ); - } - - // Just trigger 'change' on collection, it must be already triggered for models during nested commits. - // ??? TODO: do it in nested transactions loop? This way appears to be more correct. - for( let transaction of nested ){ - trigger2( object, 'change', transaction.object, _isDirty ); - } - - // Notify listeners on attribute changes... - const { added, removed } = this; - - // Trigger `add` events for both model and collection. - for( let record of added ){ - trigger3( record, 'add', record, object, _isDirty ); - trigger3( object, 'add', record, object, _isDirty ); - } - - // Trigger `remove` events for both model and collection. - for( let record of removed ){ - trigger3( record, 'remove', record, object, _isDirty ); - trigger3( object, 'remove', record, object, _isDirty ); - } - - if( this.sorted ){ - trigger2( object, 'sort', object, _isDirty ); - } - - if( added.length || removed.length ){ - trigger2( object, 'update', object, _isDirty ); - } - - this.isRoot && commit( object, initiator ); - } -} - -export function logAggregationError( collection : CollectionCore ){ - collection._log( 'error', 'added records already have an owner', collection._aggregationError ); - collection._aggregationError = void 0; -} \ No newline at end of file diff --git a/src/type-r/collection/index.ts b/src/type-r/collection/index.ts deleted file mode 100644 index 55ff533..0000000 --- a/src/type-r/collection/index.ts +++ /dev/null @@ -1,614 +0,0 @@ -import { define, tools, eventsApi, EventMap, definitions, mixinRules, EventsDefinition, Mixable } from '../object-plus' -import { ItemsBehavior, transactionApi, Transactional, CloneOptions, Transaction, TransactionOptions, TransactionalDefinition, Owner } from '../transactions' -import { Record, SharedType, AggregatedType, createSharedTypeSpec } from '../record' - -import { IdIndex, free, sortElements, dispose, Elements, CollectionCore, addIndex, removeIndex, updateIndex, Comparator, CollectionTransaction } from './commons' -import { addTransaction, AddOptions } from './add' -import { setTransaction, emptySetTransaction } from './set' -import { removeOne, removeMany } from './remove' -import { IOPromise, startIO } from '../io-tools' - -const { trigger2, on, off } = eventsApi, - { begin, commit, markAsDirty } = transactionApi, - { omit, log, assign, defaults, assignToClassProto } = tools; - -let _count = 0; - -export type GenericComparator = string | ( ( x : Record ) => number ) | ( ( a : Record, b : Record ) => number ); - -export interface CollectionOptions extends TransactionOptions { - comparator? : GenericComparator - model? : typeof Record -} - -export type Predicate = ( val : R, key : number ) => boolean | object; - -export interface CollectionDefinition extends TransactionalDefinition { - model? : typeof Record, - itemEvents? : EventsDefinition - _itemEvents? : EventMap -} - -const slice = Array.prototype.slice; - -class CollectionRefsType extends SharedType { - static defaultValue = []; -} - -@define({ - // Default client id prefix - cidPrefix : 'c', - model : Record, - _changeEventName : 'changes', - _aggregationError : null -}) -@definitions({ - comparator : mixinRules.value, - model : mixinRules.protoValue, - itemEvents : mixinRules.merge -}) -export class Collection< R extends Record = Record> extends Transactional implements CollectionCore { - _shared : number - _aggregationError : R[] - - static Subset : typeof Collection - static Refs : typeof Collection - static _SubsetOf : typeof Collection - - createSubset( models : ElementsArg, options ){ - const SubsetOf = (this.constructor).subsetOf( this ).options.type, - subset = new SubsetOf( models, options ); - - subset.resolve( this ); - return subset; - } - - static onExtend( BaseClass : typeof Transactional ){ - // Cached subset collection must not be inherited. - const Ctor = this; - this._SubsetOf = null; - - function RefsCollection( a, b, listen? ){ - Ctor.call( this, a, b, ItemsBehavior.share | ( listen ? ItemsBehavior.listen : 0 ) ); - } - - Mixable.mixins.populate( RefsCollection ); - - RefsCollection.prototype = this.prototype; - RefsCollection._attribute = CollectionRefsType; - - this.Refs = this.Subset = RefsCollection; - - Transactional.onExtend.call( this, BaseClass ); - createSharedTypeSpec( this, SharedType ); - } - - static onDefine( definition : CollectionDefinition, BaseClass : any ){ - if( definition.itemEvents ){ - const eventsMap = new EventMap( BaseClass.prototype._itemEvents ); - eventsMap.addEventsMap( definition.itemEvents ); - this.prototype._itemEvents = eventsMap; - } - - if( definition.comparator !== void 0 ) this.prototype.comparator = definition.comparator; - - Transactional.onDefine.call( this, definition ); - } - - static subsetOf : ( collectionReference : any ) => any; - - _itemEvents : EventMap - - /*********************************** - * Core Members - */ - // Array of the records - models : R[] - - // Polymorphic accessor for aggregated attribute's canBeUpdated(). - get __inner_state__(){ return this.models; } - - // Index by id and cid - _byId : { [ id : string ] : R } - - set comparator( x : GenericComparator ){ - let compare; - - switch( typeof x ){ - case 'string' : - this._comparator = ( a, b ) => { - const aa = a[ x ], bb = b[ x ]; - if( aa === bb ) return 0; - return aa < bb ? -1 : + 1; - } - break; - case 'function' : - if( x.length === 1 ){ - this._comparator = ( a, b ) => { - const aa = (x).call( this, a ), bb = (x).call( this, b ); - if( aa === bb ) return 0; - return aa < bb ? -1 : + 1; - } - } - else{ - this._comparator = ( a, b ) => (x).call( this, a, b ); - } - break; - - default : - this._comparator = null; - } - } - - // TODO: Improve typing - getStore() : Transactional { - return this._store || ( this._store = this._owner ? this._owner.getStore() : this._defaultStore ); - } - - _store : Transactional - - get comparator(){ return this._comparator; } - _comparator : ( a : R, b : R ) => number - - _onChildrenChange( record : R, options : TransactionOptions = {}, initiator? : Transactional ){ - // Ignore updates from nested transactions. - if( initiator === this ) return; - - const { idAttribute } = this; - - if( record.hasChanged( idAttribute ) ){ - updateIndex( this._byId, record ); - } - - const isRoot = begin( this ); - - if( markAsDirty( this, options ) ){ - // Forward change event from the record. - trigger2( this, 'change', record, options ) - } - - isRoot && commit( this ); - } - - get( objOrId : string | R | Object ) : R { - if( objOrId == null ) return; - - if( typeof objOrId === 'object' ){ - const id = objOrId[ this.idAttribute ]; - return ( id !== void 0 && this._byId[ id ] ) || this._byId[ (objOrId).cid ]; - } - else{ - return this._byId[ objOrId ]; - } - } - - each( iteratee : ( val : R, key : number ) => void, context? : any ){ - const fun = bindContext( iteratee, context ), - { models } = this; - - for( let i = 0; i < models.length; i++ ){ - fun( models[ i ], i ); - } - } - - forEach( iteratee : ( val : R, key? : number ) => void, context? : any ){ - return this.each( iteratee, context ); - } - - every( iteratee : Predicate, context? : any ) : boolean { - const fun = toPredicateFunction( iteratee, context ), - { models } = this; - - for( let i = 0; i < models.length; i++ ){ - if( !fun( models[ i ], i ) ) return false; - } - - return true; - } - - filter( iteratee : Predicate, context? : any ) : R[] { - const fun = toPredicateFunction( iteratee, context ), - { models } = this; - - return this.map( ( x, i ) => fun( x, i ) ? x : void 0 ); - } - - find( iteratee : Predicate, context? : any ) : R { - const fun = toPredicateFunction( iteratee, context ), - { models } = this; - - for( let i = 0; i < models.length; i++ ){ - if( fun( models[ i ], i ) ) return models[ i ]; - } - - return null; - } - - some( iteratee : Predicate, context? : any ) : boolean { - return Boolean( this.find( iteratee, context ) ); - } - - map< T >( iteratee : ( val : R, key : number ) => T, context? : any ) : T[]{ - const fun = bindContext( iteratee, context ), - { models } = this, - mapped = Array( models.length ); - - let j = 0; - - for( let i = 0; i < models.length; i++ ){ - const x = fun( models[ i ], i ); - x === void 0 || ( mapped[ j++ ] = x ); - } - - mapped.length = j; - - return mapped; - } - - _validateNested( errors : {} ) : number { - // Don't validate if not aggregated. - if( this._shared ) return 0; - - let count = 0; - - this.each( record => { - const error = record.validationError; - if( error ){ - errors[ record.cid ] = error; - count++; - } - }); - - return count; - } - - model : typeof Record - - // idAttribute extracted from the model type. - idAttribute : string - - constructor( records? : ( R | {} )[], options : CollectionOptions = {}, shared? : number ){ - super( _count++ ); - this.models = []; - this._byId = {}; - - this.comparator = this.comparator; - - if( options.comparator !== void 0 ){ - this.comparator = options.comparator; - options.comparator = void 0; - } - - this.model = this.model; - - if( options.model ){ - this.model = options.model; - options.model = void 0; - } - - this.idAttribute = this.model.prototype.idAttribute; //TODO: Remove? - - this._shared = shared || 0; - - if( records ){ - const elements = toElements( this, records, options ); - emptySetTransaction( this, elements, options, true ); - } - - this.initialize.apply( this, arguments ); - - if( this._localEvents ) this._localEvents.subscribe( this, this ); - } - - initialize(){} - - get length() : number { return this.models.length; } - first() : R { return this.models[ 0 ]; } - last() : R { return this.models[ this.models.length - 1 ]; } - at( a_index : number ) : R { - const index = a_index < 0 ? a_index + this.models.length : a_index; - return this.models[ index ]; - } - - // Deeply clone collection, optionally setting new owner. - clone( options : CloneOptions = {} ) : this { - const models = this._shared & ItemsBehavior.share ? this.models : this.map( model => model.clone() ), - copy : this = new (this.constructor)( models, { model : this.model, comparator : this.comparator }, this._shared ); - - if( options.pinStore ) copy._defaultStore = this.getStore(); - - return copy; - } - - toJSON( options? : object ) : any { - return this.models.map( model => model.toJSON( options ) ); - } - - // Apply bulk in-place object update in scope of ad-hoc transaction - set( elements : ElementsArg = [], options : TransactionOptions = {} ) : this { - if( (options).add !== void 0 ){ - this._log( 'warn', "Collection.set doesn't support 'add' option, behaving as if options.add === true.", options ); - } - - // Handle reset option here - no way it will be populated from the top as nested transaction. - if( options.reset ){ - this.reset( elements, options ) - } - else{ - const transaction = this._createTransaction( elements, options ); - transaction && transaction.commit(); - } - - return this; - } - - /** - * Enable or disable live updates. - * - * `true` enables full collection synchronization. - * `false` cancel live updates. - * `json => true | false` - filter updates - */ - liveUpdates( enabled : LiveUpdatesOption ) : IOPromise { - if( enabled ){ - this.liveUpdates( false ); - - const filter = typeof enabled === 'function' ? enabled : () => true; - - this._liveUpdates = { - updated : json => { - filter( json ) && this.add( json, { parse : true, merge : true } ); - }, - - removed : id => this.remove( id ) - }; - - return this.getEndpoint().subscribe( this._liveUpdates, this ).then( () => this ); - } - else{ - if( this._liveUpdates ){ - this.getEndpoint().unsubscribe( this._liveUpdates, this ); - this._liveUpdates = null; - } - } - } - - _liveUpdates : object - - fetch( a_options : { liveUpdates? : LiveUpdatesOption } & TransactionOptions = {} ) : IOPromise { - const options = { parse : true, ...a_options }, - endpoint = this.getEndpoint(); - - return startIO( - this, - endpoint.list( options, this ), - options, - - json => { - let result : any = this.set( json, { parse : true, ...options } as TransactionOptions ); - - if( options.liveUpdates ){ - result = this.liveUpdates( options.liveUpdates ); - } - - return result; - } - ); - } - - dispose() : void { - if( this._disposed ) return; - - const aggregated = !this._shared; - - for( let record of this.models ){ - free( this, record ); - - if( aggregated ) record.dispose(); - } - - this.liveUpdates( false ); - - super.dispose(); - } - - reset( a_elements? : ElementsArg, options : TransactionOptions = {} ) : R[] { - const isRoot = begin( this ), - previousModels = this.models; - - // Make all changes required, but be silent. - if( a_elements ){ - emptySetTransaction( this, toElements( this, a_elements, options ), options, true ); - } - else{ - this._byId = {}; - this.models = []; - } - - markAsDirty( this, options ); - - options.silent || trigger2( this, 'reset', this, defaults( { previousModels : previousModels }, options ) ); - - // Dispose models which are not in the updated collection. - const { _byId } = this; - - for( let toDispose of previousModels ){ - _byId[ toDispose.cid ] || free( this, toDispose ); - } - - isRoot && commit( this ); - return this.models; - } - - // Add elements to collection. - add( a_elements : ElementsArg , options : AddOptions = {} ){ - const elements = toElements( this, a_elements, options ), - transaction = this.models.length ? - addTransaction( this, elements, options ) : - emptySetTransaction( this, elements, options ); - - if( transaction ){ - transaction.commit(); - return transaction.added; - } - } - - // Remove elements. - remove( recordsOrIds : any, options : CollectionOptions = {} ) : R[] | R { - if( recordsOrIds ){ - return Array.isArray( recordsOrIds ) ? - removeMany( this, recordsOrIds, options ) as R[]: - removeOne( this, recordsOrIds, options ) as R; - } - - return []; - } - - // Apply bulk object update without any notifications, and return open transaction. - // Used internally to implement two-phase commit. - _createTransaction( a_elements : ElementsArg, options : TransactionOptions = {} ) : CollectionTransaction | void { - const elements = toElements( this, a_elements, options ); - - if( this.models.length ){ - return options.remove === false ? - addTransaction( this, elements, options, true ) : - setTransaction( this, elements, options ); - } - else{ - return emptySetTransaction( this, elements, options ); - } - } - - static _attribute = AggregatedType; - - /*********************************** - * Collection manipulation methods - */ - - pluck( key : keyof R ) : any[] { - return this.models.map( model => model[ key ] ); - } - - sort( options : TransactionOptions = {} ) : this { - if( sortElements( this, options ) ){ - const isRoot = begin( this ); - - if( markAsDirty( this, options ) ){ - trigger2( this, 'sort', this, options ); - } - - isRoot && commit( this ); - } - - return this; - } - - // Add a model to the end of the collection. - push(model : ElementsArg, options : CollectionOptions ) { - return this.add(model, assign({at: this.length}, options)); - } - - // Remove a model from the end of the collection. - pop( options : CollectionOptions ) : R { - var model = this.at(this.length - 1); - this.remove(model, { unset : true, ...options }); - return model; - } - - // Remove and return given model. - // TODO: do not dispose the model for aggregated collection. - unset( modelOrId : R | string, options? ) : R { - const value = this.get( modelOrId ); - this.remove( modelOrId, { unset : true, ...options } ); - return value; - } - - // Add a model to the beginning of the collection. - unshift(model : ElementsArg, options : CollectionOptions ) { - return this.add(model, assign({at: 0}, options)); - } - - // Remove a model from the beginning of the collection. - shift( options? : CollectionOptions ) : R { - var model = this.at(0); - this.remove( model, { unset : true, ...options } ); - return model; - } - - // Slice out a sub-array of models from the collection. - slice() : R[] { - return slice.apply(this.models, arguments); - } - - indexOf( modelOrId : any ) : number { - const record = this.get( modelOrId ); - return this.models.indexOf( record ); - } - - modelId( attrs : {} ) : any { - return attrs[ this.model.prototype.idAttribute ]; - } - - // Toggle model in collection. - toggle( model : R, a_next? : boolean ) : boolean { - var prev = Boolean( this.get( model ) ), - next = a_next === void 0 ? !prev : Boolean( a_next ); - - if( prev !== next ){ - if( prev ){ - this.remove( model ); - } - else{ - this.add( model ); - } - } - - return next; - } - - _log( level : tools.LogLevel, text : string, value ) : void { - tools.log( level, `[Collection Update] ${ this.model.prototype.getClassName() }.${ this.getClassName() }: ` + text, { - Argument : value, - 'Attributes spec' : this.model.prototype._attributes - }); - } - - getClassName() : string { - return super.getClassName() || 'Collection'; - } -} - -export type LiveUpdatesOption = boolean | ( ( x : any ) => boolean ); - -export type ElementsArg = Object | Record | Object[] | Record[]; - -// TODO: make is safe for parse to return null (?) -function toElements( collection : Collection, elements : ElementsArg, options : CollectionOptions ) : Elements { - const parsed = options.parse ? collection.parse( elements, options ) : elements; - return Array.isArray( parsed ) ? parsed : [ parsed ]; -} - -createSharedTypeSpec( Collection, SharedType ); - -Record.Collection = Collection; - -function bindContext( fun : Function, context? : any ){ - return context !== void 0 ? ( v, k ) => fun.call( context, v, k ) : fun; -} - -function toPredicateFunction( iteratee : Predicate, context : any ){ - if( typeof iteratee === 'object' ){ - // Wrap object to the predicate... - return x => { - for( let key in iteratee as any ){ - if( iteratee[ key ] !== x[ key ] ) - return false; - } - - return true; - } - } - - return bindContext( iteratee, context ); - -} \ No newline at end of file diff --git a/src/type-r/collection/remove.ts b/src/type-r/collection/remove.ts deleted file mode 100644 index 2ae1b5b..0000000 --- a/src/type-r/collection/remove.ts +++ /dev/null @@ -1,114 +0,0 @@ -/************* - * Remove items from collections. - * - * Cannot be a part of two-phase transaction on object tree. - * Can be executed in the scope of ad-hoc transaction or from the trigger, though. - * - * Implemented with low-level API. - * Most frequent operation - single element remove. Thus, it have the fast-path. - */ - -import { Record } from '../record' -import { free, CollectionCore, CollectionTransaction, removeIndex } from './commons' -import { eventsApi } from '../object-plus' -import { TransactionOptions, transactionApi } from '../transactions' - -const { trigger2, trigger3 } = eventsApi, - { markAsDirty, begin, commit } = transactionApi; - -/** @private */ -export function removeOne( collection : CollectionCore, el : Record | {} | string, options : TransactionOptions ) : Record { - var model : Record = collection.get( el ); - - if( model ){ - const isRoot = begin( collection ), - models = collection.models; - - // Remove model form the collection. - models.splice( models.indexOf( model ), 1 ); - removeIndex( collection._byId, model ); - - // Mark transaction as dirty. - const notify = markAsDirty( collection, options ); - - // Send out events. - if( notify ){ - trigger3( model, 'remove', model, collection, options ); - trigger3( collection, 'remove', model, collection, options ); - } - - free( collection, model, options.unset ); - - notify && trigger2( collection, 'update', collection, options ); - - // Commit transaction. - isRoot && commit( collection ); - - return model; - } -}; - -/** Optimized for removing many elements - * 1. Remove elements from the index, checking for duplicates - * 2. Create new models array matching index - * 3. Send notifications and remove references - */ - -/** @private */ -export function removeMany( collection : CollectionCore, toRemove : any[], options ){ - const removed = _removeFromIndex( collection, toRemove, options.unset ); - if( removed.length ){ - const isRoot = begin( collection ); - - _reallocate( collection, removed.length ); - - if( markAsDirty( collection, options ) ){ - const transaction = new CollectionTransaction( collection, isRoot, [], removed, [], false ); - transaction.commit(); - } - else{ - // Commit transaction. - isRoot && commit( collection ); - } - } - - return removed; -}; - -// remove models from the index... -/** @private */ -function _removeFromIndex( collection, toRemove, unset : boolean ){ - var removed = Array( toRemove.length ), - _byId = collection._byId; - - for( var i = 0, j = 0; i < toRemove.length; i++ ){ - var model = collection.get( toRemove[ i ] ); - if( model ){ - removed[ j++ ] = model; - removeIndex( _byId, model ); - free( collection, model, unset ); - } - } - - removed.length = j; - - return removed; -} - -// Allocate new models array removing models not present in the index. -/** @private */ -function _reallocate( collection, removed ){ - var prev = collection.models, - models = collection.models = Array( prev.length - removed ), - _byId = collection._byId; - - for( var i = 0, j = 0; i < prev.length; i++ ){ - var model = prev[ i ]; - - if( _byId[ model.cid ] ){ - models[ j++ ] = model; - } - } - - models.length = j; -} \ No newline at end of file diff --git a/src/type-r/collection/set.ts b/src/type-r/collection/set.ts deleted file mode 100644 index 3eedce3..0000000 --- a/src/type-r/collection/set.ts +++ /dev/null @@ -1,154 +0,0 @@ -import { Transaction, transactionApi } from '../transactions' -import { CollectionTransaction, logAggregationError, IdIndex, convertAndAquire, free, sortElements, CollectionOptions, addIndex, CollectionCore, Elements, freeAll } from './commons' -import { Record } from '../record' - -const { begin, commit, markAsDirty } = transactionApi; - -/** @private */ -const silentOptions = { silent : true }; - -/** @private */ -export function emptySetTransaction( collection : CollectionCore, items : Elements, options : CollectionOptions, silent? : boolean ){ - const isRoot = begin( collection ); - - const added = _reallocateEmpty( collection, items, options ); - - if( added.length ){ - const needSort = sortElements( collection, options ); - - if( markAsDirty( collection, silent ? silentOptions : options ) ){ - // 'added' is the reference to this.models. Need to copy it. - return new CollectionTransaction( collection, isRoot, added.slice(), [], [], needSort ); - } - - if( collection._aggregationError ) logAggregationError( collection ); - } - - // No changes... - isRoot && commit( collection ); -}; - -/** @private */ -export function setTransaction( collection, items, options ){ - const isRoot = begin( collection ), - nested = []; - - var previous = collection.models, - added = _reallocate( collection, items, nested, options ); - - const reusedCount = collection.models.length - added.length, - removed = reusedCount < previous.length ? ( - reusedCount ? _garbageCollect( collection, previous ) : - freeAll( collection, previous ) - ) : []; - - const addedOrChanged = nested.length || added.length, - // As we are reallocating models array, it needs to be sorted even if there are no changes. - sorted = ( sortElements( collection, options ) && addedOrChanged ) || added.length || options.sorted; - - if( addedOrChanged || removed.length || sorted ){ - if( markAsDirty( collection, options ) ){ - return new CollectionTransaction( collection, isRoot, added, removed, nested, sorted ); - } - - if( collection._aggregationError ) logAggregationError( collection ); - } - - isRoot && commit( collection ); -}; - -// Remove references to all previous elements, which are not present in collection. -// Returns an array with removed elements. -/** @private */ -function _garbageCollect( collection : CollectionCore, previous : Record[] ) : Record[]{ - const { _byId } = collection, - removed = []; - - // Filter out removed models and remove them from the index... - for( let record of previous ){ - if( !_byId[ record.cid ] ){ - removed.push( record ); - free( collection, record ); - } - } - - return removed; -} - -// reallocate model and index -/** @private */ -function _reallocate( collection : CollectionCore, source : any[], nested : Transaction[], options ){ - var models = Array( source.length ), - _byId : IdIndex = {}, - merge = ( options.merge == null ? true : options.merge ) && !collection._shared, - _prevById = collection._byId, - prevModels = collection.models, - idAttribute = collection.model.prototype.idAttribute, - toAdd = [], - orderKept = true; - - // for each item in source set... - for( var i = 0, j = 0; i < source.length; i++ ){ - var item = source[ i ], - model : Record = null; - - if( item ){ - var id = item[ idAttribute ], - cid = item.cid; - - if( _byId[ id ] || _byId[ cid ] ) continue; - - model = _prevById[ id ] || _prevById[ cid ]; - } - - if( model ){ - if( merge && item !== model ){ - if( orderKept && prevModels[ j ] !== model ) orderKept = false; - - var attrs = item.attributes || item; - const transaction = model._createTransaction( attrs, options ); - transaction && nested.push( transaction ); - } - } - else{ - model = convertAndAquire( collection, item, options ); - toAdd.push( model ); - } - - models[ j++ ] = model; - addIndex( _byId, model ); - } - - models.length = j; - collection.models = models; - collection._byId = _byId; - - if( !orderKept ) options.sorted = true; - - return toAdd; -} - -/** @private */ -function _reallocateEmpty( self, source, options ){ - var len = source ? source.length : 0, - models = Array( len ), - _byId : IdIndex = {}, - idAttribute = self.model.prototype.idAttribute; - - for( var i = 0, j = 0; i < len; i++ ){ - var src = source[ i ]; - - if( src && ( _byId[ src[ idAttribute ] ] || _byId[ src.cid ] ) ){ - continue; - } - - var model = convertAndAquire( self, src, options ); - models[ j++ ] = model; - addIndex( _byId, model ); - } - - models.length = j; - self._byId = _byId; - - return self.models = models; -} \ No newline at end of file diff --git a/src/type-r/index.ts b/src/type-r/index.ts deleted file mode 100644 index 09ecf5c..0000000 --- a/src/type-r/index.ts +++ /dev/null @@ -1,61 +0,0 @@ -// Polyfill for IE10. Should fix problems with babel and statics inheritance. -import { tools } from './object-plus' - -declare global { - interface ObjectConstructor { - setPrototypeOf( target : Object, proto : Object ); - } -} - -Object.setPrototypeOf || ( Object.setPrototypeOf = tools.defaults ); - -/** - * Export everything - */ - -export * from './object-plus' -export * from './collection' -export * from './relations' -export * from './record' -export * from './transactions' - -export * from './io-tools' - -// Exported module itself is the global event bus. -import { Events } from './object-plus/' -export const { on, off, trigger, once, listenTo, stopListening, listenToOnce } = Events; - -import { Collection } from './collection' - -// Define synonims for NestedTypes backward compatibility. -import { Record as Model } from './record' -import { define, Mixable as Class } from './object-plus/' -export { Model, Class }; - -export function attributes( attrDefs ) : typeof Model { - @define class DefaultRecord extends Model { - static attributes = attrDefs; - } - - return DefaultRecord; -} - -import { ChainableAttributeSpec } from './record' - -/** Typeless attribute declaration with default value. */ -export function value( x : any ) : ChainableAttributeSpec { - return new ChainableAttributeSpec({ value : x }); -} - -/** Wrap model or collection method in transaction. */ -export function transaction< F extends Function >( method : F ) : F { - return function( ...args ){ - let result; - - this.transaction( () => { - result = method.apply( this, args ); - }); - - return result; - } -} \ No newline at end of file diff --git a/src/type-r/io-tools.ts b/src/type-r/io-tools.ts deleted file mode 100644 index 2659c2d..0000000 --- a/src/type-r/io-tools.ts +++ /dev/null @@ -1,116 +0,0 @@ -export interface IONode { - _endpoint : IOEndpoint - _ioPromise : IOPromise< this > -} - -export interface IOPromise extends Promise { - abort? : () => void -} - -export interface IOEndpoint { - list( options : IOOptions, collection? ) : IOPromise - create( json : any, options : IOOptions, record? ) : IOPromise - update( id : string | number, json :any, options : IOOptions, record? ) : IOPromise - read( id : string | number, options : IOOptions, record? ) : IOPromise - destroy( id : string | number, options : IOOptions, record? ) : IOPromise - subscribe( events : IOEvents, collection? ) : IOPromise - unsubscribe( events : IOEvents, collection? ) : void -} - -export interface IOOptions { - ioUpdate? : boolean -} - -export interface IOEvents { - updated? : ( json : any ) => void - removed? : ( json : any ) => void -} - -export function getOwnerEndpoint( self ) : IOEndpoint { - // Check if we are the member of the collection... - const { collection } = self; - if( collection ){ - return getOwnerEndpoint( collection ); - } - - // Now, if we're the member of the model... - if( self._owner ){ - const { _endpoints } = self._owner; - return _endpoints && _endpoints[ self._ownerKey ]; - } -} - -/** - * Create abortable promise. - * Adds `promise.abort()` function which rejects the promise by default - * initialize() function takes third optional argument `abort : ( resolve, reject ) => void`, - * which can be used to add custom abort handling. - */ -declare var Promise: PromiseConstructorLike; - -export function createIOPromise( initialize : InitIOPromise ) : IOPromise{ - let resolve, reject, onAbort; - - function abort( fn ){ - onAbort = fn; - } - - const promise : IOPromise = new Promise( ( a_resolve, a_reject ) =>{ - reject = a_reject; - resolve = a_resolve; - initialize( resolve, reject, abort ); - }) as IOPromise; - - promise.abort = () => { - onAbort ? onAbort( resolve, reject ) : reject( new Error( "I/O Aborted" ) ); - } - - return promise; -} - -export type InitIOPromise = ( resolve : ( x? : any ) => void, reject : ( x? : any ) => void, abort? : ( fn : Function ) => void ) => void; - -export function startIO( self : IONode, promise : IOPromise, options : IOOptions, thenDo : ( json : any ) => any ) : IOPromise { - // Stop pending I/O first... - abortIO( self ); - - // Mark future update transaction as IO transaction. - options.ioUpdate = true; - - self._ioPromise = promise - .then( resp => { - self._ioPromise = null; - - const result = thenDo ? thenDo( resp ) : resp; - - triggerAndBubble( self, 'sync', self, resp, options ); - - return result; - } ) - .catch( err => { - self._ioPromise = null; - - console.error( err ); - - triggerAndBubble( self, 'error', self, err, options ); - - throw err; - } ) as IOPromise; - - self._ioPromise.abort = promise.abort; - - return self._ioPromise; -} - -export function abortIO( self : IONode ){ - if( self._ioPromise && self._ioPromise.abort ){ - self._ioPromise.abort(); - self._ioPromise = null; - } -} - -export function triggerAndBubble( eventSource, ...args ){ - eventSource.trigger.apply( eventSource, args ); - const { collection } = eventSource; - collection && collection.trigger.apply( collection, args ); -} \ No newline at end of file diff --git a/src/type-r/object-plus/README.md b/src/type-r/object-plus/README.md deleted file mode 100644 index 6f58144..0000000 --- a/src/type-r/object-plus/README.md +++ /dev/null @@ -1,121 +0,0 @@ -# MixtureJS - -Mixins is very powerful abstraction addressing cross-cutting concerns, which can dramatically simplify inheritance graph when used wisely. - -MixtureJS is the toolkit combining React-style mixins, Backbone-style events, and minimal set of Underscore-style object manipulation functions. Just what you need when you're working in modern ES5/ES6 envorinment, packed in API which you already know. - -Written in TypeScript, works with ES5, ES6, and TypeScript. - -## Installation - -`npm install mixturejs` - -Packed as UMD, exports to global `Mixture` variable when included with script tag. - -> MixtureJS is the core part of [Volicon/Verizon](http://www.volicon.com/) technology stack - [Type-R](https://github.com/Volicon/Type-R), [NestedTypes](https://github.com/Volicon/NestedTypes), and [NestedReact](https://github.com/Volicon/NestedReact). - -## Events Performance - -MixtureJS _implements_ [Backbone API for Events](http://backbonejs.org/#Events), but it's entirely different internally. Here's the results of the typical -run of the [performance tests](https://github.com/Volicon/mixturejs/tree/master/tests) enclosed. - -![performance](https://raw.githubusercontent.com/Volicon/mixturejs/master/perf-chart.jpg) - -## Features - -- `Mixable`, React-style mixins implementation. - - Fine-grained control over member merge rules. - - Can mix both classes and plain objects. - - Works with and without ES6 class decorators. -- `Object.extend` to simulate classes in ES5. - - 100% backward compatible with Backbone `.extend()`. - - Complete `Mixable` support. - - Native properties declatations (`properties` specification). -- `Messenger`, synchronous events. - - Can be used as mixin and as a base class. - - 100% backward API compatibility with [Backbone Events](http://backbonejs.org/#Events) (passes Backbone 1.2.x unit test) - - Much faster than Backbone events. -- `tools` - - Object manipulation tools (`assign`, `defaults`, `mapObject`, etc). - - Simple logging API with variable log-level and overridable functions. Defaults to the `console`. - -## Backbone Events Compatibility - -`Mixture.Events` implements the complete semantic and API of [Backbone 1.1.x Events](http://backbonejs.org/#Events), with the following exceptions: - -- `source.trigger( 'ev1 ev2 ev3' )` is not supported. Use `source.trigger( 'ev1' ).trigger( 'ev2' ).trigger( 'ev3' )` instead. -- `source.trigger( 'ev', a, b, ... )` doesn't support more than 5 event parameters. -- `source.on( 'ev', callback )` - callback will _not_ be called in the context of `source` by default. - -## Mixins - -Both plain JS object and class constructor may be used as mixins. In the case of the class constructor, missing static members will copied over as well. - -You need to import `mixins` decorator to use mixins: - -```javascript -import { mixins } from 'mixturejs' - -... - -@mixins( plainObject, MyClass, ... ) -class X { - ... -} -``` - -### Merge Rules and React Compatibility - -MixtureJS implements _configurable_ merge rules, which allows to add standard React mixins functionality to the ES6 React Components. - -```javascript -import React from 'react' -import { Mixable } from 'mixturejs' - -// Make React.Component mixable... -Mixable.mixTo( React.Component ); - -// Define lifecycle methods merge rules... -React.Component.mixinRules({ - componentWillMount : 'reverse', - componentDidMount : 'reverse', - componentWillReceiveProps : 'reverse', - shouldComponentUpdate : 'some', - componentWillUpdate : 'reverse', - componentDidUpdate : 'reverse', - componentWillUnmount : 'sequence', -}); -``` - -Mixin merge rules can be extented in any subclass using the `@mixinRules({ attr : rule })` class decorator. Rule is the string from the following list. - -- *merge* - assume property to be an object, which members taken from mixins must be merged. -- *pipe* - property is the function `( x : T ) => T` transforming the value. Multiple functions joined in pipe. -- *sequence* - property is the function. Multiple functions will be called in sequence. -- *reverse* - same as *sequence*, but functions called in reverse sequence. -- *mergeSequence* - merge the object returned by functions, executing them in sequence. -- *every* - property is the function `( ...args : any[] ) => boolean`. Resulting method will return true if every single function returns true. -- *some* - same as previous, but method will return true when at least one function returns true. - -If merge rule is an object, the corresponding member is expected to be an object and the rule defines the merge rules for its members. - -### Usage Example - -Here we adding [Events](http://backbonejs.org/#Events) support (on, off, trigger, listenTo, etc.): - -```javascript -import React from 'react' -import { mixins, Events } from 'mixturejs' - -const UnsubscribeMixin = { - componentWillUnmount(){ - this.off(); - this.stopListening(); - } -} - -@mixins( Events, UnsubscribeMixin ) -class EventedComponent extends React.Component { - // ... -} -``` \ No newline at end of file diff --git a/src/type-r/object-plus/events.ts b/src/type-r/object-plus/events.ts deleted file mode 100644 index da6e241..0000000 --- a/src/type-r/object-plus/events.ts +++ /dev/null @@ -1,210 +0,0 @@ -import { define, mixins, Mixable, Mixin, MixableConstructor, MixinsState, mixinRules, definitions, MixinMergeRules } from './mixins' -import { omit, transform } from './tools' -import { EventMap, EventsDefinition, EventSource, HandlersByEvent } from './eventsource' -import * as _eventsApi from './eventsource' - -const { EventHandler, strings, on, off, once, trigger5, trigger2, trigger3 } = _eventsApi; - -/** @hidden */ -const eventSplitter = /\s+/; - -/** @hidden */ -let _idCount = 0; - -/** @hidden */ -function uniqueId() : string { - return 'l' + _idCount++; -} - -export { EventMap, EventsDefinition } - -export interface MessengerDefinition { - _localEvents? : EventMap - localEvents? : EventsDefinition - properties? : PropertyMap - [ name : string ] : any -} - -export interface PropertyMap { - [ name : string ] : Property -} - -export type Property = PropertyDescriptor | ( () => any ) - -/** @hidden */ -export interface MessengersByCid { - [ cid : string ] : Messenger -} - -/** @hidden */ -export type CallbacksByEvents = { [ events : string ] : Function } - -/************************* - * Messenger is mixable class with capabilities of sending and receiving synchronous events. - * This class itself can serve as both mixin and base class. - */ - -@define -@definitions({ - properties : mixinRules.merge, - localEvents : mixinRules.merge -}) -export abstract class Messenger implements Mixable, EventSource { - // Define extendable mixin static properties. - static __super__ : object; - static mixins : MixinsState; - static onExtend : ( BaseClass : Function ) => void; - static define : ( definition? : MessengerDefinition, statics? : object ) => MixableConstructor; - static extend : ( definition? : MessengerDefinition, statics? : object ) => MixableConstructor; - static onDefine({ localEvents, _localEvents, properties } : MessengerDefinition, BaseClass? : typeof Mixable ){ - // Handle localEvents definition - if( localEvents || _localEvents ){ - const eventsMap = new EventMap( this.prototype._localEvents ); - - localEvents && eventsMap.addEventsMap( localEvents ); - _localEvents && eventsMap.merge( _localEvents ); - - this.prototype._localEvents = eventsMap; - } - - // Handle properties definitions... - if( properties ){ - Object.defineProperties( this.prototype, transform( {}, properties, toPropertyDescriptor ) ); - } - } - - /** @hidden */ - _events : HandlersByEvent = void 0; - - /** @hidden */ - _listeningTo : MessengersByCid = void 0 - - /** Unique client-only id. */ - cid : string - - /** @hidden Prototype-only property to manage automatic local events subscription */ - _localEvents : EventMap - - /** @hidden */ - constructor(){ - this.cid = uniqueId(); - this.initialize.apply( this, arguments ); - - // TODO: local events subscribe? - } - - /** Method is called at the end of the constructor */ - initialize() : void {} - - on( events : string | CallbacksByEvents, callback, context? ) : this { - if( typeof events === 'string' ) strings( on, this, events, callback, context ); - else for( let name in events ) strings( on, this, name, events[ name ], context || callback ); - - return this; - } - - once( events : string | CallbacksByEvents, callback, context? ) : this { - if( typeof events === 'string' ) strings( once, this, events, callback, context ); - else for( let name in events ) strings( once, this, name, events[ name ], context || callback ); - - return this; - } - - off( events? : string | CallbacksByEvents, callback?, context? ) : this { - if( !events ) off( this, void 0, callback, context ); - else if( typeof events === 'string' ) strings( off, this, events, callback, context ); - else for( let name in events ) strings( off, this, name, events[ name ], context || callback ); - - return this; - } - - // Trigger one or many events, firing all bound callbacks. Callbacks are - // passed the same arguments as `trigger` is, apart from the event name - // (unless you're listening on `"all"`, which will cause your callback to - // receive the true name of the event as the first argument). - trigger(name : string, a?, b?, c?, d?, e? ) : this { - if( d !== void 0 || e !== void 0 ) trigger5( this, name, a, b, c, d, e ); - else if( c !== void 0 ) trigger3( this, name, a, b, c ); - else trigger2( this, name, a, b ); - return this; - } - - listenTo( source : Messenger, a : string | CallbacksByEvents, b? : Function ) : this { - if( source ){ - addReference( this, source ); - source.on( a, !b && typeof a === 'object' ? this : b, this ); - } - - return this; - } - - listenToOnce( source : Messenger, a : string | CallbacksByEvents, b? : Function ) : this { - if( source ){ - addReference( this, source ); - source.once( a, !b && typeof a === 'object' ? this : b, this ); - } - - return this; - } - - stopListening( a_source? : Messenger, a? : string | CallbacksByEvents, b? : Function ) : this { - const { _listeningTo } = this; - if( _listeningTo ){ - const removeAll = !( a || b ), - second = !b && typeof a === 'object' ? this : b; - - if( a_source ){ - const source = _listeningTo[ a_source.cid ]; - if( source ){ - if( removeAll ) delete _listeningTo[ a_source.cid ]; - source.off( a, second, this ); - } - } - else if( a_source == null ){ - for( let cid in _listeningTo ) _listeningTo[ cid ].off( a, second, this ); - - if( removeAll ) ( this._listeningTo = void 0 ); - } - } - - return this; - } - - /** - * Destructor. Stops messenger from listening to all objects, - * and stop others from listening to the messenger. - */ - _disposed : boolean - - dispose() : void { - if( this._disposed ) return; - - this.stopListening(); - this.off(); - - this._disposed = true; - } -} - -/** - * Backbone 1.2 API conformant Events mixin. - */ -export const Events : Messenger = omit( Messenger.prototype, 'constructor', 'initialize' ); - -/** - * Messenger Private Helpers - */ - -function toPropertyDescriptor( x : Property ) : PropertyDescriptor { - if( x ){ - return typeof x === 'function' ? { get : < () => any >x } : x; - } -} - -/** @hidden */ -function addReference( listener : Messenger, source : Messenger ){ - const listeningTo = listener._listeningTo || (listener._listeningTo = Object.create( null ) ), - cid = source.cid || ( source.cid = uniqueId() ); - - listeningTo[ cid ] = source; -} \ No newline at end of file diff --git a/src/type-r/object-plus/eventsource.ts b/src/type-r/object-plus/eventsource.ts deleted file mode 100644 index e55c4fd..0000000 --- a/src/type-r/object-plus/eventsource.ts +++ /dev/null @@ -1,273 +0,0 @@ -import { once as _once } from './tools' - -/******************* - * Prebuilt events map, used for optimized bulk event subscriptions. - * - * const events = new EventMap({ - * 'change' : true, // Resend this event from self as it is. - * 'change:attr' : 'localTargetFunction', - * 'executedInTargetContext' : function(){ ... } - * 'executedInNativeContext' : '^props.handler' - * }) - */ -/** @hidden */ -export interface EventsDefinition { - [ events : string ] : Function | string | boolean -} - -/** @hidden */ -export class EventMap { - handlers : EventDescriptor[] = []; - - constructor( map? : EventsDefinition | EventMap ){ - if( map ){ - if( map instanceof EventMap ){ - this.handlers = map.handlers.slice(); - } - else{ - map && this.addEventsMap( map ); - } - } - } - - merge( map : EventMap ){ - this.handlers = this.handlers.concat( map.handlers ); - } - - addEventsMap( map : EventsDefinition ){ - for( let names in map ){ - this.addEvent( names, map[ names ] ) - } - } - - bubbleEvents( names : string ){ - for( let name of names.split( eventSplitter ) ){ - this.addEvent( name, getBubblingHandler( name ) ); - } - } - - addEvent( names : string, callback : Function | string | boolean ){ - const { handlers } = this; - - for( let name of names.split( eventSplitter ) ){ - handlers.push( new EventDescriptor( name, callback ) ); - } - } - - subscribe( target : {}, source : EventSource ){ - for( let event of this.handlers ){ - on( source, event.name, event.callback, target ); - } - } - - unsubscribe( target : {}, source : EventSource ){ - for( let event of this.handlers ){ - off( source, event.name, event.callback, target ); - } - } -} - -/** @hidden */ -export class EventDescriptor { - callback : Function - - constructor( - public name : string, - callback : Function | string | boolean - ){ - if( callback === true ){ - this.callback = getBubblingHandler( name ); - } - else if( typeof callback === 'string' ){ - this.callback = - function localCallback(){ - const handler = this[ callback ]; - handler && handler.apply( this, arguments ); - }; - } - else{ - this.callback = callback; - } - } -} - -/** @hidden */ -const _bubblingHandlers = {}; - -/** @hidden */ -function getBubblingHandler( event : string ){ - return _bubblingHandlers[ event ] || ( - _bubblingHandlers[ event ] = function( a?, b?, c?, d?, e? ){ - if( d !== void 0 || e !== void 0 ) trigger5( this, event, a, b, c, d, e ); - if( c !== void 0 ) trigger3( this, event, a, b, c ); - else trigger2( this, event, a, b ); - } - ); -} - -/** @hidden */ -export interface HandlersByEvent { - [ name : string ] : EventHandler -} - -/** @hidden */ -export class EventHandler { - constructor( public callback : Callback, public context : any, public next = null ){} -} - -/** @hidden */ -function listOff( _events : HandlersByEvent, name : string, callback : Callback, context : any ){ - const head = _events[ name ]; - - let filteredHead, prev; - - for( let ev = head; ev; ev = ev.next ){ - // Element must be kept - if( ( callback && callback !== ev.callback && callback !== ev.callback._callback ) || - ( context && context !== ev.context ) ){ - - prev = ev; - filteredHead || ( filteredHead = ev ); - } - // Element must be skipped - else{ - if( prev ) prev.next = ev.next; - } - } - - if( head !== filteredHead ) _events[ name ] = filteredHead; -} - -/** @hidden */ -function listSend2( head : EventHandler, a, b ){ - for( let ev = head; ev; ev = ev.next ) ev.callback.call( ev.context, a, b ); -} - -/** @hidden */ -function listSend3( head : EventHandler, a, b, c ){ - for( let ev = head; ev; ev = ev.next ) ev.callback.call( ev.context, a, b, c ); -} - -/** @hidden */ -function listSend4( head : EventHandler, a, b, c, d ){ - for( let ev = head; ev; ev = ev.next ) ev.callback.call( ev.context, a, b, c, d ); -} - -/** @hidden */ -function listSend5( head : EventHandler, a, b, c, d, e ){ - for( let ev = head; ev; ev = ev.next ) ev.callback.call( ev.context, a, b, c, d, e ); -} - -/** @hidden */ -function listSend6( head : EventHandler, a, b, c, d, e, f ){ - for( let ev = head; ev; ev = ev.next ) ev.callback.call( ev.context, a, b, c, d, e, f ); -} - -/** @hidden */ -export interface Callback extends Function { - _callback? : Function -} - -/** @hidden */ -export function on( source : EventSource, name : string, callback : Callback, context? : any ) : void { - if( callback ){ - const _events = source._events || ( source._events = Object.create( null ) ); - _events[ name ] = new EventHandler( callback, context, _events[ name ] ); - } -} - -/** @hidden */ -export function once( source : EventSource, name : string, callback : Callback, context? : any ) : void { - if( callback ){ - const once : Callback = _once( function(){ - off( source, name, once ); - callback.apply(this, arguments); - }); - - once._callback = callback; - on( source, name, once, context ); - } -} - -/** @hidden */ -export function off( source : EventSource, name? : string, callback? : Callback, context? : any ) : void { - const { _events } = source; - if( _events ){ - if( callback || context ) { - if( name ){ - listOff( _events, name, callback, context ); - } - else{ - for( let name in _events ){ - listOff( _events, name, callback, context ); - } - } - } - else if( name ){ - _events[ name ] = void 0; - } - else{ - source._events = void 0; - } - } -} - -/** @hidden */ -export interface EventSource { - _events : HandlersByEvent -} - -/** @hidden */ -const eventSplitter = /\s+/; - -/** @hidden */ -export function strings( api : ApiEntry, source : EventSource, events : string, callback : Callback, context ){ - if( eventSplitter.test( events ) ){ - const names = events.split( eventSplitter ); - for( let name of names ) api( source, name, callback, context ); - } - else api( source, events, callback, context ); -} - -/** @hidden */ -export type ApiEntry = ( source : EventSource, event : string, callback : Callback, context? : any ) => void - -/********************************* - * Event-triggering API - */ - -/** @hidden */ -export function trigger2( self : EventSource, name : string, a, b ) : void { - const { _events } = self; - if( _events ){ - const queue = _events[ name ], - { all } = _events; - - listSend2( queue, a, b ); - listSend3( all, name, a, b ); - } -}; - -/** @hidden */ -export function trigger3( self : EventSource, name : string, a, b, c ) : void{ - const { _events } = self; - if( _events ){ - const queue = _events[ name ], - { all } = _events; - - listSend3( queue, a, b, c ); - listSend4( all, name, a, b, c ); - } -}; - -/** @hidden */ -export function trigger5( self : EventSource, name : string, a, b, c, d, e ) : void{ - const { _events } = self; - if( _events ){ - const queue = _events[ name ], - { all } = _events; - - listSend5( queue, a, b, c, d, e ); - listSend6( all, name, a, b, c, d, e ); - } -}; \ No newline at end of file diff --git a/src/type-r/object-plus/index.ts b/src/type-r/object-plus/index.ts deleted file mode 100644 index d08fb80..0000000 --- a/src/type-r/object-plus/index.ts +++ /dev/null @@ -1,28 +0,0 @@ -// (c) 2016 Vlad Balin and Volicon -// MixtureJS may be freely distributed under the MIT license. - -import * as tools from './tools' -export { tools } -export * from './mixins' -export * from './events' -import * as eventsApi from './eventsource' -export { eventsApi } - -import { Mixable, MixableConstructor } from './mixins' - -declare global { - interface ObjectConstructor { - /** Polyfill for Object.assign */ - assign< T >( dest : T, ...sources : Object[] ) : T - - /** Global logging interface, for console debugging. */ - log : tools.Log - - /** ES5 Object.extend */ - extend( protoProps : {}, staticProps : {} ) : MixableConstructor - } -} - -Object.extend = ( protoProps, staticProps ) => Mixable.extend( protoProps, staticProps ); -Object.assign || ( Object.assign = tools.assign ); -Object.log = tools.log; \ No newline at end of file diff --git a/src/type-r/object-plus/mixins.ts b/src/type-r/object-plus/mixins.ts deleted file mode 100644 index 086faa0..0000000 --- a/src/type-r/object-plus/mixins.ts +++ /dev/null @@ -1,407 +0,0 @@ -/***************************************************************** - * Mixins engine and @define metaprogramming class extensions - * - * Vlad Balin & Volicon, (c) 2016-2017 - */ -import { log, assign, omit, hashMap, getPropertyDescriptor, getBaseClass, defaults, transform } from './tools' -import { __extends } from 'tslib' - -export interface Subclass< T > extends MixableConstructor { - new ( ...args ) : T - prototype : T -} - -export interface MixableConstructor extends Function{ - __super__? : object; - mixins? : MixinsState; - onExtend? : ( BaseClass : Function ) => void; - onDefine? : ( definition : object, BaseClass : Function ) => void; - define? : ( definition? : object, statics? : object ) => MixableConstructor; - extend? : ( definition? : T, statics? : object ) => Subclass; -} - -export interface MixableDefinition { - mixins? : Mixin[] -} - -/** - * Base class, holding metaprogramming class extensions. - * Supports mixins and Class.define metaprogramming method. - */ -export class Mixable { - static onExtend : ( BaseClass : Function ) => void; - static onDefine : ( definition : object, BaseClass : Function ) => object; - static __super__ : object - static mixins : MixinsState; - - /** - * Must be called after inheritance and before 'define'. - */ - static define( protoProps : MixableDefinition = {}, staticProps? : object ) : MixableConstructor { - const BaseClass : MixableConstructor = getBaseClass( this ); - - // Assign statics. - staticProps && assign( this, staticProps ); - - // Extract and apply mixins from the definition. - const { mixins, ...defineMixin } = protoProps; - mixins && this.mixins.merge( mixins ); - - // Unshift definition to the the prototype. - this.mixins.mergeObject( this.prototype, defineMixin, true ); - - // Unshift definition from statics to the prototype. - this.mixins.mergeObject( this.prototype, this.mixins.getStaticDefinitions( BaseClass ), true ); - - // Call onDefine hook, if it's present. - this.onDefine && this.onDefine( this.mixins.definitions, BaseClass ); - - // Apply merge rules to inherited members. No mixins can be added after this point. - this.mixins.mergeInheritedMembers( BaseClass ); - - return this; - } - - /** Backbone-compatible extend method to be used in ES5 and for backward compatibility */ - static extend< T extends object>(spec? : T, statics? : {} ) : Subclass< T > { - let TheSubclass : Subclass< T >; - - // 1. Create the subclass (ES5 compatibility shim). - // If constructor function is given... - if( spec && spec.hasOwnProperty( 'constructor' ) ){ - // ...we need to manually call internal TypeScript __extend function. Hack! Hack! - TheSubclass = spec.constructor as any; - __extends( TheSubclass, this ); - } - // Otherwise, create the subclall in usual way. - else{ - TheSubclass = class Subclass extends this {} as any; - } - - predefine( TheSubclass ); - spec && TheSubclass.define( spec, statics ); - - return TheSubclass; - } -} - -/** @decorator `@predefine` for forward definitions. Can be used with [[Mixable]] classes only. - * Forwards the call to the [[Mixable.predefine]]; - */ -export function predefine( Constructor : MixableConstructor ) : void { - const BaseClass : MixableConstructor = getBaseClass( Constructor ); - - // Legacy systems support - Constructor.__super__ = BaseClass.prototype; - - // Initialize mixins structures... - Constructor.define || MixinsState.get( Mixable ).populate( Constructor ); - - // Make sure Ctor.mixins are ready before the callback... - MixinsState.get( Constructor ); - - // Call extend hook. - Constructor.onExtend && Constructor.onExtend( BaseClass ); -} - -/** @decorator `@define` for metaprogramming magic. Can be used with [[Mixable]] classes only. - * Forwards the call to [[Mixable.define]]. - */ -export function define( ClassOrDefinition : Function ) : void; -export function define( ClassOrDefinition : object ) : ClassDecorator; -export function define( ClassOrDefinition : object | MixableConstructor ){ - // @define class - if( typeof ClassOrDefinition === 'function' ){ - predefine( ClassOrDefinition ); - ClassOrDefinition.define(); - } - // @define({ prop : val, ... }) class - else{ - return function( Ctor : MixableConstructor ){ - predefine( Ctor ); - Ctor.define( ClassOrDefinition ); - } - } -} - -export function definitions( rules : MixinMergeRules ) : ClassDecorator { - return ( Class : Function ) => { - const mixins = MixinsState.get( Class ); - mixins.definitionRules = defaults( hashMap(), rules, mixins.definitionRules ); - } -} - -// Create simple property list decorator -export function propertyListDecorator( listName: string ) : PropertyDecorator { - return function propList(proto, name : string) { - const list = proto.hasOwnProperty( listName ) ? - proto[ listName ] : (proto[ listName ] = (proto[ listName ] || []).slice()); - - list.push(name); - } -} - -export function definitionDecorator( definitionKey, value ){ - return ( proto : object, name : string ) => { - MixinsState - .get( proto.constructor ) - .mergeObject( proto, { - [ definitionKey ] : { - [ name ] : value - } - }); - } -} - -export class MixinsState { - mergeRules : MixinMergeRules; - definitionRules : MixinMergeRules; - definitions : object = {}; - appliedMixins : Mixin[]; - - // Return mixins state for the class. Initialize if it's not exist. - static get( Class ) : MixinsState { - const { mixins } = Class; - - return mixins && Class === mixins.Class ? mixins : - Class.mixins = new MixinsState( Class ); - } - - constructor( public Class : MixableConstructor ){ - const { mixins } = getBaseClass( Class ); - - this.mergeRules = ( mixins && mixins.mergeRules ) || hashMap(); - this.definitionRules = ( mixins && mixins.definitionRules ) || hashMap(); - this.appliedMixins = ( mixins && mixins.appliedMixins ) || []; - } - - getStaticDefinitions( BaseClass : Function ){ - const definitions = hashMap(), - { Class } = this; - - return transform( definitions, this.definitionRules, ( rule, name ) =>{ - if( BaseClass[ name ] !== Class[ name ]){ - return Class[ name ]; - } - }); - } - - merge( mixins : Mixin[] ){ - const proto = this.Class.prototype, - { mergeRules } = this; - - // Copy applied mixins array as it's going to be updated. - const appliedMixins = this.appliedMixins = this.appliedMixins.slice(); - - // Apply mixins in sequence... - for( let mixin of mixins ) { - // Mixins array should be flattened. - if( Array.isArray( mixin ) ) { - this.merge( mixin ); - } - // Don't apply mixins twice. - else if( appliedMixins.indexOf( mixin ) < 0 ){ - appliedMixins.push( mixin ); - - // For constructors, merge _both_ static and prototype members. - if( typeof mixin === 'function' ){ - // Merge static members - this.mergeObject( this.Class, mixin ); - - // merge definitionRules and mergeRules - const sourceMixins = ( mixin as any ).mixins; - if( sourceMixins ){ - this.mergeRules = defaults( hashMap(), this.mergeRules, sourceMixins.mergeRules ); - this.definitionRules = defaults( hashMap(), this.definitionRules, sourceMixins.definitionRules ); - this.appliedMixins = this.appliedMixins.concat( sourceMixins.appliedMixins ); - } - - // Prototypes are merged according with rules. - this.mergeObject( proto, mixin.prototype ); - } - // Handle plain object mixins. - else { - this.mergeObject( proto, mixin ); - } - } - } - } - - populate( ...ctors : Function[] ){ - for( let Ctor of ctors ) { - MixinsState.get( Ctor ).merge([ this.Class ]); - } - } - - mergeObject( dest : object, source : object, unshift? : boolean ) { - forEachOwnProp( source, name => { - const sourceProp = Object.getOwnPropertyDescriptor( source, name ); - let rule : MixinMergeRule; - - if( rule = this.definitionRules[ name ] ){ - assignProperty( this.definitions, name, sourceProp, rule, unshift ); - } - - if( !rule || rule === mixinRules.protoValue ){ - assignProperty( dest, name, sourceProp, this.mergeRules[ name ], unshift ); - } - }); - } - - mergeInheritedMembers( BaseClass : Function ){ - const { mergeRules, Class } = this; - - if( mergeRules ){ - const proto = Class.prototype, - baseProto = BaseClass.prototype; - - for( let name in mergeRules ) { - const rule = mergeRules[ name ]; - - if( proto.hasOwnProperty( name ) && name in baseProto ){ - proto[ name ] = resolveRule( proto[ name ], baseProto[ name ], rule ); - } - } - } - } -} - -const dontMix = { - function : hashMap({ - length : true, - prototype : true, - caller : true, - arguments : true, - name : true, - __super__ : true - }), - - object : hashMap({ - constructor : true - }) -} - -function forEachOwnProp( object : object, fun : ( name : string ) => void ){ - const ignore = dontMix[ typeof object ]; - - for( let name of Object.keys( object ) ) { - ignore[ name ] || fun( name ); - } -} - -export interface MixinMergeRules { - [ name : string ] : MixinMergeRule -} - -export type MixinMergeRule = ( a : any, b : any ) => any -export type Mixin = { [ key : string ] : any } | Function - -// @mixins( A, B, ... ) decorator. -export interface MixinRulesDecorator { - ( rules : MixinMergeRules ) : ClassDecorator - value( a : object, b : object) : object; - protoValue( a : object, b : object) : object; - merge( a : object, b : object ) : object; - pipe( a: Function, b : Function ) : Function; - defaults( a: Function, b : Function ) : Function; - classFirst( a: Function, b : Function ) : Function; - classLast( a: Function, b : Function ) : Function; - every( a: Function, b : Function ) : Function; - some( a: Function, b : Function ) : Function; -} - -export const mixins = ( ...list : Mixin[] ) => ( - ( Class : Function ) => MixinsState.get( Class ).merge( list ) -); - -// @mixinRules({ name : rule, ... }) decorator. -export const mixinRules = ( ( rules : MixinMergeRules ) => ( - ( Class : Function ) => { - const mixins = MixinsState.get( Class ); - mixins.mergeRules = defaults( rules, mixins.mergeRules ); - } -) ) as MixinRulesDecorator; - -// Pre-defined mixin merge rules - -mixinRules.value = ( a, b ) => a; - -mixinRules.protoValue = ( a, b ) => a; - -// Recursively merge members -mixinRules.merge = ( a, b ) => defaults( {}, a, b ); - - // Execute methods in pipe, with the class method executed last. -mixinRules.pipe = ( a, b ) => ( - function( x : any ) : any { - return a.call( this, b.call( this, x ) ); - } -); - - // Assume methods return an object, and merge results with defaults (class method executed first) -mixinRules.defaults = ( a : Function, b : Function ) => ( - function() : object { - return defaults( a.apply( this, arguments ), b.apply( this, arguments ) ); - } -); - -// Execute methods in sequence staring with the class method. -mixinRules.classFirst = ( a : Function, b : Function ) => ( - function() : void { - a.apply( this, arguments ); - b.apply( this, arguments ); - } -); - - // Execute methods in sequence ending with the class method. -mixinRules.classLast = ( a : Function, b : Function ) => ( - function() : void { - b.apply( this, arguments ); - a.apply( this, arguments ); - } -) - - // Execute methods in sequence returning the first falsy result. -mixinRules.every = ( a : Function, b : Function ) =>( - function() : any { - return a.apply( this, arguments ) && b.apply( this, arguments ); - } -); - // Execute methods in sequence returning the first truthy result. -mixinRules.some = ( a : Function, b : Function ) =>( - function() : any { - return a.apply( this, arguments ) || b.apply( this, arguments ); - } -); - -/** - * Helpers - */ - -function assignProperty( dest : object, name : string, sourceProp : PropertyDescriptor, rule : MixinMergeRule, unshift? : boolean ){ -// Destination prop is defined, thus the merge rules must be applied. - if( dest.hasOwnProperty( name ) ){ - const destProp = Object.getOwnPropertyDescriptor( dest, name ); - - if( destProp.configurable && 'value' in destProp ){ - dest[ name ] = unshift ? - resolveRule( sourceProp.value, destProp.value, rule ) : - resolveRule( destProp.value, sourceProp.value, rule ) ; - } - } - // If destination is empty, just copy the prop over. - else{ - Object.defineProperty( dest, name, sourceProp ); - } -} - -function resolveRule( dest, source, rule : MixinMergeRule ){ - // When destination is empty, take the source. - if( dest === void 0 ) return source; - - // In these cases we take non-empty destination: - if( !rule || source === void 0 ) return dest; - - // In other cases we must merge values. - return rule( dest, source ); -} \ No newline at end of file diff --git a/src/type-r/object-plus/tools.ts b/src/type-r/object-plus/tools.ts deleted file mode 100644 index 479646d..0000000 --- a/src/type-r/object-plus/tools.ts +++ /dev/null @@ -1,367 +0,0 @@ -/** - * Simple overridable logging stubs, writing to `console` by default. - * Node.js users might want to redirect logging somewhere. - * - * This is the singleton avaliable globally through `Object.log` or - * exported [[log]] variable. - */ - - /** Similar to underscore `_.defaults` */ -export function defaults< T >( dest : T, ...sources : Object[] ) : T -export function defaults< T >( dest : T, source : Object ) : T { - for( var name in source ) { - if( source.hasOwnProperty( name ) && !dest.hasOwnProperty( name ) ) { - dest[ name ] = source[ name ]; - } - } - - if( arguments.length > 2 ){ - for( let i = 2; i < arguments.length; i++ ){ - const other = arguments[ i ]; - other && defaults( dest, other ); - } - } - - return dest; -} - -// Logger is the function. -export type Logger = ( level : LogLevel, error : string, props? : object ) => void; - -export type LogLevel = 'none' | 'error' | 'warn' | 'info' | 'debug' | 'log'; - -const levelToNumber = { - none : 0, error : 1, warn : 2, info : 3, log : 4, debug : 5 -} - -export interface Log extends Logger { - level : number - throw : number - stop : number - logger : Logger -} - -export const log : Log = function( a_level : LogLevel, a_msg : string, a_props : object ){ - let levelAsNumber = levelToNumber[ a_level ], msg, props, level; - - if( levelAsNumber === void 0 && !a_props ){ - levelAsNumber = 4; - msg = a_level; - props = a_msg; - level = 'log'; - } - else{ - msg = a_msg, level = a_level, props = a_props; - } - - if( levelAsNumber <= log.level ){ - if( levelAsNumber <= log.throw || !log.logger ){ - const error = new Error( msg ); - (error as any).props = props; - throw error; - } - else{ - log.logger( level, msg, props ); - - if( levelAsNumber <= log.stop ){ - debugger; - } - } - } -} - -declare var process: any; - -log.level = typeof process !== 'undefined' && process.env && process.env.NODE_ENV === 'production' ? 1 : 2; -log.throw = 0; -log.stop = 0; - - -let toString = typeof window === 'undefined' ? - function toString( something ){ - if( something && typeof something === 'object' ){ - const value = something.__inner_state__ || something, - isTransactional = Boolean( something.__inner_state__ ), - isArray = Array.isArray( value ); - - const keys = Object.keys( value ).join( ', ' ), - body = isArray ? `[ length = ${ value.length } ]` : `{ ${ keys } }`; - - return something.constructor.name + ' ' + body; - } - - return something; - } : function toString( x ){ return x; }; - -if( typeof console !== 'undefined' ) { - log.logger = function _console( level : LogLevel, error : string, props : object ){ - const args = [ error ]; - for( let name in props ){ - args.push( `\n\t${name}:`, toString( props[ name ] ) ); - } - - console[ level ].apply( console, args ); - } -} - -/** Check if value is raw JSON */ -export function isValidJSON( value : any ) : boolean { - if( value === null ){ - return true; - } - - switch( typeof value ){ - case 'number' : - case 'string' : - case 'boolean' : - return true; - - case 'object': - var proto = Object.getPrototypeOf( value ); - - if( proto === Object.prototype || proto === Array.prototype ){ - return every( value, isValidJSON ); - } - } - - return false; -} - -/** Get the base class constructor function. - * @param Class Subclass constructor function. - * @returns Base class constructor function. - */ -export function getBaseClass( Class : Function ) { - return Object.getPrototypeOf( Class.prototype ).constructor -} - -export function assignToClassProto( Class, definition : T, ...names : K[] ) : void { - for( let name of names ){ - const value = definition[ name ]; - value === void 0 || ( Class.prototype[ name ] = value ); - } -} - -/** Checks whenever given object is an empty hash `{}` */ -export function isEmpty( obj : {} ) : boolean { - if( obj ){ - for( let key in obj ){ - if( obj.hasOwnProperty( key ) ){ - return false; - } - } - } - - return true; -} - -export type Iteratee = ( value : any, key? : string | number ) => any; - -/** @hidden */ -function someArray( arr : any[], fun : Iteratee ) : any { - let result; - - for( let i = 0; i < arr.length; i++ ){ - if( result = fun( arr[ i ], i ) ){ - return result; - } - } -} - -/** @hidden */ -function someObject( obj : {}, fun : Iteratee ) : any { - let result; - - for( let key in obj ){ - if( obj.hasOwnProperty( key ) ){ - if( result = fun( obj[ key ], key ) ){ - return result; - } - } - } -} - -/** Similar to underscore `_.some` */ -export function some( obj, fun : Iteratee ) : any { - if( Object.getPrototypeOf( obj ) === ArrayProto ){ - return someArray( obj, fun ); - } - else{ - return someObject( obj, fun ); - } -} - -/** Similar to underscore `_.every` */ -export function every( obj : { }, predicate : Iteratee ) : boolean { - return !some( obj, x => !predicate( x ) ); -} - -/** Similar to `getOwnPropertyDescriptor`, but traverse the whole prototype chain. */ -export function getPropertyDescriptor( obj : {}, prop : string ) : PropertyDescriptor { - let desc : PropertyDescriptor; - - for( let proto = obj; !desc && proto; proto = Object.getPrototypeOf( proto ) ) { - desc = Object.getOwnPropertyDescriptor( proto, prop ); - } - - return desc; -} - -/** Similar to underscore `_.omit` */ -export function omit( source : {}, ...rest : string[] ) : {} -export function omit( source ) : {} { - const dest = {}, discard = {}; - - for( let i = 1; i < arguments.length; i ++ ){ - discard[ arguments[ i ] ] = true; - } - - for( var name in source ) { - if( !discard.hasOwnProperty( name ) && source.hasOwnProperty( name ) ) { - dest[ name ] = source[ name ]; - } - } - - return dest; -} - -/** map `source` object properties with a given function, and assign the result to the `dest` object. - * When `fun` returns `undefined`, skip this value. - */ -export function transform< A, B >( dest : { [ key : string ] : A }, source : { [ key : string ] : B }, fun : ( value : B, key : string ) => A | void ) : { [ key : string ] : A } { - for( var name in source ) { - if( source.hasOwnProperty( name ) ) { - var value = fun( source[ name ], name ); - value === void 0 || ( dest[ name ] = < A >value ); - } - } - - return dest; -} - -/** @hidden */ -export function fastAssign< A >( dest : A, source : {} ) : A { - for( var name in source ) { - dest[ name ] = source[ name ]; - } - - return dest; -} - -/** @hidden */ -export function fastDefaults< A >( dest : A, source : {} ) : A { - for( var name in source ) { - if( dest[ name ] === void 0 ){ - dest[ name ] = source[ name ]; - } - } - - return dest; -} - -/** Similar to underscore `_.extend` and `Object.assign` */ -export function assign< T >( dest : T, ...sources : Object[] ) : T -export function assign< T >( dest : T, source : Object ) : T { - for( var name in source ) { - if( source.hasOwnProperty( name ) ) { - dest[ name ] = source[ name ]; - } - } - - if( arguments.length > 2 ){ - for( let i = 2; i < arguments.length; i++ ){ - const other = arguments[ i ]; - other && assign( dest, other ); - } - } - - return dest; -} - -/** Similar to underscore `_.keys` */ -export function keys( o : any ) : string[]{ - return o ? Object.keys( o ) : []; -} - -/** Similar to underscore `_.once` */ -export function once( func : Function ) : Function { - var memo, first = true; - return function() { - if ( first ) { - first = false; - memo = func.apply(this, arguments); - func = null; - } - return memo; - }; -} - -/** @hidden */ -const ArrayProto = Array.prototype, - DateProto = Date.prototype, - ObjectProto = Object.prototype; - -/** - * Determine whenever two values are not equal, deeply traversing - * arrays and plain JS objects (hashes). Dates are compared by enclosed timestamps, all other - * values are compared with strict comparison. - */ -export function notEqual( a : any, b : any) : boolean { - if( a === b ) return false; - - if( a && b && typeof a == 'object' && typeof b == 'object' ) { - const protoA = Object.getPrototypeOf( a ); - - if( protoA !== Object.getPrototypeOf( b ) ) return true; - - switch( protoA ){ - case DateProto : return +a !== +b; - case ArrayProto : return arraysNotEqual( a, b ); - case ObjectProto : - case null: - return objectsNotEqual( a, b ); - } - } - - return true; -} - -/** @hidden */ -function objectsNotEqual( a, b ) { - const keysA = Object.keys( a ); - - if( keysA.length !== Object.keys( b ).length ) return true; - - for( let i = 0; i < keysA.length; i++ ) { - const key = keysA[ i ]; - - if( !b.hasOwnProperty( key ) || notEqual( a[ key ], b[ key ] ) ) { - return true; - } - } - - return false; -} - -/** @hidden */ -function arraysNotEqual( a, b ) { - if( a.length !== b.length ) return true; - - for( let i = 0; i < a.length; i++ ) { - if( notEqual( a[ i ], b[ i ] ) ) return true; - } - - return false; -} - -/** - * Create an object without Object prototype members except hasOwnProperty. - * @param obj - optional parameter to populate the hash map from. - */ -const HashProto = Object.create( null ); -HashProto.hasOwnProperty = ObjectProto.hasOwnProperty; - -export function hashMap( obj? ){ - const hash = Object.create( HashProto ); - return obj ? assign( hash, obj ) : hash; -} \ No newline at end of file diff --git a/src/type-r/record/README.md b/src/type-r/record/README.md deleted file mode 100644 index 79c13b4..0000000 --- a/src/type-r/record/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# Record transactional core - -## Dependencies - - index.ts - ↑ ↑ - | | - | define.ts - | ↑ basicTypes.ts - | | ↗ - | attribute.ts → nestedTypes.ts - | ↑ / - | | / - transactions.ts diff --git a/src/type-r/record/TODO.md b/src/type-r/record/TODO.md deleted file mode 100644 index 9dc3fd4..0000000 --- a/src/type-r/record/TODO.md +++ /dev/null @@ -1,145 +0,0 @@ -# Records todo list - -(!) Add merge option to the record.set. -So, set must accept and pass through: add, remove, merge. - - - -Okay. So. - -transaction.ts (needs to be renamed to record.ts) will me the base thingy. -Keep all definitions with relates to Record there. -This includes definition (but not implementation) of the Record.define method. - -attribute.ts - imports transaction.ts, implements Attribute base class and factory. - -basicTypes.ts, nestedTypes.ts -> rename to metatypes.ts? Or rename. -nestedTypes will include Record as well, and register itself. - -define.ts will contain will compile stuff and create mixin. - -index.ts will wire up the things together, adding define method to Record. -Need it to resolve circular dependency. - -Key points: -- no reference to collection stuff from there. Remove getOwner(). -- no monadic type specs, no type inference. It takes raw attribute descriptors. -- Attribute and TransactionalAttr must be exported. - -This core must perform transactions and serialization. Cover with unit tests. -Consider moving class.ts and tools.ts inside. - -It would make the nice core project. Collection is way simpler, it doesn't require code generation. - -The rest of the stuff can be built on this foundation. - -## Minimal flat record -[ ] Primitive types attributes -[ ] Type inference -[ ] constructor -[ ] default record.toJSON() -[ ] set -[ ] transactional updates -[ ] ad-hoc attribute access - -- no parsing -- no nested stuff - -## Advanced flat record -[ ] Date type attribute -[ ] Object and Array types -[ ] JSON attr type -[ ] Constructor type -[ ] Global type inference -[ ] Custom toJSON() -[ ] Custom parse() -[ ] deep and shallow copy - -## Nested record -[ ] deep update -[ ] - -# Remarks - -Ownership stuff. - -There's a pattern with ViewModels - assigning if the globals -to state members just to listen the changes. - -With a current ownership scheme, it won't work. -1) New metatypes are needed: -- Model.ref( optional std ref ) -- Collection.ref( optional std ref ) - -These things are not serializable. Nor they set an owner. -Nor they will trigger the change. - -2) So, we need either to add these watching support to the core -(which we don't want to do), or use some mechanics to listen for events. - -``` -a : Model.Ref.events({ - change(){ this.forceChange( 'a' ); } -}) -``` - -or, more clear syntax: - -``` -a : Model.Ref.changeEvents( 'change' ) -``` - -We need to support both. - - -or, use special type - -``` -a : Model.LinkedRef -``` - -or, reverse semantic: - -``` -a : Model.Ref // listening to changes -a : Model.WeakRef // doesn't listen to changes -``` - -Regarding the text ref stuff. -- in this case attribute should be constant. -- there's an unsolvable issue that master link can be changed. So, its dangerous. -- Therefore, we could use separate .take() thingy for that. - -# Decorators - -For attributes, it's possible to make it way better. - -@define -class M extends Record { - @type( String ) s - @type( Number ) x = 6 - @type( Model ) m - @type( Model ) @has({ toJSON : false }) m5 - @attr x = 5 - @attr y = '' - @attr z = false - @attr({ type : Number }) g - - static attributes = { - s : String, - x : Number.value( 6 ), - m : Model, - m5 : Model.has.toJSON( false ), - x : 5, - y : '', - z : false, - g : Number - } -} - -- so, we can really do crazy shit here. -- for typescript, it's possible to get design-time type (!) in decorator. - -- decorator returns native property immediately. -- it can update _attributes in the prototype immediately. -- @define can just grab the results. \ No newline at end of file diff --git a/src/type-r/record/attributes/README.md b/src/type-r/record/attributes/README.md deleted file mode 100644 index d7b6a54..0000000 --- a/src/type-r/record/attributes/README.md +++ /dev/null @@ -1,42 +0,0 @@ -Attributes run-time metadata, record update pipleline, and attribute definitions. - -- `any.ts` - `AnyType` is the base class for the typeless attribute descriptor. -- `updates.ts` - transactional updates. -- `attrDef.ts` - chainable attribute spec definition. - -## Design - -Record's attributes has descriptors stored on `record._attributes`. Attribute descriptor controls all aspects of attribute behavior. - -`AnyType` is the base class for an attribute, and it represents the *typeless attribute*. This attribute might hold value of an type and perform _no type assertions and convertions_. It must implement all the update pipeline methods, though. - -### Streamlined attributes semantic - -Mutable attributes (changes _are_ detected): - -- aggregated (Record, Collection) -- shared (Record.shared, Collection.shared, Collection.Refs) -- shared serializable (Record.from, Collection.subsetOf) - -Typeless attribute: must be anything. - -- No type convertion. -- No complex comparisons and other stuff, just the raw assignments. - -Immutable attributes (changes are _not_ detected): - -- JSON (Object, Array) -- Primitives (Boolean, Number, String) -- Date -- Function -- Class (custom constructor) - -Common for immutable things: - -- dispose is noop. -- clone is noop. -- no update in place. -- no change detection. - -Consider adding value links to perform pure updates. record.linkAt( 'key1' ).at( 'key2' ).set( value ); -Consider making it optional dependency. \ No newline at end of file diff --git a/src/type-r/record/attributes/any.ts b/src/type-r/record/attributes/any.ts deleted file mode 100644 index 3a8a163..0000000 --- a/src/type-r/record/attributes/any.ts +++ /dev/null @@ -1,292 +0,0 @@ -import { setAttribute, AttributesContainer, AttributeUpdatePipeline, RecordTransaction } from './updates' -import { tools } from '../../object-plus' -import { Owner, Transactional, TransactionOptions } from '../../transactions' -import { IOEndpoint } from '../../io-tools' - -const { notEqual, assign} = tools; - -declare global { - interface Function { - _attribute : typeof AnyType - } -} - -export type Transform = ( this : AnyType, next : any, prev : any, record : AttributesContainer, options : TransactionOptions ) => any; -export type ChangeHandler = ( this : AnyType, next : any, prev : any, record : AttributesContainer, options : TransactionOptions ) => void; - -export interface AttributeOptions { - _attribute? : typeof AnyType - validate? : ( record : AttributesContainer, value : any, key : string ) => any - isRequired? : boolean - changeEvents? : boolean - - endpoint? : IOEndpoint - - type? : Function - value? : any - hasCustomDefault? : boolean - - parse? : Parse - toJSON? : AttributeToJSON - - getHooks? : GetHook[] - transforms? : Transform[] - changeHandlers? : ChangeHandler[] - - _onChange? : ChangeAttrHandler -} - -export type Parse = ( value : any, key : string ) => any; -export type GetHook = ( value : any, key : string ) => any; -export type AttributeToJSON = ( value : any, key : string ) => any -export type AttributeParse = ( value : any, key : string ) => any -export type ChangeAttrHandler = ( ( value : any, attr : string ) => void ) | string; - -// TODO: interface differs from options, do something obout it -const emptyOptions : TransactionOptions = {}; - -/** - * Typeless attribute. Is the base class for all other attributes. - */ -export class AnyType implements AttributeUpdatePipeline { - // Factory method to create attribute from options - static create( options : AttributeOptions, name : string ) : AnyType { - const type = options.type, - AttributeCtor = options._attribute || ( type ? type._attribute : AnyType ); - - return new AttributeCtor( name, options ); - } - /** - * Update pipeline functions - * ========================= - * - * Stage 0. canBeUpdated( value ) - * - presence of this function implies attribute's ability to update in place. - */ - canBeUpdated( prev, next, options : TransactionOptions ) : any {} - - /** - * Stage 1. Transform stage - */ - transform( next : any, prev : any, model : AttributesContainer, options : TransactionOptions ) : any { return next; } - - // convert attribute type to `this.type`. - convert( next : any, prev : any, model : AttributesContainer, options : TransactionOptions ) : any { return next; } - - /** - * Stage 2. Check if attr value is changed - */ - isChanged( a : any, b : any ) : boolean { - return notEqual( a, b ); - } - - /** - * Stage 3. Handle attribute change - */ - handleChange( next : any, prev : any, model : AttributesContainer, options : TransactionOptions ) {} - - /** - * End update pipeline definitions. - */ - - // create empty object passing backbone options to constructor... - create() { return void 0; } - - // generic clone function for typeless attributes - // Must be overriden in sublass - clone( value : any, record : AttributesContainer ) { - return value; - } - - dispose( record : AttributesContainer, value : any ) : void { - this.handleChange( void 0, value, record, emptyOptions ); - } - - validate( record : AttributesContainer, value : any, key : string ){} - - toJSON( value, key, options? : object ) { - return value && value.toJSON ? value.toJSON( options ) : value; - } - - createPropertyDescriptor() : PropertyDescriptor | void { - const { name, getHook } = this; - - if( name !== 'id' ){ - return { - // call to optimized set function for single argument. - set( value ){ - setAttribute( this, name, value ); - }, - - // attach get hook to the getter function, if it present - get : ( - getHook ? - function() { - return getHook.call( this, this.attributes[ name ], name ); - } : - function() { return this.attributes[ name ]; } - ) - } - } - } - - value : any - - // Used as global default value for the given metatype - static defaultValue : any; - - type : Function - - initialize( name : string, options : TransactionOptions ){} - - options : AttributeOptions - - doInit( value, record : AttributesContainer, options : TransactionOptions ){ - const v = value === void 0 ? this.defaultValue() : value, - x = this.transform( v, void 0, record, options ); - - this.handleChange( x, void 0, record, options ); - return x; - } - - doUpdate( value, record : AttributesContainer, options : TransactionOptions, nested? : RecordTransaction[] ){ - const { name } = this, - { attributes } = record, - prev = attributes[ name ]; - - const next = this.transform( value, prev, record, options ); - attributes[ name ] = next; - - if( this.isChanged( next, prev ) ) { - // Do the rest of the job after assignment - this.handleChange( next, prev, record, options ); - return true; - } - - return false; - } - - propagateChanges : boolean - - _log( level : tools.LogLevel, text : string, value, record : AttributesContainer ){ - tools.log( level, `[Attribute Update Error] ${ record.getClassName() }.${ this.name }: ` + text, { - 'Record' : record, - 'Attribute definition' : this, - 'Prev. value' : record.attributes[ this.name ], - 'New value' : value - }); - } - - defaultValue(){ - return this.value; - } - - constructor( public name : string, a_options : AttributeOptions ) { - // Save original options... - this.options = a_options; - - // Clone options. - const options : AttributeOptions = assign( { getHooks : [], transforms : [], changeHandlers : [] }, a_options ); - options.getHooks = options.getHooks.slice(); - options.transforms = options.transforms.slice(); - options.changeHandlers = options.changeHandlers.slice(); - - const { - value, type, parse, toJSON, changeEvents, - validate, getHooks, transforms, changeHandlers - } = options; - - // Initialize default value... - this.value = value; - this.type = type; - - // TODO: An opportunity to optimize for attribute subtype. - if( !options.hasCustomDefault && type ){ - this.defaultValue = this.create; - } - else if( tools.isValidJSON( value ) ){ - // JSON literals must be deep copied. - this.defaultValue = new Function( `return ${ JSON.stringify( value ) };` ) as any; - } - else{ - this.defaultValue = this.defaultValue; - } - - // Changes must be bubbled when they are not disabled for an attribute and transactional object. - this.propagateChanges = changeEvents !== false; - - this.toJSON = toJSON === void 0 ? this.toJSON : toJSON; - - this.validate = validate || this.validate; - - if( options.isRequired ){ - this.validate = wrapIsRequired( this.validate ); - } - - /** - * Assemble pipelines... - */ - - // `convert` is default transform, which is always present... - transforms.unshift( this.convert ); - - // Get hook from the attribute will be used first... - if( this.get ) getHooks.unshift( this.get ); - - // let subclasses configure the pipeline... - this.initialize.call( this, options ); - - // let attribute spec configure the pipeline... - if( getHooks.length ){ - const getHook = this.getHook = getHooks.reduce( chainGetHooks ); - - const { validate } = this; - this.validate = function( record : AttributesContainer, value : any, key : string ){ - return validate.call( this, record, getHook.call( record, value, key ), key ); - } - } - - this.transform = transforms.length ? transforms.reduce( chainTransforms ) : this.transform; - - this.handleChange = changeHandlers.length ? changeHandlers.reduce( chainChangeHandlers ) : this.handleChange; - - // Attribute-level parse transform are attached as update hooks modifiers... - const { doInit, doUpdate } = this; - this.doInit = parse ? function( value, record : AttributesContainer, options : TransactionOptions ){ - return doInit.call( this, options.parse && value !== void 0 ? parse.call( record, value, this.name ) : value, record, options ); - } : doInit; - - this.doUpdate = parse ? function( value, record : AttributesContainer, options : TransactionOptions, nested? : RecordTransaction[] ){ - return doUpdate.call( this, options.parse && value !== void 0 ? parse.call( record, value, this.name ) : value, record, options, nested ); - } : doUpdate; - } - - getHook : ( value, key : string ) => any = null - get : ( value, key : string ) => any -} - - -function chainGetHooks( prevHook : GetHook, nextHook : GetHook ) : GetHook { - return function( value, name ) { - return nextHook.call( this, prevHook.call( this, value, name ), name ); - } -} - -function chainTransforms( prevTransform : Transform, nextTransform : Transform ) : Transform { - return function( next, prev, record, options ) { - return nextTransform.call( this, prevTransform.call( this, next, prev, record, options ), prev, record, options ); - } -} - -function chainChangeHandlers( prevHandler : ChangeHandler, nextHandler : ChangeHandler ) : ChangeHandler { - return function( next, prev, record, options ) { - prevHandler.call( this, next, prev, record, options ); - nextHandler.call( this, next, prev, record, options ); - } -} - -function wrapIsRequired( validate ){ - return function( record : AttributesContainer, value : any, key : string ){ - return value ? validate.call( this, record, value, key ) : 'Required'; - } -} \ No newline at end of file diff --git a/src/type-r/record/attributes/attrDef.ts b/src/type-r/record/attributes/attrDef.ts deleted file mode 100644 index f538d5b..0000000 --- a/src/type-r/record/attributes/attrDef.ts +++ /dev/null @@ -1,213 +0,0 @@ -/** - * Type spec engine. Declare attributes using chainable syntax, - * and returns object with spec. - */ -import { Transactional } from '../../transactions' -import { ChangeAttrHandler, AttributeOptions, Parse } from './any' -import { AttributesContainer } from './updates' -import { EventMap, EventsDefinition, definitionDecorator, tools } from '../../object-plus' -import { IOEndpoint } from '../../io-tools' - -const { assign } = tools; - -export interface AttributeCheck { - ( value : any, key : string ) : boolean - error? : any -} - -export class ChainableAttributeSpec { - options : AttributeOptions; - - constructor( options : AttributeOptions ) { - // Shallow copy options, fill it with defaults. - this.options = { getHooks : [], transforms : [], changeHandlers : []}; - if( options ) assign( this.options, options ); - } - - check( check : AttributeCheck, error : any ) : ChainableAttributeSpec { - function validate( model, value, name ){ - if( !check.call( model, value, name ) ){ - const msg = error || check.error || name + ' is not valid'; - return typeof msg === 'function' ? msg.call( model, name ) : msg; - } - } - - const prev = this.options.validate; - - return this.metadata({ - validate : prev ? ( - function( model, value, name ){ - return prev( model, value, name ) || validate( model, value, name ); - } - ) : validate - }); - } - - get asProp(){ - return definitionDecorator( 'attributes', this ); - } - - get as(){ return this.asProp; } - - get isRequired() : ChainableAttributeSpec { - return this.metadata({ isRequired : true }); - } - - endpoint( endpoint : IOEndpoint ){ - return this.metadata({ endpoint }); - } - - watcher( ref : string | ( ( value : any, key : string ) => void ) ) : ChainableAttributeSpec { - return this.metadata({ _onChange : ref }); - } - - // Attribute-specific parse transform - parse( fun : Parse ) : ChainableAttributeSpec { - return this.metadata({ parse : fun }); - } - - toJSON( fun ) : ChainableAttributeSpec { - return this.metadata({ - toJSON : typeof fun === 'function' ? fun : ( fun ? ( x, k, o ) => x && x.toJSON( o ) : emptyFunction ) - }); - } - - // Attribute get hook. - get( fun ) : ChainableAttributeSpec { - return this.metadata({ - getHooks : this.options.getHooks.concat( fun ) - }); - } - - // Attribute set hook. - set( fun ) : ChainableAttributeSpec { - function handleSetHook( next, prev, record : AttributesContainer, options ) { - if( this.isChanged( next, prev ) ) { - const changed = fun.call( record, next, this.name ); - return changed === void 0 ? prev : this.convert( changed, prev, record, options ); - } - - return prev; - } - - return this.metadata({ - transforms : this.options.transforms.concat( handleSetHook ) - }); - } - - changeEvents( events : boolean ) : ChainableAttributeSpec { - return this.metadata({ changeEvents : events }); - } - - // Subsribe to events from an attribute. - events( map : EventsDefinition ) : ChainableAttributeSpec { - const eventMap = new EventMap( map ); - - function handleEventsSubscribtion( next, prev, record : AttributesContainer ){ - prev && prev.trigger && eventMap.unsubscribe( record, prev ); - - next && next.trigger && eventMap.subscribe( record, next ); - } - - return this.metadata({ - changeHandlers : this.options.changeHandlers.concat( handleEventsSubscribtion ) - }); - } - - // Creates a copy of the spec. - get has() : ChainableAttributeSpec { - return this; - } - - metadata( options : AttributeOptions ) : ChainableAttributeSpec { - const cloned = new ChainableAttributeSpec( this.options ); - assign( cloned.options, options ); - return cloned; - } - - value( x ) : ChainableAttributeSpec { - return this.metadata({ value : x, hasCustomDefault : true }); - } - - static from( spec : any ) : ChainableAttributeSpec { - let attrSpec : ChainableAttributeSpec; - - if( typeof spec === 'function' ) { - attrSpec = spec.has; - } - else if( spec && spec instanceof ChainableAttributeSpec ) { - attrSpec = spec; - } - else{ - // Infer type from value. - const type = inferType( spec ); - - // Transactional types inferred from values must have shared type. - if( type && type.prototype instanceof Transactional ){ - attrSpec = (type).shared.value( spec ); - } - // All others will be created in regular way. - else{ - attrSpec = new ChainableAttributeSpec({ type : type, value : spec, hasCustomDefault : true }); - } - } - - return attrSpec; - } -} - -function emptyFunction(){} - -export function type( this : void, spec : ChainableAttributeSpec | Function ) : ChainableAttributeSpec { - return spec instanceof ChainableAttributeSpec ? spec : new ChainableAttributeSpec( { - type : spec, - value : spec._attribute.defaultValue, - hasCustomDefault : spec._attribute.defaultValue !== void 0 - } );; -} - -declare global { - interface Function{ - value : ( x : any ) => ChainableAttributeSpec; - isRequired : ChainableAttributeSpec; - asProp : PropertyDecorator - has : ChainableAttributeSpec; - } -} - -Function.prototype.value = function( x ) { - return new ChainableAttributeSpec( { type : this, value : x, hasCustomDefault : true } ); -}; - -Object.defineProperty( Function.prototype, 'isRequired', { - get() { return this._isRequired || this.has.isRequired; }, - set( x ){ this._isRequired = x; } -}); - -Object.defineProperty( Function.prototype, 'asProp', { - get() { return this.has.asProp; }, -}); - -Object.defineProperty( Function.prototype, 'has', { - get() { - // workaround for sinon.js and other libraries overriding 'has' - return this._has || type( this ); - }, - - set( value ) { this._has = value; } -} ); - -function inferType( value : {} ) : Function { - switch( typeof value ) { - case 'number' : - return Number; - case 'string' : - return String; - case 'boolean' : - return Boolean; - case 'undefined' : - return void 0; - case 'object' : - return value ? value.constructor : void 0; - } -} diff --git a/src/type-r/record/attributes/basic.ts b/src/type-r/record/attributes/basic.ts deleted file mode 100644 index f82b029..0000000 --- a/src/type-r/record/attributes/basic.ts +++ /dev/null @@ -1,194 +0,0 @@ -/** - * Built-in JSON types attributes: Object, Array, Number, String, Boolean, and immutable class. - * - * Adds type assertions, default validation, and optimized update pipeline. - */ - -import { AnyType } from './any' -import { tools } from '../../object-plus' -import { AttributesContainer } from './updates' -import { TransactionOptions } from '../../transactions' - -/** - * Custom class must be immutable class which implements toJSON() method - * with a constructor taking json. - */ -class ImmutableClassType extends AnyType { - type : new ( value? : any ) => {} - - create(){ - return new this.type(); - } - - convert( next : any ) : any { - return next == null || next instanceof this.type ? next : new this.type( next ); - } - - toJSON( value, key? : string, options? : object ){ - return value && value.toJSON ? value.toJSON( options ) : value; - } - - clone( value ) { - return new this.type( this.toJSON( value ) ); - } - - isChanged( a, b ){ - return a !== b; - } -} - -Function.prototype._attribute = ImmutableClassType; - -/** - * Optimized attribute of primitive type. - * - * Primitives has specialized simplified pipeline. - */ -export class PrimitiveType extends AnyType { - type : NumberConstructor | StringConstructor | BooleanConstructor - - dispose(){} - create() { return this.type(); } - - toJSON( value ) { return value; } - - convert( next ) { return next == null ? next : this.type( next ); } - - isChanged( a, b ) { return a !== b; } - - clone( value ) { return value; } - - doInit( value, record : AttributesContainer, options : TransactionOptions ){ - return this.transform( value === void 0 ? this.value : value, void 0, record, options ); - } - - doUpdate( value, record, options, nested ){ - const { name } = this, - { attributes } = record, - prev = attributes[ name ]; - - return prev !== ( attributes[ name ] = this.transform( value, prev, record, options ) ); - } - - initialize(){ - if( !this.options.hasCustomDefault ){ - this.value = this.type(); - } - } -} - -Boolean._attribute = String._attribute = PrimitiveType; - -// Number type with special validation algothim. -/** @private */ -export class NumericType extends PrimitiveType { - type : NumberConstructor - - create(){ - return 0; - } - - convert( next, prev?, record? ) { - const num = next == null ? next : this.type( next ); - - if( num !== num ){ - this._log( 'warn', 'assigned with Invalid Number', next, record ); - } - - return num; - } - - validate( model, value, name ) { - // Whatever is not symmetrically serializable to JSON, is not valid by default. - if( value != null && !isFinite( value ) ) { - return name + ' is not valid number'; - } - } -} - -Number._attribute = NumericType; - -/** - * Add Number.integer attrubute type - */ -declare global { - interface NumberConstructor { - integer : Function - } - - interface Window { - Integer : Function; - } -} - -function Integer( x ){ - return x ? Math.round( x ) : 0; -} -Integer._attribute = NumericType; -Number.integer = Integer; - - -if( typeof window !== 'undefined' ){ - window.Integer = Number.integer; -} - -/** - * Compatibility wrapper for Array type. - * @private - */ -export class ArrayType extends AnyType { - toJSON( value ) { return value; } - dispose(){} - create(){ return []; } - - convert( next, prev, record ) { - // Fix incompatible constructor behaviour of Array... - if( next == null || Array.isArray( next ) ) return next; - - this._log( 'warn', 'assignment of non-array to Array attribute is ignored', next, record ); - - return []; - } - - clone( value ){ - return value && value.slice(); - } -} - -Array._attribute = ArrayType; - -export class ObjectType extends AnyType { - create(){ return {}; } - - convert( next, prev, record ) { - if( next == null || typeof next === 'object' ) return next; - - this._log( 'warn', 'assignment of non-object to Object attribute is ignored', next, record ); - return {}; - } -} - -Object._attribute = ObjectType; - -export function doNothing(){} - -export class FunctionType extends AnyType { - // Functions are not serialized. - toJSON( value ) { return void 0; } - create(){ return doNothing; } - dispose(){} - - convert( next, prev, record ) { - // Fix incompatible constructor behaviour of Function... - if( next == null || typeof next === 'function' ) return next; - - this._log( 'warn', 'assigned with non-function', next, record ); - - return doNothing; - } - - // Functions are not cloned. - clone( value ){ return value; } -} - -Function._attribute = FunctionType; \ No newline at end of file diff --git a/src/type-r/record/attributes/date.ts b/src/type-r/record/attributes/date.ts deleted file mode 100644 index 4930a7a..0000000 --- a/src/type-r/record/attributes/date.ts +++ /dev/null @@ -1,163 +0,0 @@ -/** - * Date attribute type. - * - * Implements validation, cross-browser compatibility fixes, variety of Date serialization formats, - * and optimized update pipeline. - */ -import { AnyType } from './any' -import { tools } from '../../object-plus' -import { AttributesContainer } from './updates' -import { TransactionOptions } from '../../transactions' -import { ChainableAttributeSpec } from './attrDef' - -const DateProto = Date.prototype; - -// Date Attribute -/** @private */ -export class DateType extends AnyType { - create(){ - return new Date(); - } - - convert( next : any, a, record ){ - if( next == null || next instanceof Date ) return next; - - const date = new Date( next ), - timestamp = date.getTime(); - - if( timestamp !== timestamp ){ - this._log( 'warn', 'assigned with Invalid Date', next, record ); - } - - return date; - } - - validate( model, value, name ) { - if( value != null ){ - const timestamp = value.getTime(); - if( timestamp !== timestamp ) return name + ' is Invalid Date'; - } - } - - toJSON( value ) { return value && value.toISOString(); } - - isChanged( a, b ) { return ( a && a.getTime() ) !== ( b && b.getTime() ); } - - doInit( value, record : AttributesContainer, options : TransactionOptions ){ - // Date don't have handleChanges step. - return this.transform( value === void 0 ? this.defaultValue() : value, void 0, record, options ); - } - - doUpdate( value, record, options, nested ){ - const { name } = this, - { attributes } = record, - prev = attributes[ name ]; - - // Date don't have handleChanges step. - return this.isChanged( prev , attributes[ name ] = this.transform( value, prev, record, options ) ); - } - - clone( value ) { return value && new Date( value.getTime() ); } - dispose(){} -} - -Date._attribute = DateType; - -const msDatePattern = /\/Date\(([0-9]+)\)\//; - -export class MSDateType extends DateType { - convert( next ) { - if( typeof next === 'string' ){ - const msDate = msDatePattern.exec( next ); - if( msDate ){ - return new Date( Number( msDate[ 1 ] ) ); - } - } - - return DateType.prototype.convert.apply( this, arguments ); - } - - toJSON( value ) { return value && `/Date(${ value.getTime() })/`; } -} - -export class TimestampType extends DateType { - toJSON( value ) { return value && value.getTime(); } -} - -declare global { - interface DateConstructor { - microsoft : ChainableAttributeSpec - timestamp : ChainableAttributeSpec - } -} - -Object.defineProperties( Date, { - microsoft : { - get(){ - return new ChainableAttributeSpec({ - type : Date, - _attribute : MSDateType - }) - } - }, - - timestamp : { - get(){ - return new ChainableAttributeSpec({ - type : Date, - _attribute : TimestampType - }) - } - } -}); - -// If ISO date is not supported by date constructor (such as in Safari), polyfill it. -function supportsDate( date ){ - return !isNaN( ( new Date( date ) ).getTime() ); -} - -if( !supportsDate('2011-11-29T15:52:30.5') || - !supportsDate('2011-11-29T15:52:30.52') || - !supportsDate('2011-11-29T15:52:18.867') || - !supportsDate('2011-11-29T15:52:18.867Z') || - !supportsDate('2011-11-29T15:52:18.867-03:30') ){ - - DateType.prototype.convert = function( value ){ - return value == null || value instanceof Date ? value : new Date( safeParseDate( value ) ); - } -} - -const numericKeys = [ 1, 4, 5, 6, 7, 10, 11 ], - isoDatePattern = /^(\d{4}|[+\-]\d{6})(?:-(\d{2})(?:-(\d{2}))?)?(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?(?:(Z)|([+\-])(\d{2})(?::(\d{2}))?)?)?$/; - -function safeParseDate( date : string ) : number { - var timestamp, struct : any[], minutesOffset = 0; - - if( ( struct = isoDatePattern.exec( date )) ) { - // avoid NaN timestamps caused by undefined values being passed to Date.UTC - for( var i = 0, k; ( k = numericKeys[ i ] ); ++i ) { - struct[ k ] = +struct[ k ] || 0; - } - - // allow undefined days and months - struct[ 2 ] = (+struct[ 2 ] || 1) - 1; - struct[ 3 ] = +struct[ 3 ] || 1; - - if( struct[ 8 ] !== 'Z' && struct[ 9 ] !== undefined ) { - minutesOffset = struct[ 10 ] * 60 + struct[ 11 ]; - - if( struct[ 9 ] === '+' ) { - minutesOffset = 0 - minutesOffset; - } - } - - timestamp = - Date.UTC( struct[ 1 ], struct[ 2 ], struct[ 3 ], struct[ 4 ], struct[ 5 ] + minutesOffset, struct[ 6 ], - struct[ 7 ] ); - } - else { - timestamp = Date.parse( date ); - } - - return timestamp; -} \ No newline at end of file diff --git a/src/type-r/record/attributes/index.ts b/src/type-r/record/attributes/index.ts deleted file mode 100644 index 07226c5..0000000 --- a/src/type-r/record/attributes/index.ts +++ /dev/null @@ -1,110 +0,0 @@ -import { tools as _, eventsApi } from '../../object-plus' - -export * from './any' -export * from './owned' -export * from './date' -export * from './basic' -export * from './shared' -export * from './updates' -export * from './attrDef' - -import { AnyType } from './any' -import { ConstructorsMixin, constructorsMixin } from './updates' -import { ChainableAttributeSpec } from './attrDef' -import { CompiledReference } from '../../traversable' -import { IOEndpoint } from '../../io-tools' - -export interface RecordAttributesMixin extends ConstructorsMixin { - // Attributes descriptors - _attributes : AttributeDescriptors - _attributesArray : AnyType[] - - // Attribute's property descriptors - properties : PropertyDescriptorMap - - // Event map for record's local events. - _localEvents? : eventsApi.EventMap, - - _endpoints : { [ name : string ] : IOEndpoint } -} - -export interface AttributeDescriptors { - [ name : string ] : AnyType -} - -// Create record mixin from the given record's attributes definition -export default function( attributesDefinition : object, baseClassAttributes : AttributeDescriptors ) : RecordAttributesMixin { - const myAttributes = _.transform( {} as AttributeDescriptors, attributesDefinition, createAttribute ), - allAttributes = _.defaults( {} as AttributeDescriptors, myAttributes, baseClassAttributes ); - - const ConstructorsMixin = constructorsMixin( allAttributes ); - - return { - ...ConstructorsMixin, - _attributes : new ConstructorsMixin.AttributesCopy( allAttributes ), - _attributesArray : Object.keys( allAttributes ).map( key => allAttributes[ key ] ), - properties : _.transform( {}, myAttributes, x => x.createPropertyDescriptor() ), - ...localEventsMixin( myAttributes ), - _endpoints : _.transform( {}, allAttributes, attrDef => attrDef.options.endpoint ) - } -} - -// Create attribute from the type spec. -export function createAttribute( spec : any, name : string ) : AnyType { - return AnyType.create( ChainableAttributeSpec.from( spec ).options, name ); -} - -export function createSharedTypeSpec( Constructor : Function, Attribute : typeof AnyType ){ - if( !Constructor.hasOwnProperty( 'shared' ) ){ - Object.defineProperty( Constructor, 'shared', { - get(){ - return new ChainableAttributeSpec({ - value : null, - type : Constructor, - _attribute : Attribute - }); - } - }); - } -} - -interface LocalEventsMixin { - _localEvents? : eventsApi.EventMap -} - -function localEventsMixin( attrSpecs : AttributeDescriptors ) : LocalEventsMixin { - let _localEvents : eventsApi.EventMap; - - for( var key in attrSpecs ){ - const attribute = attrSpecs[ key ], - { _onChange } = attribute.options; - - if( _onChange ){ - _localEvents || ( _localEvents = new eventsApi.EventMap() ); - - _localEvents.addEvent( 'change:' + key, - typeof _onChange === 'string' ? - createWatcherFromRef( _onChange, key ) : - wrapWatcher( _onChange, key ) ); - } - } - - return _localEvents ? { _localEvents } : {}; -} - -function wrapWatcher( watcher, key ){ - return function( record, value ){ - watcher.call( record, value, key ); - } -} - -function createWatcherFromRef( ref : string, key : string ){ - const { local, resolve, tail } = new CompiledReference( ref, true ); - return local ? - function( record, value ){ - record[ tail ]( value, key ); - } : - function( record, value ){ - resolve( record )[ tail ]( value, key ); - } -} \ No newline at end of file diff --git a/src/type-r/record/attributes/owned.ts b/src/type-r/record/attributes/owned.ts deleted file mode 100644 index ba2bcb9..0000000 --- a/src/type-r/record/attributes/owned.ts +++ /dev/null @@ -1,122 +0,0 @@ -import { AnyType } from './any' -import { Owner, transactionApi, Transactional, ItemsBehavior, TransactionOptions } from '../../transactions' -import { tools } from '../../object-plus' -import { AttributesContainer, ConstructorOptions } from './updates' -import { ValidationError } from '../../validation' - -const { free, aquire } = transactionApi; - -export class AggregatedType extends AnyType { - type : typeof Transactional - - clone( value : Transactional ) : Transactional { - return value ? value.clone() : value; - } - - toJSON( x, key : string, options : object ){ return x && x.toJSON( options ); } - - doInit( value, record : AttributesContainer, options : ConstructorOptions ){ - const v = options.clone ? this.clone( value ) : ( - value === void 0 ? this.defaultValue() : value - ); - - const x = this.transform( v, void 0, record, options ); - this.handleChange( x, void 0, record, options ); - return x; - } - - doUpdate( value, record, options, nested : any[] ){ // Last to things can be wrapped to an object, either transaction or ad-hoc - const key = this.name, { attributes } = record; - const prev = attributes[ key ]; - let update; - - // This can be moved to transactional attribute. And chained with the rest. - if( update = this.canBeUpdated( prev, value, options ) ) { // todo - skip empty updates. - const nestedTransaction = prev._createTransaction( update, options ); - if( nestedTransaction ){ - if( nested ){ - nested.push( nestedTransaction ); - } - else{ - nestedTransaction.commit( record ); - } - - if( this.propagateChanges ) return true; - } - - return false; - } - - const next = this.transform( value, prev, record, options ); - attributes[ key ] = next; - - if( this.isChanged( next, prev ) ) { // Primitives and nested comparison can be inlined. - // Do the rest of the job after assignment - this.handleChange( next, prev, record, options ); - - return true; - } - - return false; - } - - canBeUpdated( prev : Transactional, next : any, options : TransactionOptions ) : any { - // If an object already exists, and new value is of incompatible type, let object handle the update. - if( prev && next != null ){ - if( next instanceof this.type ){ - // In case if merge option explicitly specified, force merge. - if( options.merge ) return next.__inner_state__; - } - else{ - return next; - } - } - } - - convert( next : any, prev : any, record : AttributesContainer, options : TransactionOptions ) : Transactional { - // Invoke class factory to handle abstract classes - if( next == null ) return next; - - if( next instanceof this.type ){ - if( next._shared && !( next._shared & ItemsBehavior.persistent ) ) { // TODO: think more about shared types assignment compatibility. - this._log( 'error', 'aggregated collection attribute is assigned with shared collection', next, record ); - } - - // With explicit 'merge' option we need to clone an object if its previous value was 'null'. - // This is an only case we could be here when merge === true. - return options.merge ? next.clone() : next; - } - - return this.type.create( next, options ); - } - - dispose ( record : AttributesContainer, value : Transactional ){ - if( value ){ - this.handleChange( void 0, value, record, {} ); - } - } - - validate( record : AttributesContainer, value : Transactional ) : ValidationError { - var error = value && value.validationError; - if( error ) return error; - } - - create() : Transactional { - return (this.type).create(); // this the subclass of Transactional here. - } - - initialize( options ){ - options.changeHandlers.unshift( this._handleChange ); - } - - _handleChange( next : Transactional, prev : Transactional, record : AttributesContainer, options : TransactionOptions ){ - if( prev ){ - free( record, prev ); - options.unset || prev.dispose(); - } - - if( next && !aquire( record, next, this.name ) ){ - this._log( 'error', 'aggregated attribute assigned with object already having an owner', next, record ); - } - } -} \ No newline at end of file diff --git a/src/type-r/record/attributes/shared.ts b/src/type-r/record/attributes/shared.ts deleted file mode 100644 index b855e59..0000000 --- a/src/type-r/record/attributes/shared.ts +++ /dev/null @@ -1,148 +0,0 @@ -import { AnyType } from './any' -import { AttributesContainer, ConstructorOptions } from './updates' -import { ItemsBehavior, Owner, transactionApi, Transactional, TransactionOptions } from '../../transactions' -import { tools, eventsApi } from '../../object-plus' - -const { on, off } = eventsApi, - { free, aquire } = transactionApi; - -/************************ - * Shared attribute definition. - * - Not serialized. - * - Listening to the changes. - * - Doesn't take ownership when assigned with object of proper type. - * - Takes ownership on objects which are converted. - */ - -const shareAndListen = ItemsBehavior.listen | ItemsBehavior.share; - -/** @private */ -export class SharedType extends AnyType { - type : typeof Transactional - - doInit( value, record : AttributesContainer, options : ConstructorOptions ){ - const v = options.clone ? this.clone( value, record ) : ( - value === void 0 ? this.defaultValue() : value - ); - - const x = this.transform( v, void 0, record, options ); - this.handleChange( x, void 0, record, options ); - return x; - } - - doUpdate( value, record, options, nested : any[] ){ // Last to things can be wrapped to an object, either transaction or ad-hoc - const key = this.name, { attributes } = record; - const prev = attributes[ key ]; - let update; - - // This can be moved to transactional attribute. And chained with the rest. - if( update = this.canBeUpdated( prev, value, options ) ) { // todo - skip empty updates. - const nestedTransaction = prev._createTransaction( update, options ); - if( nestedTransaction ){ - if( nested ){ - nested.push( nestedTransaction ); - } - else{ - nestedTransaction.commit( record ); - } - - if( this.propagateChanges ) return true; - } - - return false; - } - - const next = this.transform( value, prev, record, options ); - attributes[ key ] = next; - - if( this.isChanged( next, prev ) ) { // Primitives and nested comparison can be inlined. - // Do the rest of the job after assignment - this.handleChange( next, prev, record, options ); - - return true; - } - - return false; - } - - clone( value : Transactional, record : AttributesContainer ) : Transactional { - // References are not cloned. - if( !value || value._owner !== record ) return value; - - // Implicitly created objects are cloned. - const clone = value.clone(); - aquire( record, clone, this.name ); - return clone; - } - - // Do not serialize by default. - toJSON(){} - - canBeUpdated( prev : Transactional, next : any, options : TransactionOptions ) : any { - // If an object already exists, and new value is of incompatible type, let object handle the update. - if( prev && next != null && !( next instanceof this.type ) ){ - return next; - } - } - - convert( next : any, prev : any, record : AttributesContainer, options : TransactionOptions ) : Transactional { - if( next == null || next instanceof this.type ) return next; - - // Convert type using implicitly created rtransactional object. - const implicitObject = new ( this.type as any )( next, options, shareAndListen ); - - // To prevent a leak, we need to take an ownership on it. - aquire( record, implicitObject, this.name ); - - return implicitObject; - } - - // Refs are always valid. - validate( model, value, name ){} - - // They are always created as null. - create() : Transactional { - return null; - } - - // Listening to the change events - _handleChange( next : Transactional, prev : Transactional, record : AttributesContainer, options ){ - if( prev ){ - // If there was an implicitly created object, remove an ownership. - if( prev._owner === record ){ - free( record, prev ); - options.unset || prev.dispose(); - } - else{ - off( prev, prev._changeEventName, this._onChange, record ); - } - } - - if( next ){ - // No need to take an ownership for an implicit object - already done in convert or clone. - if( next._owner !== record ){ - on( next, next._changeEventName, this._onChange, record ); - } - } - } - - dispose( record : AttributesContainer, value : Transactional ){ - if( value ){ - this.handleChange( void 0, value, record, {} ); - } - } - - _onChange : ( child : Transactional, options : TransactionOptions, initiator : Transactional ) => void - - initialize( options ){ - // Create change event handler which knows current attribute name. - const attribute = this; - this._onChange = this.propagateChanges ? function( child, options, initiator ){ - this === initiator || this.forceAttributeChange( attribute.name, options ); - } : ignore; - - options.changeHandlers.unshift( this._handleChange ); - } -} - -function ignore(){} \ No newline at end of file diff --git a/src/type-r/record/attributes/updates.ts b/src/type-r/record/attributes/updates.ts deleted file mode 100644 index 4f17ae7..0000000 --- a/src/type-r/record/attributes/updates.ts +++ /dev/null @@ -1,226 +0,0 @@ -import { Transactional, Transaction, TransactionOptions, Owner, transactionApi } from "../../transactions" -const { begin : _begin, markAsDirty : _markAsDirty, commit } = transactionApi; - -import { eventsApi } from '../../object-plus' -const { trigger3 } = eventsApi; - -export interface ConstructorsMixin { - Attributes : AttributesConstructor - AttributesCopy : AttributesCopyConstructor -} - -export interface ConstructorOptions extends TransactionOptions{ - clone? : boolean -} - -export type AttributesConstructor = new ( record : AttributesContainer, values : object, options : TransactionOptions ) => AttributesValues; -export type AttributesCopyConstructor = new ( values : object ) => AttributesValues; - -export interface AttributesContainer extends Transactional, Owner, ConstructorsMixin { - // Attribute descriptors. - _attributes : AttributesDescriptors - - // Attribute values. - attributes : AttributesValues - - // Previous attribute values. - _previousAttributes : AttributesValues - - // Changed attributes cache. - _changedAttributes : AttributesValues -} - -export interface AttributesValues { - [ name : string ] : any -} - -export interface AttributesDescriptors { - [ name : string ] : AttributeUpdatePipeline -} - -export interface AttributeUpdatePipeline{ - doUpdate( value, record : AttributesContainer, options : TransactionOptions, nested? : Transaction[] ) : boolean -} - - // Optimized single attribute transactional update. To be called from attributes setters - // options.silent === false, parse === false. -export function setAttribute( record : AttributesContainer, name : string, value : any ) : void { - // Open the transaction. - const isRoot = begin( record ), - options = {}; - - // Update attribute. - if( record._attributes[ name ].doUpdate( value, record, options ) ){ - // Notify listeners on changes. - markAsDirty( record, options ); - trigger3( record, 'change:' + name, record, record.attributes[ name ], options ); - } - - // Close the transaction. - isRoot && commit( record ); -} - -function begin( record : AttributesContainer ){ - if( _begin( record ) ){ - record._previousAttributes = new record.AttributesCopy( record.attributes ); - record._changedAttributes = null; - return true; - } - - return false; -} - -function markAsDirty( record : AttributesContainer, options : TransactionOptions ){ - // Need to recalculate changed attributes, when we have nested set in change:attr handler - if( record._changedAttributes ){ - record._changedAttributes = null; - } - - return _markAsDirty( record, options ); -} - -/** - * TODO: There's an opportunity to create an optimized pipeline for primitive types and Date, which makes the majority - * of attributes. It might create the major speedup. - * - * Create the dedicated pipeline for owned and shared attributes as well. - * - * Three elements of the pipeline: - * - from constructor - * - from assignment - * - from `set` - */ - -export const UpdateRecordMixin = { -// Need to override it here, since begin/end transaction brackets are overriden. - transaction( this : AttributesContainer, fun : ( self : AttributesContainer ) => void, options : TransactionOptions = {} ) : void{ - const isRoot = begin( this ); - fun.call( this, this ); - isRoot && commit( this ); - }, - - // Handle nested changes. TODO: propagateChanges == false, same in transaction. - _onChildrenChange( child : Transactional, options : TransactionOptions ) : void { - const { _ownerKey } = child, - attribute = this._attributes[ _ownerKey ]; - - if( !attribute /* TODO: Must be an opposite, likely the bug */ || attribute.propagateChanges ) this.forceAttributeChange( _ownerKey, options ); - }, - - // Simulate attribute change - forceAttributeChange( key : string, options : TransactionOptions = {} ){ - // Touch an attribute in bounds of transaction - const isRoot = begin( this ); - - if( markAsDirty( this, options ) ){ - trigger3( this, 'change:' + key, this, this.attributes[ key ], options ); - } - - isRoot && commit( this ); - }, - - _createTransaction( this : AttributesContainer, a_values : {}, options : TransactionOptions = {} ) : Transaction { - const isRoot = begin( this ), - changes : string[] = [], - nested : RecordTransaction[]= [], - { _attributes } = this, - values = options.parse ? this.parse( a_values, options ) : a_values; - - let unknown; - - if( shouldBeAnObject( this, values ) ){ - for( let name in values ){ - const spec = _attributes[ name ]; - - if( spec ){ - if( spec.doUpdate( values[ name ], this, options, nested ) ){ - changes.push( name ); - } - } - else{ - unknown || ( unknown = [] ); - unknown.push( `'${ name }'` ); - } - } - - if( unknown ){ - // this._log( 'warn', `Undefined attributes ${ unknown.join(', ')} are ignored!`, values ); - } - } - - if( changes.length && markAsDirty( this, options ) ){ - return new RecordTransaction( this, isRoot, nested, changes ); - } - - // No changes, but there might be silent attributes with open transactions. - for( let pendingTransaction of nested ){ - pendingTransaction.commit( this ); - } - - isRoot && commit( this ); - } -}; - -// One of the main performance tricks of Type-R. -// Create loop unrolled constructors for internal attribute hash, -// so the hidden class JIT optimization will be engaged and they will become static structs. -// It dramatically improves record performance. -export function constructorsMixin( attrDefs : AttributesDescriptors ) : ConstructorsMixin { - const attrs = Object.keys( attrDefs ); - - const AttributesCopy : AttributesCopyConstructor = new Function( 'values', ` - ${ attrs.map( attr =>` - this.${ attr } = values.${ attr }; - `).join( '' ) } - `) as any; - - AttributesCopy.prototype = Object.prototype; - - const Attributes : AttributesConstructor = new Function( 'record', 'values', 'options', ` - var _attrs = record._attributes; - - ${ attrs.map( attr =>` - this.${ attr } = _attrs.${ attr }.doInit( values.${ attr }, record, options ); - `).join( '' ) } - `) as any; - - Attributes.prototype = Object.prototype; - - return { Attributes, AttributesCopy }; -} - -export function shouldBeAnObject( record : AttributesContainer, values : object ){ - if( values && values.constructor === Object ) return true; - - record._log( 'warn', 'update with non-object is ignored!', { values } ); - return false; -} - -// Transaction class. Implements two-phase transactions on object's tree. -// Transaction must be created if there are actual changes and when markIsDirty returns true. -export class RecordTransaction implements Transaction { - // open transaction - constructor( public object : AttributesContainer, - public isRoot : boolean, - public nested : Transaction[], - public changes : string[] ){} - - // commit transaction - commit( initiator? : AttributesContainer ) : void { - const { nested, object, changes } = this; - - // Commit all pending nested transactions... - for( let transaction of nested ){ - transaction.commit( object ); - } - - // Notify listeners on attribute changes... - // Transaction is never created when silent option is set, so just send events out. - const { attributes, _isDirty } = object; - for( let key of changes ){ - trigger3( object, 'change:' + key, object, attributes[ key ], _isDirty ); - } - - this.isRoot && commit( object, initiator ); - } -} \ No newline at end of file diff --git a/src/type-r/record/index.ts b/src/type-r/record/index.ts deleted file mode 100644 index b47b8e0..0000000 --- a/src/type-r/record/index.ts +++ /dev/null @@ -1,94 +0,0 @@ -import { Record, RecordDefinition } from './record' -import { Mixable, tools, predefine, define, MixinsState } from '../object-plus' -import compile, { ChainableAttributeSpec } from './attributes' -import { Transactional } from '../transactions' - -import { createSharedTypeSpec, AggregatedType, MSDateType, TimestampType, NumericType, SharedType } from './attributes' - -export * from './attributes' -export { Record } - -const { assign, defaults, omit, getBaseClass } = tools; - -Record.onExtend = function( this : typeof Record, BaseClass : typeof Record ){ - Transactional.onExtend.call( this, BaseClass ); - - // Create the default collection - const Class = this; - - @predefine class DefaultCollection extends BaseClass.Collection { - static model = Class; - } - - this.DefaultCollection = DefaultCollection; - - // If there are no collection defined in statics, use the default collection. - // It will appear in onDefine's definition, overriding all other settings. - if( Class.Collection === BaseClass.Collection ){ - this.Collection = DefaultCollection; - } - - // Create Class.shared modifier - createSharedTypeSpec( this, SharedType ); -} - -Record.onDefine = function( definition : RecordDefinition, BaseClass : typeof Record ){ - const baseProto : Record = BaseClass.prototype; - - // Compile attributes spec, creating definition mixin. - const { properties, _localEvents, ...dynamicMixin } = compile( this.attributes = getAttributes( definition ), baseProto._attributes ); - assign( this.prototype, dynamicMixin ); - - definition.properties = defaults( definition.properties || {}, properties ); - definition._localEvents = _localEvents; - - Transactional.onDefine.call( this, definition, BaseClass ); - - // Finalize the definition of the default collection. - this.DefaultCollection.define( definition.collection || {} ); - - // assign collection from the definition. - this.Collection = definition.Collection; - this.Collection.prototype.model = this; - - if( definition.endpoint ) this.Collection.prototype._endpoint = definition.endpoint; -} - -Record._attribute = AggregatedType; -createSharedTypeSpec( Record, SharedType ); - -function getAttributes({ defaults, attributes, idAttribute } : RecordDefinition ) { - const definition = attributes || defaults || {}; - - // If there is an undeclared idAttribute, add its definition as untyped generic attribute. - if( idAttribute && !( idAttribute in definition ) ){ - definition[ idAttribute ] = void 0; - } - - return definition; -} - -declare var Reflect; - -export function attr( proto : object, attrName : string ) : void; -export function attr( spec : any ) : PropertyDecorator; -export function attr( proto, attrName? : string ) : any { - if( attrName ){ - // Called without the spec. Extract the type. - if( typeof Reflect !== 'undefined' && Reflect.getMetadata ){ - Reflect - .getMetadata( "design:type", proto, attrName ) - .asProp( proto, attrName ); - } - else{ - proto._log( 'error', 'Add import "reflect-metadata"; as the first line of your app.' ); - } - } - else{ - return ChainableAttributeSpec.from( proto ).asProp; - } -} - -export function prop( spec ) : any { - return spec.asProp; -} \ No newline at end of file diff --git a/src/type-r/record/io-mixin.ts b/src/type-r/record/io-mixin.ts deleted file mode 100644 index 29e9b10..0000000 --- a/src/type-r/record/io-mixin.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { getOwnerEndpoint, startIO, IOOptions, IOEndpoint, IOPromise, IONode } from '../io-tools' - -export interface IORecord extends IONode { - getEndpoint() : IOEndpoint - save( options? : IOOptions ) : IOPromise - fetch( options? : IOOptions ) : IOPromise - destroy( options? : IOOptions ) : IOPromise - toJSON( options? : object ) : any - isNew() : boolean - id : string | number - set( json : object, options : object ) -} - -export const IORecordMixin = { - save( this : IORecord, options : IOOptions = {} ){ - const endpoint = this.getEndpoint(), - json = this.toJSON( options ); - - return startIO( - this, - this.isNew() ? - endpoint.create( json, options, this ) : - endpoint.update( this.id, json, options, this ), - options, - - update => { - this.set( update, { parse : true, ...options } ); - } - ); - }, - - fetch( options : IOOptions = {} ){ - return startIO( - this, - this.getEndpoint().read( this.id, options, this ), - options, - - json => this.set( json, { parse : true, ...options } ) - ); - }, - - destroy( options : IOOptions = {} ){ - return startIO( - this, - this.getEndpoint().destroy( this.id, options, this ), - options, - - () => { - const { collection } = this; - if( collection ){ - collection.remove( this, options ); - } - else{ - this.dispose(); - } - - return this; - } - ) - } -} \ No newline at end of file diff --git a/src/type-r/record/record.ts b/src/type-r/record/record.ts deleted file mode 100644 index 873fb0b..0000000 --- a/src/type-r/record/record.ts +++ /dev/null @@ -1,506 +0,0 @@ -/** - * Record core implementing transactional updates. - * The root of all definitions. - */ - -import { tools, eventsApi, Mixable, definitions, mixins, mixinRules, define } from '../object-plus' - -import { CloneOptions, Transactional, TransactionalDefinition, Transaction, TransactionOptions, Owner } from '../transactions' -import { ChildrenErrors } from '../validation' - -import { Collection } from '../collection' - -import { AnyType, AggregatedType, setAttribute, UpdateRecordMixin, - AttributesValues, AttributesContainer, - ConstructorsMixin, AttributesConstructor, AttributesCopyConstructor } from './attributes' - -import { IORecord, IORecordMixin } from './io-mixin' -import { IOPromise, IOEndpoint } from '../io-tools' - -const { assign, isEmpty, log } = tools; - -/******************************************************* - * Record core implementation - */ - -export interface ConstructorOptions extends TransactionOptions{ - clone? : boolean -} - -// Client unique id counter -let _cidCounter : number = 0; - -/*************************************************************** - * Record Definition as accepted by Record.define( definition ) - */ -export interface RecordDefinition extends TransactionalDefinition { - idAttribute? : string - attributes? : AttributesValues - collection? : object - Collection? : typeof Transactional -} - -@define({ - // Default client id prefix - cidPrefix : 'm', - - // Name of the change event - _changeEventName : 'change', - - // Default id attribute name - idAttribute : 'id' -}) -@definitions({ - defaults : mixinRules.merge, - attributes : mixinRules.merge, - collection : mixinRules.merge, - Collection : mixinRules.value, - idAttribute : mixinRules.protoValue -}) -export class Record extends Transactional implements IORecord, AttributesContainer { - // Hack - static onDefine( definition, BaseClass ){} - - static Collection : typeof Collection; - static DefaultCollection : typeof Collection; - - static from : ( collectionReference : any ) => any; - - static defaults( attrs : AttributesValues ) : typeof Record { - return this.extend({ attributes : attrs }); - } - - static attributes : AttributesValues - - /******************** - * IO Methods - */ - _endpoints : { [ name : string ] : IOEndpoint } - - // Save record - save( options? : object ) : IOPromise { throw new Error( 'Implemented by mixin' ); } - - // Destroy record - destroy( options? : object ) : IOPromise { throw new Error( 'Implemented by mixin' ); } - - /*********************************** - * Core Members - */ - // Previous attributes - _previousAttributes : {} - - previousAttributes(){ return new this.AttributesCopy( this._previousAttributes ); } - - // Current attributes - attributes : AttributesValues - - // Polymorphic accessor for aggregated attribute's canBeUpdated(). - get __inner_state__(){ return this.attributes; } - - // Lazily evaluated changed attributes hash - _changedAttributes : AttributesValues - - get changed(){ - let changed = this._changedAttributes; - - if( !changed ){ - const prev = this._previousAttributes; - changed = {}; - - const { _attributes, attributes } = this; - - for( let attr of this._attributesArray ){ - const key = attr.name, - value = attributes[ key ]; - - if( attr.isChanged( value, prev[ key ] ) ){ - changed[ key ] = value; - } - } - - this._changedAttributes = changed; - } - - return changed; - } - - changedAttributes( diff? : {} ) : boolean | {} { - if( !diff ) return this.hasChanged() ? assign( {}, this.changed ) : false; - - var val, changed : {} | boolean = false, - old = this._transaction ? this._previousAttributes : this.attributes, - attrSpecs = this._attributes; - - for( var attr in diff ){ - if( !attrSpecs[ attr ].isChanged( old[ attr ], ( val = diff[ attr ] ) ) ) continue; - (changed || (changed = {}))[ attr ] = val; - } - - return changed; - } - - hasChanged( key? : string ) : boolean { - const { _previousAttributes } = this; - if( !_previousAttributes ) return false; - - return key ? - this._attributes[ key ].isChanged( this.attributes[ key ], _previousAttributes[ key ] ) : - !isEmpty( this.changed ); - } - - previous( key : string ) : any { - if( key ){ - const { _previousAttributes } = this; - if( _previousAttributes ) return _previousAttributes[ key ]; - } - - return null; - } - - isNew() : boolean { - return this.id == null; - } - - has( key : string ) : boolean { - return this[ key ] != void 0; - } - - // Return attribute value, setting an attribute to undefined. - // TODO: If attribute was aggregated, don't dispose it. - unset( key : string, options? ) : any { - const value = this[ key ]; - this.set({ [ key ] : void 0 }, { unset : true, ...options }); - return value; - } - - // Undocumented. Move to NestedTypes? - clear( options? ) : this { - const nullify = options && options.nullify; - - this.transaction( () =>{ - this.forEachAttr( this.attributes, ( value, key ) => this[ key ] = nullify ? null : void 0 ); - }, options ); - - return this; - } - - // Returns Record owner skipping collections. TODO: Move out - getOwner() : Owner { - const owner : any = this._owner; - - // If there are no key, owner must be transactional object, and it's the collection. - // We don't expect that collection can be the member of collection, so we're skipping just one level up. An optimization. - return this._ownerKey ? owner : owner && owner._owner; - } - - /*********************************** - * Identity managements - */ - - // Id attribute name ('id' by default) - idAttribute : string; - - // Fixed 'id' property pointing to id attribute - get id() : string | number { return this.attributes[ this.idAttribute ]; } - set id( x : string | number ){ setAttribute( this, this.idAttribute, x ); } - - /*********************************** - * Dynamically compiled stuff - */ - - // Attributes specifications - _attributes : { [ key : string ] : AnyType } - _attributesArray : AnyType[] - - // Attributes object copy constructor - Attributes : AttributesConstructor - AttributesCopy : AttributesCopyConstructor - - // forEach function for traversing through attributes, with protective default implementation - // Overriden by dynamically compiled loop unrolled function in define.ts - forEachAttr( attrs : {}, iteratee : ( value : any, key? : string, spec? : AnyType ) => void ) : void { - const { _attributes } = this; - let unknown : string[]; - - for( let name in attrs ){ - const spec = _attributes[ name ]; - - if( spec ){ - iteratee( attrs[ name ], name, spec ); - } - else{ - unknown || ( unknown = [] ); - unknown.push( `'${ name }'` ); - } - } - - if( unknown ){ - this._log( 'warn', `attributes ${ unknown.join(', ')} are not defined`,{ - attributes : attrs - } ); - } - } - - each( iteratee : ( value? : any, key? : string ) => void, context? : any ){ - const fun = context !== void 0 ? ( v, k ) => iteratee.call( context, v, k ) : iteratee, - { attributes } = this; - - for( const key in this.attributes ){ - const value = attributes[ key ]; - if( value !== void 0 ) fun( value, key ); - } - } - - // Get array of attribute keys (Record) or record ids (Collection) - keys() : string[] { - const keys : string[] = []; - - this.each( ( value, key ) => value === void 0 || keys.push( key ) ); - - return keys; - } - - // Get array of attribute values (Record) or records (Collection) - values() : any[] { - return this.map( value => value ); - } - - // Create record default values, optionally augmenting given values. - defaults( values = {} ){ - const defaults = {}, - { _attributesArray } = this; - - for( let attr of _attributesArray ){ - const key = attr.name, - value = values[ key ]; - - defaults[ key ] = value === void 0 ? attr.defaultValue() : value; - } - - return defaults; - } - - /*************************************************** - * Record construction - */ - // Create record, optionally setting an owner - constructor( a_values? : {}, a_options? : ConstructorOptions ){ - super( _cidCounter++ ); - this.attributes = {}; - - const options = a_options || {}, - values = ( options.parse ? this.parse( a_values, options ) : a_values ) || {}; - - if( log.level > 1 ) typeCheck( this, values ); - - this._previousAttributes = this.attributes = new this.Attributes( this, values, options ); - - this.initialize( a_values, a_options ); - - if( this._localEvents ) this._localEvents.subscribe( this, this ); - } - - // Initialization callback, to be overriden by the subclasses - initialize( values?, options? ){} - - // Deeply clone record, optionally setting new owner. - clone( options : CloneOptions = {} ) : this { - const copy : this = new (this.constructor)( this.attributes, { clone : true } ); - - if( options.pinStore ) copy._defaultStore = this.getStore(); - - return copy; - } - - // Deprecated, every clone is the deep one now. - deepClone() : this { return this.clone() }; - - // Validate attributes. - _validateNested( errors : ChildrenErrors ) : number { - var length = 0; - - this.forEachAttr( this.attributes, ( value, name, attribute ) => { - const error = attribute.validate( this, value, name ); - - if( error ){ - errors[ name ] = error; - length++; - } - } ); - - return length; - } - - // Get attribute by key - get( key : string ) : any { - return this[ key ]; - } - - /** - * Serialization control - */ - - // Default record-level serializer, to be overriden by subclasses - toJSON( options? : object ) : any { - const json = {}; - - this.forEachAttr( this.attributes, ( value, key : string, { toJSON } ) =>{ - // If attribute serialization is not disabled, and its value is not undefined... - if( value !== void 0 ){ - // ...serialize it according to its spec. - const asJson = toJSON.call( this, value, key, options ); - - // ...skipping undefined values. Such an attributes are excluded. - if( asJson !== void 0 ) json[ key ] = asJson; - } - }); - - return json; - } - - // Default record-level parser, to be overriden by the subclasses. - parse( data, options? : TransactionOptions ){ - return data; - } - - // DEPRECATED: Attributes-level parse. Is moved to attribute descriptors. - _parse( data ){ return data; } - - /** - * Transactional control - */ - - deepSet( name : string, value : any, options? ){ - // Operation might involve series of nested object updates, thus it's wrapped in transaction. - this.transaction( () => { - const path = name.split( '.' ), - l = path.length - 1, - attr = path[ l ]; - - let model = this; - - // Locate the model, traversing the path. - for( let i = 0; i < l; i++ ){ - const key = path[ i ]; - - // There might be collections in path, so use `get`. - let next = model.get ? model.get( key ) : model[ key ]; - - // Create models, if they are not exist. - if( !next ){ - const attrSpecs = model._attributes; - if( attrSpecs ){ - // If current object is model, create default attribute - var newModel = attrSpecs[ key ].create(); - - // If created object is model, nullify attributes when requested - if( options && options.nullify && newModel._attributes ){ - newModel.clear( options ); - } - - model[ key ] = next = newModel; - } - // Silently fail in other case. - else return; - } - - model = next; - } - - // Set model attribute. - if( model.set ){ - model.set({ [ attr ] : value }, options ); - } - else{ - model[ attr ] = value; - } - }); - - return this; - } - - // Returns owner without the key (usually it's collection) - get collection() : any { - return this._ownerKey ? null : this._owner; - } - - // Dispose object and all childrens - dispose(){ - if( this._disposed ) return; - - this.forEachAttr( this.attributes, ( value, key, attribute ) => { - attribute.dispose( this, value ); - }); - - super.dispose(); - } - - _log( level : tools.LogLevel, text : string, props : object ) : void { - tools.log( level, '[Record] ' + text, { - 'Record' : this, - 'Attributes definition:' : this._attributes, - ...props - }); - } - - getClassName() : string { - return super.getClassName() || 'Record'; - } - - // Dummies to - _createTransaction( values : object, options : TransactionOptions ) : Transaction { return void 0; } - // Simulate attribute change - forceAttributeChange : ( key : string, options : TransactionOptions ) => void - _onChildrenChange : ( child : Transactional, options : TransactionOptions ) => void -}; - -assign( Record.prototype, UpdateRecordMixin, IORecordMixin ); - -/*********************************************** - * Helper functions - */ - -class BaseRecordAttributes { - id : string | number - - constructor( record : Record, x : AttributesValues, options : TransactionOptions ) { - this.id = x.id; - } -} - -Record.prototype.Attributes = BaseRecordAttributes; - -class BaseRecordAttributesCopy { - id : string | number - - constructor( x : AttributesValues ) { - this.id = x.id; - } -} - -Record.prototype.AttributesCopy = BaseRecordAttributesCopy; - -const IdAttribute = AnyType.create({ value : void 0 }, 'id' ); -Record.prototype._attributes = { id : IdAttribute }; -Record.prototype._attributesArray = [ IdAttribute ]; -Record._attribute = AggregatedType; - -import { shouldBeAnObject } from './attributes' - -function typeCheck( record : Record, values : object ){ - if( shouldBeAnObject( record, values ) ){ - const { _attributes } = record; - let unknown : string[]; - - for( let name in values ){ - if( !_attributes[ name ] ){ - unknown || ( unknown = [] ); - unknown.push( `'${ name }'` ); - } - } - - if( unknown ){ - record._log( 'warn', `undefined attributes ${ unknown.join(', ')} are ignored.`, { values } ); - } - } -} \ No newline at end of file diff --git a/src/type-r/relations/commons.ts b/src/type-r/relations/commons.ts deleted file mode 100644 index 6248b68..0000000 --- a/src/type-r/relations/commons.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Collection } from '../collection' -import { Record } from '../record' -import { CompiledReference } from '../traversable' - -export type CollectionReference = ( () => Collection ) | Collection | string; - -/** @private */ -export function parseReference( collectionRef : CollectionReference ) : ( root : Record ) => Collection { - switch( typeof collectionRef ){ - case 'function' : - return root => (collectionRef).call( root ); - case 'object' : - return () => collectionRef; - case 'string' : - const { resolve } = new CompiledReference( collectionRef ); - return resolve; - } -} \ No newline at end of file diff --git a/src/type-r/relations/from.ts b/src/type-r/relations/from.ts deleted file mode 100644 index 5ef3f13..0000000 --- a/src/type-r/relations/from.ts +++ /dev/null @@ -1,72 +0,0 @@ -import { AnyType, AttributeOptions } from '../record' -import { parseReference, CollectionReference } from './commons' -import { Collection } from '../collection' -import { Record } from '../record' - -import { ChainableAttributeSpec } from '../record' - -/******** - * Reference to model by id. - * - * Untyped attribute. Holds model id, when unresolved. When resolved, is substituted - * with a real model. - * - * No model changes are detected and counted as owner's change. That's intentional. - */ - -/** @private */ -type RecordRefValue = Record | string; - -/** @private */ -class RecordRefType extends AnyType { - // It is always serialized as an id, whenever it's resolved or not. - toJSON( value : RecordRefValue ){ - return value && typeof value === 'object' ? value.id : value; - } - - // Wne - clone( value : RecordRefValue ){ - return value && typeof value === 'object' ? value.id : value; - } - - // Model refs by id are equal when their ids are equal. - isChanged( a : RecordRefValue, b : RecordRefValue){ - var aId = a && ( (a).id == null ? a : (a).id ), - bId = b && ( (b).id == null ? b : (b).id ); - - return aId !== bId; - } - - // Refs are always valid. - validate( model, value, name ){} -} - -Record.from = function from( masterCollection : CollectionReference ) : ChainableAttributeSpec { - const getMasterCollection = parseReference( masterCollection ); - - const typeSpec = new ChainableAttributeSpec({ - value : null, - _attribute : RecordRefType - }); - - return typeSpec - .get( function( objOrId : RecordRefValue, name : string ) : Record { - if( typeof objOrId === 'object' ) return objOrId; - - // So, we're dealing with an id reference. Resolve it. - const collection = getMasterCollection( this ); - let record : Record = null; - - // If master collection exists and is not empty... - if( collection && collection.length ){ - // Silently update attribute with record from this collection. - record = collection.get( objOrId ) || null; - this.attributes[ name ] = record; - - // Subscribe for events manually. delegateEvents won't be invoked. - record && this._attributes[ name ].handleChange( record, null, this, {} ); - } - - return record; - }); -}; \ No newline at end of file diff --git a/src/type-r/relations/index.ts b/src/type-r/relations/index.ts deleted file mode 100644 index 3052dd5..0000000 --- a/src/type-r/relations/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -import './from' -import './subsetOf' - -export * from './store' \ No newline at end of file diff --git a/src/type-r/relations/store.ts b/src/type-r/relations/store.ts deleted file mode 100644 index 6ee3c3b..0000000 --- a/src/type-r/relations/store.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { Record } from '../record' -import { Transactional } from '../transactions' -import { startIO, IOPromise } from '../io-tools' - -let _store : Store = null; - -export class Store extends Record { - getStore() : Store { return this; } - - // delegate item lookup to owner, and to the global store if undefined - get( name : string ) : any { - // Lookup for resource in the current store. - let local = this[ name ]; - - // If something is found or it's the global store, return result. - if( local || this === this._defaultStore ) return local; - - // Forward failed lookup to owner or global store. - return this._owner ? this._owner.get( name ) : this._defaultStore.get( name ); - } - - static get global(){ return _store; } - static set global( store : Store ){ - if( _store ){ - _store.dispose(); - } - - Transactional.prototype._defaultStore = _store = store; - } -} - -Store.global = new Store(); \ No newline at end of file diff --git a/src/type-r/relations/subsetOf.ts b/src/type-r/relations/subsetOf.ts deleted file mode 100644 index 0e21d1e..0000000 --- a/src/type-r/relations/subsetOf.ts +++ /dev/null @@ -1,198 +0,0 @@ -import { Collection, CollectionOptions } from '../collection' -import { tools, eventsApi, define } from '../object-plus' -import { Record, AggregatedType } from '../record' -import { parseReference, CollectionReference } from './commons' -import { ChainableAttributeSpec } from '../record' -import { Transactional, ItemsBehavior, TransactionOptions, transactionApi } from '../transactions' - -const { fastDefaults } = tools; - -type RecordsIds = ( string | number )[]; - -Collection.subsetOf = function subsetOf( masterCollection : CollectionReference ) : ChainableAttributeSpec { - const SubsetOf = this._SubsetOf || ( this._SubsetOf = defineSubsetCollection( this ) ), - getMasterCollection = parseReference( masterCollection ), - typeSpec = new ChainableAttributeSpec({ - type : SubsetOf - }); - - return typeSpec.get( - function( refs ){ - !refs || refs.resolvedWith || refs.resolve( getMasterCollection( this ) ); - return refs; - } - ); -}; - -const subsetOfBehavior = ItemsBehavior.share | ItemsBehavior.persistent; - -function defineSubsetCollection( CollectionConstructor : typeof Collection ) { - @define class SubsetOfCollection extends CollectionConstructor { - refs : any[]; - resolvedWith : Collection = null; - - _attribute : AggregatedType - - get __inner_state__(){ return this.refs || this.models; } - - constructor( recordsOrIds?, options? ){ - super( [], options, subsetOfBehavior ); - this.refs = toArray( recordsOrIds ); - } - - // Remove should work fine as it already accepts ids. Add won't... - add( a_elements, options = {} ){ - const { resolvedWith } = this, - toAdd = toArray( a_elements ); - - if( resolvedWith ){ - // If the collection is resolved already, everything is simple. - return super.add( resolveRefs( resolvedWith, toAdd ), options ); - } - else{ - // Collection is not resolved yet. So, we prepare the delayed computation. - if( toAdd.length ){ - const isRoot = transactionApi.begin( this ); - - // Save elements to resolve in future... - this.refs = this.refs ? this.refs.concat( toAdd ) : toAdd.slice(); - - transactionApi.markAsDirty( this, options ); - - // And throw the 'changes' event. - isRoot && transactionApi.commit( this ); - } - } - } - - reset( a_elements?, options = {} ){ - const { resolvedWith } = this, - elements = toArray( a_elements ); - - return resolvedWith ? - // Collection is resolved, so parse ids and forward the call to set. - super.reset( resolveRefs( resolvedWith, elements ), options ) : - // Collection is not resolved yet. So, we prepare the delayed computation. - delaySet( this, elements, options ) || []; - } - - _createTransaction( a_elements, options? ){ - const { resolvedWith } = this, - elements = toArray( a_elements ); - - return resolvedWith ? - // Collection is resolved, so parse ids and forward the call to set. - super._createTransaction( resolveRefs( resolvedWith, elements ), options ) : - // Collection is not resolved yet. So, we prepare the delayed computation. - delaySet( this, elements, options ); - } - - // Serialized as an array of model ids. - toJSON() : RecordsIds { - return this.refs ? - this.refs.map( objOrId => objOrId.id || objOrId ) : - this.models.map( model => model.id ); - } - - // Subset is always valid. - _validateNested(){ return 0; } - - get length() : number { - return this.models.length || ( this.refs ? this.refs.length : 0 ); - } - - // Must be shallow copied on clone. - clone( owner? ){ - var Ctor = (this).constructor, - copy = new Ctor( [], { - model : this.model, - comparator : this.comparator - }); - - if( this.resolvedWith ){ - // TODO: bug here. - copy.resolvedWith = this.resolvedWith; - copy.refs = null; - copy.reset( this.models, { silent : true } ); - } - else{ - copy.refs = this.refs.slice(); - } - - return copy; - } - - // Clean up the custom parse method possibly defined in the base class. - parse( raw : any ) : Record[] { - return raw; - } - - resolve( collection : Collection ) : this { - if( collection && collection.length ){ - this.resolvedWith = collection; - - if( this.refs ){ - this.reset( this.refs, { silent : true } ); - this.refs = null; - } - } - - return this; - } - - getModelIds() : RecordsIds { return this.toJSON(); } - - toggle( modelOrId : any, val : boolean ) : boolean { - return super.toggle( this.resolvedWith.get( modelOrId ), val ); - } - - addAll() : Record[] { - if( this.resolvedWith ){ - this.set( this.resolvedWith.models ); - return this.models; - } - - throw new Error( "Cannot add elemens because the subset collection is not resolved yet." ); - } - - toggleAll() : Record[] { - return this.length ? this.reset() : this.addAll(); - } - } - - // Clean up all custom item events to prevent memory leaks. - SubsetOfCollection.prototype._itemEvents = void 0; - - return SubsetOfCollection; -} - -function resolveRefs( master, elements ){ - const records = []; - - for( let el of elements ){ - const record = master.get( el ); - if( record ) records.push( record ); - } - - return records; -} - -function delaySet( collection, elements, options ) : void { - if( tools.notEqual( collection.refs, elements ) ){ - const isRoot = transactionApi.begin( collection ); - - // Save elements to resolve in future... - collection.refs = elements.slice(); - - transactionApi.markAsDirty( collection, options ); - - // And throw the 'changes' event. - isRoot && transactionApi.commit( collection ); - } -} - -function toArray( elements ){ - return elements ? ( - Array.isArray( elements ) ? elements : [ elements ] - ) : []; -} \ No newline at end of file diff --git a/src/type-r/transactions.ts b/src/type-r/transactions.ts deleted file mode 100644 index 915af16..0000000 --- a/src/type-r/transactions.ts +++ /dev/null @@ -1,499 +0,0 @@ -import { Messenger, CallbacksByEvents, MessengersByCid, MixinsState, MixinMergeRules, MessengerDefinition, tools, mixins, mixinRules, definitions, eventsApi, define, Subclass } from './object-plus' -import { ValidationError, Validatable, ChildrenErrors } from './validation' -import { Traversable, resolveReference } from './traversable' -import { IOEndpoint, IOPromise, IONode, abortIO } from './io-tools' - -const { assign } = tools, - { trigger2, trigger3, on, off } = eventsApi; -/*** - * Abstract class implementing ownership tree, tho-phase transactions, and validation. - * 1. createTransaction() - apply changes to an object tree, and if there are some events to send, transaction object is created. - * 2. transaction.commit() - send and process all change events, and close transaction. - */ - -/** @private */ -export interface TransactionalDefinition extends MessengerDefinition { - endpoint? : IOEndpoint -} - -export enum ItemsBehavior { - share = 0b0001, - listen = 0b0010, - persistent = 0b0100 -} - -// Transactional object interface -@define -@definitions({ - endpoint : mixinRules.value -}) -@mixins( Messenger ) -export abstract class Transactional implements Messenger, IONode, Validatable, Traversable { - // Mixins are hard in TypeScript. We need to copy type signatures over... - // Here goes 'Mixable' mixin. - static endpoint : IOEndpoint; - static __super__ : object; - static mixins : MixinsState; - static define : ( definition? : TransactionalDefinition, statics? : object ) => typeof Transactional; - static extend : ( definition? : T, statics? : object ) => any; - - static onDefine( definitions : TransactionalDefinition, BaseClass : typeof Transactional ){ - if( definitions.endpoint ) this.prototype._endpoint = definitions.endpoint; - Messenger.onDefine.call( this, definitions, BaseClass ); - }; - - static onExtend( BaseClass : typeof Transactional ) : void { - // Make sure we don't inherit class factories. - if( BaseClass.create === this.create ) { - this.create = Transactional.create; - } - } - - // Define extendable mixin static properties. - static create( a : any, b? : any ) : Transactional { - return new (this as any)( a, b ); - } - - /** Generic class factory. May be overridden for abstract classes. Not inherited. */ - on : ( events : string | CallbacksByEvents, callback, context? ) => this - once : ( events : string | CallbacksByEvents, callback, context? ) => this - off : ( events? : string | CallbacksByEvents, callback?, context? ) => this - trigger : (name : string, a?, b?, c?, d?, e? ) => this - - stopListening : ( source? : Messenger, a? : string | CallbacksByEvents, b? : Function ) => this - listenTo : ( source : Messenger, a : string | CallbacksByEvents, b? : Function ) => this - listenToOnce : ( source : Messenger, a : string | CallbacksByEvents, b? : Function ) => this - - _disposed : boolean; - - // State accessor. - readonly __inner_state__ : any; - - // Shared modifier (used by collections of shared models) - _shared? : number; - - dispose() : void { - if( this._disposed ) return; - - abortIO( this ); - this._owner = void 0; - this._ownerKey = void 0; - this.off(); - this.stopListening(); - this._disposed = true; - } - - // Must be called at the end of the constructor in the subclass. - initialize() : void {} - - /** @private */ - _events : eventsApi.HandlersByEvent = void 0; - - /** @private */ - _listeningTo : MessengersByCid - - /** @private */ - _localEvents : eventsApi.EventMap - - cid : string - cidPrefix : string - - static shared : any; - - // Unique version token replaced on change - /** @private */ - _changeToken : {} = {} - - // true while inside of the transaction - /** @private */ - _transaction : boolean = false; - - // Holds current transaction's options, when in the middle of transaction and there're changes but is an unsent change event - /** @private */ - _isDirty : TransactionOptions = null; - - // Backreference set by owner (Record, Collection, or other object) - /** @private */ - _owner : Owner = void 0; - - // Key supplied by owner. Used by record to identify attribute key. - // Only collections doesn't set the key, which is used to distinguish collections. - /** @private */ - _ownerKey : string = void 0; - - // Name of the change event - /** @private */ - _changeEventName : string - - /** - * Subsribe for the changes. - */ - onChanges( handler : Function, target? : Messenger ){ - on( this, this._changeEventName, handler, target ); - } - - /** - * Unsubscribe from changes. - */ - offChanges( handler? : Function, target? : Messenger ){ - off( this, this._changeEventName, handler, target ); - } - - /** - * Listen to changes event. - */ - listenToChanges( target : Transactional, handler ){ - this.listenTo( target, target._changeEventName, handler ); - } - - constructor( cid : string | number ){ - this.cid = this.cidPrefix + cid; - } - - // Deeply clone ownership subtree - abstract clone( options? : CloneOptions ) : this - - // Execute given function in the scope of ad-hoc transaction. - transaction( fun : ( self : this ) => void, options : TransactionOptions = {} ) : void{ - const isRoot = transactionApi.begin( this ); - const update = fun.call( this, this ); - update && this.set( update ); - isRoot && transactionApi.commit( this ); - } - - // Loop through the members in the scope of transaction. - // Transactional version of each() - updateEach( iteratee : ( val : any, key : string | number ) => void, options? : TransactionOptions ){ - const isRoot = transactionApi.begin( this ); - this.each( iteratee ); - isRoot && transactionApi.commit( this ); - } - - // Apply bulk in-place object update in scope of ad-hoc transaction - set( values : any, options? : TransactionOptions ) : this { - if( values ){ - const transaction = this._createTransaction( values, options ); - transaction && transaction.commit(); - } - - return this; - } - - // Assign transactional object "by value", copying aggregated items. - assignFrom( source : Transactional | Object ) : this { - // Need to delay change events until change token willl by synced. - this.transaction( () =>{ - this.set( ( source ).__inner_state__ || source, { merge : true } ); - - // Synchronize change tokens - const { _changeToken } = source as any; - - if( _changeToken ){ - this._changeToken = _changeToken; - } - }); - - return this; - } - - // Apply bulk object update without any notifications, and return open transaction. - // Used internally to implement two-phase commit. - // Returns null if there are no any changes. - /** @private */ - abstract _createTransaction( values : any, options? : TransactionOptions ) : Transaction | void - - // Parse function applied when 'parse' option is set for transaction. - parse( data : any, options? : TransactionOptions ) : any { return data } - - // Convert object to the serializable JSON structure - abstract toJSON( options? : object ) : {} - - /******************* - * Traversals and member access - */ - - // Get object member by its key. - abstract get( key : string ) : any - - // Get object member by symbolic reference. - deepGet( reference : string ) : any { - return resolveReference( this, reference, ( object, key ) => object.get ? object.get( key ) : object[ key ] ); - } - - //_isCollection : boolean - - // Return owner skipping collections. - getOwner() : Owner { - return this._owner; - } - - // Store used when owner chain store lookup failed. Static value in the prototype. - /** @private */ - _defaultStore : Transactional - - // Locate the closest store. Store object stops traversal by overriding this method. - getStore() : Transactional { - const { _owner } = this; - return _owner ? _owner.getStore() : this._defaultStore; - } - - - /*************************************************** - * Iteration API - */ - - // Loop through the members. Must be efficiently implemented in container class. - abstract each( iteratee : ( val : any, key : string | number ) => void, context? : any ) - - // Map members to an array - map( iteratee : ( val : any, key : string | number ) => T, context? : any ) : T[]{ - const arr : T[] = [], - fun = context !== void 0 ? ( v, k ) => iteratee.call( context, v, k ) : iteratee; - - this.each( ( val, key ) => { - const result = fun( val, key ); - if( result !== void 0 ) arr.push( result ); - } ); - - return arr; - } - - _endpoint : IOEndpoint - _ioPromise : IOPromise - - hasPendingIO() : IOPromise { return this._ioPromise; } - - fetch( options? : object ) : IOPromise { throw new Error( "Not implemented" ); } - - getEndpoint() : IOEndpoint { - return getOwnerEndpoint( this ) || this._endpoint; - } - - // Map members to an object - mapObject( iteratee : ( val : any, key : string | number ) => T, context? : any ) : { [ key : string ] : T }{ - const obj : { [ key : string ] : T } = {}, - fun = context !== void 0 ? ( v, k ) => iteratee.call( context, v, k ) : iteratee; - - this.each( ( val, key ) => { - const result = iteratee( val, key ); - if( result !== void 0 ) obj[ key ] = result; - } ); - - return obj; - } - - /********************************* - * Validation API - */ - - // Lazily evaluated validation error - /** @private */ - _validationError : ValidationError = void 0 - - // Validate ownership tree and return valudation error - get validationError() : ValidationError { - const error = this._validationError || ( this._validationError = new ValidationError( this ) ); - return error.length ? error : null; - } - - // Validate nested members. Returns errors count. - /** @private */ - abstract _validateNested( errors : ChildrenErrors ) : number - - // Object-level validator. Returns validation error. - validate( obj? : Transactional ) : any {} - - // Return validation error (or undefined) for nested object with the given key. - getValidationError( key : string ) : any { - var error = this.validationError; - return ( key ? error && error.nested[ key ] : error ) || null; - } - - // Get validation error for the given symbolic reference. - deepValidationError( reference : string ) : any { - return resolveReference( this, reference, ( object, key ) => object.getValidationError( key ) ); - } - - // Iterate through all validation errors across the ownership tree. - eachValidationError( iteratee : ( error : any, key : string, object : Transactional ) => void ) : void { - const { validationError } = this; - validationError && validationError.eachError( iteratee, this ); - } - - // Check whenever member with a given key is valid. - isValid( key : string ) : boolean { - return !this.getValidationError( key ); - } - - valueOf() : Object { return this.cid; } - toString(){ return this.cid; } - - // Get class name for an object instance. Works fine with ES6 classes definitions (not in IE). - getClassName() : string { - const { name } = this.constructor; - if( name !== 'Subclass' ) return name; - } - - // Logging interface for run time errors and warnings. - abstract _log( level : string, text : string, value : any ) : void; -} - -export interface CloneOptions { - // 'Pin store' shall assign this._defaultStore = this.getStore(); - pinStore? : boolean -} - -// Owner must accept children update events. It's an only way children communicates with an owner. -/** @private */ -export interface Owner extends Traversable, Messenger { - _onChildrenChange( child : Transactional, options : TransactionOptions ) : void; - getOwner() : Owner - getStore() : Transactional -} - -// Transaction object used for two-phase commit protocol. -// Must be implemented by subclasses. -// Transaction must be created if there are actual changes and when markIsDirty returns true. -/** @private */ -export interface Transaction { - // Object transaction is being made on. - object : Transactional - - // Send out change events, process update triggers, and close transaction. - // Nested transactions must be marked with isNested flag (it suppress owner notification). - commit( initiator? : Transactional ) -} - -// Options for distributed transaction -export interface TransactionOptions { - // Invoke parsing - parse? : boolean - - // Suppress change notifications and update triggers - silent? : boolean - - // Update existing transactional members in place, or skip the update (ignored by models) - merge? : boolean // =true - - // Should collections remove elements in set (ignored by models) - remove? : boolean // =true - - // Always replace enclosed objects with new instances - reset? : boolean // = false - - // Do not dispose aggregated members - unset? : boolean - - validate? : boolean - - // `true` if the transaction is initiated as a result of IO operation - ioUpdate? : boolean - - // The hint for IOEndpoint - // If `true`, `record.save()` will behave as "upsert" operation for the records having id. - upsert? : boolean -} - -/** - * Low-level transactions API. Must be used like this: - * const isRoot = begin( record ); - * ... - * isRoot && commit( record, options ); - * - * When committing nested transaction, the flag must be set to true. - * commit( object, options, isNested ) - */ - -export const transactionApi = { - // Start transaction. Return true if it's the root one. - /** @private */ - begin( object : Transactional ) : boolean { - return object._transaction ? false : ( object._transaction = true ); - }, - - // Mark object having changes inside of the current transaction. - // Returns true whenever there notifications are required. - /** @private */ - markAsDirty( object : Transactional, options : TransactionOptions ) : boolean { - // If silent option is in effect, don't set isDirty flag. - const dirty = !options.silent; - if( dirty ) object._isDirty = options; - - // Reset version token. - object._changeToken = {}; - - // Object is changed, so validation must happen again. Clear the cache. - object._validationError = void 0; - - return dirty; - }, - - // Commit transaction. Send out change event and notify owner. Returns true if there were changes. - // Must be executed for the root transaction only. - /** @private */ - commit( object : Transactional, initiator? : Transactional ){ - let originalOptions = object._isDirty; - - if( originalOptions ){ - // Send the sequence of change events, handling chained handlers. - while( object._isDirty ){ - const options = object._isDirty; - object._isDirty = null; - trigger3( object, object._changeEventName, object, options, initiator ); - } - - // Mark transaction as closed. - object._transaction = false; - - // Notify owner on changes out of transaction scope. - const { _owner } = object; - if( _owner && _owner !== initiator ){ // If it's the nested transaction, owner is already aware there are some changes. - _owner._onChildrenChange( object, originalOptions ); - } - } - else{ - // No changes. Silently close transaction. - object._isDirty = null; - object._transaction = false; - } - }, - - /************************************ - * Ownership management - */ - - // Add reference to the record. - /** @private */ - aquire( owner : Owner, child : Transactional, key? : string ) : boolean { - if( !child._owner ){ - child._owner = owner; - child._ownerKey = key; - return true; - } - - return child._owner === owner; - }, - - // Remove reference to the record. - /** @private */ - free( owner : Owner, child : Transactional ) : void { - if( owner === child._owner ){ - child._owner = void 0; - child._ownerKey = void 0; - } - } -} - -function getOwnerEndpoint( self : Transactional ) : IOEndpoint { - // Check if we are the member of the collection... - const { collection } = self as any; - if( collection ){ - return getOwnerEndpoint( collection ); - } - - // Now, if we're the member of the model... - if( self._owner ){ - const { _endpoints } = self._owner as any; - return _endpoints && _endpoints[ self._ownerKey ]; - } -} diff --git a/src/type-r/traversable.ts b/src/type-r/traversable.ts deleted file mode 100644 index f0e3974..0000000 --- a/src/type-r/traversable.ts +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Some sketches for reference resolution. - * - * - * a : Model.from( '~collection' ) - * - * We need two functions. One for get, and one for compile. - */ -export interface Traversable { - getStore() : Traversable - getOwner() : Traversable - get( key : string ) : any -} - -const referenceMask = /\^|(store\.[^.]+)|([^.]+)/g; - -// Compile reference to function -export type ResolveReference = ( root : Traversable ) => any; - -export class CompiledReference { - resolve : ResolveReference - tail : string - local : boolean - - constructor( reference : string, splitTail : boolean = false ){ - const path = reference - .match( referenceMask ) - .map( key => { - if( key === '^' || key === 'owner' ) return 'getOwner()'; - - if( key[ 0 ] === '~' ) return `getStore().get("${ key.substr( 1 ) }")`; - - if( key.indexOf( 'store.' ) === 0 ) return `getStore().get("${ key.substr( 6 ) }")`; - - return key; - } ); - - this.tail = splitTail && path.pop(); - this.local = !path.length; - - this.resolve = new Function( 'self', ` - var v = self.${ path.shift() }; - - ${ path.map( x => ` - v = v && v.${ x }; - `).join('')} - - return v; - ` ); - } -} - -export function resolveReference( root : Traversable, reference : string, action : ( object, key : string ) => any ) : any { - const path = reference.match( referenceMask ), - skip = path.length - 1; - - let self = root; - - for( var i = 0; i < skip; i++ ){ - const key = path[ i ]; - switch( key ){ - case '~' : self = self.getStore(); break; - case '^' : self = self.getOwner(); break; - default : self = self.get( key ); - } - - // Do nothing if object on the path doesn't exist. - if( !self ) return; - } - - return action( self, path[ skip ] ); -} \ No newline at end of file diff --git a/src/type-r/validation.ts b/src/type-r/validation.ts deleted file mode 100644 index ff023a9..0000000 --- a/src/type-r/validation.ts +++ /dev/null @@ -1,48 +0,0 @@ -export interface ChildrenErrors { - [ key : string ] : ValidationError | any -} - -export interface Validatable { - _validateNested( errors : ChildrenErrors ) : number; - validate( self : any ) : any - get( key : string ) : any -} - -// Validation error object. -export class ValidationError { - // Invalid nested object keys - nested : ChildrenErrors - length : number - - // Local error - error : any - - constructor( obj : Validatable ){ - this.length = obj._validateNested( this.nested = {} ); - - if( this.error = obj.validate( obj ) ){ - this.length++; - } - } - - each( iteratee : ( value : any, key : string ) => void ) : void { - const { error, nested } = this; - - if( error ) iteratee( error, null ); - - for( const key in nested ){ - iteratee( nested[ key ], key ); - } - } - - eachError( iteratee : ( error : any, key : string, object : Validatable ) => void, object : Validatable ) : void { - this.each( ( value : any, key : string ) => { - if( value instanceof ValidationError ){ - (value).eachError( iteratee, object.get( key ) ); - } - else{ - iteratee( value, key, object ); - } - }); - } -} \ No newline at end of file diff --git a/src/underscore-mixin.ts b/src/underscore-mixin.ts index f0a3530..b1570b9 100644 --- a/src/underscore-mixin.ts +++ b/src/underscore-mixin.ts @@ -1,10 +1,17 @@ import * as _ from 'underscore' +import { Model, tools } from 'type-r' export const ModelMixin = { pick( ...args : any[] ){ return _.pick( this, args ); }, + values( this : Model ){ + return this.keys().map( name => this[ name ] ); + }, + + each: Model.prototype.forEach, + escape( attr ){ return _.escape( this[ attr ] ); }, diff --git a/submodules/Type-R b/submodules/Type-R deleted file mode 160000 index 7edd1e4..0000000 --- a/submodules/Type-R +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 7edd1e49cb024ef674a870072943de3ff602ccba diff --git a/tsconfig.json b/tsconfig.json index c56ad6d..cf7abb6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,6 +2,9 @@ "compilerOptions": { "target": "es5", "module":"es6", + "lib": [ + "es2015","dom" + ], "declaration": true, "moduleResolution": "node", "importHelpers": true,