diff --git a/app/gui/src/dashboard/services/Chat.ts b/app/gui/src/common/services/Chat.ts similarity index 100% rename from app/gui/src/dashboard/services/Chat.ts rename to app/gui/src/common/services/Chat.ts diff --git a/app/gui/src/dashboard/services/LocalBackend.ts b/app/gui/src/common/services/LocalBackend.ts similarity index 99% rename from app/gui/src/dashboard/services/LocalBackend.ts rename to app/gui/src/common/services/LocalBackend.ts index 4b8e6a430b46b..1648afa1fd964 100644 --- a/app/gui/src/dashboard/services/LocalBackend.ts +++ b/app/gui/src/common/services/LocalBackend.ts @@ -58,7 +58,8 @@ 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, @@ -66,8 +67,7 @@ import { 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) { diff --git a/app/gui/src/dashboard/services/ProjectManager.ts b/app/gui/src/common/services/ProjectManager.ts similarity index 100% rename from app/gui/src/dashboard/services/ProjectManager.ts rename to app/gui/src/common/services/ProjectManager.ts diff --git a/app/gui/src/dashboard/services/RemoteBackend.ts b/app/gui/src/common/services/RemoteBackend.ts similarity index 99% rename from app/gui/src/dashboard/services/RemoteBackend.ts rename to app/gui/src/common/services/RemoteBackend.ts index 1a177c727fd4e..7f6b6d6115e98 100644 --- a/app/gui/src/dashboard/services/RemoteBackend.ts +++ b/app/gui/src/common/services/RemoteBackend.ts @@ -155,7 +155,7 @@ import { updateAssetPath, updateDirectoryPath, updateSecretPath, -} from '#/services/remoteBackendPaths' +} from '@common/services/remoteBackendPaths' import type HttpClient from '#/utilities/HttpClient' diff --git a/app/gui/src/dashboard/services/remoteBackendPaths.ts b/app/gui/src/common/services/remoteBackendPaths.ts similarity index 98% rename from app/gui/src/dashboard/services/remoteBackendPaths.ts rename to app/gui/src/common/services/remoteBackendPaths.ts index 4954fe40b02ad..075e009f2e00f 100644 --- a/app/gui/src/dashboard/services/remoteBackendPaths.ts +++ b/app/gui/src/common/services/remoteBackendPaths.ts @@ -1,4 +1,5 @@ /** @file Paths used by the `RemoteBackend`. */ +import { newtypeConstructor, type Newtype } from '../utilities/data/newtype' import type { AssetId, CheckoutSessionId, @@ -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' @@ -203,7 +203,6 @@ export function getCheckoutSessionPath(checkoutSessionId: CheckoutSessionId) { /** Unique identifier for a directory. */ type DirectoryId = Newtype -// eslint-disable-next-line @typescript-eslint/no-redeclare const DirectoryId = newtypeConstructor() export const ROOT_PARENT_DIRECTORY_ID = DirectoryId('') /** The ID of the directory containing the home directories of all users. */ diff --git a/app/gui/src/dashboard/App.tsx b/app/gui/src/dashboard/App.tsx index c038bb11c0bdb..4a565d2d97e05 100644 --- a/app/gui/src/dashboard/App.tsx +++ b/app/gui/src/dashboard/App.tsx @@ -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' { /** */ diff --git a/app/gui/src/dashboard/components/dashboard/AssetRow.tsx b/app/gui/src/dashboard/components/dashboard/AssetRow.tsx index 2884b0416e346..41580e868e019 100644 --- a/app/gui/src/dashboard/components/dashboard/AssetRow.tsx +++ b/app/gui/src/dashboard/components/dashboard/AssetRow.tsx @@ -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' diff --git a/app/gui/src/dashboard/hooks/backendHooks.tsx b/app/gui/src/dashboard/hooks/backendHooks.tsx index 1cae7358d2fec..b7dd0d94db5aa 100644 --- a/app/gui/src/dashboard/hooks/backendHooks.tsx +++ b/app/gui/src/dashboard/hooks/backendHooks.tsx @@ -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 diff --git a/app/gui/src/dashboard/layouts/AssetContextMenu.tsx b/app/gui/src/dashboard/layouts/AssetContextMenu.tsx index 0a3d9f2378e4a..998cda6d22f27 100644 --- a/app/gui/src/dashboard/layouts/AssetContextMenu.tsx +++ b/app/gui/src/dashboard/layouts/AssetContextMenu.tsx @@ -46,8 +46,6 @@ 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, @@ -55,6 +53,8 @@ import { 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}. */ diff --git a/app/gui/src/dashboard/layouts/AssetProperties.tsx b/app/gui/src/dashboard/layouts/AssetProperties.tsx index 178df8f1a4797..98509d42d6471 100644 --- a/app/gui/src/dashboard/layouts/AssetProperties.tsx +++ b/app/gui/src/dashboard/layouts/AssetProperties.tsx @@ -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: '', diff --git a/app/gui/src/dashboard/layouts/AssetsTable.tsx b/app/gui/src/dashboard/layouts/AssetsTable.tsx index c0944f934ba5b..e079015d659aa 100644 --- a/app/gui/src/dashboard/layouts/AssetsTable.tsx +++ b/app/gui/src/dashboard/layouts/AssetsTable.tsx @@ -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' @@ -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' { /** */ diff --git a/app/gui/src/dashboard/layouts/CategorySwitcher.tsx b/app/gui/src/dashboard/layouts/CategorySwitcher.tsx index e818a0ed7cff9..19a88a12dcb8f 100644 --- a/app/gui/src/dashboard/layouts/CategorySwitcher.tsx +++ b/app/gui/src/dashboard/layouts/CategorySwitcher.tsx @@ -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 === diff --git a/app/gui/src/dashboard/layouts/CategorySwitcher/Category.ts b/app/gui/src/dashboard/layouts/CategorySwitcher/Category.ts index 67f60b59c8324..7270700dbb115 100644 --- a/app/gui/src/dashboard/layouts/CategorySwitcher/Category.ts +++ b/app/gui/src/dashboard/layouts/CategorySwitcher/Category.ts @@ -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) diff --git a/app/gui/src/dashboard/layouts/Chat.tsx b/app/gui/src/dashboard/layouts/Chat.tsx index 2d20bec8d9735..5925724ad925d 100644 --- a/app/gui/src/dashboard/layouts/Chat.tsx +++ b/app/gui/src/dashboard/layouts/Chat.tsx @@ -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, @@ -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() diff --git a/app/gui/src/dashboard/layouts/Drive/assetTreeHooks.tsx b/app/gui/src/dashboard/layouts/Drive/assetTreeHooks.tsx index ea9e95df86fce..e08c12d6c738c 100644 --- a/app/gui/src/dashboard/layouts/Drive/assetTreeHooks.tsx +++ b/app/gui/src/dashboard/layouts/Drive/assetTreeHooks.tsx @@ -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 diff --git a/app/gui/src/dashboard/layouts/Drive/assetsTableItemsHooks.tsx b/app/gui/src/dashboard/layouts/Drive/assetsTableItemsHooks.tsx index 4ad88177f48c3..e8b220033e37c 100644 --- a/app/gui/src/dashboard/layouts/Drive/assetsTableItemsHooks.tsx +++ b/app/gui/src/dashboard/layouts/Drive/assetsTableItemsHooks.tsx @@ -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}. */ diff --git a/app/gui/src/dashboard/layouts/Settings/MembersSettingsSection.tsx b/app/gui/src/dashboard/layouts/Settings/MembersSettingsSection.tsx index 82adb3eca223d..e43356b592b93 100644 --- a/app/gui/src/dashboard/layouts/Settings/MembersSettingsSection.tsx +++ b/app/gui/src/dashboard/layouts/Settings/MembersSettingsSection.tsx @@ -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 diff --git a/app/gui/src/dashboard/layouts/Settings/data.tsx b/app/gui/src/dashboard/layouts/Settings/data.tsx index 276d33a705a8a..69d66dd60d131 100644 --- a/app/gui/src/dashboard/layouts/Settings/data.tsx +++ b/app/gui/src/dashboard/layouts/Settings/data.tsx @@ -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' diff --git a/app/gui/src/dashboard/layouts/Settings/index.tsx b/app/gui/src/dashboard/layouts/Settings/index.tsx index 43a758b0ae874..f6d1e92a2e74a 100644 --- a/app/gui/src/dashboard/layouts/Settings/index.tsx +++ b/app/gui/src/dashboard/layouts/Settings/index.tsx @@ -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, diff --git a/app/gui/src/dashboard/pages/dashboard/Dashboard.tsx b/app/gui/src/dashboard/pages/dashboard/Dashboard.tsx index 114fc7185d9c0..36725645ecf4b 100644 --- a/app/gui/src/dashboard/pages/dashboard/Dashboard.tsx +++ b/app/gui/src/dashboard/pages/dashboard/Dashboard.tsx @@ -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' diff --git a/app/gui/src/dashboard/providers/AuthProvider.tsx b/app/gui/src/dashboard/providers/AuthProvider.tsx index 893cb80ae6d49..da1aae441415f 100644 --- a/app/gui/src/dashboard/providers/AuthProvider.tsx +++ b/app/gui/src/dashboard/providers/AuthProvider.tsx @@ -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, diff --git a/app/gui/src/dashboard/providers/BackendProvider.tsx b/app/gui/src/dashboard/providers/BackendProvider.tsx index 275385ada4b0e..87c2d81a989e0 100644 --- a/app/gui/src/dashboard/providers/BackendProvider.tsx +++ b/app/gui/src/dashboard/providers/BackendProvider.tsx @@ -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 { diff --git a/app/gui/tsconfig.node.json b/app/gui/tsconfig.node.json index 05f19dbcefd03..1173db268c7a6 100644 --- a/app/gui/tsconfig.node.json +++ b/app/gui/tsconfig.node.json @@ -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" ],