Socket
Socket
Sign inDemoInstall

starhs-models

Package Overview
Dependencies
3
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.1.0 to 4.2.0

56

dist/model.js

@@ -20,9 +20,25 @@ 'use strict';

var maybeDate = (0, _tcomb.maybe)(_tcomb.Date);
var Model = exports.Model = function () {
function Model($context) {
/**
* @param {{$context: URIValue, $createdAt: Date|undefined, $updatedAt: Date|undefined, $deletedAt: Date|undefined}} fields
*/
function Model(fields) {
_classCallCheck(this, Model);
var $context = fields.$context,
$createdAt = fields.$createdAt,
$updatedAt = fields.$updatedAt,
$deletedAt = fields.$deletedAt;
_uri2.default.Type($context);
maybeDate($createdAt);
maybeDate($updatedAt);
maybeDate($deletedAt);
this.$context = $context;
this.$links = [];
this.$createdAt = $createdAt;
this.$updatedAt = $updatedAt;
this.$deletedAt = $deletedAt;
}

@@ -40,5 +56,43 @@

$context: this.$context.toString(),
$createdAt: this.$createdAt ? this.$createdAt.toUTCString() : undefined,
$updatedAt: this.$updatedAt ? this.$updatedAt.toUTCString() : undefined,
$deletedAt: this.$deletedAt ? this.$deletedAt.toUTCString() : undefined,
$links: this.$links
};
}
/**
* @param {{$context: string, $createdAt: string|undefined, $updatedAt: string|undefined, $deletedAt: string|undefined}} data
* @returns {Model}
*/
}, {
key: '$modifiedAt',
/**
* Returns the timestamp when the model was modified the last time, which is the latest value of
* createdAt, updatedAt or deletedAt
*
* @returns {Date|undefined}
*/
get: function get() {
if (this.$deletedAt) {
return this.$deletedAt;
}
if (this.$updatedAt) {
return this.$updatedAt;
}
return this.$createdAt;
}
}], [{
key: 'fromJSON',
value: function fromJSON(data) {
return new Model({
$context: new _uri2.default(data.$context),
$createdAt: data.$createdAt ? new Date(data.$createdAt) : undefined,
$updatedAt: data.$updatedAt ? new Date(data.$updatedAt) : undefined,
$deletedAt: data.$deletedAt ? new Date(data.$deletedAt) : undefined
});
}
}]);

@@ -45,0 +99,0 @@

6

dist/profile.js

@@ -45,3 +45,3 @@ 'use strict';

var _this = _possibleConstructorReturn(this, (Profile.__proto__ || Object.getPrototypeOf(Profile)).call(this, $context));
var _this = _possibleConstructorReturn(this, (Profile.__proto__ || Object.getPrototypeOf(Profile)).call(this, { $context: $context }));

@@ -106,3 +106,3 @@ var email = fields.email,

return new Profile({
return new Profile((0, _lodash.merge)(_get(Profile.__proto__ || Object.getPrototypeOf(Profile), 'fromJSON', this).call(this, data), {
email: new _email2.default(email),

@@ -112,3 +112,3 @@ firstname: firstname,

avatar: avatar ? new _uri2.default(avatar) : avatar
});
}));
}

@@ -115,0 +115,0 @@

@@ -39,3 +39,3 @@ 'use strict';

/**
* @param {{from: PersonType, to: PersonType, amount: number, message: string}} fields
* @param {{from: PersonType, to: PersonType, amount: number, message: string, $createdAt: Date}} fields
*/

@@ -45,9 +45,10 @@ function StaRH(fields) {

var _this = _possibleConstructorReturn(this, (StaRH.__proto__ || Object.getPrototypeOf(StaRH)).call(this, $context));
var from = fields.from,
to = fields.to,
amount = fields.amount,
message = fields.message;
message = fields.message,
$createdAt = fields.$createdAt;
var _this = _possibleConstructorReturn(this, (StaRH.__proto__ || Object.getPrototypeOf(StaRH)).call(this, { $context: $context, $createdAt: $createdAt }));
PersonType(from);

@@ -65,3 +66,3 @@ PersonType(to);

/**
* @returns {{from: string, to: string, amount: number, message: string, $context: string, $links: Array<{href: string, $context: string}>}}
* @returns {{from: string, to: string, amount: number, message: string, $createdAt: string, $context: string, $links: Array<{href: string, $context: string}>}}
*/

@@ -76,7 +77,7 @@

name: this.from.name,
avatar: this.from.avatar.toString()
avatar: this.from.avatar ? this.from.avatar.toString() : undefined
},
to: {
name: this.to.name,
avatar: this.to.avatar.toString()
avatar: this.to.avatar ? this.to.avatar.toString() : undefined
},

@@ -96,14 +97,14 @@ amount: this.amount,

value: function fromJSON(data) {
return new StaRH({
return new StaRH((0, _lodash.merge)(_get(StaRH.__proto__ || Object.getPrototypeOf(StaRH), 'fromJSON', this).call(this, data), {
from: {
name: data.from.name,
avatar: new _uri2.default(data.from.avatar)
avatar: data.from.avatar ? new _uri2.default(data.from.avatar) : undefined
},
to: {
name: data.to.name,
avatar: new _uri2.default(data.to.avatar)
avatar: data.to.avatar ? new _uri2.default(data.to.avatar) : undefined
},
amount: data.amount,
message: data.message
});
}));
}

@@ -128,2 +129,2 @@

});
var PersonType = exports.PersonType = (0, _tcomb.struct)({ name: _tcomb.String, avatar: _uri2.default.Type }, 'PersonType');
var PersonType = exports.PersonType = (0, _tcomb.struct)({ name: _tcomb.String, avatar: (0, _tcomb.maybe)(_uri2.default.Type) }, 'PersonType');

@@ -44,3 +44,3 @@ 'use strict';

var _this = _possibleConstructorReturn(this, (StaRHsStatus.__proto__ || Object.getPrototypeOf(StaRHsStatus)).call(this, $context));
var _this = _possibleConstructorReturn(this, (StaRHsStatus.__proto__ || Object.getPrototypeOf(StaRHsStatus)).call(this, { $context: $context }));

@@ -91,3 +91,3 @@ var cycleShared = fields.cycleShared,

value: function fromJSON(data) {
return new StaRHsStatus(data);
return new StaRHsStatus((0, _lodash.merge)(_get(StaRHsStatus.__proto__ || Object.getPrototypeOf(StaRHsStatus), 'fromJSON', this).call(this, data), data));
}

@@ -94,0 +94,0 @@

{
"name": "starhs-models",
"version": "4.1.0",
"version": "4.2.0",
"description": "Shared models for the staRHs API",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc