Skip to content

Commit

Permalink
Gix Gitbook refs (#120)
Browse files Browse the repository at this point in the history
* Gix Gitbook refs

* New organization

* Remove introduction duplicate link

* Prepare to release new alpha
  • Loading branch information
talyssonoc committed Mar 20, 2020
1 parent 935305a commit f683c66
Show file tree
Hide file tree
Showing 11 changed files with 201 additions and 120 deletions.
2 changes: 1 addition & 1 deletion .gitbook.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
structure:
readme: README.md
readme: packages/structure/README.md
summary: docs/SUMMARY.md
1 change: 0 additions & 1 deletion CHANGELOG.md

This file was deleted.

95 changes: 95 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
## 2.0.0-alpha.3 - 2020-03-20

- Reorganize md files

## 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))
1 change: 0 additions & 1 deletion README.md

This file was deleted.

44 changes: 44 additions & 0 deletions README.md
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)
2 changes: 1 addition & 1 deletion docs/SUMMARY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Table of contents

- [Introduction](../README.md)
- [Schema concept](schema-concept/README.md)
- [Shorthand and complete type descriptor](schema-concept/shorthand-and-complete-type-descriptor.md)
- [Circular reference](schema-concept/circular-references-and-dynamic-types.md)
Expand All @@ -24,6 +23,7 @@
- [Strict mode](strict-mode.md)
- [Cloning an instance](cloning.md)
- [Serialization](serialization.md)
- [Support and compatibility](support.md)
- [Changelog](../CHANGELOG.md)
- [Contributing](../contributing.md)
- [License](../license.md)
Expand Down
11 changes: 11 additions & 0 deletions docs/support.md
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.
21 changes: 21 additions & 0 deletions packages/jest-structure/license.md
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.
4 changes: 2 additions & 2 deletions packages/jest-structure/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jest-structure",
"version": "2.0.0-alpha.2",
"version": "2.0.0-alpha.3",
"description": "Jest assertions to use with Structure",
"main": "index.js",
"author": "Talysson <talyssonoc@gmail.com>",
Expand All @@ -12,7 +12,7 @@
"node": ">=10.13.0"
},
"devDependencies": {
"structure": "2.0.0-alpha.2"
"structure": "2.0.0-alpha.3"
},
"peerDependencies": {
"jest": "^25.1.0"
Expand Down
91 changes: 0 additions & 91 deletions packages/structure/CHANGELOG.md

This file was deleted.

24 changes: 3 additions & 21 deletions packages/structure/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,12 @@ You can use Structure for a lot of different cases, including:
- Map pure objects and JSON to your application classes
- Add attributes to classes that you can't change the class hierarchy

Structure was inspired by Ruby's [Virtus](https://github.com/solnic/virtus).

What Structure is **not**:

- It's not a database abstraction
- It's not a MVC framework (but it can be used to domain entities)
- It's not a Model of a MVC framework
- It's not an attempt to simulate classic inheritance in JavaScript

## Getting started

`npm install --save 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.
Expand Down Expand Up @@ -60,18 +54,6 @@ user.name; // 'John Foo'
user.greet(); // 'Hello John Foo'
```

## 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](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.

## BattleCry generators

There are configurable [BattleCry](https://github.com/pedsmoreira/battlecry) generators ready to be downloaded and help scaffolding schema:
Expand All @@ -84,6 +66,6 @@ cry g schema user name age:int:required cars:string[] favoriteBook:book friends:

Run `cry --help` to check more info about the generators available;

## [Contributing](contributing.md)
## [Contributing](../../contributing.md)

## [LICENSE](license.md)
## [LICENSE](../../license.md)
21 changes: 21 additions & 0 deletions packages/structure/license.md
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.
4 changes: 2 additions & 2 deletions packages/structure/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "structure",
"version": "2.0.0-alpha.2",
"version": "2.0.0-alpha.3",
"description": "A simple schema/attributes library built on top of modern JavaScript",
"main": "src/index.js",
"browser": "dist/structure.js",
Expand Down Expand Up @@ -52,7 +52,7 @@
"babel-loader": "^8.0.6",
"coveralls": "^3.0.7",
"electron": "^8.1.1",
"jest-structure": "2.0.0-alpha.2",
"jest-structure": "2.0.0-alpha.3",
"webpack": "^4.41.2",
"webpack-cli": "^3.3.9"
}
Expand Down

0 comments on commit f683c66

Please sign in to comment.