cqrs-eventdenormalizer
Advanced tools
Comparing version 1.15.0 to 1.16.0
@@ -8,2 +8,3 @@ var debug = require('debug')('denormalizer'), | ||
uuid = require('uuid').v4, | ||
customLoader = require('./structure/customLoader'), | ||
structureLoader = require('./structure/structureLoader'), | ||
@@ -17,2 +18,14 @@ attachLookupFunctions = require('./structure/treeExtender'), | ||
function createStructureLoader (options) { | ||
if (options) { | ||
if (!_.isFunction(options)) { | ||
var err = new Error('"options.structureLoader" is not a valid structure loader method'); | ||
debug(err); | ||
throw err; | ||
}; | ||
return customLoader(options); | ||
} | ||
return structureLoader; | ||
} | ||
/** | ||
@@ -42,2 +55,4 @@ * Denormalizer constructor | ||
this.structureLoader = createStructureLoader(options.structureLoader); | ||
this.repository = viewmodel.write(options.repository); | ||
@@ -272,3 +287,3 @@ | ||
debug('load denormalizer files..'); | ||
structureLoader(self.options.denormalizerPath, function (err, tree, warns) { | ||
self.structureLoader(self.options.denormalizerPath, function (err, tree, warns) { | ||
if (err) { | ||
@@ -275,0 +290,0 @@ return callback(err); |
{ | ||
"author": "adrai", | ||
"name": "cqrs-eventdenormalizer", | ||
"version": "1.15.0", | ||
"version": "1.16.0", | ||
"private": false, | ||
@@ -6,0 +6,0 @@ "main": "index.js", |
@@ -301,2 +301,31 @@ # Introduction | ||
## Using custom structure loader function | ||
The built-in structure loader can be replaced with one adapted to your needs. | ||
To do that, you need to include a loading method in the options object passed to the domain constructor. | ||
// options will contain denormalizerPath as well as the as well as a definition object containing all the constructors of the denormalizer components ( Collection, ViewBuilder etc. ) | ||
function structureLoader(options) { | ||
const collection = new options.definitions.Collection({ | ||
name: 'col' | ||
}); | ||
collection.addViewBuilder(new options.definitions.ViewBuilder({ | ||
name: 'evt', | ||
aggregate: 'agg', | ||
context: 'ctx' | ||
}, function() {})); | ||
return { | ||
collections: [ | ||
collection | ||
] | ||
}; | ||
// or more probably | ||
return myExternalLoader(options.denormalizerPath, options.definitions); | ||
} | ||
require('cqrs-eventdenormalizer')({ | ||
denormalizerPath: '/path/to/my/files', | ||
structureLoader: structureLoader | ||
}); | ||
## Initialization | ||
@@ -303,0 +332,0 @@ |
@@ -0,1 +1,4 @@ | ||
## [v1.16.0](https://github.com/adrai/node-cqrs-eventdenormalizer/compare/v1.15.0...v1.16.0) | ||
- add option to add custom structureLoader implementation | ||
## [v1.15.0](https://github.com/adrai/node-cqrs-eventdenormalizer/compare/v1.14.12...v1.15.0) | ||
@@ -2,0 +5,0 @@ - add useAsId methods to ViewModel and EventExtender [#75](https://github.com/adrai/node-cqrs-eventdenormalizer/pull/75) thanks to [nanov](https://github.com/nanov) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
204322
30
4665
927
1