Comparing version 0.6.0 to 0.6.1
@@ -6,2 +6,13 @@ # Change Log | ||
## [0.6.1](https://github.com/ai-labs-team/mgFx/compare/mgfx@0.6.0...mgfx@0.6.1) (2020-04-08) | ||
### Bug Fixes | ||
* core: always return original input value from validation ([17e8c68](https://github.com/ai-labs-team/mgFx/commit/17e8c68)) | ||
# [0.6.0](https://github.com/ai-labs-team/mgFx/compare/mgfx@0.5.3...mgfx@0.6.0) (2020-04-03) | ||
@@ -8,0 +19,0 @@ |
@@ -39,3 +39,3 @@ /** | ||
*/ | ||
export declare type EnvironmentInitializer<S extends Spec = Spec> = (process: Pick<Process<S>, 'id' | 'context' | 'input'>) => Environment<S>; | ||
export declare type EnvironmentInitializer<S extends Spec = Spec> = (process: Pick<Process, 'id' | 'context' | 'input'>) => Environment<S>; | ||
/** | ||
@@ -42,0 +42,0 @@ * A 'run' function is used by various components; it accepts a Process object (created by calling a Task's Definition |
@@ -46,6 +46,6 @@ "use strict"; | ||
process: rest, | ||
context: context ? context.values : {}, | ||
runChild: child => child | ||
.pipe(fluture_1.map(childProcess => (Object.assign(Object.assign({}, childProcess), { parentId: process.id, context })))) | ||
.pipe(self.run), | ||
context: context ? context.values : {} | ||
.pipe(self.run) | ||
}; | ||
@@ -57,9 +57,10 @@ }; | ||
.pre(process) | ||
.pipe(fluenture_1.fluent) | ||
.chain(process => validator_1.validateContext(process.spec.context, process.context) | ||
.pipe(fluenture_1.fluent) | ||
.both(validator_1.validateInput(process.spec.input, process.input)) | ||
.and(config.dispatch(process)) | ||
.chain(output => validator_1.validateOutput(process.spec.output, output)) | ||
.pipe(future => middleware.apply.post(future, process))), | ||
.pipe(fluture_1.chain(process => fluture_1.parallel(Infinity)([ | ||
validator_1.validateInput(process.spec.input, process.input), | ||
validator_1.validateContext(process.spec.context, process.context) | ||
]) | ||
.pipe(fluture_1.chain(_ => config.dispatch(process))) | ||
.pipe(fluture_1.chain(output => validator_1.validateOutput(process.spec.output, output))) | ||
.pipe(future => middleware.apply.post(future, process)))) | ||
.pipe(fluenture_1.fluent), | ||
serve: ({ spec, implementation }) => config.provide(spec, exports.encaseImplementation(implementation), environmentInitializer), | ||
@@ -66,0 +67,0 @@ serveModule: module => { |
@@ -68,3 +68,3 @@ import { CustomError } from 'ts-custom-error'; | ||
values: T; | ||
}) => FutureInstance<ContextValidationError<any, any>, T>; | ||
}) => FutureInstance<ContextValidationError<any, string>, T>; | ||
//# sourceMappingURL=validator.d.ts.map |
@@ -41,3 +41,5 @@ "use strict"; | ||
*/ | ||
exports.validateInput = (validator, value) => validator(value).pipe(fluture_1.chainRej(reason => fluture_1.reject(new InputValidationError(reason.errors)))); | ||
exports.validateInput = (validator, value) => validator(value) | ||
.pipe(fluture_1.chainRej((reason) => fluture_1.reject(new InputValidationError(reason.errors)))) | ||
.pipe(always(value)); | ||
/** | ||
@@ -47,3 +49,5 @@ * Specialized application of a Validator function and value, that coerces validation failure errors to | ||
*/ | ||
exports.validateOutput = (validator, value) => validator(value).pipe(fluture_1.chainRej(reason => fluture_1.reject(new OutputValidationError(reason.errors)))); | ||
exports.validateOutput = (validator, value) => validator(value) | ||
.pipe(fluture_1.chainRej((reason) => fluture_1.reject(new OutputValidationError(reason.errors)))) | ||
.pipe(always(value)); | ||
/** | ||
@@ -63,9 +67,10 @@ * Specialized application of multiple Validator functions and values contained within an object. | ||
const validatorKeys = Object.keys(validators); | ||
const validations = validatorKeys.map(key => { | ||
const validations = validatorKeys.map((key) => { | ||
const validator = validators[key]; | ||
const value = context.values[key]; | ||
return validator(value).pipe(fluture_1.chainRej(reason => fluture_1.reject(new ContextValidationError(key, reason.errors)))); | ||
return validator(value).pipe(fluture_1.chainRej((reason) => fluture_1.reject(new ContextValidationError(key, reason.errors)))); | ||
}); | ||
return fluture_1.parallel(validatorKeys.length)(validations).pipe(fluture_1.and(fluture_1.resolve(context))); | ||
return fluture_1.parallel(validatorKeys.length)(validations).pipe(always(context.values)); | ||
}; | ||
const always = (value) => fluture_1.map(() => value); | ||
//# sourceMappingURL=validator.js.map |
{ | ||
"name": "mgfx", | ||
"description": "Managed Side-Effects for JavaScript", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"files": [ | ||
@@ -32,3 +32,3 @@ "dist" | ||
}, | ||
"gitHead": "15ba4b6d699e5e9d7c88bf07ed4ae3ecf5eb373e" | ||
"gitHead": "635d0d0d60c6b4cc2fffa46fd6161921ca4ade35" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
62590
829