Flatten the front end api folder

This commit is contained in:
Mattias Granlund 2023-11-01 13:43:48 +01:00
parent 2f4e26475e
commit f2e609e791
58 changed files with 64 additions and 65 deletions

View File

@ -1 +0,0 @@
export type { User, LoginToken, Project } from './api';

View File

@ -1,6 +1,6 @@
import { invoke } from '$lib/ipc';
import { asyncWritable, type WritableLoadable } from '@square/svelte-store';
import { subscribeToSessions } from '../ipc/sessions';
import { subscribeToSessions } from './sessions';
type Diffs = Partial<Record<string, string>>;

View File

@ -1,4 +1,4 @@
import type { User } from '../cloud/api';
import type { User } from './cloud';
import { invoke } from '$lib/ipc';
export async function get() {

View File

@ -1,5 +1,5 @@
<script lang="ts">
import { isInsert, type Delta, isDelete } from '$lib/api/ipc/deltas';
import { isInsert, type Delta, isDelete } from '$lib/api/deltas';
import Differ from './Differ';
import { line } from '$lib/diff';

View File

@ -1,5 +1,5 @@
<script lang="ts">
import { getCloudApiClient, type LoginToken } from '$lib/api/cloud/api';
import { getCloudApiClient, type LoginToken } from '$lib/api/cloud';
import * as toasts from '$lib/toasts';
import { userStore } from '$lib/stores/user';
import { derived, writable } from '@square/svelte-store';

View File

@ -1,6 +1,6 @@
import posthog from 'posthog-js';
import { PUBLIC_POSTHOG_API_KEY } from '$env/static/public';
import type { User } from './api/cloud/api';
import type { User } from './api/cloud';
import { getVersion, getName } from '@tauri-apps/api/app';
interface PostHogClient {

View File

@ -1,5 +1,5 @@
import { setUser } from '@sentry/sveltekit';
import type { User } from './api/cloud/api';
import type { User } from './api/cloud';
export default () => {
return {

View File

@ -1,4 +1,4 @@
import * as bookmarks from '$lib/api/ipc/bookmarks';
import * as bookmarks from '$lib/api/bookmarks';
import { type Loadable, asyncWritable, asyncDerived } from '@square/svelte-store';
export function getBookmarksStore(params: { projectId: string }): Loadable<bookmarks.Bookmark[]> {

View File

@ -1,5 +1,5 @@
import { asyncWritable, isReloadable, type AsyncWritable, type Stores } from '@square/svelte-store';
import { subscribeToDeltas, type Delta, listDeltas } from '$lib/api/ipc/deltas';
import { subscribeToDeltas, type Delta, listDeltas } from '$lib/api/deltas';
/**
* We have a special situation here where we use deltas to know when to re-run

View File

@ -1,4 +1,4 @@
import { subscribe } from '$lib/api/git/fetches';
import { subscribe } from '$lib/api/fetches';
import { writable, type Loadable } from '@square/svelte-store';
export function getFetchesStore(projectId: string): Loadable<any> {

View File

@ -1,4 +1,4 @@
import { getHead, subscribeToHead } from '$lib/api/git/heads';
import { getHead, subscribeToHead } from '$lib/api/heads';
import { asyncWritable, type Loadable } from '@square/svelte-store';
export function getHeadsStore(projectId: string): Loadable<string> {

View File

@ -1,4 +1,4 @@
import { Session, listSessions, subscribeToSessions } from '$lib/api/ipc/sessions';
import { Session, listSessions, subscribeToSessions } from '$lib/api/sessions';
import { asyncWritable, get, type Loadable, type WritableLoadable } from '@square/svelte-store';
export function getSessionStore(projectId: string): Loadable<Session[]> {

View File

@ -1,4 +1,4 @@
import * as users from '$lib/api/ipc/users';
import * as users from '$lib/api/users';
import { asyncWritable } from '@square/svelte-store';
export const userStore = asyncWritable([], users.get, async (user) => {

View File

@ -1,4 +1,4 @@
import { getCloudApiClient } from './api/cloud/api';
import { getCloudApiClient } from './api/cloud';
import lscache from 'lscache';
const cloud = getCloudApiClient();

View File

@ -8,10 +8,10 @@ import {
} from './types';
import { plainToInstance } from 'class-transformer';
import { invoke } from '$lib/ipc';
import { isDelete, isInsert, type Delta } from '$lib/api/ipc/deltas';
import type { Session } from '$lib/api/ipc/sessions';
import { isDelete, isInsert, type Delta } from '$lib/api/deltas';
import type { Session } from '$lib/api/sessions';
import { get } from 'svelte/store';
import type { FileContent } from '$lib/api/ipc/files';
import type { FileContent } from '$lib/api/files';
export function getVirtualBranchStore(
projectId: string,

View File

@ -1,6 +1,6 @@
import type { LayoutLoad } from './$types';
import { getCloudApiClient } from '$lib/api/cloud/api';
import { projectsStore } from '$lib/api/ipc/projects';
import { getCloudApiClient } from '$lib/api/cloud';
import { projectsStore } from '$lib/api/projects';
import Posthog from '$lib/posthog';
import Sentry from '$lib/sentry';
import lscache from 'lscache';

View File

@ -3,9 +3,9 @@
import { asyncDerived } from '@square/svelte-store';
import { compareDesc, formatDistanceToNow } from 'date-fns';
import { IconFolder, IconLoading } from '$lib/icons';
import type { getCloudApiClient } from '$lib/api/cloud/api';
import type { getCloudApiClient } from '$lib/api/cloud';
import { userStore } from '$lib/stores/user';
import { getProjectStore, projectsStore } from '$lib/api/ipc/projects';
import { getProjectStore, projectsStore } from '$lib/api/projects';
import * as toasts from '$lib/toasts';
import IconFolderPlus from '$lib/icons/IconFolderPlus.svelte';
import { goto } from '$app/navigation';

View File

@ -1,8 +1,8 @@
<script lang="ts">
import * as toasts from '$lib/toasts';
import * as zip from '$lib/api/ipc/zip';
import * as zip from '$lib/api/zip';
import { page } from '$app/stores';
import type { User, getCloudApiClient } from '$lib/api/cloud/api';
import type { User, getCloudApiClient } from '$lib/api/cloud';
import Modal from '$lib/components/Modal.svelte';
import Checkbox from '$lib/components/Checkbox.svelte';
import Button from '$lib/components/Button.svelte';

View File

@ -1,5 +1,5 @@
import type { PageLoadEvent } from './$types';
import { getProjectStore, type Project } from '$lib/api/ipc/projects';
import { getProjectStore, type Project } from '$lib/api/projects';
import type { Loadable } from '@square/svelte-store';
export async function load({ params }: PageLoadEvent) {

View File

@ -4,7 +4,7 @@
import type { BaseBranch, Branch } from '$lib/vbranches/types';
import { dzHighlight } from './dropZone';
import type { BranchController } from '$lib/vbranches/branchController';
import type { getCloudApiClient } from '$lib/api/cloud/api';
import type { getCloudApiClient } from '$lib/api/cloud';
import type { LoadState } from '@square/svelte-store';
import { open } from '@tauri-apps/api/shell';
import { IconFile, IconTerminal, IconExternalLink } from '$lib/icons';

View File

@ -13,7 +13,7 @@
import { quintOut } from 'svelte/easing';
import { crossfade, fade } from 'svelte/transition';
import { flip } from 'svelte/animate';
import type { getCloudApiClient } from '$lib/api/cloud/api';
import type { getCloudApiClient } from '$lib/api/cloud';
import Scrollbar from '$lib/components/Scrollbar.svelte';
import IconNewBadge from '$lib/icons/IconNewBadge.svelte';
import IconGithub from '$lib/icons/IconGithub.svelte';

View File

@ -4,7 +4,7 @@
import { invoke } from '@tauri-apps/api/tauri';
import type { BranchController } from '$lib/vbranches/branchController';
import type { Branch, File } from '$lib/vbranches/types';
import type { getCloudApiClient } from '$lib/api/cloud/api';
import type { getCloudApiClient } from '$lib/api/cloud';
import type { User } from '$lib/api/cloud';
import { IconAISparkles, IconLoading, IconTriangleDown, IconTriangleUp } from '$lib/icons';
import {

View File

@ -17,7 +17,7 @@
import Modal from '$lib/components/Modal.svelte';
import Resizer from '$lib/components/Resizer.svelte';
import IconButton from '$lib/components/IconButton.svelte';
import type { User, getCloudApiClient } from '$lib/api/cloud/api';
import type { User, getCloudApiClient } from '$lib/api/cloud';
import IconChevronRightSmall from '$lib/icons/IconChevronRightSmall.svelte';
import { slide } from 'svelte/transition';
import { computedAddedRemoved } from '$lib/vbranches/fileStatus';

View File

@ -11,7 +11,7 @@
import Resizer from '$lib/components/Resizer.svelte';
import Lane from './BranchLane.svelte';
import type { GitHubIntegrationContext } from '$lib/github/types';
import type { getCloudApiClient } from '$lib/api/cloud/api';
import type { getCloudApiClient } from '$lib/api/cloud';
import { PullRequest } from '$lib/github/types';
export let item:

View File

@ -5,8 +5,8 @@
import CloudForm from './CloudForm.svelte';
import DetailsForm from './DetailsForm.svelte';
import KeysForm from './KeysForm.svelte';
import * as projects from '$lib/api/ipc/projects';
import { projectsStore } from '$lib/api/ipc/projects';
import * as projects from '$lib/api/projects';
import { projectsStore } from '$lib/api/projects';
import type { PageData } from './$types';
import BackButton from '$lib/components/BackButton.svelte';
import Modal from '$lib/components/Modal.svelte';

View File

@ -1,5 +1,5 @@
import type { PageLoadEvent } from './$types';
import { getProjectStore, type Project } from '$lib/api/ipc/projects';
import { getProjectStore, type Project } from '$lib/api/projects';
import type { Loadable } from '@square/svelte-store';
export async function load({ params }: PageLoadEvent) {

View File

@ -1,7 +1,7 @@
<script lang="ts">
import * as toasts from '$lib/toasts';
import { getCloudApiClient } from '$lib/api/cloud/api';
import type { Project } from '$lib/api/ipc/projects';
import { getCloudApiClient } from '$lib/api/cloud';
import type { Project } from '$lib/api/projects';
import { userStore } from '$lib/stores/user';
import { createEventDispatcher, onMount } from 'svelte';
import Checkbox from '$lib/components/Checkbox.svelte';

View File

@ -1,5 +1,5 @@
<script lang="ts">
import type { Project } from '$lib/api/ipc/projects';
import type { Project } from '$lib/api/projects';
import { debounce } from '$lib/utils';
import { createEventDispatcher } from 'svelte';

View File

@ -1,5 +1,5 @@
<script lang="ts">
import type { Key, Project } from '$lib/api/ipc/projects';
import type { Key, Project } from '$lib/api/projects';
import { invoke } from '$lib/ipc';
import { copyToClipboard } from '$lib/clipboard';
import { createEventDispatcher } from 'svelte';

View File

@ -1,9 +1,9 @@
import { getHeadStore } from '$lib/api/git/heads';
import { getHeadStore } from '$lib/api/heads';
import { getSessionStore } from '$lib/stores/sessions';
import { getDiffsStore } from '$lib/api/git/diffs';
import { getDiffsStore } from '$lib/api/diffs';
import { error } from '@sveltejs/kit';
import type { LayoutLoad } from './$types';
import { getProjectStore, type Project } from '$lib/api/ipc/projects';
import { getProjectStore, type Project } from '$lib/api/projects';
export const prerender = false;

View File

@ -1,8 +1,8 @@
<script lang="ts">
import Button from '$lib/components/Button.svelte';
import { getCloudApiClient } from '$lib/api/cloud/api';
import { getCloudApiClient } from '$lib/api/cloud';
import { userStore } from '$lib/stores/user';
import type { Project } from '$lib/api/ipc/projects';
import type { Project } from '$lib/api/projects';
import { marked } from 'marked';
import { IconAISparkles } from '$lib/icons';
import { onMount } from 'svelte';

View File

@ -1,5 +1,5 @@
<script lang="ts">
import type { Delta } from '$lib/api/ipc/deltas';
import type { Delta } from '$lib/api/deltas';
import { fillBuckets, type Bucket } from './histogram';
export let deltas: Delta[];

View File

@ -1,13 +1,13 @@
<script lang="ts">
import { format, startOfDay } from 'date-fns';
import type { Delta } from '$lib/api/ipc/deltas';
import type { Delta } from '$lib/api/deltas';
import { generateBuckets } from './histogram';
import FileActivity from './FileActivity.svelte';
import { page } from '$app/stores';
import Link from '$lib/components/Link.svelte';
import { IconRewind, IconPlayerPlayFilled, IconLoading, IconSparkle } from '$lib/icons';
import { collapse } from '$lib/paths';
import type { Session } from '$lib/api/ipc/sessions';
import type { Session } from '$lib/api/sessions';
import { getDeltasStore } from '$lib/stores/deltas';
import { asyncDerived } from '@square/svelte-store';

View File

@ -1,10 +1,10 @@
<script lang="ts">
import { page } from '$app/stores';
import { getSessionStore } from '$lib/stores/sessions';
import { listDeltas } from '$lib/api/ipc/deltas';
import { listDeltas } from '$lib/api/deltas';
import { format } from 'date-fns';
import { asyncDerived, type Readable } from '@square/svelte-store';
import type { Session } from '$lib/api/ipc/sessions';
import type { Session } from '$lib/api/sessions';
const sessions = getSessionStore($page.params.projectId);

View File

@ -9,7 +9,7 @@
import SessionsList from './SessionsList.svelte';
import SessionNavigations from './SessionNavigations.svelte';
import { IconLoading } from '$lib/icons';
import * as bookmarks from '$lib/api/ipc/bookmarks';
import * as bookmarks from '$lib/api/bookmarks';
import { goto } from '$app/navigation';
export let data: LayoutData;

View File

@ -2,8 +2,8 @@ import { asyncDerived, derived, writable } from '@square/svelte-store';
import type { LayoutLoad } from './$types';
import { format } from 'date-fns';
import { page } from '$app/stores';
import { listDeltas, type Delta } from '$lib/api/ipc/deltas';
import { list } from '$lib/api/ipc/files';
import { listDeltas, type Delta } from '$lib/api/deltas';
import { list } from '$lib/api/files';
export const load: LayoutLoad = async ({ parent, params, url }) => {
const { sessions } = await parent();

View File

@ -1,6 +1,6 @@
<script lang="ts">
import * as toasts from '$lib/toasts';
import * as bookmarks from '$lib/api/ipc/bookmarks';
import * as bookmarks from '$lib/api/bookmarks';
import { IconBookmarkFilled } from '$lib/icons';
import Modal from '$lib/components/Modal.svelte';
import Button from '$lib/components/Button.svelte';

View File

@ -1,6 +1,6 @@
<script lang="ts">
import type { Session } from '$lib/api/ipc/sessions';
import { isInsert, type Delta, isDelete } from '$lib/api/ipc/deltas';
import type { Session } from '$lib/api/sessions';
import { isInsert, type Delta, isDelete } from '$lib/api/deltas';
import { page } from '$app/stores';
import { collapse } from '$lib/paths';
import { asyncDerived } from '@square/svelte-store';

View File

@ -4,8 +4,8 @@
import { page } from '$app/stores';
import * as hotkeys from '$lib/hotkeys';
import type { Session } from '$lib/api/ipc/sessions';
import type { Delta } from '$lib/api/ipc/deltas';
import type { Session } from '$lib/api/sessions';
import type { Delta } from '$lib/api/deltas';
import { unsubscribe } from '$lib/utils';
import { onMount } from 'svelte';
import { format } from 'date-fns';

View File

@ -1,6 +1,6 @@
<script lang="ts">
import type { Session } from '$lib/api/ipc/sessions';
import type { Delta } from '$lib/api/ipc/deltas';
import type { Session } from '$lib/api/sessions';
import type { Delta } from '$lib/api/deltas';
import SessionCard from './SessionCard.svelte';
export let sessions: (Session & {

View File

@ -1,6 +1,6 @@
<script lang="ts">
import type { Session } from '$lib/api/ipc/sessions';
import type { Delta } from '$lib/api/ipc/deltas';
import type { Session } from '$lib/api/sessions';
import type { Delta } from '$lib/api/deltas';
import type { Frame } from './frame';
import DeltasViewer from '$lib/components/DeltasViewer.svelte';

View File

@ -4,7 +4,7 @@
import { IconBookmark, IconBookmarkFilled } from '$lib/icons';
import { format } from 'date-fns';
import { page } from '$app/stores';
import * as bookmarks from '$lib/api/ipc/bookmarks';
import * as bookmarks from '$lib/api/bookmarks';
import { getBookmark } from '$lib/stores/bookmarks';
export let timestampMs: number;

View File

@ -1,5 +1,5 @@
<script lang="ts">
import type { Delta } from '$lib/api/ipc/deltas';
import type { Delta } from '$lib/api/deltas';
import { IconPlayerPauseFilled, IconPlayerPlayFilled } from '$lib/icons';
import DiffContext from '$lib/components/DiffContext.svelte';
import { unsubscribe } from '$lib/utils';

View File

@ -1,6 +1,6 @@
<script lang="ts">
import type { Delta } from '$lib/api/ipc/deltas';
import type { Bookmark } from '$lib/api/ipc/bookmarks';
import type { Delta } from '$lib/api/deltas';
import type { Bookmark } from '$lib/api/bookmarks';
import { ModuleChapters, ModuleMarkers, type Marker } from './slider';
import { JSR, ModuleSlider } from 'mm-jsr';
import { asyncDerived, type Loadable } from '@square/svelte-store';

View File

@ -1,4 +1,4 @@
import type { Delta } from '$lib/api/ipc/deltas';
import type { Delta } from '$lib/api/deltas';
export type Frame = {
sessionId: string;

View File

@ -1,9 +1,9 @@
<script lang="ts">
import type { PageData } from './$types';
import * as toasts from '$lib/toasts';
import { initDeviceOauth, checkAuthStatus } from '$lib/api/ipc/github';
import { initDeviceOauth, checkAuthStatus } from '$lib/api/github';
import { getAuthenticated } from '$lib/github/user';
import { deleteAllData } from '$lib/api/ipc';
import { deleteAllData } from '$lib/api/data';
import { userStore } from '$lib/stores/user';
import { goto } from '$app/navigation';
import ThemeSelector from './ThemeSelector.svelte';