Skip to content

Releases: JaapRood/vry

Remove features deprecated in v2

09 May 05:52
Compare
Choose a tag to compare

We had some features that were to be removed in v3 that I missed in it's release. All of these caused warnings in v2, so if you're code is warning free running against that, everything should be fine!

Add defaults as option to type.factory

04 May 06:16
Compare
Choose a tag to compare

This version introduces defaults and the schema to be overridden when using state.factory or model.factory, as well as the schema (was already possible, but poorly documented). This allows for partial instances to be created that can then be merged with their more complete versions, while allowing to define defaults for client-only or base instances. This flexibility is instrumental in using Vry to model API resources.

Breaking Changes

While the API is purely additive, the new propagation behaviour of the defaults for models, changes previously expected behaviour. The following now does something different:

const User = Model.create({
  typeName: 'user',
  defaults: {
    name: 'Unknown Author'
  }
})

const Post = Model.create({
  typeName: 'post',
  defaults: {
    author: {}
  },
  schema: {
    author: User
  }
})

const post = Post.factory()

Before these changes, creating a new post would create an embedded author with the name Unknown Author, with the defaults of the nested schema applied. Now, however, the defaults are propagated to the nested model. In this case, the post would still have a User model embedded as an author, but with it's defaults set to {}, not have the default name prop applied.

To get the old behaviour, you can use the model.defaults() to explicitly set the defaults for the nested schema:

// ....
const Post = Model.create({
  typeName: 'post',
  defaults: {
    author: User.defaults()
  },
  schema: {
    author: User
  }
})

Bugfix for mergeDeep when used with embedded types

03 May 04:30
4ac5d61
Compare
Choose a tag to compare
Merge pull request #8 from JaapRood/fix/merge-deep

Fix bug where non-instances were attempted to be merged as instances

Add mergeDeep to State, Model and IterableSchemas

03 May 02:06
Compare
Choose a tag to compare

Forward options to item schemas

03 Apr 06:15
Compare
Choose a tag to compare
v2.0.3

Bump version number

Iterable schema fix

03 Apr 03:13
Compare
Choose a tag to compare
Merge pull request #5 from JaapRood/fix/iterable-schema

Fix the applying of the item schema's factory and / or serialize methods by IterableSchema's

Model and Schema

21 Jun 02:16
Compare
Choose a tag to compare

This release adds Model and Schema concepts. In addition, the way State has been implemented has changed significantly, causing a couple of breaking changes. The changes were to make sure a Model can be like a State, without creating an "is-a" relationship. Instead, both constructs are composed out and have things like a Factory and Identity.

Breaking changes

  • State.prototype no longer has the methods factory, merge, parse and serialize. To use default behaviour when overriding one of these methods, they are available on type.prototype, where type is the generated type with State.create.
  • The metadata prop __name has been renamed to __typeName. For future use be sure to use the new type.typeName(instance) to access the type name.

Deprecations

These changes will cause warnings and will be removed in the future.

  • State.serialize(instance, omitCid=true) has changed to State.serialize(instance, options={omitCid: true}).