Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lux-framework

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lux-framework - npm Package Compare versions

Comparing version 0.0.1-beta.5 to 0.0.1-beta.6

ROADMAP.md

2

dist/packages/cli/index.js

@@ -1,1 +0,1 @@

"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}var _regenerator=require("babel-runtime/regenerator"),_regenerator2=_interopRequireDefault(_regenerator),_asyncToGenerator2=require("babel-runtime/helpers/asyncToGenerator"),_asyncToGenerator3=_interopRequireDefault(_asyncToGenerator2),_commander=require("commander"),_commander2=_interopRequireDefault(_commander),_test=require("./commands/test"),_test2=_interopRequireDefault(_test),_serve=require("./commands/serve"),_serve2=_interopRequireDefault(_serve),_create=require("./commands/create"),_create2=_interopRequireDefault(_create),_destroy=require("./commands/destroy"),_destroy2=_interopRequireDefault(_destroy),_generate=require("./commands/generate"),_generate2=_interopRequireDefault(_generate),_tryCatch=require("../../utils/try-catch"),_tryCatch2=_interopRequireDefault(_tryCatch);_commander2["default"].version("0.0.1-beta.5"),_commander2["default"].command("n <name>").alias("new").description("Create a new application").action(function(){var e=(0,_asyncToGenerator3["default"])(_regenerator2["default"].mark(function r(e){return _regenerator2["default"].wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,(0,_tryCatch2["default"])((0,_asyncToGenerator3["default"])(_regenerator2["default"].mark(function t(){return _regenerator2["default"].wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,(0,_create2["default"])(e);case 2:case"end":return r.stop()}},t,void 0)})),function(e){console.error(e),process.exit(1)});case 2:case"end":return r.stop()}},r,void 0)}));return function(r){return e.apply(this,arguments)}}()),_commander2["default"].command("t").alias("test").description("Run your app's tests").action(function(){var e=(0,_asyncToGenerator3["default"])(_regenerator2["default"].mark(function r(){return _regenerator2["default"].wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,_tryCatch2["default"])((0,_asyncToGenerator3["default"])(_regenerator2["default"].mark(function r(){return _regenerator2["default"].wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,_test2["default"])();case 2:case"end":return e.stop()}},r,void 0)})),function(e){console.error(e),process.exit(1)});case 2:case"end":return e.stop()}},r,void 0)}));return function(r){return e.apply(this,arguments)}}()),_commander2["default"].command("s").alias("serve").description("Serve your application").option("-e, --environment","(Default: development)").option("-p, --port","(Default: 4000)").action(function(){var e=(0,_asyncToGenerator3["default"])(_regenerator2["default"].mark(function r(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];return _regenerator2["default"].wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,_tryCatch2["default"])((0,_asyncToGenerator3["default"])(_regenerator2["default"].mark(function r(){var e;return _regenerator2["default"].wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return e=4e3,t.forEach(function(r){/^\d+$/gi.test(r)?e=parseInt(r,10):/^\w+$/gi.test(r)&&(process.env.NODE_ENV=r)}),r.next=4,(0,_serve2["default"])(e);case 4:case"end":return r.stop()}},r,void 0)})),function(e){console.error(e),process.exit(1)});case 2:case"end":return e.stop()}},r,void 0)}));return function(r){return e.apply(this,arguments)}}()),_commander2["default"].command("g").alias("generate").description("Example: lux generate model user").option("type").option("name").action(function(){var e=(0,_asyncToGenerator3["default"])(_regenerator2["default"].mark(function r(e,t){return _regenerator2["default"].wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,(0,_tryCatch2["default"])((0,_asyncToGenerator3["default"])(_regenerator2["default"].mark(function n(){return _regenerator2["default"].wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if("string"!=typeof e||"string"!=typeof t){r.next=5;break}return r.next=3,(0,_generate2["default"])(e,t);case 3:r.next=6;break;case 5:throw new TypeError("Invalid arguements for type or name");case 6:case"end":return r.stop()}},n,void 0)})),function(e){console.error(e),process.exit(1)});case 2:case"end":return r.stop()}},r,void 0)}));return function(r,t){return e.apply(this,arguments)}}()),_commander2["default"].command("d").alias("destroy").description("Example: lux destroy model user").option("type").option("name").action(function(){var e=(0,_asyncToGenerator3["default"])(_regenerator2["default"].mark(function r(e,t){return _regenerator2["default"].wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,(0,_tryCatch2["default"])((0,_asyncToGenerator3["default"])(_regenerator2["default"].mark(function n(){return _regenerator2["default"].wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if("string"!=typeof e||"string"!=typeof t){r.next=5;break}return r.next=3,(0,_destroy2["default"])(e,t);case 3:r.next=6;break;case 5:throw new TypeError("Invalid arguements for type or name");case 6:case"end":return r.stop()}},n,void 0)})),function(e){console.error(e),process.exit(1)});case 2:case"end":return r.stop()}},r,void 0)}));return function(r,t){return e.apply(this,arguments)}}()),_commander2["default"].parse(process.argv);
"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}var _regenerator=require("babel-runtime/regenerator"),_regenerator2=_interopRequireDefault(_regenerator),_asyncToGenerator2=require("babel-runtime/helpers/asyncToGenerator"),_asyncToGenerator3=_interopRequireDefault(_asyncToGenerator2),_commander=require("commander"),_commander2=_interopRequireDefault(_commander),_test=require("./commands/test"),_test2=_interopRequireDefault(_test),_serve=require("./commands/serve"),_serve2=_interopRequireDefault(_serve),_create=require("./commands/create"),_create2=_interopRequireDefault(_create),_destroy=require("./commands/destroy"),_destroy2=_interopRequireDefault(_destroy),_generate=require("./commands/generate"),_generate2=_interopRequireDefault(_generate),_tryCatch=require("../../utils/try-catch"),_tryCatch2=_interopRequireDefault(_tryCatch);_commander2["default"].version("0.0.1-beta.6"),_commander2["default"].command("n <name>").alias("new").description("Create a new application").action(function(){var e=(0,_asyncToGenerator3["default"])(_regenerator2["default"].mark(function r(e){return _regenerator2["default"].wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,(0,_tryCatch2["default"])((0,_asyncToGenerator3["default"])(_regenerator2["default"].mark(function t(){return _regenerator2["default"].wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,(0,_create2["default"])(e);case 2:case"end":return r.stop()}},t,void 0)})),function(e){console.error(e),process.exit(1)});case 2:case"end":return r.stop()}},r,void 0)}));return function(r){return e.apply(this,arguments)}}()),_commander2["default"].command("t").alias("test").description("Run your app's tests").action(function(){var e=(0,_asyncToGenerator3["default"])(_regenerator2["default"].mark(function r(){return _regenerator2["default"].wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,_tryCatch2["default"])((0,_asyncToGenerator3["default"])(_regenerator2["default"].mark(function r(){return _regenerator2["default"].wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,_test2["default"])();case 2:case"end":return e.stop()}},r,void 0)})),function(e){console.error(e),process.exit(1)});case 2:case"end":return e.stop()}},r,void 0)}));return function(r){return e.apply(this,arguments)}}()),_commander2["default"].command("s").alias("serve").description("Serve your application").option("-e, --environment","(Default: development)").option("-p, --port","(Default: 4000)").action(function(){var e=(0,_asyncToGenerator3["default"])(_regenerator2["default"].mark(function r(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];return _regenerator2["default"].wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,_tryCatch2["default"])((0,_asyncToGenerator3["default"])(_regenerator2["default"].mark(function r(){var e;return _regenerator2["default"].wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return e=4e3,t.forEach(function(r){/^\d+$/gi.test(r)?e=parseInt(r,10):/^\w+$/gi.test(r)&&(process.env.NODE_ENV=r)}),r.next=4,(0,_serve2["default"])(e);case 4:case"end":return r.stop()}},r,void 0)})),function(e){console.error(e),process.exit(1)});case 2:case"end":return e.stop()}},r,void 0)}));return function(r){return e.apply(this,arguments)}}()),_commander2["default"].command("g").alias("generate").description("Example: lux generate model user").option("type").option("name").action(function(){var e=(0,_asyncToGenerator3["default"])(_regenerator2["default"].mark(function r(e,t){return _regenerator2["default"].wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,(0,_tryCatch2["default"])((0,_asyncToGenerator3["default"])(_regenerator2["default"].mark(function n(){return _regenerator2["default"].wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if("string"!=typeof e||"string"!=typeof t){r.next=5;break}return r.next=3,(0,_generate2["default"])(e,t);case 3:r.next=6;break;case 5:throw new TypeError("Invalid arguements for type or name");case 6:case"end":return r.stop()}},n,void 0)})),function(e){console.error(e),process.exit(1)});case 2:case"end":return r.stop()}},r,void 0)}));return function(r,t){return e.apply(this,arguments)}}()),_commander2["default"].command("d").alias("destroy").description("Example: lux destroy model user").option("type").option("name").action(function(){var e=(0,_asyncToGenerator3["default"])(_regenerator2["default"].mark(function r(e,t){return _regenerator2["default"].wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,(0,_tryCatch2["default"])((0,_asyncToGenerator3["default"])(_regenerator2["default"].mark(function n(){return _regenerator2["default"].wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if("string"!=typeof e||"string"!=typeof t){r.next=5;break}return r.next=3,(0,_destroy2["default"])(e,t);case 3:r.next=6;break;case 5:throw new TypeError("Invalid arguements for type or name");case 6:case"end":return r.stop()}},n,void 0)})),function(e){console.error(e),process.exit(1)});case 2:case"end":return r.stop()}},r,void 0)}));return function(r,t){return e.apply(this,arguments)}}()),_commander2["default"].parse(process.argv);

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=function(e){return('\n{\n "name": "'+e+'",\n "version": "0.0.1",\n "description": "",\n "main": "bin/app.js",\n "scripts": {\n "start": "lux serve",\n "test": "lux test"\n },\n "author": "",\n "license": "MIT",\n "dependencies": {\n "lux-framework": "0.0.1-beta.5",\n "babel-core": "6.7.7",\n "babel-eslint": "6.0.3",\n "babel-plugin-transform-decorators-legacy": "1.3.4",\n "babel-plugin-transform-runtime": "6.7.5",\n "babel-preset-es2015": "6.6.0",\n "babel-preset-stage-1": "6.5.0",\n "babel-runtime": "6.6.1",\n "mysql": "2.10.2"\n }\n}\n ').substr(1).trim()};
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=function(e){return('\n{\n "name": "'+e+'",\n "version": "0.0.1",\n "description": "",\n "main": "bin/app.js",\n "scripts": {\n "start": "lux serve",\n "test": "lux test"\n },\n "author": "",\n "license": "MIT",\n "dependencies": {\n "lux-framework": "0.0.1-beta.6",\n "babel-core": "6.7.7",\n "babel-eslint": "6.0.3",\n "babel-plugin-transform-decorators-legacy": "1.3.4",\n "babel-plugin-transform-runtime": "6.7.5",\n "babel-preset-es2015": "6.6.0",\n "babel-preset-stage-1": "6.5.0",\n "babel-runtime": "6.6.1",\n "mysql": "2.10.2"\n }\n}\n ').substr(1).trim()};

@@ -1,1 +0,1 @@

"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function _applyDecoratedDescriptor(e,r,t,i,a){var n={};return Object.keys(i).forEach(function(e){n[e]=i[e]}),n.enumerable=!!n.enumerable,n.configurable=!!n.configurable,("value"in n||n.initializer)&&(n.writable=!0),n=t.slice().reverse().reduce(function(t,i){return i(e,r,t)||t},n),a&&void 0!==n.initializer&&(n.value=n.initializer?n.initializer.call(a):void 0,n.initializer=void 0),void 0===n.initializer&&(Object.defineProperty(e,r,n),n=null),n}Object.defineProperty(exports,"__esModule",{value:!0});var _keys=require("babel-runtime/core-js/object/keys"),_keys2=_interopRequireDefault(_keys),_getOwnPropertyDescriptor=require("babel-runtime/core-js/object/get-own-property-descriptor"),_getOwnPropertyDescriptor2=_interopRequireDefault(_getOwnPropertyDescriptor),_regenerator=require("babel-runtime/regenerator"),_regenerator2=_interopRequireDefault(_regenerator),_asyncToGenerator2=require("babel-runtime/helpers/asyncToGenerator"),_asyncToGenerator3=_interopRequireDefault(_asyncToGenerator2),_stringify=require("babel-runtime/core-js/json/stringify"),_stringify2=_interopRequireDefault(_stringify),_toConsumableArray2=require("babel-runtime/helpers/toConsumableArray"),_toConsumableArray3=_interopRequireDefault(_toConsumableArray2),_map=require("babel-runtime/core-js/map"),_map2=_interopRequireDefault(_map),_getPrototypeOf=require("babel-runtime/core-js/object/get-prototype-of"),_getPrototypeOf2=_interopRequireDefault(_getPrototypeOf),_classCallCheck2=require("babel-runtime/helpers/classCallCheck"),_classCallCheck3=_interopRequireDefault(_classCallCheck2),_createClass2=require("babel-runtime/helpers/createClass"),_createClass3=_interopRequireDefault(_createClass2),_possibleConstructorReturn2=require("babel-runtime/helpers/possibleConstructorReturn"),_possibleConstructorReturn3=_interopRequireDefault(_possibleConstructorReturn2),_inherits2=require("babel-runtime/helpers/inherits"),_inherits3=_interopRequireDefault(_inherits2),_desc,_value,_class,_stream=require("stream"),_inflection=require("inflection"),_base=require("../base"),_base2=_interopRequireDefault(_base),_tryCatch=require("../../utils/try-catch"),_tryCatch2=_interopRequireDefault(_tryCatch),_bound=require("../../decorators/bound"),_bound2=_interopRequireDefault(_bound),max=Math.max,keys=_keys2["default"],isArray=Array.isArray,Serializer=(_class=function(e){function r(){var e,t,i,a;(0,_classCallCheck3["default"])(this,r);for(var n=arguments.length,l=Array(n),s=0;n>s;s++)l[s]=arguments[s];return t=i=(0,_possibleConstructorReturn3["default"])(this,(e=(0,_getPrototypeOf2["default"])(r)).call.apply(e,[this].concat(l))),i.hasOne=[],i.hasMany=[],i.attributes=[],i.serializers=new _map2["default"],a=t,(0,_possibleConstructorReturn3["default"])(i,a)}return(0,_inherits3["default"])(r,e),(0,_createClass3["default"])(r,[{key:"fieldsFor",value:function(e){var r=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];return r[(0,_inflection.camelize)(e.replace(/\-/g,"_"),!0)]}},{key:"attributesFor",value:function(e,r){var t=void 0,i=void 0,a=void 0;for(a={},r||(r=this.attributes),t=0;t<r.length;t++)i=r[t],i.indexOf("id")<0&&(a[this.formatKey(i)]=e[i]);return a}},{key:"relationshipsFor",value:function(e,r,t){var i=this.domain,a=this.hasOne,n=this.hasMany,l={data:{},included:[]},s=void 0,u=void 0,o=void 0,c=void 0,d=void 0,f=void 0,_=void 0,p=void 0;for(s=0;s<a.length;s++)c=a[s],_=e[c],_&&(o=_.id,d=(0,_inflection.pluralize)(_.getModelName()),l.data[c]={data:{id:o,type:d},links:{self:i+"/"+d+"/"+o}},r.indexOf(c)>=0&&(p=this.serializers.get(d),p&&l.included.push(p.serializeOne(_,[],t))));for(s=0;s<n.length;s++)if(c=n[s],f=e[c],f&&f.length)for(l.data[c]=[],f=f.slice(),u=0;s<f.length;u++)_=f[u],_&&(o=_.id,d||(d=(0,_inflection.pluralize)(_.getModelName())),l.data[c][s]={id:o,type:d,links:{self:i+"/"+d+"/"+o}},r.indexOf(c)>=0&&(p||(p=this.serializers.get(d)),p&&l.included.push(p.serializeOne(_,[],t))));return l}},{key:"formatKey",value:function(e){return(0,_inflection.dasherize)((0,_inflection.underscore)(e))}},{key:"serializeGroup",value:function(e,r,t,i,a){if(e.push('"'+this.formatKey(r)+'":'),"data"===r){var n=[],l=void 0;if(isArray(t)){l=max(t.length-1,0),e.push("[");for(var s=0;s<t.length;s++){var u=this.serializeOne(t[s],i,a);u.included&&u.included.length&&(n=[].concat((0,_toConsumableArray3["default"])(n),(0,_toConsumableArray3["default"])(u.included)),delete u.included),e.push((0,_stringify2["default"])(u)),s!==l&&e.push(",")}e.push("]")}else t=this.serializeOne(t,i,a,!1),t.included&&t.included.length&&(n=[].concat((0,_toConsumableArray3["default"])(n),(0,_toConsumableArray3["default"])(t.included)),delete t.included),e.push((0,_stringify2["default"])(t));if(n.length){l=max(n.length-1,0),e.push(',"included":[');for(var o=0;o<n.length;o++)e.push((0,_stringify2["default"])(n[o])),o!==l&&e.push(",");e.push("]")}}else e.push((0,_stringify2["default"])(t))}},{key:"serializePayload",value:function(){function e(e,t,i,a){return r.apply(this,arguments)}var r=(0,_asyncToGenerator3["default"])(_regenerator2["default"].mark(function t(e,r,i,a){var n=this;return _regenerator2["default"].wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return(0,_tryCatch2["default"])(function(){var t=void 0,l=void 0,s=void 0;for(e.push("{"),s=keys(r),t=0;t<s.length;t++)l=s[t],n.serializeGroup(e,l,r[l],i,a),e.push(",");e.push('"jsonapi":{"version":"1.0"}}')},function(e){console.error(e)}),e.push(null),t.abrupt("return",e);case 3:case"end":return t.stop()}},t,this)}));return e}()},{key:"stream",value:function t(e,r,i){var t=new _stream.Readable({encoding:"utf8"});return this.serializePayload(t,e,r,i),t}},{key:"serializeOne",value:function(e,r,t){var i=arguments.length<=3||void 0===arguments[3]?!0:arguments[3],a=e.id,n=e.getModelName(),l=(0,_inflection.pluralize)(n),s={id:a,type:l,attributes:this.attributesFor(e,this.fieldsFor(n,t))},u=this.relationshipsFor(e,r,t);return keys(u.data).length&&(s.relationships=u.data),u.included.length&&(s.included=u.included),i&&(s.links={self:this.domain+"/"+l+"/"+a}),s}}]),r}(_base2["default"]),_applyDecoratedDescriptor(_class.prototype,"serializeOne",[_bound2["default"]],(0,_getOwnPropertyDescriptor2["default"])(_class.prototype,"serializeOne"),_class.prototype),_class);exports["default"]=Serializer;
"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function _applyDecoratedDescriptor(e,r,t,i,a){var n={};return Object.keys(i).forEach(function(e){n[e]=i[e]}),n.enumerable=!!n.enumerable,n.configurable=!!n.configurable,("value"in n||n.initializer)&&(n.writable=!0),n=t.slice().reverse().reduce(function(t,i){return i(e,r,t)||t},n),a&&void 0!==n.initializer&&(n.value=n.initializer?n.initializer.call(a):void 0,n.initializer=void 0),void 0===n.initializer&&(Object.defineProperty(e,r,n),n=null),n}Object.defineProperty(exports,"__esModule",{value:!0});var _keys=require("babel-runtime/core-js/object/keys"),_keys2=_interopRequireDefault(_keys),_getOwnPropertyDescriptor=require("babel-runtime/core-js/object/get-own-property-descriptor"),_getOwnPropertyDescriptor2=_interopRequireDefault(_getOwnPropertyDescriptor),_regenerator=require("babel-runtime/regenerator"),_regenerator2=_interopRequireDefault(_regenerator),_asyncToGenerator2=require("babel-runtime/helpers/asyncToGenerator"),_asyncToGenerator3=_interopRequireDefault(_asyncToGenerator2),_stringify=require("babel-runtime/core-js/json/stringify"),_stringify2=_interopRequireDefault(_stringify),_toConsumableArray2=require("babel-runtime/helpers/toConsumableArray"),_toConsumableArray3=_interopRequireDefault(_toConsumableArray2),_defineProperty2=require("babel-runtime/helpers/defineProperty"),_defineProperty3=_interopRequireDefault(_defineProperty2),_extends3=require("babel-runtime/helpers/extends"),_extends4=_interopRequireDefault(_extends3),_map=require("babel-runtime/core-js/map"),_map2=_interopRequireDefault(_map),_getPrototypeOf=require("babel-runtime/core-js/object/get-prototype-of"),_getPrototypeOf2=_interopRequireDefault(_getPrototypeOf),_classCallCheck2=require("babel-runtime/helpers/classCallCheck"),_classCallCheck3=_interopRequireDefault(_classCallCheck2),_createClass2=require("babel-runtime/helpers/createClass"),_createClass3=_interopRequireDefault(_createClass2),_possibleConstructorReturn2=require("babel-runtime/helpers/possibleConstructorReturn"),_possibleConstructorReturn3=_interopRequireDefault(_possibleConstructorReturn2),_inherits2=require("babel-runtime/helpers/inherits"),_inherits3=_interopRequireDefault(_inherits2),_desc,_value,_class,_stream=require("stream"),_inflection=require("inflection"),_base=require("../base"),_base2=_interopRequireDefault(_base),_tryCatch=require("../../utils/try-catch"),_tryCatch2=_interopRequireDefault(_tryCatch),_bound=require("../../decorators/bound"),_bound2=_interopRequireDefault(_bound),max=Math.max,keys=_keys2["default"],isArray=Array.isArray,Serializer=(_class=function(e){function r(){var e,t,i,a;(0,_classCallCheck3["default"])(this,r);for(var n=arguments.length,l=Array(n),u=0;n>u;u++)l[u]=arguments[u];return t=i=(0,_possibleConstructorReturn3["default"])(this,(e=(0,_getPrototypeOf2["default"])(r)).call.apply(e,[this].concat(l))),i.hasOne=[],i.hasMany=[],i.attributes=[],i.serializers=new _map2["default"],a=t,(0,_possibleConstructorReturn3["default"])(i,a)}return(0,_inherits3["default"])(r,e),(0,_createClass3["default"])(r,[{key:"fieldsFor",value:function(e){var r=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];return r[(0,_inflection.camelize)(e.replace(/\-/g,"_"),!0)]}},{key:"attributesFor",value:function(e,r){var t=void 0,i=void 0,a=void 0;for(a={},r||(r=this.attributes),t=0;t<r.length;t++)i=r[t],i.indexOf("id")<0&&(a[this.formatKey(i)]=e[i]);return a}},{key:"relationshipsFor",value:function(e,r,t){var i=this,a=this.domain,n=this.hasOne,l=this.hasMany,u={data:{},included:[]},s=void 0,o=void 0,d=void 0,c=void 0,f=void 0,_=void 0,p=void 0;for(s=0;s<n.length;s++)d=n[s],_=e[d],_&&(o=_.id,c=(0,_inflection.pluralize)(_.getModelName()),u.data[d]={data:{id:o,type:c},links:{self:a+"/"+c+"/"+o}},r.indexOf(d)>=0&&(p=this.serializers.get(c),p&&u.included.push(p.serializeOne(_,[],t))));return u.data=(0,_extends4["default"])({},u.data,l.reduce(function(n,l){return f=e[l],f&&f.length?(0,_extends4["default"])({},n,(0,_defineProperty3["default"])({},l,{data:f.map(function(e){return o=e.id,c||(c=(0,_inflection.pluralize)(e.getModelName())),r.indexOf(l)>=0&&(p||(p=i.serializers.get(c)),p&&u.included.push(p.serializeOne(e,[],t))),{id:o,type:c,links:{self:a+"/"+c+"/"+o}}})})):n},{})),u}},{key:"formatKey",value:function(e){return(0,_inflection.dasherize)((0,_inflection.underscore)(e))}},{key:"serializeGroup",value:function(e,r,t,i,a){if(e.push('"'+this.formatKey(r)+'":'),"data"===r){var n=[],l=void 0;if(isArray(t)){l=max(t.length-1,0),e.push("[");for(var u=0;u<t.length;u++){var s=this.serializeOne(t[u],i,a);s.included&&s.included.length&&(n=[].concat((0,_toConsumableArray3["default"])(n),(0,_toConsumableArray3["default"])(s.included)),delete s.included),e.push((0,_stringify2["default"])(s)),u!==l&&e.push(",")}e.push("]")}else t=this.serializeOne(t,i,a,!1),t.included&&t.included.length&&(n=[].concat((0,_toConsumableArray3["default"])(n),(0,_toConsumableArray3["default"])(t.included)),delete t.included),e.push((0,_stringify2["default"])(t));if(n.length){l=max(n.length-1,0),e.push(',"included":[');for(var o=0;o<n.length;o++)e.push((0,_stringify2["default"])(n[o])),o!==l&&e.push(",");e.push("]")}}else e.push((0,_stringify2["default"])(t))}},{key:"serializePayload",value:function(){function e(e,t,i,a){return r.apply(this,arguments)}var r=(0,_asyncToGenerator3["default"])(_regenerator2["default"].mark(function t(e,r,i,a){var n=this;return _regenerator2["default"].wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return(0,_tryCatch2["default"])(function(){var t=void 0,l=void 0,u=void 0;for(e.push("{"),u=keys(r),t=0;t<u.length;t++)l=u[t],n.serializeGroup(e,l,r[l],i,a),e.push(",");e.push('"jsonapi":{"version":"1.0"}}')},function(e){console.error(e)}),e.push(null),t.abrupt("return",e);case 3:case"end":return t.stop()}},t,this)}));return e}()},{key:"stream",value:function t(e,r,i){var t=new _stream.Readable({encoding:"utf8"});return this.serializePayload(t,e,r,i),t}},{key:"serializeOne",value:function(e,r,t){var i=arguments.length<=3||void 0===arguments[3]?!0:arguments[3],a=e.id,n=e.getModelName(),l=(0,_inflection.pluralize)(n),u={id:a,type:l,attributes:this.attributesFor(e,this.fieldsFor(n,t))},s=this.relationshipsFor(e,r,t);return keys(s.data).length&&(u.relationships=s.data),s.included.length&&(u.included=s.included),i&&(u.links={self:this.domain+"/"+l+"/"+a}),u}}]),r}(_base2["default"]),_applyDecoratedDescriptor(_class.prototype,"serializeOne",[_bound2["default"]],(0,_getOwnPropertyDescriptor2["default"])(_class.prototype,"serializeOne"),_class.prototype),_class);exports["default"]=Serializer;
{
"name": "lux-framework",
"version": "0.0.1-beta.5",
"version": "0.0.1-beta.6",
"description": "A MVC style Node.js framework for building lightning fast JSON APIs",

@@ -5,0 +5,0 @@ "repository": "https://github.com/postlight/lux",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc