From c9402c58d0baa134843673fa58c8c31818c3ec4c Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Thu, 29 Mar 2018 13:59:32 -0400 Subject: [PATCH] Upgrade flow --- packages/insomnia-app/app/common/import.js | 2 +- packages/insomnia-app/app/common/misc.js | 6 +- packages/insomnia-app/app/common/render.js | 5 +- packages/insomnia-app/app/templating/utils.js | 7 +- .../components/editors/auth/auth-wrapper.js | 1 + .../components/editors/auth/o-auth-1-auth.js | 1 + .../components/modals/cookie-modify-modal.js | 7 +- .../modals/request-switcher-modal.js | 17 +- .../app/ui/components/request-pane.js | 2 +- .../app/ui/components/settings/general.js | 2 +- .../ui/components/sidebar/sidebar-children.js | 3 +- .../ui/components/templating/tag-editor.js | 6 +- .../insomnia-app/app/ui/components/tooltip.js | 2 +- .../flow-typed/insomnia-importers.js | 9 +- .../flow-typed/insomnia-libcurl.js | 3 + packages/insomnia-app/package-lock.json | 1337 +++++++++++++++-- packages/insomnia-app/package.json | 3 +- 17 files changed, 1256 insertions(+), 157 deletions(-) diff --git a/packages/insomnia-app/app/common/import.js b/packages/insomnia-app/app/common/import.js index fa10c31c2..4bab7105c 100644 --- a/packages/insomnia-app/app/common/import.js +++ b/packages/insomnia-app/app/common/import.js @@ -278,6 +278,6 @@ async function getDocWithDescendants ( const docs = await db.withDescendants(parentDoc); return docs.filter(d => ( // Don't include if private, except if we want to - !d.isPrivate || includePrivateDocs + !(d: any).isPrivate || includePrivateDocs )); } diff --git a/packages/insomnia-app/app/common/misc.js b/packages/insomnia-app/app/common/misc.js index d9997f7dd..f6e6e05dd 100644 --- a/packages/insomnia-app/app/common/misc.js +++ b/packages/insomnia-app/app/common/misc.js @@ -118,7 +118,7 @@ export function removeVowels (str: string): string { } export function keyedDebounce (callback: Function, millis: number = DEBOUNCE_MILLIS): Function { - let timeout = null; + let timeout; let results = {}; return function (key, ...args) { @@ -289,11 +289,11 @@ export function getUserLanguage (): string { export async function waitForStreamToFinish (s: Readable | Writable): Promise { return new Promise(resolve => { - if (s._readableState && s._readableState.finished) { + if ((s: any)._readableState && (s: any)._readableState.finished) { return resolve(); } - if (s._writableState && s._writableState.finished) { + if ((s: any)._writableState && (s: any)._writableState.finished) { return resolve(); } diff --git a/packages/insomnia-app/app/common/render.js b/packages/insomnia-app/app/common/render.js index ac14d51a0..9fac1b5ce 100644 --- a/packages/insomnia-app/app/common/render.js +++ b/packages/insomnia-app/app/common/render.js @@ -37,8 +37,9 @@ export async function buildRenderContext ( } for (const doc of (ancestors || []).reverse()) { - if (typeof doc.environment === 'object' && doc.environment !== null) { - envObjects.push(doc.environment); + const environment = (doc: any).environment; + if (typeof environment === 'object' && environment !== null) { + envObjects.push(environment); } } diff --git a/packages/insomnia-app/app/templating/utils.js b/packages/insomnia-app/app/templating/utils.js index 5bb42e392..cacff5ee8 100644 --- a/packages/insomnia-app/app/templating/utils.js +++ b/packages/insomnia-app/app/templating/utils.js @@ -5,7 +5,12 @@ export type NunjucksParsedTagArg = { value: string | number | boolean, defaultValue?: string | number | boolean, forceVariable?: boolean, - quotedBy?: '"' | "'" + placeholder?: string, + help?: string, + displayName?: string, + quotedBy?: '"' | "'", + validate?: (value: any) => string, + hide?: (Array) => boolean }; export type NunjucksParsedTag = { diff --git a/packages/insomnia-app/app/ui/components/editors/auth/auth-wrapper.js b/packages/insomnia-app/app/ui/components/editors/auth/auth-wrapper.js index 17e741c40..40d490dbf 100644 --- a/packages/insomnia-app/app/ui/components/editors/auth/auth-wrapper.js +++ b/packages/insomnia-app/app/ui/components/editors/auth/auth-wrapper.js @@ -71,6 +71,7 @@ class AuthWrapper extends PureComponent { handleRender={handleRender} handleGetRenderContext={handleGetRenderContext} nunjucksPowerUserMode={nunjucksPowerUserMode} + showPasswords={showPasswords} onChange={onChange} /> ); diff --git a/packages/insomnia-app/app/ui/components/editors/auth/o-auth-1-auth.js b/packages/insomnia-app/app/ui/components/editors/auth/o-auth-1-auth.js index a2b328562..398e0d3d9 100644 --- a/packages/insomnia-app/app/ui/components/editors/auth/o-auth-1-auth.js +++ b/packages/insomnia-app/app/ui/components/editors/auth/o-auth-1-auth.js @@ -15,6 +15,7 @@ type Props = { handleRender: Function, handleGetRenderContext: Function, nunjucksPowerUserMode: boolean, + showPasswords: boolean, onChange: Function, request: Request }; diff --git a/packages/insomnia-app/app/ui/components/modals/cookie-modify-modal.js b/packages/insomnia-app/app/ui/components/modals/cookie-modify-modal.js index d6453da5a..05f8e8b47 100644 --- a/packages/insomnia-app/app/ui/components/modals/cookie-modify-modal.js +++ b/packages/insomnia-app/app/ui/components/modals/cookie-modify-modal.js @@ -32,8 +32,8 @@ type State = { @autobind class CookieModifyModal extends React.PureComponent { modal: Modal | null; - _rawTimeout: number | null; - _cookieUpdateTimeout: number | null; + _rawTimeout: TimeoutID; + _cookieUpdateTimeout: TimeoutID; constructor (props: any) { super(props); @@ -42,9 +42,6 @@ class CookieModifyModal extends React.PureComponent { cookie: null, rawValue: '' }; - - this._rawTimeout = null; - this._cookieUpdateTimeout = null; } _setModalRef (n: Modal | null) { diff --git a/packages/insomnia-app/app/ui/components/modals/request-switcher-modal.js b/packages/insomnia-app/app/ui/components/modals/request-switcher-modal.js index 0842f2389..c22a62102 100644 --- a/packages/insomnia-app/app/ui/components/modals/request-switcher-modal.js +++ b/packages/insomnia-app/app/ui/components/modals/request-switcher-modal.js @@ -7,6 +7,7 @@ import Modal from '../base/modal'; import ModalHeader from '../base/modal-header'; import ModalBody from '../base/modal-body'; import MethodTag from '../tags/method-tag'; +import type {BaseModel} from '../../../models'; import * as models from '../../../models'; import {fuzzyMatchAll} from '../../../common/misc'; import type {RequestGroup} from '../../../models/request-group'; @@ -146,12 +147,12 @@ class RequestSwitcherModal extends React.PureComponent { } /** Return array of path segments for given request or folder */ - _groupOf (requestOrRequestGroup: Request | RequestGroup): Array { + _groupOf (requestOrRequestGroup: BaseModel): Array { const {workspaceChildren} = this.props; const requestGroups = workspaceChildren.filter(d => d.type === models.requestGroup.type); const matchedGroups = requestGroups.filter(g => g._id === requestOrRequestGroup.parentId); const currentGroupName = requestOrRequestGroup.type === models.requestGroup.type - ? `${requestOrRequestGroup.name}` + ? `${(requestOrRequestGroup: any).name}` : ''; // It's the final parent @@ -235,8 +236,10 @@ class RequestSwitcherModal extends React.PureComponent { this.setState({ activeIndex, searchString, - matchedRequests, - matchedWorkspaces + matchedWorkspaces, + + // Ugh. Force cast to make Flow happy + matchedRequests: ((matchedRequests: any): Array) }); } @@ -316,8 +319,8 @@ class RequestSwitcherModal extends React.PureComponent { )} - - {r.name} + + {(r: any).name} ); @@ -340,7 +343,7 @@ class RequestSwitcherModal extends React.PureComponent { ); diff --git a/packages/insomnia-app/app/ui/components/request-pane.js b/packages/insomnia-app/app/ui/components/request-pane.js index db0b74644..af580de2d 100644 --- a/packages/insomnia-app/app/ui/components/request-pane.js +++ b/packages/insomnia-app/app/ui/components/request-pane.js @@ -62,7 +62,7 @@ type Props = { @autobind class RequestPane extends React.PureComponent { - _handleUpdateRequestUrlTimeout: number; + _handleUpdateRequestUrlTimeout: TimeoutID; _handleEditDescriptionAdd () { this._handleEditDescription(true); diff --git a/packages/insomnia-app/app/ui/components/settings/general.js b/packages/insomnia-app/app/ui/components/settings/general.js index 63aaef24a..2462b596c 100644 --- a/packages/insomnia-app/app/ui/components/settings/general.js +++ b/packages/insomnia-app/app/ui/components/settings/general.js @@ -19,7 +19,7 @@ class General extends React.PureComponent { const el = e.currentTarget; let value = el.type === 'checkbox' ? el.checked : el.value; - if (e.target.type === 'number') { + if (e.currentTarget.type === 'number') { value = parseInt(value, 10); } diff --git a/packages/insomnia-app/app/ui/components/sidebar/sidebar-children.js b/packages/insomnia-app/app/ui/components/sidebar/sidebar-children.js index 12ee7981b..61d979d4c 100644 --- a/packages/insomnia-app/app/ui/components/sidebar/sidebar-children.js +++ b/packages/insomnia-app/app/ui/components/sidebar/sidebar-children.js @@ -10,7 +10,8 @@ import type {Request} from '../../../models/request'; type Child = { doc: Request | RequestGroup, children: Array, - collapsed: boolean + collapsed: boolean, + hidden: boolean }; type Props = { diff --git a/packages/insomnia-app/app/ui/components/templating/tag-editor.js b/packages/insomnia-app/app/ui/components/templating/tag-editor.js index 4d33a82c5..567e8232b 100644 --- a/packages/insomnia-app/app/ui/components/templating/tag-editor.js +++ b/packages/insomnia-app/app/ui/components/templating/tag-editor.js @@ -421,17 +421,17 @@ class TagEditor extends React.PureComponent { return (