Skip to content

Commit

Permalink
Remove types and useBoolean proxy modules (#3088)
Browse files Browse the repository at this point in the history
  • Loading branch information
Janpot authored Jan 18, 2024
1 parent 15561dc commit 13d41d0
Show file tree
Hide file tree
Showing 36 changed files with 117 additions and 123 deletions.
2 changes: 1 addition & 1 deletion packages/toolpad-app/src/appDom/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import invariant from 'invariant';
import { BoxProps, ThemeOptions as MuiThemeOptions } from '@mui/material';
import { guessTitle, pascalCase, removeDiacritics, uncapitalize } from '@mui/toolpad-utils/strings';
import { mapProperties, mapValues, hasOwnProperty } from '@mui/toolpad-utils/collections';
import { ExactEntriesOf, Maybe } from '@mui/toolpad-utils/types';
import { AuthProviderConfig, ConnectionStatus } from '../types';
import { omit, update, updateOrCreate } from '../utils/immutability';
import { ExactEntriesOf, Maybe } from '../utils/types';
import { envBindingSchema } from '../server/schema';

export const CURRENT_APPDOM_VERSION = 7;
Expand Down
2 changes: 1 addition & 1 deletion packages/toolpad-app/src/components/MapEntriesEditor.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Box, TextField, IconButton, SxProps } from '@mui/material';
import * as React from 'react';
import DeleteIcon from '@mui/icons-material/Delete';
import { WithControlledProp } from '../utils/types';
import { WithControlledProp } from '@mui/toolpad-utils/types';

function renderStringValueEditor({
label,
Expand Down
2 changes: 1 addition & 1 deletion packages/toolpad-app/src/components/MuiThemeEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
} from '@mui/material';
import LightModeIcon from '@mui/icons-material/LightMode';
import DarkModeIcon from '@mui/icons-material/DarkMode';
import { WithControlledProp } from '../utils/types';
import { WithControlledProp } from '@mui/toolpad-utils/types';
import ColorTool from './ColorTool';
import FlexFill from './FlexFill';

Expand Down
2 changes: 1 addition & 1 deletion packages/toolpad-app/src/server/EnvManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import * as dotenv from 'dotenv';
import { Emitter } from '@mui/toolpad-utils/events';
import chalk from 'chalk';
import { truncate } from '@mui/toolpad-utils/strings';
import { Awaitable } from '@mui/toolpad-utils/types';
import { ProjectEvents, ToolpadProjectOptions } from '../types';
import { Awaitable } from '../utils/types';

interface IToolpadProject {
options: ToolpadProjectOptions;
Expand Down
2 changes: 1 addition & 1 deletion packages/toolpad-app/src/server/FunctionsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ import { ToolpadDataProviderIntrospection } from '@mui/toolpad-core/runtime';
import * as url from 'node:url';
import type { GridRowId } from '@mui/x-data-grid';
import invariant from 'invariant';
import { Awaitable } from '@mui/toolpad-utils/types';
import EnvManager from './EnvManager';
import { ProjectEvents, ToolpadProjectOptions } from '../types';
import * as functionsRuntime from './functionsRuntime';
import type { ExtractTypesParams, IntrospectionResult } from './functionsTypesWorker';
import { Awaitable } from '../utils/types';
import { format } from '../utils/prettier';
import { compilerOptions } from './functionsShared';

Expand Down
2 changes: 1 addition & 1 deletion packages/toolpad-app/src/server/localMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
readJsonFile,
} from '@mui/toolpad-utils/fs';
import { z } from 'zod';
import { Awaitable } from '@mui/toolpad-utils/types';
import * as appDom from '../appDom';
import insecureHash from '../utils/insecureHash';
import {
Expand Down Expand Up @@ -57,7 +58,6 @@ import type {
ToolpadProjectOptions,
CodeEditorFileType,
} from '../types';
import { Awaitable } from '../utils/types';
import EnvManager from './EnvManager';
import FunctionsManager, { CreateDataProviderOptions } from './FunctionsManager';
import { VersionInfo, checkVersion } from './versionInfo';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ import { TabContext, TabList } from '@mui/lab';
import useDebounced from '@mui/toolpad-utils/hooks/useDebounced';
import { errorFrom } from '@mui/toolpad-utils/errors';
import useLatest from '@mui/toolpad-utils/hooks/useLatest';
import { WithControlledProp, Maybe } from '@mui/toolpad-utils/types';
import { JsExpressionEditor } from './PageEditor/JsExpressionEditor';
import JsonView from '../../components/JsonView';
import { useEvaluateLiveBinding } from './useEvaluateLiveBinding';
import GlobalScopeExplorer from './GlobalScopeExplorer';
import { WithControlledProp, Maybe } from '../../utils/types';

import { tryFormatExpression } from '../../utils/prettier';
import useShortcut from '../../utils/useShortcut';
Expand Down
2 changes: 1 addition & 1 deletion packages/toolpad-app/src/toolpad/AppEditor/NoPageFound.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Grid, Typography, Button } from '@mui/material';
import * as React from 'react';
import useBoolean from '../../utils/useBoolean';
import useBoolean from '@mui/toolpad-utils/hooks/useBoolean';
import CreatePageNodeDialog from './PagesExplorer/CreatePageNodeDialog';

export default function NoPageFound() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
ScopeMeta,
EnvAttrValue,
} from '@mui/toolpad-core';
import { WithControlledProp } from '../../../utils/types';
import { WithControlledProp } from '@mui/toolpad-utils/types';
import { getBindingType } from '../../../runtime/bindings';
import { getDefaultControl, usePropControlsContext } from '../../propertyControls';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
ComponentConfig,
LiveBinding,
} from '@mui/toolpad-core';
import { ExactEntriesOf } from '../../../utils/types';
import { ExactEntriesOf } from '@mui/toolpad-utils/types';
import * as appDom from '../../../appDom';
import NodeAttributeEditor from './NodeAttributeEditor';
import { usePageEditorState } from './PageEditorProvider';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { TextField, MenuItem, SxProps } from '@mui/material';
import * as React from 'react';
import { NodeId } from '@mui/toolpad-core';
import { asArray } from '@mui/toolpad-utils/collections';
import { Maybe, WithControlledProp } from '@mui/toolpad-utils/types';
import * as appDom from '../../../appDom';
import { Maybe, WithControlledProp } from '../../../utils/types';
import { useAppState } from '../../AppState';
import dataSources from '../../../toolpadDataSources/client';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import jsonToTs from 'json-to-ts';
import { Skeleton, styled, SxProps } from '@mui/material';
import { ScopeMeta } from '@mui/toolpad-core';
import { getCircularReplacer, replaceRecursive } from '@mui/toolpad-utils/json';
import { WithControlledProp } from '../../../utils/types';
import { WithControlledProp } from '@mui/toolpad-utils/types';
import lazyComponent from '../../../utils/lazyComponent';
import ElementContext from '../ElementContext';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Box, TextField, IconButton, SxProps, inputLabelClasses } from '@mui/mat
import * as React from 'react';
import DeleteIcon from '@mui/icons-material/Delete';
import { BindableAttrValue, ScopeMeta, JsRuntime, LiveBinding } from '@mui/toolpad-core';
import { WithControlledProp } from '../../../utils/types';
import { WithControlledProp } from '@mui/toolpad-utils/types';
import BindableEditor from './BindableEditor';

export interface StringRecordEntriesEditorProps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import AddIcon from '@mui/icons-material/Add';
import MoreVertIcon from '@mui/icons-material/MoreVert';
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
import ChevronRightIcon from '@mui/icons-material/ChevronRight';
import useBoolean from '@mui/toolpad-utils/hooks/useBoolean';
import * as appDom from '../../../../appDom';
import dataSources from '../../../../toolpadDataSources/client';
import QueryIcon from '../../QueryIcon';
import { useAppState, useAppStateApi } from '../../../AppState';
import useBoolean from '../../../../utils/useBoolean';
import EditableTreeItem, { EditableTreeItemProps } from '../../../../components/EditableTreeItem';
import NodeMenu from '../../NodeMenu';
import ExplorerHeader from '../../ExplorerHeader';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import {
import * as React from 'react';
import AddIcon from '@mui/icons-material/Add';
import { NodeId } from '@mui/toolpad-core';
import useBoolean from '@mui/toolpad-utils/hooks/useBoolean';
import * as appDom from '../../../appDom';
import { useAppState, useDomApi, useAppStateApi } from '../../AppState';
import MapEntriesEditor from '../../../components/MapEntriesEditor';
import useBoolean from '../../../utils/useBoolean';
import useUnsavedChangesConfirm from '../../hooks/useUnsavedChangesConfirm';

export interface UrlQueryEditorProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import { NodeId } from '@mui/toolpad-core';
import clsx from 'clsx';
import invariant from 'invariant';
import { alphabeticComparator, createPropComparator } from '@mui/toolpad-utils/comparators';
import useBoolean from '@mui/toolpad-utils/hooks/useBoolean';
import * as appDom from '../../../appDom';
import { useAppStateApi, useAppState, useDomApi } from '../../AppState';
import useLocalStorageState from '../../../utils/useLocalStorageState';
import NodeMenu from '../NodeMenu';
import { DomView } from '../../../utils/domView';
import { useProjectApi } from '../../../projectApi';
import useBoolean from '../../../utils/useBoolean';
import EditableTreeItem, { EditableTreeItemProps } from '../../../components/EditableTreeItem';
import { scrollIntoViewIfNeeded } from '../../../utils/dom';
import ExplorerHeader from '../ExplorerHeader';
Expand Down
2 changes: 1 addition & 1 deletion packages/toolpad-app/src/toolpad/AppOptions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { Divider, ListItemIcon, ListItemText, Menu, MenuItem } from '@mui/materi
import IconButton from '@mui/material/IconButton';
import MoreVertIcon from '@mui/icons-material/MoreVert';
import CodeIcon from '@mui/icons-material/Code';
import useBoolean from '@mui/toolpad-utils/hooks/useBoolean';
import useMenu from '../../utils/useMenu';
import useBoolean from '../../utils/useBoolean';
import AppExportDialog from './AppExportDialog';
import * as appDom from '../../appDom';

Expand Down
2 changes: 1 addition & 1 deletion packages/toolpad-app/src/toolpad/Toolpad.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import CloudDoneIcon from '@mui/icons-material/CloudDone';
import SyncIcon from '@mui/icons-material/Sync';
import SyncProblemIcon from '@mui/icons-material/SyncProblem';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import useBoolean from '@mui/toolpad-utils/hooks/useBoolean';
import AppEditor from './AppEditor';
import ErrorAlert from './AppEditor/PageEditor/ErrorAlert';
import { ThemeProvider } from '../ThemeContext';
Expand All @@ -17,7 +18,6 @@ import AppProvider, { AppState, useAppStateContext } from './AppState';
import { FEATURE_FLAG_AUTHORIZATION, FEATURE_FLAG_GLOBAL_FUNCTIONS } from '../constants';
import { ProjectProvider } from '../project';
import AppAuthorizationDialog from './AppEditor/AppAuthorizationEditor';
import useBoolean from '../utils/useBoolean';

const Centered = styled('div')({
height: '100%',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import {
import HelpOutlinedIcon from '@mui/icons-material/HelpOutlined';
import OpenInNewIcon from '@mui/icons-material/OpenInNew';
import invariant from 'invariant';
import useBoolean from '@mui/toolpad-utils/hooks/useBoolean';
import useMenu from '../../../../utils/useMenu';
import { DOCUMENTATION_URL, VERSION_CHECK_INTERVAL } from '../../../../constants';
import { useProjectApi } from '../../../../projectApi';
import useBoolean from '../../../../utils/useBoolean';
import type { PackageManager } from '../../../../server/versionInfo';

const REPORT_BUG_URL =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { OAuth2Client } from 'google-auth-library';
import { match } from 'path-to-regexp';
import { asArray } from '@mui/toolpad-utils/collections';
import * as express from 'express';
import { Maybe } from '@mui/toolpad-utils/types';
import { ServerDataSource, CreateHandlerApi } from '../../types';
import config from '../../server/config';
import {
Expand All @@ -12,7 +13,6 @@ import {
GoogleSheetsApiQuery,
GoogleSheetsResult,
} from './types';
import { Maybe } from '../../utils/types';
import type { IToolpadProject } from '../server';

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ExecFetchResult } from '@mui/toolpad-core';
import { Maybe } from '@mui/toolpad-utils/types';
import { ServerDataSource } from '../../types';
import { LocalQuery, LocalConnectionParams, LocalPrivateApi } from './types';
import { Maybe } from '../../utils/types';
import { parseLegacyFunctionId } from './shared';
import type { IToolpadProject } from '../server';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createConnection, OkPacket, ResultSetHeader } from 'mysql2/promise';
import { errorFrom } from '@mui/toolpad-utils/errors';
import { Maybe } from '../../utils/types';
import { Maybe } from '@mui/toolpad-utils/types';
import { SqlConnectionParams, SqlQuery, SqlResult } from '../sql/types';
import { createSqlServerDatasource } from '../sql/server';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pg from 'pg';
import { errorFrom } from '@mui/toolpad-utils/errors';
import { Maybe } from '../../utils/types';
import { Maybe } from '@mui/toolpad-utils/types';
import { SqlConnectionParams, SqlQuery, SqlResult } from '../sql/types';
import { createSqlServerDatasource } from '../sql/server';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import { Grid, MenuItem, Stack, TextField } from '@mui/material';
import { Maybe, WithControlledProp } from '@mui/toolpad-utils/types';
import { ApiKeyAuth, Authentication, BasicAuth, BearerTokenAuth } from './types';
import { Maybe, WithControlledProp } from '../../utils/types';

interface AuthMethodEditorProps<T> extends WithControlledProp<T> {
disabled?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import {
import { TabContext } from '@mui/lab';
import { BindableAttrValue, LiveBinding, ScopeMeta } from '@mui/toolpad-core';
import { useServerJsRuntime } from '@mui/toolpad-core/jsServerRuntime';
import { Maybe, WithControlledProp } from '@mui/toolpad-utils/types';
import { Body, RawBody, UrlEncodedBody } from './types';
import { Maybe, WithControlledProp } from '../../utils/types';
import {
useEvaluateLiveBinding,
useEvaluateLiveBindingEntries,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import PlayArrowIcon from '@mui/icons-material/PlayArrow';
import { Controller, useForm } from 'react-hook-form';
import { TabContext, TabList } from '@mui/lab';
import { createServerJsRuntime } from '@mui/toolpad-core/jsServerRuntime';
import { Maybe } from '@mui/toolpad-utils/types';
import { Panel, PanelGroup, PanelResizeHandle } from '../../components/resizablePanels';
import { ClientDataSource, ConnectionEditorProps, QueryEditorProps } from '../../types';
import {
Expand All @@ -41,7 +42,6 @@ import {
useEvaluateLiveBindingEntries,
} from '../../toolpad/AppEditor/useEvaluateLiveBinding';
import MapEntriesEditor from '../../components/MapEntriesEditor';
import { Maybe } from '../../utils/types';
import AuthenticationEditor from './AuthenticationEditor';
import { isSaveDisabled, validation } from '../../utils/forms';
import { useAppState, useAppStateApi } from '../../toolpad/AppState';
Expand Down
2 changes: 1 addition & 1 deletion packages/toolpad-app/src/toolpadDataSources/rest/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { createServerJsRuntime } from '@mui/toolpad-core/jsServerRuntime';
import { SerializedError, errorFrom, serializeError } from '@mui/toolpad-utils/errors';
import { evaluateBindable } from '@mui/toolpad-core/jsRuntime';
import { removePrefix } from '@mui/toolpad-utils/strings';
import { Maybe } from '@mui/toolpad-utils/types';
import { withHarInstrumentation, createHarLog } from '../../server/har';
import { ServerDataSource } from '../../types';
import {
Expand All @@ -21,7 +22,6 @@ import {
RestConnectionParams,
UrlEncodedBody,
} from './types';
import { Maybe } from '../../utils/types';
import applyTransform from '../applyTransform';
import { HTTP_NO_BODY, getAuthenticationHeaders, getDefaultUrl, parseBaseUrl } from './shared';
import type { IToolpadProject } from '../server';
Expand Down
2 changes: 1 addition & 1 deletion packages/toolpad-app/src/toolpadDataSources/rest/shared.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BindableAttrValue } from '@mui/toolpad-core';
import { ensureSuffix } from '@mui/toolpad-utils/strings';
import { Maybe } from '../../utils/types';
import { Maybe } from '@mui/toolpad-utils/types';
import { Authentication, RestConnectionParams } from './types';
import type { RuntimeConfig } from '../../types';

Expand Down
2 changes: 1 addition & 1 deletion packages/toolpad-app/src/toolpadDataSources/rest/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BindableAttrValue, ExecFetchResult } from '@mui/toolpad-core';
import type { Har } from 'har-format';
import { Maybe } from '../../utils/types';
import { Maybe } from '@mui/toolpad-utils/types';

interface AuthenticationBase {
type: 'basic' | 'bearerToken' | 'apiKey';
Expand Down
2 changes: 1 addition & 1 deletion packages/toolpad-app/src/toolpadDataSources/sql/client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ import { getObjectKey } from '@mui/toolpad-utils/objectKey';
import { BindableAttrEntries, BindableAttrValue, ExecFetchResult } from '@mui/toolpad-core';
import { useBrowserJsRuntime } from '@mui/toolpad-core/jsBrowserRuntime';
import { serializeError, errorFrom } from '@mui/toolpad-utils/errors';
import { Maybe } from '@mui/toolpad-utils/types';
import { Panel, PanelGroup, PanelResizeHandle } from '../../components/resizablePanels';
import ParametersEditor from '../../toolpad/AppEditor/PageEditor/ParametersEditor';
import { useEvaluateLiveBindingEntries } from '../../toolpad/AppEditor/useEvaluateLiveBinding';
import { QueryEditorProps } from '../../types';
import { isSaveDisabled, validation } from '../../utils/forms';
import lazyComponent from '../../utils/lazyComponent';
import { Maybe } from '../../utils/types';
import QueryInputPanel from '../QueryInputPanel';
import useFetchPrivate from '../useFetchPrivate';
import useQueryPreview from '../useQueryPreview';
Expand Down
2 changes: 1 addition & 1 deletion packages/toolpad-app/src/toolpadDataSources/sql/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ExecFetchResult } from '@mui/toolpad-core';
import type { Maybe, WithControlledProp } from '../../utils/types';
import type { Maybe, WithControlledProp } from '@mui/toolpad-utils/types';

export interface SqlConnectionParams {
host: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/toolpad-app/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import {
NodeHashes,
} from '@mui/toolpad-core';
import { PaletteMode } from '@mui/material';
import type { Awaitable, Maybe, WithControlledProp } from '@mui/toolpad-utils/types';
import type * as appDom from './appDom';
import type { Awaitable, Maybe, WithControlledProp } from './utils/types';
import type { Rectangle } from './utils/geometry';
import type { RuntimeState } from './runtime';

Expand Down
2 changes: 1 addition & 1 deletion packages/toolpad-app/src/utils/express.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as express from 'express';
import { Awaitable } from './types';
import { Awaitable } from '@mui/toolpad-utils/types';

export function asyncHandler(
handler: (
Expand Down
Loading

0 comments on commit 13d41d0

Please sign in to comment.