-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9764 from marmelab/data-generator-types
Add better types to data-generator
- Loading branch information
Showing
20 changed files
with
489 additions
and
279 deletions.
There are no files selected for viewing
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
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
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 |
---|---|---|
@@ -1,31 +1,34 @@ | ||
import { RaRecord } from 'ra-core'; | ||
|
||
import generateCustomers from './customers'; | ||
import generateCategories from './categories'; | ||
import generateProducts from './products'; | ||
import generateCommands from './commands'; | ||
import generateInvoices from './invoices'; | ||
import generateReviews from './reviews'; | ||
import { generateCustomers, Customer } from './customers'; | ||
import { generateCategories, Category } from './categories'; | ||
import { generateProducts, Product } from './products'; | ||
import { generateCommands, Command, BasketItem } from './commands'; | ||
import { generateInvoices, Invoice } from './invoices'; | ||
import { generateReviews, Review } from './reviews'; | ||
import finalize from './finalize'; | ||
import { Db } from './types'; | ||
|
||
export interface Db { | ||
customers: RaRecord[]; | ||
categories: RaRecord[]; | ||
products: RaRecord[]; | ||
commands: RaRecord[]; | ||
invoices: RaRecord[]; | ||
reviews: RaRecord[]; | ||
} | ||
|
||
export default (options = { serializeDate: true }): Db => { | ||
const generateData = (): Db => { | ||
const db = {} as Db; | ||
db.customers = generateCustomers(db, options); | ||
db.customers = generateCustomers(); | ||
db.categories = generateCategories(); | ||
db.products = generateProducts(db); | ||
db.commands = generateCommands(db, options); | ||
db.commands = generateCommands(db); | ||
db.invoices = generateInvoices(db); | ||
db.reviews = generateReviews(db, options); | ||
db.reviews = generateReviews(db); | ||
finalize(db); | ||
|
||
return db; | ||
}; | ||
|
||
export default generateData; | ||
|
||
export type { | ||
BasketItem, | ||
Category, | ||
Command, | ||
Customer, | ||
Db, | ||
Invoice, | ||
Product, | ||
Review, | ||
}; |
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
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,17 @@ | ||
import type { Customer } from './customers'; | ||
import type { Category } from './categories'; | ||
import type { Product } from './products'; | ||
import type { Command } from './commands'; | ||
import type { Invoice } from './invoices'; | ||
import type { Review } from './reviews'; | ||
import { Settings } from './finalize'; | ||
|
||
export interface Db { | ||
customers: Customer[]; | ||
categories: Category[]; | ||
products: Product[]; | ||
commands: Command[]; | ||
invoices: Invoice[]; | ||
reviews: Review[]; | ||
settings: Settings; | ||
} |
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
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.