Socket
Socket
Sign inDemoInstall

rheactor-event-store

Package Overview
Dependencies
7
Maintainers
3
Versions
34
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 9.5.0 to 9.6.0

30

dist/aggregate-meta.js

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

* @param {Date|undefined} deletedAt
* @param {Number} createdBy
*/
function AggregateMeta(id, version) {
var createdAt = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new Date();
var updatedAt = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : undefined;
var deletedAt = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : undefined;
var updatedAt = arguments[3];
var deletedAt = arguments[4];
var createdBy = arguments[5];
_classCallCheck(this, AggregateMeta);
(0, _types.AggregateIdType)(id, ['AggregateMeta', 'id:AggregateId']);
(0, _types.AggregateVersionType)(version, ['AggregateMeta', 'version:AggregateVersion']);
(0, _tcomb.Date)(createdAt, ['AggregateMeta', 'createdAt:Date']);
MaybeDateType(updatedAt, ['AggregateMeta', 'updatedAt:?Date']);
MaybeDateType(deletedAt, ['AggregateMeta', 'deletedAt:?Date']);
this._id = id;
this._version = version;
this._id = (0, _types.AggregateIdType)(id, ['AggregateMeta', 'id:AggregateId']);
this._version = (0, _types.AggregateVersionType)(version, ['AggregateMeta', 'version:AggregateVersion']);
this._createdAt = createdAt;
this._updatedAt = updatedAt;
this._deletedAt = deletedAt;
this._updatedAt = MaybeDateType(updatedAt, ['AggregateMeta', 'updatedAt:?Date']);
this._deletedAt = MaybeDateType(deletedAt, ['AggregateMeta', 'deletedAt:?Date']);
this._createdBy = (0, _types.MaybeAggregateIdType)(createdBy, ['AggregateMeta', 'createdBy:?AggregateId']);
}

@@ -167,2 +165,12 @@

}
/**
* @returns {Number|undefined}
*/
}, {
key: 'createdBy',
get: function get() {
return this._createdBy;
}
}], [{

@@ -169,0 +177,0 @@ key: 'is',

@@ -30,3 +30,2 @@ 'use strict';

var AggregateRepository = exports.AggregateRepository = function () {
/**

@@ -33,0 +32,0 @@ * Creates a new aggregate repository

@@ -37,3 +37,4 @@ 'use strict';

updatedAt: null,
deletedAt: null
deletedAt: null,
createdBy: null
}

@@ -46,2 +47,3 @@ });

* @param {Date} createdAt
* @param {String|undefined} createdBy
*/

@@ -54,2 +56,3 @@

var createdAt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Date();
var createdBy = arguments[2];

@@ -61,2 +64,3 @@ (0, _types.AggregateIdType)(aggregateId);

this.$aggregateMeta.createdAt = createdAt;
this.$aggregateMeta.createdBy = (0, _types.MaybeAggregateIdType)(createdBy, ['AggregateRoot', 'persisted()', 'createdBy:?AggregateId']);
}

@@ -134,3 +138,3 @@

*
* @returns {Number}
* @returns {Date}
*/

@@ -147,3 +151,3 @@

*
* @returns {Number|null}
* @returns {Date|null}
*/

@@ -161,3 +165,3 @@

*
* @returns {Number}
* @returns {Date}
*/

@@ -180,3 +184,3 @@

*
* @returns {Number|null}
* @returns {Date|null}
*/

@@ -191,2 +195,14 @@

/**
* Returns the id of the creator
*
* @returns {String|undefined}
*/
}, {
key: 'createdBy',
value: function createdBy() {
return this.$aggregateMeta.createdBy;
}
/**
* Applies the event to the aggregate.

@@ -216,3 +232,3 @@ * Should return the modified aggregate.

value: function is(x) {
return x instanceof AggregateRoot || x && x.constructor && x.constructor.name === AggregateRoot.name && 'persisted' in x && 'updated' in x && 'deleted' in x && 'aggregateVersion' in x && 'aggregateId' in x && 'isDeleted' in x && 'createdAt' in x && 'modifiedAt' in x && 'updatedAt' in x && 'deletedAt' in x;
return x instanceof AggregateRoot || x && x.constructor && x.constructor.name === AggregateRoot.name && 'persisted' in x && 'updated' in x && 'deleted' in x && 'aggregateVersion' in x && 'aggregateId' in x && 'isDeleted' in x && 'createdAt' in x && 'modifiedAt' in x && 'updatedAt' in x && 'deletedAt' in x && 'createdBy' in x;
}

@@ -219,0 +235,0 @@ }]);

@@ -27,3 +27,2 @@ 'use strict';

var ImmutableAggregateRepository = exports.ImmutableAggregateRepository = function () {
/**

@@ -30,0 +29,0 @@ * Creates a new aggregate repository

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

});
exports.AggregateVersionType = exports.AggregateIdType = exports.MaybeStringType = exports.PositiveIntegerType = undefined;
exports.AggregateVersionType = exports.MaybeAggregateIdType = exports.AggregateIdType = exports.MaybeStringType = exports.PositiveIntegerType = undefined;

@@ -16,4 +16,5 @@ var _tcomb = require('tcomb');

var AggregateIdType = exports.AggregateIdType = (0, _tcomb.union)([_tcomb.String, PositiveIntegerType]);
var MaybeAggregateIdType = exports.MaybeAggregateIdType = (0, _tcomb.maybe)(AggregateIdType);
var AggregateVersionType = exports.AggregateVersionType = (0, _tcomb.refinement)(_tcomb.Integer, function (n) {
return n > 0;
}, 'AggregateVersionType');
{
"name": "rheactor-event-store",
"description": "Implementation of an event store based on redis",
"version": "9.5.0",
"version": "9.6.0",
"main": "dist/index.js",

@@ -45,3 +45,3 @@ "scripts": {

"semantic-release": "^6.3.2",
"standard": "^8.6.0",
"standard": "^9.0.0",
"validate-commit-msg": "^2.11.1"

@@ -48,0 +48,0 @@ },

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

import {AggregateIdType, AggregateVersionType} from './types'
import {AggregateIdType, MaybeAggregateIdType, AggregateVersionType} from './types'
import {Date as DateType, irreducible, maybe} from 'tcomb'

@@ -12,14 +12,11 @@ const MaybeDateType = maybe(DateType)

* @param {Date|undefined} deletedAt
* @param {Number} createdBy
*/
constructor (id, version, createdAt = new Date(), updatedAt = undefined, deletedAt = undefined) {
AggregateIdType(id, ['AggregateMeta', 'id:AggregateId'])
AggregateVersionType(version, ['AggregateMeta', 'version:AggregateVersion'])
DateType(createdAt, ['AggregateMeta', 'createdAt:Date'])
MaybeDateType(updatedAt, ['AggregateMeta', 'updatedAt:?Date'])
MaybeDateType(deletedAt, ['AggregateMeta', 'deletedAt:?Date'])
this._id = id
this._version = version
constructor (id, version, createdAt = new Date(), updatedAt, deletedAt, createdBy) {
this._id = AggregateIdType(id, ['AggregateMeta', 'id:AggregateId'])
this._version = AggregateVersionType(version, ['AggregateMeta', 'version:AggregateVersion'])
this._createdAt = createdAt
this._updatedAt = updatedAt
this._deletedAt = deletedAt
this._updatedAt = MaybeDateType(updatedAt, ['AggregateMeta', 'updatedAt:?Date'])
this._deletedAt = MaybeDateType(deletedAt, ['AggregateMeta', 'deletedAt:?Date'])
this._createdBy = MaybeAggregateIdType(createdBy, ['AggregateMeta', 'createdBy:?AggregateId'])
}

@@ -88,2 +85,9 @@

/**
* @returns {Number|undefined}
*/
get createdBy () {
return this._createdBy
}
/**
* Returns an instance of this with updated version and the updatedAt timestamp set

@@ -90,0 +94,0 @@ *

@@ -13,3 +13,2 @@ import {EventStore} from './event-store'

export class AggregateRepository {
/**

@@ -16,0 +15,0 @@ * Creates a new aggregate repository

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

import {AggregateIdType} from './types'
import {AggregateIdType, MaybeAggregateIdType} from './types'
import {Date as DateType, irreducible} from 'tcomb'

@@ -21,3 +21,4 @@ import {ModelEventType} from './model-event'

updatedAt: null,
deletedAt: null
deletedAt: null,
createdBy: null
}

@@ -30,4 +31,5 @@ })

* @param {Date} createdAt
* @param {String|undefined} createdBy
*/
persisted (aggregateId, createdAt = new Date()) {
persisted (aggregateId, createdAt = new Date(), createdBy) {
AggregateIdType(aggregateId)

@@ -38,2 +40,3 @@ DateType(createdAt)

this.$aggregateMeta.createdAt = createdAt
this.$aggregateMeta.createdBy = MaybeAggregateIdType(createdBy, ['AggregateRoot', 'persisted()', 'createdBy:?AggregateId'])
}

@@ -92,3 +95,3 @@

*
* @returns {Number}
* @returns {Date}
*/

@@ -102,3 +105,3 @@ createdAt () {

*
* @returns {Number|null}
* @returns {Date|null}
*/

@@ -113,3 +116,3 @@ updatedAt () {

*
* @returns {Number}
* @returns {Date}
*/

@@ -129,3 +132,3 @@ modifiedAt () {

*
* @returns {Number|null}
* @returns {Date|null}
*/

@@ -137,2 +140,11 @@ deletedAt () {

/**
* Returns the id of the creator
*
* @returns {String|undefined}
*/
createdBy () {
return this.$aggregateMeta.createdBy
}
/**
* Applies the event to the aggregate.

@@ -169,3 +181,4 @@ * Should return the modified aggregate.

'updatedAt' in x &&
'deletedAt' in x
'deletedAt' in x &&
'createdBy' in x
)

@@ -172,0 +185,0 @@ }

@@ -84,3 +84,2 @@ import {Promise} from 'bluebird'

}
}

@@ -10,3 +10,2 @@ import {EventStore} from './event-store'

export class ImmutableAggregateRepository {
/**

@@ -13,0 +12,0 @@ * Creates a new aggregate repository

@@ -6,2 +6,3 @@ import {union, Integer as IntegerType, String as StringType, maybe, refinement} from 'tcomb'

export const AggregateIdType = union([StringType, PositiveIntegerType])
export const MaybeAggregateIdType = maybe(AggregateIdType)
export const AggregateVersionType = refinement(IntegerType, n => n > 0, 'AggregateVersionType')

@@ -92,2 +92,12 @@ /* global describe, it */

})
describe('.createdBy', () => {
it('should return id of the creator', () => {
const a = new AggregateMeta('17', 1, undefined, undefined, undefined, '42')
expect(a.createdBy).to.equal('42')
})
it('should default to new undefined', () => {
const a = new AggregateMeta('17', 1)
expect(a.createdBy).to.equal(undefined)
})
})
describe('.is()', () => {

@@ -94,0 +104,0 @@ it('should return true, if ImmutableAggregateRoot is passed', () => {

@@ -89,2 +89,14 @@ /* global describe, it */

})
describe('.createdBy()', () => {
it('should return if of the creator', () => {
const a = new AggregateRoot()
a.persisted('42', undefined, '17')
expect(a.createdBy()).to.equal('17')
})
it('should default to undefined', () => {
const a = new AggregateRoot()
a.persisted('42')
expect(a.createdBy()).to.equal(undefined)
})
})
describe('.is()', () => {

@@ -106,3 +118,4 @@ it('should return true, if AggregateRoot is passed', () => {

updatedAt: () => {},
deletedAt: () => {}
deletedAt: () => {},
createdBy: () => {}
}

@@ -109,0 +122,0 @@ expect(AggregateRoot.is(root)).to.equal(true)

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc