Skip to content

Commit

Permalink
deps: update flow-bin to version 0.31.1 🚀 (#341)
Browse files Browse the repository at this point in the history
* chore(package): update flow-bin to version 0.31.1

https://greenkeeper.io/

* refactor: remove events module decl override

* fix: missing/invalid type decls
  • Loading branch information
greenkeeperio-bot authored and zacharygolba committed Aug 25, 2016
1 parent 6e88a55 commit 0e66aa5
Show file tree
Hide file tree
Showing 18 changed files with 58 additions and 37 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"chai": "3.5.0",
"documentation": "4.0.0-beta9",
"eslint-plugin-flowtype": "2.11.1",
"flow-bin": "0.30.0",
"flow-bin": "0.31.1",
"isomorphic-fetch": "2.2.1",
"mocha": "3.0.2",
"rollup-plugin-multi-entry": "2.0.1"
Expand Down
2 changes: 1 addition & 1 deletion src/packages/application/initialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default async function initialize<T: Application>(app: T, {
logging,
database,
server: serverConfig
}: Application$opts) {
}: Application$opts): Promise<T> {
const routes = loader(path, 'routes');
const models = loader(path, 'models');
const controllers = loader(path, 'controllers');
Expand Down
12 changes: 8 additions & 4 deletions src/packages/controller/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ class Controller {
* @param {Request} request
* @param {Response} response
*/
async create(req: Request, res: Response) {
async create(req: Request, res: Response): Promise<Model> {
const {
url: {
pathname
Expand Down Expand Up @@ -507,7 +507,7 @@ class Controller {
* @param {Request} request
* @param {Response} response
*/
async update(req: Request) {
async update(req: Request): Promise<number | Model | void> {
const record = await findOne(req);

const {
Expand Down Expand Up @@ -536,7 +536,11 @@ class Controller {

return await record.save(true);
} else {
return record.isDirty ? await record.save() : 204;
if (record.isDirty) {
return await record.save();
} else {
return 204;
}
}
}

Expand All @@ -550,7 +554,7 @@ class Controller {
* @param {Request} request
* @param {Response} response
*/
async destroy(req: Request) {
async destroy(req: Request): Promise<number | void> {
const record = await findOne(req);

if (record) {
Expand Down
2 changes: 1 addition & 1 deletion src/packages/database/initialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default async function initialize<T: Database>(instance: T, {
config,
logger,
checkMigrations
}: Database$opts) {
}: Database$opts): Promise<T> {
config = Reflect.get(config, NODE_ENV);

if (!config) {
Expand Down
11 changes: 8 additions & 3 deletions src/packages/database/model/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ class Model {
}
}

save(deep?: boolean): Promise<void | Model> {
save(deep?: boolean): Promise<Model> {
return tryCatch(async () => {
const {
constructor: {
Expand Down Expand Up @@ -367,12 +367,17 @@ class Model {
return this;
}, err => {
throw processWriteError(err);
});
}).then(() => this);
}

async update(attributes: Object = {}): Promise<Model> {
Object.assign(this, attributes);
return this.isDirty ? await this.save(true) : this;

if (this.isDirty) {
return await this.save(true);
}

return this;
}

async destroy(): Promise<Model> {
Expand Down
5 changes: 4 additions & 1 deletion src/packages/database/query/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,10 @@ class Query {
this.select(...this.model.attributeNames);
}

const records = snapshots.reduce((query, [name, params]) => {
const records: any = snapshots.reduce((
query,
[name, params]
) => {
if (!shouldCount && name === 'includeSelect') {
name = 'select';
}
Expand Down
2 changes: 1 addition & 1 deletion src/packages/database/relationship/utils/getters.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ async function getHasManyThrough(owner: Model, {
inverse,
through,
foreignKey: baseKey
}: Relationship$opts) {
}: Relationship$opts): Promise<Array<Model>> {
const inverseOpts = model.relationshipFor(inverse);

if (through && inverseOpts) {
Expand Down
4 changes: 3 additions & 1 deletion src/packages/database/utils/create-migrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
/**
* @private
*/
export default async function createMigrations(schema: Function) {
export default async function createMigrations(
schema: Function
): Promise<boolean> {
const hasTable = await schema().hasTable('migrations');

if (!hasTable) {
Expand Down
2 changes: 1 addition & 1 deletion src/packages/database/utils/pending-migrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { readdir } from '../../fs';
export default async function pendingMigrations(
appPath: string,
table: Function
) {
): Promise<Array<string>> {
const migrations = await readdir(`${appPath}/db/migrate`);
const versions = await table().select().map(({ version }) => version);

Expand Down
5 changes: 4 additions & 1 deletion src/packages/fs/utils/exists.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import tryCatch from '../../../utils/try-catch';
/**
* @private
*/
export default async function exists(path: string | RegExp, dir: string) {
export default async function exists(
path: string | RegExp,
dir: string
): Promise<boolean> {
if (typeof path === 'string') {
return Boolean(await tryCatch(() => stat(path)));
} else if (path instanceof RegExp) {
Expand Down
2 changes: 1 addition & 1 deletion src/packages/fs/utils/rmrf.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import tryCatch from '../../../utils/try-catch';
/**
* @private
*/
async function rmrf(target: string) {
async function rmrf(target: string): Promise<boolean> {
const stats = await tryCatch(() => stat(target));

if (stats && stats.isDirectory()) {
Expand Down
5 changes: 3 additions & 2 deletions src/packages/logger/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import type {
Logger$config,
Logger$format,
Logger$level,
Logger$logFn
Logger$logFn,
Logger$filter
} from './interfaces';

import type { Logger$RequestLogger } from './request-logger/interfaces';
Expand Down Expand Up @@ -46,7 +47,7 @@ class Logger {
* @memberof Logger
* @instance
*/
filter: Logger$config.filter;
filter: Logger$filter;

/**
* Wether on not logging is enabled for an instance of `Logger`.
Expand Down
9 changes: 5 additions & 4 deletions src/packages/logger/interfaces.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ export type Logger$data = {
timestamp: string;
};

export type Logger$filter = {
params: Array<string>;
};

export type Logger$config = {
level: Logger$level;
format: Logger$format;
filter: Logger$filter;
enabled: boolean;

filter: {
params: Array<string>;
};
};
6 changes: 3 additions & 3 deletions src/packages/route/action/utils/create-page-links.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import omit from '../../../../utils/omit';
import merge from '../../../../utils/merge';
import createQueryString from '../../../../utils/create-query-string';

import type { Request } from '../../../server';
import type { Request$params } from '../../../server';
import type { JSONAPI$DocumentLinks } from '../../../jsonapi';

function createLinkTemplate({
Expand All @@ -14,7 +14,7 @@ function createLinkTemplate({
defaultPerPage
}: {
total: number,
params: Request.params;
params: Request$params;
domain: string;
pathname: string;
defaultPerPage: number;
Expand Down Expand Up @@ -68,7 +68,7 @@ function createLinkTemplate({
*/
export default function createPageLinks(opts: {
total: number;
params: Request.params;
params: Request$params;
domain: string;
pathname: string;
defaultPerPage: number;
Expand Down
8 changes: 4 additions & 4 deletions src/packages/route/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import getStaticPath from './utils/get-static-path';
import getDynamicSegments from './utils/get-dynamic-segments';

import type Controller from '../controller';
import type { Request, Response } from '../server';
import type { Request, Response, Request$method } from '../server';
import type { Action } from './action';
import type { ParameterGroup } from './params';
import type { Route$opts } from './interfaces';
Expand All @@ -19,13 +19,13 @@ import type { Route$opts } from './interfaces';
* @private
*/
class Route extends FreezeableSet<Action<any>> {
path: Route$opts.path;
path: string;

params: ParameterGroup;

action: Route$opts.action;
action: string;

method: Route$opts.method;
method: Request$method;

resource: string;

Expand Down
4 changes: 2 additions & 2 deletions src/packages/route/params/utils/get-url-params.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// @flow
import Parameter from '../parameter';

import type { ParameterLike, Params$opts } from '../interfaces';
import type { ParameterLike } from '../interfaces';

/**
* @private
*/
export default function getURLParams(
dynamicSegments: Params$opts.dynamicSegments
dynamicSegments: Array<string>
): Array<[string, ParameterLike]> {
return dynamicSegments.map(param => [param, new Parameter({
path: param,
Expand Down
4 changes: 2 additions & 2 deletions src/packages/serializer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Serializer {
* @readonly
* @private
*/
model: Serializer$opts.model;
model: Class<Model>;

/**
* A Map of all resolved serializers in a an `Application` instance. This is
Expand All @@ -50,7 +50,7 @@ class Serializer {
* @readonly
* @private
*/
serializers: Serializer$opts.serializers;
serializers: Map<string, Serializer>;

/**
* Create an instance of `Serializer`.
Expand Down
10 changes: 6 additions & 4 deletions src/packages/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,21 @@ import setCORSHeaders from './utils/set-cors-headers';
import type { Writable } from 'stream';
import type { IncomingMessage, Server as HTTPServer } from 'http';

import type Logger from '../logger';
import type Router from '../router';
import type { Request } from './request/interfaces';
import type { Response } from './response/interfaces';
import type { Server$opts, Server$config } from './interfaces';
import type { Server$opts, Server$cors } from './interfaces';

/**
* @private
*/
class Server {
logger: Server$opts.logger;
logger: Logger;

router: Server$opts.router;
router: Router;

cors: Server$config.cors;
cors: Server$cors;

instance: HTTPServer;

Expand Down

0 comments on commit 0e66aa5

Please sign in to comment.