Fix types

pull/947/head
Rick Carlino 2018-08-02 16:46:58 -05:00
parent 05c737eec4
commit d03e38e7f9
33 changed files with 72 additions and 47 deletions

View File

@ -22,11 +22,10 @@ import {
TaggedSavedGarden,
TaggedPlantTemplate,
} from "farmbot";
import { ExecutableType } from "../../farm_designer/interfaces";
import { fakeResource } from "../fake_resource";
import { emptyToolSlot } from "../../tools/components/empty_tool_slot";
import { FirmwareConfig } from "../../config_storage/firmware_configs";
import { PinBindingType } from "../../devices/pin_bindings/interfaces";
import { ExecutableType, PinBindingType } from "farmbot/dist/resources/api_resources";
export let resources: Everything["resources"] = buildResourceIndex();
let idCounter = 1;

View File

@ -43,7 +43,7 @@ import {
} from "../../connect_device";
import { onLogs } from "../../log_handlers";
import { Actions, Content } from "../../../constants";
import { Log } from "../../../interfaces";
import { Log } from "farmbot/dist/resources/api_resources";
import { ALLOWED_CHANNEL_NAMES, ALLOWED_MESSAGE_TYPES, Farmbot } from "farmbot";
import { success, error, info, warning } from "farmbot-toastr";
import { dispatchNetworkUp, dispatchNetworkDown } from "../../index";

View File

@ -1,6 +1,6 @@
import { fetchNewDevice, getDevice } from "../device";
import { dispatchNetworkUp, dispatchNetworkDown } from "./index";
import { Log } from "../interfaces";
import { Log } from "farmbot/dist/resources/api_resources";
import { Farmbot, BotStateTree, TaggedResource, SpecialStatus } from "farmbot";
import { noop, throttle } from "lodash";
import { success, error, info, warning } from "farmbot-toastr";

View File

@ -7,7 +7,7 @@ import {
} from "./connect_device";
import { GetState } from "../redux/interfaces";
import { dispatchNetworkDown } from ".";
import { Log } from "../interfaces";
import { Log } from "farmbot/dist/resources/api_resources";
import * as _ from "lodash";
import { globalQueue } from "./batch_queue";

View File

@ -3,7 +3,7 @@ import axios from "axios";
import * as _ from "lodash";
import { success, warning, info, error } from "farmbot-toastr";
import { getDevice } from "../device";
import { Log, Everything } from "../interfaces";
import { Everything } from "../interfaces";
import {
GithubRelease, MoveRelProps, MinOsFeatureLookup, SourceFwConfig, Axis
} from "./interfaces";
@ -28,6 +28,7 @@ import { getFbosConfig } from "../resources/selectors_by_kind";
import { FbosConfig } from "../config_storage/fbos_configs";
import { FirmwareConfig } from "../config_storage/firmware_configs";
import { CONFIG_DEFAULTS } from "farmbot/dist/config";
import { Log } from "farmbot/dist/resources/api_resources";
const ON = 1, OFF = 0;
export type ConfigKey = keyof McuParams;

View File

@ -20,9 +20,7 @@ import {
fakeSequence
} from "../../../__test_support__/fake_state/resources";
import { initSave } from "../../../api/crud";
import {
PinBindingInputGroupProps, PinBindingType, PinBindingSpecialAction
} from "../interfaces";
import { PinBindingInputGroupProps } from "../interfaces";
import {
PinBindingInputGroup, PinNumberInputGroup, BindingTypeDropDown,
ActionTargetDropDown, SequenceTargetDropDown
@ -31,6 +29,7 @@ import { error, warning } from "farmbot-toastr";
import {
fakeResourceIndex
} from "../../../sequences/step_tiles/tile_move_absolute/test_helpers";
import { PinBindingType, PinBindingSpecialAction } from "farmbot/dist/resources/api_resources";
describe("<PinBindingInputGroup/>", () => {
function fakeProps(): PinBindingInputGroupProps {

View File

@ -1,3 +1,4 @@
import { PinBindingType, PinBindingSpecialAction } from "farmbot/dist/resources/api_resources";
const mockDevice = {
registerGpio: jest.fn(() => { return Promise.resolve(); }),
unregisterGpio: jest.fn(() => { return Promise.resolve(); }),
@ -10,7 +11,6 @@ jest.mock("../../../api/crud", () => ({
destroy: jest.fn()
}));
import { PinBindingSpecialAction, PinBindingType, } from "../interfaces";
const mockData = [{
pin_number: 1, sequence_id: undefined,
special_action: PinBindingSpecialAction.sync,

View File

@ -8,9 +8,12 @@ import {
import {
fakeSequence, fakePinBinding
} from "../../../__test_support__/fake_state/resources";
import { PinBindingsProps } from "../interfaces";
import {
PinBindingsProps, PinBindingType, PinBindingSpecialAction, SpecialPinBinding
} from "../interfaces";
SpecialPinBinding,
PinBindingType,
PinBindingSpecialAction
} from "farmbot/dist/resources/api_resources";
describe("<PinBindings/>", () => {
function fakeProps(): PinBindingsProps {
@ -62,7 +65,7 @@ describe("<PinBindings/>", () => {
p.shouldDisplay = () => true;
const wrapper = mount(<PinBindings {...p} />);
["pin bindings", "pin number", "none", "bind", "stock bindings"]
.map(string => expect(wrapper.text().toLowerCase()).toContain(string));
.map(string => expect(wrapper.text().toLowerCase()).toContain(string));
["26", "action"].map(string =>
expect(wrapper.text().toLowerCase()).toContain(string));
const buttons = wrapper.find("button");

View File

@ -1,6 +1,10 @@
import { BotState, ShouldDisplay } from "../interfaces";
import { NetworkState } from "../../connectivity/interfaces";
import { ResourceIndex } from "../../resources/interfaces";
import {
PinBindingType,
PinBindingSpecialAction
} from "farmbot/dist/resources/api_resources";
export interface PinBindingsProps {
bot: BotState;

View File

@ -1,5 +1,8 @@
import { t } from "i18next";
import { PinBindingType, PinBindingSpecialAction } from "./interfaces";
import {
PinBindingType,
PinBindingSpecialAction
} from "farmbot/dist/resources/api_resources";
import { DropDownItem } from "../../ui";
import { gpio } from "./rpi_gpio_diagram";
import { flattenDeep, isNumber } from "lodash";

View File

@ -5,8 +5,8 @@ import { PinBindingColWidth } from "./pin_bindings";
import { Popover, Position } from "@blueprintjs/core";
import { RpiGpioDiagram } from "./rpi_gpio_diagram";
import {
PinBindingType, PinBindingSpecialAction,
PinBindingInputGroupProps, PinBindingInputGroupState
PinBindingInputGroupProps,
PinBindingInputGroupState
} from "./interfaces";
import { isNumber, includes } from "lodash";
import { Feature, ShouldDisplay } from "../interfaces";
@ -22,6 +22,7 @@ import {
} from "./list_and_label_support";
import { SequenceSelectBox } from "../../sequences/sequence_select_box";
import { ResourceIndex } from "../../resources/interfaces";
import { PinBindingType, PinBindingSpecialAction } from "farmbot/dist/resources/api_resources";
export class PinBindingInputGroup
extends React.Component<PinBindingInputGroupProps, PinBindingInputGroupState> {

View File

@ -6,7 +6,7 @@ import { Feature, BotState } from "../interfaces";
import { selectAllPinBindings } from "../../resources/selectors";
import { MustBeOnline } from "../must_be_online";
import {
PinBinding, PinBindingSpecialAction, PinBindingType, PinBindingsProps,
PinBindingsProps,
PinBindingListItems
} from "./interfaces";
import { PinBindingsList } from "./pin_bindings_list";
@ -16,6 +16,11 @@ import {
} from "./tagged_pin_binding_init";
import { ResourceIndex } from "../../resources/interfaces";
import { Popover, Position, PopoverInteractionKind } from "@blueprintjs/core";
import {
PinBindingSpecialAction,
PinBindingType,
PinBinding
} from "farmbot/dist/resources/api_resources";
/** Width of UI columns in Pin Bindings widget. */
export enum PinBindingColWidth {

View File

@ -1,7 +1,10 @@
import * as React from "react";
import {
PinBindingType, PinBindingSpecialAction, PinBinding, PinBindingListItems
} from "./interfaces";
PinBindingType,
PinBindingSpecialAction,
PinBinding
} from "farmbot/dist/resources/api_resources";
import { PinBindingListItems } from "./interfaces";
import { TaggedPinBinding, SpecialStatus } from "farmbot";
import { ShouldDisplay, Feature } from "../interfaces";
import { stockPinBindings } from "./list_and_label_support";

View File

@ -10,7 +10,7 @@ import {
} from "../../../__test_support__/resource_index_builder";
import * as moment from "moment";
import { countBy } from "lodash";
import { TimeUnit } from "../../interfaces";
import { TimeUnit } from "farmbot/dist/resources/api_resources";
describe("mapStateToProps()", () => {
function testState() {

View File

@ -10,11 +10,11 @@ import { entries } from "../../resources/util";
import { Link } from "react-router";
import {
AddEditFarmEventProps,
TaggedExecutable,
ExecutableType
TaggedExecutable
} from "../interfaces";
import { BackArrow } from "../../ui/index";
import { SpecialStatus } from "farmbot";
import { ExecutableType } from "farmbot/dist/resources/api_resources";
interface State {
uuid: string;

View File

@ -7,9 +7,9 @@ import {
gracePeriodSeconds
} from "../scheduler";
import * as moment from "moment";
import { TimeUnit } from "../../../interfaces";
import { Moment } from "moment";
import { range, padStart } from "lodash";
import { TimeUnit } from "farmbot/dist/resources/api_resources";
describe("scheduler", () => {
it("runs every 4 hours, starting Tu, until Th w/ origin of Mo", () => {

View File

@ -1,6 +1,6 @@
import { FarmEvent, ExecutableType } from "../../interfaces";
import { Regimen } from "../../../regimens/interfaces";
import { Sequence } from "../../../sequences/interfaces";
import { ExecutableType, FarmEvent } from "farmbot/dist/resources/api_resources";
/** Would it be better to make a fully formed farm event? Join regimen, sequence, etc. */

View File

@ -1,8 +1,8 @@
import * as moment from "moment";
import { Moment, unitOfTime } from "moment";
import { range } from "lodash";
import { TimeUnit } from "../../interfaces";
import { NEVER } from "../edit_fe_form";
import { TimeUnit } from "farmbot/dist/resources/api_resources";
interface SchedulerProps {
startTime: Moment;

View File

@ -5,9 +5,7 @@ import { success, error } from "farmbot-toastr";
import {
TaggedFarmEvent, SpecialStatus, TaggedSequence, TaggedRegimen
} from "farmbot";
import {
TimeUnit, ExecutableQuery, ExecutableType, FarmEvent
} from "../interfaces";
import { ExecutableQuery } from "../interfaces";
import { formatTime, formatDate } from "./map_state_to_props_add_edit";
import {
BackArrow,
@ -31,6 +29,7 @@ import { EventTimePicker } from "./event_time_picker";
import { TzWarning } from "./tz_warning";
import { nextRegItemTimes } from "./map_state_to_props";
import { first } from "lodash";
import { TimeUnit, ExecutableType, FarmEvent } from "farmbot/dist/resources/api_resources";
type FormEvent = React.SyntheticEvent<HTMLInputElement>;
export const NEVER: TimeUnit = "never";

View File

@ -5,9 +5,9 @@ import {
} from "../../ui/index";
import { repeatOptions } from "./map_state_to_props_add_edit";
import { keyBy } from "lodash";
import { TimeUnit } from "../interfaces";
import { FarmEventViewModel } from "./edit_fe_form";
import { EventTimePicker } from "./event_time_picker";
import { TimeUnit } from "farmbot/dist/resources/api_resources";
type Ev = React.SyntheticEvent<HTMLInputElement>;
type Key = keyof FarmEventViewModel;

View File

@ -1,4 +1,4 @@
import { AddEditFarmEventProps, ExecutableType } from "../interfaces";
import { AddEditFarmEventProps } from "../interfaces";
import { Everything } from "../../interfaces";
import * as moment from "moment";
import { t } from "i18next";
@ -29,6 +29,7 @@ import {
import { sourceFbosConfigValue } from "../../devices/components/source_config_value";
import { Feature } from "../../devices/interfaces";
import { hasId } from "../../resources/util";
import { ExecutableType } from "farmbot/dist/resources/api_resources";
export let formatTime = (input: string, timeOffset: number) => {
const iso = new Date(input).toISOString();

View File

@ -9,7 +9,6 @@ import {
TaggedPlantPointer,
TaggedImage,
} from "farmbot";
import { PlantPointer } from "../interfaces";
import { SlotWithTool } from "../resources/interfaces";
import { BotPosition, StepsPerMmXY, BotLocationData } from "../devices/interfaces";
import { isNumber } from "lodash";
@ -18,6 +17,7 @@ import { AxisNumberProperty, BotSize } from "./map/interfaces";
import { SelectionBoxData } from "./map/selection_box";
import { BooleanConfigKey } from "../config_storage/web_app_configs";
import { GetWebAppConfigValue } from "../config_storage/actions";
import { ExecutableType, PlantPointer } from "farmbot/dist/resources/api_resources";
/* BotOriginQuadrant diagram

View File

@ -8,9 +8,9 @@ import * as React from "react";
import { ToolSlotLayer, ToolSlotLayerProps } from "../tool_slot_layer";
import { fakeMapTransformProps } from "../../../../__test_support__/map_transform_props";
import { fakeResource } from "../../../../__test_support__/fake_resource";
import { ToolSlotPointer } from "../../../../interfaces";
import { shallow } from "enzyme";
import { history } from "../../../../history";
import { ToolSlotPointer } from "farmbot/dist/resources/api_resources";
describe("<ToolSlotLayer/>", () => {
function fakeProps(): ToolSlotLayerProps {

View File

@ -1,8 +1,8 @@
import * as React from "react";
import { Color } from "../../ui/index";
import { trim } from "../../util";
import { ToolPulloutDirection } from "../../interfaces";
import { BotOriginQuadrant } from "../interfaces";
import { ToolPulloutDirection } from "farmbot/dist/resources/api_resources";
export interface ToolGraphicProps {
x: number;

View File

@ -1,7 +1,7 @@
import * as React from "react";
import { Color } from "../../ui/index";
import { ToolPulloutDirection } from "../../interfaces";
import { BotOriginQuadrant } from "../interfaces";
import { ToolPulloutDirection } from "farmbot/dist/resources/api_resources";
enum Anchor {
start = 0,

View File

@ -1,5 +1,5 @@
import { PlantOptions } from "./interfaces";
import { PlantPointer } from "../interfaces";
import { PlantPointer } from "farmbot/dist/resources/api_resources";
export const DEFAULT_PLANT_RADIUS = 25;

View File

@ -36,6 +36,7 @@ interface SelectPlantsState {
stashedUuid: string | undefined;
stashedIcon: string;
}
const YOU_SURE = "Are you sure you want to delete {{length}} plants?";
@connect(mapStateToProps)
export class SelectPlants
@ -66,7 +67,7 @@ export class SelectPlants
destroySelected = (plantUUIDs: string[]) => {
if (plantUUIDs &&
confirm(t("Are you sure you want to delete {{length}} plants?", { length: plantUUIDs.length }))) {
confirm(t(YOU_SURE, { length: plantUUIDs.length }))) {
plantUUIDs.map(uuid => {
this
.props

View File

@ -2,8 +2,8 @@ import axios, { AxiosPromise } from "axios";
import * as _ from "lodash";
import { OpenFarm, CropSearchResult } from "./openfarm";
import { DEFAULT_ICON } from "../open_farm/icons";
import { ExecutableType } from "./interfaces";
import { Actions } from "../constants";
import { ExecutableType } from "farmbot/dist/resources/api_resources";
const url = (q: string) => `${OpenFarm.cropUrl}?include=pictures&filter=${q}`;
const openFarmSearchQuery = (q: string): AxiosPromise<CropSearchResult> =>

View File

@ -5,12 +5,12 @@ import { success, error } from "farmbot-toastr";
import { Thunk } from "../../redux/interfaces";
import { API } from "../../api";
import { Progress, ProgressCallback } from "../../util";
import { GenericPointer } from "../../interfaces";
import { getDevice } from "../../device";
import { WDENVKey } from "./remote_env/interfaces";
import { NumericValues } from "./image_workspace";
import { envSave } from "./remote_env/actions";
import { noop } from "lodash";
import { GenericPointer } from "farmbot/dist/resources/api_resources";
type Key = keyof NumericValues;
type Translation = Record<Key, WDENVKey>;

View File

@ -1,9 +1,9 @@
import { Actions } from "../constants";
import { API } from "../api";
import { Log } from "../interfaces";
import { noop, throttle } from "lodash";
import axios from "axios";
import { ResourceName } from "farmbot";
import { Log } from "farmbot/dist/resources/api_resources";
const name: ResourceName = "Log";
/** re-Downloads all logs from the API and force replaces all entries for logs

View File

@ -1,12 +1,10 @@
import axios from "axios";
import { Log, Point, SensorReading, Sensor, DeviceConfig } from "../interfaces";
import { SensorReading, Sensor, DeviceConfig } from "../interfaces";
import { API } from "../api";
import { Sequence } from "../sequences/interfaces";
import { Tool } from "../tools/interfaces";
import { Regimen } from "../regimens/interfaces";
import { Peripheral } from "../controls/peripherals/interfaces";
import { FarmEvent, SavedGarden, PlantTemplate } from "../farm_designer/interfaces";
import { Image } from "../farmware/images/interfaces";
import { SavedGarden } from "../farm_designer/interfaces";
import { DeviceAccountSettings } from "../devices/interfaces";
import { ResourceName, DiagnosticDump } from "farmbot";
import { User } from "../auth/interfaces";
@ -14,9 +12,17 @@ import { WebcamFeed } from "../controls/interfaces";
import { WebAppConfig } from "../config_storage/web_app_configs";
import { Session } from "../session";
import { FbosConfig } from "../config_storage/fbos_configs";
import { FarmwareInstallation } from "../farmware/interfaces";
import { FirmwareConfig } from "../config_storage/firmware_configs";
import { PinBinding } from "../devices/pin_bindings/interfaces";
import {
FarmEvent,
Image,
Log,
Point,
Peripheral,
FarmwareInstallation,
PinBinding,
PlantTemplate
} from "farmbot/dist/resources/api_resources";
export interface ResourceReadyPayl {
name: ResourceName;

View File

@ -2,9 +2,9 @@ import * as React from "react";
import { t } from "i18next";
import { FBSelect, DropDownItem } from "../../ui/index";
import { TaggedToolSlotPointer } from "farmbot";
import { ToolPulloutDirection } from "../../interfaces";
import { edit } from "../../api/crud";
import { isNumber } from "lodash";
import { ToolPulloutDirection } from "farmbot/dist/resources/api_resources";
const DIRECTION_CHOICES_DDI: { [index: number]: DropDownItem } = {
[ToolPulloutDirection.NONE]:

View File

@ -3,9 +3,9 @@ import { t } from "i18next";
import { isNumber } from "lodash";
import { BotPosition } from "../../devices/interfaces";
import { TaggedToolSlotPointer } from "farmbot";
import { ToolPulloutDirection } from "../../interfaces";
import { edit } from "../../api/crud";
import { SlotDirectionSelect } from "./toolbay_slot_direction_selection";
import { ToolPulloutDirection } from "farmbot/dist/resources/api_resources";
const positionIsDefined = (position: BotPosition): boolean => {
return isNumber(position.x) && isNumber(position.y) && isNumber(position.z);