starhs-models
Advanced tools
Comparing version 5.1.2 to 5.1.3
@@ -42,3 +42,2 @@ 'use strict'; | ||
var $id = fields.$id, | ||
$context = fields.$context, | ||
$createdAt = fields.$createdAt, | ||
@@ -48,3 +47,3 @@ $updatedAt = fields.$updatedAt, | ||
var _this = _possibleConstructorReturn(this, (Entity.__proto__ || Object.getPrototypeOf(Entity)).call(this, { $context: $context })); | ||
var _this = _possibleConstructorReturn(this, (Entity.__proto__ || Object.getPrototypeOf(Entity)).call(this, fields)); | ||
@@ -106,3 +105,3 @@ (0, _tcomb.String)($id); | ||
EntityJSONType(data); | ||
return new Entity({ | ||
return new Entity((0, _lodash.merge)(_get(Entity.__proto__ || Object.getPrototypeOf(Entity), 'fromJSON', this).call(this, data), { | ||
$id: data.$id, | ||
@@ -113,3 +112,3 @@ $context: new _uri2.default(data.$context), | ||
$deletedAt: data.$deletedAt ? new Date(data.$deletedAt) : undefined | ||
}); | ||
})); | ||
} | ||
@@ -116,0 +115,0 @@ }]); |
@@ -16,2 +16,4 @@ 'use strict'; | ||
var _link = require('./link'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -21,2 +23,4 @@ | ||
var LinkListType = (0, _tcomb.list)(_link.Link); | ||
var Model = exports.Model = function () { | ||
@@ -29,7 +33,9 @@ /** | ||
var $context = fields.$context; | ||
var $context = fields.$context, | ||
$links = fields.$links; | ||
_uri2.default.Type($context); | ||
LinkListType($links || []); | ||
this.$context = $context; | ||
this.$links = []; | ||
this.$links = $links || []; | ||
} | ||
@@ -64,3 +70,6 @@ | ||
return new Model({ | ||
$context: new _uri2.default(data.$context) | ||
$context: new _uri2.default(data.$context), | ||
$links: data.$links ? data.$links.map(function (l) { | ||
return _link.Link.fromJSON(l); | ||
}) : [] | ||
}); | ||
@@ -74,3 +83,4 @@ } | ||
var ModelJSONType = exports.ModelJSONType = (0, _tcomb.struct)({ | ||
$context: _tcomb.String | ||
$context: _tcomb.String, | ||
$links: (0, _tcomb.maybe)((0, _tcomb.list)(_link.LinkJSONType)) | ||
}, 'ModelJSONType'); | ||
@@ -77,0 +87,0 @@ var ModelType = exports.ModelType = (0, _tcomb.irreducible)('ModelType', function (x) { |
@@ -26,4 +26,2 @@ 'use strict'; | ||
var _link = require('./link'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -37,3 +35,2 @@ | ||
var LinkListType = (0, _tcomb.list)(_link.Link); | ||
var $context = new _uri2.default('https://github.com/ResourcefulHumans/staRHs-models#Profile'); | ||
@@ -50,10 +47,8 @@ | ||
var $id = fields.$id, | ||
email = fields.email, | ||
var email = fields.email, | ||
firstname = fields.firstname, | ||
lastname = fields.lastname, | ||
avatar = fields.avatar, | ||
$links = fields.$links; | ||
avatar = fields.avatar; | ||
var _this = _possibleConstructorReturn(this, (Profile.__proto__ || Object.getPrototypeOf(Profile)).call(this, { $id: $id, $context: $context })); | ||
var _this = _possibleConstructorReturn(this, (Profile.__proto__ || Object.getPrototypeOf(Profile)).call(this, (0, _lodash.merge)(fields, { $context: $context }))); | ||
@@ -64,3 +59,2 @@ (0, _tcomb.String)(firstname); | ||
(0, _tcomb.maybe)(_uri2.default.Type)(avatar); | ||
LinkListType($links || []); | ||
_this.email = email; | ||
@@ -70,3 +64,2 @@ _this.firstname = firstname; | ||
_this.avatar = avatar; | ||
_this.$links = $links || []; | ||
return _this; | ||
@@ -147,4 +140,3 @@ } | ||
lastname: _tcomb.String, | ||
avatar: _tcomb.String, | ||
$links: (0, _tcomb.maybe)((0, _tcomb.list)(_link.LinkJSONType)) | ||
avatar: _tcomb.String | ||
}, 'ProfileJSONType'); | ||
@@ -151,0 +143,0 @@ var ProfileType = exports.ProfileType = (0, _tcomb.irreducible)('ProfileType', function (x) { |
@@ -44,10 +44,8 @@ 'use strict'; | ||
var $id = fields.$id, | ||
from = fields.from, | ||
var from = fields.from, | ||
to = fields.to, | ||
amount = fields.amount, | ||
message = fields.message, | ||
$createdAt = fields.$createdAt; | ||
message = fields.message; | ||
var _this = _possibleConstructorReturn(this, (StaRH.__proto__ || Object.getPrototypeOf(StaRH)).call(this, { $id: $id, $context: $context, $createdAt: $createdAt })); | ||
var _this = _possibleConstructorReturn(this, (StaRH.__proto__ || Object.getPrototypeOf(StaRH)).call(this, (0, _lodash.merge)(fields, { $context: $context }))); | ||
@@ -54,0 +52,0 @@ PersonType(from); |
@@ -44,3 +44,3 @@ 'use strict'; | ||
var _this = _possibleConstructorReturn(this, (StaRHsStatus.__proto__ || Object.getPrototypeOf(StaRHsStatus)).call(this, { $context: $context })); | ||
var _this = _possibleConstructorReturn(this, (StaRHsStatus.__proto__ || Object.getPrototypeOf(StaRHsStatus)).call(this, (0, _lodash.merge)(fields, { $context: $context }))); | ||
@@ -47,0 +47,0 @@ var cycleShared = fields.cycleShared, |
{ | ||
"name": "starhs-models", | ||
"version": "5.1.2", | ||
"version": "5.1.3", | ||
"description": "Shared models for the staRHs API", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
39504
774