diff --git a/actions/createNewLeafletFromTemplate.ts b/actions/createNewLeafletFromTemplate.ts index 958bb6ed..d237d87c 100644 --- a/actions/createNewLeafletFromTemplate.ts +++ b/actions/createNewLeafletFromTemplate.ts @@ -4,8 +4,8 @@ import { createServerClient } from "@supabase/ssr"; import { drizzle } from "drizzle-orm/postgres-js"; import { NextRequest } from "next/server"; import postgres from "postgres"; -import { Fact } from "src/replicache"; -import { Attributes } from "src/replicache/attributes"; +import type { Fact } from "src/replicache"; +import type { Attribute } from "src/replicache/attributes"; import { Database } from "supabase/database.types"; import { v7 } from "uuid"; @@ -41,7 +41,7 @@ export async function createNewLeafletFromTemplate( let { data } = await supabase.rpc("get_facts", { root: rootEntity, }); - let initialFacts = (data as unknown as Fact[]) || []; + let initialFacts = (data as unknown as Fact[]) || []; let oldEntityIDToNewID = {} as { [k: string]: string }; let oldEntities = initialFacts.reduce((acc, f) => { diff --git a/actions/publishToPublication.ts b/actions/publishToPublication.ts index c42cac23..35d7a9f4 100644 --- a/actions/publishToPublication.ts +++ b/actions/publishToPublication.ts @@ -15,8 +15,8 @@ import { Block } from "components/Blocks/Block"; import { TID } from "@atproto/common"; import { supabaseServerClient } from "supabase/serverClient"; import { scanIndex, scanIndexLocal } from "src/replicache/utils"; -import { Fact } from "src/replicache"; -import { Attributes } from "src/replicache/attributes"; +import type { Fact } from "src/replicache"; +import type { Attribute } from "src/replicache/attributes"; import { YJSFragmentToString } from "components/Blocks/TextBlock/RenderYJSFragment"; import { ids } from "lexicons/api/lexicons"; import { OmitKey } from "lexicons/api/util"; @@ -59,9 +59,7 @@ export async function publishToPublication({ root: root_entity, }); - let scan = scanIndexLocal( - (data as unknown as Fact[]) || [], - ); + let scan = scanIndexLocal((data as unknown as Fact[]) || []); let images = blocks .filter((b) => b.type === "image") .map((b) => scan.eav(b.value, "block/image")[0]); diff --git a/actions/subscriptions/confirmEmailSubscription.ts b/actions/subscriptions/confirmEmailSubscription.ts index 476b4428..0d54cba9 100644 --- a/actions/subscriptions/confirmEmailSubscription.ts +++ b/actions/subscriptions/confirmEmailSubscription.ts @@ -1,7 +1,6 @@ "use server"; import { createClient } from "@supabase/supabase-js"; -import { createIdentity } from "actions/createIdentity"; import { and, eq, sql } from "drizzle-orm"; import { drizzle } from "drizzle-orm/postgres-js"; import { @@ -10,8 +9,7 @@ import { permission_tokens, } from "drizzle/schema"; import postgres from "postgres"; -import { Fact, PermissionToken } from "src/replicache"; -import { serverMutationContext } from "src/replicache/serverMutationContext"; +import type { Fact } from "src/replicache"; import { Database } from "supabase/database.types"; import { v7 } from "uuid"; diff --git a/actions/subscriptions/deleteSubscription.ts b/actions/subscriptions/deleteSubscription.ts index 44cc8d46..8350434c 100644 --- a/actions/subscriptions/deleteSubscription.ts +++ b/actions/subscriptions/deleteSubscription.ts @@ -4,7 +4,7 @@ import { drizzle } from "drizzle-orm/postgres-js"; import { email_subscriptions_to_entity, facts } from "drizzle/schema"; import postgres from "postgres"; import { eq, and, sql } from "drizzle-orm"; -import { Fact } from "src/replicache"; +import type { Fact } from "src/replicache"; import { v7 } from "uuid"; export async function deleteSubscription(subscriptionID: string) { diff --git a/actions/subscriptions/sendPostToSubscribers.ts b/actions/subscriptions/sendPostToSubscribers.ts index d51e5d75..8aeeee76 100644 --- a/actions/subscriptions/sendPostToSubscribers.ts +++ b/actions/subscriptions/sendPostToSubscribers.ts @@ -6,7 +6,7 @@ import { and, eq } from "drizzle-orm"; import { drizzle } from "drizzle-orm/postgres-js"; import { email_subscriptions_to_entity, entities } from "drizzle/schema"; import postgres from "postgres"; -import { PermissionToken } from "src/replicache"; +import type { PermissionToken } from "src/replicache"; import { Database } from "supabase/database.types"; let supabase = createServerClient( diff --git a/actions/subscriptions/subscribeToMailboxWithEmail.ts b/actions/subscriptions/subscribeToMailboxWithEmail.ts index 8c21f8c6..6710b26c 100644 --- a/actions/subscriptions/subscribeToMailboxWithEmail.ts +++ b/actions/subscriptions/subscribeToMailboxWithEmail.ts @@ -7,8 +7,8 @@ import { drizzle } from "drizzle-orm/postgres-js"; import { email_subscriptions_to_entity } from "drizzle/schema"; import postgres from "postgres"; import { getBlocksWithTypeLocal } from "src/hooks/queries/useBlocks"; -import { Fact, PermissionToken } from "src/replicache"; -import { Attributes } from "src/replicache/attributes"; +import type { Fact, PermissionToken } from "src/replicache"; +import type { Attribute } from "src/replicache/attributes"; import { Database } from "supabase/database.types"; import * as Y from "yjs"; import { YJSFragmentToString } from "components/Blocks/TextBlock/RenderYJSFragment"; @@ -90,7 +90,7 @@ async function getPageTitle(root_entity: string) { let { data } = await supabase.rpc("get_facts", { root: root_entity, }); - let initialFacts = (data as unknown as Fact[]) || []; + let initialFacts = (data as unknown as Fact[]) || []; let firstPage = initialFacts.find((f) => f.attribute === "root/page") as | Fact<"root/page"> | undefined; diff --git a/app/[leaflet_id]/Leaflet.tsx b/app/[leaflet_id]/Leaflet.tsx index 35ad2ec1..b4776e0a 100644 --- a/app/[leaflet_id]/Leaflet.tsx +++ b/app/[leaflet_id]/Leaflet.tsx @@ -1,6 +1,6 @@ "use client"; import { Fact, PermissionToken, ReplicacheProvider } from "src/replicache"; -import { Attributes } from "src/replicache/attributes"; +import type { Attribute } from "src/replicache/attributes"; import { SelectionManager } from "components/SelectionManager"; import { Pages } from "components/Pages"; import { @@ -16,7 +16,7 @@ import { LeafletSidebar } from "./Sidebar"; export function Leaflet(props: { token: PermissionToken; - initialFacts: Fact[]; + initialFacts: Fact[]; leaflet_id: string; }) { return ( diff --git a/app/[leaflet_id]/icon.tsx b/app/[leaflet_id]/icon.tsx index 9df3b9a2..fb597e5c 100644 --- a/app/[leaflet_id]/icon.tsx +++ b/app/[leaflet_id]/icon.tsx @@ -1,6 +1,6 @@ import { ImageResponse } from "next/og"; -import { Fact } from "src/replicache"; -import { Attributes } from "src/replicache/attributes"; +import type { Fact } from "src/replicache"; +import type { Attribute } from "src/replicache/attributes"; import { Database } from "../../supabase/database.types"; import { createServerClient } from "@supabase/ssr"; import { parseHSBToRGB } from "src/utils/parseHSB"; @@ -36,8 +36,7 @@ export default async function Icon(props: { params: { leaflet_id: string } }) { let { data } = await supabase.rpc("get_facts", { root: rootEntity, }); - let initialFacts = - (data as unknown as Fact[]) || []; + let initialFacts = (data as unknown as Fact[]) || []; let themePageBG = initialFacts.find( (f) => f.attribute === "theme/card-background", ) as Fact<"theme/card-background"> | undefined; diff --git a/app/[leaflet_id]/page.tsx b/app/[leaflet_id]/page.tsx index 85f81a9f..f985b6df 100644 --- a/app/[leaflet_id]/page.tsx +++ b/app/[leaflet_id]/page.tsx @@ -2,8 +2,8 @@ import { Metadata } from "next"; import * as Y from "yjs"; import * as base64 from "base64-js"; -import { Fact } from "src/replicache"; -import { Attributes } from "src/replicache/attributes"; +import type { Fact } from "src/replicache"; +import type { Attribute } from "src/replicache/attributes"; import { YJSFragmentToString } from "components/Blocks/TextBlock/RenderYJSFragment"; import { Leaflet } from "./Leaflet"; import { scanIndexLocal } from "src/replicache/utils"; @@ -53,7 +53,7 @@ export default async function LeafletPage(props: Props) { getRSVPData(res.data.permission_token_rights.map((ptr) => ptr.entity_set)), getPollData(res.data.permission_token_rights.map((ptr) => ptr.entity_set)), ]); - let initialFacts = (data as unknown as Fact[]) || []; + let initialFacts = (data as unknown as Fact[]) || []; return ( { let { data } = await supabaseServerClient.rpc("get_facts", { root: rootEntity, }); - let initialFacts = (data as unknown as Fact[]) || []; + let initialFacts = (data as unknown as Fact[]) || []; let scan = scanIndexLocal(initialFacts); let firstPage = scan.eav(rootEntity, "root/page")[0]?.data.value || rootEntity; diff --git a/app/api/rpc/[command]/getFactsFromHomeLeaflets.ts b/app/api/rpc/[command]/getFactsFromHomeLeaflets.ts index 4652d450..5b770698 100644 --- a/app/api/rpc/[command]/getFactsFromHomeLeaflets.ts +++ b/app/api/rpc/[command]/getFactsFromHomeLeaflets.ts @@ -1,6 +1,6 @@ import { z } from "zod"; -import { Fact } from "src/replicache"; -import { Attributes } from "src/replicache/attributes"; +import type { Fact } from "src/replicache"; +import type { Attribute } from "src/replicache/attributes"; import { makeRoute } from "../lib"; import { Env } from "./route"; @@ -20,12 +20,10 @@ export const getFactsFromHomeLeaflets = makeRoute({ result: all_facts.data.reduce( (acc, fact) => { if (!acc[fact.root_id]) acc[fact.root_id] = []; - acc[fact.root_id].push( - fact as unknown as Fact, - ); + acc[fact.root_id].push(fact as unknown as Fact); return acc; }, - {} as { [key: string]: Fact[] }, + {} as { [key: string]: Fact[] }, ), }; } diff --git a/app/api/rpc/[command]/pull.ts b/app/api/rpc/[command]/pull.ts index 409f2e5f..769de7e0 100644 --- a/app/api/rpc/[command]/pull.ts +++ b/app/api/rpc/[command]/pull.ts @@ -4,9 +4,9 @@ import { PullResponseV1, VersionNotSupportedResponse, } from "replicache"; -import { Fact } from "src/replicache"; +import type { Fact } from "src/replicache"; import { FactWithIndexes } from "src/replicache/utils"; -import { Attributes } from "src/replicache/attributes"; +import type { Attributes } from "src/replicache/attributes"; import { makeRoute } from "../lib"; import { Env } from "./route"; @@ -95,9 +95,7 @@ export const pull = makeRoute({ return { op: "put", key: f.id, - value: FactWithIndexes( - f as unknown as Fact, - ), + value: FactWithIndexes(f as unknown as Fact), } as const; }), ], diff --git a/app/home/LeafletList.tsx b/app/home/LeafletList.tsx index cc3ccf1e..eaa6d822 100644 --- a/app/home/LeafletList.tsx +++ b/app/home/LeafletList.tsx @@ -6,13 +6,13 @@ import useSWR from "swr"; import { Fact, ReplicacheProvider } from "src/replicache"; import { LeafletPreview } from "./LeafletPreview"; import { useIdentityData } from "components/IdentityProvider"; -import { Attributes } from "src/replicache/attributes"; +import type { Attribute } from "src/replicache/attributes"; import { getIdentityData } from "actions/getIdentityData"; import { callRPC } from "app/api/rpc/client"; export function LeafletList(props: { initialFacts: { - [root_entity: string]: Fact[]; + [root_entity: string]: Fact[]; }; }) { let { data: localLeaflets } = useSWR("leaflets", () => getHomeDocs(), { diff --git a/app/home/LeafletOptions.tsx b/app/home/LeafletOptions.tsx index a14fb025..b73fc72f 100644 --- a/app/home/LeafletOptions.tsx +++ b/app/home/LeafletOptions.tsx @@ -1,7 +1,7 @@ "use client"; import { Menu, MenuItem } from "components/Layout"; -import { PermissionToken } from "src/replicache"; +import type { PermissionToken } from "src/replicache"; import { hideDoc } from "./storage"; import { useState } from "react"; import { ButtonPrimary } from "components/Buttons"; diff --git a/app/home/icon.tsx b/app/home/icon.tsx index c2ca2501..1ad8e4d7 100644 --- a/app/home/icon.tsx +++ b/app/home/icon.tsx @@ -1,6 +1,6 @@ import { ImageResponse } from "next/og"; -import { Fact } from "src/replicache"; -import { Attributes } from "src/replicache/attributes"; +import type { Fact } from "src/replicache"; +import type { Attribute } from "src/replicache/attributes"; import { Database } from "../../supabase/database.types"; import { createServerClient } from "@supabase/ssr"; import { parseHSBToRGB } from "src/utils/parseHSB"; @@ -49,8 +49,7 @@ export default async function Icon() { let { data } = await supabase.rpc("get_facts", { root: rootEntity, }); - let initialFacts = - (data as unknown as Fact[]) || []; + let initialFacts = (data as unknown as Fact[]) || []; let themePageBG = initialFacts.find( (f) => f.attribute === "theme/card-background", ) as Fact<"theme/card-background"> | undefined; @@ -67,7 +66,7 @@ export default async function Icon() { return new ImageResponse( ( // ImageResponse JSX element - (
+
-
) +
), // ImageResponse options { diff --git a/app/home/page.tsx b/app/home/page.tsx index 485d0238..4eeeda5d 100644 --- a/app/home/page.tsx +++ b/app/home/page.tsx @@ -1,6 +1,6 @@ import { cookies } from "next/headers"; import { Fact, ReplicacheProvider } from "src/replicache"; -import { Attributes } from "src/replicache/attributes"; +import type { Attribute } from "src/replicache/attributes"; import { ThemeBackgroundProvider, ThemeProvider, @@ -76,7 +76,7 @@ export default async function Home() { : undefined, ]); let initialFacts = - (homeLeafletFacts.data as unknown as Fact[]) || []; + (homeLeafletFacts.data as unknown as Fact[]) || []; let root_entity = permission_token.root_entity; let home_docs_initialFacts = allLeafletFacts?.result || {}; diff --git a/app/home/storage.ts b/app/home/storage.ts index e6e5d861..32020a98 100644 --- a/app/home/storage.ts +++ b/app/home/storage.ts @@ -1,4 +1,4 @@ -import { PermissionToken } from "src/replicache"; +import type { PermissionToken } from "src/replicache"; import { mutate } from "swr"; export type HomeDoc = { diff --git a/app/lish/[handle]/[publication]/DraftList.tsx b/app/lish/[handle]/[publication]/DraftList.tsx index 24af4171..54cf5e0b 100644 --- a/app/lish/[handle]/[publication]/DraftList.tsx +++ b/app/lish/[handle]/[publication]/DraftList.tsx @@ -1,6 +1,5 @@ "use client"; -import { Fact, ReplicacheProvider } from "src/replicache"; import { usePublicationRelationship } from "./usePublicationRelationship"; import { usePublicationContext } from "components/Providers/PublicationContext"; import Link from "next/link"; diff --git a/app/templates/icon.tsx b/app/templates/icon.tsx index 472c29a6..e9f2c3f4 100644 --- a/app/templates/icon.tsx +++ b/app/templates/icon.tsx @@ -2,8 +2,8 @@ // we could make it different so it's clear it's not your personal colors? import { ImageResponse } from "next/og"; -import { Fact } from "src/replicache"; -import { Attributes } from "src/replicache/attributes"; +import type { Fact } from "src/replicache"; +import type { Attribute } from "src/replicache/attributes"; import { Database } from "../../supabase/database.types"; import { createServerClient } from "@supabase/ssr"; import { parseHSBToRGB } from "src/utils/parseHSB"; @@ -52,8 +52,7 @@ export default async function Icon() { let { data } = await supabase.rpc("get_facts", { root: rootEntity, }); - let initialFacts = - (data as unknown as Fact[]) || []; + let initialFacts = (data as unknown as Fact[]) || []; let themePageBG = initialFacts.find( (f) => f.attribute === "theme/card-background", ) as Fact<"theme/card-background"> | undefined; @@ -70,7 +69,7 @@ export default async function Icon() { return new ImageResponse( ( // ImageResponse JSX element - (
+
-
) +
), // ImageResponse options { diff --git a/components/Blocks/BlockCommands.tsx b/components/Blocks/BlockCommands.tsx index efb3a2b1..08d75b26 100644 --- a/components/Blocks/BlockCommands.tsx +++ b/components/Blocks/BlockCommands.tsx @@ -1,4 +1,4 @@ -import { Fact, ReplicacheMutators } from "src/replicache"; +import type { Fact, ReplicacheMutators } from "src/replicache"; import { useUIState } from "src/useUIState"; import { generateKeyBetween } from "fractional-indexing"; diff --git a/components/Blocks/TextBlock/inputRules.ts b/components/Blocks/TextBlock/inputRules.ts index 8862ce59..c8956db1 100644 --- a/components/Blocks/TextBlock/inputRules.ts +++ b/components/Blocks/TextBlock/inputRules.ts @@ -5,7 +5,7 @@ import { } from "prosemirror-inputrules"; import { MutableRefObject } from "react"; import { Replicache } from "replicache"; -import { ReplicacheMutators } from "src/replicache"; +import type { ReplicacheMutators } from "src/replicache"; import { BlockProps } from "../Block"; import { focusBlock } from "src/utils/focusBlock"; import { schema } from "./schema"; diff --git a/components/Blocks/TextBlock/keymap.ts b/components/Blocks/TextBlock/keymap.ts index 1a886827..874ed665 100644 --- a/components/Blocks/TextBlock/keymap.ts +++ b/components/Blocks/TextBlock/keymap.ts @@ -12,7 +12,7 @@ import { } from "prosemirror-state"; import { RefObject } from "react"; import { Replicache } from "replicache"; -import { ReplicacheMutators } from "src/replicache"; +import type { ReplicacheMutators } from "src/replicache"; import { elementId } from "src/utils/elementId"; import { schema } from "./schema"; import { useUIState } from "src/useUIState"; diff --git a/components/Blocks/TextBlock/useHandlePaste.ts b/components/Blocks/TextBlock/useHandlePaste.ts index dab38357..7c9ce4f2 100644 --- a/components/Blocks/TextBlock/useHandlePaste.ts +++ b/components/Blocks/TextBlock/useHandlePaste.ts @@ -14,7 +14,7 @@ import { Replicache } from "replicache"; import { markdownToHtml } from "src/htmlMarkdownParsers"; import { betterIsUrl, isUrl } from "src/utils/isURL"; import { TextSelection } from "prosemirror-state"; -import { FilterAttributes } from "src/replicache/attributes"; +import type { FilterAttributes } from "src/replicache/attributes"; import { addLinkBlock } from "src/utils/addLinkBlock"; import { UndoManager } from "src/undoManager"; diff --git a/src/replicache/attributes.ts b/src/replicache/attributes.ts index 67f74621..d0aa377f 100644 --- a/src/replicache/attributes.ts +++ b/src/replicache/attributes.ts @@ -242,7 +242,8 @@ export const Attributes = { ...ImageBlockAttributes, ...PollBlockAttributes, }; -type Attribute = typeof Attributes; +export type Attributes = typeof Attributes; +export type Attribute = keyof Attributes; export type Data = { text: { type: "text"; value: string }; string: { type: "string"; value: string }; @@ -316,6 +317,9 @@ export type Data = { }; color: { type: "color"; value: string }; }[(typeof Attributes)[A]["type"]]; -export type FilterAttributes> = { - [A in keyof Attribute as Attribute[A] extends F ? A : never]: Attribute[A]; -}; +export type FilterAttributes> = + { + [A in keyof Attributes as Attributes[A] extends F + ? A + : never]: Attributes[A]; + }; diff --git a/src/replicache/clientMutationContext.ts b/src/replicache/clientMutationContext.ts index 5ad103fc..e350a3a5 100644 --- a/src/replicache/clientMutationContext.ts +++ b/src/replicache/clientMutationContext.ts @@ -39,7 +39,7 @@ export function clientMutationContext( }, }, async assertFact(f) { - let attribute = Attributes[f.attribute as keyof typeof Attributes]; + let attribute = Attributes[f.attribute as Attribute]; if (!attribute) return; let id = f.id || v7(); let data = { ...f.data }; @@ -110,13 +110,13 @@ export function clientMutationContext( }, async deleteEntity(entity) { let existingFacts = await tx - .scan>({ + .scan>({ indexName: "eav", prefix: `${entity}`, }) .toArray(); let references = await tx - .scan>({ + .scan>({ indexName: "vae", prefix: entity, }) diff --git a/src/replicache/index.tsx b/src/replicache/index.tsx index 84c245f9..9d969974 100644 --- a/src/replicache/index.tsx +++ b/src/replicache/index.tsx @@ -17,7 +17,8 @@ import { WriteTransaction, } from "replicache"; import { mutations } from "./mutations"; -import { Attributes, Data, FilterAttributes } from "./attributes"; +import { Attributes } from "./attributes"; +import { Attribute, Data, FilterAttributes } from "./attributes"; import { clientMutationContext } from "./clientMutationContext"; import { supabaseBrowserClient } from "supabase/browserClient"; import { callRPC } from "app/api/rpc/client"; @@ -26,7 +27,7 @@ import { addShortcut } from "src/shortcuts"; import { createUndoManager } from "src/undoManager"; import { RealtimeChannel } from "@supabase/supabase-js"; -export type Fact = { +export type Fact = { id: string; entity: string; attribute: A; @@ -37,7 +38,7 @@ let ReplicacheContext = createContext({ undoManager: createUndoManager(), rootEntity: "" as string, rep: null as null | Replicache, - initialFacts: [] as Fact[], + initialFacts: [] as Fact[], permission_token: {} as PermissionToken, }); export function useReplicache() { @@ -65,7 +66,7 @@ export type PermissionToken = { }; export function ReplicacheProvider(props: { rootEntity: string; - initialFacts: Fact[]; + initialFacts: Fact[]; token: PermissionToken; name: string; children: React.ReactNode; @@ -191,11 +192,11 @@ export function ReplicacheProvider(props: { ); } -type CardinalityResult = +type CardinalityResult = (typeof Attributes)[A]["cardinality"] extends "one" ? DeepReadonlyObject> | null : DeepReadonlyObject>[]; -export function useEntity( +export function useEntity( entity: string | null, attribute: A, ): CardinalityResult { diff --git a/src/replicache/mutations.ts b/src/replicache/mutations.ts index f4eda687..b89eae85 100644 --- a/src/replicache/mutations.ts +++ b/src/replicache/mutations.ts @@ -11,13 +11,13 @@ export type MutationContext = { permission_set: string; }) => Promise; scanIndex: { - eav: ( + eav: ( entity: string, attribute: A, ) => Promise[]>>; }; deleteEntity: (entity: string) => Promise; - assertFact: ( + assertFact: ( f: Omit, "id"> & { id?: string }, ) => Promise; retractFact: (id: string) => Promise; @@ -332,8 +332,8 @@ const deleteEntity: Mutation<{ entity: string }> = async (args, ctx) => { }; export type FactInput = { - [k in keyof typeof Attributes]: Omit, "id"> & { id?: string }; -}[keyof typeof Attributes]; + [k in Attribute]: Omit, "id"> & { id?: string }; +}[Attribute]; const assertFact: Mutation> = async ( args, ctx, diff --git a/src/replicache/serverMutationContext.ts b/src/replicache/serverMutationContext.ts index eb6097f4..6e44bdb0 100644 --- a/src/replicache/serverMutationContext.ts +++ b/src/replicache/serverMutationContext.ts @@ -77,7 +77,7 @@ export function serverMutationContext( }, async assertFact(f) { if (!f.entity) return; - let attribute = Attributes[f.attribute as keyof typeof Attributes]; + let attribute = Attributes[f.attribute as Attribute]; if (!attribute) return; let id = f.id || v7(); let data = { ...f.data }; diff --git a/src/replicache/utils.ts b/src/replicache/utils.ts index 4d106bad..d4a4c618 100644 --- a/src/replicache/utils.ts +++ b/src/replicache/utils.ts @@ -1,11 +1,11 @@ import { PostgresJsDatabase } from "drizzle-orm/postgres-js"; import * as driz from "drizzle-orm"; -import { Fact } from "."; +import type { Fact } from "."; import { replicache_clients } from "drizzle/schema"; -import { Attributes, FilterAttributes } from "./attributes"; +import type { Attribute, FilterAttributes } from "./attributes"; import { ReadTransaction, WriteTransaction } from "replicache"; -export function FactWithIndexes(f: Fact) { +export function FactWithIndexes(f: Fact) { let indexes: { eav: string; aev: string; @@ -42,10 +42,7 @@ export async function getClientGroup( } export const scanIndex = (tx: ReadTransaction) => ({ - async eav( - entity: string, - attribute: A | "", - ) { + async eav(entity: string, attribute: A | "") { return ( ( await tx @@ -69,7 +66,7 @@ export const scanIndex = (tx: ReadTransaction) => ({ }); export const scanIndexLocal = (initialFacts: Fact[]) => ({ - eav(entity: string, attribute: A) { + eav(entity: string, attribute: A) { return initialFacts.filter( (f) => f.entity === entity && f.attribute === attribute, ) as Fact[]; diff --git a/src/utils/addImage.ts b/src/utils/addImage.ts index 827068ff..86f26ed4 100644 --- a/src/utils/addImage.ts +++ b/src/utils/addImage.ts @@ -1,7 +1,7 @@ import { Replicache } from "replicache"; import { ReplicacheMutators } from "../replicache"; import { supabaseBrowserClient } from "supabase/browserClient"; -import { FilterAttributes } from "src/replicache/attributes"; +import type { FilterAttributes } from "src/replicache/attributes"; import { rgbaToDataURL, rgbaToThumbHash, thumbHashToDataURL } from "thumbhash"; import { v7 } from "uuid"; diff --git a/src/utils/addLinkBlock.ts b/src/utils/addLinkBlock.ts index be4165e3..4749947a 100644 --- a/src/utils/addLinkBlock.ts +++ b/src/utils/addLinkBlock.ts @@ -4,7 +4,7 @@ import { LinkPreviewMetadataResult, } from "app/api/link_previews/route"; import { Replicache } from "replicache"; -import { ReplicacheMutators } from "src/replicache"; +import type { ReplicacheMutators } from "src/replicache"; import { AtpAgent } from "@atproto/api"; import { v7 } from "uuid"; diff --git a/src/utils/copySelection.ts b/src/utils/copySelection.ts index 7edbf074..c93b3a74 100644 --- a/src/utils/copySelection.ts +++ b/src/utils/copySelection.ts @@ -1,7 +1,7 @@ import { getBlocksAsHTML } from "src/utils/getBlocksAsHTML"; import { htmlToMarkdown } from "src/htmlMarkdownParsers"; import { Replicache } from "replicache"; -import { ReplicacheMutators } from "src/replicache"; +import type { ReplicacheMutators } from "src/replicache"; import { Block } from "components/Blocks/Block"; export async function copySelection( diff --git a/src/utils/getBlocksAsHTML.tsx b/src/utils/getBlocksAsHTML.tsx index 5ccb3fb5..8b876395 100644 --- a/src/utils/getBlocksAsHTML.tsx +++ b/src/utils/getBlocksAsHTML.tsx @@ -1,5 +1,5 @@ import { ReadTransaction, Replicache } from "replicache"; -import { Fact, ReplicacheMutators } from "src/replicache"; +import type { Fact, ReplicacheMutators } from "src/replicache"; import { scanIndex } from "src/replicache/utils"; import { renderToStaticMarkup } from "react-dom/server"; import * as Y from "yjs"; diff --git a/src/utils/list-operations.ts b/src/utils/list-operations.ts index c8aae20b..7ceff234 100644 --- a/src/utils/list-operations.ts +++ b/src/utils/list-operations.ts @@ -1,6 +1,6 @@ import { Block } from "components/Blocks/Block"; import { Replicache } from "replicache"; -import { ReplicacheMutators } from "src/replicache"; +import type { ReplicacheMutators } from "src/replicache"; import { useUIState } from "src/useUIState"; import { v7 } from "uuid";