@seedprotocol/sdk 0.4.4 → 0.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -348
- package/dist/{ArweaveClient-DkNLWiSZ.js → ArweaveClient-CgWK-JgT.js} +8 -8
- package/dist/{ArweaveClient-DkNLWiSZ.js.map → ArweaveClient-CgWK-JgT.js.map} +1 -1
- package/dist/{ArweaveClient-CczHvccG.js → ArweaveClient-WcG8CZAE.js} +8 -8
- package/dist/{ArweaveClient-CczHvccG.js.map → ArweaveClient-WcG8CZAE.js.map} +1 -1
- package/dist/{Db-DJvjXVlp.js → Db-DjFdIdR9.js} +9 -9
- package/dist/{Db-DJvjXVlp.js.map → Db-DjFdIdR9.js.map} +1 -1
- package/dist/{Db-BzQR2KX9.js → Db-DjofXdeU.js} +9 -9
- package/dist/{Db-BzQR2KX9.js.map → Db-DjofXdeU.js.map} +1 -1
- package/dist/{EasClient-CHQYmjj2.js → EasClient-Aojewp6P.js} +8 -8
- package/dist/{EasClient-CodrIgW-.js.map → EasClient-Aojewp6P.js.map} +1 -1
- package/dist/{EasClient-CodrIgW-.js → EasClient-BVFXp2O6.js} +8 -8
- package/dist/{EasClient-CHQYmjj2.js.map → EasClient-BVFXp2O6.js.map} +1 -1
- package/dist/{FileManager-BbvkZJCH.js → FileManager-C9zr4AJe.js} +8 -8
- package/dist/{FileManager-BbvkZJCH.js.map → FileManager-C9zr4AJe.js.map} +1 -1
- package/dist/{FileManager-BIVsDnMu.js → FileManager-CxGJLw5C.js} +8 -8
- package/dist/{FileManager-BIVsDnMu.js.map → FileManager-CxGJLw5C.js.map} +1 -1
- package/dist/Item/Item.d.ts.map +1 -1
- package/dist/ItemProperty/ItemProperty.d.ts.map +1 -1
- package/dist/Model/Model.d.ts.map +1 -1
- package/dist/ModelProperty/ModelProperty.d.ts.map +1 -1
- package/dist/ModelProperty/service/actors/compareAndMarkDraft.d.ts.map +1 -1
- package/dist/ModelProperty/service/actors/saveToSchema.d.ts.map +1 -1
- package/dist/{ModelProperty-gjcA83Mq.js → ModelProperty-CGdkocQ8.js} +31 -766
- package/dist/ModelProperty-CGdkocQ8.js.map +1 -0
- package/dist/{PathResolver-kGzba-zC.js → PathResolver-CX6GHoTS.js} +8 -8
- package/dist/{PathResolver-kGzba-zC.js.map → PathResolver-CX6GHoTS.js.map} +1 -1
- package/dist/{PathResolver-9zAzPhee.js → PathResolver-z_WX47_o.js} +8 -8
- package/dist/{PathResolver-9zAzPhee.js.map → PathResolver-z_WX47_o.js.map} +1 -1
- package/dist/{QueryClient-C7ZkTT0z.js → QueryClient-ByKPdRmE.js} +8 -8
- package/dist/{QueryClient-C7ZkTT0z.js.map → QueryClient-ByKPdRmE.js.map} +1 -1
- package/dist/{QueryClient-CEtsek7Q.js → QueryClient-Cb1iJO-x.js} +8 -8
- package/dist/{QueryClient-CEtsek7Q.js.map → QueryClient-Cb1iJO-x.js.map} +1 -1
- package/dist/Schema/Schema.d.ts.map +1 -1
- package/dist/Schema/service/actors/writePropertiesToDb.d.ts.map +1 -1
- package/dist/Schema/service/addModelsMachine.d.ts.map +1 -1
- package/dist/{Schema-ClTcpgbt.js → Schema-D1eqDHyt.js} +758 -60
- package/dist/Schema-D1eqDHyt.js.map +1 -0
- package/dist/{SchemaValidationService-BfoEiHNr.js → SchemaValidationService-DyttFaV_.js} +7 -7
- package/dist/{SchemaValidationService-BfoEiHNr.js.map → SchemaValidationService-DyttFaV_.js.map} +1 -1
- package/dist/cjs/{ModelProperty-BRKRREYP.js → ModelProperty-BeJvgKMw.js} +62 -436
- package/dist/cjs/ModelProperty-BeJvgKMw.js.map +1 -0
- package/dist/cjs/{Schema-CV9hMg8m.js → Schema-CVs9J6eP.js} +426 -91
- package/dist/cjs/Schema-CVs9J6eP.js.map +1 -0
- package/dist/cjs/{SchemaValidationService-DUtQUerg.js → SchemaValidationService-CDKcVRFQ.js} +3 -3
- package/dist/cjs/{SchemaValidationService-DUtQUerg.js.map → SchemaValidationService-CDKcVRFQ.js.map} +1 -1
- package/dist/cjs/{getItem-BThT-UOt.js → getItem-B5RYPvrG.js} +3 -3
- package/dist/cjs/{getItem-BThT-UOt.js.map → getItem-B5RYPvrG.js.map} +1 -1
- package/dist/cjs/{getPublishPayload-CKZ7rVbU.js → getPublishPayload-BD1qRob1.js} +6 -6
- package/dist/cjs/getPublishPayload-BD1qRob1.js.map +1 -0
- package/dist/cjs/{getPublishUploads-CuGIvV-Q.js → getPublishUploads-CnC9aYxs.js} +4 -4
- package/dist/cjs/{getPublishUploads-CuGIvV-Q.js.map → getPublishUploads-CnC9aYxs.js.map} +1 -1
- package/dist/cjs/{getSegmentedItemProperties-BCJXJlTR.js → getSegmentedItemProperties-B_njnntx.js} +2 -2
- package/dist/cjs/{getSegmentedItemProperties-BCJXJlTR.js.map → getSegmentedItemProperties-B_njnntx.js.map} +1 -1
- package/dist/cjs/{index-C3j3m34a.js → index-BeKPbbk0.js} +11466 -11546
- package/dist/cjs/index-BeKPbbk0.js.map +1 -0
- package/dist/cjs/{index-CbTBDqTJ.js → index-Dnywap_P.js} +3 -3
- package/dist/cjs/index-Dnywap_P.js.map +1 -0
- package/dist/client/actors/platformClassesInit.d.ts.map +1 -1
- package/dist/client/actors/saveAppState.d.ts.map +1 -1
- package/dist/eas.d.ts.map +1 -1
- package/dist/{getItem-BWPo8wd0.js → getItem-BB5HBCbK.js} +8 -8
- package/dist/{getItem-BWPo8wd0.js.map → getItem-BB5HBCbK.js.map} +1 -1
- package/dist/{getPublishPayload-Caw2laZM.js → getPublishPayload-uLm0AqN_.js} +10 -10
- package/dist/getPublishPayload-uLm0AqN_.js.map +1 -0
- package/dist/{getPublishUploads-MlyBuoXh.js → getPublishUploads-Dc-HqhO8.js} +9 -9
- package/dist/{getPublishUploads-MlyBuoXh.js.map → getPublishUploads-Dc-HqhO8.js.map} +1 -1
- package/dist/{getSegmentedItemProperties-COLLdDo4.js → getSegmentedItemProperties-BrIqFNfD.js} +2 -2
- package/dist/{getSegmentedItemProperties-COLLdDo4.js.map → getSegmentedItemProperties-BrIqFNfD.js.map} +1 -1
- package/dist/helpers/schema.d.ts.map +1 -1
- package/dist/helpers/updateSchema.d.ts.map +1 -1
- package/dist/imports/json.d.ts.map +1 -1
- package/dist/{index-D2OGsG4v.js → index-2FcQHgKp.js} +2 -2
- package/dist/index-2FcQHgKp.js.map +1 -0
- package/dist/{ClientManager-DoHUt8tU.js → index-DPll6EAp.js} +11460 -11538
- package/dist/index-DPll6EAp.js.map +1 -0
- package/dist/{index-B9i_mXXp.js → index-LEY0Og1p.js} +9 -9
- package/dist/index-LEY0Og1p.js.map +1 -0
- package/dist/main.cjs +2 -2
- package/dist/main.js +13 -13
- package/dist/main.js.map +1 -1
- package/dist/node.js +15 -15
- package/dist/{property-fK7tSUDX.js → property-B15X7jLX.js} +4 -4
- package/dist/property-B15X7jLX.js.map +1 -0
- package/dist/{queries-DGOk16cd.js → queries-BPDSpiEX.js} +2 -2
- package/dist/{queries-DGOk16cd.js.map → queries-BPDSpiEX.js.map} +1 -1
- package/dist/services/write/actors/writeToDatabase.d.ts.map +1 -1
- package/package.json +6 -2
- package/dist/ClientManager-DoHUt8tU.js.map +0 -1
- package/dist/ModelProperty-gjcA83Mq.js.map +0 -1
- package/dist/Schema-ClTcpgbt.js.map +0 -1
- package/dist/cjs/ModelProperty-BRKRREYP.js.map +0 -1
- package/dist/cjs/Schema-CV9hMg8m.js.map +0 -1
- package/dist/cjs/getPublishPayload-CKZ7rVbU.js.map +0 -1
- package/dist/cjs/index-C3j3m34a.js.map +0 -1
- package/dist/cjs/index-CbTBDqTJ.js.map +0 -1
- package/dist/getPublishPayload-Caw2laZM.js.map +0 -1
- package/dist/index-B9i_mXXp.js.map +0 -1
- package/dist/index-D2OGsG4v.js.map +0 -1
- package/dist/property-fK7tSUDX.js.map +0 -1
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sources":["../src/browser/react/client.ts","../src/browser/react/liveQuery.ts","../src/browser/react/item.ts","../src/browser/react/itemProperty.ts","../src/browser/react/services.ts","../src/browser/react/db.ts","../src/browser/react/schema.ts","../src/browser/react/model.ts","../src/browser/react/modelProperty.ts","../src/browser/react/trash.ts","../src/browser/react/queryClient.ts","../src/browser/react/SeedProvider.tsx","../src/feed.ts"],"sourcesContent":["import { ClientManagerState } from \"@/client/constants\"\nimport { getClient } from \"@/client/ClientManager\"\nimport { useSelector } from \"@xstate/react\"\n\n\nexport const useIsClientReady = () => {\n const client = getClient()\n\n const clientService = client.getService()\n\n const isClientReady = useSelector(clientService, (snapshot) => {\n return snapshot.value === ClientManagerState.IDLE\n })\n\n // GlobalState removed - check ClientManager state directly\n return isClientReady\n}","import { useEffect, useState, useRef, useMemo } from 'react'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport { Observable } from 'rxjs'\nimport { useIsClientReady } from './client'\n\n/**\n * Hook to execute a reactive query that emits new results whenever the underlying data changes.\n * \n * Supports two usage patterns:\n * 1. SQL tag function: useLiveQuery((sql) => sql`SELECT * FROM models`)\n * 2. Drizzle query builder: useLiveQuery(db.select().from(models))\n * \n * @param query - SQL query function or Drizzle query builder, or null/undefined to disable the query\n * @returns Array of query results, or undefined if not yet loaded\n * \n * @example\n * ```typescript\n * // Using SQL tag function\n * const models = useLiveQuery<ModelRow>(\n * (sql) => sql`SELECT * FROM models WHERE schema_file_id = ${schemaId}`\n * )\n * \n * // Using Drizzle query builder\n * import { models } from '@/seedSchema'\n * import { eq } from 'drizzle-orm'\n * \n * const appDb = BaseDb.getAppDb()\n * const models = useLiveQuery<ModelRow>(\n * appDb.select().from(models).where(eq(models.schemaFileId, schemaId))\n * )\n * ```\n */\nexport function useLiveQuery<T>(\n query: ((sql: any) => any) | any | null | undefined\n): T[] | undefined {\n const [data, setData] = useState<T[] | undefined>(undefined)\n const subscriptionRef = useRef<{ unsubscribe: () => void } | null>(null)\n const previousDataRef = useRef<T[] | undefined>(undefined)\n const isClientReady = useIsClientReady()\n\n // Create Observable outside useEffect so it's stable and distinctUntilChanged can work\n // Only recreate when query or isClientReady changes\n const observable = useMemo(() => {\n if (!isClientReady || !query) {\n return null\n }\n try {\n return BaseDb.liveQuery<T>(query)\n } catch (error) {\n console.error('[useLiveQuery] Failed to create live query:', error)\n return null\n }\n }, [query, isClientReady])\n\n useEffect(() => {\n // Cleanup previous subscription if it exists\n if (subscriptionRef.current) {\n subscriptionRef.current.unsubscribe()\n subscriptionRef.current = null\n }\n\n // Don't subscribe if observable is null\n if (!observable) {\n return\n }\n\n const subscription = observable.subscribe({\n next: (results) => {\n const prev = previousDataRef.current\n const prevJson = prev ? JSON.stringify(prev) : 'undefined'\n const currJson = results ? JSON.stringify(results) : 'undefined'\n const isSameValue = prevJson === currJson\n\n // Defensive check: don't update state if values are the same\n // This should be handled by distinctUntilChanged, but adding as safety\n // (especially important for Drizzle query builders which may not work with distinctUntilChanged)\n if (isSameValue && prev !== undefined) {\n return\n }\n\n previousDataRef.current = results\n setData(results)\n },\n error: (err) => {\n console.error('[useLiveQuery] Error:', err)\n // Don't set data to undefined on error - keep last known good state\n // This prevents UI flickering on transient errors\n },\n })\n\n subscriptionRef.current = subscription\n\n // Cleanup on unmount or observable change\n return () => {\n if (subscriptionRef.current) {\n subscriptionRef.current.unsubscribe()\n subscriptionRef.current = null\n }\n }\n }, [observable]) // Only re-subscribe when observable changes\n\n return data\n}\n\n","import { useCallback, useEffect, useRef, useState, useMemo } from 'react'\nimport { flushSync } from 'react-dom'\nimport { createNewItem } from '@/db/write/createNewItem'\nimport { Item } from '@/Item/Item'\nimport { orderBy } from 'lodash-es'\nimport debug from 'debug'\nimport { ModelValues } from '@/types'\nimport { Subscription } from 'xstate'\nimport { IItem } from '@/interfaces'\nimport { useIsClientReady } from './client'\nimport { useLiveQuery } from './liveQuery'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport { seeds } from '@/seedSchema'\nimport { and, eq, gt, isNotNull, isNull, or } from 'drizzle-orm'\nimport type { SeedType } from '@/seedSchema/SeedSchema'\nimport { getVersionData } from '@/db/read/subqueries/versionData'\nimport { useQuery, useQueryClient } from '@tanstack/react-query'\n\nconst logger = debug('seedSdk:react:item')\n\ntype UseItemReturn<T extends ModelValues<T>> = {\n item: IItem<T> | undefined\n isLoading: boolean\n error: Error | null\n}\n\ntype UseItemProps = {\n modelName: string\n seedLocalId?: string\n seedUid?: string\n}\n\ntype UseItem = <T extends ModelValues<T>>(props: UseItemProps) => UseItemReturn<T>\n\nexport const useItem: UseItem = <T extends ModelValues<T>>({ modelName, seedLocalId, seedUid }: UseItemProps) => {\n const [item, setItem] = useState<Item<T> | undefined>()\n const [isLoading, setIsLoading] = useState(!!(seedLocalId || seedUid))\n const [error, setError] = useState<Error | null>(null)\n const subscriptionRef = useRef<Subscription | undefined>(undefined)\n const hasSeenIdleRef = useRef(false)\n\n const isClientReady = useIsClientReady()\n\n const modelNameRef = useRef<string>(modelName)\n const seedLocalIdRef = useRef<string | undefined>(seedLocalId)\n const seedUidRef = useRef<string | undefined>(seedUid)\n\n // Determine if we should be loading based on parameters - use useMemo to stabilize\n // Use refs to check current values to avoid dependency issues\n const shouldLoad = useMemo(() => {\n if (!isClientReady) return false\n return !!(seedLocalIdRef.current || seedUidRef.current)\n }, [isClientReady, seedLocalId, seedUid])\n\n const loadItem = useCallback(async () => {\n // Check shouldLoad inside the function to avoid recreating the callback\n const currentShouldLoad = !!(isClientReady && (seedLocalIdRef.current || seedUidRef.current))\n if (!currentShouldLoad) {\n setItem(undefined)\n setIsLoading(false)\n setError(null)\n return\n }\n\n try {\n // Don't set isLoading here - let the subscription effect handle it\n // This avoids race conditions where isLoading is set to true but then\n // the subscription effect hasn't run yet to set it to false\n setError(null)\n\n const foundItem = await Item.find({\n modelName: modelNameRef.current,\n seedLocalId: seedLocalIdRef.current,\n seedUid: seedUidRef.current,\n }) as Item<T> | undefined\n\n if (!foundItem) {\n logger('[useItem] [loadItem] no item found', modelNameRef.current, seedLocalIdRef.current)\n // Don't clear item if we already have one for the same request (e.g. duplicate loadItem from effect re-run)\n setItem((prev) => {\n if (!prev) return undefined\n const match = (prev.seedLocalId && prev.seedLocalId === seedLocalIdRef.current) ||\n (prev.seedUid && prev.seedUid === seedUidRef.current)\n return match ? prev : undefined\n })\n setIsLoading(false)\n setError(null)\n return\n }\n\n // Item.find() now waits for idle by default, so the item should be ready\n setItem(foundItem)\n setIsLoading(false) // Item is ready since find() waited for idle\n setError(null)\n } catch (error) {\n logger('[useItem] Error loading item:', error)\n setItem(undefined)\n setIsLoading(false)\n setError(error as Error)\n }\n }, [isClientReady])\n\n useEffect(() => {\n modelNameRef.current = modelName\n seedLocalIdRef.current = seedLocalId\n seedUidRef.current = seedUid\n }, [modelName, seedLocalId, seedUid])\n\n // Fetch/refetch when parameters change or client becomes ready\n useEffect(() => {\n // Only clear item if we don't have parameters to load\n // Don't clear if shouldLoad is false but we have an item - it might just be a timing issue\n if (!shouldLoad) {\n // Only clear if we actually don't have parameters (not just client not ready)\n if (!seedLocalId && !seedUid) {\n setItem(undefined)\n setIsLoading(false)\n setError(null)\n }\n return\n }\n loadItem()\n }, [shouldLoad, loadItem, seedLocalId, seedUid])\n\n // Subscribe to service changes when item is available\n useEffect(() => {\n if (!item) {\n // Clean up subscription if item is not available\n subscriptionRef.current?.unsubscribe()\n subscriptionRef.current = undefined\n hasSeenIdleRef.current = false\n return\n }\n\n // Clean up previous subscription\n subscriptionRef.current?.unsubscribe()\n hasSeenIdleRef.current = false\n\n // Subscribe to service changes. Only set isLoading to true after we've seen idle at least\n // once, so we don't overwrite the ready state that loadItem() just set (find() waits for idle).\n const service = item.getService()\n\n const subscription = service.subscribe((snapshot: any) => {\n // Update loading state based on service state changes\n if (snapshot && typeof snapshot === 'object' && 'value' in snapshot) {\n const isIdle = snapshot.value === 'idle'\n if (isIdle) {\n hasSeenIdleRef.current = true\n setIsLoading(false)\n setError(null)\n } else if (snapshot.value === 'error') {\n setError(new Error('Item service error'))\n setIsLoading(false)\n } else {\n // Only show loading if we've already seen idle (real transition to loading)\n if (hasSeenIdleRef.current) {\n setIsLoading(true)\n }\n }\n }\n })\n \n subscriptionRef.current = subscription\n\n return () => {\n subscriptionRef.current?.unsubscribe()\n subscriptionRef.current = undefined\n }\n }, [item])\n\n return {\n item,\n isLoading,\n error,\n }\n}\n\ntype UseItemsReturn = {\n items: IItem<any>[]\n isLoading: boolean\n error: Error | null\n}\n\ntype UseItemsProps = {\n modelName?: string\n deleted?: boolean\n}\n\ntype UseItems = (props: UseItemsProps) => UseItemsReturn\n\nconst getItemsQueryKey = (modelName?: string, deleted?: boolean) =>\n ['seed', 'items', modelName ?? null, deleted ?? false] as const\n\nexport const useItems: UseItems = ({ modelName, deleted = false }) => {\n const isClientReady = useIsClientReady()\n const queryClient = useQueryClient()\n const previousSeedsTableDataRef = useRef<SeedType[] | undefined>(undefined)\n const itemsRef = useRef<IItem<any>[]>([])\n const lastFetchedIdsRef = useRef<Set<string>>(new Set())\n\n const queryKey = useMemo(() => getItemsQueryKey(modelName, deleted), [modelName, deleted])\n\n const {\n data: items = [],\n isLoading,\n error: queryError,\n } = useQuery({\n queryKey,\n queryFn: () => Item.all(modelName, deleted, { waitForReady: true }),\n enabled: isClientReady,\n })\n itemsRef.current = items\n\n // Watch the seeds table for changes\n const db = isClientReady ? BaseDb.getAppDb() : null\n const seedsQuery = useMemo(() => {\n if (!db) return null\n const conditions: any[] = []\n if (modelName) {\n conditions.push(eq(seeds.type, modelName.toLowerCase()))\n }\n if (deleted) {\n conditions.push(\n or(\n isNotNull(seeds._markedForDeletion),\n eq(seeds._markedForDeletion, 1)\n ) as any\n )\n } else {\n conditions.push(\n or(\n isNull(seeds._markedForDeletion),\n eq(seeds._markedForDeletion, 0)\n ) as any\n )\n }\n const versionData = getVersionData()\n return db\n .with(versionData)\n .select({\n localId: seeds.localId,\n uid: seeds.uid,\n type: seeds.type,\n schemaUid: seeds.schemaUid,\n createdAt: seeds.createdAt,\n attestationCreatedAt: seeds.attestationCreatedAt,\n _markedForDeletion: seeds._markedForDeletion,\n })\n .from(seeds)\n .leftJoin(versionData, eq(seeds.localId, versionData.seedLocalId))\n .where(and(gt(versionData.versionsCount, 0), ...conditions))\n .groupBy(seeds.localId)\n }, [db, isClientReady, modelName, deleted])\n const seedsTableData = useLiveQuery<SeedType>(seedsQuery)\n\n // Invalidate when table data actually changes so useQuery refetches\n useEffect(() => {\n if (!isClientReady || !seedsTableData) return\n\n const tableDataItemsSet = new Set<string>()\n for (const dbSeed of seedsTableData) {\n const key = dbSeed.localId || dbSeed.uid\n if (key) tableDataItemsSet.add(key)\n }\n\n const currentItemsSet = new Set<string>()\n for (const item of itemsRef.current) {\n const key = item.seedLocalId || item.seedUid\n if (key) currentItemsSet.add(key)\n }\n\n if (tableDataItemsSet.size === 0 && currentItemsSet.size > 0) return\n\n const lastFetched = lastFetchedIdsRef.current\n if (\n lastFetched.size === tableDataItemsSet.size &&\n [...lastFetched].every((id) => tableDataItemsSet.has(id))\n ) {\n return\n }\n\n previousSeedsTableDataRef.current = seedsTableData\n\n const setsAreEqual =\n currentItemsSet.size === tableDataItemsSet.size &&\n [...currentItemsSet].every((id) => tableDataItemsSet.has(id))\n\n if (setsAreEqual) {\n lastFetchedIdsRef.current = new Set(tableDataItemsSet)\n return\n }\n\n lastFetchedIdsRef.current = new Set(tableDataItemsSet)\n queryClient.invalidateQueries({ queryKey })\n }, [isClientReady, seedsTableData, queryClient, queryKey])\n\n return {\n items: orderBy(\n items,\n [\n (item) =>\n item.lastVersionPublishedAt ||\n item.attestationCreatedAt ||\n item.createdAt,\n ],\n ['desc'],\n ),\n isLoading,\n error: queryError as Error | null,\n }\n}\n\nexport type UseCreateItemReturn = {\n createItem: (modelName: string, itemData?: Record<string, any>) => Promise<Item<any> | undefined>\n isLoading: boolean\n error: Error | null\n resetError: () => void\n}\n\nexport const useCreateItem = (): UseCreateItemReturn => {\n const [isLoading, setIsLoading] = useState(false)\n const [error, setError] = useState<Error | null>(null)\n\n const resetError = useCallback(() => setError(null), [])\n\n const createItem = useCallback(\n async (modelName: string, itemData?: Record<string, any>): Promise<Item<any> | undefined> => {\n if (isLoading) {\n logger('[useCreateItem] [createItem] already creating item, skipping')\n return undefined\n }\n\n setError(null)\n // Flush loading=true synchronously so the UI (and tests) can observe it before async work runs.\n flushSync(() => setIsLoading(true))\n\n try {\n const data = itemData ?? {}\n const { seedLocalId } = await createNewItem({ modelName, ...data })\n const newItem = await Item.find({ modelName, seedLocalId })\n return (newItem ?? undefined) as Item<any> | undefined\n } catch (err) {\n logger('[useCreateItem] Error creating item:', err)\n setError(err instanceof Error ? err : new Error(String(err)))\n return undefined\n } finally {\n // Defer clearing loading so React can commit the loading=true render first.\n // Otherwise the test (or UI) may never observe isLoading true (same continuation batching).\n queueMicrotask(() => setIsLoading(false))\n }\n },\n [isLoading],\n )\n\n return {\n createItem,\n isLoading,\n error,\n resetError,\n }\n}\n\ntype UsePublishItemReturn = {\n publishItem: (item: Item<any> | undefined) => void\n isLoading: boolean\n error: Error | null\n resetError: () => void\n}\n\nexport const usePublishItem = (): UsePublishItemReturn => {\n const [publishingItem, setPublishingItem] = useState<Item<any> | null>(null)\n const [isLoading, setIsLoading] = useState(false)\n const [error, setError] = useState<Error | null>(null)\n const subscriptionRef = useRef<Subscription | undefined>(undefined)\n\n const resetError = useCallback(() => setError(null), [])\n\n const publishItem = useCallback((item: Item<any> | undefined) => {\n if (!item) return\n setPublishingItem(item)\n setError(null)\n item.publish().catch(() => {\n // Error is surfaced via service state subscription; avoid unhandled rejection\n })\n }, [])\n\n useEffect(() => {\n if (!publishingItem) {\n subscriptionRef.current?.unsubscribe()\n subscriptionRef.current = undefined\n setIsLoading(false)\n return\n }\n\n subscriptionRef.current?.unsubscribe()\n const service = publishingItem.getService()\n const subscription = service.subscribe((snapshot: any) => {\n const value = snapshot?.value\n const ctx = snapshot?.context\n setIsLoading(value === 'publishing')\n const publishError = ctx?._publishError\n setError(publishError ? new Error(publishError.message) : null)\n })\n\n subscriptionRef.current = subscription\n const snap = service.getSnapshot()\n setIsLoading(snap?.value === 'publishing')\n const ctx = snap?.context\n const publishError = ctx?._publishError\n setError(publishError ? new Error(publishError.message) : null)\n\n return () => {\n subscriptionRef.current?.unsubscribe()\n subscriptionRef.current = undefined\n }\n }, [publishingItem])\n\n return {\n publishItem,\n isLoading,\n error,\n resetError,\n }\n}\n","import { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport { Subscription, SnapshotFrom } from 'xstate'\nimport debug from 'debug'\nimport { ItemProperty } from '@/ItemProperty/ItemProperty'\nimport { useIsClientReady } from './client'\nimport { IItemProperty } from '@/interfaces'\nimport { useLiveQuery } from './liveQuery'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport { metadata } from '@/seedSchema/MetadataSchema'\nimport { seeds } from '@/seedSchema'\nimport { and, eq, isNotNull } from 'drizzle-orm'\nimport { getMetadataLatest } from '@/db/read/subqueries/metadataLatest'\nimport { propertyMachine } from '@/ItemProperty/service/propertyMachine'\nimport { startCase } from 'lodash-es'\nimport { useQuery, useQueryClient } from '@tanstack/react-query'\n\nconst logger = debug('seedSdk:react:property')\nconst propertiesLogger = debug('seedSdk:react:itemProperties')\n\ntype ItemPropertySnapshot = SnapshotFrom<typeof propertyMachine>\n\ntype UseItemPropertyReturn = {\n property: IItemProperty | undefined\n isLoading: boolean\n error: Error | null\n}\n\n/**\n * Hook to get a specific ItemProperty instance\n * Can be called in multiple ways:\n * 1. With seedLocalId/seedUid and propertyName: useItemProperty({ seedLocalId, propertyName }) or useItemProperty({ seedUid, propertyName })\n * 2. With itemId and propertyName: useItemProperty(itemId, propertyName) or useItemProperty({ itemId, propertyName })\n * \n * @overload\n * @param props - Object with seedLocalId or seedUid, and propertyName\n * @returns Object with property, isLoading, and error\n * \n * @overload\n * @param props - Object with itemId and propertyName\n * @returns Object with property, isLoading, and error\n * \n * @overload\n * @param itemId - The item ID (seedLocalId or seedUid)\n * @param propertyName - The name of the property\n * @returns Object with property, isLoading, and error\n */\nexport function useItemProperty(props: {\n seedLocalId?: string\n seedUid?: string\n propertyName: string\n}): UseItemPropertyReturn\nexport function useItemProperty(props: {\n itemId?: string\n propertyName: string\n}): UseItemPropertyReturn\nexport function useItemProperty(\n itemId: string,\n propertyName: string\n): UseItemPropertyReturn\nexport function useItemProperty(\n arg1:\n | { seedLocalId?: string; seedUid?: string; propertyName: string }\n | { itemId: string; propertyName: string }\n | string,\n arg2?: string\n) {\n const isClientReady = useIsClientReady()\n const [property, setProperty] = useState<IItemProperty | undefined>(undefined)\n const [isLoading, setIsLoading] = useState(false)\n const [error, setError] = useState<Error | null>(null)\n const subscriptionRef = useRef<Subscription | undefined>(undefined)\n const [, setVersion] = useState(0) // Version counter to force re-renders\n\n // Extract primitives so useMemo/useCallback deps are stable when caller passes inline objects\n // Support object form with itemId: useItemProperty({ itemId, propertyName })\n const arg1IsObject = typeof arg1 === 'object' && arg1 != null\n const obj = arg1IsObject ? (arg1 as Record<string, unknown>) : null\n const itemIdFromObj = obj != null ? (obj.itemId as string | undefined) : undefined\n const seedLocalId =\n obj != null ? (obj.seedLocalId as string | undefined) : undefined\n const seedUid =\n obj != null ? (obj.seedUid as string | undefined) : undefined\n const propertyNameFromObj =\n obj != null ? (obj.propertyName as string | undefined) : undefined\n const itemId =\n typeof arg1 === 'string' ? arg1 : (itemIdFromObj !== undefined && itemIdFromObj !== '' ? itemIdFromObj : undefined)\n const propertyNameFromArgs = typeof arg1 === 'string' ? arg2 : undefined\n const propertyName = propertyNameFromObj ?? propertyNameFromArgs\n\n // Determine which lookup mode we're in based on arguments (deps are primitives to avoid infinite loop)\n // Unify itemId and identifiers: when itemId is provided (string or object form), use it as seedLocalId so we hit the same code path\n const lookupMode = useMemo(() => {\n const resolvedSeedLocalId = (itemId !== undefined && itemId !== '') ? itemId : seedLocalId\n const resolvedSeedUid = (itemId !== undefined && itemId !== '') ? undefined : seedUid\n if ((resolvedSeedLocalId != null || resolvedSeedUid != null) && propertyName != null && propertyName !== '') {\n return {\n type: 'identifiers' as const,\n seedLocalId: resolvedSeedLocalId ?? undefined,\n seedUid: resolvedSeedUid,\n propertyName,\n }\n }\n return null\n }, [itemId, propertyName, seedLocalId, seedUid])\n\n // Determine initial loading state\n const initialLoadingState = useMemo(() => {\n if (!lookupMode) return false\n return !!(\n (lookupMode.seedLocalId || lookupMode.seedUid) &&\n lookupMode.propertyName\n )\n }, [lookupMode])\n\n // Determine if we should be loading based on parameters\n const shouldLoad = useMemo(() => {\n if (!isClientReady) return false\n if (!lookupMode) return false\n return !!(\n (lookupMode.seedLocalId || lookupMode.seedUid) &&\n lookupMode.propertyName\n )\n }, [isClientReady, lookupMode])\n\n const updateItemProperty = useCallback(async () => {\n if (!isClientReady || !lookupMode) {\n setProperty(undefined)\n setIsLoading(false)\n setError(null)\n return\n }\n\n try {\n setIsLoading(true)\n setError(null)\n\n const seedLocalId = lookupMode.seedLocalId\n const seedUid = lookupMode.seedUid\n\n if (!seedLocalId && !seedUid) {\n setProperty(undefined)\n setIsLoading(false)\n setError(null)\n return\n }\n\n const foundProperty = await ItemProperty.find({\n propertyName: lookupMode.propertyName,\n seedLocalId,\n seedUid,\n })\n\n if (!foundProperty) {\n logger(\n `[useItemProperty] [updateItemProperty] no property found for Item.${seedLocalId || seedUid}.${lookupMode.propertyName}`,\n )\n setProperty(undefined)\n setIsLoading(false)\n setError(null)\n return\n }\n\n // ItemProperty.find() now waits for idle by default, so the property should be ready\n setProperty(foundProperty)\n setIsLoading(false) // Property is ready since find() waited for idle\n setError(null)\n } catch (error) {\n logger('[useItemProperty] Error updating item property:', error)\n setProperty(undefined)\n setIsLoading(false)\n setError(error as Error)\n }\n }, [isClientReady, lookupMode])\n\n // Fetch/refetch when lookup parameters change or client becomes ready.\n // Skip refetch when we already have the property for this lookup (avoids setting loading true\n // again when effect re-runs e.g. from Strict Mode or updateItemProperty identity change).\n // Match by the active identifier only: when looking up by seedLocalId both must match;\n // when looking up by seedUid both must match. Do not use (seedUid === undefined) as a match\n // when seedLocalIds differ, which would incorrectly skip refetch after seedLocalId change.\n useEffect(() => {\n if (!shouldLoad) {\n setProperty(undefined)\n setIsLoading(false)\n setError(null)\n return\n }\n const alreadyHavePropertyGuard =\n property &&\n lookupMode &&\n property.propertyName === lookupMode.propertyName &&\n ((lookupMode.seedLocalId != null && property.seedLocalId === lookupMode.seedLocalId) ||\n (lookupMode.seedUid != null && (property as any).seedUid === lookupMode.seedUid))\n if (alreadyHavePropertyGuard) return\n updateItemProperty()\n }, [shouldLoad, updateItemProperty, property, lookupMode])\n\n // Subscribe to service changes when property is available\n useEffect(() => {\n if (!property) {\n // Clean up subscription if property is not available\n subscriptionRef.current?.unsubscribe()\n subscriptionRef.current = undefined\n return\n }\n\n // Clean up previous subscription\n subscriptionRef.current?.unsubscribe()\n\n // Subscribe to service changes. Only set isLoading to false when idle; never set to true\n // here so we never overwrite the loaded state when the machine emits any non-idle state\n // (e.g. loading, initializing, resolvingRelatedValue) after the initial fetch.\n const subscription = property.getService().subscribe((snapshot: any) => {\n if (snapshot && typeof snapshot === 'object' && 'value' in snapshot && snapshot.value === 'idle') {\n setIsLoading(false)\n setError(null)\n }\n \n // Force re-render by incrementing version counter\n setVersion(prev => prev + 1)\n })\n \n subscriptionRef.current = subscription\n\n return () => {\n subscriptionRef.current?.unsubscribe()\n subscriptionRef.current = undefined\n }\n }, [property])\n\n return {\n property,\n isLoading,\n error,\n }\n}\ntype UseItemPropertiesReturn = {\n properties: IItemProperty[]\n isLoading: boolean\n error: Error | null\n}\n\n/** Fetches item properties list for useQuery (shared with useItemProperties). */\nasync function fetchItemPropertiesList(\n seedLocalId: string | undefined,\n seedUid: string | undefined\n): Promise<IItemProperty[]> {\n if (!seedLocalId && !seedUid) return []\n const db = BaseDb.getAppDb()\n if (!db) return []\n\n const baseList = await ItemProperty.all(\n { seedLocalId: seedLocalId ?? undefined, seedUid: seedUid ?? undefined },\n { waitForReady: true },\n )\n const _itemProperties: IItemProperty[] = [...(baseList as IItemProperty[])]\n\n const propertiesWithMetadata = new Set<string>()\n for (const p of baseList) {\n if (p.propertyName) propertiesWithMetadata.add(p.propertyName)\n }\n\n let modelName: string | undefined\n if (baseList.length > 0) {\n const first = baseList[0]\n modelName = first.modelName ?? (first as any).modelType\n if (modelName && typeof modelName === 'string') modelName = startCase(modelName)\n }\n if (!modelName) {\n const seedRecords = await db\n .select({ type: seeds.type })\n .from(seeds)\n .where(seedUid ? eq(seeds.uid, seedUid) : eq(seeds.localId, seedLocalId!))\n .limit(1)\n if (seedRecords.length > 0 && seedRecords[0].type) {\n modelName = startCase(seedRecords[0].type)\n }\n }\n\n const modelProperties: string[] = []\n if (modelName) {\n try {\n const { Model } = await import('@/Model/Model')\n const model = await Model.getByNameAsync(modelName)\n if (model?.properties) {\n for (const modelProperty of model.properties) {\n if (modelProperty.name) modelProperties.push(modelProperty.name)\n }\n }\n } catch (error) {\n propertiesLogger(`[useItemProperties] Error getting ModelProperties for ${modelName}:`, error)\n }\n }\n\n if (modelName && modelProperties.length > 0) {\n const resolvedSeedLocalId = baseList.length > 0 ? (baseList[0].seedLocalId ?? seedLocalId) : seedLocalId\n const resolvedSeedUid = baseList.length > 0 ? (baseList[0].seedUid ?? seedUid) : seedUid\n for (const propertyName of modelProperties) {\n if (propertiesWithMetadata.has(propertyName)) continue\n try {\n const itemProperty = ItemProperty.create(\n {\n propertyName,\n modelName,\n seedLocalId: resolvedSeedLocalId || undefined,\n seedUid: resolvedSeedUid || undefined,\n propertyValue: null,\n },\n { waitForReady: false },\n )\n if (itemProperty) _itemProperties.push(itemProperty as any as IItemProperty)\n } catch (error) {\n logger(`[useItemProperties] Error creating ItemProperty for missing property ${propertyName}:`, error)\n }\n }\n }\n\n if (seedLocalId || seedUid) {\n const seedRecords = await db\n .select({ createdAt: seeds.createdAt })\n .from(seeds)\n .where(seedUid ? eq(seeds.uid, seedUid) : eq(seeds.localId, seedLocalId!))\n .limit(1)\n if (seedRecords.length > 0 && seedRecords[0].createdAt) {\n const createdAtPropertyName = 'createdAt'\n const hasCreatedAtProperty = _itemProperties.some((p) => p.propertyName === createdAtPropertyName)\n if (!hasCreatedAtProperty && modelName) {\n try {\n const resolvedSeedLocalId = baseList.length > 0 ? (baseList[0].seedLocalId ?? seedLocalId) : seedLocalId\n const resolvedSeedUid = baseList.length > 0 ? (baseList[0].seedUid ?? seedUid) : seedUid\n const createdAtProperty = ItemProperty.create(\n {\n propertyName: createdAtPropertyName,\n modelName,\n seedLocalId: resolvedSeedLocalId || undefined,\n seedUid: resolvedSeedUid || undefined,\n propertyValue: seedRecords[0].createdAt.toString(),\n },\n { waitForReady: false },\n )\n if (createdAtProperty) _itemProperties.push(createdAtProperty as any as IItemProperty)\n } catch (error) {\n logger(`[useItemProperties] Error creating createdAt ItemProperty:`, error)\n }\n }\n }\n }\n\n return _itemProperties\n}\n\n/**\n * Hook to get all ItemProperty instances for a specific item\n * Can be called in multiple ways:\n * 1. With seedLocalId: useItemProperties({ seedLocalId })\n * 2. With seedUid: useItemProperties({ seedUid })\n * 3. With itemId: useItemProperties(itemId)\n * \n * Uses useLiveQuery to watch for changes in the metadata table and automatically\n * updates the returned ItemProperty instances when changes occur.\n * \n * @overload\n * @param props - Object with seedLocalId or seedUid\n * @returns Object with properties array, isLoading, and error\n * \n * @overload\n * @param itemId - The item ID (seedLocalId or seedUid)\n * @returns Object with properties array, isLoading, and error\n */\nexport function useItemProperties(props: {\n seedLocalId?: string\n seedUid?: string\n}): UseItemPropertiesReturn\nexport function useItemProperties(itemId: string): UseItemPropertiesReturn\nexport function useItemProperties(\n arg1: { seedLocalId?: string; seedUid?: string } | string\n): UseItemPropertiesReturn {\n\n const isClientReady = useIsClientReady()\n const queryClient = useQueryClient()\n const previousTableDataRef = useRef<string | undefined>(undefined)\n\n // Determine which lookup mode we're in based on arguments\n const lookupMode = useMemo(() => {\n if (typeof arg1 === 'string') {\n // String argument: itemId (assumed to be seedLocalId)\n return { type: 'itemId' as const, itemId: arg1 }\n } else if (typeof arg1 === 'object') {\n // Object argument: { seedLocalId/seedUid }\n return {\n type: 'identifiers' as const,\n seedLocalId: arg1.seedLocalId,\n seedUid: arg1.seedUid,\n }\n } else {\n return null\n }\n }, [arg1])\n\n // Determine seedLocalId and seedUid for query\n const seedLocalId = useMemo(() => {\n if (!lookupMode) return undefined\n if (lookupMode.type === 'itemId') {\n return lookupMode.itemId\n } else {\n return lookupMode.seedLocalId\n }\n }, [lookupMode])\n\n const seedUid = useMemo(() => {\n if (!lookupMode || lookupMode.type === 'itemId') return undefined\n return lookupMode.seedUid\n }, [lookupMode])\n\n const canonicalItemKey = seedLocalId ?? seedUid ?? ''\n const itemPropertiesQueryKey = useMemo(\n () => (['seed', 'itemProperties', canonicalItemKey] as const),\n [canonicalItemKey],\n )\n\n const {\n data: properties = [],\n isLoading,\n error: queryError,\n } = useQuery({\n queryKey: itemPropertiesQueryKey,\n queryFn: () => fetchItemPropertiesList(seedLocalId, seedUid),\n enabled: isClientReady && !!canonicalItemKey,\n })\n\n // Watch the metadata table for changes\n // Query metadata table directly and filter for latest records in JavaScript\n // This is simpler and works better with useLiveQuery than CTEs\n // Get db inside useMemo to avoid recreating query on each render\n // Drizzle query builders are new objects each time, but useMemo will only recreate\n // when dependencies change, which is what we want for reactive queries\n const propertiesQuery = useMemo(() => {\n if (!isClientReady || (!seedLocalId && !seedUid)) {\n propertiesLogger('[useItemProperties] Query: returning null (not ready or no identifiers)')\n return null\n }\n \n const db = BaseDb.getAppDb()\n if (!db) {\n propertiesLogger('[useItemProperties] Query: returning null (no db)')\n return null\n }\n \n propertiesLogger(`[useItemProperties] Query: creating query for seedLocalId=${seedLocalId}, seedUid=${seedUid}`)\n \n // Query metadata table directly - we'll filter for latest records in JavaScript\n const query = seedUid\n ? db\n .select({\n propertyName: metadata.propertyName,\n propertyValue: metadata.propertyValue,\n seedLocalId: metadata.seedLocalId,\n seedUid: metadata.seedUid,\n modelType: metadata.modelType,\n schemaUid: metadata.schemaUid,\n createdAt: metadata.createdAt,\n attestationCreatedAt: metadata.attestationCreatedAt,\n })\n .from(metadata)\n .where(\n and(\n eq(metadata.seedUid, seedUid),\n isNotNull(metadata.propertyName)\n )\n )\n : seedLocalId\n ? db\n .select({\n propertyName: metadata.propertyName,\n propertyValue: metadata.propertyValue,\n seedLocalId: metadata.seedLocalId,\n seedUid: metadata.seedUid,\n modelType: metadata.modelType,\n schemaUid: metadata.schemaUid,\n createdAt: metadata.createdAt,\n attestationCreatedAt: metadata.attestationCreatedAt,\n })\n .from(metadata)\n .where(\n and(\n eq(metadata.seedLocalId, seedLocalId),\n isNotNull(metadata.propertyName)\n )\n )\n : null\n \n propertiesLogger(`[useItemProperties] Query: created query object`, { queryType: seedUid ? 'seedUid' : 'seedLocalId' })\n return query\n }, [isClientReady, seedLocalId, seedUid])\n \n const rawPropertiesTableData = useLiveQuery<{\n propertyName: string | null\n propertyValue: string | null\n seedLocalId: string | null\n seedUid: string | null\n modelType: string | null\n schemaUid: string | null\n createdAt: number | null\n attestationCreatedAt: number | null\n }>(propertiesQuery)\n \n // Filter for latest records (one per propertyName) in JavaScript\n const propertiesTableData = useMemo(() => {\n if (!rawPropertiesTableData || rawPropertiesTableData.length === 0) {\n return []\n }\n\n // Group by propertyName and keep only the latest record for each\n const latestByProperty = new Map<string, typeof rawPropertiesTableData[0]>()\n \n for (const record of rawPropertiesTableData) {\n if (!record.propertyName) continue\n \n const existing = latestByProperty.get(record.propertyName)\n if (!existing) {\n latestByProperty.set(record.propertyName, record)\n } else {\n // Compare timestamps to find the latest\n const existingTime = existing.attestationCreatedAt || existing.createdAt || 0\n const currentTime = record.attestationCreatedAt || record.createdAt || 0\n if (currentTime > existingTime) {\n latestByProperty.set(record.propertyName, record)\n }\n }\n }\n\n return Array.from(latestByProperty.values())\n }, [rawPropertiesTableData])\n\n // Invalidate when metadata table data actually changes so useQuery refetches\n useEffect(() => {\n if (!isClientReady || (!seedLocalId && !seedUid) || propertiesTableData === undefined) return\n\n // Include propertyValue so value-only changes produce a different string and trigger invalidation\n const tableDataString = JSON.stringify(\n propertiesTableData\n .map((p) => ({\n propertyName: p.propertyName,\n propertyValue: p.propertyValue,\n seedLocalId: p.seedLocalId,\n seedUid: p.seedUid,\n }))\n .sort((a, b) => (a.propertyName || '').localeCompare(b.propertyName || ''))\n )\n\n if (previousTableDataRef.current === tableDataString) return\n previousTableDataRef.current = tableDataString\n\n // Invalidate when metadata table data changed (new/updated/removed props or value changes)\n // so useQuery refetches and UI shows latest values.\n if (propertiesTableData.length > 0) {\n queryClient.invalidateQueries({ queryKey: itemPropertiesQueryKey })\n }\n }, [isClientReady, propertiesTableData, properties, seedLocalId, seedUid, queryClient, itemPropertiesQueryKey])\n\n useEffect(() => {\n previousTableDataRef.current = undefined\n }, [seedLocalId, seedUid])\n\n return {\n properties,\n isLoading,\n error: queryError as Error | null,\n }\n}\n\nexport type UseCreateItemPropertyProps = {\n seedLocalId?: string\n seedUid?: string\n propertyName: string\n modelName: string\n propertyValue?: any\n versionLocalId?: string\n versionUid?: string\n [key: string]: any\n}\n\nexport type UseCreateItemPropertyReturn = {\n create: (props: UseCreateItemPropertyProps) => IItemProperty | undefined\n isLoading: boolean\n error: Error | null\n resetError: () => void\n}\n\n/**\n * Hook to create an ItemProperty with loading and error state.\n * create(props) creates a new property instance for an item; provide seedLocalId or seedUid, propertyName, and modelName.\n */\nexport const useCreateItemProperty = (): UseCreateItemPropertyReturn => {\n const subscriptionRef = useRef<Subscription | undefined>(undefined)\n const [isLoading, setIsLoading] = useState(false)\n const [error, setError] = useState<Error | null>(null)\n\n const resetError = useCallback(() => setError(null), [])\n\n const create = useCallback((props: UseCreateItemPropertyProps): IItemProperty | undefined => {\n if (!props.propertyName || (!props.seedLocalId && !props.seedUid) || !props.modelName) {\n const err = new Error('seedLocalId or seedUid, propertyName, and modelName are required')\n setError(err)\n return undefined\n }\n\n setError(null)\n setIsLoading(true)\n subscriptionRef.current?.unsubscribe()\n subscriptionRef.current = undefined\n\n const instance = ItemProperty.create(props, { waitForReady: false })\n if (!instance) {\n setError(new Error('Failed to create item property'))\n setIsLoading(false)\n return undefined\n }\n\n const subscription = instance.getService().subscribe((snapshot: any) => {\n if (snapshot?.value === 'error') {\n const err = (snapshot.context as any)?._loadingError?.error ?? new Error('Failed to create item property')\n setError(err instanceof Error ? err : new Error(String(err)))\n setIsLoading(false)\n }\n if (snapshot?.value === 'idle') {\n setError(null)\n setIsLoading(false)\n }\n })\n subscriptionRef.current = subscription\n return instance\n }, [])\n\n useEffect(() => {\n return () => {\n subscriptionRef.current?.unsubscribe()\n subscriptionRef.current = undefined\n }\n }, [])\n\n return {\n create,\n isLoading,\n error,\n resetError,\n }\n}\n\nexport type UseDestroyItemPropertyReturn = {\n destroy: (itemProperty: IItemProperty) => Promise<void>\n isLoading: boolean\n error: Error | null\n resetError: () => void\n}\n\nexport const useDestroyItemProperty = (): UseDestroyItemPropertyReturn => {\n const [currentInstance, setCurrentInstance] = useState<IItemProperty | null>(null)\n const [destroyState, setDestroyState] = useState<{ isLoading: boolean; error: Error | null }>({\n isLoading: false,\n error: null,\n })\n\n useEffect(() => {\n if (!currentInstance) {\n setDestroyState({ isLoading: false, error: null })\n return\n }\n const service = currentInstance.getService()\n const update = () => {\n const snap = service.getSnapshot() as unknown as {\n context: { _destroyInProgress?: boolean; _destroyError?: { message: string } | null }\n }\n const ctx = snap.context\n setDestroyState({\n isLoading: !!ctx._destroyInProgress,\n error: ctx._destroyError ? new Error(ctx._destroyError.message) : null,\n })\n }\n update()\n const sub = service.subscribe(update)\n return () => sub.unsubscribe()\n }, [currentInstance])\n\n const destroy = useCallback(async (itemProperty: IItemProperty) => {\n if (!itemProperty) return\n setCurrentInstance(itemProperty)\n await itemProperty.destroy()\n }, [])\n\n const resetError = useCallback(() => {\n if (currentInstance) {\n currentInstance.getService().send({ type: 'clearDestroyError' })\n }\n }, [currentInstance])\n\n return {\n destroy,\n isLoading: destroyState.isLoading,\n error: destroyState.error,\n resetError,\n }\n}\n","import { useCallback, useEffect, useState } from 'react'\nimport { ActorRef, InspectedEventEvent } from 'xstate'\nimport { orderBy } from 'lodash-es'\nimport { produce } from 'immer'\nimport { eventEmitter } from '@/eventBus'\nimport pluralize from 'pluralize'\nimport { useSelector } from '@xstate/react'\nimport debug from 'debug'\nimport { appState } from '@/seedSchema'\nimport { like } from 'drizzle-orm'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport { MachineIds, ClientManagerState } from '@/client/constants'\nimport { getClient } from '@/client/ClientManager'\n\nconst logger = debug('seedSdk:react:services')\n\nconst finalStrings = ['idle', 'ready', 'done', 'success', 'initialized']\n\nexport const getServiceName = (service: ActorRef<any, any>) => {\n let name = 'actor'\n const serviceAny = service as any\n if (service && serviceAny.uniqueKey) {\n name = serviceAny.uniqueKey\n }\n if (service && !serviceAny.uniqueKey && serviceAny.logic && serviceAny.logic.config) {\n name = getServiceUniqueKey(service)\n }\n return name\n}\n\nexport const getServiceValue = (\n service: ActorRef<any, any>,\n): string | undefined => {\n let value\n if (service && service.getSnapshot() && service.getSnapshot().value) {\n value = service.getSnapshot().value\n }\n if (getServiceName(service) === 'global') {\n if (\n value &&\n typeof value === 'object' &&\n Object.keys(value).length > 0 &&\n Object.keys(value)[0] === 'initialized'\n ) {\n value = 'ready'\n }\n }\n if (value && typeof value === 'object') {\n value = JSON.stringify(value)\n }\n return value\n}\n\nexport const getServiceUniqueKey = (service: ActorRef<any, any>) => {\n const serviceAny = service as any\n if (!service || !serviceAny.logic || !serviceAny.logic.config || !serviceAny._snapshot) {\n return\n }\n const config = serviceAny.logic.config\n if (!config.id) {\n return\n }\n let uniqueKey = config.id\n if (config.id.includes('@seedSdk/')) {\n uniqueKey = config.id.match(/^.*@seedSdk\\/(\\w+)[\\.\\w]*/)[1]\n }\n let snapshot\n try {\n snapshot = service.getSnapshot()\n } catch (error) {\n logger('Error:', error)\n return uniqueKey\n }\n if (snapshot) {\n const context = snapshot.context\n if (context && context.dbName) {\n uniqueKey = context.dbName\n }\n if (context && context.modelNamePlural) {\n uniqueKey = context.modelNamePlural\n }\n if (context && context.modelName) {\n uniqueKey = pluralize(context.modelName.toLowerCase())\n }\n }\n return uniqueKey\n}\n\nexport const useService = (service: ActorRef<any, any>) => {\n const [timeElapsed, setTimeElapsed] = useState(0)\n\n const getPercentComplete = (service: ActorRef<any, any>) => {\n let percentComplete = 0\n const serviceAny = service as any\n if (serviceAny.logic?.states) {\n const stateNames: string[] = []\n const startupStates: any[] = []\n\n for (const [stateName, state] of Object.entries(serviceAny.logic.states)) {\n const stateTyped = state as { tags?: string[] }\n if (stateTyped.tags?.includes('loading')) {\n stateNames.push(stateName)\n startupStates.push(state)\n }\n }\n\n const totalStates = startupStates.length\n const value = getServiceValue(service)\n if (value && finalStrings.includes(value)) {\n return 0\n }\n if (value) {\n const stateIndex = stateNames.indexOf(value)\n percentComplete = (stateIndex / totalStates) * 100\n }\n }\n return percentComplete\n }\n\n const updateTime = useCallback(\n (interval: ReturnType<typeof setInterval>) => {\n const context = service.getSnapshot().context\n const status = service.getSnapshot().value\n if (\n status === 'done' ||\n status === 'success' ||\n status === 'idle' ||\n status === 'ready'\n ) {\n clearInterval(interval)\n return\n }\n setTimeElapsed((timeElapsed) => timeElapsed + 1)\n },\n [service],\n )\n\n const startInterval = useCallback(() => {\n const interval = setInterval(() => {\n updateTime(interval)\n }, 1000)\n return interval\n }, [updateTime, service])\n\n useEffect(() => {\n const interval = startInterval()\n return () => clearInterval(interval)\n }, [])\n\n return {\n name: getServiceName(service),\n timeElapsed,\n value: getServiceValue(service),\n percentComplete: getPercentComplete(service),\n uniqueKey: getServiceUniqueKey(service),\n }\n}\n\nexport const useIsDbReady = () => {\n const [isDbReady, setIsDbReady] = useState(false)\n\n const { internalStatus } = useGlobalServiceStatus()\n\n useEffect(() => {\n if (internalStatus === 'ready') {\n setIsDbReady(true)\n }\n }, [internalStatus])\n\n useEffect(() => {\n if (internalStatus === 'ready') {\n setIsDbReady(true)\n }\n }, [])\n \n\n return isDbReady\n}\n\nexport const usePersistedSnapshots = () => {\n const [initialized, setInitialized] = useState(false)\n\n const hasSavedSnapshots = useHasSavedSnapshots()\n\n const { services, percentComplete } = useServices()\n\n // Helper function to save all actor snapshots to the database\n const save = useCallback(async () => {\n for (const actor of services) {\n const uniqueKey = getServiceUniqueKey(actor)\n logger(\n `would save to db with snapshot__${uniqueKey}:`,\n JSON.stringify(actor.getPersistedSnapshot()),\n )\n // await writeAppState(\n // `snapshot__${uniqueKey}`,\n // JSON.stringify(actor.getPersistedSnapshot()),\n // )\n }\n }, [services])\n\n // Helper function to load persisted snapshots from the database\n const load = useCallback(async () => {\n const appDb = BaseDb.getAppDb()\n\n if (!appDb) {\n return []\n }\n\n const persistedSnapshots = await appDb\n .select()\n .from(appState)\n .where(like(appState.key, 'snapshot__%'))\n return persistedSnapshots\n }, [])\n\n useEffect(() => {\n if (!hasSavedSnapshots || initialized) {\n return\n }\n const initialize = async () => {\n const persistedSnapshots = await load()\n logger('persistedSnapshots:', persistedSnapshots)\n setInitialized(true)\n }\n\n initialize()\n\n return () => {\n save() // Save snapshots on unmount\n }\n }, [hasSavedSnapshots, initialized])\n}\n\nexport const useHasSavedSnapshots = () => {\n const [hasSavedSnapshots, setHasSavedSnapshots] = useState(false)\n\n const isDbReady = useIsDbReady()\n\n useEffect(() => {\n if (isDbReady) {\n const _checkForSnapshots = async (): Promise<void> => {\n const appDb = BaseDb.getAppDb()\n\n const rows = await appDb\n .select()\n .from(appState)\n .where(like(appState.key, 'snapshot__%'))\n\n if (rows && rows.length > 0) {\n setHasSavedSnapshots(true)\n }\n }\n\n _checkForSnapshots()\n }\n }, [isDbReady])\n\n return hasSavedSnapshots\n}\n\nexport const useServices = () => {\n const [actors, setActors] = useState<ActorRef<any, any>[]>([])\n const [percentComplete, setPercentComplete] = useState(5)\n\n // Global service removed - now track ClientManager directly\n useEffect(() => {\n const clientManager = getClient()\n const clientService = clientManager.getService()\n \n // Add ClientManager to actors list\n const clientActor = clientService as any\n clientActor.uniqueKey = 'clientManager'\n \n setActors([clientActor])\n \n // Calculate percent complete based on ClientManager state\n const subscription = clientService.subscribe((snapshot) => {\n const state = snapshot.value\n // Calculate completion based on state progression\n let percent = 0\n if (state === ClientManagerState.IDLE) {\n percent = 100\n } else if (state === ClientManagerState.ADD_MODELS_TO_DB) {\n percent = 90\n } else if (state === ClientManagerState.ADD_MODELS_TO_STORE) {\n percent = 80\n } else if (state === ClientManagerState.PROCESS_SCHEMA_FILES) {\n percent = 70\n } else if (state === ClientManagerState.SAVE_CONFIG) {\n percent = 60\n } else if (state === ClientManagerState.DB_INIT) {\n percent = 50\n } else if (state === ClientManagerState.FILE_SYSTEM_INIT) {\n percent = 30\n } else if (state === ClientManagerState.PLATFORM_CLASSES_INIT) {\n percent = 10\n }\n setPercentComplete(percent)\n })\n \n return () => {\n subscription.unsubscribe()\n }\n }, [])\n\n return {\n services: actors,\n percentComplete,\n }\n}\n\nexport const useGlobalServiceStatus = () => {\n const clientManager = getClient()\n const clientService = clientManager.getService()\n\n const status = useSelector(clientService, (snapshot) => {\n return snapshot.value\n })\n\n // Internal service functionality is now part of ClientManager\n // DB is ready when ClientManager reaches DB_INIT or later states\n const internalStatus = useSelector(clientService, (snapshot) => {\n const state = snapshot.value\n if (state === ClientManagerState.DB_INIT || \n state === ClientManagerState.SAVE_CONFIG ||\n state === ClientManagerState.PROCESS_SCHEMA_FILES ||\n state === ClientManagerState.ADD_MODELS_TO_STORE ||\n state === ClientManagerState.ADD_MODELS_TO_DB ||\n state === ClientManagerState.IDLE) {\n return 'ready'\n }\n return state\n })\n\n return {\n status,\n internalStatus,\n }\n}\n","import { useCallback, useEffect, useState } from 'react'\nimport { Subscription } from 'xstate'\nimport { getClient } from '@/client/ClientManager'\nimport { ClientManagerState } from '@/client/constants'\nimport debug from 'debug'\n\nconst logger = debug('seedSdk:react:db')\n\nexport const useDbsAreReady = () => {\n const [dbsAreReady, setDbsAreReady] = useState(false)\n\n const update = useCallback(() => {\n if (dbsAreReady) {\n return\n }\n setDbsAreReady(true)\n }, [])\n\n useEffect(() => {\n let subscription: Subscription | undefined\n\n const _waitForDbs = async (): Promise<void> => {\n const clientManager = getClient()\n const clientService = clientManager.getService()\n \n const currentState = clientService.getSnapshot().value\n // DB is ready when ClientManager reaches DB_INIT state or later\n if (currentState === ClientManagerState.DB_INIT || \n currentState === ClientManagerState.SAVE_CONFIG ||\n currentState === ClientManagerState.PROCESS_SCHEMA_FILES ||\n currentState === ClientManagerState.ADD_MODELS_TO_STORE ||\n currentState === ClientManagerState.ADD_MODELS_TO_DB ||\n currentState === ClientManagerState.IDLE) {\n update()\n return\n }\n \n subscription = clientService.subscribe((snapshot) => {\n const state = snapshot.value\n if (state === ClientManagerState.DB_INIT || \n state === ClientManagerState.SAVE_CONFIG ||\n state === ClientManagerState.PROCESS_SCHEMA_FILES ||\n state === ClientManagerState.ADD_MODELS_TO_STORE ||\n state === ClientManagerState.ADD_MODELS_TO_DB ||\n state === ClientManagerState.IDLE) {\n update()\n subscription?.unsubscribe()\n }\n })\n }\n\n _waitForDbs()\n\n return () => {\n if (subscription) {\n subscription.unsubscribe()\n }\n }\n }, [])\n\n return {\n dbsAreReady,\n }\n}\n","import { loadAllSchemasFromDb, } from \"@/helpers/schema\"\nimport { useCallback, useEffect, useRef, useState, useMemo } from \"react\"\nimport { flushSync } from \"react-dom\"\nimport debug from \"debug\"\nimport { useIsClientReady } from \"./client\"\nimport { Schema } from \"@/Schema/Schema\"\nimport { SnapshotFrom, Subscription } from \"xstate\"\nimport { schemaMachine } from \"@/Schema/service/schemaMachine\"\nimport { SEED_PROTOCOL_SCHEMA_NAME } from \"@/helpers/constants\"\nimport { useLiveQuery } from \"./liveQuery\"\nimport { BaseDb } from \"@/db/Db/BaseDb\"\nimport { schemas as schemasTable } from \"@/seedSchema/SchemaSchema\"\nimport { desc } from \"drizzle-orm\"\nimport type { SchemaType as DbSchemaType } from \"@/seedSchema/SchemaSchema\"\nimport { useQuery, useQueryClient } from \"@tanstack/react-query\"\n\nconst logger = debug('seedSdk:react:schema')\n\n/**\n * Hook to get a Schema class instance (with setters) that is reactive\n * This allows you to edit schema properties directly like: schema.name = 'New name'\n * The schema instance uses a Proxy to ensure React re-renders when properties change\n * @param schemaIdentifier - The name of the schema or the schema file ID\n * - If a name is provided, retrieves the latest version with that name\n * - If an ID is provided, retrieves the specific schema by ID\n * @returns Object with schema instance\n */\nexport const useSchema = (schemaIdentifier: string | null | undefined) => {\n const [schema, setSchema] = useState<Schema | null>(null)\n const [isLoading, setIsLoading] = useState(schemaIdentifier ? true : false)\n const [error, setError] = useState<Error | null>(null)\n const subscriptionRef = useRef<Subscription | null>(null)\n\n const isClientReady = useIsClientReady()\n\n const loadSchema = useCallback((identifier: string) => {\n setIsLoading(true)\n setError(null)\n try {\n const schemaInstance = Schema.create(identifier, {\n waitForReady: false,\n }) as Schema\n setSchema(schemaInstance)\n\n const service = schemaInstance.getService()\n const initialSnapshot = service.getSnapshot()\n\n // Set initial loading state based on whether status is 'idle'\n const isIdle = initialSnapshot.value === 'idle'\n if (isIdle) {\n flushSync(() => setIsLoading(false))\n setError(null)\n } else {\n setIsLoading(true)\n }\n\n // Subscribe to all status changes and update isLoading based on whether status is 'idle'\n subscriptionRef.current = service.subscribe((snapshot: SchemaSnapshot) => {\n const isIdle = snapshot.value === 'idle'\n if (isIdle) {\n flushSync(() => setIsLoading(false))\n setError(null)\n } else {\n setIsLoading(true)\n }\n })\n\n } catch (error) {\n logger('[useSchema] Error creating schema:', error)\n setError(error as Error)\n setSchema(null)\n setIsLoading(false)\n return null\n }\n }, [])\n\n useEffect(() => {\n // Clean up previous subscription before starting a new load\n if (subscriptionRef.current) {\n subscriptionRef.current.unsubscribe()\n subscriptionRef.current = null\n }\n \n if (!isClientReady) {\n setSchema(null)\n setError(null)\n setIsLoading(false)\n return\n }\n if (!schemaIdentifier) {\n setSchema(null)\n setError(null)\n setIsLoading(false)\n return\n }\n\n loadSchema(schemaIdentifier)\n \n // Cleanup function to unsubscribe when effect re-runs or component unmounts\n return () => {\n if (subscriptionRef.current) {\n subscriptionRef.current.unsubscribe()\n subscriptionRef.current = null\n }\n }\n }, [schemaIdentifier, isClientReady, loadSchema])\n \n return {\n schema,\n isLoading,\n error,\n }\n\n}\n\nconst SEED_SCHEMAS_QUERY_KEY = ['seed', 'schemas'] as const\n\nexport const useSchemas = () => {\n const isClientReady = useIsClientReady()\n const queryClient = useQueryClient()\n const previousSchemasTableDataRef = useRef<DbSchemaType[] | undefined>(undefined)\n const schemasRef = useRef<Schema[]>([])\n\n const {\n data: schemas = [],\n isLoading,\n error: queryError,\n } = useQuery({\n queryKey: SEED_SCHEMAS_QUERY_KEY,\n queryFn: () => Schema.all({ waitForReady: true }),\n enabled: isClientReady,\n })\n schemasRef.current = schemas\n\n // Watch the schemas table for changes and invalidate so useQuery refetches\n const db = isClientReady ? BaseDb.getAppDb() : null\n const schemasQuery = useMemo(() => {\n if (!db) return null\n return db.select().from(schemasTable).orderBy(schemasTable.name, desc(schemasTable.version))\n }, [db, isClientReady])\n const schemasTableData = useLiveQuery<DbSchemaType>(schemasQuery)\n\n useEffect(() => {\n if (!isClientReady || !schemasTableData) {\n return\n }\n\n const prevData = previousSchemasTableDataRef.current\n const prevDataJson = prevData ? JSON.stringify(prevData) : 'undefined'\n const currDataJson = schemasTableData ? JSON.stringify(schemasTableData) : 'undefined'\n\n if (prevDataJson === currDataJson && prevData !== undefined) {\n return\n }\n\n previousSchemasTableDataRef.current = schemasTableData\n\n const currentSchemasSet = new Set<string>()\n for (const schema of schemasRef.current) {\n const schemaFileId = schema.id || schema.schemaFileId\n if (schemaFileId) {\n currentSchemasSet.add(schemaFileId)\n } else {\n const name = schema.metadata?.name\n const version = schema.version\n if (name && version !== undefined) {\n currentSchemasSet.add(`${name}:${version}`)\n }\n }\n }\n\n const tableDataSchemasSet = new Set<string>()\n for (const dbSchema of schemasTableData) {\n if (dbSchema.name === 'Seed Protocol') continue\n if (dbSchema.schemaFileId) {\n tableDataSchemasSet.add(dbSchema.schemaFileId)\n } else if (dbSchema.name != null && dbSchema.version !== undefined) {\n tableDataSchemasSet.add(`${dbSchema.name}:${dbSchema.version}`)\n }\n }\n\n const setsAreEqual =\n currentSchemasSet.size === tableDataSchemasSet.size &&\n [...currentSchemasSet].every((id) => tableDataSchemasSet.has(id))\n\n if (!setsAreEqual) {\n queryClient.invalidateQueries({ queryKey: SEED_SCHEMAS_QUERY_KEY })\n }\n }, [isClientReady, schemasTableData, queryClient])\n\n return {\n schemas,\n isLoading,\n error: queryError as Error | null,\n }\n}\n\nexport const useCreateSchema = () => {\n const subscriptionRef = useRef<{ unsubscribe: () => void } | null>(null)\n const [isLoading, setIsLoading] = useState(false)\n const [error, setError] = useState<Error | null>(null)\n\n const resetError = useCallback(() => setError(null), [])\n\n const createSchema = useCallback((schemaName: string) => {\n setError(null)\n setIsLoading(true)\n subscriptionRef.current?.unsubscribe()\n subscriptionRef.current = null\n const schema = Schema.create(schemaName, {\n waitForReady: false,\n }) as Schema\n const subscription = schema.getService().subscribe((snapshot: SchemaSnapshot) => {\n if (snapshot.value === 'error') {\n const err = snapshot.context._loadingError?.error\n setError(err instanceof Error ? err : new Error('Failed to create schema'))\n setIsLoading(false)\n }\n if (snapshot.value === 'idle') {\n setError(null)\n setIsLoading(false)\n }\n })\n subscriptionRef.current = subscription\n return schema\n }, [])\n\n useEffect(() => {\n return () => {\n subscriptionRef.current?.unsubscribe()\n subscriptionRef.current = null\n }\n }, [])\n\n return {\n createSchema,\n isLoading,\n error,\n resetError,\n }\n}\n\nexport type UseDestroySchemaReturn = {\n destroy: (schema: Schema) => Promise<void>\n isLoading: boolean\n error: Error | null\n resetError: () => void\n}\n\nexport const useDestroySchema = (): UseDestroySchemaReturn => {\n const [currentInstance, setCurrentInstance] = useState<Schema | null>(null)\n const [destroyState, setDestroyState] = useState<{ isLoading: boolean; error: Error | null }>({\n isLoading: false,\n error: null,\n })\n\n useEffect(() => {\n if (!currentInstance) {\n setDestroyState({ isLoading: false, error: null })\n return\n }\n const service = currentInstance.getService()\n const update = () => {\n const snap = service.getSnapshot()\n const ctx = snap.context as { _destroyInProgress?: boolean; _destroyError?: { message: string } | null }\n setDestroyState({\n isLoading: !!ctx._destroyInProgress,\n error: ctx._destroyError ? new Error(ctx._destroyError.message) : null,\n })\n }\n update()\n const sub = service.subscribe(update)\n return () => sub.unsubscribe()\n }, [currentInstance])\n\n const destroy = useCallback(async (schema: Schema) => {\n if (!schema) return\n setCurrentInstance(schema)\n await schema.destroy()\n }, [])\n\n const resetError = useCallback(() => {\n if (currentInstance) {\n currentInstance.getService().send({ type: 'clearDestroyError' })\n }\n }, [currentInstance])\n\n return {\n destroy,\n isLoading: destroyState.isLoading,\n error: destroyState.error,\n resetError,\n }\n}\n\nexport const useAllSchemaVersions = () => {\n const [schemaInstances, setSchemaInstances] = useState<Schema[] | undefined | null>()\n const schemaInstancesRef = useRef<Map<string, Schema>>(new Map())\n const isClientReady = useIsClientReady()\n\n const fetchSchemas = useCallback(async () => {\n if (!isClientReady) {\n return\n }\n\n try {\n // Use DB-first approach: load all schemas from database\n // This will also import any missing schemas from files\n const allSchemasData = await loadAllSchemasFromDb()\n\n // Extract unique schema names\n const schemaNames = new Set<string>()\n for (const schemaData of allSchemasData) {\n const schemaName = schemaData.schema.metadata?.name\n if (schemaName) {\n schemaNames.add(schemaName)\n }\n }\n\n // Create/update Schema instances\n const currentInstances = new Map<string, Schema>()\n \n for (const schemaName of schemaNames) {\n // Reuse existing instance if it exists\n if (schemaInstancesRef.current.has(schemaName)) {\n const existingInstance = schemaInstancesRef.current.get(schemaName)!\n currentInstances.set(schemaName, existingInstance)\n } else {\n // Create new instance\n const schema = Schema.create(schemaName, {\n waitForReady: false,\n }) as Schema\n currentInstances.set(schemaName, schema)\n }\n }\n\n // Cleanup instances that are no longer needed\n for (const [name, instance] of schemaInstancesRef.current.entries()) {\n if (!schemaNames.has(name)) {\n instance.unload()\n }\n }\n\n // Update ref and state\n schemaInstancesRef.current = currentInstances\n setSchemaInstances(Array.from(currentInstances.values()))\n } catch (error) {\n logger('Error fetching all schema versions from database:', error)\n setSchemaInstances(null)\n }\n }, [isClientReady])\n\n useEffect(() => {\n if (!isClientReady) {\n return\n }\n fetchSchemas()\n }, [isClientReady, fetchSchemas])\n\n // Cleanup on unmount\n useEffect(() => {\n return () => {\n schemaInstancesRef.current.forEach((instance) => {\n instance.unload()\n })\n schemaInstancesRef.current.clear()\n }\n }, [])\n\n return schemaInstances\n}\n\ntype SchemaSnapshot = SnapshotFrom<typeof schemaMachine>\n\n\n/**\n * Hook to get the internal Seed Protocol schema (SDK-only schema)\n * This schema is managed by the SDK and should not be edited by app developers\n * @returns Object with schema instance and schemaData (version, metadata, etc.)\n */\nexport const useSeedProtocolSchema = () => {\n return useSchema(SEED_PROTOCOL_SCHEMA_NAME)\n}","import { useMemo, useState, useEffect, useCallback, useRef } from 'react'\nimport { Model } from '@/Model/Model'\nimport { useIsClientReady } from './client'\nimport { useLiveQuery } from './liveQuery'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport { models as modelsTable } from '@/seedSchema/ModelSchema'\nimport { modelSchemas } from '@/seedSchema/ModelSchemaSchema'\nimport { schemas as schemasTable } from '@/seedSchema/SchemaSchema'\nimport { eq, or } from 'drizzle-orm'\nimport { Subscription } from 'xstate'\nimport { useQuery, useQueryClient } from '@tanstack/react-query'\n\ntype UseModelsResult = {\n models: Model[]\n isLoading: boolean\n error: Error | null\n}\n\ntype UseModelsParams = string | null | undefined\n\ntype UseModels = (schemaId: UseModelsParams) => UseModelsResult\n\n/**\n * Hook to get all Model instances for a specific schema\n * Uses useLiveQuery to watch for changes in the models table and automatically\n * updates the returned Model instances when changes occur.\n * @param schemaId - The schema ID (schema file ID) or schema name to get models from\n * @returns Array of Model instances belonging to the schema\n */\nconst getModelsQueryKey = (schemaId: UseModelsParams) => ['seed', 'models', schemaId] as const\n\n// Last-known-good models per schemaId so we never flash [] after remount or refetch race (survives component unmount).\nconst lastModelsBySchemaId = new Map<string, Model[]>()\n\nexport const useModels: UseModels = (schemaId) => {\n const isClientReady = useIsClientReady()\n const queryClient = useQueryClient()\n const modelsRef = useRef<Model[]>([])\n\n const queryKey = useMemo(() => getModelsQueryKey(schemaId), [schemaId])\n\n const {\n data: models = [],\n isLoading,\n error: queryError,\n } = useQuery({\n queryKey,\n queryFn: async () => {\n // Capture previous data before any async work so we don't overwrite good cache with [].\n const prev = queryClient.getQueryData<Model[]>(queryKey)\n // Use waitForReady: false so we return models as soon as they exist; waitForReady: true\n // filters to only idle models and can return [] while a model is in creatingProperties.\n const next = await Model.all(schemaId!, { waitForReady: false })\n // getModelsData can intermittently return [] after returning data; keep prev to avoid overwrite.\n if (Array.isArray(prev) && prev.length > 0 && Array.isArray(next) && next.length === 0) {\n return [...prev]\n }\n // If this refetch returned [], avoid overwriting non-empty cache (e.g. race where another refetch already wrote data).\n if (Array.isArray(next) && next.length === 0) {\n const current = queryClient.getQueryData<Model[]>(queryKey)\n if (Array.isArray(current) && current.length > 0) {\n return [...current]\n }\n }\n return next\n },\n enabled: isClientReady && !!schemaId,\n })\n // Never expose [] when we previously had models (avoids flash from refetch races, remounts, or intermittent getModelsData returning []).\n // When schemaId is null/undefined, always show [] — do not use fallback from a previous schema.\n const schemaIdKey = schemaId && typeof schemaId === 'string' ? schemaId : ''\n if (models.length > 0) {\n lastModelsBySchemaId.set(schemaIdKey, models)\n }\n const fallback = modelsRef.current.length > 0 ? modelsRef.current : lastModelsBySchemaId.get(schemaIdKey)\n const displayModels =\n !schemaId\n ? models\n : models.length > 0\n ? models\n : fallback?.length\n ? fallback\n : models\n modelsRef.current = displayModels\n\n // When a model is created, writeModelToDb posts to this channel; live query over join often doesn't re-run\n useEffect(() => {\n if (!schemaId || typeof BroadcastChannel === 'undefined') return\n const ch = new BroadcastChannel('seed-models-invalidate')\n const onMessage = (event: MessageEvent<{ schemaName?: string; schemaFileId?: string }>) => {\n const { schemaName, schemaFileId } = event.data || {}\n if (schemaId === schemaName || schemaId === schemaFileId) {\n queryClient.invalidateQueries({ queryKey })\n queryClient.refetchQueries({ queryKey })\n }\n }\n ch.addEventListener('message', onMessage)\n return () => {\n ch.removeEventListener('message', onMessage)\n ch.close()\n }\n }, [schemaId, queryClient, queryKey])\n\n // Stabilize query reference: only recreate when (schemaId, isClientReady) change, not when db reference changes.\n // This keeps the same liveQuery observable/subscription alive so effects can deliver updates when a new model is added.\n const stableModelsQueryKeyRef = useRef<{ schemaId: string; ready: boolean } | null>(null)\n const stableModelsQueryRef = useRef<ReturnType<typeof buildModelsQuery> | null>(null)\n function buildModelsQuery() {\n const currentDb = BaseDb.getAppDb()\n if (!currentDb || !schemaId) return null\n return currentDb\n .select({\n modelFileId: modelsTable.schemaFileId,\n modelName: modelsTable.name,\n })\n .from(schemasTable)\n .innerJoin(modelSchemas, eq(schemasTable.id, modelSchemas.schemaId))\n .innerJoin(modelsTable, eq(modelSchemas.modelId, modelsTable.id))\n .where(\n or(\n eq(schemasTable.schemaFileId, schemaId),\n eq(schemasTable.name, schemaId)\n )\n )\n }\n const modelsQuery = useMemo(() => {\n if (!schemaId || !isClientReady) return null\n const key = { schemaId, ready: isClientReady }\n const prevKey = stableModelsQueryKeyRef.current\n if (\n prevKey &&\n prevKey.schemaId === key.schemaId &&\n prevKey.ready === key.ready &&\n stableModelsQueryRef.current !== null\n ) {\n return stableModelsQueryRef.current\n }\n const q = buildModelsQuery()\n if (!q) return null\n stableModelsQueryKeyRef.current = key\n stableModelsQueryRef.current = q\n return q\n }, [schemaId, isClientReady])\n\n const modelsTableData = useLiveQuery<{ modelFileId: string | null; modelName: string }>(modelsQuery)\n\n useEffect(() => {\n if (!isClientReady || !modelsTableData || !schemaId) return\n\n const currentModelsSet = new Set<string>()\n for (const model of modelsRef.current) {\n const modelFileId = model.id || (model as any).modelFileId\n if (modelFileId) currentModelsSet.add(modelFileId)\n else if (model.modelName) currentModelsSet.add(model.modelName)\n }\n\n const tableDataModelsSet = new Set<string>()\n for (const dbModel of modelsTableData) {\n if (dbModel.modelFileId) tableDataModelsSet.add(dbModel.modelFileId)\n else if (dbModel.modelName) tableDataModelsSet.add(dbModel.modelName)\n }\n\n const setsAreEqual =\n currentModelsSet.size === tableDataModelsSet.size &&\n [...currentModelsSet].every((id) => tableDataModelsSet.has(id))\n\n // Only invalidate when the table has rows we might be missing (live query saw new data).\n // Do NOT invalidate when we have more than the table: the live query may not have updated\n // yet (e.g. join over model_schemas), and refetching would overwrite cache with [].\n const tableHasNewRows =\n tableDataModelsSet.size > 0 &&\n [...tableDataModelsSet].some((id) => !currentModelsSet.has(id))\n\n if (!setsAreEqual && tableHasNewRows) {\n queryClient.invalidateQueries({ queryKey })\n }\n }, [isClientReady, modelsTableData, schemaId, queryClient, queryKey])\n\n return {\n models: displayModels,\n isLoading,\n error: queryError as Error | null,\n }\n}\n\ntype UseModelResult = {\n model: Model | undefined\n isLoading: boolean\n error: Error | null\n}\n\n/**\n * Hook to get a specific Model instance\n * Can be called in two ways:\n * 1. With schemaId and modelName: useModel(schemaId, modelName)\n * 2. With modelId: useModel(modelId)\n * \n * @param schemaIdOrModelId - The schema ID (schema file ID) OR the model ID (modelFileId)\n * @param modelName - The name of the model to retrieve (required if first param is schemaId)\n * @returns Object with model, isLoading, and error\n */\nexport const useModel = (\n schemaIdOrModelId: string | null | undefined,\n modelName?: string | null | undefined\n): UseModelResult => {\n const isClientReady = useIsClientReady()\n const [model, setModel] = useState<Model | undefined>(undefined)\n const [isLoading, setIsLoading] = useState(false)\n const [error, setError] = useState<Error | null>(null)\n const subscriptionRef = useRef<Subscription | undefined>(undefined)\n const [, setVersion] = useState(0) // Version counter to force re-renders\n\n // If modelName is provided, treat first param as schemaId\n // Otherwise, treat first param as modelId\n const isModelIdLookup = modelName === undefined || modelName === null\n\n // Determine initial loading state\n const shouldLoad = useMemo(() => {\n if (!isClientReady) return false\n if (isModelIdLookup) {\n return !!schemaIdOrModelId\n } else {\n return !!(schemaIdOrModelId && modelName)\n }\n }, [isClientReady, isModelIdLookup, schemaIdOrModelId, modelName])\n\n // Lookup model by ID if needed\n useEffect(() => {\n if (!isClientReady || !isModelIdLookup || !schemaIdOrModelId) {\n setModel(undefined)\n setIsLoading(false)\n setError(null)\n return\n }\n\n const lookupModelById = async () => {\n try {\n setIsLoading(true)\n setError(null)\n // Use Model.createById which handles cache + DB lookup\n const foundModel = await Model.createById(schemaIdOrModelId)\n setModel(foundModel || undefined)\n setIsLoading(false)\n setError(null)\n } catch (error) {\n console.error('[useModel] Error looking up model by ID:', error)\n setModel(undefined)\n setIsLoading(false)\n setError(error as Error)\n }\n }\n\n lookupModelById()\n }, [isClientReady, isModelIdLookup, schemaIdOrModelId])\n\n // Subscribe to service changes when model is available (for modelId lookup)\n useEffect(() => {\n if (!isModelIdLookup || !model) {\n // Clean up subscription if model is not available\n subscriptionRef.current?.unsubscribe()\n subscriptionRef.current = undefined\n return\n }\n\n // Clean up previous subscription\n subscriptionRef.current?.unsubscribe()\n\n // Subscribe to service changes\n const subscription = model.getService().subscribe((snapshot) => {\n // Force re-render by incrementing version counter\n setVersion(prev => prev + 1)\n })\n \n subscriptionRef.current = subscription\n\n return () => {\n subscriptionRef.current?.unsubscribe()\n subscriptionRef.current = undefined\n }\n }, [isModelIdLookup, model])\n\n // If doing modelId lookup, return the model directly\n if (isModelIdLookup) {\n return {\n model,\n isLoading,\n error,\n }\n }\n\n // Otherwise, use schemaId + modelName lookup via useModels\n const { models: modelsList, isLoading: modelsLoading, error: modelsError } = useModels(schemaIdOrModelId)\n const foundModel = useMemo(() => {\n if (!modelName) {\n return undefined\n }\n // Try both modelName property and name getter for compatibility\n return modelsList.find((m: Model) => {\n const mName = m.modelName ?? (m as any).name\n return mName === modelName\n })\n }, [modelsList, modelName])\n\n // Subscribe to service changes when model is available (for schemaId + modelName lookup)\n useEffect(() => {\n if (isModelIdLookup || !foundModel) {\n // Clean up subscription if model is not available\n subscriptionRef.current?.unsubscribe()\n subscriptionRef.current = undefined\n return\n }\n\n // Clean up previous subscription\n subscriptionRef.current?.unsubscribe()\n\n // Subscribe to service changes\n const subscription = foundModel.getService().subscribe((snapshot) => {\n // Force re-render by incrementing version counter\n setVersion(prev => prev + 1)\n })\n \n subscriptionRef.current = subscription\n\n return () => {\n subscriptionRef.current?.unsubscribe()\n subscriptionRef.current = undefined\n }\n }, [isModelIdLookup, foundModel])\n\n // For schemaId + modelName lookup, derive loading/error from useModels\n return {\n model: foundModel,\n isLoading: modelsLoading,\n error: modelsError,\n }\n}\n\nexport type UseCreateModelOptions = {\n modelFileId?: string\n properties?: { [propertyName: string]: any }\n registerWithSchema?: boolean\n}\n\nexport type UseCreateModelReturn = {\n create: (\n schemaName: string,\n modelName: string,\n options?: UseCreateModelOptions\n ) => Model\n isLoading: boolean\n error: Error | null\n resetError: () => void\n}\n\nexport const useCreateModel = (): UseCreateModelReturn => {\n const subscriptionRef = useRef<Subscription | undefined>(undefined)\n const [isLoading, setIsLoading] = useState(false)\n const [error, setError] = useState<Error | null>(null)\n\n const resetError = useCallback(() => setError(null), [])\n\n const create = useCallback(\n (schemaName: string, modelName: string, options?: UseCreateModelOptions): Model => {\n setError(null)\n setIsLoading(true)\n subscriptionRef.current?.unsubscribe()\n subscriptionRef.current = undefined\n const model = Model.create(modelName, schemaName, {\n ...options,\n waitForReady: false,\n }) as import('@/Model/Model').Model\n const subscription = model.getService().subscribe((snapshot) => {\n if (snapshot.value === 'error') {\n setError(\n (snapshot.context as any)._loadingError?.error ??\n new Error('Failed to create model')\n )\n setIsLoading(false)\n }\n if (snapshot.value === 'idle') {\n setError(null)\n setIsLoading(false)\n }\n })\n subscriptionRef.current = subscription\n return model\n },\n []\n )\n\n useEffect(() => {\n return () => {\n subscriptionRef.current?.unsubscribe()\n subscriptionRef.current = undefined\n }\n }, [])\n\n return {\n create,\n isLoading,\n error,\n resetError,\n }\n}\n\nexport type UseDestroyModelReturn = {\n destroy: (model: Model) => Promise<void>\n isLoading: boolean\n error: Error | null\n resetError: () => void\n}\n\nexport const useDestroyModel = (): UseDestroyModelReturn => {\n const [currentInstance, setCurrentInstance] = useState<Model | null>(null)\n const [destroyState, setDestroyState] = useState<{ isLoading: boolean; error: Error | null }>({\n isLoading: false,\n error: null,\n })\n\n useEffect(() => {\n if (!currentInstance) {\n setDestroyState({ isLoading: false, error: null })\n return\n }\n const service = currentInstance.getService()\n const update = () => {\n const snap = service.getSnapshot()\n const ctx = snap.context as { _destroyInProgress?: boolean; _destroyError?: { message: string } | null }\n setDestroyState({\n isLoading: !!ctx._destroyInProgress,\n error: ctx._destroyError ? new Error(ctx._destroyError.message) : null,\n })\n }\n update()\n const sub = service.subscribe(update)\n return () => sub.unsubscribe()\n }, [currentInstance])\n\n const destroy = useCallback(async (model: Model) => {\n if (!model) return\n setCurrentInstance(model)\n await model.destroy()\n }, [])\n\n const resetError = useCallback(() => {\n if (currentInstance) {\n currentInstance.getService().send({ type: 'clearDestroyError' })\n }\n }, [currentInstance])\n\n return {\n destroy,\n isLoading: destroyState.isLoading,\n error: destroyState.error,\n resetError,\n }\n}","import { useModel } from \"./model\"\nimport { useCallback, useEffect, useRef, useState, useMemo } from \"react\"\nimport { flushSync } from \"react-dom\"\nimport { getPropertySchema } from \"@/helpers/property\"\nimport { ModelProperty } from \"@/ModelProperty/ModelProperty\"\nimport { useIsClientReady } from \"./client\"\nimport { Subscription } from \"xstate\"\nimport debug from \"debug\"\nimport { useLiveQuery } from \"./liveQuery\"\nimport { BaseDb } from \"@/db/Db/BaseDb\"\nimport { properties as propertiesTable, models as modelsTable } from \"@/seedSchema/ModelSchema\"\nimport { eq } from \"drizzle-orm\"\nimport { Model } from \"@/Model/Model\"\nimport { useQuery, useQueryClient } from \"@tanstack/react-query\"\n\nconst logger = debug('seedSdk:browser:react:modelProperty')\n\ntype UseModelPropertiesResult = {\n modelProperties: ModelProperty[]\n isLoading: boolean\n error: Error | null\n}\n\n/**\n * Hook to get all ModelProperty instances for a specific model\n * Can be called in two ways:\n * 1. With schemaId and modelName: useModelProperties(schemaId, modelName)\n * 2. With modelId: useModelProperties(modelId)\n * \n * Uses useLiveQuery to watch for changes in the properties table and automatically\n * updates the returned ModelProperty instances when changes occur.\n * \n * @param schemaIdOrModelId - The schema ID (schema file ID) OR the model ID (modelFileId)\n * @param modelName - The name of the model to get properties from (required if first param is schemaId)\n * @returns Object with modelProperties array, isLoading, and error\n */\nexport const useModelProperties = (\n schemaIdOrModelId: string | null | undefined,\n modelName?: string | null | undefined\n): UseModelPropertiesResult => {\n // Use useModel to handle both lookup patterns (by ID or by schemaId + modelName)\n const { model } = useModel(schemaIdOrModelId, modelName)\n \n // Determine the modelName for use in getPropertySchema\n const modelNameForProperty = useMemo(() => {\n if (!model) return undefined\n try {\n return model.modelName ?? (model as any).name\n } catch {\n return undefined\n }\n }, [model])\n const isClientReady = useIsClientReady()\n const queryClient = useQueryClient()\n\n // Get _dbId (database ID) from model context\n const dbModelId = useMemo(() => {\n if (!model) return null\n try {\n const context = (model as any)._getSnapshotContext()\n return context._dbId as number | undefined\n } catch {\n return null\n }\n }, [model])\n\n const modelId = model?.id\n const modelPropertiesQueryKey = useMemo(\n () => ['seed', 'modelProperties', modelId ?? ''] as const,\n [modelId],\n )\n\n const {\n data: modelProperties = [],\n isLoading,\n error: queryError,\n } = useQuery({\n queryKey: modelPropertiesQueryKey,\n queryFn: () => ModelProperty.all(modelId!, { waitForReady: true }),\n enabled: isClientReady && !!modelId,\n })\n\n const db = isClientReady ? BaseDb.getAppDb() : null\n const propertiesQuery = useMemo(() => {\n if (!db || !dbModelId) return null\n return db\n .select({\n id: propertiesTable.id,\n name: propertiesTable.name,\n dataType: propertiesTable.dataType,\n schemaFileId: propertiesTable.schemaFileId,\n })\n .from(propertiesTable)\n .where(eq(propertiesTable.modelId, dbModelId))\n }, [db, isClientReady, dbModelId])\n const propertiesTableData = useLiveQuery<{ id: number; name: string; dataType: string; schemaFileId: string | null }>(propertiesQuery)\n\n const modelPropertiesRef = useRef<ModelProperty[]>([])\n modelPropertiesRef.current = modelProperties\n\n // Fallback: when we have modelId but query returned [] (e.g. properties not in DB yet or\n // propertiesTableData is undefined because model._dbId isn't set yet), schedule refetches\n // so we pick up properties after they're written.\n useEffect(() => {\n if (!modelId || modelProperties.length > 0 || !queryClient || !modelPropertiesQueryKey) return\n const delays = [400, 1200, 2500]\n const timers = delays.map((ms) =>\n setTimeout(() => {\n queryClient.invalidateQueries({ queryKey: modelPropertiesQueryKey })\n }, ms)\n )\n return () => timers.forEach((t) => clearTimeout(t))\n }, [modelId, modelProperties.length, queryClient, modelPropertiesQueryKey])\n\n useEffect(() => {\n if (!isClientReady || !model?.id || !propertiesTableData || !modelPropertiesQueryKey) return\n\n const currentPropertiesSet = new Set<string>()\n for (const prop of modelPropertiesRef.current) {\n const context = (prop as any)._getSnapshotContext()\n const propertyFileId = context?.id\n if (propertyFileId) currentPropertiesSet.add(propertyFileId)\n else if (prop.name) currentPropertiesSet.add(prop.name)\n }\n\n const tableDataPropertiesSet = new Set<string>()\n for (const dbProperty of propertiesTableData) {\n if (dbProperty.schemaFileId) tableDataPropertiesSet.add(dbProperty.schemaFileId)\n else if (dbProperty.name) tableDataPropertiesSet.add(dbProperty.name)\n }\n\n const setsAreEqual =\n currentPropertiesSet.size === tableDataPropertiesSet.size &&\n (currentPropertiesSet.size === 0 ||\n [...currentPropertiesSet].every((id) => tableDataPropertiesSet.has(id)))\n\n // Invalidate when cached list is out of sync with the table: either we have stale cached data\n // (currentPropertiesSet.size > 0) or the table has new rows we don't have yet (tableDataPropertiesSet.size > 0).\n // The latter handles the case where the initial query returned [] before properties were written.\n const shouldInvalidate =\n !setsAreEqual && (currentPropertiesSet.size > 0 || tableDataPropertiesSet.size > 0)\n\n if (shouldInvalidate) {\n queryClient.invalidateQueries({ queryKey: modelPropertiesQueryKey })\n }\n }, [isClientReady, propertiesTableData, model?.id, queryClient, modelPropertiesQueryKey])\n\n return {\n modelProperties,\n isLoading,\n error: queryError as Error | null,\n }\n}\n\n/**\n * Helper function to get property schema by modelFileId and propertyName\n */\nconst getPropertySchemaByModelFileId = async (\n modelFileId: string,\n propertyName: string\n): Promise<ReturnType<typeof getPropertySchema>> => {\n // Get model by modelFileId\n const model = await Model.createById(modelFileId)\n if (!model) {\n return undefined\n }\n\n // Get modelName from model\n const modelName = model.modelName ?? (model as any).name\n if (!modelName) {\n return undefined\n }\n\n // Use existing getPropertySchema function\n return getPropertySchema(modelName, propertyName)\n}\n\n/**\n * Hook to get a specific ModelProperty instance\n * Can be called in three ways:\n * 1. With propertyFileId: useModelProperty(propertyFileId)\n * 2. With modelFileId and propertyName: useModelProperty(modelFileId, propertyName)\n * 3. With schemaId, modelName, and propertyName: useModelProperty(schemaId, modelName, propertyName)\n * \n * @overload\n * @param propertyFileId - The property file ID (schemaFileId)\n * @returns Object with modelProperty, isLoading, and error\n * \n * @overload\n * @param modelFileId - The model file ID (modelFileId)\n * @param propertyName - The name of the property\n * @returns Object with modelProperty, isLoading, and error\n * \n * @overload\n * @param schemaId - The schema ID (schema file ID)\n * @param modelName - The name of the model\n * @param propertyName - The name of the property\n * @returns Object with modelProperty, isLoading, and error\n */\nexport function useModelProperty(propertyFileId: string): {\n modelProperty: ModelProperty | undefined\n isLoading: boolean\n error: Error | null\n}\nexport function useModelProperty(\n modelFileId: string,\n propertyName: string\n): {\n modelProperty: ModelProperty | undefined\n isLoading: boolean\n error: Error | null\n}\nexport function useModelProperty(\n schemaId: string,\n modelName: string,\n propertyName: string\n): {\n modelProperty: ModelProperty | undefined\n isLoading: boolean\n error: Error | null\n}\nexport function useModelProperty(\n arg1: string | null | undefined,\n arg2?: string | null | undefined,\n arg3?: string | null | undefined\n) {\n // Determine initial loading state - start loading if we have valid parameters\n const initialLoadingState = useMemo(() => {\n if (arg3 !== undefined && arg3 !== null) {\n // Three arguments: schemaId, modelName, propertyName\n return !!(arg1 && arg2 && arg3)\n } else if (arg2 !== undefined && arg2 !== null) {\n // Two arguments: modelFileId, propertyName\n return !!(arg1 && arg2)\n } else {\n // One argument: propertyFileId\n return !!arg1\n }\n }, [arg1, arg2, arg3])\n\n const [modelProperty, setModelProperty] = useState<ModelProperty | undefined>(undefined)\n const [isLoading, setIsLoading] = useState(initialLoadingState)\n const [error, setError] = useState<Error | null>(null)\n const subscriptionRef = useRef<Subscription | undefined>(undefined)\n\n const isClientReady = useIsClientReady()\n\n // Determine which lookup mode we're in based on arguments\n const lookupMode = useMemo(() => {\n if (arg3 !== undefined && arg3 !== null) {\n // Three arguments: schemaId, modelName, propertyName\n return { type: 'schemaId' as const, schemaId: arg1, modelName: arg2, propertyName: arg3 }\n } else if (arg2 !== undefined && arg2 !== null) {\n // Two arguments: modelFileId, propertyName\n return { type: 'modelFileId' as const, modelFileId: arg1, propertyName: arg2 }\n } else {\n // One argument: propertyFileId\n return { type: 'propertyFileId' as const, propertyFileId: arg1 }\n }\n }, [arg1, arg2, arg3])\n\n // Determine if we should be loading based on parameters\n const shouldLoad = useMemo(() => {\n if (!isClientReady) return false\n if (lookupMode.type === 'propertyFileId') {\n return !!lookupMode.propertyFileId\n } else if (lookupMode.type === 'modelFileId') {\n return !!(lookupMode.modelFileId && lookupMode.propertyName)\n } else {\n return !!(lookupMode.schemaId && lookupMode.modelName && lookupMode.propertyName)\n }\n }, [isClientReady, lookupMode])\n\n const updateModelProperty = useCallback(async () => {\n if (!isClientReady) {\n setModelProperty(undefined)\n setIsLoading(false)\n setError(null)\n return\n }\n\n let propertyData: Awaited<ReturnType<typeof getPropertySchema>> | undefined\n let resolvedModelName: string | undefined\n\n try {\n setIsLoading(true)\n setError(null)\n\n if (lookupMode.type === 'propertyFileId') {\n if (!lookupMode.propertyFileId) {\n setModelProperty(undefined)\n setIsLoading(false)\n setError(null)\n return\n }\n\n // Use ModelProperty.createById for propertyFileId lookup\n const foundProperty = await ModelProperty.createById(lookupMode.propertyFileId)\n if (foundProperty) {\n setModelProperty(foundProperty)\n setIsLoading(false)\n setError(null)\n } else {\n setModelProperty(undefined)\n setIsLoading(false)\n setError(null)\n }\n return\n } else if (lookupMode.type === 'modelFileId') {\n if (!lookupMode.modelFileId || !lookupMode.propertyName) {\n setModelProperty(undefined)\n setIsLoading(false)\n setError(null)\n return\n }\n\n // Get property schema by modelFileId and propertyName\n // This function already gets the model and resolves modelName\n propertyData = await getPropertySchemaByModelFileId(lookupMode.modelFileId, lookupMode.propertyName)\n \n // Get modelName from model (needed for ModelProperty.create)\n const model = await Model.createById(lookupMode.modelFileId)\n resolvedModelName = model?.modelName ?? (model as any)?.name\n } else {\n // lookupMode.type === 'schemaId'\n if (!lookupMode.schemaId || !lookupMode.modelName || !lookupMode.propertyName) {\n setModelProperty(undefined)\n setIsLoading(false)\n setError(null)\n return\n }\n\n // Use existing getPropertySchema for schemaId + modelName + propertyName\n propertyData = await getPropertySchema(lookupMode.modelName, lookupMode.propertyName)\n resolvedModelName = lookupMode.modelName\n }\n\n if (propertyData && resolvedModelName) {\n const createdProperty = ModelProperty.create(\n { ...propertyData, modelName: resolvedModelName },\n { waitForReady: false }\n )\n const resolvedProperty = createdProperty instanceof Promise ? await createdProperty : createdProperty\n flushSync(() => {\n setModelProperty(resolvedProperty)\n setIsLoading(false)\n setError(null)\n })\n } else {\n setModelProperty(undefined)\n setIsLoading(false)\n setError(null)\n }\n } catch (error) {\n console.error('[useModelProperty] Error updating model property:', error)\n setModelProperty(undefined)\n setIsLoading(false)\n setError(error as Error)\n }\n }, [isClientReady, lookupMode.type, lookupMode.propertyFileId, lookupMode.modelFileId, lookupMode.propertyName, lookupMode.schemaId, lookupMode.modelName])\n\n // Fetch/refetch when lookup parameters change or client becomes ready\n useEffect(() => {\n if (!shouldLoad) {\n setModelProperty(undefined)\n setIsLoading(false)\n setError(null)\n return\n }\n updateModelProperty()\n }, [shouldLoad, updateModelProperty])\n\n // Subscribe to service changes when modelProperty is available.\n // Skip subscription for schemaId/modelFileId lookups where we created the instance locally—\n // refetching on every snapshot would set loading and can race with the initial render.\n const shouldSubscribe = lookupMode.type === 'propertyFileId'\n useEffect(() => {\n if (!modelProperty || !shouldSubscribe) {\n return\n }\n\n // Clean up previous subscription\n subscriptionRef.current?.unsubscribe()\n\n // Subscribe to service changes\n const subscription = modelProperty.getService().subscribe((snapshot) => {\n updateModelProperty()\n })\n \n subscriptionRef.current = subscription\n\n return () => {\n subscriptionRef.current?.unsubscribe()\n subscriptionRef.current = undefined\n }\n }, [modelProperty, updateModelProperty, shouldSubscribe])\n\n return {\n modelProperty,\n isLoading,\n error,\n }\n}\n\nexport type UseCreateModelPropertyOptions = {\n name: string\n dataType: string\n [key: string]: any\n}\n\nexport type UseCreateModelPropertyReturn = {\n create: (\n schemaId: string,\n modelName: string,\n property: UseCreateModelPropertyOptions\n ) => ModelProperty\n isLoading: boolean\n error: Error | null\n resetError: () => void\n}\n\n/**\n * Hook to create a ModelProperty with loading and error state.\n * create(schemaId, modelName, property) creates a new property on the model.\n */\nexport const useCreateModelProperty = (): UseCreateModelPropertyReturn => {\n const subscriptionRef = useRef<Subscription | undefined>(undefined)\n const [isLoading, setIsLoading] = useState(false)\n const [error, setError] = useState<Error | null>(null)\n\n const resetError = useCallback(() => setError(null), [])\n\n const create = useCallback(\n (\n _schemaId: string,\n modelName: string,\n property: UseCreateModelPropertyOptions\n ): ModelProperty => {\n setError(null)\n setIsLoading(true)\n subscriptionRef.current?.unsubscribe()\n subscriptionRef.current = undefined\n\n if (!modelName || !property.name || !property.dataType) {\n const err = new Error('modelName, property name and dataType are required')\n setError(err)\n setIsLoading(false)\n throw err\n }\n\n const created = ModelProperty.create(\n { ...property, modelName } as Parameters<typeof ModelProperty.create>[0],\n { waitForReady: false }\n ) as ModelProperty\n const subscription = created.getService().subscribe((snapshot) => {\n if ((snapshot as { value?: string }).value === 'error') {\n const err = (snapshot.context as any)._loadingError?.error ?? new Error('Failed to create model property')\n setError(err instanceof Error ? err : new Error(String(err)))\n setIsLoading(false)\n }\n if (snapshot.value === 'idle') {\n setError(null)\n setIsLoading(false)\n }\n })\n subscriptionRef.current = subscription\n return created\n },\n []\n )\n\n useEffect(() => {\n return () => {\n subscriptionRef.current?.unsubscribe()\n subscriptionRef.current = undefined\n }\n }, [])\n\n return {\n create,\n isLoading,\n error,\n resetError,\n }\n}\n\nexport type UseDestroyModelPropertyReturn = {\n destroy: (modelProperty: ModelProperty) => Promise<void>\n isLoading: boolean\n error: Error | null\n resetError: () => void\n}\n\nexport const useDestroyModelProperty = (): UseDestroyModelPropertyReturn => {\n const [currentInstance, setCurrentInstance] = useState<ModelProperty | null>(null)\n const [destroyState, setDestroyState] = useState<{ isLoading: boolean; error: Error | null }>({\n isLoading: false,\n error: null,\n })\n\n useEffect(() => {\n if (!currentInstance) {\n setDestroyState({ isLoading: false, error: null })\n return\n }\n const service = currentInstance.getService()\n const update = () => {\n const snap = service.getSnapshot()\n const ctx = snap.context as { _destroyInProgress?: boolean; _destroyError?: { message: string } | null }\n setDestroyState({\n isLoading: !!ctx._destroyInProgress,\n error: ctx._destroyError ? new Error(ctx._destroyError.message) : null,\n })\n }\n update()\n const sub = service.subscribe(update)\n return () => sub.unsubscribe()\n }, [currentInstance])\n\n const destroy = useCallback(async (modelProperty: ModelProperty) => {\n if (!modelProperty) return\n setCurrentInstance(modelProperty)\n await modelProperty.destroy()\n }, [])\n\n const resetError = useCallback(() => {\n if (currentInstance) {\n currentInstance.getService().send({ type: 'clearDestroyError' })\n }\n }, [currentInstance])\n\n return {\n destroy,\n isLoading: destroyState.isLoading,\n error: destroyState.error,\n resetError,\n }\n}","import { useCallback, useEffect, useState } from 'react'\nimport { Item } from '@/Item/Item'\n\nexport type UseDeleteItemReturn = {\n deleteItem: (item: Item<any>) => Promise<void>\n isLoading: boolean\n error: Error | null\n resetError: () => void\n}\n\nexport const useDeleteItem = (): UseDeleteItemReturn => {\n const [currentInstance, setCurrentInstance] = useState<Item<any> | null>(null)\n const [destroyState, setDestroyState] = useState<{ isLoading: boolean; error: Error | null }>({\n isLoading: false,\n error: null,\n })\n\n useEffect(() => {\n if (!currentInstance) {\n setDestroyState({ isLoading: false, error: null })\n return\n }\n const service = currentInstance.getService()\n const update = () => {\n const snap = service.getSnapshot()\n const ctx = snap.context as { _destroyInProgress?: boolean; _destroyError?: { message: string } | null }\n setDestroyState({\n isLoading: !!ctx._destroyInProgress,\n error: ctx._destroyError ? new Error(ctx._destroyError.message) : null,\n })\n }\n update()\n const sub = service.subscribe(update)\n return () => sub.unsubscribe()\n }, [currentInstance])\n\n const destroy = useCallback(async (item: Item<any>) => {\n if (!item) return\n setCurrentInstance(item)\n await item.destroy()\n }, [])\n\n const resetError = useCallback(() => {\n if (currentInstance) {\n currentInstance.getService().send({ type: 'clearDestroyError' })\n }\n }, [currentInstance])\n\n return {\n deleteItem: destroy,\n isLoading: destroyState.isLoading,\n error: destroyState.error,\n resetError,\n }\n}\n","import {\n type QueryClient,\n type DefaultOptions,\n QueryClient as ReactQueryClient,\n type QueryClientConfig,\n NetworkMode,\n} from '@tanstack/react-query'\n\nconst SEED_QUERY_DEFAULT_OPTIONS: DefaultOptions = {\n queries: {\n networkMode: 'offlineFirst' as NetworkMode,\n gcTime: 1000 * 60 * 60 * 24, // 24 hours\n staleTime: 1000 * 60, // 1 minute - list data can be slightly stale\n },\n}\n\n/**\n * Returns the default options used by Seed for list-query caching.\n * Use this when building your own QueryClient so Seed hooks get consistent behavior.\n */\nexport function getSeedQueryDefaultOptions(): DefaultOptions {\n return { ...SEED_QUERY_DEFAULT_OPTIONS }\n}\n\n/**\n * Merges Seed's default query options with your existing default options.\n * Your options take precedence over Seed's. Use when constructing your own QueryClient:\n *\n * @example\n * ```ts\n * const client = new QueryClient({\n * defaultOptions: mergeSeedQueryDefaults({\n * queries: { gcTime: 1000 * 60 * 60 },\n * }),\n * })\n * ```\n */\nexport function mergeSeedQueryDefaults(\n userOptions?: Partial<DefaultOptions> | null\n): DefaultOptions {\n const seed = getSeedQueryDefaultOptions()\n if (!userOptions) return seed\n return {\n queries: {\n ...seed.queries,\n ...(userOptions.queries ?? {}),\n },\n mutations: {\n ...(seed.mutations ?? {}),\n ...(userOptions.mutations ?? {}),\n },\n }\n}\n\n/**\n * Creates a QueryClient configured with Seed's default options.\n * Use this when you want to provide your own QueryClientProvider but still use Seed's defaults.\n *\n * @param overrides - Optional config to merge with Seed defaults (e.g. defaultOptions, logger).\n */\nexport function createSeedQueryClient(overrides?: Partial<QueryClientConfig>): QueryClient {\n const defaults = getSeedQueryDefaultOptions()\n const { defaultOptions: userDefaultOptions, ...restOverrides } = overrides ?? {}\n return new ReactQueryClient({\n ...restOverrides,\n defaultOptions: userDefaultOptions\n ? mergeSeedQueryDefaults(userDefaultOptions as DefaultOptions)\n : defaults,\n })\n}\n","import React, { type ReactNode, useMemo, useEffect } from 'react'\nimport { QueryClientProvider } from '@tanstack/react-query'\nimport type { QueryClient } from '@tanstack/react-query'\nimport { createSeedQueryClient } from './queryClient'\nimport { eventEmitter } from '@/eventBus'\n\nexport type SeedProviderProps = {\n children: ReactNode\n /** Optional: use your own QueryClient. If not provided, a default client with Seed options is created. */\n queryClient?: QueryClient\n /** Optional: ref to receive the QueryClient instance (e.g. for tests). */\n queryClientRef?: React.MutableRefObject<QueryClient | null>\n}\n\ndeclare global {\n interface Window {\n __SEED_INVALIDATE_ITEM_PROPERTIES__?: ((canonicalId: string) => void) | null\n }\n}\n\n/** Module-level ref so invalidateItemPropertiesForItem works when test and app share the same bundle but not the same window (e.g. iframe). */\nlet invalidateItemPropertiesRef: ((canonicalId: string) => void | Promise<void>) | null = null\n\n/**\n * Invalidates and refetches the item-properties query for an item.\n * Call this after updating an ItemProperty (e.g. after save()) so useItemProperties\n * refetches and the UI updates. Returns a Promise that resolves when the refetch has completed (if available).\n */\nexport function invalidateItemPropertiesForItem(canonicalId: string): Promise<void> {\n const p1 = invalidateItemPropertiesRef?.(canonicalId)\n if (typeof window !== 'undefined' && window.__SEED_INVALIDATE_ITEM_PROPERTIES__) {\n window.__SEED_INVALIDATE_ITEM_PROPERTIES__(canonicalId)\n }\n return Promise.resolve(p1).then(() => {})\n}\n\nfunction SeedProviderEventSubscriber({ queryClient }: { queryClient: QueryClient }) {\n useEffect(() => {\n const invalidate = (canonicalId: string) => {\n const key: readonly [string, string, string] = ['seed', 'itemProperties', canonicalId]\n queryClient.invalidateQueries({ queryKey: key })\n return queryClient.refetchQueries({ queryKey: key })\n }\n invalidateItemPropertiesRef = invalidate\n if (typeof window !== 'undefined') {\n window.__SEED_INVALIDATE_ITEM_PROPERTIES__ = invalidate\n }\n const handler = (payload: { seedLocalId?: string; seedUid?: string }) => {\n const canonicalId = payload?.seedLocalId ?? payload?.seedUid\n if (canonicalId) {\n invalidate(canonicalId)\n }\n }\n eventEmitter.on('itemProperty.saved', handler)\n return () => {\n eventEmitter.off('itemProperty.saved', handler)\n invalidateItemPropertiesRef = null\n if (typeof window !== 'undefined') {\n window.__SEED_INVALIDATE_ITEM_PROPERTIES__ = null\n }\n }\n }, [queryClient])\n return null\n}\n\n/**\n * Provider that supplies a React Query client to Seed list hooks (useSchemas, useItems, useModels, etc.)\n * so results are cached and shared across components. Wrap your app (or the subtree that uses Seed hooks)\n * after calling client.init().\n *\n * - No props: uses an internal QueryClient with Seed defaults.\n * - queryClient prop: use your own client (e.g. merge getSeedQueryDefaultOptions when creating it).\n */\nexport function SeedProvider({ children, queryClient: queryClientProp, queryClientRef }: SeedProviderProps) {\n const queryClient = useMemo(\n () => queryClientProp ?? createSeedQueryClient(),\n [queryClientProp]\n )\n if (queryClientRef) {\n queryClientRef.current = queryClient\n if (typeof window !== 'undefined') {\n const w = window as { __TEST_SEED_QUERY_CLIENT__?: QueryClient }\n w.__TEST_SEED_QUERY_CLIENT__ = queryClient\n try {\n if (window.parent && window.parent !== window) (window.parent as { __TEST_SEED_QUERY_CLIENT__?: QueryClient }).__TEST_SEED_QUERY_CLIENT__ = queryClient\n } catch {\n // cross-origin frame, ignore\n }\n }\n }\n return (\n <QueryClientProvider client={queryClient}>\n <SeedProviderEventSubscriber queryClient={queryClient} />\n {children}\n </QueryClientProvider>\n )\n}\n","import { getSeedsBySchemaName, getItemVersionsFromEas, getItemPropertiesFromEas } from \"./eas\"\nimport { Attestation } from \"./graphql/gql/graphql\"\nimport { setSchemaUidForSchemaDefinition } from \"./stores/eas\"\nimport { BaseEasClient, parseEasRelationPropertyName } from \"./helpers\"\nimport { BaseArweaveClient } from \"./helpers/ArweaveClient/BaseArweaveClient\"\nimport { GET_SEEDS } from \"./Item/queries\"\nimport debug from 'debug'\n\nconst logger = debug('seedSdk:feed')\n\nconst relationValuesToExclude = [\n '0x0000000000000000000000000000000000000000000000000000000000000020',\n]\n\n// Helper to convert snake_case to camelCase\nconst toCamelCase = (str: string): string => {\n return str.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase())\n}\n\n// Helper to format timestamp as RFC 822 date string for RSS pubDate\nconst formatRfc822Date = (timestamp: number): string => {\n const date = new Date(timestamp * 1000) // Convert from seconds to milliseconds\n const days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']\n const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']\n \n const day = days[date.getUTCDay()]\n const month = months[date.getUTCMonth()]\n const year = date.getUTCFullYear()\n const dayNum = date.getUTCDate().toString().padStart(2, '0')\n const hours = date.getUTCHours().toString().padStart(2, '0')\n const minutes = date.getUTCMinutes().toString().padStart(2, '0')\n const seconds = date.getUTCSeconds().toString().padStart(2, '0')\n \n return `${day}, ${dayNum} ${month} ${year} ${hours}:${minutes}:${seconds} GMT`\n}\n\n// Helper to set default values for feed items\nconst setFeedItemDefaults = (item: Record<string, any>, seedUid: string, schemaName: string): void => {\n // Set default title if not present (check both snake_case and camelCase)\n if (!item.title && !item.Title) {\n item.title = seedUid\n item.Title = seedUid // Also set camelCase version\n } else if (item.title && !item.Title) {\n item.Title = item.title\n } else if (item.Title && !item.title) {\n item.title = item.Title\n }\n \n // Set default link/guid using seedUid or storage_transaction_id\n // Handle empty strings, null, and undefined - check both formats\n const storageTransactionIdSnake = item.storage_transaction_id && \n typeof item.storage_transaction_id === 'string' && \n item.storage_transaction_id.trim() !== '' && \n item.storage_transaction_id !== 'undefined' &&\n item.storage_transaction_id !== seedUid // Don't use seedUid as transaction ID\n ? item.storage_transaction_id.trim() \n : null\n const storageTransactionIdCamel = item.storageTransactionId && \n typeof item.storageTransactionId === 'string' && \n item.storageTransactionId.trim() !== '' && \n item.storageTransactionId !== 'undefined' &&\n item.storageTransactionId !== seedUid // Don't use seedUid as transaction ID\n ? item.storageTransactionId.trim() \n : null\n const storageTransactionId = storageTransactionIdSnake || storageTransactionIdCamel\n \n console.log('[feed] [setFeedItemDefaults] Setting defaults for item:', {\n seedUid,\n schemaName,\n hasStorageTransactionIdSnake: !!storageTransactionIdSnake,\n hasStorageTransactionIdCamel: !!storageTransactionIdCamel,\n storageTransactionIdSnakeValue: item.storage_transaction_id,\n storageTransactionIdCamelValue: item.storageTransactionId,\n storageTransactionId,\n itemKeys: Object.keys(item),\n })\n \n // If there's a valid storageTransactionId (not seedUid), use Arweave URL for the link\n // Otherwise, build URL based on schema name (e.g., /images/ for image schema, /posts/ for post schema)\n let defaultLink: string\n if (storageTransactionId && storageTransactionId !== seedUid && storageTransactionId.length > 0) {\n try {\n defaultLink = BaseArweaveClient.getRawUrl(storageTransactionId)\n console.log('[feed] [setFeedItemDefaults] Using Arweave URL for storageTransactionId:', defaultLink)\n } catch (error) {\n console.error('[feed] [setFeedItemDefaults] Error generating Arweave URL:', error)\n // Fallback to default link format\n const basePath = schemaName === 'image' ? 'images' : schemaName === 'post' ? 'posts' : schemaName.toLowerCase() + 's'\n const baseUrl = 'https://seedprotocol.io'\n defaultLink = `${baseUrl}/${basePath}/${seedUid || 'unknown'}`\n }\n } else {\n const basePath = schemaName === 'image' ? 'images' : schemaName === 'post' ? 'posts' : schemaName.toLowerCase() + 's'\n const baseUrl = 'https://seedprotocol.io'\n // Ensure seedUid is valid, use 'unknown' as fallback to prevent 'undefined' in URLs\n const validSeedUid = seedUid && typeof seedUid === 'string' && seedUid.trim() !== '' ? seedUid : 'unknown'\n defaultLink = `${baseUrl}/${basePath}/${validSeedUid}`\n console.log('[feed] [setFeedItemDefaults] Using default link format:', defaultLink, { seedUid, validSeedUid })\n }\n \n // Always ensure link is set (override if undefined, null, empty, or the string \"undefined\")\n const currentLink = item.link || item.Link\n if (!currentLink || currentLink === 'undefined' || (typeof currentLink === 'string' && currentLink.trim() === '')) {\n item.link = defaultLink\n item.Link = defaultLink\n console.log('[feed] [setFeedItemDefaults] Set link to:', defaultLink)\n } else {\n // Ensure both formats are set\n if (!item.link || item.link === 'undefined') {\n item.link = currentLink\n }\n if (!item.Link || item.Link === 'undefined') {\n item.Link = currentLink\n }\n }\n \n // Always ensure guid is set (use link if available, otherwise default)\n const currentGuid = item.guid || item.Guid\n if (!currentGuid || currentGuid === 'undefined' || (typeof currentGuid === 'string' && currentGuid.trim() === '')) {\n item.guid = item.link || defaultLink\n item.Guid = item.guid\n console.log('[feed] [setFeedItemDefaults] Set guid to:', item.guid)\n } else {\n // Ensure both formats are set\n if (!item.guid || item.guid === 'undefined') {\n item.guid = currentGuid\n }\n if (!item.Guid || item.Guid === 'undefined') {\n item.Guid = currentGuid\n }\n }\n \n // Set pubDate from timeCreated if available\n if (item.timeCreated && !item.pubDate && !item.PubDate) {\n const pubDate = formatRfc822Date(item.timeCreated)\n item.pubDate = pubDate\n item.PubDate = pubDate\n } else if (item.pubDate && !item.PubDate) {\n item.PubDate = item.pubDate\n } else if (item.PubDate && !item.pubDate) {\n item.pubDate = item.PubDate\n }\n \n // Ensure seedUid is always present\n if (!item.seedUid && !item.SeedUid) {\n item.seedUid = seedUid\n item.SeedUid = seedUid\n } else if (item.seedUid && !item.SeedUid) {\n item.SeedUid = item.seedUid\n } else if (item.SeedUid && !item.seedUid) {\n item.seedUid = item.SeedUid\n }\n \n // Note: We don't set storageTransactionId to seedUid as a fallback anymore\n // because seedUid is not a valid Arweave transaction ID. If storageTransactionId\n // doesn't exist, we'll use the default link format with seedUid instead.\n}\n\nconst seedUidToModelType = new Map<string, string>()\nconst relatedSeedUids = new Set<string>()\n\nconst versionUidToSeedUid = new Map<string, string>()\n\nconst assembledFeedItems = new Map<string, Record<string, any>>()\n\nconst versionsBySeedUid = new Map<string, Attestation[]>()\n\nconst latestVersionUidsBySeedUid = new Map<string, string>()\n\n\nconst processItemProperty = async (property: Attestation, itemSeeds: Attestation[]) => {\n console.log('[feed] [processItemProperty] Starting to process property:', {\n propertyId: property.id,\n refUID: property.refUID,\n schemaId: property.schemaId,\n })\n\n let metadata\n try {\n metadata = JSON.parse(property.decodedDataJson)[0].value\n } catch (error) {\n console.error('[feed] [processItemProperty] Error parsing metadata:', error)\n return\n }\n\n let propertyNameSnake = metadata.name\n\n if (!propertyNameSnake) {\n console.log('[feed] [processItemProperty] WARNING: no propertyName found for property:', {\n propertyId: property.id,\n property,\n })\n console.warn(\n '[item/events] [syncDbWithEas] no propertyName found for property: ',\n property,\n )\n return\n }\n\n console.log('[feed] [processItemProperty] Processing property:', {\n propertyNameSnake,\n propertyId: property.id,\n })\n\n let isRelation = false\n let refValueType\n let refSeedType\n let refSchemaUid\n let refResolvedValue\n let isList = false\n const schemaUid = property.schemaId\n\n console.log('[feed] [processItemProperty] Setting schema UID for schema definition:', {\n propertyNameSnake,\n schemaUid,\n })\n\n setSchemaUidForSchemaDefinition({\n text: propertyNameSnake,\n schemaUid,\n })\n\n if (\n (propertyNameSnake.endsWith('_id') ||\n propertyNameSnake.endsWith('_ids')) &&\n propertyNameSnake !== 'storage_transaction_id' &&\n propertyNameSnake !== 'storage_provider_transaction_id'\n ) {\n isRelation = true\n console.log('[feed] [processItemProperty] Detected relation property:', {\n propertyNameSnake,\n metadataValue: metadata.value,\n })\n\n if (Array.isArray(metadata.value)) {\n isList = true\n refValueType = 'list'\n console.log('[feed] [processItemProperty] Detected list relation:', {\n propertyNameSnake,\n listLength: metadata.value.length,\n values: metadata.value,\n })\n\n const result = parseEasRelationPropertyName(propertyNameSnake)\n console.log('[feed] [processItemProperty] Parsed relation property name:', {\n result,\n originalPropertyName: propertyNameSnake,\n })\n\n if (result) {\n propertyNameSnake = result.propertyName\n refSeedType = result.modelName\n console.log('[feed] [processItemProperty] Updated property name and seed type:', {\n newPropertyName: propertyNameSnake,\n refSeedType,\n })\n }\n\n metadata.value.forEach((value: string) => {\n relatedSeedUids.add(value)\n console.log('[feed] [processItemProperty] Added related seed UID to set:', {\n relatedSeedUid: value,\n totalRelatedSeeds: relatedSeedUids.size,\n })\n })\n }\n\n if (!isList) {\n if (relationValuesToExclude.includes(metadata.value)) {\n console.log('[feed] [processItemProperty] Excluding relation value:', {\n propertyNameSnake,\n excludedValue: metadata.value,\n })\n return\n }\n relatedSeedUids.add(metadata.value)\n console.log('[feed] [processItemProperty] Added single related seed UID:', {\n relatedSeedUid: metadata.value,\n totalRelatedSeeds: relatedSeedUids.size,\n })\n }\n }\n\n let propertyValue = metadata.value\n\n if (typeof propertyValue !== 'string') {\n console.log('[feed] [processItemProperty] Converting property value to string:', {\n propertyNameSnake,\n originalType: typeof propertyValue,\n originalValue: propertyValue,\n })\n propertyValue = JSON.stringify(propertyValue)\n }\n\n console.log('[feed] [processItemProperty] Final property value:', {\n propertyNameSnake,\n propertyValue,\n isRelation,\n isList,\n })\n\n if (isRelation && !isList) {\n console.log('[feed] [processItemProperty] Processing single relation:', {\n propertyNameSnake,\n relationValue: metadata.value,\n itemSeedsCount: itemSeeds.length,\n })\n const relatedSeed = itemSeeds.find(\n (seed: Attestation) => seed.id === metadata.value,\n )\n if (relatedSeed && relatedSeed.schema && relatedSeed.schema.schemaNames) {\n refSeedType = relatedSeed.schema.schemaNames[0].name\n refSchemaUid = relatedSeed.schemaId\n console.log('[feed] [processItemProperty] Found related seed for single relation:', {\n propertyNameSnake,\n refSeedType,\n refSchemaUid,\n relatedSeedId: relatedSeed.id,\n })\n } else {\n console.log('[feed] [processItemProperty] No related seed found for single relation:', {\n propertyNameSnake,\n relationValue: metadata.value,\n })\n }\n }\n\n if (isRelation && isList) {\n console.log('[feed] [processItemProperty] Processing list relation:', {\n propertyNameSnake,\n relationValues: metadata.value,\n itemSeedsCount: itemSeeds.length,\n })\n const relatedSeeds = itemSeeds.filter((seed: Attestation) =>\n metadata.value.includes(seed.id),\n )\n console.log('[feed] [processItemProperty] Filtered related seeds for list:', {\n propertyNameSnake,\n foundSeedsCount: relatedSeeds.length,\n foundSeedIds: relatedSeeds.map((s) => s.id),\n })\n if (relatedSeeds && relatedSeeds.length > 0) {\n refSeedType = relatedSeeds[0].schema.schemaNames[0].name\n refSchemaUid = relatedSeeds[0].schemaId\n console.log('[feed] [processItemProperty] Set ref seed type and schema UID from list relation:', {\n propertyNameSnake,\n refSeedType,\n refSchemaUid,\n })\n } else {\n console.log('[feed] [processItemProperty] No related seeds found for list relation:', {\n propertyNameSnake,\n })\n }\n }\n\n console.log('[feed] [processItemProperty] Looking up seed UID for property:', {\n propertyRefUID: property.refUID,\n versionUidToSeedUidSize: versionUidToSeedUid.size,\n })\n\n const seedUidForProperty = versionUidToSeedUid.get(property.refUID)\n if (!seedUidForProperty) {\n console.log('[feed] [processItemProperty] WARNING: no seedUid found for property:', {\n propertyRefUID: property.refUID,\n propertyId: property.id,\n property,\n })\n console.warn(\n 'no seedUid found for property: ',\n property,\n )\n return\n }\n\n console.log('[feed] [processItemProperty] Found seed UID for property:', {\n seedUidForProperty,\n propertyNameSnake,\n })\n\n let existingFeedItem = assembledFeedItems.get(seedUidForProperty) || {}\n const existingKeys = Object.keys(existingFeedItem)\n // Store property in snake_case (original format)\n existingFeedItem[propertyNameSnake] = propertyValue\n // Also store in camelCase for easier access by external consumers (e.g., RSS generators)\n const propertyNameCamel = toCamelCase(propertyNameSnake)\n if (propertyNameCamel !== propertyNameSnake) {\n existingFeedItem[propertyNameCamel] = propertyValue\n }\n assembledFeedItems.set(seedUidForProperty, existingFeedItem)\n\n console.log('[feed] [processItemProperty] Updated assembled feed item:', {\n seedUidForProperty,\n propertyNameSnake,\n propertyValue,\n existingKeysCount: existingKeys.length,\n newKeysCount: Object.keys(existingFeedItem).length,\n totalAssembledItems: assembledFeedItems.size,\n })\n}\n\nconst processSeeds = async (seeds: Attestation[]) => {\n console.log('[feed] [processSeeds] Starting to process seeds:', {\n seedsCount: seeds.length,\n seedIds: seeds.map((s) => s.id),\n })\n\n const seedUids = seeds.map((seed: Attestation) => seed.id)\n\n for (let i = 0; i < seeds.length; i++) {\n const seed = seeds[i]\n seedUids.push(seed.id)\n const modelType = seed.schema.schemaNames[0].name\n seedUidToModelType.set(seed.id, modelType)\n \n // Initialize feed item with seed metadata\n if (!assembledFeedItems.has(seed.id)) {\n assembledFeedItems.set(seed.id, {\n seedUid: seed.id,\n timeCreated: seed.timeCreated,\n })\n console.log('[feed] [processSeeds] Initialized feed item for seed:', {\n seedId: seed.id,\n modelType,\n })\n }\n \n console.log('[feed] [processSeeds] Processing seed:', {\n index: i,\n seedId: seed.id,\n modelType,\n totalSeedsProcessed: i + 1,\n })\n }\n\n console.log('[feed] [processSeeds] Completed seed mapping:', {\n totalSeeds: seeds.length,\n seedUidToModelTypeSize: seedUidToModelType.size,\n seedUids,\n })\n\n console.log('[feed] [processSeeds] Fetching item versions from EAS:', {\n seedUidsCount: seedUids.length,\n seedUids,\n })\n\n const itemVersions = await getItemVersionsFromEas({seedUids})\n\n console.log('[feed] [processSeeds] Received item versions from EAS:', {\n itemVersionsCount: itemVersions.length,\n versionIds: itemVersions.map((v) => v.id),\n })\n\n for (let i = 0; i < itemVersions.length; i++) {\n const itemVersion = itemVersions[i]\n const seedUid = itemVersion.refUID\n versionUidToSeedUid.set(itemVersion.id, seedUid)\n const existingVersions = versionsBySeedUid.get(seedUid) || []\n versionsBySeedUid.set(seedUid, [...existingVersions, itemVersion])\n console.log('[feed] [processSeeds] Processed item version:', {\n index: i,\n versionId: itemVersion.id,\n seedUid,\n timeCreated: itemVersion.timeCreated,\n versionsForSeedCount: existingVersions.length + 1,\n })\n }\n\n console.log('[feed] [processSeeds] Completed version mapping:', {\n totalVersions: itemVersions.length,\n versionUidToSeedUidSize: versionUidToSeedUid.size,\n versionsBySeedUidSize: versionsBySeedUid.size,\n uniqueSeedsWithVersions: Array.from(versionsBySeedUid.keys()),\n })\n\n // Get latest version for each seed and then use those to get the properties\n console.log('[feed] [processSeeds] Determining latest versions for each seed')\n const latestVersionUids: string[] = []\n \n for (const [seedUid, versions] of versionsBySeedUid.entries()) {\n console.log('[feed] [processSeeds] Processing versions for seed:', {\n seedUid,\n versionsCount: versions.length,\n versionIds: versions.map((v) => v.id),\n timeCreateds: versions.map((v) => v.timeCreated),\n })\n // Sort versions by timeCreated in descending order (most recent first)\n const sortedVersions = [...versions].sort((a, b) => b.timeCreated - a.timeCreated)\n \n console.log('[feed] [processSeeds] Sorted versions:', {\n seedUid,\n sortedVersionIds: sortedVersions.map((v) => v.id),\n sortedTimeCreateds: sortedVersions.map((v) => v.timeCreated),\n })\n \n // Get the most recent version for this seedUid\n if (sortedVersions.length > 0) {\n const latestVersion = sortedVersions[0]\n latestVersionUids.push(latestVersion.id)\n latestVersionUidsBySeedUid.set(seedUid, latestVersion.id)\n console.log('[feed] [processSeeds] Set latest version for seed:', {\n seedUid,\n latestVersionId: latestVersion.id,\n latestTimeCreated: latestVersion.timeCreated,\n })\n } else {\n console.log('[feed] [processSeeds] WARNING: No versions found for seed:', {\n seedUid,\n })\n }\n }\n\n console.log('[feed] [processSeeds] Completed latest version determination:', {\n latestVersionUidsCount: latestVersionUids.length,\n latestVersionUids,\n latestVersionUidsBySeedUidSize: latestVersionUidsBySeedUid.size,\n })\n\n console.log('[feed] [processSeeds] Fetching item properties from EAS:', {\n latestVersionUidsCount: latestVersionUids.length,\n latestVersionUids,\n })\n\n const itemProperties = await getItemPropertiesFromEas({versionUids: latestVersionUids})\n\n console.log('[feed] [processSeeds] Received item properties from EAS:', {\n itemPropertiesCount: itemProperties.length,\n propertyIds: itemProperties.map((p) => p.id),\n })\n\n for (let i = 0; i < itemProperties.length; i++) {\n console.log('[feed] [processSeeds] Processing item property:', {\n index: i,\n propertyId: itemProperties[i].id,\n totalProperties: itemProperties.length,\n })\n await processItemProperty(itemProperties[i], seeds)\n }\n\n console.log('[feed] [processSeeds] Completed processing all seeds:', {\n seedsCount: seeds.length,\n itemVersionsCount: itemVersions.length,\n itemPropertiesCount: itemProperties.length,\n assembledFeedItemsSize: assembledFeedItems.size,\n })\n}\n\nexport const getFeedItemsBySchemaName = async (schemaName: string) => {\n console.log('[feed] [getFeedItemsBySchemaName] Starting feed retrieval:', {\n schemaName,\n currentAssembledItemsSize: assembledFeedItems.size,\n currentRelatedSeedUidsSize: relatedSeedUids.size,\n })\n\n const easClient = BaseEasClient.getEasClient()\n console.log('[feed] [getFeedItemsBySchemaName] Retrieved EAS client')\n\n console.log('[feed] [getFeedItemsBySchemaName] Fetching seeds by schema name:', {\n schemaName,\n })\n const seeds = await getSeedsBySchemaName(schemaName)\n\n console.log('[feed] [getFeedItemsBySchemaName] Received seeds:', {\n seedsCount: seeds.length,\n seedIds: seeds.map((s: Attestation) => s.id),\n })\n\n await processSeeds(seeds)\n\n const relatedSeedUidsArray = Array.from(relatedSeedUids)\n console.log('[feed] [getFeedItemsBySchemaName] Fetching related seeds:', {\n relatedSeedUidsCount: relatedSeedUidsArray.length,\n relatedSeedUids: relatedSeedUidsArray,\n })\n\n const {itemSeeds: relatedSeeds} = await easClient.request(GET_SEEDS, {\n where: {\n id: {\n in: relatedSeedUidsArray,\n },\n },\n })\n\n console.log('[feed] [getFeedItemsBySchemaName] Received related seeds:', {\n relatedSeedsCount: relatedSeeds.length,\n relatedSeedIds: relatedSeeds.map((s: Attestation) => s.id),\n })\n\n await processSeeds(relatedSeeds)\n\n // Filter feed items to only include items matching the requested schema name\n // and apply default values for required RSS fields\n const feedItems = Array.from(assembledFeedItems.entries())\n .filter(([seedUid]) => seedUidToModelType.get(seedUid) === schemaName)\n .map(([seedUid, item]) => {\n // Apply defaults for required RSS feed fields\n setFeedItemDefaults(item, seedUid, schemaName)\n return item\n })\n \n console.log('[feed] [getFeedItemsBySchemaName] Completed feed retrieval:', {\n schemaName,\n feedItemsCount: feedItems.length,\n assembledFeedItemsSize: assembledFeedItems.size,\n filteredFeedItemsCount: feedItems.length,\n feedItemKeys: feedItems.map((item) => Object.keys(item)),\n })\n\n return feedItems\n}"],"names":["logger","schemas","schemasTable","models","modelsTable","propertiesTable","ReactQueryClient"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKO,MAAM,gBAAgB,GAAG,MAAK;AACnC,IAAA,MAAM,MAAM,GAAG,SAAS,EAAE;AAE1B,IAAA,MAAM,aAAa,GAAG,MAAM,CAAC,UAAU,EAAE;IAEzC,MAAM,aAAa,GAAG,WAAW,CAAC,aAAa,EAAE,CAAC,QAAQ,KAAI;AAC5D,QAAA,OAAO,QAAQ,CAAC,KAAK,KAAK,kBAAkB,CAAC,IAAI;AACnD,IAAA,CAAC,CAAC;;AAGF,IAAA,OAAO,aAAa;AACtB,CAAC;;ACXD;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BG;AACG,SAAU,YAAY,CAC1B,KAAmD,EAAA;IAEnD,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAkB,SAAS,CAAC;AAC5D,IAAA,MAAM,eAAe,GAAG,MAAM,CAAqC,IAAI,CAAC;AACxE,IAAA,MAAM,eAAe,GAAG,MAAM,CAAkB,SAAS,CAAC;AAC1D,IAAA,MAAM,aAAa,GAAG,gBAAgB,EAAE;;;AAIxC,IAAA,MAAM,UAAU,GAAG,OAAO,CAAC,MAAK;AAC9B,QAAA,IAAI,CAAC,aAAa,IAAI,CAAC,KAAK,EAAE;AAC5B,YAAA,OAAO,IAAI;QACb;AACA,QAAA,IAAI;AACF,YAAA,OAAO,MAAM,CAAC,SAAS,CAAI,KAAK,CAAC;QACnC;QAAE,OAAO,KAAK,EAAE;AACd,YAAA,OAAO,CAAC,KAAK,CAAC,6CAA6C,EAAE,KAAK,CAAC;AACnE,YAAA,OAAO,IAAI;QACb;AACF,IAAA,CAAC,EAAE,CAAC,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,UAAU;SACpE,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC,KAAI;;AAEvB,QAAA,mBAAmB,CAAC,IAAI,EAAE,OAAO,EAAE,UAAU,CAAC;AAC9C,QAAA,OAAO,IAAI;AACb,IAAA,CAAC,CAAC;AAEJ,IAAA,OAAO,CAAC,GAAG,CAAC,6DAA6D,EAAE;QACzE,UAAU;QACV,cAAc,EAAE,SAAS,CAAC,MAAM;QAChC,sBAAsB,EAAE,kBAAkB,CAAC,IAAI;QAC/C,sBAAsB,EAAE,SAAS,CAAC,MAAM;AACxC,QAAA,YAAY,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACzD,KAAA,CAAC;AAEF,IAAA,OAAO,SAAS;AAClB;;;;"}
|
|
1
|
+
{"version":3,"file":"main.js","sources":["../src/browser/react/client.ts","../src/browser/react/liveQuery.ts","../src/browser/react/item.ts","../src/browser/react/itemProperty.ts","../src/browser/react/services.ts","../src/browser/react/db.ts","../src/browser/react/schema.ts","../src/browser/react/model.ts","../src/browser/react/modelProperty.ts","../src/browser/react/trash.ts","../src/browser/react/queryClient.ts","../src/browser/react/SeedProvider.tsx","../src/feed.ts"],"sourcesContent":["import { ClientManagerState } from \"@/client/constants\"\nimport { getClient } from \"@/client/ClientManager\"\nimport { useSelector } from \"@xstate/react\"\n\n\nexport const useIsClientReady = () => {\n const client = getClient()\n\n const clientService = client.getService()\n\n const isClientReady = useSelector(clientService, (snapshot) => {\n return snapshot.value === ClientManagerState.IDLE\n })\n\n // GlobalState removed - check ClientManager state directly\n return isClientReady\n}","import { useEffect, useState, useRef, useMemo } from 'react'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport { Observable } from 'rxjs'\nimport { useIsClientReady } from './client'\n\n/**\n * Hook to execute a reactive query that emits new results whenever the underlying data changes.\n * \n * Supports two usage patterns:\n * 1. SQL tag function: useLiveQuery((sql) => sql`SELECT * FROM models`)\n * 2. Drizzle query builder: useLiveQuery(db.select().from(models))\n * \n * @param query - SQL query function or Drizzle query builder, or null/undefined to disable the query\n * @returns Array of query results, or undefined if not yet loaded\n * \n * @example\n * ```typescript\n * // Using SQL tag function\n * const models = useLiveQuery<ModelRow>(\n * (sql) => sql`SELECT * FROM models WHERE schema_file_id = ${schemaId}`\n * )\n * \n * // Using Drizzle query builder\n * import { models } from '@/seedSchema'\n * import { eq } from 'drizzle-orm'\n * \n * const appDb = BaseDb.getAppDb()\n * const models = useLiveQuery<ModelRow>(\n * appDb.select().from(models).where(eq(models.schemaFileId, schemaId))\n * )\n * ```\n */\nexport function useLiveQuery<T>(\n query: ((sql: any) => any) | any | null | undefined\n): T[] | undefined {\n const [data, setData] = useState<T[] | undefined>(undefined)\n const subscriptionRef = useRef<{ unsubscribe: () => void } | null>(null)\n const previousDataRef = useRef<T[] | undefined>(undefined)\n const isClientReady = useIsClientReady()\n\n // Create Observable outside useEffect so it's stable and distinctUntilChanged can work\n // Only recreate when query or isClientReady changes\n const observable = useMemo(() => {\n if (!isClientReady || !query) {\n return null\n }\n try {\n return BaseDb.liveQuery<T>(query)\n } catch (error) {\n console.error('[useLiveQuery] Failed to create live query:', error)\n return null\n }\n }, [query, isClientReady])\n\n useEffect(() => {\n // Cleanup previous subscription if it exists\n if (subscriptionRef.current) {\n subscriptionRef.current.unsubscribe()\n subscriptionRef.current = null\n }\n\n // Don't subscribe if observable is null\n if (!observable) {\n return\n }\n\n const subscription = observable.subscribe({\n next: (results) => {\n const prev = previousDataRef.current\n const prevJson = prev ? JSON.stringify(prev) : 'undefined'\n const currJson = results ? JSON.stringify(results) : 'undefined'\n const isSameValue = prevJson === currJson\n\n // Defensive check: don't update state if values are the same\n // This should be handled by distinctUntilChanged, but adding as safety\n // (especially important for Drizzle query builders which may not work with distinctUntilChanged)\n if (isSameValue && prev !== undefined) {\n return\n }\n\n previousDataRef.current = results\n setData(results)\n },\n error: (err) => {\n console.error('[useLiveQuery] Error:', err)\n // Don't set data to undefined on error - keep last known good state\n // This prevents UI flickering on transient errors\n },\n })\n\n subscriptionRef.current = subscription\n\n // Cleanup on unmount or observable change\n return () => {\n if (subscriptionRef.current) {\n subscriptionRef.current.unsubscribe()\n subscriptionRef.current = null\n }\n }\n }, [observable]) // Only re-subscribe when observable changes\n\n return data\n}\n\n","import { useCallback, useEffect, useRef, useState, useMemo } from 'react'\nimport { flushSync } from 'react-dom'\nimport { createNewItem } from '@/db/write/createNewItem'\nimport { Item } from '@/Item/Item'\nimport { orderBy } from 'lodash-es'\nimport debug from 'debug'\nimport { ModelValues } from '@/types'\nimport { Subscription } from 'xstate'\nimport { IItem } from '@/interfaces'\nimport { useIsClientReady } from './client'\nimport { useLiveQuery } from './liveQuery'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport { seeds } from '@/seedSchema'\nimport { and, eq, gt, isNotNull, isNull, or } from 'drizzle-orm'\nimport type { SeedType } from '@/seedSchema/SeedSchema'\nimport { getVersionData } from '@/db/read/subqueries/versionData'\nimport { useQuery, useQueryClient } from '@tanstack/react-query'\n\nconst logger = debug('seedSdk:react:item')\n\ntype UseItemReturn<T extends ModelValues<T>> = {\n item: IItem<T> | undefined\n isLoading: boolean\n error: Error | null\n}\n\ntype UseItemProps = {\n modelName: string\n seedLocalId?: string\n seedUid?: string\n}\n\ntype UseItem = <T extends ModelValues<T>>(props: UseItemProps) => UseItemReturn<T>\n\nexport const useItem: UseItem = <T extends ModelValues<T>>({ modelName, seedLocalId, seedUid }: UseItemProps) => {\n const [item, setItem] = useState<Item<T> | undefined>()\n const [isLoading, setIsLoading] = useState(!!(seedLocalId || seedUid))\n const [error, setError] = useState<Error | null>(null)\n const subscriptionRef = useRef<Subscription | undefined>(undefined)\n const hasSeenIdleRef = useRef(false)\n\n const isClientReady = useIsClientReady()\n\n const modelNameRef = useRef<string>(modelName)\n const seedLocalIdRef = useRef<string | undefined>(seedLocalId)\n const seedUidRef = useRef<string | undefined>(seedUid)\n\n // Determine if we should be loading based on parameters - use useMemo to stabilize\n // Use refs to check current values to avoid dependency issues\n const shouldLoad = useMemo(() => {\n if (!isClientReady) return false\n return !!(seedLocalIdRef.current || seedUidRef.current)\n }, [isClientReady, seedLocalId, seedUid])\n\n const loadItem = useCallback(async () => {\n // Check shouldLoad inside the function to avoid recreating the callback\n const currentShouldLoad = !!(isClientReady && (seedLocalIdRef.current || seedUidRef.current))\n if (!currentShouldLoad) {\n setItem(undefined)\n setIsLoading(false)\n setError(null)\n return\n }\n\n try {\n // Don't set isLoading here - let the subscription effect handle it\n // This avoids race conditions where isLoading is set to true but then\n // the subscription effect hasn't run yet to set it to false\n setError(null)\n\n const foundItem = await Item.find({\n modelName: modelNameRef.current,\n seedLocalId: seedLocalIdRef.current,\n seedUid: seedUidRef.current,\n }) as Item<T> | undefined\n\n if (!foundItem) {\n logger('[useItem] [loadItem] no item found', modelNameRef.current, seedLocalIdRef.current)\n // Don't clear item if we already have one for the same request (e.g. duplicate loadItem from effect re-run)\n setItem((prev) => {\n if (!prev) return undefined\n const match = (prev.seedLocalId && prev.seedLocalId === seedLocalIdRef.current) ||\n (prev.seedUid && prev.seedUid === seedUidRef.current)\n return match ? prev : undefined\n })\n setIsLoading(false)\n setError(null)\n return\n }\n\n // Item.find() now waits for idle by default, so the item should be ready\n setItem(foundItem)\n setIsLoading(false) // Item is ready since find() waited for idle\n setError(null)\n } catch (error) {\n logger('[useItem] Error loading item:', error)\n setItem(undefined)\n setIsLoading(false)\n setError(error as Error)\n }\n }, [isClientReady])\n\n useEffect(() => {\n modelNameRef.current = modelName\n seedLocalIdRef.current = seedLocalId\n seedUidRef.current = seedUid\n }, [modelName, seedLocalId, seedUid])\n\n // Fetch/refetch when parameters change or client becomes ready\n useEffect(() => {\n // Only clear item if we don't have parameters to load\n // Don't clear if shouldLoad is false but we have an item - it might just be a timing issue\n if (!shouldLoad) {\n // Only clear if we actually don't have parameters (not just client not ready)\n if (!seedLocalId && !seedUid) {\n setItem(undefined)\n setIsLoading(false)\n setError(null)\n }\n return\n }\n loadItem()\n }, [shouldLoad, loadItem, seedLocalId, seedUid])\n\n // Subscribe to service changes when item is available\n useEffect(() => {\n if (!item) {\n // Clean up subscription if item is not available\n subscriptionRef.current?.unsubscribe()\n subscriptionRef.current = undefined\n hasSeenIdleRef.current = false\n return\n }\n\n // Clean up previous subscription\n subscriptionRef.current?.unsubscribe()\n hasSeenIdleRef.current = false\n\n // Subscribe to service changes. Only set isLoading to true after we've seen idle at least\n // once, so we don't overwrite the ready state that loadItem() just set (find() waits for idle).\n const service = item.getService()\n\n const subscription = service.subscribe((snapshot: any) => {\n // Update loading state based on service state changes\n if (snapshot && typeof snapshot === 'object' && 'value' in snapshot) {\n const isIdle = snapshot.value === 'idle'\n if (isIdle) {\n hasSeenIdleRef.current = true\n setIsLoading(false)\n setError(null)\n } else if (snapshot.value === 'error') {\n setError(new Error('Item service error'))\n setIsLoading(false)\n } else {\n // Only show loading if we've already seen idle (real transition to loading)\n if (hasSeenIdleRef.current) {\n setIsLoading(true)\n }\n }\n }\n })\n \n subscriptionRef.current = subscription\n\n return () => {\n subscriptionRef.current?.unsubscribe()\n subscriptionRef.current = undefined\n }\n }, [item])\n\n return {\n item,\n isLoading,\n error,\n }\n}\n\ntype UseItemsReturn = {\n items: IItem<any>[]\n isLoading: boolean\n error: Error | null\n}\n\ntype UseItemsProps = {\n modelName?: string\n deleted?: boolean\n}\n\ntype UseItems = (props: UseItemsProps) => UseItemsReturn\n\nconst getItemsQueryKey = (modelName?: string, deleted?: boolean) =>\n ['seed', 'items', modelName ?? null, deleted ?? false] as const\n\nexport const useItems: UseItems = ({ modelName, deleted = false }) => {\n const isClientReady = useIsClientReady()\n const queryClient = useQueryClient()\n const previousSeedsTableDataRef = useRef<SeedType[] | undefined>(undefined)\n const itemsRef = useRef<IItem<any>[]>([])\n const lastFetchedIdsRef = useRef<Set<string>>(new Set())\n\n const queryKey = useMemo(() => getItemsQueryKey(modelName, deleted), [modelName, deleted])\n\n const {\n data: items = [],\n isLoading,\n error: queryError,\n } = useQuery({\n queryKey,\n queryFn: () => Item.all(modelName, deleted, { waitForReady: true }),\n enabled: isClientReady,\n })\n itemsRef.current = items\n\n // Watch the seeds table for changes\n const db = isClientReady ? BaseDb.getAppDb() : null\n const seedsQuery = useMemo(() => {\n if (!db) return null\n const conditions: any[] = []\n if (modelName) {\n conditions.push(eq(seeds.type, modelName.toLowerCase()))\n }\n if (deleted) {\n conditions.push(\n or(\n isNotNull(seeds._markedForDeletion),\n eq(seeds._markedForDeletion, 1)\n ) as any\n )\n } else {\n conditions.push(\n or(\n isNull(seeds._markedForDeletion),\n eq(seeds._markedForDeletion, 0)\n ) as any\n )\n }\n const versionData = getVersionData()\n return db\n .with(versionData)\n .select({\n localId: seeds.localId,\n uid: seeds.uid,\n type: seeds.type,\n schemaUid: seeds.schemaUid,\n createdAt: seeds.createdAt,\n attestationCreatedAt: seeds.attestationCreatedAt,\n _markedForDeletion: seeds._markedForDeletion,\n })\n .from(seeds)\n .leftJoin(versionData, eq(seeds.localId, versionData.seedLocalId))\n .where(and(gt(versionData.versionsCount, 0), ...conditions))\n .groupBy(seeds.localId)\n }, [db, isClientReady, modelName, deleted])\n const seedsTableData = useLiveQuery<SeedType>(seedsQuery)\n\n // Invalidate when table data actually changes so useQuery refetches\n useEffect(() => {\n if (!isClientReady || !seedsTableData) return\n\n const tableDataItemsSet = new Set<string>()\n for (const dbSeed of seedsTableData) {\n const key = dbSeed.localId || dbSeed.uid\n if (key) tableDataItemsSet.add(key)\n }\n\n const currentItemsSet = new Set<string>()\n for (const item of itemsRef.current) {\n const key = item.seedLocalId || item.seedUid\n if (key) currentItemsSet.add(key)\n }\n\n if (tableDataItemsSet.size === 0 && currentItemsSet.size > 0) return\n\n const lastFetched = lastFetchedIdsRef.current\n if (\n lastFetched.size === tableDataItemsSet.size &&\n [...lastFetched].every((id) => tableDataItemsSet.has(id))\n ) {\n return\n }\n\n previousSeedsTableDataRef.current = seedsTableData\n\n const setsAreEqual =\n currentItemsSet.size === tableDataItemsSet.size &&\n [...currentItemsSet].every((id) => tableDataItemsSet.has(id))\n\n if (setsAreEqual) {\n lastFetchedIdsRef.current = new Set(tableDataItemsSet)\n return\n }\n\n lastFetchedIdsRef.current = new Set(tableDataItemsSet)\n queryClient.invalidateQueries({ queryKey })\n }, [isClientReady, seedsTableData, queryClient, queryKey])\n\n return {\n items: orderBy(\n items,\n [\n (item) =>\n item.lastVersionPublishedAt ||\n item.attestationCreatedAt ||\n item.createdAt,\n ],\n ['desc'],\n ),\n isLoading,\n error: queryError as Error | null,\n }\n}\n\nexport type UseCreateItemReturn = {\n createItem: (modelName: string, itemData?: Record<string, any>) => Promise<Item<any> | undefined>\n isLoading: boolean\n error: Error | null\n resetError: () => void\n}\n\nexport const useCreateItem = (): UseCreateItemReturn => {\n const [isLoading, setIsLoading] = useState(false)\n const [error, setError] = useState<Error | null>(null)\n\n const resetError = useCallback(() => setError(null), [])\n\n const createItem = useCallback(\n async (modelName: string, itemData?: Record<string, any>): Promise<Item<any> | undefined> => {\n if (isLoading) {\n logger('[useCreateItem] [createItem] already creating item, skipping')\n return undefined\n }\n\n setError(null)\n // Flush loading=true synchronously so the UI (and tests) can observe it before async work runs.\n flushSync(() => setIsLoading(true))\n\n try {\n const data = itemData ?? {}\n const { seedLocalId } = await createNewItem({ modelName, ...data })\n const newItem = await Item.find({ modelName, seedLocalId })\n return (newItem ?? undefined) as Item<any> | undefined\n } catch (err) {\n logger('[useCreateItem] Error creating item:', err)\n setError(err instanceof Error ? err : new Error(String(err)))\n return undefined\n } finally {\n // Defer clearing loading so React can commit the loading=true render first.\n // Otherwise the test (or UI) may never observe isLoading true (same continuation batching).\n queueMicrotask(() => setIsLoading(false))\n }\n },\n [isLoading],\n )\n\n return {\n createItem,\n isLoading,\n error,\n resetError,\n }\n}\n\ntype UsePublishItemReturn = {\n publishItem: (item: Item<any> | undefined) => void\n isLoading: boolean\n error: Error | null\n resetError: () => void\n}\n\nexport const usePublishItem = (): UsePublishItemReturn => {\n const [publishingItem, setPublishingItem] = useState<Item<any> | null>(null)\n const [isLoading, setIsLoading] = useState(false)\n const [error, setError] = useState<Error | null>(null)\n const subscriptionRef = useRef<Subscription | undefined>(undefined)\n\n const resetError = useCallback(() => setError(null), [])\n\n const publishItem = useCallback((item: Item<any> | undefined) => {\n if (!item) return\n setPublishingItem(item)\n setError(null)\n item.publish().catch(() => {\n // Error is surfaced via service state subscription; avoid unhandled rejection\n })\n }, [])\n\n useEffect(() => {\n if (!publishingItem) {\n subscriptionRef.current?.unsubscribe()\n subscriptionRef.current = undefined\n setIsLoading(false)\n return\n }\n\n subscriptionRef.current?.unsubscribe()\n const service = publishingItem.getService()\n const subscription = service.subscribe((snapshot: any) => {\n const value = snapshot?.value\n const ctx = snapshot?.context\n setIsLoading(value === 'publishing')\n const publishError = ctx?._publishError\n setError(publishError ? new Error(publishError.message) : null)\n })\n\n subscriptionRef.current = subscription\n const snap = service.getSnapshot()\n setIsLoading(snap?.value === 'publishing')\n const ctx = snap?.context\n const publishError = ctx?._publishError\n setError(publishError ? new Error(publishError.message) : null)\n\n return () => {\n subscriptionRef.current?.unsubscribe()\n subscriptionRef.current = undefined\n }\n }, [publishingItem])\n\n return {\n publishItem,\n isLoading,\n error,\n resetError,\n }\n}\n","import { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport { Subscription, SnapshotFrom } from 'xstate'\nimport debug from 'debug'\nimport { ItemProperty } from '@/ItemProperty/ItemProperty'\nimport { useIsClientReady } from './client'\nimport { IItemProperty } from '@/interfaces'\nimport { useLiveQuery } from './liveQuery'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport { metadata } from '@/seedSchema/MetadataSchema'\nimport { seeds } from '@/seedSchema'\nimport { and, eq, isNotNull } from 'drizzle-orm'\nimport { getMetadataLatest } from '@/db/read/subqueries/metadataLatest'\nimport { propertyMachine } from '@/ItemProperty/service/propertyMachine'\nimport { startCase } from 'lodash-es'\nimport { useQuery, useQueryClient } from '@tanstack/react-query'\n\nconst logger = debug('seedSdk:react:property')\nconst propertiesLogger = debug('seedSdk:react:itemProperties')\n\ntype ItemPropertySnapshot = SnapshotFrom<typeof propertyMachine>\n\ntype UseItemPropertyReturn = {\n property: IItemProperty | undefined\n isLoading: boolean\n error: Error | null\n}\n\n/**\n * Hook to get a specific ItemProperty instance\n * Can be called in multiple ways:\n * 1. With seedLocalId/seedUid and propertyName: useItemProperty({ seedLocalId, propertyName }) or useItemProperty({ seedUid, propertyName })\n * 2. With itemId and propertyName: useItemProperty(itemId, propertyName) or useItemProperty({ itemId, propertyName })\n * \n * @overload\n * @param props - Object with seedLocalId or seedUid, and propertyName\n * @returns Object with property, isLoading, and error\n * \n * @overload\n * @param props - Object with itemId and propertyName\n * @returns Object with property, isLoading, and error\n * \n * @overload\n * @param itemId - The item ID (seedLocalId or seedUid)\n * @param propertyName - The name of the property\n * @returns Object with property, isLoading, and error\n */\nexport function useItemProperty(props: {\n seedLocalId?: string\n seedUid?: string\n propertyName: string\n}): UseItemPropertyReturn\nexport function useItemProperty(props: {\n itemId?: string\n propertyName: string\n}): UseItemPropertyReturn\nexport function useItemProperty(\n itemId: string,\n propertyName: string\n): UseItemPropertyReturn\nexport function useItemProperty(\n arg1:\n | { seedLocalId?: string; seedUid?: string; propertyName: string }\n | { itemId: string; propertyName: string }\n | string,\n arg2?: string\n) {\n const isClientReady = useIsClientReady()\n const [property, setProperty] = useState<IItemProperty | undefined>(undefined)\n const [isLoading, setIsLoading] = useState(false)\n const [error, setError] = useState<Error | null>(null)\n const subscriptionRef = useRef<Subscription | undefined>(undefined)\n const [, setVersion] = useState(0) // Version counter to force re-renders\n\n // Extract primitives so useMemo/useCallback deps are stable when caller passes inline objects\n // Support object form with itemId: useItemProperty({ itemId, propertyName })\n const arg1IsObject = typeof arg1 === 'object' && arg1 != null\n const obj = arg1IsObject ? (arg1 as Record<string, unknown>) : null\n const itemIdFromObj = obj != null ? (obj.itemId as string | undefined) : undefined\n const seedLocalId =\n obj != null ? (obj.seedLocalId as string | undefined) : undefined\n const seedUid =\n obj != null ? (obj.seedUid as string | undefined) : undefined\n const propertyNameFromObj =\n obj != null ? (obj.propertyName as string | undefined) : undefined\n const itemId =\n typeof arg1 === 'string' ? arg1 : (itemIdFromObj !== undefined && itemIdFromObj !== '' ? itemIdFromObj : undefined)\n const propertyNameFromArgs = typeof arg1 === 'string' ? arg2 : undefined\n const propertyName = propertyNameFromObj ?? propertyNameFromArgs\n\n // Determine which lookup mode we're in based on arguments (deps are primitives to avoid infinite loop)\n // Unify itemId and identifiers: when itemId is provided (string or object form), use it as seedLocalId so we hit the same code path\n const lookupMode = useMemo(() => {\n const resolvedSeedLocalId = (itemId !== undefined && itemId !== '') ? itemId : seedLocalId\n const resolvedSeedUid = (itemId !== undefined && itemId !== '') ? undefined : seedUid\n if ((resolvedSeedLocalId != null || resolvedSeedUid != null) && propertyName != null && propertyName !== '') {\n return {\n type: 'identifiers' as const,\n seedLocalId: resolvedSeedLocalId ?? undefined,\n seedUid: resolvedSeedUid,\n propertyName,\n }\n }\n return null\n }, [itemId, propertyName, seedLocalId, seedUid])\n\n // Determine initial loading state\n const initialLoadingState = useMemo(() => {\n if (!lookupMode) return false\n return !!(\n (lookupMode.seedLocalId || lookupMode.seedUid) &&\n lookupMode.propertyName\n )\n }, [lookupMode])\n\n // Determine if we should be loading based on parameters\n const shouldLoad = useMemo(() => {\n if (!isClientReady) return false\n if (!lookupMode) return false\n return !!(\n (lookupMode.seedLocalId || lookupMode.seedUid) &&\n lookupMode.propertyName\n )\n }, [isClientReady, lookupMode])\n\n const updateItemProperty = useCallback(async () => {\n if (!isClientReady || !lookupMode) {\n setProperty(undefined)\n setIsLoading(false)\n setError(null)\n return\n }\n\n try {\n setIsLoading(true)\n setError(null)\n\n const seedLocalId = lookupMode.seedLocalId\n const seedUid = lookupMode.seedUid\n\n if (!seedLocalId && !seedUid) {\n setProperty(undefined)\n setIsLoading(false)\n setError(null)\n return\n }\n\n const foundProperty = await ItemProperty.find({\n propertyName: lookupMode.propertyName,\n seedLocalId,\n seedUid,\n })\n\n if (!foundProperty) {\n logger(\n `[useItemProperty] [updateItemProperty] no property found for Item.${seedLocalId || seedUid}.${lookupMode.propertyName}`,\n )\n setProperty(undefined)\n setIsLoading(false)\n setError(null)\n return\n }\n\n // ItemProperty.find() now waits for idle by default, so the property should be ready\n setProperty(foundProperty)\n setIsLoading(false) // Property is ready since find() waited for idle\n setError(null)\n } catch (error) {\n logger('[useItemProperty] Error updating item property:', error)\n setProperty(undefined)\n setIsLoading(false)\n setError(error as Error)\n }\n }, [isClientReady, lookupMode])\n\n // Fetch/refetch when lookup parameters change or client becomes ready.\n // Skip refetch when we already have the property for this lookup (avoids setting loading true\n // again when effect re-runs e.g. from Strict Mode or updateItemProperty identity change).\n // Match by the active identifier only: when looking up by seedLocalId both must match;\n // when looking up by seedUid both must match. Do not use (seedUid === undefined) as a match\n // when seedLocalIds differ, which would incorrectly skip refetch after seedLocalId change.\n useEffect(() => {\n if (!shouldLoad) {\n setProperty(undefined)\n setIsLoading(false)\n setError(null)\n return\n }\n const alreadyHavePropertyGuard =\n property &&\n lookupMode &&\n property.propertyName === lookupMode.propertyName &&\n ((lookupMode.seedLocalId != null && property.seedLocalId === lookupMode.seedLocalId) ||\n (lookupMode.seedUid != null && (property as any).seedUid === lookupMode.seedUid))\n if (alreadyHavePropertyGuard) return\n updateItemProperty()\n }, [shouldLoad, updateItemProperty, property, lookupMode])\n\n // Subscribe to service changes when property is available\n useEffect(() => {\n if (!property) {\n // Clean up subscription if property is not available\n subscriptionRef.current?.unsubscribe()\n subscriptionRef.current = undefined\n return\n }\n\n // Clean up previous subscription\n subscriptionRef.current?.unsubscribe()\n\n // Subscribe to service changes. Only set isLoading to false when idle; never set to true\n // here so we never overwrite the loaded state when the machine emits any non-idle state\n // (e.g. loading, initializing, resolvingRelatedValue) after the initial fetch.\n const subscription = property.getService().subscribe((snapshot: any) => {\n if (snapshot && typeof snapshot === 'object' && 'value' in snapshot && snapshot.value === 'idle') {\n setIsLoading(false)\n setError(null)\n }\n \n // Force re-render by incrementing version counter\n setVersion(prev => prev + 1)\n })\n \n subscriptionRef.current = subscription\n\n return () => {\n subscriptionRef.current?.unsubscribe()\n subscriptionRef.current = undefined\n }\n }, [property])\n\n return {\n property,\n isLoading,\n error,\n }\n}\ntype UseItemPropertiesReturn = {\n properties: IItemProperty[]\n isLoading: boolean\n error: Error | null\n}\n\n/** Fetches item properties list for useQuery (shared with useItemProperties). */\nasync function fetchItemPropertiesList(\n seedLocalId: string | undefined,\n seedUid: string | undefined\n): Promise<IItemProperty[]> {\n if (!seedLocalId && !seedUid) return []\n const db = BaseDb.getAppDb()\n if (!db) return []\n\n const baseList = await ItemProperty.all(\n { seedLocalId: seedLocalId ?? undefined, seedUid: seedUid ?? undefined },\n { waitForReady: true },\n )\n const _itemProperties: IItemProperty[] = [...(baseList as IItemProperty[])]\n\n const propertiesWithMetadata = new Set<string>()\n for (const p of baseList) {\n if (p.propertyName) propertiesWithMetadata.add(p.propertyName)\n }\n\n let modelName: string | undefined\n if (baseList.length > 0) {\n const first = baseList[0]\n modelName = first.modelName ?? (first as any).modelType\n if (modelName && typeof modelName === 'string') modelName = startCase(modelName)\n }\n if (!modelName) {\n const seedRecords = await db\n .select({ type: seeds.type })\n .from(seeds)\n .where(seedUid ? eq(seeds.uid, seedUid) : eq(seeds.localId, seedLocalId!))\n .limit(1)\n if (seedRecords.length > 0 && seedRecords[0].type) {\n modelName = startCase(seedRecords[0].type)\n }\n }\n\n const modelProperties: string[] = []\n if (modelName) {\n try {\n const { Model } = await import('../../Model/Model')\n const model = await Model.getByNameAsync(modelName)\n if (model?.properties) {\n for (const modelProperty of model.properties) {\n if (modelProperty.name) modelProperties.push(modelProperty.name)\n }\n }\n } catch (error) {\n propertiesLogger(`[useItemProperties] Error getting ModelProperties for ${modelName}:`, error)\n }\n }\n\n if (modelName && modelProperties.length > 0) {\n const resolvedSeedLocalId = baseList.length > 0 ? (baseList[0].seedLocalId ?? seedLocalId) : seedLocalId\n const resolvedSeedUid = baseList.length > 0 ? (baseList[0].seedUid ?? seedUid) : seedUid\n for (const propertyName of modelProperties) {\n if (propertiesWithMetadata.has(propertyName)) continue\n try {\n const itemProperty = ItemProperty.create(\n {\n propertyName,\n modelName,\n seedLocalId: resolvedSeedLocalId || undefined,\n seedUid: resolvedSeedUid || undefined,\n propertyValue: null,\n },\n { waitForReady: false },\n )\n if (itemProperty) _itemProperties.push(itemProperty as any as IItemProperty)\n } catch (error) {\n logger(`[useItemProperties] Error creating ItemProperty for missing property ${propertyName}:`, error)\n }\n }\n }\n\n if (seedLocalId || seedUid) {\n const seedRecords = await db\n .select({ createdAt: seeds.createdAt })\n .from(seeds)\n .where(seedUid ? eq(seeds.uid, seedUid) : eq(seeds.localId, seedLocalId!))\n .limit(1)\n if (seedRecords.length > 0 && seedRecords[0].createdAt) {\n const createdAtPropertyName = 'createdAt'\n const hasCreatedAtProperty = _itemProperties.some((p) => p.propertyName === createdAtPropertyName)\n if (!hasCreatedAtProperty && modelName) {\n try {\n const resolvedSeedLocalId = baseList.length > 0 ? (baseList[0].seedLocalId ?? seedLocalId) : seedLocalId\n const resolvedSeedUid = baseList.length > 0 ? (baseList[0].seedUid ?? seedUid) : seedUid\n const createdAtProperty = ItemProperty.create(\n {\n propertyName: createdAtPropertyName,\n modelName,\n seedLocalId: resolvedSeedLocalId || undefined,\n seedUid: resolvedSeedUid || undefined,\n propertyValue: seedRecords[0].createdAt.toString(),\n },\n { waitForReady: false },\n )\n if (createdAtProperty) _itemProperties.push(createdAtProperty as any as IItemProperty)\n } catch (error) {\n logger(`[useItemProperties] Error creating createdAt ItemProperty:`, error)\n }\n }\n }\n }\n\n return _itemProperties\n}\n\n/**\n * Hook to get all ItemProperty instances for a specific item\n * Can be called in multiple ways:\n * 1. With seedLocalId: useItemProperties({ seedLocalId })\n * 2. With seedUid: useItemProperties({ seedUid })\n * 3. With itemId: useItemProperties(itemId)\n * \n * Uses useLiveQuery to watch for changes in the metadata table and automatically\n * updates the returned ItemProperty instances when changes occur.\n * \n * @overload\n * @param props - Object with seedLocalId or seedUid\n * @returns Object with properties array, isLoading, and error\n * \n * @overload\n * @param itemId - The item ID (seedLocalId or seedUid)\n * @returns Object with properties array, isLoading, and error\n */\nexport function useItemProperties(props: {\n seedLocalId?: string\n seedUid?: string\n}): UseItemPropertiesReturn\nexport function useItemProperties(itemId: string): UseItemPropertiesReturn\nexport function useItemProperties(\n arg1: { seedLocalId?: string; seedUid?: string } | string\n): UseItemPropertiesReturn {\n\n const isClientReady = useIsClientReady()\n const queryClient = useQueryClient()\n const previousTableDataRef = useRef<string | undefined>(undefined)\n\n // Determine which lookup mode we're in based on arguments\n const lookupMode = useMemo(() => {\n if (typeof arg1 === 'string') {\n // String argument: itemId (assumed to be seedLocalId)\n return { type: 'itemId' as const, itemId: arg1 }\n } else if (typeof arg1 === 'object') {\n // Object argument: { seedLocalId/seedUid }\n return {\n type: 'identifiers' as const,\n seedLocalId: arg1.seedLocalId,\n seedUid: arg1.seedUid,\n }\n } else {\n return null\n }\n }, [arg1])\n\n // Determine seedLocalId and seedUid for query\n const seedLocalId = useMemo(() => {\n if (!lookupMode) return undefined\n if (lookupMode.type === 'itemId') {\n return lookupMode.itemId\n } else {\n return lookupMode.seedLocalId\n }\n }, [lookupMode])\n\n const seedUid = useMemo(() => {\n if (!lookupMode || lookupMode.type === 'itemId') return undefined\n return lookupMode.seedUid\n }, [lookupMode])\n\n const canonicalItemKey = seedLocalId ?? seedUid ?? ''\n const itemPropertiesQueryKey = useMemo(\n () => (['seed', 'itemProperties', canonicalItemKey] as const),\n [canonicalItemKey],\n )\n\n const {\n data: properties = [],\n isLoading,\n error: queryError,\n } = useQuery({\n queryKey: itemPropertiesQueryKey,\n queryFn: () => fetchItemPropertiesList(seedLocalId, seedUid),\n enabled: isClientReady && !!canonicalItemKey,\n })\n\n // Watch the metadata table for changes\n // Query metadata table directly and filter for latest records in JavaScript\n // This is simpler and works better with useLiveQuery than CTEs\n // Get db inside useMemo to avoid recreating query on each render\n // Drizzle query builders are new objects each time, but useMemo will only recreate\n // when dependencies change, which is what we want for reactive queries\n const propertiesQuery = useMemo(() => {\n if (!isClientReady || (!seedLocalId && !seedUid)) {\n propertiesLogger('[useItemProperties] Query: returning null (not ready or no identifiers)')\n return null\n }\n \n const db = BaseDb.getAppDb()\n if (!db) {\n propertiesLogger('[useItemProperties] Query: returning null (no db)')\n return null\n }\n \n propertiesLogger(`[useItemProperties] Query: creating query for seedLocalId=${seedLocalId}, seedUid=${seedUid}`)\n \n // Query metadata table directly - we'll filter for latest records in JavaScript\n const query = seedUid\n ? db\n .select({\n propertyName: metadata.propertyName,\n propertyValue: metadata.propertyValue,\n seedLocalId: metadata.seedLocalId,\n seedUid: metadata.seedUid,\n modelType: metadata.modelType,\n schemaUid: metadata.schemaUid,\n createdAt: metadata.createdAt,\n attestationCreatedAt: metadata.attestationCreatedAt,\n })\n .from(metadata)\n .where(\n and(\n eq(metadata.seedUid, seedUid),\n isNotNull(metadata.propertyName)\n )\n )\n : seedLocalId\n ? db\n .select({\n propertyName: metadata.propertyName,\n propertyValue: metadata.propertyValue,\n seedLocalId: metadata.seedLocalId,\n seedUid: metadata.seedUid,\n modelType: metadata.modelType,\n schemaUid: metadata.schemaUid,\n createdAt: metadata.createdAt,\n attestationCreatedAt: metadata.attestationCreatedAt,\n })\n .from(metadata)\n .where(\n and(\n eq(metadata.seedLocalId, seedLocalId),\n isNotNull(metadata.propertyName)\n )\n )\n : null\n \n propertiesLogger(`[useItemProperties] Query: created query object`, { queryType: seedUid ? 'seedUid' : 'seedLocalId' })\n return query\n }, [isClientReady, seedLocalId, seedUid])\n \n const rawPropertiesTableData = useLiveQuery<{\n propertyName: string | null\n propertyValue: string | null\n seedLocalId: string | null\n seedUid: string | null\n modelType: string | null\n schemaUid: string | null\n createdAt: number | null\n attestationCreatedAt: number | null\n }>(propertiesQuery)\n \n // Filter for latest records (one per propertyName) in JavaScript\n const propertiesTableData = useMemo(() => {\n if (!rawPropertiesTableData || rawPropertiesTableData.length === 0) {\n return []\n }\n\n // Group by propertyName and keep only the latest record for each\n const latestByProperty = new Map<string, typeof rawPropertiesTableData[0]>()\n \n for (const record of rawPropertiesTableData) {\n if (!record.propertyName) continue\n \n const existing = latestByProperty.get(record.propertyName)\n if (!existing) {\n latestByProperty.set(record.propertyName, record)\n } else {\n // Compare timestamps to find the latest\n const existingTime = existing.attestationCreatedAt || existing.createdAt || 0\n const currentTime = record.attestationCreatedAt || record.createdAt || 0\n if (currentTime > existingTime) {\n latestByProperty.set(record.propertyName, record)\n }\n }\n }\n\n return Array.from(latestByProperty.values())\n }, [rawPropertiesTableData])\n\n // Invalidate when metadata table data actually changes so useQuery refetches\n useEffect(() => {\n if (!isClientReady || (!seedLocalId && !seedUid) || propertiesTableData === undefined) return\n\n // Include propertyValue so value-only changes produce a different string and trigger invalidation\n const tableDataString = JSON.stringify(\n propertiesTableData\n .map((p) => ({\n propertyName: p.propertyName,\n propertyValue: p.propertyValue,\n seedLocalId: p.seedLocalId,\n seedUid: p.seedUid,\n }))\n .sort((a, b) => (a.propertyName || '').localeCompare(b.propertyName || ''))\n )\n\n if (previousTableDataRef.current === tableDataString) return\n previousTableDataRef.current = tableDataString\n\n // Invalidate when metadata table data changed (new/updated/removed props or value changes)\n // so useQuery refetches and UI shows latest values.\n if (propertiesTableData.length > 0) {\n queryClient.invalidateQueries({ queryKey: itemPropertiesQueryKey })\n }\n }, [isClientReady, propertiesTableData, properties, seedLocalId, seedUid, queryClient, itemPropertiesQueryKey])\n\n useEffect(() => {\n previousTableDataRef.current = undefined\n }, [seedLocalId, seedUid])\n\n return {\n properties,\n isLoading,\n error: queryError as Error | null,\n }\n}\n\nexport type UseCreateItemPropertyProps = {\n seedLocalId?: string\n seedUid?: string\n propertyName: string\n modelName: string\n propertyValue?: any\n versionLocalId?: string\n versionUid?: string\n [key: string]: any\n}\n\nexport type UseCreateItemPropertyReturn = {\n create: (props: UseCreateItemPropertyProps) => IItemProperty | undefined\n isLoading: boolean\n error: Error | null\n resetError: () => void\n}\n\n/**\n * Hook to create an ItemProperty with loading and error state.\n * create(props) creates a new property instance for an item; provide seedLocalId or seedUid, propertyName, and modelName.\n */\nexport const useCreateItemProperty = (): UseCreateItemPropertyReturn => {\n const subscriptionRef = useRef<Subscription | undefined>(undefined)\n const [isLoading, setIsLoading] = useState(false)\n const [error, setError] = useState<Error | null>(null)\n\n const resetError = useCallback(() => setError(null), [])\n\n const create = useCallback((props: UseCreateItemPropertyProps): IItemProperty | undefined => {\n if (!props.propertyName || (!props.seedLocalId && !props.seedUid) || !props.modelName) {\n const err = new Error('seedLocalId or seedUid, propertyName, and modelName are required')\n setError(err)\n return undefined\n }\n\n setError(null)\n setIsLoading(true)\n subscriptionRef.current?.unsubscribe()\n subscriptionRef.current = undefined\n\n const instance = ItemProperty.create(props, { waitForReady: false })\n if (!instance) {\n setError(new Error('Failed to create item property'))\n setIsLoading(false)\n return undefined\n }\n\n const subscription = instance.getService().subscribe((snapshot: any) => {\n if (snapshot?.value === 'error') {\n const err = (snapshot.context as any)?._loadingError?.error ?? new Error('Failed to create item property')\n setError(err instanceof Error ? err : new Error(String(err)))\n setIsLoading(false)\n }\n if (snapshot?.value === 'idle') {\n setError(null)\n setIsLoading(false)\n }\n })\n subscriptionRef.current = subscription\n return instance\n }, [])\n\n useEffect(() => {\n return () => {\n subscriptionRef.current?.unsubscribe()\n subscriptionRef.current = undefined\n }\n }, [])\n\n return {\n create,\n isLoading,\n error,\n resetError,\n }\n}\n\nexport type UseDestroyItemPropertyReturn = {\n destroy: (itemProperty: IItemProperty) => Promise<void>\n isLoading: boolean\n error: Error | null\n resetError: () => void\n}\n\nexport const useDestroyItemProperty = (): UseDestroyItemPropertyReturn => {\n const [currentInstance, setCurrentInstance] = useState<IItemProperty | null>(null)\n const [destroyState, setDestroyState] = useState<{ isLoading: boolean; error: Error | null }>({\n isLoading: false,\n error: null,\n })\n\n useEffect(() => {\n if (!currentInstance) {\n setDestroyState({ isLoading: false, error: null })\n return\n }\n const service = currentInstance.getService()\n const update = () => {\n const snap = service.getSnapshot() as unknown as {\n context: { _destroyInProgress?: boolean; _destroyError?: { message: string } | null }\n }\n const ctx = snap.context\n setDestroyState({\n isLoading: !!ctx._destroyInProgress,\n error: ctx._destroyError ? new Error(ctx._destroyError.message) : null,\n })\n }\n update()\n const sub = service.subscribe(update)\n return () => sub.unsubscribe()\n }, [currentInstance])\n\n const destroy = useCallback(async (itemProperty: IItemProperty) => {\n if (!itemProperty) return\n setCurrentInstance(itemProperty)\n await itemProperty.destroy()\n }, [])\n\n const resetError = useCallback(() => {\n if (currentInstance) {\n currentInstance.getService().send({ type: 'clearDestroyError' })\n }\n }, [currentInstance])\n\n return {\n destroy,\n isLoading: destroyState.isLoading,\n error: destroyState.error,\n resetError,\n }\n}\n","import { useCallback, useEffect, useState } from 'react'\nimport { ActorRef, InspectedEventEvent } from 'xstate'\nimport { orderBy } from 'lodash-es'\nimport { produce } from 'immer'\nimport { eventEmitter } from '@/eventBus'\nimport pluralize from 'pluralize'\nimport { useSelector } from '@xstate/react'\nimport debug from 'debug'\nimport { appState } from '@/seedSchema'\nimport { like } from 'drizzle-orm'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport { MachineIds, ClientManagerState } from '@/client/constants'\nimport { getClient } from '@/client/ClientManager'\n\nconst logger = debug('seedSdk:react:services')\n\nconst finalStrings = ['idle', 'ready', 'done', 'success', 'initialized']\n\nexport const getServiceName = (service: ActorRef<any, any>) => {\n let name = 'actor'\n const serviceAny = service as any\n if (service && serviceAny.uniqueKey) {\n name = serviceAny.uniqueKey\n }\n if (service && !serviceAny.uniqueKey && serviceAny.logic && serviceAny.logic.config) {\n name = getServiceUniqueKey(service)\n }\n return name\n}\n\nexport const getServiceValue = (\n service: ActorRef<any, any>,\n): string | undefined => {\n let value\n if (service && service.getSnapshot() && service.getSnapshot().value) {\n value = service.getSnapshot().value\n }\n if (getServiceName(service) === 'global') {\n if (\n value &&\n typeof value === 'object' &&\n Object.keys(value).length > 0 &&\n Object.keys(value)[0] === 'initialized'\n ) {\n value = 'ready'\n }\n }\n if (value && typeof value === 'object') {\n value = JSON.stringify(value)\n }\n return value\n}\n\nexport const getServiceUniqueKey = (service: ActorRef<any, any>) => {\n const serviceAny = service as any\n if (!service || !serviceAny.logic || !serviceAny.logic.config || !serviceAny._snapshot) {\n return\n }\n const config = serviceAny.logic.config\n if (!config.id) {\n return\n }\n let uniqueKey = config.id\n if (config.id.includes('@seedSdk/')) {\n uniqueKey = config.id.match(/^.*@seedSdk\\/(\\w+)[\\.\\w]*/)[1]\n }\n let snapshot\n try {\n snapshot = service.getSnapshot()\n } catch (error) {\n logger('Error:', error)\n return uniqueKey\n }\n if (snapshot) {\n const context = snapshot.context\n if (context && context.dbName) {\n uniqueKey = context.dbName\n }\n if (context && context.modelNamePlural) {\n uniqueKey = context.modelNamePlural\n }\n if (context && context.modelName) {\n uniqueKey = pluralize(context.modelName.toLowerCase())\n }\n }\n return uniqueKey\n}\n\nexport const useService = (service: ActorRef<any, any>) => {\n const [timeElapsed, setTimeElapsed] = useState(0)\n\n const getPercentComplete = (service: ActorRef<any, any>) => {\n let percentComplete = 0\n const serviceAny = service as any\n if (serviceAny.logic?.states) {\n const stateNames: string[] = []\n const startupStates: any[] = []\n\n for (const [stateName, state] of Object.entries(serviceAny.logic.states)) {\n const stateTyped = state as { tags?: string[] }\n if (stateTyped.tags?.includes('loading')) {\n stateNames.push(stateName)\n startupStates.push(state)\n }\n }\n\n const totalStates = startupStates.length\n const value = getServiceValue(service)\n if (value && finalStrings.includes(value)) {\n return 0\n }\n if (value) {\n const stateIndex = stateNames.indexOf(value)\n percentComplete = (stateIndex / totalStates) * 100\n }\n }\n return percentComplete\n }\n\n const updateTime = useCallback(\n (interval: ReturnType<typeof setInterval>) => {\n const context = service.getSnapshot().context\n const status = service.getSnapshot().value\n if (\n status === 'done' ||\n status === 'success' ||\n status === 'idle' ||\n status === 'ready'\n ) {\n clearInterval(interval)\n return\n }\n setTimeElapsed((timeElapsed) => timeElapsed + 1)\n },\n [service],\n )\n\n const startInterval = useCallback(() => {\n const interval = setInterval(() => {\n updateTime(interval)\n }, 1000)\n return interval\n }, [updateTime, service])\n\n useEffect(() => {\n const interval = startInterval()\n return () => clearInterval(interval)\n }, [])\n\n return {\n name: getServiceName(service),\n timeElapsed,\n value: getServiceValue(service),\n percentComplete: getPercentComplete(service),\n uniqueKey: getServiceUniqueKey(service),\n }\n}\n\nexport const useIsDbReady = () => {\n const [isDbReady, setIsDbReady] = useState(false)\n\n const { internalStatus } = useGlobalServiceStatus()\n\n useEffect(() => {\n if (internalStatus === 'ready') {\n setIsDbReady(true)\n }\n }, [internalStatus])\n\n useEffect(() => {\n if (internalStatus === 'ready') {\n setIsDbReady(true)\n }\n }, [])\n \n\n return isDbReady\n}\n\nexport const usePersistedSnapshots = () => {\n const [initialized, setInitialized] = useState(false)\n\n const hasSavedSnapshots = useHasSavedSnapshots()\n\n const { services, percentComplete } = useServices()\n\n // Helper function to save all actor snapshots to the database\n const save = useCallback(async () => {\n for (const actor of services) {\n const uniqueKey = getServiceUniqueKey(actor)\n logger(\n `would save to db with snapshot__${uniqueKey}:`,\n JSON.stringify(actor.getPersistedSnapshot()),\n )\n // await writeAppState(\n // `snapshot__${uniqueKey}`,\n // JSON.stringify(actor.getPersistedSnapshot()),\n // )\n }\n }, [services])\n\n // Helper function to load persisted snapshots from the database\n const load = useCallback(async () => {\n const appDb = BaseDb.getAppDb()\n\n if (!appDb) {\n return []\n }\n\n const persistedSnapshots = await appDb\n .select()\n .from(appState)\n .where(like(appState.key, 'snapshot__%'))\n return persistedSnapshots\n }, [])\n\n useEffect(() => {\n if (!hasSavedSnapshots || initialized) {\n return\n }\n const initialize = async () => {\n const persistedSnapshots = await load()\n logger('persistedSnapshots:', persistedSnapshots)\n setInitialized(true)\n }\n\n initialize()\n\n return () => {\n save() // Save snapshots on unmount\n }\n }, [hasSavedSnapshots, initialized])\n}\n\nexport const useHasSavedSnapshots = () => {\n const [hasSavedSnapshots, setHasSavedSnapshots] = useState(false)\n\n const isDbReady = useIsDbReady()\n\n useEffect(() => {\n if (isDbReady) {\n const _checkForSnapshots = async (): Promise<void> => {\n const appDb = BaseDb.getAppDb()\n\n const rows = await appDb\n .select()\n .from(appState)\n .where(like(appState.key, 'snapshot__%'))\n\n if (rows && rows.length > 0) {\n setHasSavedSnapshots(true)\n }\n }\n\n _checkForSnapshots()\n }\n }, [isDbReady])\n\n return hasSavedSnapshots\n}\n\nexport const useServices = () => {\n const [actors, setActors] = useState<ActorRef<any, any>[]>([])\n const [percentComplete, setPercentComplete] = useState(5)\n\n // Global service removed - now track ClientManager directly\n useEffect(() => {\n const clientManager = getClient()\n const clientService = clientManager.getService()\n \n // Add ClientManager to actors list\n const clientActor = clientService as any\n clientActor.uniqueKey = 'clientManager'\n \n setActors([clientActor])\n \n // Calculate percent complete based on ClientManager state\n const subscription = clientService.subscribe((snapshot) => {\n const state = snapshot.value\n // Calculate completion based on state progression\n let percent = 0\n if (state === ClientManagerState.IDLE) {\n percent = 100\n } else if (state === ClientManagerState.ADD_MODELS_TO_DB) {\n percent = 90\n } else if (state === ClientManagerState.ADD_MODELS_TO_STORE) {\n percent = 80\n } else if (state === ClientManagerState.PROCESS_SCHEMA_FILES) {\n percent = 70\n } else if (state === ClientManagerState.SAVE_CONFIG) {\n percent = 60\n } else if (state === ClientManagerState.DB_INIT) {\n percent = 50\n } else if (state === ClientManagerState.FILE_SYSTEM_INIT) {\n percent = 30\n } else if (state === ClientManagerState.PLATFORM_CLASSES_INIT) {\n percent = 10\n }\n setPercentComplete(percent)\n })\n \n return () => {\n subscription.unsubscribe()\n }\n }, [])\n\n return {\n services: actors,\n percentComplete,\n }\n}\n\nexport const useGlobalServiceStatus = () => {\n const clientManager = getClient()\n const clientService = clientManager.getService()\n\n const status = useSelector(clientService, (snapshot) => {\n return snapshot.value\n })\n\n // Internal service functionality is now part of ClientManager\n // DB is ready when ClientManager reaches DB_INIT or later states\n const internalStatus = useSelector(clientService, (snapshot) => {\n const state = snapshot.value\n if (state === ClientManagerState.DB_INIT || \n state === ClientManagerState.SAVE_CONFIG ||\n state === ClientManagerState.PROCESS_SCHEMA_FILES ||\n state === ClientManagerState.ADD_MODELS_TO_STORE ||\n state === ClientManagerState.ADD_MODELS_TO_DB ||\n state === ClientManagerState.IDLE) {\n return 'ready'\n }\n return state\n })\n\n return {\n status,\n internalStatus,\n }\n}\n","import { useCallback, useEffect, useState } from 'react'\nimport { Subscription } from 'xstate'\nimport { getClient } from '@/client/ClientManager'\nimport { ClientManagerState } from '@/client/constants'\nimport debug from 'debug'\n\nconst logger = debug('seedSdk:react:db')\n\nexport const useDbsAreReady = () => {\n const [dbsAreReady, setDbsAreReady] = useState(false)\n\n const update = useCallback(() => {\n if (dbsAreReady) {\n return\n }\n setDbsAreReady(true)\n }, [])\n\n useEffect(() => {\n let subscription: Subscription | undefined\n\n const _waitForDbs = async (): Promise<void> => {\n const clientManager = getClient()\n const clientService = clientManager.getService()\n \n const currentState = clientService.getSnapshot().value\n // DB is ready when ClientManager reaches DB_INIT state or later\n if (currentState === ClientManagerState.DB_INIT || \n currentState === ClientManagerState.SAVE_CONFIG ||\n currentState === ClientManagerState.PROCESS_SCHEMA_FILES ||\n currentState === ClientManagerState.ADD_MODELS_TO_STORE ||\n currentState === ClientManagerState.ADD_MODELS_TO_DB ||\n currentState === ClientManagerState.IDLE) {\n update()\n return\n }\n \n subscription = clientService.subscribe((snapshot) => {\n const state = snapshot.value\n if (state === ClientManagerState.DB_INIT || \n state === ClientManagerState.SAVE_CONFIG ||\n state === ClientManagerState.PROCESS_SCHEMA_FILES ||\n state === ClientManagerState.ADD_MODELS_TO_STORE ||\n state === ClientManagerState.ADD_MODELS_TO_DB ||\n state === ClientManagerState.IDLE) {\n update()\n subscription?.unsubscribe()\n }\n })\n }\n\n _waitForDbs()\n\n return () => {\n if (subscription) {\n subscription.unsubscribe()\n }\n }\n }, [])\n\n return {\n dbsAreReady,\n }\n}\n","import { loadAllSchemasFromDb, } from \"@/helpers/schema\"\nimport { useCallback, useEffect, useRef, useState, useMemo } from \"react\"\nimport { flushSync } from \"react-dom\"\nimport debug from \"debug\"\nimport { useIsClientReady } from \"./client\"\nimport { Schema } from \"@/Schema/Schema\"\nimport { SnapshotFrom, Subscription } from \"xstate\"\nimport { schemaMachine } from \"@/Schema/service/schemaMachine\"\nimport { SEED_PROTOCOL_SCHEMA_NAME } from \"@/helpers/constants\"\nimport { useLiveQuery } from \"./liveQuery\"\nimport { BaseDb } from \"@/db/Db/BaseDb\"\nimport { schemas as schemasTable } from \"@/seedSchema/SchemaSchema\"\nimport { desc } from \"drizzle-orm\"\nimport type { SchemaType as DbSchemaType } from \"@/seedSchema/SchemaSchema\"\nimport { useQuery, useQueryClient } from \"@tanstack/react-query\"\n\nconst logger = debug('seedSdk:react:schema')\n\n/**\n * Hook to get a Schema class instance (with setters) that is reactive\n * This allows you to edit schema properties directly like: schema.name = 'New name'\n * The schema instance uses a Proxy to ensure React re-renders when properties change\n * @param schemaIdentifier - The name of the schema or the schema file ID\n * - If a name is provided, retrieves the latest version with that name\n * - If an ID is provided, retrieves the specific schema by ID\n * @returns Object with schema instance\n */\nexport const useSchema = (schemaIdentifier: string | null | undefined) => {\n const [schema, setSchema] = useState<Schema | null>(null)\n const [isLoading, setIsLoading] = useState(schemaIdentifier ? true : false)\n const [error, setError] = useState<Error | null>(null)\n const subscriptionRef = useRef<Subscription | null>(null)\n\n const isClientReady = useIsClientReady()\n\n const loadSchema = useCallback((identifier: string) => {\n setIsLoading(true)\n setError(null)\n try {\n const schemaInstance = Schema.create(identifier, {\n waitForReady: false,\n }) as Schema\n setSchema(schemaInstance)\n\n const service = schemaInstance.getService()\n const initialSnapshot = service.getSnapshot()\n\n // Set initial loading state based on whether status is 'idle'\n const isIdle = initialSnapshot.value === 'idle'\n if (isIdle) {\n flushSync(() => setIsLoading(false))\n setError(null)\n } else {\n setIsLoading(true)\n }\n\n // Subscribe to all status changes and update isLoading based on whether status is 'idle'\n subscriptionRef.current = service.subscribe((snapshot: SchemaSnapshot) => {\n const isIdle = snapshot.value === 'idle'\n if (isIdle) {\n flushSync(() => setIsLoading(false))\n setError(null)\n } else {\n setIsLoading(true)\n }\n })\n\n } catch (error) {\n logger('[useSchema] Error creating schema:', error)\n setError(error as Error)\n setSchema(null)\n setIsLoading(false)\n return null\n }\n }, [])\n\n useEffect(() => {\n // Clean up previous subscription before starting a new load\n if (subscriptionRef.current) {\n subscriptionRef.current.unsubscribe()\n subscriptionRef.current = null\n }\n \n if (!isClientReady) {\n setSchema(null)\n setError(null)\n setIsLoading(false)\n return\n }\n if (!schemaIdentifier) {\n setSchema(null)\n setError(null)\n setIsLoading(false)\n return\n }\n\n loadSchema(schemaIdentifier)\n \n // Cleanup function to unsubscribe when effect re-runs or component unmounts\n return () => {\n if (subscriptionRef.current) {\n subscriptionRef.current.unsubscribe()\n subscriptionRef.current = null\n }\n }\n }, [schemaIdentifier, isClientReady, loadSchema])\n \n return {\n schema,\n isLoading,\n error,\n }\n\n}\n\nconst SEED_SCHEMAS_QUERY_KEY = ['seed', 'schemas'] as const\n\nexport const useSchemas = () => {\n const isClientReady = useIsClientReady()\n const queryClient = useQueryClient()\n const previousSchemasTableDataRef = useRef<DbSchemaType[] | undefined>(undefined)\n const schemasRef = useRef<Schema[]>([])\n\n const {\n data: schemas = [],\n isLoading,\n error: queryError,\n } = useQuery({\n queryKey: SEED_SCHEMAS_QUERY_KEY,\n queryFn: () => Schema.all({ waitForReady: true }),\n enabled: isClientReady,\n })\n schemasRef.current = schemas\n\n // Watch the schemas table for changes and invalidate so useQuery refetches\n const db = isClientReady ? BaseDb.getAppDb() : null\n const schemasQuery = useMemo(() => {\n if (!db) return null\n return db.select().from(schemasTable).orderBy(schemasTable.name, desc(schemasTable.version))\n }, [db, isClientReady])\n const schemasTableData = useLiveQuery<DbSchemaType>(schemasQuery)\n\n useEffect(() => {\n if (!isClientReady || !schemasTableData) {\n return\n }\n\n const prevData = previousSchemasTableDataRef.current\n const prevDataJson = prevData ? JSON.stringify(prevData) : 'undefined'\n const currDataJson = schemasTableData ? JSON.stringify(schemasTableData) : 'undefined'\n\n if (prevDataJson === currDataJson && prevData !== undefined) {\n return\n }\n\n previousSchemasTableDataRef.current = schemasTableData\n\n const currentSchemasSet = new Set<string>()\n for (const schema of schemasRef.current) {\n const schemaFileId = schema.id || schema.schemaFileId\n if (schemaFileId) {\n currentSchemasSet.add(schemaFileId)\n } else {\n const name = schema.metadata?.name\n const version = schema.version\n if (name && version !== undefined) {\n currentSchemasSet.add(`${name}:${version}`)\n }\n }\n }\n\n const tableDataSchemasSet = new Set<string>()\n for (const dbSchema of schemasTableData) {\n if (dbSchema.name === 'Seed Protocol') continue\n if (dbSchema.schemaFileId) {\n tableDataSchemasSet.add(dbSchema.schemaFileId)\n } else if (dbSchema.name != null && dbSchema.version !== undefined) {\n tableDataSchemasSet.add(`${dbSchema.name}:${dbSchema.version}`)\n }\n }\n\n const setsAreEqual =\n currentSchemasSet.size === tableDataSchemasSet.size &&\n [...currentSchemasSet].every((id) => tableDataSchemasSet.has(id))\n\n if (!setsAreEqual) {\n queryClient.invalidateQueries({ queryKey: SEED_SCHEMAS_QUERY_KEY })\n }\n }, [isClientReady, schemasTableData, queryClient])\n\n return {\n schemas,\n isLoading,\n error: queryError as Error | null,\n }\n}\n\nexport const useCreateSchema = () => {\n const subscriptionRef = useRef<{ unsubscribe: () => void } | null>(null)\n const [isLoading, setIsLoading] = useState(false)\n const [error, setError] = useState<Error | null>(null)\n\n const resetError = useCallback(() => setError(null), [])\n\n const createSchema = useCallback((schemaName: string) => {\n setError(null)\n setIsLoading(true)\n subscriptionRef.current?.unsubscribe()\n subscriptionRef.current = null\n const schema = Schema.create(schemaName, {\n waitForReady: false,\n }) as Schema\n const subscription = schema.getService().subscribe((snapshot: SchemaSnapshot) => {\n if (snapshot.value === 'error') {\n const err = snapshot.context._loadingError?.error\n setError(err instanceof Error ? err : new Error('Failed to create schema'))\n setIsLoading(false)\n }\n if (snapshot.value === 'idle') {\n setError(null)\n setIsLoading(false)\n }\n })\n subscriptionRef.current = subscription\n return schema\n }, [])\n\n useEffect(() => {\n return () => {\n subscriptionRef.current?.unsubscribe()\n subscriptionRef.current = null\n }\n }, [])\n\n return {\n createSchema,\n isLoading,\n error,\n resetError,\n }\n}\n\nexport type UseDestroySchemaReturn = {\n destroy: (schema: Schema) => Promise<void>\n isLoading: boolean\n error: Error | null\n resetError: () => void\n}\n\nexport const useDestroySchema = (): UseDestroySchemaReturn => {\n const [currentInstance, setCurrentInstance] = useState<Schema | null>(null)\n const [destroyState, setDestroyState] = useState<{ isLoading: boolean; error: Error | null }>({\n isLoading: false,\n error: null,\n })\n\n useEffect(() => {\n if (!currentInstance) {\n setDestroyState({ isLoading: false, error: null })\n return\n }\n const service = currentInstance.getService()\n const update = () => {\n const snap = service.getSnapshot()\n const ctx = snap.context as { _destroyInProgress?: boolean; _destroyError?: { message: string } | null }\n setDestroyState({\n isLoading: !!ctx._destroyInProgress,\n error: ctx._destroyError ? new Error(ctx._destroyError.message) : null,\n })\n }\n update()\n const sub = service.subscribe(update)\n return () => sub.unsubscribe()\n }, [currentInstance])\n\n const destroy = useCallback(async (schema: Schema) => {\n if (!schema) return\n setCurrentInstance(schema)\n await schema.destroy()\n }, [])\n\n const resetError = useCallback(() => {\n if (currentInstance) {\n currentInstance.getService().send({ type: 'clearDestroyError' })\n }\n }, [currentInstance])\n\n return {\n destroy,\n isLoading: destroyState.isLoading,\n error: destroyState.error,\n resetError,\n }\n}\n\nexport const useAllSchemaVersions = () => {\n const [schemaInstances, setSchemaInstances] = useState<Schema[] | undefined | null>()\n const schemaInstancesRef = useRef<Map<string, Schema>>(new Map())\n const isClientReady = useIsClientReady()\n\n const fetchSchemas = useCallback(async () => {\n if (!isClientReady) {\n return\n }\n\n try {\n // Use DB-first approach: load all schemas from database\n // This will also import any missing schemas from files\n const allSchemasData = await loadAllSchemasFromDb()\n\n // Extract unique schema names\n const schemaNames = new Set<string>()\n for (const schemaData of allSchemasData) {\n const schemaName = schemaData.schema.metadata?.name\n if (schemaName) {\n schemaNames.add(schemaName)\n }\n }\n\n // Create/update Schema instances\n const currentInstances = new Map<string, Schema>()\n \n for (const schemaName of schemaNames) {\n // Reuse existing instance if it exists\n if (schemaInstancesRef.current.has(schemaName)) {\n const existingInstance = schemaInstancesRef.current.get(schemaName)!\n currentInstances.set(schemaName, existingInstance)\n } else {\n // Create new instance\n const schema = Schema.create(schemaName, {\n waitForReady: false,\n }) as Schema\n currentInstances.set(schemaName, schema)\n }\n }\n\n // Cleanup instances that are no longer needed\n for (const [name, instance] of schemaInstancesRef.current.entries()) {\n if (!schemaNames.has(name)) {\n instance.unload()\n }\n }\n\n // Update ref and state\n schemaInstancesRef.current = currentInstances\n setSchemaInstances(Array.from(currentInstances.values()))\n } catch (error) {\n logger('Error fetching all schema versions from database:', error)\n setSchemaInstances(null)\n }\n }, [isClientReady])\n\n useEffect(() => {\n if (!isClientReady) {\n return\n }\n fetchSchemas()\n }, [isClientReady, fetchSchemas])\n\n // Cleanup on unmount\n useEffect(() => {\n return () => {\n schemaInstancesRef.current.forEach((instance) => {\n instance.unload()\n })\n schemaInstancesRef.current.clear()\n }\n }, [])\n\n return schemaInstances\n}\n\ntype SchemaSnapshot = SnapshotFrom<typeof schemaMachine>\n\n\n/**\n * Hook to get the internal Seed Protocol schema (SDK-only schema)\n * This schema is managed by the SDK and should not be edited by app developers\n * @returns Object with schema instance and schemaData (version, metadata, etc.)\n */\nexport const useSeedProtocolSchema = () => {\n return useSchema(SEED_PROTOCOL_SCHEMA_NAME)\n}","import { useMemo, useState, useEffect, useCallback, useRef } from 'react'\nimport { Model } from '@/Model/Model'\nimport { useIsClientReady } from './client'\nimport { useLiveQuery } from './liveQuery'\nimport { BaseDb } from '@/db/Db/BaseDb'\nimport { models as modelsTable } from '@/seedSchema/ModelSchema'\nimport { modelSchemas } from '@/seedSchema/ModelSchemaSchema'\nimport { schemas as schemasTable } from '@/seedSchema/SchemaSchema'\nimport { eq, or } from 'drizzle-orm'\nimport { Subscription } from 'xstate'\nimport { useQuery, useQueryClient } from '@tanstack/react-query'\n\ntype UseModelsResult = {\n models: Model[]\n isLoading: boolean\n error: Error | null\n}\n\ntype UseModelsParams = string | null | undefined\n\ntype UseModels = (schemaId: UseModelsParams) => UseModelsResult\n\n/**\n * Hook to get all Model instances for a specific schema\n * Uses useLiveQuery to watch for changes in the models table and automatically\n * updates the returned Model instances when changes occur.\n * @param schemaId - The schema ID (schema file ID) or schema name to get models from\n * @returns Array of Model instances belonging to the schema\n */\nconst getModelsQueryKey = (schemaId: UseModelsParams) => ['seed', 'models', schemaId] as const\n\n// Last-known-good models per schemaId so we never flash [] after remount or refetch race (survives component unmount).\nconst lastModelsBySchemaId = new Map<string, Model[]>()\n\nexport const useModels: UseModels = (schemaId) => {\n const isClientReady = useIsClientReady()\n const queryClient = useQueryClient()\n const modelsRef = useRef<Model[]>([])\n\n const queryKey = useMemo(() => getModelsQueryKey(schemaId), [schemaId])\n\n const {\n data: models = [],\n isLoading,\n error: queryError,\n } = useQuery({\n queryKey,\n queryFn: async () => {\n // Capture previous data before any async work so we don't overwrite good cache with [].\n const prev = queryClient.getQueryData<Model[]>(queryKey)\n // Use waitForReady: false so we return models as soon as they exist; waitForReady: true\n // filters to only idle models and can return [] while a model is in creatingProperties.\n const next = await Model.all(schemaId!, { waitForReady: false })\n // getModelsData can intermittently return [] after returning data; keep prev to avoid overwrite.\n if (Array.isArray(prev) && prev.length > 0 && Array.isArray(next) && next.length === 0) {\n return [...prev]\n }\n // If this refetch returned [], avoid overwriting non-empty cache (e.g. race where another refetch already wrote data).\n if (Array.isArray(next) && next.length === 0) {\n const current = queryClient.getQueryData<Model[]>(queryKey)\n if (Array.isArray(current) && current.length > 0) {\n return [...current]\n }\n }\n return next\n },\n enabled: isClientReady && !!schemaId,\n })\n // Never expose [] when we previously had models (avoids flash from refetch races, remounts, or intermittent getModelsData returning []).\n // When schemaId is null/undefined, always show [] — do not use fallback from a previous schema.\n const schemaIdKey = schemaId && typeof schemaId === 'string' ? schemaId : ''\n if (models.length > 0) {\n lastModelsBySchemaId.set(schemaIdKey, models)\n }\n const fallback = modelsRef.current.length > 0 ? modelsRef.current : lastModelsBySchemaId.get(schemaIdKey)\n const displayModels =\n !schemaId\n ? models\n : models.length > 0\n ? models\n : fallback?.length\n ? fallback\n : models\n modelsRef.current = displayModels\n\n // When a model is created, writeModelToDb posts to this channel; live query over join often doesn't re-run\n useEffect(() => {\n if (!schemaId || typeof BroadcastChannel === 'undefined') return\n const ch = new BroadcastChannel('seed-models-invalidate')\n const onMessage = (event: MessageEvent<{ schemaName?: string; schemaFileId?: string }>) => {\n const { schemaName, schemaFileId } = event.data || {}\n if (schemaId === schemaName || schemaId === schemaFileId) {\n queryClient.invalidateQueries({ queryKey })\n queryClient.refetchQueries({ queryKey })\n }\n }\n ch.addEventListener('message', onMessage)\n return () => {\n ch.removeEventListener('message', onMessage)\n ch.close()\n }\n }, [schemaId, queryClient, queryKey])\n\n // Stabilize query reference: only recreate when (schemaId, isClientReady) change, not when db reference changes.\n // This keeps the same liveQuery observable/subscription alive so effects can deliver updates when a new model is added.\n const stableModelsQueryKeyRef = useRef<{ schemaId: string; ready: boolean } | null>(null)\n const stableModelsQueryRef = useRef<ReturnType<typeof buildModelsQuery> | null>(null)\n function buildModelsQuery() {\n const currentDb = BaseDb.getAppDb()\n if (!currentDb || !schemaId) return null\n return currentDb\n .select({\n modelFileId: modelsTable.schemaFileId,\n modelName: modelsTable.name,\n })\n .from(schemasTable)\n .innerJoin(modelSchemas, eq(schemasTable.id, modelSchemas.schemaId))\n .innerJoin(modelsTable, eq(modelSchemas.modelId, modelsTable.id))\n .where(\n or(\n eq(schemasTable.schemaFileId, schemaId),\n eq(schemasTable.name, schemaId)\n )\n )\n }\n const modelsQuery = useMemo(() => {\n if (!schemaId || !isClientReady) return null\n const key = { schemaId, ready: isClientReady }\n const prevKey = stableModelsQueryKeyRef.current\n if (\n prevKey &&\n prevKey.schemaId === key.schemaId &&\n prevKey.ready === key.ready &&\n stableModelsQueryRef.current !== null\n ) {\n return stableModelsQueryRef.current\n }\n const q = buildModelsQuery()\n if (!q) return null\n stableModelsQueryKeyRef.current = key\n stableModelsQueryRef.current = q\n return q\n }, [schemaId, isClientReady])\n\n const modelsTableData = useLiveQuery<{ modelFileId: string | null; modelName: string }>(modelsQuery)\n\n useEffect(() => {\n if (!isClientReady || !modelsTableData || !schemaId) return\n\n const currentModelsSet = new Set<string>()\n for (const model of modelsRef.current) {\n const modelFileId = model.id || (model as any).modelFileId\n if (modelFileId) currentModelsSet.add(modelFileId)\n else if (model.modelName) currentModelsSet.add(model.modelName)\n }\n\n const tableDataModelsSet = new Set<string>()\n for (const dbModel of modelsTableData) {\n if (dbModel.modelFileId) tableDataModelsSet.add(dbModel.modelFileId)\n else if (dbModel.modelName) tableDataModelsSet.add(dbModel.modelName)\n }\n\n const setsAreEqual =\n currentModelsSet.size === tableDataModelsSet.size &&\n [...currentModelsSet].every((id) => tableDataModelsSet.has(id))\n\n // Only invalidate when the table has rows we might be missing (live query saw new data).\n // Do NOT invalidate when we have more than the table: the live query may not have updated\n // yet (e.g. join over model_schemas), and refetching would overwrite cache with [].\n const tableHasNewRows =\n tableDataModelsSet.size > 0 &&\n [...tableDataModelsSet].some((id) => !currentModelsSet.has(id))\n\n if (!setsAreEqual && tableHasNewRows) {\n queryClient.invalidateQueries({ queryKey })\n }\n }, [isClientReady, modelsTableData, schemaId, queryClient, queryKey])\n\n return {\n models: displayModels,\n isLoading,\n error: queryError as Error | null,\n }\n}\n\ntype UseModelResult = {\n model: Model | undefined\n isLoading: boolean\n error: Error | null\n}\n\n/**\n * Hook to get a specific Model instance\n * Can be called in two ways:\n * 1. With schemaId and modelName: useModel(schemaId, modelName)\n * 2. With modelId: useModel(modelId)\n * \n * @param schemaIdOrModelId - The schema ID (schema file ID) OR the model ID (modelFileId)\n * @param modelName - The name of the model to retrieve (required if first param is schemaId)\n * @returns Object with model, isLoading, and error\n */\nexport const useModel = (\n schemaIdOrModelId: string | null | undefined,\n modelName?: string | null | undefined\n): UseModelResult => {\n const isClientReady = useIsClientReady()\n const [model, setModel] = useState<Model | undefined>(undefined)\n const [isLoading, setIsLoading] = useState(false)\n const [error, setError] = useState<Error | null>(null)\n const subscriptionRef = useRef<Subscription | undefined>(undefined)\n const [, setVersion] = useState(0) // Version counter to force re-renders\n\n // If modelName is provided, treat first param as schemaId\n // Otherwise, treat first param as modelId\n const isModelIdLookup = modelName === undefined || modelName === null\n\n // Determine initial loading state\n const shouldLoad = useMemo(() => {\n if (!isClientReady) return false\n if (isModelIdLookup) {\n return !!schemaIdOrModelId\n } else {\n return !!(schemaIdOrModelId && modelName)\n }\n }, [isClientReady, isModelIdLookup, schemaIdOrModelId, modelName])\n\n // Lookup model by ID if needed\n useEffect(() => {\n if (!isClientReady || !isModelIdLookup || !schemaIdOrModelId) {\n setModel(undefined)\n setIsLoading(false)\n setError(null)\n return\n }\n\n const lookupModelById = async () => {\n try {\n setIsLoading(true)\n setError(null)\n // Use Model.createById which handles cache + DB lookup\n const foundModel = await Model.createById(schemaIdOrModelId)\n setModel(foundModel || undefined)\n setIsLoading(false)\n setError(null)\n } catch (error) {\n console.error('[useModel] Error looking up model by ID:', error)\n setModel(undefined)\n setIsLoading(false)\n setError(error as Error)\n }\n }\n\n lookupModelById()\n }, [isClientReady, isModelIdLookup, schemaIdOrModelId])\n\n // Subscribe to service changes when model is available (for modelId lookup)\n useEffect(() => {\n if (!isModelIdLookup || !model) {\n // Clean up subscription if model is not available\n subscriptionRef.current?.unsubscribe()\n subscriptionRef.current = undefined\n return\n }\n\n // Clean up previous subscription\n subscriptionRef.current?.unsubscribe()\n\n // Subscribe to service changes\n const subscription = model.getService().subscribe((snapshot) => {\n // Force re-render by incrementing version counter\n setVersion(prev => prev + 1)\n })\n \n subscriptionRef.current = subscription\n\n return () => {\n subscriptionRef.current?.unsubscribe()\n subscriptionRef.current = undefined\n }\n }, [isModelIdLookup, model])\n\n // If doing modelId lookup, return the model directly\n if (isModelIdLookup) {\n return {\n model,\n isLoading,\n error,\n }\n }\n\n // Otherwise, use schemaId + modelName lookup via useModels\n const { models: modelsList, isLoading: modelsLoading, error: modelsError } = useModels(schemaIdOrModelId)\n const foundModel = useMemo(() => {\n if (!modelName) {\n return undefined\n }\n // Try both modelName property and name getter for compatibility\n return modelsList.find((m: Model) => {\n const mName = m.modelName ?? (m as any).name\n return mName === modelName\n })\n }, [modelsList, modelName])\n\n // Subscribe to service changes when model is available (for schemaId + modelName lookup)\n useEffect(() => {\n if (isModelIdLookup || !foundModel) {\n // Clean up subscription if model is not available\n subscriptionRef.current?.unsubscribe()\n subscriptionRef.current = undefined\n return\n }\n\n // Clean up previous subscription\n subscriptionRef.current?.unsubscribe()\n\n // Subscribe to service changes\n const subscription = foundModel.getService().subscribe((snapshot) => {\n // Force re-render by incrementing version counter\n setVersion(prev => prev + 1)\n })\n \n subscriptionRef.current = subscription\n\n return () => {\n subscriptionRef.current?.unsubscribe()\n subscriptionRef.current = undefined\n }\n }, [isModelIdLookup, foundModel])\n\n // For schemaId + modelName lookup, derive loading/error from useModels\n return {\n model: foundModel,\n isLoading: modelsLoading,\n error: modelsError,\n }\n}\n\nexport type UseCreateModelOptions = {\n modelFileId?: string\n properties?: { [propertyName: string]: any }\n registerWithSchema?: boolean\n}\n\nexport type UseCreateModelReturn = {\n create: (\n schemaName: string,\n modelName: string,\n options?: UseCreateModelOptions\n ) => Model\n isLoading: boolean\n error: Error | null\n resetError: () => void\n}\n\nexport const useCreateModel = (): UseCreateModelReturn => {\n const subscriptionRef = useRef<Subscription | undefined>(undefined)\n const [isLoading, setIsLoading] = useState(false)\n const [error, setError] = useState<Error | null>(null)\n\n const resetError = useCallback(() => setError(null), [])\n\n const create = useCallback(\n (schemaName: string, modelName: string, options?: UseCreateModelOptions): Model => {\n setError(null)\n setIsLoading(true)\n subscriptionRef.current?.unsubscribe()\n subscriptionRef.current = undefined\n const model = Model.create(modelName, schemaName, {\n ...options,\n waitForReady: false,\n }) as import('@/Model/Model').Model\n const subscription = model.getService().subscribe((snapshot) => {\n if (snapshot.value === 'error') {\n setError(\n (snapshot.context as any)._loadingError?.error ??\n new Error('Failed to create model')\n )\n setIsLoading(false)\n }\n if (snapshot.value === 'idle') {\n setError(null)\n setIsLoading(false)\n }\n })\n subscriptionRef.current = subscription\n return model\n },\n []\n )\n\n useEffect(() => {\n return () => {\n subscriptionRef.current?.unsubscribe()\n subscriptionRef.current = undefined\n }\n }, [])\n\n return {\n create,\n isLoading,\n error,\n resetError,\n }\n}\n\nexport type UseDestroyModelReturn = {\n destroy: (model: Model) => Promise<void>\n isLoading: boolean\n error: Error | null\n resetError: () => void\n}\n\nexport const useDestroyModel = (): UseDestroyModelReturn => {\n const [currentInstance, setCurrentInstance] = useState<Model | null>(null)\n const [destroyState, setDestroyState] = useState<{ isLoading: boolean; error: Error | null }>({\n isLoading: false,\n error: null,\n })\n\n useEffect(() => {\n if (!currentInstance) {\n setDestroyState({ isLoading: false, error: null })\n return\n }\n const service = currentInstance.getService()\n const update = () => {\n const snap = service.getSnapshot()\n const ctx = snap.context as { _destroyInProgress?: boolean; _destroyError?: { message: string } | null }\n setDestroyState({\n isLoading: !!ctx._destroyInProgress,\n error: ctx._destroyError ? new Error(ctx._destroyError.message) : null,\n })\n }\n update()\n const sub = service.subscribe(update)\n return () => sub.unsubscribe()\n }, [currentInstance])\n\n const destroy = useCallback(async (model: Model) => {\n if (!model) return\n setCurrentInstance(model)\n await model.destroy()\n }, [])\n\n const resetError = useCallback(() => {\n if (currentInstance) {\n currentInstance.getService().send({ type: 'clearDestroyError' })\n }\n }, [currentInstance])\n\n return {\n destroy,\n isLoading: destroyState.isLoading,\n error: destroyState.error,\n resetError,\n }\n}","import { useModel } from \"./model\"\nimport { useCallback, useEffect, useRef, useState, useMemo } from \"react\"\nimport { flushSync } from \"react-dom\"\nimport { getPropertySchema } from \"@/helpers/property\"\nimport { ModelProperty } from \"@/ModelProperty/ModelProperty\"\nimport { useIsClientReady } from \"./client\"\nimport { Subscription } from \"xstate\"\nimport debug from \"debug\"\nimport { useLiveQuery } from \"./liveQuery\"\nimport { BaseDb } from \"@/db/Db/BaseDb\"\nimport { properties as propertiesTable, models as modelsTable } from \"@/seedSchema/ModelSchema\"\nimport { eq } from \"drizzle-orm\"\nimport { Model } from \"@/Model/Model\"\nimport { useQuery, useQueryClient } from \"@tanstack/react-query\"\n\nconst logger = debug('seedSdk:browser:react:modelProperty')\n\ntype UseModelPropertiesResult = {\n modelProperties: ModelProperty[]\n isLoading: boolean\n error: Error | null\n}\n\n/**\n * Hook to get all ModelProperty instances for a specific model\n * Can be called in two ways:\n * 1. With schemaId and modelName: useModelProperties(schemaId, modelName)\n * 2. With modelId: useModelProperties(modelId)\n * \n * Uses useLiveQuery to watch for changes in the properties table and automatically\n * updates the returned ModelProperty instances when changes occur.\n * \n * @param schemaIdOrModelId - The schema ID (schema file ID) OR the model ID (modelFileId)\n * @param modelName - The name of the model to get properties from (required if first param is schemaId)\n * @returns Object with modelProperties array, isLoading, and error\n */\nexport const useModelProperties = (\n schemaIdOrModelId: string | null | undefined,\n modelName?: string | null | undefined\n): UseModelPropertiesResult => {\n // Use useModel to handle both lookup patterns (by ID or by schemaId + modelName)\n const { model } = useModel(schemaIdOrModelId, modelName)\n \n // Determine the modelName for use in getPropertySchema\n const modelNameForProperty = useMemo(() => {\n if (!model) return undefined\n try {\n return model.modelName ?? (model as any).name\n } catch {\n return undefined\n }\n }, [model])\n const isClientReady = useIsClientReady()\n const queryClient = useQueryClient()\n\n // Get _dbId (database ID) from model context\n const dbModelId = useMemo(() => {\n if (!model) return null\n try {\n const context = (model as any)._getSnapshotContext()\n return context._dbId as number | undefined\n } catch {\n return null\n }\n }, [model])\n\n const modelId = model?.id\n const modelPropertiesQueryKey = useMemo(\n () => ['seed', 'modelProperties', modelId ?? ''] as const,\n [modelId],\n )\n\n const {\n data: modelProperties = [],\n isLoading,\n error: queryError,\n } = useQuery({\n queryKey: modelPropertiesQueryKey,\n queryFn: () => ModelProperty.all(modelId!, { waitForReady: true }),\n enabled: isClientReady && !!modelId,\n })\n\n const db = isClientReady ? BaseDb.getAppDb() : null\n const propertiesQuery = useMemo(() => {\n if (!db || !dbModelId) return null\n return db\n .select({\n id: propertiesTable.id,\n name: propertiesTable.name,\n dataType: propertiesTable.dataType,\n schemaFileId: propertiesTable.schemaFileId,\n })\n .from(propertiesTable)\n .where(eq(propertiesTable.modelId, dbModelId))\n }, [db, isClientReady, dbModelId])\n const propertiesTableData = useLiveQuery<{ id: number; name: string; dataType: string; schemaFileId: string | null }>(propertiesQuery)\n\n const modelPropertiesRef = useRef<ModelProperty[]>([])\n modelPropertiesRef.current = modelProperties\n\n // Fallback: when we have modelId but query returned [] (e.g. properties not in DB yet or\n // propertiesTableData is undefined because model._dbId isn't set yet), schedule refetches\n // so we pick up properties after they're written.\n useEffect(() => {\n if (!modelId || modelProperties.length > 0 || !queryClient || !modelPropertiesQueryKey) return\n const delays = [400, 1200, 2500]\n const timers = delays.map((ms) =>\n setTimeout(() => {\n queryClient.invalidateQueries({ queryKey: modelPropertiesQueryKey })\n }, ms)\n )\n return () => timers.forEach((t) => clearTimeout(t))\n }, [modelId, modelProperties.length, queryClient, modelPropertiesQueryKey])\n\n useEffect(() => {\n if (!isClientReady || !model?.id || !propertiesTableData || !modelPropertiesQueryKey) return\n\n const currentPropertiesSet = new Set<string>()\n for (const prop of modelPropertiesRef.current) {\n const context = (prop as any)._getSnapshotContext()\n const propertyFileId = context?.id\n if (propertyFileId) currentPropertiesSet.add(propertyFileId)\n else if (prop.name) currentPropertiesSet.add(prop.name)\n }\n\n const tableDataPropertiesSet = new Set<string>()\n for (const dbProperty of propertiesTableData) {\n if (dbProperty.schemaFileId) tableDataPropertiesSet.add(dbProperty.schemaFileId)\n else if (dbProperty.name) tableDataPropertiesSet.add(dbProperty.name)\n }\n\n const setsAreEqual =\n currentPropertiesSet.size === tableDataPropertiesSet.size &&\n (currentPropertiesSet.size === 0 ||\n [...currentPropertiesSet].every((id) => tableDataPropertiesSet.has(id)))\n\n // Invalidate when cached list is out of sync with the table: either we have stale cached data\n // (currentPropertiesSet.size > 0) or the table has new rows we don't have yet (tableDataPropertiesSet.size > 0).\n // The latter handles the case where the initial query returned [] before properties were written.\n const shouldInvalidate =\n !setsAreEqual && (currentPropertiesSet.size > 0 || tableDataPropertiesSet.size > 0)\n\n if (shouldInvalidate) {\n queryClient.invalidateQueries({ queryKey: modelPropertiesQueryKey })\n }\n }, [isClientReady, propertiesTableData, model?.id, queryClient, modelPropertiesQueryKey])\n\n return {\n modelProperties,\n isLoading,\n error: queryError as Error | null,\n }\n}\n\n/**\n * Helper function to get property schema by modelFileId and propertyName\n */\nconst getPropertySchemaByModelFileId = async (\n modelFileId: string,\n propertyName: string\n): Promise<ReturnType<typeof getPropertySchema>> => {\n // Get model by modelFileId\n const model = await Model.createById(modelFileId)\n if (!model) {\n return undefined\n }\n\n // Get modelName from model\n const modelName = model.modelName ?? (model as any).name\n if (!modelName) {\n return undefined\n }\n\n // Use existing getPropertySchema function\n return getPropertySchema(modelName, propertyName)\n}\n\n/**\n * Hook to get a specific ModelProperty instance\n * Can be called in three ways:\n * 1. With propertyFileId: useModelProperty(propertyFileId)\n * 2. With modelFileId and propertyName: useModelProperty(modelFileId, propertyName)\n * 3. With schemaId, modelName, and propertyName: useModelProperty(schemaId, modelName, propertyName)\n * \n * @overload\n * @param propertyFileId - The property file ID (schemaFileId)\n * @returns Object with modelProperty, isLoading, and error\n * \n * @overload\n * @param modelFileId - The model file ID (modelFileId)\n * @param propertyName - The name of the property\n * @returns Object with modelProperty, isLoading, and error\n * \n * @overload\n * @param schemaId - The schema ID (schema file ID)\n * @param modelName - The name of the model\n * @param propertyName - The name of the property\n * @returns Object with modelProperty, isLoading, and error\n */\nexport function useModelProperty(propertyFileId: string): {\n modelProperty: ModelProperty | undefined\n isLoading: boolean\n error: Error | null\n}\nexport function useModelProperty(\n modelFileId: string,\n propertyName: string\n): {\n modelProperty: ModelProperty | undefined\n isLoading: boolean\n error: Error | null\n}\nexport function useModelProperty(\n schemaId: string,\n modelName: string,\n propertyName: string\n): {\n modelProperty: ModelProperty | undefined\n isLoading: boolean\n error: Error | null\n}\nexport function useModelProperty(\n arg1: string | null | undefined,\n arg2?: string | null | undefined,\n arg3?: string | null | undefined\n) {\n // Determine initial loading state - start loading if we have valid parameters\n const initialLoadingState = useMemo(() => {\n if (arg3 !== undefined && arg3 !== null) {\n // Three arguments: schemaId, modelName, propertyName\n return !!(arg1 && arg2 && arg3)\n } else if (arg2 !== undefined && arg2 !== null) {\n // Two arguments: modelFileId, propertyName\n return !!(arg1 && arg2)\n } else {\n // One argument: propertyFileId\n return !!arg1\n }\n }, [arg1, arg2, arg3])\n\n const [modelProperty, setModelProperty] = useState<ModelProperty | undefined>(undefined)\n const [isLoading, setIsLoading] = useState(initialLoadingState)\n const [error, setError] = useState<Error | null>(null)\n const subscriptionRef = useRef<Subscription | undefined>(undefined)\n\n const isClientReady = useIsClientReady()\n\n // Determine which lookup mode we're in based on arguments\n const lookupMode = useMemo(() => {\n if (arg3 !== undefined && arg3 !== null) {\n // Three arguments: schemaId, modelName, propertyName\n return { type: 'schemaId' as const, schemaId: arg1, modelName: arg2, propertyName: arg3 }\n } else if (arg2 !== undefined && arg2 !== null) {\n // Two arguments: modelFileId, propertyName\n return { type: 'modelFileId' as const, modelFileId: arg1, propertyName: arg2 }\n } else {\n // One argument: propertyFileId\n return { type: 'propertyFileId' as const, propertyFileId: arg1 }\n }\n }, [arg1, arg2, arg3])\n\n // Determine if we should be loading based on parameters\n const shouldLoad = useMemo(() => {\n if (!isClientReady) return false\n if (lookupMode.type === 'propertyFileId') {\n return !!lookupMode.propertyFileId\n } else if (lookupMode.type === 'modelFileId') {\n return !!(lookupMode.modelFileId && lookupMode.propertyName)\n } else {\n return !!(lookupMode.schemaId && lookupMode.modelName && lookupMode.propertyName)\n }\n }, [isClientReady, lookupMode])\n\n const updateModelProperty = useCallback(async () => {\n if (!isClientReady) {\n setModelProperty(undefined)\n setIsLoading(false)\n setError(null)\n return\n }\n\n let propertyData: Awaited<ReturnType<typeof getPropertySchema>> | undefined\n let resolvedModelName: string | undefined\n\n try {\n setIsLoading(true)\n setError(null)\n\n if (lookupMode.type === 'propertyFileId') {\n if (!lookupMode.propertyFileId) {\n setModelProperty(undefined)\n setIsLoading(false)\n setError(null)\n return\n }\n\n // Use ModelProperty.createById for propertyFileId lookup\n const foundProperty = await ModelProperty.createById(lookupMode.propertyFileId)\n if (foundProperty) {\n setModelProperty(foundProperty)\n setIsLoading(false)\n setError(null)\n } else {\n setModelProperty(undefined)\n setIsLoading(false)\n setError(null)\n }\n return\n } else if (lookupMode.type === 'modelFileId') {\n if (!lookupMode.modelFileId || !lookupMode.propertyName) {\n setModelProperty(undefined)\n setIsLoading(false)\n setError(null)\n return\n }\n\n // Get property schema by modelFileId and propertyName\n // This function already gets the model and resolves modelName\n propertyData = await getPropertySchemaByModelFileId(lookupMode.modelFileId, lookupMode.propertyName)\n \n // Get modelName from model (needed for ModelProperty.create)\n const model = await Model.createById(lookupMode.modelFileId)\n resolvedModelName = model?.modelName ?? (model as any)?.name\n } else {\n // lookupMode.type === 'schemaId'\n if (!lookupMode.schemaId || !lookupMode.modelName || !lookupMode.propertyName) {\n setModelProperty(undefined)\n setIsLoading(false)\n setError(null)\n return\n }\n\n // Use existing getPropertySchema for schemaId + modelName + propertyName\n propertyData = await getPropertySchema(lookupMode.modelName, lookupMode.propertyName)\n resolvedModelName = lookupMode.modelName\n }\n\n if (propertyData && resolvedModelName) {\n const createdProperty = ModelProperty.create(\n { ...propertyData, modelName: resolvedModelName },\n { waitForReady: false }\n )\n const resolvedProperty = createdProperty instanceof Promise ? await createdProperty : createdProperty\n flushSync(() => {\n setModelProperty(resolvedProperty)\n setIsLoading(false)\n setError(null)\n })\n } else {\n setModelProperty(undefined)\n setIsLoading(false)\n setError(null)\n }\n } catch (error) {\n console.error('[useModelProperty] Error updating model property:', error)\n setModelProperty(undefined)\n setIsLoading(false)\n setError(error as Error)\n }\n }, [isClientReady, lookupMode.type, lookupMode.propertyFileId, lookupMode.modelFileId, lookupMode.propertyName, lookupMode.schemaId, lookupMode.modelName])\n\n // Fetch/refetch when lookup parameters change or client becomes ready\n useEffect(() => {\n if (!shouldLoad) {\n setModelProperty(undefined)\n setIsLoading(false)\n setError(null)\n return\n }\n updateModelProperty()\n }, [shouldLoad, updateModelProperty])\n\n // Subscribe to service changes when modelProperty is available.\n // Skip subscription for schemaId/modelFileId lookups where we created the instance locally—\n // refetching on every snapshot would set loading and can race with the initial render.\n const shouldSubscribe = lookupMode.type === 'propertyFileId'\n useEffect(() => {\n if (!modelProperty || !shouldSubscribe) {\n return\n }\n\n // Clean up previous subscription\n subscriptionRef.current?.unsubscribe()\n\n // Subscribe to service changes\n const subscription = modelProperty.getService().subscribe((snapshot) => {\n updateModelProperty()\n })\n \n subscriptionRef.current = subscription\n\n return () => {\n subscriptionRef.current?.unsubscribe()\n subscriptionRef.current = undefined\n }\n }, [modelProperty, updateModelProperty, shouldSubscribe])\n\n return {\n modelProperty,\n isLoading,\n error,\n }\n}\n\nexport type UseCreateModelPropertyOptions = {\n name: string\n dataType: string\n [key: string]: any\n}\n\nexport type UseCreateModelPropertyReturn = {\n create: (\n schemaId: string,\n modelName: string,\n property: UseCreateModelPropertyOptions\n ) => ModelProperty\n isLoading: boolean\n error: Error | null\n resetError: () => void\n}\n\n/**\n * Hook to create a ModelProperty with loading and error state.\n * create(schemaId, modelName, property) creates a new property on the model.\n */\nexport const useCreateModelProperty = (): UseCreateModelPropertyReturn => {\n const subscriptionRef = useRef<Subscription | undefined>(undefined)\n const [isLoading, setIsLoading] = useState(false)\n const [error, setError] = useState<Error | null>(null)\n\n const resetError = useCallback(() => setError(null), [])\n\n const create = useCallback(\n (\n _schemaId: string,\n modelName: string,\n property: UseCreateModelPropertyOptions\n ): ModelProperty => {\n setError(null)\n setIsLoading(true)\n subscriptionRef.current?.unsubscribe()\n subscriptionRef.current = undefined\n\n if (!modelName || !property.name || !property.dataType) {\n const err = new Error('modelName, property name and dataType are required')\n setError(err)\n setIsLoading(false)\n throw err\n }\n\n const created = ModelProperty.create(\n { ...property, modelName } as Parameters<typeof ModelProperty.create>[0],\n { waitForReady: false }\n ) as ModelProperty\n const subscription = created.getService().subscribe((snapshot) => {\n if ((snapshot as { value?: string }).value === 'error') {\n const err = (snapshot.context as any)._loadingError?.error ?? new Error('Failed to create model property')\n setError(err instanceof Error ? err : new Error(String(err)))\n setIsLoading(false)\n }\n if (snapshot.value === 'idle') {\n setError(null)\n setIsLoading(false)\n }\n })\n subscriptionRef.current = subscription\n return created\n },\n []\n )\n\n useEffect(() => {\n return () => {\n subscriptionRef.current?.unsubscribe()\n subscriptionRef.current = undefined\n }\n }, [])\n\n return {\n create,\n isLoading,\n error,\n resetError,\n }\n}\n\nexport type UseDestroyModelPropertyReturn = {\n destroy: (modelProperty: ModelProperty) => Promise<void>\n isLoading: boolean\n error: Error | null\n resetError: () => void\n}\n\nexport const useDestroyModelProperty = (): UseDestroyModelPropertyReturn => {\n const [currentInstance, setCurrentInstance] = useState<ModelProperty | null>(null)\n const [destroyState, setDestroyState] = useState<{ isLoading: boolean; error: Error | null }>({\n isLoading: false,\n error: null,\n })\n\n useEffect(() => {\n if (!currentInstance) {\n setDestroyState({ isLoading: false, error: null })\n return\n }\n const service = currentInstance.getService()\n const update = () => {\n const snap = service.getSnapshot()\n const ctx = snap.context as { _destroyInProgress?: boolean; _destroyError?: { message: string } | null }\n setDestroyState({\n isLoading: !!ctx._destroyInProgress,\n error: ctx._destroyError ? new Error(ctx._destroyError.message) : null,\n })\n }\n update()\n const sub = service.subscribe(update)\n return () => sub.unsubscribe()\n }, [currentInstance])\n\n const destroy = useCallback(async (modelProperty: ModelProperty) => {\n if (!modelProperty) return\n setCurrentInstance(modelProperty)\n await modelProperty.destroy()\n }, [])\n\n const resetError = useCallback(() => {\n if (currentInstance) {\n currentInstance.getService().send({ type: 'clearDestroyError' })\n }\n }, [currentInstance])\n\n return {\n destroy,\n isLoading: destroyState.isLoading,\n error: destroyState.error,\n resetError,\n }\n}","import { useCallback, useEffect, useState } from 'react'\nimport { Item } from '@/Item/Item'\n\nexport type UseDeleteItemReturn = {\n deleteItem: (item: Item<any>) => Promise<void>\n isLoading: boolean\n error: Error | null\n resetError: () => void\n}\n\nexport const useDeleteItem = (): UseDeleteItemReturn => {\n const [currentInstance, setCurrentInstance] = useState<Item<any> | null>(null)\n const [destroyState, setDestroyState] = useState<{ isLoading: boolean; error: Error | null }>({\n isLoading: false,\n error: null,\n })\n\n useEffect(() => {\n if (!currentInstance) {\n setDestroyState({ isLoading: false, error: null })\n return\n }\n const service = currentInstance.getService()\n const update = () => {\n const snap = service.getSnapshot()\n const ctx = snap.context as { _destroyInProgress?: boolean; _destroyError?: { message: string } | null }\n setDestroyState({\n isLoading: !!ctx._destroyInProgress,\n error: ctx._destroyError ? new Error(ctx._destroyError.message) : null,\n })\n }\n update()\n const sub = service.subscribe(update)\n return () => sub.unsubscribe()\n }, [currentInstance])\n\n const destroy = useCallback(async (item: Item<any>) => {\n if (!item) return\n setCurrentInstance(item)\n await item.destroy()\n }, [])\n\n const resetError = useCallback(() => {\n if (currentInstance) {\n currentInstance.getService().send({ type: 'clearDestroyError' })\n }\n }, [currentInstance])\n\n return {\n deleteItem: destroy,\n isLoading: destroyState.isLoading,\n error: destroyState.error,\n resetError,\n }\n}\n","import {\n type QueryClient,\n type DefaultOptions,\n QueryClient as ReactQueryClient,\n type QueryClientConfig,\n NetworkMode,\n} from '@tanstack/react-query'\n\nconst SEED_QUERY_DEFAULT_OPTIONS: DefaultOptions = {\n queries: {\n networkMode: 'offlineFirst' as NetworkMode,\n gcTime: 1000 * 60 * 60 * 24, // 24 hours\n staleTime: 1000 * 60, // 1 minute - list data can be slightly stale\n },\n}\n\n/**\n * Returns the default options used by Seed for list-query caching.\n * Use this when building your own QueryClient so Seed hooks get consistent behavior.\n */\nexport function getSeedQueryDefaultOptions(): DefaultOptions {\n return { ...SEED_QUERY_DEFAULT_OPTIONS }\n}\n\n/**\n * Merges Seed's default query options with your existing default options.\n * Your options take precedence over Seed's. Use when constructing your own QueryClient:\n *\n * @example\n * ```ts\n * const client = new QueryClient({\n * defaultOptions: mergeSeedQueryDefaults({\n * queries: { gcTime: 1000 * 60 * 60 },\n * }),\n * })\n * ```\n */\nexport function mergeSeedQueryDefaults(\n userOptions?: Partial<DefaultOptions> | null\n): DefaultOptions {\n const seed = getSeedQueryDefaultOptions()\n if (!userOptions) return seed\n return {\n queries: {\n ...seed.queries,\n ...(userOptions.queries ?? {}),\n },\n mutations: {\n ...(seed.mutations ?? {}),\n ...(userOptions.mutations ?? {}),\n },\n }\n}\n\n/**\n * Creates a QueryClient configured with Seed's default options.\n * Use this when you want to provide your own QueryClientProvider but still use Seed's defaults.\n *\n * @param overrides - Optional config to merge with Seed defaults (e.g. defaultOptions, logger).\n */\nexport function createSeedQueryClient(overrides?: Partial<QueryClientConfig>): QueryClient {\n const defaults = getSeedQueryDefaultOptions()\n const { defaultOptions: userDefaultOptions, ...restOverrides } = overrides ?? {}\n return new ReactQueryClient({\n ...restOverrides,\n defaultOptions: userDefaultOptions\n ? mergeSeedQueryDefaults(userDefaultOptions as DefaultOptions)\n : defaults,\n })\n}\n","import React, { type ReactNode, useMemo, useEffect } from 'react'\nimport { QueryClientProvider } from '@tanstack/react-query'\nimport type { QueryClient } from '@tanstack/react-query'\nimport { createSeedQueryClient } from './queryClient'\nimport { eventEmitter } from '@/eventBus'\n\nexport type SeedProviderProps = {\n children: ReactNode\n /** Optional: use your own QueryClient. If not provided, a default client with Seed options is created. */\n queryClient?: QueryClient\n /** Optional: ref to receive the QueryClient instance (e.g. for tests). */\n queryClientRef?: React.MutableRefObject<QueryClient | null>\n}\n\ndeclare global {\n interface Window {\n __SEED_INVALIDATE_ITEM_PROPERTIES__?: ((canonicalId: string) => void) | null\n }\n}\n\n/** Module-level ref so invalidateItemPropertiesForItem works when test and app share the same bundle but not the same window (e.g. iframe). */\nlet invalidateItemPropertiesRef: ((canonicalId: string) => void | Promise<void>) | null = null\n\n/**\n * Invalidates and refetches the item-properties query for an item.\n * Call this after updating an ItemProperty (e.g. after save()) so useItemProperties\n * refetches and the UI updates. Returns a Promise that resolves when the refetch has completed (if available).\n */\nexport function invalidateItemPropertiesForItem(canonicalId: string): Promise<void> {\n const p1 = invalidateItemPropertiesRef?.(canonicalId)\n if (typeof window !== 'undefined' && window.__SEED_INVALIDATE_ITEM_PROPERTIES__) {\n window.__SEED_INVALIDATE_ITEM_PROPERTIES__(canonicalId)\n }\n return Promise.resolve(p1).then(() => {})\n}\n\nfunction SeedProviderEventSubscriber({ queryClient }: { queryClient: QueryClient }) {\n useEffect(() => {\n const invalidate = (canonicalId: string) => {\n const key: readonly [string, string, string] = ['seed', 'itemProperties', canonicalId]\n queryClient.invalidateQueries({ queryKey: key })\n return queryClient.refetchQueries({ queryKey: key })\n }\n invalidateItemPropertiesRef = invalidate\n if (typeof window !== 'undefined') {\n window.__SEED_INVALIDATE_ITEM_PROPERTIES__ = invalidate\n }\n const handler = (payload: { seedLocalId?: string; seedUid?: string }) => {\n const canonicalId = payload?.seedLocalId ?? payload?.seedUid\n if (canonicalId) {\n invalidate(canonicalId)\n }\n }\n eventEmitter.on('itemProperty.saved', handler)\n return () => {\n eventEmitter.off('itemProperty.saved', handler)\n invalidateItemPropertiesRef = null\n if (typeof window !== 'undefined') {\n window.__SEED_INVALIDATE_ITEM_PROPERTIES__ = null\n }\n }\n }, [queryClient])\n return null\n}\n\n/**\n * Provider that supplies a React Query client to Seed list hooks (useSchemas, useItems, useModels, etc.)\n * so results are cached and shared across components. Wrap your app (or the subtree that uses Seed hooks)\n * after calling client.init().\n *\n * - No props: uses an internal QueryClient with Seed defaults.\n * - queryClient prop: use your own client (e.g. merge getSeedQueryDefaultOptions when creating it).\n */\nexport function SeedProvider({ children, queryClient: queryClientProp, queryClientRef }: SeedProviderProps) {\n const queryClient = useMemo(\n () => queryClientProp ?? createSeedQueryClient(),\n [queryClientProp]\n )\n if (queryClientRef) {\n queryClientRef.current = queryClient\n if (typeof window !== 'undefined') {\n const w = window as { __TEST_SEED_QUERY_CLIENT__?: QueryClient }\n w.__TEST_SEED_QUERY_CLIENT__ = queryClient\n try {\n if (window.parent && window.parent !== window) (window.parent as { __TEST_SEED_QUERY_CLIENT__?: QueryClient }).__TEST_SEED_QUERY_CLIENT__ = queryClient\n } catch {\n // cross-origin frame, ignore\n }\n }\n }\n return (\n <QueryClientProvider client={queryClient}>\n <SeedProviderEventSubscriber queryClient={queryClient} />\n {children}\n </QueryClientProvider>\n )\n}\n","import { getSeedsBySchemaName, getItemVersionsFromEas, getItemPropertiesFromEas } from \"./eas\"\nimport { Attestation } from \"./graphql/gql/graphql\"\nimport { setSchemaUidForSchemaDefinition } from \"./stores/eas\"\nimport { BaseEasClient, parseEasRelationPropertyName } from \"./helpers\"\nimport { BaseArweaveClient } from \"./helpers/ArweaveClient/BaseArweaveClient\"\nimport { GET_SEEDS } from \"./Item/queries\"\nimport debug from 'debug'\n\nconst logger = debug('seedSdk:feed')\n\nconst relationValuesToExclude = [\n '0x0000000000000000000000000000000000000000000000000000000000000020',\n]\n\n// Helper to convert snake_case to camelCase\nconst toCamelCase = (str: string): string => {\n return str.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase())\n}\n\n// Helper to format timestamp as RFC 822 date string for RSS pubDate\nconst formatRfc822Date = (timestamp: number): string => {\n const date = new Date(timestamp * 1000) // Convert from seconds to milliseconds\n const days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']\n const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']\n \n const day = days[date.getUTCDay()]\n const month = months[date.getUTCMonth()]\n const year = date.getUTCFullYear()\n const dayNum = date.getUTCDate().toString().padStart(2, '0')\n const hours = date.getUTCHours().toString().padStart(2, '0')\n const minutes = date.getUTCMinutes().toString().padStart(2, '0')\n const seconds = date.getUTCSeconds().toString().padStart(2, '0')\n \n return `${day}, ${dayNum} ${month} ${year} ${hours}:${minutes}:${seconds} GMT`\n}\n\n// Helper to set default values for feed items\nconst setFeedItemDefaults = (item: Record<string, any>, seedUid: string, schemaName: string): void => {\n // Set default title if not present (check both snake_case and camelCase)\n if (!item.title && !item.Title) {\n item.title = seedUid\n item.Title = seedUid // Also set camelCase version\n } else if (item.title && !item.Title) {\n item.Title = item.title\n } else if (item.Title && !item.title) {\n item.title = item.Title\n }\n \n // Set default link/guid using seedUid or storage_transaction_id\n // Handle empty strings, null, and undefined - check both formats\n const storageTransactionIdSnake = item.storage_transaction_id && \n typeof item.storage_transaction_id === 'string' && \n item.storage_transaction_id.trim() !== '' && \n item.storage_transaction_id !== 'undefined' &&\n item.storage_transaction_id !== seedUid // Don't use seedUid as transaction ID\n ? item.storage_transaction_id.trim() \n : null\n const storageTransactionIdCamel = item.storageTransactionId && \n typeof item.storageTransactionId === 'string' && \n item.storageTransactionId.trim() !== '' && \n item.storageTransactionId !== 'undefined' &&\n item.storageTransactionId !== seedUid // Don't use seedUid as transaction ID\n ? item.storageTransactionId.trim() \n : null\n const storageTransactionId = storageTransactionIdSnake || storageTransactionIdCamel\n \n console.log('[feed] [setFeedItemDefaults] Setting defaults for item:', {\n seedUid,\n schemaName,\n hasStorageTransactionIdSnake: !!storageTransactionIdSnake,\n hasStorageTransactionIdCamel: !!storageTransactionIdCamel,\n storageTransactionIdSnakeValue: item.storage_transaction_id,\n storageTransactionIdCamelValue: item.storageTransactionId,\n storageTransactionId,\n itemKeys: Object.keys(item),\n })\n \n // If there's a valid storageTransactionId (not seedUid), use Arweave URL for the link\n // Otherwise, build URL based on schema name (e.g., /images/ for image schema, /posts/ for post schema)\n let defaultLink: string\n if (storageTransactionId && storageTransactionId !== seedUid && storageTransactionId.length > 0) {\n try {\n defaultLink = BaseArweaveClient.getRawUrl(storageTransactionId)\n console.log('[feed] [setFeedItemDefaults] Using Arweave URL for storageTransactionId:', defaultLink)\n } catch (error) {\n console.error('[feed] [setFeedItemDefaults] Error generating Arweave URL:', error)\n // Fallback to default link format\n const basePath = schemaName === 'image' ? 'images' : schemaName === 'post' ? 'posts' : schemaName.toLowerCase() + 's'\n const baseUrl = 'https://seedprotocol.io'\n defaultLink = `${baseUrl}/${basePath}/${seedUid || 'unknown'}`\n }\n } else {\n const basePath = schemaName === 'image' ? 'images' : schemaName === 'post' ? 'posts' : schemaName.toLowerCase() + 's'\n const baseUrl = 'https://seedprotocol.io'\n // Ensure seedUid is valid, use 'unknown' as fallback to prevent 'undefined' in URLs\n const validSeedUid = seedUid && typeof seedUid === 'string' && seedUid.trim() !== '' ? seedUid : 'unknown'\n defaultLink = `${baseUrl}/${basePath}/${validSeedUid}`\n console.log('[feed] [setFeedItemDefaults] Using default link format:', defaultLink, { seedUid, validSeedUid })\n }\n \n // Always ensure link is set (override if undefined, null, empty, or the string \"undefined\")\n const currentLink = item.link || item.Link\n if (!currentLink || currentLink === 'undefined' || (typeof currentLink === 'string' && currentLink.trim() === '')) {\n item.link = defaultLink\n item.Link = defaultLink\n console.log('[feed] [setFeedItemDefaults] Set link to:', defaultLink)\n } else {\n // Ensure both formats are set\n if (!item.link || item.link === 'undefined') {\n item.link = currentLink\n }\n if (!item.Link || item.Link === 'undefined') {\n item.Link = currentLink\n }\n }\n \n // Always ensure guid is set (use link if available, otherwise default)\n const currentGuid = item.guid || item.Guid\n if (!currentGuid || currentGuid === 'undefined' || (typeof currentGuid === 'string' && currentGuid.trim() === '')) {\n item.guid = item.link || defaultLink\n item.Guid = item.guid\n console.log('[feed] [setFeedItemDefaults] Set guid to:', item.guid)\n } else {\n // Ensure both formats are set\n if (!item.guid || item.guid === 'undefined') {\n item.guid = currentGuid\n }\n if (!item.Guid || item.Guid === 'undefined') {\n item.Guid = currentGuid\n }\n }\n \n // Set pubDate from timeCreated if available\n if (item.timeCreated && !item.pubDate && !item.PubDate) {\n const pubDate = formatRfc822Date(item.timeCreated)\n item.pubDate = pubDate\n item.PubDate = pubDate\n } else if (item.pubDate && !item.PubDate) {\n item.PubDate = item.pubDate\n } else if (item.PubDate && !item.pubDate) {\n item.pubDate = item.PubDate\n }\n \n // Ensure seedUid is always present\n if (!item.seedUid && !item.SeedUid) {\n item.seedUid = seedUid\n item.SeedUid = seedUid\n } else if (item.seedUid && !item.SeedUid) {\n item.SeedUid = item.seedUid\n } else if (item.SeedUid && !item.seedUid) {\n item.seedUid = item.SeedUid\n }\n \n // Note: We don't set storageTransactionId to seedUid as a fallback anymore\n // because seedUid is not a valid Arweave transaction ID. If storageTransactionId\n // doesn't exist, we'll use the default link format with seedUid instead.\n}\n\nconst seedUidToModelType = new Map<string, string>()\nconst relatedSeedUids = new Set<string>()\n\nconst versionUidToSeedUid = new Map<string, string>()\n\nconst assembledFeedItems = new Map<string, Record<string, any>>()\n\nconst versionsBySeedUid = new Map<string, Attestation[]>()\n\nconst latestVersionUidsBySeedUid = new Map<string, string>()\n\n\nconst processItemProperty = async (property: Attestation, itemSeeds: Attestation[]) => {\n console.log('[feed] [processItemProperty] Starting to process property:', {\n propertyId: property.id,\n refUID: property.refUID,\n schemaId: property.schemaId,\n })\n\n let metadata\n try {\n metadata = JSON.parse(property.decodedDataJson)[0].value\n } catch (error) {\n console.error('[feed] [processItemProperty] Error parsing metadata:', error)\n return\n }\n\n let propertyNameSnake = metadata.name\n\n if (!propertyNameSnake) {\n console.log('[feed] [processItemProperty] WARNING: no propertyName found for property:', {\n propertyId: property.id,\n property,\n })\n console.warn(\n '[item/events] [syncDbWithEas] no propertyName found for property: ',\n property,\n )\n return\n }\n\n console.log('[feed] [processItemProperty] Processing property:', {\n propertyNameSnake,\n propertyId: property.id,\n })\n\n let isRelation = false\n let refValueType\n let refSeedType\n let refSchemaUid\n let refResolvedValue\n let isList = false\n const schemaUid = property.schemaId\n\n console.log('[feed] [processItemProperty] Setting schema UID for schema definition:', {\n propertyNameSnake,\n schemaUid,\n })\n\n setSchemaUidForSchemaDefinition({\n text: propertyNameSnake,\n schemaUid,\n })\n\n if (\n (propertyNameSnake.endsWith('_id') ||\n propertyNameSnake.endsWith('_ids')) &&\n propertyNameSnake !== 'storage_transaction_id' &&\n propertyNameSnake !== 'storage_provider_transaction_id'\n ) {\n isRelation = true\n console.log('[feed] [processItemProperty] Detected relation property:', {\n propertyNameSnake,\n metadataValue: metadata.value,\n })\n\n if (Array.isArray(metadata.value)) {\n isList = true\n refValueType = 'list'\n console.log('[feed] [processItemProperty] Detected list relation:', {\n propertyNameSnake,\n listLength: metadata.value.length,\n values: metadata.value,\n })\n\n const result = parseEasRelationPropertyName(propertyNameSnake)\n console.log('[feed] [processItemProperty] Parsed relation property name:', {\n result,\n originalPropertyName: propertyNameSnake,\n })\n\n if (result) {\n propertyNameSnake = result.propertyName\n refSeedType = result.modelName\n console.log('[feed] [processItemProperty] Updated property name and seed type:', {\n newPropertyName: propertyNameSnake,\n refSeedType,\n })\n }\n\n metadata.value.forEach((value: string) => {\n relatedSeedUids.add(value)\n console.log('[feed] [processItemProperty] Added related seed UID to set:', {\n relatedSeedUid: value,\n totalRelatedSeeds: relatedSeedUids.size,\n })\n })\n }\n\n if (!isList) {\n if (relationValuesToExclude.includes(metadata.value)) {\n console.log('[feed] [processItemProperty] Excluding relation value:', {\n propertyNameSnake,\n excludedValue: metadata.value,\n })\n return\n }\n relatedSeedUids.add(metadata.value)\n console.log('[feed] [processItemProperty] Added single related seed UID:', {\n relatedSeedUid: metadata.value,\n totalRelatedSeeds: relatedSeedUids.size,\n })\n }\n }\n\n let propertyValue = metadata.value\n\n if (typeof propertyValue !== 'string') {\n console.log('[feed] [processItemProperty] Converting property value to string:', {\n propertyNameSnake,\n originalType: typeof propertyValue,\n originalValue: propertyValue,\n })\n propertyValue = JSON.stringify(propertyValue)\n }\n\n console.log('[feed] [processItemProperty] Final property value:', {\n propertyNameSnake,\n propertyValue,\n isRelation,\n isList,\n })\n\n if (isRelation && !isList) {\n console.log('[feed] [processItemProperty] Processing single relation:', {\n propertyNameSnake,\n relationValue: metadata.value,\n itemSeedsCount: itemSeeds.length,\n })\n const relatedSeed = itemSeeds.find(\n (seed: Attestation) => seed.id === metadata.value,\n )\n if (relatedSeed && relatedSeed.schema && relatedSeed.schema.schemaNames) {\n refSeedType = relatedSeed.schema.schemaNames[0].name\n refSchemaUid = relatedSeed.schemaId\n console.log('[feed] [processItemProperty] Found related seed for single relation:', {\n propertyNameSnake,\n refSeedType,\n refSchemaUid,\n relatedSeedId: relatedSeed.id,\n })\n } else {\n console.log('[feed] [processItemProperty] No related seed found for single relation:', {\n propertyNameSnake,\n relationValue: metadata.value,\n })\n }\n }\n\n if (isRelation && isList) {\n console.log('[feed] [processItemProperty] Processing list relation:', {\n propertyNameSnake,\n relationValues: metadata.value,\n itemSeedsCount: itemSeeds.length,\n })\n const relatedSeeds = itemSeeds.filter((seed: Attestation) =>\n metadata.value.includes(seed.id),\n )\n console.log('[feed] [processItemProperty] Filtered related seeds for list:', {\n propertyNameSnake,\n foundSeedsCount: relatedSeeds.length,\n foundSeedIds: relatedSeeds.map((s) => s.id),\n })\n if (relatedSeeds && relatedSeeds.length > 0) {\n refSeedType = relatedSeeds[0].schema.schemaNames[0].name\n refSchemaUid = relatedSeeds[0].schemaId\n console.log('[feed] [processItemProperty] Set ref seed type and schema UID from list relation:', {\n propertyNameSnake,\n refSeedType,\n refSchemaUid,\n })\n } else {\n console.log('[feed] [processItemProperty] No related seeds found for list relation:', {\n propertyNameSnake,\n })\n }\n }\n\n console.log('[feed] [processItemProperty] Looking up seed UID for property:', {\n propertyRefUID: property.refUID,\n versionUidToSeedUidSize: versionUidToSeedUid.size,\n })\n\n const seedUidForProperty = versionUidToSeedUid.get(property.refUID)\n if (!seedUidForProperty) {\n console.log('[feed] [processItemProperty] WARNING: no seedUid found for property:', {\n propertyRefUID: property.refUID,\n propertyId: property.id,\n property,\n })\n console.warn(\n 'no seedUid found for property: ',\n property,\n )\n return\n }\n\n console.log('[feed] [processItemProperty] Found seed UID for property:', {\n seedUidForProperty,\n propertyNameSnake,\n })\n\n let existingFeedItem = assembledFeedItems.get(seedUidForProperty) || {}\n const existingKeys = Object.keys(existingFeedItem)\n // Store property in snake_case (original format)\n existingFeedItem[propertyNameSnake] = propertyValue\n // Also store in camelCase for easier access by external consumers (e.g., RSS generators)\n const propertyNameCamel = toCamelCase(propertyNameSnake)\n if (propertyNameCamel !== propertyNameSnake) {\n existingFeedItem[propertyNameCamel] = propertyValue\n }\n assembledFeedItems.set(seedUidForProperty, existingFeedItem)\n\n console.log('[feed] [processItemProperty] Updated assembled feed item:', {\n seedUidForProperty,\n propertyNameSnake,\n propertyValue,\n existingKeysCount: existingKeys.length,\n newKeysCount: Object.keys(existingFeedItem).length,\n totalAssembledItems: assembledFeedItems.size,\n })\n}\n\nconst processSeeds = async (seeds: Attestation[]) => {\n console.log('[feed] [processSeeds] Starting to process seeds:', {\n seedsCount: seeds.length,\n seedIds: seeds.map((s) => s.id),\n })\n\n const seedUids = seeds.map((seed: Attestation) => seed.id)\n\n for (let i = 0; i < seeds.length; i++) {\n const seed = seeds[i]\n seedUids.push(seed.id)\n const modelType = seed.schema.schemaNames[0].name\n seedUidToModelType.set(seed.id, modelType)\n \n // Initialize feed item with seed metadata\n if (!assembledFeedItems.has(seed.id)) {\n assembledFeedItems.set(seed.id, {\n seedUid: seed.id,\n timeCreated: seed.timeCreated,\n })\n console.log('[feed] [processSeeds] Initialized feed item for seed:', {\n seedId: seed.id,\n modelType,\n })\n }\n \n console.log('[feed] [processSeeds] Processing seed:', {\n index: i,\n seedId: seed.id,\n modelType,\n totalSeedsProcessed: i + 1,\n })\n }\n\n console.log('[feed] [processSeeds] Completed seed mapping:', {\n totalSeeds: seeds.length,\n seedUidToModelTypeSize: seedUidToModelType.size,\n seedUids,\n })\n\n console.log('[feed] [processSeeds] Fetching item versions from EAS:', {\n seedUidsCount: seedUids.length,\n seedUids,\n })\n\n const itemVersions = await getItemVersionsFromEas({seedUids})\n\n console.log('[feed] [processSeeds] Received item versions from EAS:', {\n itemVersionsCount: itemVersions.length,\n versionIds: itemVersions.map((v) => v.id),\n })\n\n for (let i = 0; i < itemVersions.length; i++) {\n const itemVersion = itemVersions[i]\n const seedUid = itemVersion.refUID\n versionUidToSeedUid.set(itemVersion.id, seedUid)\n const existingVersions = versionsBySeedUid.get(seedUid) || []\n versionsBySeedUid.set(seedUid, [...existingVersions, itemVersion])\n console.log('[feed] [processSeeds] Processed item version:', {\n index: i,\n versionId: itemVersion.id,\n seedUid,\n timeCreated: itemVersion.timeCreated,\n versionsForSeedCount: existingVersions.length + 1,\n })\n }\n\n console.log('[feed] [processSeeds] Completed version mapping:', {\n totalVersions: itemVersions.length,\n versionUidToSeedUidSize: versionUidToSeedUid.size,\n versionsBySeedUidSize: versionsBySeedUid.size,\n uniqueSeedsWithVersions: Array.from(versionsBySeedUid.keys()),\n })\n\n // Get latest version for each seed and then use those to get the properties\n console.log('[feed] [processSeeds] Determining latest versions for each seed')\n const latestVersionUids: string[] = []\n \n for (const [seedUid, versions] of versionsBySeedUid.entries()) {\n console.log('[feed] [processSeeds] Processing versions for seed:', {\n seedUid,\n versionsCount: versions.length,\n versionIds: versions.map((v) => v.id),\n timeCreateds: versions.map((v) => v.timeCreated),\n })\n // Sort versions by timeCreated in descending order (most recent first)\n const sortedVersions = [...versions].sort((a, b) => b.timeCreated - a.timeCreated)\n \n console.log('[feed] [processSeeds] Sorted versions:', {\n seedUid,\n sortedVersionIds: sortedVersions.map((v) => v.id),\n sortedTimeCreateds: sortedVersions.map((v) => v.timeCreated),\n })\n \n // Get the most recent version for this seedUid\n if (sortedVersions.length > 0) {\n const latestVersion = sortedVersions[0]\n latestVersionUids.push(latestVersion.id)\n latestVersionUidsBySeedUid.set(seedUid, latestVersion.id)\n console.log('[feed] [processSeeds] Set latest version for seed:', {\n seedUid,\n latestVersionId: latestVersion.id,\n latestTimeCreated: latestVersion.timeCreated,\n })\n } else {\n console.log('[feed] [processSeeds] WARNING: No versions found for seed:', {\n seedUid,\n })\n }\n }\n\n console.log('[feed] [processSeeds] Completed latest version determination:', {\n latestVersionUidsCount: latestVersionUids.length,\n latestVersionUids,\n latestVersionUidsBySeedUidSize: latestVersionUidsBySeedUid.size,\n })\n\n console.log('[feed] [processSeeds] Fetching item properties from EAS:', {\n latestVersionUidsCount: latestVersionUids.length,\n latestVersionUids,\n })\n\n const itemProperties = await getItemPropertiesFromEas({versionUids: latestVersionUids})\n\n console.log('[feed] [processSeeds] Received item properties from EAS:', {\n itemPropertiesCount: itemProperties.length,\n propertyIds: itemProperties.map((p) => p.id),\n })\n\n for (let i = 0; i < itemProperties.length; i++) {\n console.log('[feed] [processSeeds] Processing item property:', {\n index: i,\n propertyId: itemProperties[i].id,\n totalProperties: itemProperties.length,\n })\n await processItemProperty(itemProperties[i], seeds)\n }\n\n console.log('[feed] [processSeeds] Completed processing all seeds:', {\n seedsCount: seeds.length,\n itemVersionsCount: itemVersions.length,\n itemPropertiesCount: itemProperties.length,\n assembledFeedItemsSize: assembledFeedItems.size,\n })\n}\n\nexport const getFeedItemsBySchemaName = async (schemaName: string) => {\n console.log('[feed] [getFeedItemsBySchemaName] Starting feed retrieval:', {\n schemaName,\n currentAssembledItemsSize: assembledFeedItems.size,\n currentRelatedSeedUidsSize: relatedSeedUids.size,\n })\n\n const easClient = BaseEasClient.getEasClient()\n console.log('[feed] [getFeedItemsBySchemaName] Retrieved EAS client')\n\n console.log('[feed] [getFeedItemsBySchemaName] Fetching seeds by schema name:', {\n schemaName,\n })\n const seeds = await getSeedsBySchemaName(schemaName)\n\n console.log('[feed] [getFeedItemsBySchemaName] Received seeds:', {\n seedsCount: seeds.length,\n seedIds: seeds.map((s: Attestation) => s.id),\n })\n\n await processSeeds(seeds)\n\n const relatedSeedUidsArray = Array.from(relatedSeedUids)\n console.log('[feed] [getFeedItemsBySchemaName] Fetching related seeds:', {\n relatedSeedUidsCount: relatedSeedUidsArray.length,\n relatedSeedUids: relatedSeedUidsArray,\n })\n\n const {itemSeeds: relatedSeeds} = await easClient.request(GET_SEEDS, {\n where: {\n id: {\n in: relatedSeedUidsArray,\n },\n },\n })\n\n console.log('[feed] [getFeedItemsBySchemaName] Received related seeds:', {\n relatedSeedsCount: relatedSeeds.length,\n relatedSeedIds: relatedSeeds.map((s: Attestation) => s.id),\n })\n\n await processSeeds(relatedSeeds)\n\n // Filter feed items to only include items matching the requested schema name\n // and apply default values for required RSS fields\n const feedItems = Array.from(assembledFeedItems.entries())\n .filter(([seedUid]) => seedUidToModelType.get(seedUid) === schemaName)\n .map(([seedUid, item]) => {\n // Apply defaults for required RSS feed fields\n setFeedItemDefaults(item, seedUid, schemaName)\n return item\n })\n \n console.log('[feed] [getFeedItemsBySchemaName] Completed feed retrieval:', {\n schemaName,\n feedItemsCount: feedItems.length,\n assembledFeedItemsSize: assembledFeedItems.size,\n filteredFeedItemsCount: feedItems.length,\n feedItemKeys: feedItems.map((item) => Object.keys(item)),\n })\n\n return feedItems\n}"],"names":["logger","schemas","schemasTable","models","modelsTable","propertiesTable","ReactQueryClient"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKO,MAAM,gBAAgB,GAAG,MAAK;AACnC,IAAA,MAAM,MAAM,GAAG,SAAS,EAAE;AAE1B,IAAA,MAAM,aAAa,GAAG,MAAM,CAAC,UAAU,EAAE;IAEzC,MAAM,aAAa,GAAG,WAAW,CAAC,aAAa,EAAE,CAAC,QAAQ,KAAI;AAC5D,QAAA,OAAO,QAAQ,CAAC,KAAK,KAAK,kBAAkB,CAAC,IAAI;AACnD,IAAA,CAAC,CAAC;;AAGF,IAAA,OAAO,aAAa;AACtB,CAAC;;ACXD;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BG;AACG,SAAU,YAAY,CAC1B,KAAmD,EAAA;IAEnD,MAAM,CAAC,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