Skip to content

Commit

Permalink
Merge pull request #3096 from marmelab/data-generator-retail
Browse files Browse the repository at this point in the history
[RFR] Turn data generator for demo into a public repository
  • Loading branch information
Gildas Garcia authored Apr 4, 2019
2 parents bc703a9 + 172c3bc commit 82aea2a
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 5 deletions.
21 changes: 21 additions & 0 deletions examples/data-generator/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2019-present, Francois Zaninotto, Marmelab

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 NON INFRINGEMENT. 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.
96 changes: 96 additions & 0 deletions examples/data-generator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# Fake Data Generator for Retail

Generates a large JSON object full of fake data for simulating the backend of a poster shop.

Used to simulate a REST / GraphQL backend in [react-admin](https://github.com/marmelab/react-admin). To get a glimpse of the test data, browse the [react-admin demo](https://marmelab.com/react-admin-demo/#/).

[![react-admin-demo](https://marmelab.com/react-admin/img/react-admin-demo-still.png)](https://vimeo.com/268958716)

## Usage

```js
import generator from 'data-generator-retail';

const data = generateData();
// now do whatever you want with the data...
console.log(data);
{
customers: [ /* ...900 customers */],
categories: [ /* ...12 categories */],
products: [ /* ...120 products */],
commands: [ /* ...600 orders */],
invoices: [ /* ...about 500 invoices */],
reviews: [ /* ... */],
}
```

## Data schema

- customers
- id: integer
- first_name: string
- last_name: string
- email: string
- address: string
- zipcode: string
- city: string
- avatar: string
- birthday: date
- first_seen: date
- last_seen: date
- has_ordered: boolean
- latest_purchase
- has_newsletter: boolean
- groups: array
- nb_commands: integer
- total_spent: integer
- categories
- id: number
- name: string
- products
- id: integer
- category_id: integer
- reference: string
- width: float
- height: float
- price: float
- thumbnail: string
- image: string
- description: string
- stock: integer
- commands
- id: integer
- reference: string
- date: date
- customer_id: integer
- basket: [{ product_id: integer, quantity: integer }]
- total_ex_taxes: float
- delivery_fees: float
- tax_rate: float
- taxes: float
- total: float
- status: 'ordered' | 'delivered' | 'canceled'
- returned: boolean
- invoices
- id: integer
- date: date
- command_id: integer
- customer_id: integer
- total_ex_taxes: float
- delivery_fees: float
- tax_rate: float
- taxes: float
- total: float
- reviews
- id: integer
- date: date
- status: 'pending' | 'accepted' | 'rejected'
- command_id: integer
- product_id: integer
- customer_id: integer
- rating: integer
- comment: string

## Licence

Data Generator for Retail is licensed under the [MIT License](https://github.com/marmelab/react-admin/blob/master/LICENSE.md), sponsored and supported by [marmelab](http://marmelab.com).
6 changes: 4 additions & 2 deletions examples/data-generator/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"name": "data-generator",
"name": "data-generator-retail",
"version": "2.7.1",
"private": true,
"homepage": "https://github.com/marmelab/react-admin/tree/master/examples/data-generator",
"bugs": "https://github.com/marmelab/react-admin/issues",
"license": "MIT",
"main": "./lib/index.js",
"scripts": {
"build": "yarn run build-cjs && yarn run build-esm",
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"dependencies": {
"@material-ui/core": "~1.5.1",
"@material-ui/icons": "~1.1.1",
"data-generator": "^2.4.0",
"data-generator-retail": "^2.7.0",
"fakerest": "~2.1.0",
"fetch-mock": "~6.3.0",
"json-graphql-server": "~2.1.3",
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/src/fakeServer/graphql.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import JsonGraphqlServer from 'json-graphql-server';
import generateData from 'data-generator';
import generateData from 'data-generator-retail';
import fetchMock from 'fetch-mock';

export default () => {
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/src/fakeServer/rest.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import FakeRest from 'fakerest';
import fetchMock from 'fetch-mock';
import generateData from 'data-generator';
import generateData from 'data-generator-retail';

export default () => {
const data = generateData({ serializeDate: true });
Expand Down

0 comments on commit 82aea2a

Please sign in to comment.