-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6e5f48c
commit d308879
Showing
10 changed files
with
221 additions
and
145 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
## 2.0.0-alpha.2 - 2020-03-19 | ||
|
||
- Invert symlinks | ||
|
||
## 2.0.0-alpha.1 - 2020-03-19 | ||
|
||
- Add symlinks to md files to packages/structure | ||
|
||
## 2.0.0-alpha.0 - 2020-03-19 | ||
|
||
Refactors: | ||
|
||
- The whole part of schemas and attribute definitions was refactored | ||
- Tests are now run by Jest (and Electron for browser tests) | ||
- Prettier was added | ||
- Move to mono-repo | ||
|
||
Enhancements | ||
|
||
- Implement jest-structure assertions | ||
- It's possible to set custom getters e setters directly in the structure class | ||
|
||
Breaking changes: | ||
|
||
- Joi is updated to v16 | ||
- Attribute path in validation _errors_ is an array instead of a string | ||
- Attribute path in validation _messages_ contains the whole path joined by '.' | ||
- The name used for the dynamic import should aways be the same as the name of its type or else a custom identifier must be used | ||
- Non-nullable attributes with value null will use default value the same way undefined does | ||
- Structure classes now have two methods to generically set and get the value of the attributes, `.get(attributeName)` and `.set(attributeName, attributeValue)` | ||
- Minimum Node version is now 10 | ||
|
||
## 1.8.0 - 2019-09-16 | ||
|
||
Enhancements: | ||
|
||
- Add `unique` validation to arrays | ||
|
||
## 1.7.0 - 2019-09-14 | ||
|
||
Enhancements: | ||
|
||
- Add method to clone structures | ||
|
||
## 1.6.0 - 2019-08-27 | ||
|
||
Enhancements: | ||
|
||
- Allow custom error class to static mode | ||
|
||
## 1.5.0 - 2019-07-08 | ||
|
||
Enhancements: | ||
|
||
- Add `buildStrict` static method | ||
|
||
## 1.4.0 - 2019-03-26 | ||
|
||
Enhancements: | ||
|
||
- Add `nullable` option | ||
|
||
## 1.3.2 - 2019-03-22 | ||
|
||
Fix: | ||
|
||
- The actual instance is passed to the dynamic defaults | ||
|
||
## 1.3.0 - 2018-03-23 | ||
|
||
Enhancements: | ||
|
||
- When using default function to initialize attributes you can now refer to another attribute values to compose value | ||
|
||
## 1.2.0 - 2017-02-01 | ||
|
||
Features: | ||
|
||
- Allow circular reference on type definitions ([@talyssonoc](https://github.com/talyssonoc/structure/pull/30)) | ||
|
||
Enhancements: | ||
|
||
- Make validation faster ([@talyssonoc](https://github.com/talyssonoc/structure/pull/28)) | ||
|
||
Dependencies update: | ||
|
||
- Update joi from 9.2.0 to 10.2.0 ([@talyssonoc](https://github.com/talyssonoc/structure/pull/26)) | ||
|
||
## 1.1.0 - 2017-01-17 | ||
|
||
- Added static method `validate()` to structures ([@talyssonoc](https://github.com/talyssonoc/structure/pull/25)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# <a href="https://structure.js.org/v/structure-2/"><img src="https://raw.githubusercontent.com/talyssonoc/structure/master/structure.jpg" width="300"></a> | ||
|
||
## A simple schema/attributes library built on top of modern JavaScript | ||
|
||
Structure provides a simple interface which allows you to add attributes to your ES6 classes based on a schema, with validations and type coercion. | ||
|
||
## Packages | ||
|
||
- [Structure](packages/structure) | ||
- [jest-structure](packages/jest-structure) | ||
|
||
## Example Structure usage | ||
|
||
For each attribute on your schema, a getter and a setter will be created into the given class. It'll also auto-assign those attributes passed to the constructor. | ||
|
||
```js | ||
const { attributes } = require('structure'); | ||
|
||
const User = attributes({ | ||
name: String, | ||
age: { | ||
type: Number, | ||
default: 18, | ||
}, | ||
birthday: Date, | ||
})( | ||
class User { | ||
greet() { | ||
return `Hello ${this.name}`; | ||
} | ||
} | ||
); | ||
|
||
const user = new User({ | ||
name: 'John Foo', | ||
}); | ||
|
||
user.name; // 'John Foo' | ||
user.greet(); // 'Hello John Foo' | ||
``` | ||
|
||
## [Contributing](contributing.md) | ||
|
||
## [LICENSE](license.md) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Contributing | ||
|
||
Contributions are always welcome! When contributing to Structure we ask you to follow our code of conduct: | ||
|
||
## Code of conduct | ||
|
||
In short: _Be nice_. Pay attention to the fact that Structure is free software, don't be rude with the contributors or with people with doubts and we'll be more than glad on helping you. Destructive criticism and demanding will be ignored. | ||
|
||
## Opening issues | ||
|
||
When opening an issue be descriptive about the bug or the feature suggestion, don't simply paste the error message on the issue title or description. Also, __provide code to simulate the bug__, we need to know the exact circumstances in which the bug occurs. Again, follow our [code of conduct](#code-of-conduct). | ||
|
||
## Pull requests | ||
|
||
When opening a pull request to Structure, follow this steps: | ||
|
||
1. Fork Structure; | ||
2. Create a new branch for your changes; | ||
3. Do your changes; | ||
4. Write tests for your changes; | ||
5. Check the coverage; | ||
6. Open the pull request; | ||
7. Write a complete description about the bug or the feature the pull request is about. | ||
|
||
Be aware that we keep __100% of code coverage__, any change that makes the code coverage less than 100% covered will be requested to write more tests. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Support and compatibility | ||
|
||
Structure is built on top of modern JavaScript, using new features like [Proxy](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy), [Reflect](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Reflect) and [Symbol](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Symbol). That being so, there are some things regarding compatibility you should consider when using Structure. | ||
|
||
## Node | ||
|
||
Node has only implemented all the used features at version 10, so for using Structure for a backend application you'll need Node 10 or later. | ||
|
||
## Browser | ||
|
||
We have a UMD version for usage in browsers. Right now the tests are ran both in Node (using the original code) and in Electron (using the UMD version) and the whole test suite passes for both cases. Since we use modern JavaScript features inside the lib (like [Proxy](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy)), older browsers may not support it. Polyfilling them may be an option but it's not oficially supported. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2017 Structure | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 jest-tructure | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.