Skip to content

Commit

Permalink
Move services to @common
Browse files Browse the repository at this point in the history
  • Loading branch information
somebody1234 committed Dec 19, 2024
1 parent 2d1ee47 commit ffa9c77
Show file tree
Hide file tree
Showing 23 changed files with 34 additions and 35 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,16 @@ import { download } from '@common/utilities/download'
import { tryGetMessage } from '@common/utilities/error'
import { uniqueString } from '@common/utilities/uniqueString'

import type ProjectManager from '#/services/ProjectManager'
import { APP_BASE_URL } from '#/utilities/appBaseUrl'
import type ProjectManager from '@common/services/ProjectManager'
import {
FileSystemEntryType,
MissingComponentAction,
Path,
ProjectName,
UUID,
type IpWithSocket,
} from '#/services/ProjectManager'
import { APP_BASE_URL } from '#/utilities/appBaseUrl'
} from '@common/services/ProjectManager'

/** Convert a {@link IpWithSocket} to a {@link Address}. */
function ipWithSocketToAddress(ipWithSocket: IpWithSocket) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ import {
updateAssetPath,
updateDirectoryPath,
updateSecretPath,
} from '#/services/remoteBackendPaths'
} from '@common/services/remoteBackendPaths'

import type HttpClient from '#/utilities/HttpClient'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/** @file Paths used by the `RemoteBackend`. */
import { newtypeConstructor, type Newtype } from '../utilities/data/newtype'
import type {
AssetId,
CheckoutSessionId,
Expand All @@ -11,8 +12,7 @@ import type {
TagId,
UserGroupId,
UserId,
} from '@common/services/Backend'
import { newtypeConstructor, type Newtype } from '@common/utilities/data/newtype'
} from './Backend'

/** Relative HTTP path to the "list users" endpoint of the Cloud backend API. */
export const LIST_USERS_PATH = 'users'
Expand Down Expand Up @@ -203,7 +203,6 @@ export function getCheckoutSessionPath(checkoutSessionId: CheckoutSessionId) {

/** Unique identifier for a directory. */
type DirectoryId = Newtype<string, 'DirectoryId'>
// eslint-disable-next-line @typescript-eslint/no-redeclare
const DirectoryId = newtypeConstructor<DirectoryId>()
export const ROOT_PARENT_DIRECTORY_ID = DirectoryId('')
/** The ID of the directory containing the home directories of all users. */
Expand Down
6 changes: 3 additions & 3 deletions app/gui/src/dashboard/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,13 @@ import ModalProvider, { useSetModal } from '#/providers/ModalProvider'
import { useNavigator2D } from '#/providers/Navigator2DProvider'
import SessionProvider from '#/providers/SessionProvider'
import { useText } from '#/providers/TextProvider'
import LocalBackend from '#/services/LocalBackend'
import ProjectManager, * as projectManager from '#/services/ProjectManager'
import RemoteBackend from '#/services/RemoteBackend'
import { APP_BASE_URL } from '#/utilities/appBaseUrl'
import { isElementPartOfMonaco, isElementTextInput } from '#/utilities/event'
import LocalStorage from '#/utilities/LocalStorage'
import { STATIC_QUERY_OPTIONS } from '#/utilities/reactQuery'
import LocalBackend from '@common/services/LocalBackend'
import ProjectManager, * as projectManager from '@common/services/ProjectManager'
import RemoteBackend from '@common/services/RemoteBackend'

declare module '#/utilities/LocalStorage' {
/** */
Expand Down
2 changes: 1 addition & 1 deletion app/gui/src/dashboard/components/dashboard/AssetRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import AssetContextMenu from '#/layouts/AssetContextMenu'
import type * as assetsTable from '#/layouts/AssetsTable'
import { isCloudCategory, isLocalCategory } from '#/layouts/CategorySwitcher/Category'
import * as eventListProvider from '#/layouts/Drive/EventListProvider'
import * as localBackend from '#/services/LocalBackend'
import * as localBackend from '@common/services/LocalBackend'

import { Text } from '#/components/AriaComponents'
import { IndefiniteSpinner } from '#/components/Spinner'
Expand Down
4 changes: 2 additions & 2 deletions app/gui/src/dashboard/hooks/backendHooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ import {
import { useLocalStorageState } from '#/providers/LocalStorageProvider'
import { useSetModal } from '#/providers/ModalProvider'
import { useText } from '#/providers/TextProvider'
import LocalBackend from '#/services/LocalBackend'
import { TEAMS_DIRECTORY_ID, USERS_DIRECTORY_ID } from '#/services/remoteBackendPaths'
import { tryCreateOwnerPermission } from '#/utilities/permissions'
import { usePreventNavigation } from '#/utilities/preventNavigation'
import LocalBackend from '@common/services/LocalBackend'
import { TEAMS_DIRECTORY_ID, USERS_DIRECTORY_ID } from '@common/services/remoteBackendPaths'

// The number of bytes in 1 megabyte.
const MB_BYTES = 1_000_000
Expand Down
4 changes: 2 additions & 2 deletions app/gui/src/dashboard/layouts/AssetContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ import { useLocalBackend, useRemoteBackend } from '#/providers/BackendProvider'
import { usePasteData } from '#/providers/DriveProvider'
import { useSetModal } from '#/providers/ModalProvider'
import { useText } from '#/providers/TextProvider'
import { extractTypeAndId } from '#/services/LocalBackend'
import { TEAMS_DIRECTORY_ID, USERS_DIRECTORY_ID } from '#/services/remoteBackendPaths'
import {
canPermissionModifyDirectoryContents,
isTeamPath,
PERMISSION_ACTION_CAN_EXECUTE,
PermissionAction,
tryFindSelfPermission,
} from '#/utilities/permissions'
import { extractTypeAndId } from '@common/services/LocalBackend'
import { TEAMS_DIRECTORY_ID, USERS_DIRECTORY_ID } from '@common/services/remoteBackendPaths'
import { useSetAssetPanelProps, useSetIsAssetPanelTemporarilyVisible } from './AssetPanel'

/** Props for a {@link AssetContextMenu}. */
Expand Down
2 changes: 1 addition & 1 deletion app/gui/src/dashboard/layouts/AssetProperties.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ import { useFullUserSession } from '#/providers/AuthProvider'
import { useLocalBackend } from '#/providers/BackendProvider'
import { useFeatureFlags } from '#/providers/FeatureFlagsProvider'
import { useText } from '#/providers/TextProvider'
import { extractTypeAndId } from '#/services/LocalBackend'
import { PermissionAction, tryFindSelfPermission } from '#/utilities/permissions'
import { tv } from '#/utilities/tailwindVariants'
import { useStore } from '#/utilities/zustand'
import { extractTypeAndId } from '@common/services/LocalBackend'

const ASSET_PROPERTIES_VARIANTS = tv({
base: '',
Expand Down
2 changes: 1 addition & 1 deletion app/gui/src/dashboard/layouts/AssetsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ import { useSetModal } from '#/providers/ModalProvider'
import { useNavigator2D } from '#/providers/Navigator2DProvider'
import { useLaunchedProjects } from '#/providers/ProjectsProvider'
import { useText } from '#/providers/TextProvider'
import { isSpecialReadonlyDirectoryId } from '#/services/RemoteBackend'
import type { AssetQueryKey } from '#/utilities/AssetQuery'
import AssetQuery from '#/utilities/AssetQuery'
import type AssetTreeNode from '#/utilities/AssetTreeNode'
Expand All @@ -141,6 +140,7 @@ import { document } from '#/utilities/sanitizedEventTargets'
import type { SortInfo } from '#/utilities/sorting'
import { twJoin, twMerge } from '#/utilities/tailwindMerge'
import Visibility from '#/utilities/Visibility'
import { isSpecialReadonlyDirectoryId } from '@common/services/RemoteBackend'

declare module '#/utilities/LocalStorage' {
/** */
Expand Down
4 changes: 2 additions & 2 deletions app/gui/src/dashboard/layouts/CategorySwitcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ import { useLocalStorageState } from '#/providers/LocalStorageProvider'
import { useSetModal } from '#/providers/ModalProvider'
import { TabType } from '#/providers/ProjectsProvider'
import { useText } from '#/providers/TextProvider'
import { newDirectoryId } from '#/services/LocalBackend'
import { TEAMS_DIRECTORY_ID, USERS_DIRECTORY_ID } from '#/services/remoteBackendPaths'
import LocalStorage from '#/utilities/LocalStorage'
import { tv } from '#/utilities/tailwindVariants'
import { newDirectoryId } from '@common/services/LocalBackend'
import { TEAMS_DIRECTORY_ID, USERS_DIRECTORY_ID } from '@common/services/remoteBackendPaths'

// ============================
// === Global configuration ===
Expand Down
2 changes: 1 addition & 1 deletion app/gui/src/dashboard/layouts/CategorySwitcher/Category.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { useEventCallback } from '#/hooks/eventCallbackHooks'
import { useDispatchAssetEvent } from '#/layouts/Drive/EventListProvider'
import { useFullUserSession } from '#/providers/AuthProvider'
import { useBackend, useLocalBackend, useRemoteBackend } from '#/providers/BackendProvider'
import { newDirectoryId } from '#/services/LocalBackend'
import { newDirectoryId } from '@common/services/LocalBackend'

const PATH_SCHEMA = z.string().refine((s): s is Path => true)
const DIRECTORY_ID_SCHEMA = z.string().refine((s): s is DirectoryId => true)
Expand Down
4 changes: 2 additions & 2 deletions app/gui/src/dashboard/layouts/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { useToastAndLog } from '#/hooks/toastAndLogHooks'
import { useFullUserSession } from '#/providers/AuthProvider'
import { useLogger } from '#/providers/LoggerProvider'
import { useText } from '#/providers/TextProvider'
import { twMerge } from '#/utilities/tailwindMerge'
import {
ChatMessageDataType,
type ChatClientMessageData,
Expand All @@ -36,8 +37,7 @@ import {
type ReactionSymbol,
type ThreadData,
type ThreadId,
} from '#/services/Chat'
import { twMerge } from '#/utilities/tailwindMerge'
} from '@common/services/Chat'

/** Create a {@link ChatMessageId}. */
const MessageId = newtypeConstructor<ChatMessageId>()
Expand Down
2 changes: 1 addition & 1 deletion app/gui/src/dashboard/layouts/Drive/assetTreeHooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import type { Category } from '#/layouts/CategorySwitcher/Category'
import { useFullUserSession } from '#/providers/AuthProvider'
import { useBackend } from '#/providers/BackendProvider'
import { useFeatureFlag } from '#/providers/FeatureFlagsProvider'
import { ROOT_PARENT_DIRECTORY_ID } from '#/services/remoteBackendPaths'
import AssetTreeNode, { type AnyAssetTreeNode } from '#/utilities/AssetTreeNode'
import { ROOT_PARENT_DIRECTORY_ID } from '@common/services/remoteBackendPaths'

/** Return type of the query function for the `listDirectory` query. */
export type DirectoryQuery = readonly AnyAsset[] | undefined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import { PermissionAction } from '@common/utilities/permissions'

import type { SortableColumn } from '#/components/dashboard/column/columnUtils'
import { Column } from '#/components/dashboard/column/columnUtils'
import type { DirectoryId } from '#/services/ProjectManager'
import type AssetQuery from '#/utilities/AssetQuery'
import type { AnyAssetTreeNode } from '#/utilities/AssetTreeNode'
import Visibility from '#/utilities/Visibility'
import { SortDirection, type SortInfo } from '#/utilities/sorting'
import { createStore, useStore } from '#/utilities/zustand'
import type { DirectoryId } from '@common/services/ProjectManager'
import invariant from 'tiny-invariant'

/** Options for {@link useAssetsTableItems}. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import InviteUsersModal from '#/modals/InviteUsersModal'
import { useFullUserSession } from '#/providers/AuthProvider'
import { useRemoteBackend } from '#/providers/BackendProvider'
import { useText } from '#/providers/TextProvider'
import type RemoteBackend from '#/services/RemoteBackend'
import type RemoteBackend from '@common/services/RemoteBackend'

const LIST_USERS_STALE_TIME_MS = 60_000

Expand Down
4 changes: 2 additions & 2 deletions app/gui/src/dashboard/layouts/Settings/data.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ import type { PaywallFeatureName } from '#/hooks/billing'
import type { ToastAndLogCallback } from '#/hooks/toastAndLogHooks'
import { passwordWithPatternSchema } from '#/pages/authentication/schemas'
import type { GetText } from '#/providers/TextProvider'
import type LocalBackend from '#/services/LocalBackend'
import type RemoteBackend from '#/services/RemoteBackend'
import { PASSWORD_REGEX } from '#/utilities/validation'
import type LocalBackend from '@common/services/LocalBackend'
import type RemoteBackend from '@common/services/RemoteBackend'
import ActivityLogSettingsSection from './ActivityLogSettingsSection'
import DeleteUserAccountSettingsSection from './DeleteUserAccountSettingsSection'
import KeyboardShortcutsSettingsSection from './KeyboardShortcutsSettingsSection'
Expand Down
2 changes: 1 addition & 1 deletion app/gui/src/dashboard/layouts/Settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { useAuth, useFullUserSession } from '#/providers/AuthProvider'
import { useLocalBackend, useRemoteBackend } from '#/providers/BackendProvider'
import { useLocalStorageState } from '#/providers/LocalStorageProvider'
import { useText } from '#/providers/TextProvider'
import { Path } from '#/services/ProjectManager'
import { Path } from '@common/services/ProjectManager'
import {
ALL_SETTINGS_TABS,
SETTINGS_DATA,
Expand Down
4 changes: 2 additions & 2 deletions app/gui/src/dashboard/pages/dashboard/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ import ProjectsProvider, {
useSetPage,
type LaunchedProject,
} from '#/providers/ProjectsProvider'
import { newDirectoryId, newProjectId } from '#/services/LocalBackend'
import { UUID } from '#/services/ProjectManager'
import { tryFindSelfPermission } from '#/utilities/permissions'
import { STATIC_QUERY_OPTIONS } from '#/utilities/reactQuery'
import { document } from '#/utilities/sanitizedEventTargets'
import { newDirectoryId, newProjectId } from '@common/services/LocalBackend'
import { UUID } from '@common/services/ProjectManager'
import { DashboardTabBar } from './DashboardTabBar'
import { DashboardTabPanels } from './DashboardTabPanels'

Expand Down
2 changes: 1 addition & 1 deletion app/gui/src/dashboard/providers/AuthProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import { useText } from '#/providers/TextProvider'
import { Dialog } from '#/components/AriaComponents'
import { Result } from '#/components/Result'

import type RemoteBackend from '#/services/RemoteBackend'
import type RemoteBackend from '@common/services/RemoteBackend'

import {
CognitoErrorType,
Expand Down
6 changes: 3 additions & 3 deletions app/gui/src/dashboard/providers/BackendProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import * as common from 'enso-common'
import { type Category, isCloudCategory } from '#/layouts/CategorySwitcher/Category'

import { useEventCallback } from '#/hooks/eventCallbackHooks'
import type LocalBackend from '#/services/LocalBackend'
import { ProjectManagerEvents } from '#/services/ProjectManager'
import type RemoteBackend from '#/services/RemoteBackend'
import type LocalBackend from '@common/services/LocalBackend'
import { ProjectManagerEvents } from '@common/services/ProjectManager'
import type RemoteBackend from '@common/services/RemoteBackend'

/** State contained in a `BackendContext`. */
export interface BackendContextType {
Expand Down
2 changes: 1 addition & 1 deletion app/gui/tsconfig.node.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"src/dashboard/hooks/eventCallbackHooks.ts",
"src/dashboard/modules/payments/constants.ts",
"src/dashboard/services/Backend.ts",
"src/dashboard/services/RemoteBackend.ts",
"src/common/services/RemoteBackend.ts",
"src/dashboard/utilities/**/*",
"node.env.d.ts"
],
Expand Down

0 comments on commit ffa9c77

Please sign in to comment.