Introduces flow types for storage (#4349)

* Introduces flow types for storage

* Better typing of QueryOptions

* Adds flow types to SchemaCOntroller,

- runs flow on pre tests
- fixes flow

* Adds ClassLevelPermissions type

* Moves Controller types into a single file

* Changes import styles

* Changes import styles

* fixing method setIndexesWithSchemaFormat (#4454)

Fixing invalid database code in method `setIndexesWithSchemaFormat`:

* It must be a transaction, not a task, as it executes multiple database changes
* It should contain the initial queries inside the transaction, providing the context, not outside it;
* Replaced the code with the ES6 Generator notation
* Removing the use of batch, as the value of the result promise is irrelevant, only success/failure that matters

* nits

* Fixes tests, improves flow typing
This commit is contained in:
Florent Vilmart
2017-12-30 20:44:18 -05:00
committed by GitHub
parent f0f1870aa3
commit 10631371e6
20 changed files with 1085 additions and 915 deletions

29
src/Controllers/types.js Normal file
View File

@@ -0,0 +1,29 @@
export type LoadSchemaOptions = {
clearCache: boolean
};
export type SchemaField = {
type: string;
targetClass?: ?string;
}
export type SchemaFields = { [string]: SchemaField }
export type Schema = {
className: string,
fields: SchemaFields,
classLevelPermissions: ClassLevelPermissions,
indexes?: ?any
};
export type ClassLevelPermissions = {
find?: {[string]: boolean};
count?: {[string]: boolean};
get?: {[string]: boolean};
create?: {[string]: boolean};
update?: {[string]: boolean};
delete?: {[string]: boolean};
addField?: {[string]: boolean};
readUserFields?: string[];
writeUserFields?: string[];
};