-
[UPDATE] Upgrade dependencies version to resolve vulnerabilities and use latest Typescript
-
[FEATURE] Add
foreign
andtarget
keys toAttributeOptions
- [FIX] relax ModelProperties typing in a better way
- [FIX] relax ModelProperties typing slightly as typescript isn't quite there yet
- [UPDATE] update to modelsafe 2
- [FEATURE] add
targetAssoc
to associations
- [FEATURE] interpret de/serialisation depth of null as infinite depth
- [FIX] test defaultValue for undefined, not truthiness
- [FIX] reject invalid dates in date validator
- [FIX] deserialize ISO strings into Date objects
- [FEATURE] allow
defaultValue
to be lazily loaded - [FEATURE] use
defaultValue
in place of a nil value invalidate
- Revert to
es5
TypeScript target due to transpile model issues - Upgrade to TypeScript 2.3
- [FIX]
isLazyLoad()
should only match functions, not any object that's not a model constructor
- [FIX]
ModelErrors
should havePropertyError[]
per property, not a singlePropertyError
- [FIX] If
required
is set tofalse
when validating, then attribute type validations will be properly skipped
- [FIX] Make
associations
serialization options optional
- [FIX] Serialize/deserialize now no longer infinitely recursively serialize association values by default
- [FEATURE] Serialization/deserialization of associations can now be turned off, and you can provide a depth for serializing associations (defaults to 1 level)
- [FEATURE] Added
required
option withValidationOptions
to support skipping required attribute checks during validation
- [CHANGE] Uses the ES6 environment with
tsconfig.json
- [CHANGE] Removed unused attribute types
DECIMAL
,FLOAT
/DOUBLE
/ (in favour ofREAL
),JSONB
- [CHANGE] Renamed
JSON
toOBJECT
, is now for plain object types. JSON strings should useSTRING
- [CHANGE] Removed
Model.associate
in favour of lazy-loaded association decoration - [FEATURE] A
defaultValue
option for attributes that will be automatically set on new model instances unless you provide thedefaults
option in constructing the model asfalse
- [FEATURE]
ValidationError
s now have acommonErrors
property, which is a list of errors that are either for a subset of the model's properties or the whole model - [FEATURE] Added multiple decorators for more declarative definitions of models
@defaultValue
for decorating the default value of an attribute@required
for decorating an association or attribute as required@optional
for decorating an association or attribute as optional@readOnly
for decorating an attribute as read-only@primary
for decorating an attribute as a primary key@unique
for decorating an attribute as unique
- [FEATURE] Added
validate
to model instances for performing validations of model instance data. This will run a few types of validations:- Validates that the each property on the model data matches a type expected for the decorated attribute type
- Validates with any extra validations decorated through the
@validate
decorator - Validates that attributes that have
optional
set tofalse
have values provided
- Introduced a series of built-in decoratable validations, specifically:
@email
@url
@uuid
@json
@hex
@alpha
@alphanumeric
@base64
@uppercase
@lowercase
@ip
@matches
@gt
@gte
@lt
@lte
@length
@minLength
@maxLength
- [FEATURE] Add serialization and de-serialization from JSON. De-serialization performs validations by default but this can be disabled through an option. This can be used for sending or receiving the data of ModelSafe model instances.
- Catch errors during
hasModelOptions
in-case a non-object is given toreflect-metadata
- Fix
isLazyLoad
to just check if the target has been decorated and assume lazy load otherwises - Add
hasModelOptions
to check whether a class has been decorated as a model - Have
Model.associate
take anAssociationTarget
- Add
readOnly
metadata for attributes and assocations
- Fix
ValidationError
being able to use instanceof calls (gets around TypeScript 2.1+ issue)
- Add
isLazyLoad
function for checking if association targets are lazily loaded
- Add option of instantiating model instance with initial data
- Add lazy-load support to association targets in the
@assoc
decorator
- Add primary attribute option
- Add unqiue attribute option
- Add validation error and mapped model errors type
- Change metadata keys to prevent nameclash
- Move to es5 target
- Fix missing .npmignore
- Initial release