Skip to content

Commit 935305a

Browse files
authored
Invert symlinks (#119)
* Invert symlinks * Bump alpha patch
1 parent 792e51f commit 935305a

File tree

6 files changed

+186
-182
lines changed

6 files changed

+186
-182
lines changed

CHANGELOG.md

Lines changed: 0 additions & 87 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
./packages/structure/CHANGELOG.md

README.md

Lines changed: 0 additions & 89 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
./packages/structure/README.md

packages/jest-structure/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jest-structure",
3-
"version": "2.0.0-alpha.1",
3+
"version": "2.0.0-alpha.2",
44
"description": "Jest assertions to use with Structure",
55
"main": "index.js",
66
"author": "Talysson <[email protected]>",
@@ -12,7 +12,7 @@
1212
"node": ">=10.13.0"
1313
},
1414
"devDependencies": {
15-
"structure": "2.0.0-alpha.1"
15+
"structure": "2.0.0-alpha.2"
1616
},
1717
"peerDependencies": {
1818
"jest": "^25.1.0"

packages/structure/CHANGELOG.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/structure/CHANGELOG.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
## 2.0.0-alpha.2 - 2020-03-19
2+
3+
- Invert symlinks
4+
5+
## 2.0.0-alpha.1 - 2020-03-19
6+
7+
- Add symlinks to md files to packages/structure
8+
9+
## 2.0.0-alpha.0 - 2020-03-19
10+
11+
Refactors:
12+
13+
- The whole part of schemas and attribute definitions was refactored
14+
- Tests are now run by Jest (and Electron for browser tests)
15+
- Prettier was added
16+
- Move to mono-repo
17+
18+
Enhancements
19+
20+
- Implement jest-structure assertions
21+
- It's possible to set custom getters e setters directly in the structure class
22+
23+
Breaking changes:
24+
25+
- Joi is updated to v16
26+
- Attribute path in validation _errors_ is an array instead of a string
27+
- Attribute path in validation _messages_ contains the whole path joined by '.'
28+
- 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
29+
- Non-nullable attributes with value null will use default value the same way undefined does
30+
- Structure classes now have two methods to generically set and get the value of the attributes, `.get(attributeName)` and `.set(attributeName, attributeValue)`
31+
- Minimum Node version is now 10
32+
33+
## 1.8.0 - 2019-09-16
34+
35+
Enhancements:
36+
37+
- Add `unique` validation to arrays
38+
39+
## 1.7.0 - 2019-09-14
40+
41+
Enhancements:
42+
43+
- Add method to clone structures
44+
45+
## 1.6.0 - 2019-08-27
46+
47+
Enhancements:
48+
49+
- Allow custom error class to static mode
50+
51+
## 1.5.0 - 2019-07-08
52+
53+
Enhancements:
54+
55+
- Add `buildStrict` static method
56+
57+
## 1.4.0 - 2019-03-26
58+
59+
Enhancements:
60+
61+
- Add `nullable` option
62+
63+
## 1.3.2 - 2019-03-22
64+
65+
Fix:
66+
67+
- The actual instance is passed to the dynamic defaults
68+
69+
## 1.3.0 - 2018-03-23
70+
71+
Enhancements:
72+
73+
- When using default function to initialize attributes you can now refer to another attribute values to compose value
74+
75+
## 1.2.0 - 2017-02-01
76+
77+
Features:
78+
79+
- Allow circular reference on type definitions ([@talyssonoc](https://github.com/talyssonoc/structure/pull/30))
80+
81+
Enhancements:
82+
83+
- Make validation faster ([@talyssonoc](https://github.com/talyssonoc/structure/pull/28))
84+
85+
Dependencies update:
86+
87+
- Update joi from 9.2.0 to 10.2.0 ([@talyssonoc](https://github.com/talyssonoc/structure/pull/26))
88+
89+
## 1.1.0 - 2017-01-17
90+
91+
- Added static method `validate()` to structures ([@talyssonoc](https://github.com/talyssonoc/structure/pull/25))

packages/structure/README.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/structure/README.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# <a href="https://structure.js.org/v/structure-2/"><img src="https://raw.githubusercontent.com/talyssonoc/structure/master/structure.jpg" width="300"></a>
2+
3+
## A simple schema/attributes library built on top of modern JavaScript
4+
5+
## [![npm](https://img.shields.io/npm/v/structure.svg?style=flat)](https://www.npmjs.com/package/structure) [![Build Status](https://travis-ci.org/talyssonoc/structure.svg?branch=master)](https://travis-ci.org/talyssonoc/structure) [![Coverage Status](https://coveralls.io/repos/github/talyssonoc/structure/badge.svg?branch=master)](https://coveralls.io/github/talyssonoc/structure?branch=master) [![Code Climate](https://codeclimate.com/github/talyssonoc/structure/badges/gpa.svg)](https://codeclimate.com/github/talyssonoc/structure) [![JS.ORG](https://img.shields.io/badge/js.org-structure-ffb400.svg?style=flat)](https://js.org/)
6+
7+
Structure provides a simple interface which allows you to add attributes to your ES6 classes based on a schema, with validations and type coercion.
8+
9+
## Use cases
10+
11+
You can use Structure for a lot of different cases, including:
12+
13+
- Domain entities and value objects
14+
- Model business rules
15+
- Validation and coercion of request data
16+
- Map pure objects and JSON to your application classes
17+
- Add attributes to classes that you can't change the class hierarchy
18+
19+
Structure was inspired by Ruby's [Virtus](https://github.com/solnic/virtus).
20+
21+
What Structure is **not**:
22+
23+
- It's not a database abstraction
24+
- It's not a MVC framework (but it can be used to domain entities)
25+
- It's not an attempt to simulate classic inheritance in JavaScript
26+
27+
## Getting started
28+
29+
`npm install --save structure`
30+
31+
## Usage
32+
33+
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.
34+
35+
```js
36+
const { attributes } = require('structure');
37+
38+
const User = attributes({
39+
name: String,
40+
age: {
41+
type: Number,
42+
default: 18,
43+
},
44+
birthday: Date,
45+
})(
46+
class User {
47+
greet() {
48+
return `Hello ${this.name}`;
49+
}
50+
}
51+
);
52+
53+
/* The attributes "wraps" the Class, still providing access to its methods: */
54+
55+
const user = new User({
56+
name: 'John Foo',
57+
});
58+
59+
user.name; // 'John Foo'
60+
user.greet(); // 'Hello John Foo'
61+
```
62+
63+
## Support and compatibility
64+
65+
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.
66+
67+
### Node
68+
69+
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.
70+
71+
### Browser
72+
73+
We have a [UMD version](https://github.com/talyssonoc/structure/blob/master/dist/structure.js) 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.
74+
75+
## BattleCry generators
76+
77+
There are configurable [BattleCry](https://github.com/pedsmoreira/battlecry) generators ready to be downloaded and help scaffolding schema:
78+
79+
```sh
80+
npm install -g battlecry
81+
cry download generator talyssonoc/structure
82+
cry g schema user name age:int:required cars:string[] favoriteBook:book friends:user[]:default :updateAge
83+
```
84+
85+
Run `cry --help` to check more info about the generators available;
86+
87+
## [Contributing](contributing.md)
88+
89+
## [LICENSE](license.md)

0 commit comments

Comments
 (0)