@thisisagile/easy
Advanced tools
Comparing version 1.10.0 to 1.11.0
export * from "./Entity"; | ||
export * from "./Record"; | ||
export * from "./Repo"; |
@@ -15,2 +15,3 @@ "use strict"; | ||
__exportStar(require("./Record"), exports); | ||
__exportStar(require("./Repo"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -10,5 +10,6 @@ import { Constructor, Gateway, Id, Json, JsonValue, List } from '../types'; | ||
exists: (id: Id) => Promise<boolean>; | ||
add: (item: Json) => Promise<T>; | ||
add: (json: Json) => Promise<T>; | ||
update: (item: Json) => Promise<T>; | ||
remove: (id: Id) => Promise<boolean>; | ||
validate: (item: T) => Promise<T>; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Repo = void 0; | ||
const types_1 = require("../types"); | ||
const validation_1 = require("../validation"); | ||
const utils_1 = require("../utils"); | ||
class Repo { | ||
@@ -12,5 +15,9 @@ constructor(ctor, gateway) { | ||
this.exists = (id) => this.gateway.exists(id); | ||
this.add = (item) => this.gateway.add(item).then(j => new this.ctor(j)); | ||
this.add = (json) => validation_1.when(new this.ctor(json)).not.isValid.reject() | ||
.then(i => this.validate(i)) | ||
.then(i => this.gateway.add(types_1.jsonify(i))) | ||
.then(j => new this.ctor(j)); | ||
this.update = (item) => this.gateway.update(item).then(j => new this.ctor(j)); | ||
this.remove = (id) => this.gateway.remove(id); | ||
this.validate = (item) => utils_1.resolve(item); | ||
} | ||
@@ -17,0 +24,0 @@ } |
@@ -8,2 +8,3 @@ export * from "./Array"; | ||
export * from "./IsA"; | ||
export * from "./IsDate"; | ||
export * from "./Json"; | ||
@@ -17,1 +18,4 @@ export * from "./List"; | ||
export * from "./Validatable"; | ||
export { inFuture } from './IsDate'; | ||
export { inPast } from './IsDate'; | ||
export { isDate } from './IsDate'; |
@@ -13,2 +13,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isDate = exports.inPast = exports.inFuture = void 0; | ||
__exportStar(require("./Array"), exports); | ||
@@ -21,2 +22,3 @@ __exportStar(require("./Constructor"), exports); | ||
__exportStar(require("./IsA"), exports); | ||
__exportStar(require("./IsDate"), exports); | ||
__exportStar(require("./Json"), exports); | ||
@@ -30,2 +32,8 @@ __exportStar(require("./List"), exports); | ||
__exportStar(require("./Validatable"), exports); | ||
var IsDate_1 = require("./IsDate"); | ||
Object.defineProperty(exports, "inFuture", { enumerable: true, get: function () { return IsDate_1.inFuture; } }); | ||
var IsDate_2 = require("./IsDate"); | ||
Object.defineProperty(exports, "inPast", { enumerable: true, get: function () { return IsDate_2.inPast; } }); | ||
var IsDate_3 = require("./IsDate"); | ||
Object.defineProperty(exports, "isDate", { enumerable: true, get: function () { return IsDate_3.isDate; } }); | ||
//# sourceMappingURL=index.js.map |
@@ -13,1 +13,3 @@ import { Text } from '../types'; | ||
export declare const lte: (limit: number, message?: Text) => PropertyDecorator; | ||
export declare const past: (message?: Text) => PropertyDecorator; | ||
export declare const future: (message?: Text) => PropertyDecorator; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.lte = exports.lt = exports.gte = exports.gt = exports.inList = exports.includes = exports.valid = exports.required = exports.defined = exports.constraint = void 0; | ||
exports.future = exports.past = exports.lte = exports.lt = exports.gte = exports.gt = exports.inList = exports.includes = exports.valid = exports.required = exports.defined = exports.constraint = void 0; | ||
const types_1 = require("../types"); | ||
@@ -27,2 +27,6 @@ const constraint = (c, message) => (subject, property) => { | ||
exports.lte = lte; | ||
const past = (message) => exports.constraint(v => types_1.inPast(v), message !== null && message !== void 0 ? message : 'Value for $property must be in the past.'); | ||
exports.past = past; | ||
const future = (message) => exports.constraint(v => types_1.inFuture(v), message !== null && message !== void 0 ? message : 'Value for $property must be in the future.'); | ||
exports.future = future; | ||
//# sourceMappingURL=Contraints.js.map |
{ | ||
"name": "@thisisagile/easy", | ||
"version": "1.10.0", | ||
"version": "1.11.0", | ||
"description": "Straightforward library for building domain-driven microservice architectures", | ||
@@ -5,0 +5,0 @@ "author": "Sander Hoogendoorn", |
export * from "./Entity"; | ||
export * from "./Record"; | ||
export * from "./Repo"; |
@@ -1,2 +0,4 @@ | ||
import { Constructor, Gateway, Id, Json, JsonValue, List } from '../types'; | ||
import { Constructor, Gateway, Id, Json, jsonify, JsonValue, List } from '../types'; | ||
import { when } from '../validation'; | ||
import { resolve } from '../utils'; | ||
@@ -11,6 +13,13 @@ export class Repo<T> { | ||
add = (item: Json): Promise<T> => this.gateway.add(item).then(j => new this.ctor(j)); | ||
add = (json: Json): Promise<T> => | ||
when(new this.ctor(json)).not.isValid.reject() | ||
.then(i => this.validate(i)) | ||
.then(i => this.gateway.add(jsonify(i))) | ||
.then(j => new this.ctor(j)); | ||
update = (item: Json): Promise<T> => this.gateway.update(item).then(j => new this.ctor(j)); | ||
remove = (id: Id): Promise<boolean> => this.gateway.remove(id); | ||
validate = (item: T): Promise<T> => resolve(item); | ||
} | ||
@@ -8,2 +8,3 @@ export * from "./Array"; | ||
export * from "./IsA"; | ||
export * from "./IsDate"; | ||
export * from "./Json"; | ||
@@ -17,1 +18,4 @@ export * from "./List"; | ||
export * from "./Validatable"; | ||
export { inFuture } from './IsDate'; | ||
export { inPast } from './IsDate'; | ||
export { isDate } from './IsDate'; |
@@ -1,2 +0,2 @@ | ||
import { isDefined, isIn, isString, isValidatable, meta, Text } from '../types'; | ||
import { inFuture, inPast, isDefined, isIn, isString, isValidatable, meta, Text } from '../types'; | ||
@@ -37,1 +37,7 @@ export type Constraint = (value: unknown) => boolean; | ||
export const past = (message?: Text): PropertyDecorator => | ||
constraint(v => inPast(v), message ?? 'Value for $property must be in the past.'); | ||
export const future = (message?: Text): PropertyDecorator => | ||
constraint(v => inFuture(v), message ?? 'Value for $property must be in the future.'); | ||
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
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
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
131206
183
1931