@marktiderman/genesis-core 2.5.0 → 2.6.0

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.
Files changed (47) hide show
  1. package/dist/{chunk-227N654S.js → chunk-BIIENNTW.js} +2 -2
  2. package/dist/chunk-BIIENNTW.js.map +1 -0
  3. package/dist/{chunk-XMC4EJUE.js → chunk-EHFYSJJA.js} +6 -3
  4. package/dist/chunk-EHFYSJJA.js.map +1 -0
  5. package/dist/chunk-LZVU5NGV.js +82 -0
  6. package/dist/chunk-LZVU5NGV.js.map +1 -0
  7. package/dist/{chunk-X6EO3XBB.js → chunk-OKCSGNCU.js} +9 -4
  8. package/dist/chunk-OKCSGNCU.js.map +1 -0
  9. package/dist/{chunk-H2RGMX6L.js → chunk-OWYX4BEI.js} +3 -3
  10. package/dist/{chunk-H2RGMX6L.js.map → chunk-OWYX4BEI.js.map} +1 -1
  11. package/dist/csv.d.ts +1 -3
  12. package/dist/dates.d.ts +27 -1
  13. package/dist/dates.js +1 -1
  14. package/dist/form-types.d.ts +1 -70
  15. package/dist/hooks/index.d.ts +3 -4
  16. package/dist/hooks/index.js +6 -5
  17. package/dist/hooks/mutation-mode.d.ts +1 -3
  18. package/dist/hooks/related-keys.d.ts +1 -3
  19. package/dist/hooks/use-capabilities.d.ts +1 -2
  20. package/dist/hooks/use-infinite-resource.d.ts +1 -3
  21. package/dist/hooks/use-link-options.d.ts +58 -0
  22. package/dist/hooks/use-link-options.js +10 -0
  23. package/dist/hooks/use-link-options.js.map +1 -0
  24. package/dist/hooks/use-live.d.ts +1 -3
  25. package/dist/hooks/use-one.d.ts +1 -3
  26. package/dist/hooks/use-relation-label.d.ts +8 -4
  27. package/dist/hooks/use-relation-label.js +1 -1
  28. package/dist/hooks/use-resource-form.d.ts +1 -3
  29. package/dist/hooks/use-resource-form.js +2 -2
  30. package/dist/hooks/use-resource.d.ts +1 -3
  31. package/dist/hooks/use-write.d.ts +1 -3
  32. package/dist/index.d.ts +5 -6
  33. package/dist/index.js +6 -5
  34. package/dist/provider/index.d.ts +4 -6
  35. package/dist/resource-view/index.d.ts +85 -4
  36. package/dist/resource-view/index.js +122 -34
  37. package/dist/resource-view/index.js.map +1 -1
  38. package/dist/schema/index.d.ts +3 -5
  39. package/dist/testing/index.d.ts +2 -4
  40. package/dist/types-r_Rlw7BB.d.ts +800 -0
  41. package/dist/{write-outcome-CFnpciUI.d.ts → write-outcome-BWV34wh5.d.ts} +1 -1
  42. package/package.json +1 -1
  43. package/dist/chunk-227N654S.js.map +0 -1
  44. package/dist/chunk-X6EO3XBB.js.map +0 -1
  45. package/dist/chunk-XMC4EJUE.js.map +0 -1
  46. package/dist/types-CXhqXPN1.d.ts +0 -367
  47. package/dist/types-o8j7g6O6.d.ts +0 -331
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/hooks/viewer-scope.tsx","../src/hooks/workspace-scope.tsx"],"names":["Fragment","createContext","useContext","useMemo","useEffect","jsx"],"mappings":";;;;;;;;;;AAUA,IAAI,cAAA,GAAiB,KAAA;AAOrB,SAAS,WAAW,KAAA,EAA+C;AACjE,EAAA,IAAI,QAAA,GAAW,KAAA;AACf,EAAA,MAAM,KAAA,GAAQ,CAAC,CAAA,KAAwB;AACrC,IAAA,IAAI,MAAM,OAAA,CAAQ,CAAC,GAAG,OAAO,CAAA,CAAE,IAAI,KAAK,CAAA,CAAE,GAAA,CAAI,CAAC,MAAM,CAAC,UAAA,CAAW,CAAC,CAAA,EAAG,CAAC,CAAU,CAAA,CAAE,IAAA,CAAK,CAAC,CAAC,CAAC,CAAA,EAAG,CAAC,CAAC,CAAA,KAAO,CAAA,GAAI,IAAI,EAAA,GAAK,CAAA,GAAI,IAAI,CAAA,GAAI,CAAE,EAAE,GAAA,CAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;AACnJ,IAAA,IAAI,CAAA,IAAK,OAAO,CAAA,KAAM,QAAA,EAAU;AAC9B,MAAA,MAAM,KAAA,GAAQ,M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Context, Fragment, useContext, useEffect, useMemo, useRef, useState, type ReactNode } from \"react\";\nimport { dayIn, isTimeZone, personTimeZone, type Day } from \"../dates\";\nimport { reportError } from \"../errors\";\nimport { stableJson } from \"./draft-controller\";\nimport { NO_VIEWER, type GenesisViewerRoles, type Viewer } from \"../viewer\";\nimport { dropPendingWrites, flushPendingWrites } from \"./mutation-mode\";\n\nexport { NO_VIEWER, type GenesisViewerRoles, type Viewer };\n\nlet warnedNotPlain = false;\n\n/**\n * Roles as a value: object keys and lists sorted, so `[\"editor\", \"owner\"]` equals\n * `[\"owner\", \"editor\"]`. A Set, Map or class would stringify as `{}` and hide a change: in\n * development that throws; in production it warns once and the roles count as unknown (undefined).\n */\nfunction rolesKeyOf(roles: GenesisViewerRoles): string | undefined {\n let notPlain = false;\n const plain = (v: unknown): unknown => {\n if (Array.isArray(v)) return v.map(plain).map((x) => [stableJson(x), x] as const).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)).map(([, x]) => x);\n if (v && typeof v === \"object\") {\n const proto = Object.getPrototypeOf(v);\n if (proto !== Object.prototype && proto !== null) {\n if (process.env.NODE_ENV !== \"production\") throw new TypeError(\"[genesis-core] ViewerScope roles must be plain JSON (no Set, Map or class)\");\n notPlain = true;\n return null;\n }\n return Object.fromEntries(Object.entries(v as Record<string, unknown>).map(([k, x]) => [k, plain(x)]));\n }\n return v;\n };\n const key = stableJson(plain(roles));\n if (!notPlain) return key;\n if (!warnedNotPlain) {\n warnedNotPlain = true;\n reportError(new TypeError(\"ViewerScope roles must be plain JSON (no Set, Map or class); treating them as unknown, so guards that need them refuse\"), \"core:viewer-scope\");\n }\n return undefined;\n}\n\n/** Today in `zone`, rechecked when the page comes back into view and at the next minute boundary while it's open. */\nfunction useToday(zone: string): Day {\n const [day, setDay] = useState(() => dayIn(zone));\n useEffect(() => {\n const check = () => setDay(dayIn(zone));\n check();\n const onVisible = () => {\n if (typeof document === \"undefined\" || document.visibilityState === \"visible\") check();\n };\n if (typeof document !== \"undefined\") document.addEventListener(\"visibilitychange\", onVisible);\n // A page left open over midnight rolls over within a minute.\n const timer = setInterval(check, 60_000);\n return () => {\n if (typeof document !== \"undefined\") document.removeEventListener(\"visibilitychange\", onVisible);\n clearInterval(timer);\n };\n }, [zone]);\n return day;\n}\n\n/**\n * Empties the query cache for a new viewer: sends the old viewer's waiting\n * undoable writes (the session is still theirs), cancels reads in flight,\n * then removes every query. Call it in the sign-in and sign-out actions,\n * before the session changes.\n */\nexport async function clearViewerCache(queryClient: QueryClient): Promise<void> {\n await flushPendingWrites(queryClient);\n await queryClient.cancelQueries();\n queryClient.clear();\n}\n\n/**\n * Where the viewer is working: the person, space or set of people Genesis knows by name, plus\n * whatever the app scopes to under its own key (`{ orgId }`, `{ leagueId }`, `{ locationId }`).\n * Screens turn it into server filters and create defaults (a view's `scope: [\"league_id\"]` reads\n * `league_id`, then `leagueId`); it never decides access (row-level security does).\n */\nexport interface ResourceScope {\n personId?: string;\n spaceId?: string;\n /** Several people at once (a coach's client list, a group). */\n personIds?: readonly string[];\n /** The app's own scope keys: `orgId`, `leagueId`, `locationId`, … */\n [key: string]: unknown;\n}\n\nexport interface ViewerContext {\n viewer: string | null;\n scope: ResourceScope;\n /** The viewer's roles (see `GenesisViewerRoles`), when ViewerScope was given them. */\n roles?: GenesisViewerRoles;\n /** The zone the viewer's days are counted in: theirs if known, else the device's. */\n timeZone: string;\n /**\n * The zone of whatever the viewer is scoped to (a location, a league), for columns with\n * `timeZone: \"scope\"`: ViewerScope's `scopeTimeZone` when valid, else {@link timeZone}.\n */\n scopeTimeZone?: string;\n /**\n * Today on the viewer's clock (YYYY-MM-DD), kept current when the page comes back into view.\n * Use it for every \"today\" read and as query keys' `day`: `keys.for(useViewerScope())`.\n */\n day: Day;\n}\n\nconst ViewerContextValue = createContext<ViewerContext | null>(null);\n\n/** The viewer and scope from the nearest `ViewerScope`. Throws without one: screens that cache per viewer need it. */\nexport function useViewerScope(): ViewerContext {\n const value = useContext(ViewerContextValue);\n if (!value) throw new Error(\"[genesis-core] useViewerScope needs a <ViewerScope> above it\");\n return value;\n}\n\n/** Like useViewerScope, or null outside a ViewerScope. */\nexport function useOptionalViewerScope(): ViewerContext | null {\n return useContext(ViewerContextValue);\n}\n\n/**\n * The viewer for guards: `{ id, scope, roles }` from the nearest ViewerScope, or\n * {@link NO_VIEWER} without one. The object is stable while those are equal by value, so it can\n * sit in a memo's dependencies.\n */\nexport function useViewer(): Viewer {\n const context = useContext(ViewerContextValue);\n return useMemo<Viewer>(\n () =>\n context\n ? Object.freeze({ id: context.viewer, scope: context.scope, ...(context.roles !== undefined ? { roles: context.roles } : {}) })\n : NO_VIEWER,\n [context],\n );\n}\n\nexport interface ViewerScopeProps {\n /** The signed-in viewer's id, null when signed out, undefined while the session loads. */\n viewer: string | null | undefined;\n /**\n * The viewer a persisted cache was saved for. When the first known viewer\n * is this one, the restored cache is kept; otherwise it's emptied.\n */\n persistedViewer?: string | null;\n /** Where the viewer is working (see `ResourceScope`). Changing it doesn't remount or clear anything. */\n scope?: ResourceScope;\n /**\n * What the viewer may do there (see `GenesisViewerRoles`), for view guards. Compared by value,\n * so a new object with the same roles changes nothing. Undefined while they load: guards that\n * need them refuse. Arriving (undefined → roles) or going back to undefined changes nothing;\n * different roles send the person's waiting writes, then reread every query, with nothing\n * remounted. Plain JSON values only (lists are compared as sets, in any order): a Set, Map or\n * class instance throws in development; in production it warns once and the roles count as\n * unknown (as if undefined), so guards that need them refuse.\n */\n roles?: GenesisViewerRoles;\n /**\n * The viewer's saved time zone (IANA), when known; else the device's is used. Pass it when\n * rendering on a server, whose own zone is rarely the viewer's.\n */\n timeZone?: string | null;\n /**\n * The IANA zone of whatever the viewer is scoped to (a location, a league), when it has one.\n * Columns with `timeZone: \"scope\"` read on it; without it they read on the viewer's clock.\n */\n scopeTimeZone?: string | null;\n /** Shown while the session loads (and for the one render a change takes). */\n fallback?: ReactNode;\n children: ReactNode;\n}\n\n/**\n * The scope's clock: `scopeTimeZone` when the runtime knows it, else the viewer's. A zone it\n * doesn't know is never a quiet fallback: it throws in development, and in production it is\n * reported (`reportError`, once per zone) before the viewer's clock is used, so a misspelt zone can't show\n * times on the wrong clock unnoticed.\n */\nexport function scopeClock(scopeTimeZone: string | null | undefined, viewerZone: string): string {\n if (scopeTimeZone === undefined || scopeTimeZone === null || scopeTimeZone === \"\") return viewerZone;\n if (isTimeZone(scopeTimeZone)) return scopeTimeZone;\n const error = new RangeError(`[genesis-core] scopeTimeZone \"${scopeTimeZone}\" isn't a time zone this runtime knows (an IANA name such as \"Europe/Berlin\")`);\n if (process.env.NODE_ENV !== \"production\") throw error;\n // Once per zone: a bad zone in a long-lived screen must not flood the error reporter.\n if (!reportedScopeZones.has(scopeTimeZone)) {\n reportedScopeZones.add(scopeTimeZone);\n reportError(error, \"core:viewer-scope\");\n }\n return viewerZone;\n}\n\n/** The unknown scope zones already reported, so each is reported once per page load. */\nconst reportedScopeZones = new Set<string>();\n\n/**\n * Keeps one viewer's cached data from ever showing to the next. Children\n * render only once the viewer is known, under a key of that viewer, so a\n * sign-out or a new person signing in unmounts every screen and its queries\n * before the cache is emptied and the new viewer's screens mount fresh. The\n * first known viewer empties a restored cache too, unless it's the\n * `persistedViewer` it was saved for.\n *\n * ```tsx\n * <ViewerScope viewer={session === undefined ? undefined : (session?.user.id ?? null)}>\n * <App />\n * </ViewerScope>\n * ```\n */\nexport function ViewerScope({ viewer, persistedViewer, scope, roles, timeZone, scopeTimeZone, fallback = null, children }: ViewerScopeProps) {\n const queryClient = useQueryClient();\n const zone = personTimeZone({ timeZone });\n // Memoised, and scopeClock reports a zone once, so a bad zone isn't reported on every render.\n const scopeZone = useMemo(() => scopeClock(scopeTimeZone, zone), [scopeTimeZone, zone]);\n const day = useToday(zone);\n // A new scope object each render shouldn't re-render every reader: compare by value.\n const scopeKey = stableJson(scope ?? {});\n // Roles by value too: undefined stays undefined, so \"not known yet\" never equals \"none\".\n // Roles that aren't plain JSON count as unknown in production (rolesKeyOf warns; development throws).\n const rolesKey = roles === undefined ? undefined : rolesKeyOf(roles);\n const value = useMemo<ViewerContext>(\n () => ({ viewer: viewer ?? null, scope: scope ?? {}, ...(rolesKey !== undefined ? { roles } : {}), timeZone: zone, scopeTimeZone: scopeZone, day }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [viewer, scopeKey, rolesKey, zone, scopeZone, day],\n );\n // The last roles known for this viewer. Arriving (undefined → roles) or going back to undefined\n // changes nothing; different roles for the same person send their waiting writes, then reread\n // everything under the new roles. Nothing remounts: the person, their drafts and their\n // navigation are the same.\n const known = useRef<{ viewer: string | null | undefined; roles: string | undefined }>({ viewer, roles: undefined });\n useEffect(() => {\n if (known.current.viewer !== viewer) known.current = { viewer, roles: undefined };\n if (rolesKey === undefined) return;\n const previous = known.current.roles;\n known.current.roles = rolesKey;\n if (previous === undefined || previous === rolesKey) return;\n // The session is still theirs: their writes go out, and the database decides each one with the\n // roles as they are when it arrives (a refused one fails as any refused write does).\n void flushPendingWrites(queryClient).then(() => queryClient.invalidateQueries());\n }, [viewer, rolesKey, queryClient]);\n // Who the children were last mounted for, and how many times they were reset. Undefined before\n // the first mount.\n const [mounted, setMounted] = useState<{ viewer: string | null; epoch: number } | undefined>(undefined);\n if (viewer === undefined) return <>{fallback}</>;\n if (mounted === undefined || mounted.viewer !== viewer) {\n const keep = mounted === undefined && persistedViewer !== undefined && persistedViewer === viewer;\n // Nothing for the new viewer is mounted yet, so emptying now can't strand\n // a fetch; the old viewer's screens unmount with this render.\n if (!keep) {\n // The session already belongs to the new viewer: the old one's unsent\n // writes must never go out under it. (clearViewerCache, run before the\n // session changes, sends them instead.)\n dropPendingWrites(queryClient);\n void queryClient.cancelQueries();\n queryClient.clear();\n }\n setMounted({ viewer, epoch: (mounted?.epoch ?? 0) + 1 });\n return <>{fallback}</>;\n }\n return (\n <ViewerContextValue.Provider value={value}>\n <Fragment key={`${viewer ?? \"signed-out\"}#${mounted.epoch}`}>{children}</Fragment>\n </ViewerContextValue.Provider>\n );\n}\n","import { createContext, useContext, useEffect, useMemo } from \"react\";\nimport { ViewerScope, type ViewerScopeProps } from \"./viewer-scope\";\nimport { workspaceAt, workspaceHref, type Workspace, type WorkspaceHrefOptions } from \"../workspaces\";\n\n/**\n * The workspace the viewer is in, and where each of their others is from here.\n *\n * @stability Beta\n */\nexport interface WorkspaceContext<W extends Workspace = Workspace> {\n /** Undefined when the URL is in no workspace (the app's front door, a sign-in page). */\n current: W | undefined;\n workspaces: readonly W[];\n /** Where switching to `to` goes from the current URL, keeping the viewer's place when it can. */\n hrefFor: (to: W) => string;\n}\n\nconst WorkspaceContextValue = createContext<WorkspaceContext | null>(null);\n\n/**\n * The nearest `WorkspaceScope`'s workspaces, or null outside one.\n *\n * @stability Beta\n */\nexport function useWorkspace<W extends Workspace = Workspace>(): WorkspaceContext<W> | null {\n return useContext(WorkspaceContextValue) as WorkspaceContext<W> | null;\n}\n\nconst STORAGE_PREFIX = \"genesis:workspace:\";\n\n/**\n * The workspace this viewer was last in on this device, for the app's front door\n * (`defaultWorkspace(workspaces, rememberedWorkspaceId(viewer))`). Null when unknown.\n *\n * @stability Beta\n */\nexport function rememberedWorkspaceId(viewer: string | null | undefined): string | null {\n if (!viewer || typeof window === \"undefined\") return null;\n try {\n return window.localStorage.getItem(STORAGE_PREFIX + viewer);\n } catch {\n return null;\n }\n}\n\nfunction remember(viewer: string, id: string) {\n try {\n window.localStorage.setItem(STORAGE_PREFIX + viewer, id);\n } catch {\n // private mode or full: the front door falls back to the first tenant.\n }\n}\n\n/** @stability Beta */\nexport interface WorkspaceScopeProps<W extends Workspace = Workspace> extends Omit<ViewerScopeProps, \"scope\" | \"roles\" | \"scopeTimeZone\"> {\n /** Every workspace this viewer has. */\n workspaces: readonly W[];\n /** The current URL's path (`useLocation().pathname`): the workspace is read from it. */\n pathname: string;\n /** Scope keys every workspace adds to its own (rarely needed). */\n scope?: ViewerScopeProps[\"scope\"];\n /** How switching keeps the viewer's place (see `workspaceHref`). */\n keep?: WorkspaceHrefOptions[\"keep\"];\n}\n\n/**\n * `ViewerScope` for an app with workspaces: use it in place of `ViewerScope`. It reads the current\n * workspace from the URL and scopes everything under it to that workspace (its `scope`, `roles` and\n * `timeZone`), so every view with `scope: [\"org_id\"]` follows the switcher with no screen code. It\n * remembers the workspace per viewer on this device, and gives `WorkspaceSwitcher` its list.\n *\n * ```tsx\n * <WorkspaceScope viewer={userId} workspaces={workspaces} pathname={location.pathname}>\n * <AppShell headerSlot={<WorkspaceSwitcher linkComponent={Link} />} …>\n * </WorkspaceScope>\n * ```\n *\n * @stability Beta\n */\nexport function WorkspaceScope<W extends Workspace>({ workspaces, pathname, scope, keep, children, ...viewerProps }: WorkspaceScopeProps<W>) {\n const current = workspaceAt(workspaces, pathname);\n const value = useMemo<WorkspaceContext<W>>(\n () => ({\n current,\n workspaces,\n hrefFor: (to) => workspaceHref(workspaces, to, pathname, keep ? { keep } : {}),\n }),\n [current, workspaces, pathname, keep],\n );\n const viewer = viewerProps.viewer;\n useEffect(() => {\n if (viewer && current) remember(viewer, current.id);\n }, [viewer, current]);\n return (\n <WorkspaceContextValue.Provider value={value as unknown as WorkspaceContext}>\n <ViewerScope\n {...viewerProps}\n scope={{ ...scope, ...current?.scope }}\n {...(current?.roles !== undefined ? { roles: current.roles } : {})}\n {...(current?.timeZone !== undefined ? { scopeTimeZone: current.timeZone } : {})}\n >\n {children}\n </ViewerScope>\n </WorkspaceContextValue.Provider>\n );\n}\n\n"]}
1
+ {"version":3,"sources":["../src/hooks/viewer-scope.tsx","../src/hooks/workspace-scope.tsx"],"names":["Fragment","createContext","useContext","useMemo","useEffect","jsx"],"mappings":";;;;;;;;;;AAUA,IAAI,cAAA,GAAiB,KAAA;AAOrB,SAAS,WAAW,KAAA,EAA+C;AACjE,EAAA,IAAI,QAAA,GAAW,KAAA;AACf,EAAA,MAAM,KAAA,GAAQ,CAAC,CAAA,KAAwB;AACrC,IAAA,IAAI,MAAM,OAAA,CAAQ,CAAC,GAAG,OAAO,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AAA;AAAA,MACJ,OAAO,EAAE,GAAG,KAAA,EAAO,GAAG,SAAS,KAAA,EAAM;AAAA,MACpC,GAAI,SAAS,KAAA,KAAU,MAAA,GAAY,EAAE,KAAA,EAAO,OAAA,CAAQ,KAAA,EAAM,GAAI,EAAC;AAAA,MAC/D,GAAI,SAAS,QAAA,KAAa,MAAA,GAAY,EAAE,aAAA,EAAe,OAAA,CAAQ,QAAA,EAAS,GAAI,EAAC;AAAA,MAE7E;AAAA;AAAA,GACH,EACF,CAAA;AAEJ","file":"chunk-OWYX4BEI.js","sourcesContent":["import { useQueryClient, type QueryClient } from \"@tanstack/react-query\";\nimport { createContext, Fragment, useContext, useEffect, useMemo, useRef, useState, type ReactNode } from \"react\";\nimport { dayIn, isTimeZone, personTimeZone, type Day } from \"../dates\";\nimport { reportError } from \"../errors\";\nimport { stableJson } from \"./draft-controller\";\nimport { NO_VIEWER, type GenesisViewerRoles, type Viewer } from \"../viewer\";\nimport { dropPendingWrites, flushPendingWrites } from \"./mutation-mode\";\n\nexport { NO_VIEWER, type GenesisViewerRoles, type Viewer };\n\nlet warnedNotPlain = false;\n\n/**\n * Roles as a value: object keys and lists sorted, so `[\"editor\", \"owner\"]` equals\n * `[\"owner\", \"editor\"]`. A Set, Map or class would stringify as `{}` and hide a change: in\n * development that throws; in production it warns once and the roles count as unknown (undefined).\n */\nfunction rolesKeyOf(roles: GenesisViewerRoles): string | undefined {\n let notPlain = false;\n const plain = (v: unknown): unknown => {\n if (Array.isArray(v)) return v.map(plain).map((x) => [stableJson(x), x] as const).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)).map(([, x]) => x);\n if (v && typeof v === \"object\") {\n const proto = Object.getPrototypeOf(v);\n if (proto !== Object.prototype && proto !== null) {\n if (process.env.NODE_ENV !== \"production\") throw new TypeError(\"[genesis-core] ViewerScope roles must be plain JSON (no Set, Map or class)\");\n notPlain = true;\n return null;\n }\n return Object.fromEntries(Object.entries(v as Record<string, unknown>).map(([k, x]) => [k, plain(x)]));\n }\n return v;\n };\n const key = stableJson(plain(roles));\n if (!notPlain) return key;\n if (!warnedNotPlain) {\n warnedNotPlain = true;\n reportError(new TypeError(\"ViewerScope roles must be plain JSON (no Set, Map or class); treating them as unknown, so guards that need them refuse\"), \"core:viewer-scope\");\n }\n return undefined;\n}\n\n/** Today in `zone`, rechecked when the page comes back into view and at the next minute boundary while it's open. */\nfunction useToday(zone: string): Day {\n const [day, setDay] = useState(() => dayIn(zone));\n useEffect(() => {\n const check = () => setDay(dayIn(zone));\n check();\n const onVisible = () => {\n if (typeof document === \"undefined\" || document.visibilityState === \"visible\") check();\n };\n if (typeof document !== \"undefined\") document.addEventListener(\"visibilitychange\", onVisible);\n // A page left open over midnight rolls over within a minute.\n const timer = setInterval(check, 60_000);\n return () => {\n if (typeof document !== \"undefined\") document.removeEventListener(\"visibilitychange\", onVisible);\n clearInterval(timer);\n };\n }, [zone]);\n return day;\n}\n\n/**\n * Empties the query cache for a new viewer: sends the old viewer's waiting\n * undoable writes (the session is still theirs), cancels reads in flight,\n * then removes every query. Call it in the sign-in and sign-out actions,\n * before the session changes.\n */\nexport async function clearViewerCache(queryClient: QueryClient): Promise<void> {\n await flushPendingWrites(queryClient);\n await queryClient.cancelQueries();\n queryClient.clear();\n}\n\n/**\n * Where the viewer is working: the person, space or set of people Genesis knows by name, plus\n * whatever the app scopes to under its own key (`{ orgId }`, `{ leagueId }`, `{ locationId }`).\n * Screens turn it into server filters and create defaults (a view's `scope: [\"league_id\"]` reads\n * `league_id`, then `leagueId`); it never decides access (row-level security does).\n */\nexport interface ResourceScope {\n personId?: string;\n spaceId?: string;\n /** Several people at once (a coach's client list, a group). */\n personIds?: readonly string[];\n /** The app's own scope keys: `orgId`, `leagueId`, `locationId`, … */\n [key: string]: unknown;\n}\n\nexport interface ViewerContext {\n viewer: string | null;\n scope: ResourceScope;\n /** The viewer's roles (see `GenesisViewerRoles`), when ViewerScope was given them. */\n roles?: GenesisViewerRoles;\n /** The zone the viewer's days are counted in: theirs if known, else the device's. */\n timeZone: string;\n /**\n * The zone of whatever the viewer is scoped to (a location, a league), for columns with\n * `timeZone: \"scope\"`: ViewerScope's `scopeTimeZone` when valid, else {@link timeZone}.\n */\n scopeTimeZone?: string;\n /**\n * Today on the viewer's clock (YYYY-MM-DD), kept current when the page comes back into view.\n * Use it for every \"today\" read and as query keys' `day`: `keys.for(useViewerScope())`.\n */\n day: Day;\n}\n\nconst ViewerContextValue = createContext<ViewerContext | null>(null);\n\n/** The viewer and scope from the nearest `ViewerScope`. Throws without one: screens that cache per viewer need it. */\nexport function useViewerScope(): ViewerContext {\n const value = useContext(ViewerContextValue);\n if (!value) throw new Error(\"[genesis-core] useViewerScope needs a <ViewerScope> above it\");\n return value;\n}\n\n/** Like useViewerScope, or null outside a ViewerScope. */\nexport function useOptionalViewerScope(): ViewerContext | null {\n return useContext(ViewerContextValue);\n}\n\n/**\n * The viewer for guards: `{ id, scope, roles }` from the nearest ViewerScope, or\n * {@link NO_VIEWER} without one. The object is stable while those are equal by value, so it can\n * sit in a memo's dependencies.\n */\nexport function useViewer(): Viewer {\n const context = useContext(ViewerContextValue);\n return useMemo<Viewer>(\n () =>\n context\n ? Object.freeze({ id: context.viewer, scope: context.scope, ...(context.roles !== undefined ? { roles: context.roles } : {}) })\n : NO_VIEWER,\n [context],\n );\n}\n\nexport interface ViewerScopeProps {\n /** The signed-in viewer's id, null when signed out, undefined while the session loads. */\n viewer: string | null | undefined;\n /**\n * The viewer a persisted cache was saved for. When the first known viewer\n * is this one, the restored cache is kept; otherwise it's emptied.\n */\n persistedViewer?: string | null;\n /** Where the viewer is working (see `ResourceScope`). Changing it doesn't remount or clear anything. */\n scope?: ResourceScope;\n /**\n * What the viewer may do there (see `GenesisViewerRoles`), for view guards. Compared by value,\n * so a new object with the same roles changes nothing. Undefined while they load: guards that\n * need them refuse. Arriving (undefined → roles) or going back to undefined changes nothing;\n * different roles send the person's waiting writes, then reread every query, with nothing\n * remounted. Plain JSON values only (lists are compared as sets, in any order): a Set, Map or\n * class instance throws in development; in production it warns once and the roles count as\n * unknown (as if undefined), so guards that need them refuse.\n */\n roles?: GenesisViewerRoles;\n /**\n * The viewer's saved time zone (IANA), when known; else the device's is used. Pass it when\n * rendering on a server, whose own zone is rarely the viewer's.\n */\n timeZone?: string | null;\n /**\n * The IANA zone of whatever the viewer is scoped to (a location, a league), when it has one.\n * Columns with `timeZone: \"scope\"` read on it; without it they read on the viewer's clock.\n */\n scopeTimeZone?: string | null;\n /** Shown while the session loads (and for the one render a change takes). */\n fallback?: ReactNode;\n children: ReactNode;\n}\n\n/**\n * The scope's clock: `scopeTimeZone` when the runtime knows it, else the viewer's. A zone it\n * doesn't know is never a quiet fallback: it throws in development, and in production it is\n * reported (`reportError`, once per zone) before the viewer's clock is used, so a misspelt zone can't show\n * times on the wrong clock unnoticed.\n */\nexport function scopeClock(scopeTimeZone: string | null | undefined, viewerZone: string): string {\n if (scopeTimeZone === undefined || scopeTimeZone === null || scopeTimeZone === \"\") return viewerZone;\n if (isTimeZone(scopeTimeZone)) return scopeTimeZone;\n const error = new RangeError(`[genesis-core] scopeTimeZone \"${scopeTimeZone}\" isn't a time zone this runtime knows (an IANA name such as \"Europe/Berlin\")`);\n if (process.env.NODE_ENV !== \"production\") throw error;\n // Once per zone: a bad zone in a long-lived screen must not flood the error reporter.\n if (!reportedScopeZones.has(scopeTimeZone)) {\n reportedScopeZones.add(scopeTimeZone);\n reportError(error, \"core:viewer-scope\");\n }\n return viewerZone;\n}\n\n/** The unknown scope zones already reported, so each is reported once per page load. */\nconst reportedScopeZones = new Set<string>();\n\n/**\n * Keeps one viewer's cached data from ever showing to the next. Children\n * render only once the viewer is known, under a key of that viewer, so a\n * sign-out or a new person signing in unmounts every screen and its queries\n * before the cache is emptied and the new viewer's screens mount fresh. The\n * first known viewer empties a restored cache too, unless it's the\n * `persistedViewer` it was saved for.\n *\n * ```tsx\n * <ViewerScope viewer={session === undefined ? undefined : (session?.user.id ?? null)}>\n * <App />\n * </ViewerScope>\n * ```\n */\nexport function ViewerScope({ viewer, persistedViewer, scope, roles, timeZone, scopeTimeZone, fallback = null, children }: ViewerScopeProps) {\n const queryClient = useQueryClient();\n const zone = personTimeZone({ timeZone });\n // Memoised, and scopeClock reports a zone once, so a bad zone isn't reported on every render.\n const scopeZone = useMemo(() => scopeClock(scopeTimeZone, zone), [scopeTimeZone, zone]);\n const day = useToday(zone);\n // A new scope object each render shouldn't re-render every reader: compare by value.\n const scopeKey = stableJson(scope ?? {});\n // Roles by value too: undefined stays undefined, so \"not known yet\" never equals \"none\".\n // Roles that aren't plain JSON count as unknown in production (rolesKeyOf warns; development throws).\n const rolesKey = roles === undefined ? undefined : rolesKeyOf(roles);\n const value = useMemo<ViewerContext>(\n () => ({ viewer: viewer ?? null, scope: scope ?? {}, ...(rolesKey !== undefined ? { roles } : {}), timeZone: zone, scopeTimeZone: scopeZone, day }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [viewer, scopeKey, rolesKey, zone, scopeZone, day],\n );\n // The last roles known for this viewer. Arriving (undefined → roles) or going back to undefined\n // changes nothing; different roles for the same person send their waiting writes, then reread\n // everything under the new roles. Nothing remounts: the person, their drafts and their\n // navigation are the same.\n const known = useRef<{ viewer: string | null | undefined; roles: string | undefined }>({ viewer, roles: undefined });\n useEffect(() => {\n if (known.current.viewer !== viewer) known.current = { viewer, roles: undefined };\n if (rolesKey === undefined) return;\n const previous = known.current.roles;\n known.current.roles = rolesKey;\n if (previous === undefined || previous === rolesKey) return;\n // The session is still theirs: their writes go out, and the database decides each one with the\n // roles as they are when it arrives (a refused one fails as any refused write does).\n void flushPendingWrites(queryClient).then(() => queryClient.invalidateQueries());\n }, [viewer, rolesKey, queryClient]);\n // Who the children were last mounted for, and how many times they were reset. Undefined before\n // the first mount.\n const [mounted, setMounted] = useState<{ viewer: string | null; epoch: number } | undefined>(undefined);\n if (viewer === undefined) return <>{fallback}</>;\n if (mounted === undefined || mounted.viewer !== viewer) {\n const keep = mounted === undefined && persistedViewer !== undefined && persistedViewer === viewer;\n // Nothing for the new viewer is mounted yet, so emptying now can't strand\n // a fetch; the old viewer's screens unmount with this render.\n if (!keep) {\n // The session already belongs to the new viewer: the old one's unsent\n // writes must never go out under it. (clearViewerCache, run before the\n // session changes, sends them instead.)\n dropPendingWrites(queryClient);\n void queryClient.cancelQueries();\n queryClient.clear();\n }\n setMounted({ viewer, epoch: (mounted?.epoch ?? 0) + 1 });\n return <>{fallback}</>;\n }\n return (\n <ViewerContextValue.Provider value={value}>\n <Fragment key={`${viewer ?? \"signed-out\"}#${mounted.epoch}`}>{children}</Fragment>\n </ViewerContextValue.Provider>\n );\n}\n","import { createContext, useContext, useEffect, useMemo } from \"react\";\nimport { ViewerScope, type ViewerScopeProps } from \"./viewer-scope\";\nimport { workspaceAt, workspaceHref, type Workspace, type WorkspaceHrefOptions } from \"../workspaces\";\n\n/**\n * The workspace the viewer is in, and where each of their others is from here.\n *\n * @stability Beta\n */\nexport interface WorkspaceContext<W extends Workspace = Workspace> {\n /** Undefined when the URL is in no workspace (the app's front door, a sign-in page). */\n current: W | undefined;\n workspaces: readonly W[];\n /** Where switching to `to` goes from the current URL, keeping the viewer's place when it can. */\n hrefFor: (to: W) => string;\n}\n\nconst WorkspaceContextValue = createContext<WorkspaceContext | null>(null);\n\n/**\n * The nearest `WorkspaceScope`'s workspaces, or null outside one.\n *\n * @stability Beta\n */\nexport function useWorkspace<W extends Workspace = Workspace>(): WorkspaceContext<W> | null {\n return useContext(WorkspaceContextValue) as WorkspaceContext<W> | null;\n}\n\nconst STORAGE_PREFIX = \"genesis:workspace:\";\n\n/**\n * The workspace this viewer was last in on this device, for the app's front door\n * (`defaultWorkspace(workspaces, rememberedWorkspaceId(viewer))`). Null when unknown.\n *\n * @stability Beta\n */\nexport function rememberedWorkspaceId(viewer: string | null | undefined): string | null {\n if (!viewer || typeof window === \"undefined\") return null;\n try {\n return window.localStorage.getItem(STORAGE_PREFIX + viewer);\n } catch {\n return null;\n }\n}\n\nfunction remember(viewer: string, id: string) {\n try {\n window.localStorage.setItem(STORAGE_PREFIX + viewer, id);\n } catch {\n // private mode or full: the front door falls back to the first tenant.\n }\n}\n\n/** @stability Beta */\nexport interface WorkspaceScopeProps<W extends Workspace = Workspace> extends Omit<ViewerScopeProps, \"scope\" | \"roles\" | \"scopeTimeZone\"> {\n /** Every workspace this viewer has. */\n workspaces: readonly W[];\n /** The current URL's path (`useLocation().pathname`): the workspace is read from it. */\n pathname: string;\n /** Scope keys every workspace adds to its own (rarely needed). */\n scope?: ViewerScopeProps[\"scope\"];\n /** How switching keeps the viewer's place (see `workspaceHref`). */\n keep?: WorkspaceHrefOptions[\"keep\"];\n}\n\n/**\n * `ViewerScope` for an app with workspaces: use it in place of `ViewerScope`. It reads the current\n * workspace from the URL and scopes everything under it to that workspace (its `scope`, `roles` and\n * `timeZone`), so every view with `scope: [\"org_id\"]` follows the switcher with no screen code. It\n * remembers the workspace per viewer on this device, and gives `WorkspaceSwitcher` its list.\n *\n * ```tsx\n * <WorkspaceScope viewer={userId} workspaces={workspaces} pathname={location.pathname}>\n * <AppShell headerSlot={<WorkspaceSwitcher linkComponent={Link} />} …>\n * </WorkspaceScope>\n * ```\n *\n * @stability Beta\n */\nexport function WorkspaceScope<W extends Workspace>({ workspaces, pathname, scope, keep, children, ...viewerProps }: WorkspaceScopeProps<W>) {\n const current = workspaceAt(workspaces, pathname);\n const value = useMemo<WorkspaceContext<W>>(\n () => ({\n current,\n workspaces,\n hrefFor: (to) => workspaceHref(workspaces, to, pathname, keep ? { keep } : {}),\n }),\n [current, workspaces, pathname, keep],\n );\n const viewer = viewerProps.viewer;\n useEffect(() => {\n if (viewer && current) remember(viewer, current.id);\n }, [viewer, current]);\n return (\n <WorkspaceContextValue.Provider value={value as unknown as WorkspaceContext}>\n <ViewerScope\n {...viewerProps}\n scope={{ ...scope, ...current?.scope }}\n {...(current?.roles !== undefined ? { roles: current.roles } : {})}\n {...(current?.timeZone !== undefined ? { scopeTimeZone: current.timeZone } : {})}\n >\n {children}\n </ViewerScope>\n </WorkspaceContextValue.Provider>\n );\n}\n\n"]}
package/dist/csv.d.ts CHANGED
@@ -1,6 +1,4 @@
1
- import { D as DataProvider, S as SortParam, F as FilterParam } from './types-CXhqXPN1.js';
2
- import { F as FieldSchema } from './types-o8j7g6O6.js';
3
- import './form-types.js';
1
+ import { D as DataProvider, F as FieldSchema, S as SortParam, a as FilterParam } from './types-r_Rlw7BB.js';
4
2
 
5
3
  /** RFC 4180 field: quoted when it holds a comma, quote or line break. */
6
4
  declare function csvField(value: unknown): string;
package/dist/dates.d.ts CHANGED
@@ -239,6 +239,32 @@ interface RecurrenceOptions {
239
239
  * @stability Beta
240
240
  */
241
241
  declare function expandRecurrence(options: RecurrenceOptions): RecurrenceResult;
242
+ /**
243
+ * One dated occurrence of an event, the shape every calendar reader and writer shares (a feed's
244
+ * events, a provider's, an app's own sessions). A recurring event is one per occurrence, each
245
+ * expanded with `expandRecurrence`.
246
+ *
247
+ * An all-day occurrence's `start` and `end` are days, `end` the day after its last day
248
+ * (exclusive, as RFC 5545 and calendar providers write it). A timed one's are instants, `end`
249
+ * exclusive. Where it came from (a source, its ids) is the reading package's to add.
250
+ *
251
+ * @stability Beta
252
+ */
253
+ interface EventOccurrence {
254
+ title: string;
255
+ location: string | null;
256
+ allDay: boolean;
257
+ start: Day | Date;
258
+ end: Day | Date;
259
+ /** The zone it was written in, when it names one (IANA). */
260
+ timeZone: string | null;
261
+ /** One occurrence of a repeating series. */
262
+ recurring: boolean;
263
+ /** `private`: others see it only as a busy block, without its title or place. */
264
+ visibility: "public" | "private";
265
+ /** A cancelled occurrence is removed, never kept with a status. */
266
+ status: "confirmed" | "tentative";
267
+ }
242
268
  /**
243
269
  * A stored date or timestamp as a calendar value: a day for a `date` column (`dateOnly`) or a
244
270
  * value with no time; an instant for a timestamp. A timestamp written without a zone (Postgres
@@ -253,4 +279,4 @@ declare function readEventTime(value: unknown, options?: {
253
279
  timeZone?: string;
254
280
  }): Day | Date | null;
255
281
 
256
- export { type Day, type DayRange, type Occurrence, type PersonClock, type RRule, type RecurrenceOptions, type RecurrenceResult, type RecurrenceStart, type RuleWeekday, type WallClock, type WallTime, addDays, addMonths, addWeeks, dayIn, dayRangeIn, daysBetween, daysInMonth, deviceTimeZone, eachDay, expandRecurrence, instantIn, isDay, isTimeZone, monthGridRange, monthRange, parseRRule, personDay, personTimeZone, quarterRange, rangeIn, readEventTime, startOfDayIn, startOfMonth, startOfQuarter, startOfWeek, wallClock, wallTimeIn, weekdayOf, weeksRange };
282
+ export { type Day, type DayRange, type EventOccurrence, type Occurrence, type PersonClock, type RRule, type RecurrenceOptions, type RecurrenceResult, type RecurrenceStart, type RuleWeekday, type WallClock, type WallTime, addDays, addMonths, addWeeks, dayIn, dayRangeIn, daysBetween, daysInMonth, deviceTimeZone, eachDay, expandRecurrence, instantIn, isDay, isTimeZone, monthGridRange, monthRange, parseRRule, personDay, personTimeZone, quarterRange, rangeIn, readEventTime, startOfDayIn, startOfMonth, startOfQuarter, startOfWeek, wallClock, wallTimeIn, weekdayOf, weeksRange };
package/dist/dates.js CHANGED
@@ -1,3 +1,3 @@
1
- export { addDays, addMonths, addWeeks, dayIn, dayRangeIn, daysBetween, daysInMonth, deviceTimeZone, eachDay, expandRecurrence, instantIn, isDay, isTimeZone, monthGridRange, monthRange, parseRRule, personDay, personTimeZone, quarterRange, rangeIn, readEventTime, startOfDayIn, startOfMonth, startOfQuarter, startOfWeek, wallClock, wallTimeIn, weekdayOf, weeksRange } from './chunk-227N654S.js';
1
+ export { addDays, addMonths, addWeeks, dayIn, dayRangeIn, daysBetween, daysInMonth, deviceTimeZone, eachDay, expandRecurrence, instantIn, isDay, isTimeZone, monthGridRange, monthRange, parseRRule, personDay, personTimeZone, quarterRange, rangeIn, readEventTime, startOfDayIn, startOfMonth, startOfQuarter, startOfWeek, wallClock, wallTimeIn, weekdayOf, weeksRange } from './chunk-BIIENNTW.js';
2
2
  //# sourceMappingURL=dates.js.map
3
3
  //# sourceMappingURL=dates.js.map
@@ -1,70 +1 @@
1
- type FieldType = "text" | "number" | "email" | "url" | "textarea" | "select" | "checkbox" | "switch" | "date" | "hidden" | "relation" | "file" | "image" | "array";
2
- interface SelectOption {
3
- value: string;
4
- label: string;
5
- }
6
- interface ResourceFormFieldDef {
7
- key: string;
8
- label?: string;
9
- type?: FieldType;
10
- placeholder?: string;
11
- required?: boolean;
12
- defaultValue?: unknown;
13
- options?: SelectOption[];
14
- hidden?: boolean;
15
- /** Shown read-only when editing, and never sent by an edit (a create still sends it). */
16
- readOnlyOnEdit?: boolean;
17
- /**
18
- * The column takes null. A left-empty input is then sent as null on an edit and left out of
19
- * a create (so the column's default applies), text included. `false`: an empty text input keeps
20
- * sending "" (left out of a create when `hasDefault`), while an empty input of another type is
21
- * handled as for `true`, since "" is never a valid value for those. Unset, the form doesn't know
22
- * the column: every empty input is sent as it is ("" or undefined), on a create and an edit.
23
- */
24
- nullable?: boolean;
25
- /**
26
- * The column has a default: a create leaves an empty input out, text included, so the default
27
- * applies. Acts only when `nullable` is set.
28
- */
29
- hasDefault?: boolean;
30
- description?: string;
31
- min?: number;
32
- max?: number;
33
- rows?: number;
34
- /**
35
- * Longest value accepted by a text-like field (text, email, url, textarea).
36
- * Validated on save, and the web renderer also sets the input's
37
- * `maxLength` so the user cannot type past it.
38
- */
39
- maxLength?: number;
40
- /** Relation field configuration. */
41
- relation?: {
42
- resource: string;
43
- labelField: string;
44
- valueField?: string;
45
- searchable?: boolean;
46
- allowCreate?: boolean;
47
- };
48
- /** Accepted file types, e.g. "image/*", ".pdf,.doc". */
49
- accept?: string;
50
- /** Max file size in bytes. Default 10MB. */
51
- maxSize?: number;
52
- /** Allow multiple files. */
53
- multiple?: boolean;
54
- /** Sub-field definitions for array (child records) fields. */
55
- arrayFields?: ResourceFormFieldDef[];
56
- /** Minimum number of array items. */
57
- arrayMin?: number;
58
- /** Maximum number of array items. */
59
- arrayMax?: number;
60
- /** Group heading for field grouping in the form. */
61
- group?: string;
62
- /** Column span in 2-column layout. Default 1. */
63
- colSpan?: 1 | 2;
64
- /** Return false to hide this field based on current form values. */
65
- visible?: (values: Record<string, unknown>) => boolean;
66
- /** Return true to disable this field based on current form values. */
67
- disabled?: (values: Record<string, unknown>) => boolean;
68
- }
69
-
70
- export type { FieldType, ResourceFormFieldDef, SelectOption };
1
+ export { m as FieldType, y as ResourceFormFieldDef, T as SelectOption } from './types-r_Rlw7BB.js';
@@ -1,6 +1,7 @@
1
1
  export { UseResourceOptions, UseResourceReturn, useResource } from './use-resource.js';
2
2
  export { UseOneOptions, useOne } from './use-one.js';
3
- export { UseRelationLabelOptions, loadRelationLabel, useRelationLabel } from './use-relation-label.js';
3
+ export { UseRelationLabelOptions, loadRelationLabel, relationNamingField, useRelationLabel } from './use-relation-label.js';
4
+ export { LinkOption, LinkTarget, UseLinkOptionsOptions, UseLinkOptionsReturn, useLinkOptions } from './use-link-options.js';
4
5
  export { InfinitePageParam, UseInfiniteResourceOptions, UseInfiniteResourceReturn, useInfiniteResource } from './use-infinite-resource.js';
5
6
  export { useCapabilities } from './use-capabilities.js';
6
7
  export { UseWriteOptions, UseWriteReturn, WRITE_FAILED, useWrite } from './use-write.js';
@@ -16,9 +17,7 @@ export { UseWizardReturn, WizardStep, useWizard } from './use-wizard.js';
16
17
  export { DEFAULT_UNDO_DELAY_MS, MutationMode, MutationModeOptions, UndoableWrite, dropPendingWrites, flushPendingWrites, pendingWriteCount } from './mutation-mode.js';
17
18
  export { DEFAULT_UNSAVED_CHANGES_MESSAGE, UseUnsavedChangesGuardOptions, UseUnsavedChangesGuardReturn, useUnsavedChangesGuard } from './use-unsaved-changes-guard.js';
18
19
  import '@tanstack/react-query';
19
- import '../types-CXhqXPN1.js';
20
- import '../types-o8j7g6O6.js';
21
- import '../form-types.js';
20
+ import '../types-r_Rlw7BB.js';
22
21
  import '../dates.js';
23
22
  import 'react-hook-form';
24
23
 
@@ -1,15 +1,16 @@
1
- export { ViewerScope, WorkspaceScope, clearViewerCache, rememberedWorkspaceId, scopeClock, useOptionalViewerScope, useViewer, useViewerScope, useWorkspace } from '../chunk-H2RGMX6L.js';
1
+ export { ViewerScope, WorkspaceScope, clearViewerCache, rememberedWorkspaceId, scopeClock, useOptionalViewerScope, useViewer, useViewerScope, useWorkspace } from '../chunk-OWYX4BEI.js';
2
2
  export { useWizard } from '../chunk-7KOLYF27.js';
3
3
  export { WRITE_FAILED, useWrite } from '../chunk-52T2EYXH.js';
4
4
  export { NO_VIEWER } from '../chunk-OZYF55E3.js';
5
5
  export { useDraft } from '../chunk-DF2UWEEB.js';
6
+ export { useLinkOptions } from '../chunk-LZVU5NGV.js';
6
7
  export { useInfiniteResource } from '../chunk-2VVZ2KX3.js';
7
- export { loadRelationLabel, useRelationLabel } from '../chunk-XMC4EJUE.js';
8
- export { blankValues, buildArrayItemDefaults, useResourceForm } from '../chunk-X6EO3XBB.js';
8
+ export { loadRelationLabel, relationNamingField, useRelationLabel } from '../chunk-EHFYSJJA.js';
9
+ export { blankValues, buildArrayItemDefaults, useResourceForm } from '../chunk-OKCSGNCU.js';
10
+ export { DEFAULT_UNSAVED_CHANGES_MESSAGE, useUnsavedChangesGuard } from '../chunk-XQO4OH2N.js';
9
11
  export { useOne } from '../chunk-GWQHP3RC.js';
10
12
  export { useResource } from '../chunk-CC37H7O2.js';
11
13
  export { DEFAULT_LIVE_DEBOUNCE_MS, DEFAULT_LIVE_RESYNC_MS } from '../chunk-K4ZNAF3G.js';
12
- export { DEFAULT_UNSAVED_CHANGES_MESSAGE, useUnsavedChangesGuard } from '../chunk-XQO4OH2N.js';
13
14
  import '../chunk-UHOMTFBD.js';
14
15
  export { DEFAULT_DRAFT_DELAY_MS, DRAFT_NOT_SAVED, DraftController, isNetworkFailure, stableJson } from '../chunk-HBAPYA5K.js';
15
16
  import '../chunk-AUVKRXRC.js';
@@ -19,7 +20,7 @@ import '../chunk-7NUL32W7.js';
19
20
  export { useCapabilities } from '../chunk-LGTXQTHA.js';
20
21
  import '../chunk-VDEW4AOS.js';
21
22
  import '../chunk-ZYJUEJ4Z.js';
22
- import '../chunk-227N654S.js';
23
+ import '../chunk-BIIENNTW.js';
23
24
  import '../chunk-37RWGNIO.js';
24
25
  import '../chunk-PA6WJE5E.js';
25
26
  import '../chunk-HUNGCTRA.js';
@@ -1,7 +1,5 @@
1
1
  import { QueryClient } from '@tanstack/react-query';
2
- import { a as Identifier, B as BaseRecord, D as DataProvider } from '../types-CXhqXPN1.js';
3
- import { A as AuditEntry } from '../types-o8j7g6O6.js';
4
- import '../form-types.js';
2
+ import { b as Identifier, B as BaseRecord, D as DataProvider, c as AuditEntry } from '../types-r_Rlw7BB.js';
5
3
 
6
4
  type MutationMode = "pessimistic" | "optimistic" | "undoable";
7
5
  /** How long an `undoable` write waits for an undo before it is sent. */
@@ -1,6 +1,4 @@
1
- import { D as DataProvider, W as WriteEvent, I as InvalidationKey } from '../types-CXhqXPN1.js';
2
- import '../types-o8j7g6O6.js';
3
- import '../form-types.js';
1
+ import { D as DataProvider, W as WriteEvent, I as InvalidationKey } from '../types-r_Rlw7BB.js';
4
2
 
5
3
  /**
6
4
  * The cache keys a committed write makes stale beyond `[resource]`: the
@@ -1,6 +1,5 @@
1
1
  import { UseQueryResult } from '@tanstack/react-query';
2
- import { P as ProviderCapabilities } from '../types-o8j7g6O6.js';
3
- import '../form-types.js';
2
+ import { t as ProviderCapabilities } from '../types-r_Rlw7BB.js';
4
3
 
5
4
  /**
6
5
  * The query key for `provider`'s capabilities for `resource`. It includes
@@ -1,8 +1,6 @@
1
1
  import { UseInfiniteQueryResult, InfiniteData } from '@tanstack/react-query';
2
- import { S as SortParam, F as FilterParam, l as ListResult, L as ListParams, B as BaseRecord } from '../types-CXhqXPN1.js';
2
+ import { S as SortParam, a as FilterParam, s as ListResult, L as ListParams, B as BaseRecord } from '../types-r_Rlw7BB.js';
3
3
  import { LiveOptions } from './use-live.js';
4
- import '../types-o8j7g6O6.js';
5
- import '../form-types.js';
6
4
 
7
5
  interface UseInfiniteResourceOptions {
8
6
  defaultSort?: SortParam;
@@ -0,0 +1,58 @@
1
+ import { a as FilterParam } from '../types-r_Rlw7BB.js';
2
+
3
+ interface LinkTarget {
4
+ /** The linked resource. */
5
+ resource: string;
6
+ /** The linked field the link stores. Default `id`. */
7
+ field?: string | undefined;
8
+ /** The linked field that names a row. Default: the provider's `describe`, else a name-like field. */
9
+ labelField?: string | undefined;
10
+ /** The linked fields a search matches. Default: the naming field. */
11
+ searchFields?: readonly string[] | undefined;
12
+ }
13
+ interface UseLinkOptionsOptions {
14
+ /** Filters every request carries: the linked view's scope and default filter, the link's own. */
15
+ filters?: FilterParam[] | undefined;
16
+ /** What the person typed. Sent to the server (`search`), never matched against loaded rows. */
17
+ search?: string | undefined;
18
+ /** Rows per page. Default 25. */
19
+ perPage?: number | undefined;
20
+ /** Default true. A picker passes false until it opens, so a closed form asks for nothing. */
21
+ enabled?: boolean | undefined;
22
+ /**
23
+ * The words for a row whose naming field is empty: a picker passes its catalogue's
24
+ * (`common.untitled`). Default "Untitled". Never the row's raw key.
25
+ */
26
+ untitled?: string | undefined;
27
+ }
28
+ /** One row a picker offers: the key it stores and the words it shows. */
29
+ interface LinkOption {
30
+ /** The linked row's key, as the row holds it (text or a number). */
31
+ value: string | number;
32
+ label: string;
33
+ }
34
+ interface UseLinkOptionsReturn {
35
+ options: LinkOption[];
36
+ /** The naming field used, once known. */
37
+ labelField: string | undefined;
38
+ /** Whether a search can be sent: false when nothing names the rows. */
39
+ searchable: boolean;
40
+ /** The first page is loading. */
41
+ isLoading: boolean;
42
+ isError: boolean;
43
+ /** More rows than are loaded match. */
44
+ hasMore: boolean;
45
+ /** Loads the next page. Does nothing while one loads or none is left. */
46
+ loadMore: () => void;
47
+ isLoadingMore: boolean;
48
+ }
49
+ /**
50
+ * The rows a link can point at, for a picker: listed through the data provider with `filters`,
51
+ * searched on the server with `search` across `searchFields` (else the naming field), sorted by
52
+ * the naming field then the key, `perPage` at a time (`loadMore` for the next). A large table is
53
+ * never loaded whole. Each option is the row's key and its words; a row with no words shows
54
+ * `untitled`, never its key.
55
+ */
56
+ declare function useLinkOptions(target: LinkTarget, options?: UseLinkOptionsOptions): UseLinkOptionsReturn;
57
+
58
+ export { type LinkOption, type LinkTarget, type UseLinkOptionsOptions, type UseLinkOptionsReturn, useLinkOptions };
@@ -0,0 +1,10 @@
1
+ export { useLinkOptions } from '../chunk-LZVU5NGV.js';
2
+ import '../chunk-2VVZ2KX3.js';
3
+ import '../chunk-EHFYSJJA.js';
4
+ import '../chunk-K4ZNAF3G.js';
5
+ import '../chunk-AUVKRXRC.js';
6
+ import '../chunk-7PUFVNPB.js';
7
+ import '../chunk-VDEW4AOS.js';
8
+ import '../chunk-ZYJUEJ4Z.js';
9
+ //# sourceMappingURL=use-link-options.js.map
10
+ //# sourceMappingURL=use-link-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"use-link-options.js"}
@@ -1,7 +1,5 @@
1
1
  import { QueryKey } from '@tanstack/react-query';
2
- import { p as SubscribeParams, m as ResourceChangeEvent } from '../types-CXhqXPN1.js';
3
- import '../types-o8j7g6O6.js';
4
- import '../form-types.js';
2
+ import { V as SubscribeParams, w as ResourceChangeEvent } from '../types-r_Rlw7BB.js';
5
3
 
6
4
  /** How long a burst of change events is gathered into one refetch. */
7
5
  declare const DEFAULT_LIVE_DEBOUNCE_MS = 250;
@@ -1,8 +1,6 @@
1
1
  import { UseQueryResult } from '@tanstack/react-query';
2
- import { B as BaseRecord, a as Identifier } from '../types-CXhqXPN1.js';
2
+ import { B as BaseRecord, b as Identifier } from '../types-r_Rlw7BB.js';
3
3
  import { LiveOptions } from './use-live.js';
4
- import '../types-o8j7g6O6.js';
5
- import '../form-types.js';
6
4
 
7
5
  interface UseOneOptions {
8
6
  /** Supabase select/join syntax, e.g. "*, author:profiles(name)". */
@@ -1,6 +1,4 @@
1
- import { D as DataProvider, a as Identifier } from '../types-CXhqXPN1.js';
2
- import { b as FieldReference } from '../types-o8j7g6O6.js';
3
- import '../form-types.js';
1
+ import { D as DataProvider, l as FieldReference, b as Identifier } from '../types-r_Rlw7BB.js';
4
2
 
5
3
  interface UseRelationLabelOptions {
6
4
  /** The linked row's field that names it. Default: the linked resource's `labelField` (`describe`). */
@@ -8,6 +6,12 @@ interface UseRelationLabelOptions {
8
6
  /** Default `true`. */
9
7
  enabled?: boolean;
10
8
  }
9
+ /**
10
+ * The linked resource's naming field, as a link's words find it: its `labelField` from
11
+ * `describe`, else a `name`/`title`-like field. Undefined when it can't say. Asked once per
12
+ * resource and provider; a picker uses it to search and sort the rows it lists.
13
+ */
14
+ declare function relationNamingField(provider: DataProvider, resource: string): Promise<string | undefined>;
11
15
  /**
12
16
  * The words for one linked id, batched with every other id asked for in the same tick: one
13
17
  * `getList(resource, { filters: [{ field, operator: "in" }] })` per linked resource and naming
@@ -22,4 +26,4 @@ declare function loadRelationLabel(provider: DataProvider, reference: FieldRefer
22
26
  */
23
27
  declare function useRelationLabel(reference: FieldReference | undefined, id: unknown, options?: UseRelationLabelOptions): string | null | undefined;
24
28
 
25
- export { type UseRelationLabelOptions, loadRelationLabel, useRelationLabel };
29
+ export { type UseRelationLabelOptions, loadRelationLabel, relationNamingField, useRelationLabel };
@@ -1,4 +1,4 @@
1
- export { loadRelationLabel, useRelationLabel } from '../chunk-XMC4EJUE.js';
1
+ export { loadRelationLabel, relationNamingField, useRelationLabel } from '../chunk-EHFYSJJA.js';
2
2
  import '../chunk-VDEW4AOS.js';
3
3
  import '../chunk-ZYJUEJ4Z.js';
4
4
  //# sourceMappingURL=use-relation-label.js.map
@@ -1,8 +1,6 @@
1
1
  import { UseFormReturn } from 'react-hook-form';
2
- import { ResourceFormFieldDef } from '../form-types.js';
3
- import { I as InvalidationKey } from '../types-CXhqXPN1.js';
2
+ import { y as ResourceFormFieldDef, I as InvalidationKey } from '../types-r_Rlw7BB.js';
4
3
  import { MutationModeOptions } from './mutation-mode.js';
5
- import '../types-o8j7g6O6.js';
6
4
  import '@tanstack/react-query';
7
5
 
8
6
  interface UseResourceFormOptions extends MutationModeOptions {
@@ -1,7 +1,7 @@
1
- export { blankValues, buildArrayItemDefaults, useResourceForm } from '../chunk-X6EO3XBB.js';
1
+ export { blankValues, buildArrayItemDefaults, useResourceForm } from '../chunk-OKCSGNCU.js';
2
+ import '../chunk-XQO4OH2N.js';
2
3
  import '../chunk-GWQHP3RC.js';
3
4
  import '../chunk-K4ZNAF3G.js';
4
- import '../chunk-XQO4OH2N.js';
5
5
  import '../chunk-AUVKRXRC.js';
6
6
  import '../chunk-OSFG3GFY.js';
7
7
  import '../chunk-7PUFVNPB.js';
@@ -1,9 +1,7 @@
1
1
  import { UseQueryResult, UseMutationResult } from '@tanstack/react-query';
2
- import { S as SortParam, F as FilterParam, I as InvalidationKey, l as ListResult, L as ListParams, a as Identifier, B as BaseRecord } from '../types-CXhqXPN1.js';
2
+ import { S as SortParam, a as FilterParam, I as InvalidationKey, s as ListResult, L as ListParams, b as Identifier, B as BaseRecord } from '../types-r_Rlw7BB.js';
3
3
  import { MutationModeOptions } from './mutation-mode.js';
4
4
  import { LiveOptions } from './use-live.js';
5
- import '../types-o8j7g6O6.js';
6
- import '../form-types.js';
7
5
 
8
6
  interface UseResourceOptions<T> extends MutationModeOptions {
9
7
  defaultSort?: SortParam;
@@ -1,7 +1,5 @@
1
1
  import { QueryClient, MutationOptions } from '@tanstack/react-query';
2
- import { I as InvalidationKey } from '../types-CXhqXPN1.js';
3
- import '../types-o8j7g6O6.js';
4
- import '../form-types.js';
2
+ import { I as InvalidationKey } from '../types-r_Rlw7BB.js';
5
3
 
6
4
  declare const WRITE_FAILED = "That didn't work. Try again.";
7
5
  interface UseWriteOptions<A, R> {
package/dist/index.d.ts CHANGED
@@ -1,13 +1,14 @@
1
- import { L as ListParams, a as Identifier } from './types-CXhqXPN1.js';
2
- export { A as ArrayFilter, B as BaseRecord, b as BulkChange, c as BulkResult, C as CountMode, d as CreateParams, e as CreateResult, D as DataProvider, f as DeleteParams, g as DeleteResult, F as FilterParam, G as GetManyParams, h as GetManyResult, i as GetOneParams, j as GetOneResult, H as HistoryParams, k as ImportParams, I as InvalidationKey, l as ListResult, N as NullFilter, P as PaginationParam, R as RangeFilter, m as ResourceChangeEvent, n as RowFailure, o as ScalarFilter, S as SortParam, p as SubscribeParams, U as UpdateParams, q as UpdateResult, W as WriteEvent } from './types-CXhqXPN1.js';
3
- export { D as DataWriteError, a as DataWriteErrorOptions, W as WriteOutcome, i as isDataWriteError } from './write-outcome-CFnpciUI.js';
1
+ import { L as ListParams, b as Identifier } from './types-r_Rlw7BB.js';
2
+ export { A as ArrayFilter, c as AuditEntry, B as BaseRecord, d as BulkChange, e as BulkResult, C as CountMode, f as CreateParams, g as CreateResult, D as DataProvider, h as DataRow, i as DeleteParams, j as DeleteResult, k as FieldPermissions, l as FieldReference, F as FieldSchema, m as FieldType, n as FilterOperator, a as FilterParam, G as GetManyParams, o as GetManyResult, p as GetOneParams, q as GetOneResult, H as HistoryParams, r as ImportParams, I as InvalidationKey, s as ListResult, N as NullFilter, P as PaginationParam, t as ProviderCapabilities, R as RangeFilter, u as RecordComment, v as ResourceAccess, w as ResourceChangeEvent, x as ResourceContract, y as ResourceFormFieldDef, z as ResourceRelation, E as ResourceSchema, J as ResourceSummary, K as RowAction, M as RowFailure, O as RowOf, Q as ScalarFilter, T as SelectOption, S as SortParam, U as StorageType, V as SubscribeParams, X as UpdateParams, Y as UpdateResult, Z as VersionField, m as WidgetHint, W as WriteEvent, _ as defineResource } from './types-r_Rlw7BB.js';
3
+ export { D as DataWriteError, a as DataWriteErrorOptions, W as WriteOutcome, i as isDataWriteError } from './write-outcome-BWV34wh5.js';
4
4
  export { CallRpcOptions, CreateOrAdoptOptions, CreateOrAdoptResult, DEFAULT_RPC_MESSAGES, DataProviderRoot, DataProviderRootProps, GenesisProvider, GenesisProviderProps, MockProviderOptions, PostgrestFieldErrors, RPC_FAILED, RpcClient, SupabaseClient, SupabaseClientInput, SupabaseProviderOptions, SupabaseRealtimeChannel, SupabaseRealtimePayload, SupabaseResourceConfig, SupabaseWriteContext, callRpc, createMockProvider, createOrAdopt, createSupabaseProvider, fieldErrorsFromPostgrest, readOutcomeFromCode, toDataWriteError, useDataProvider, useStorage, writeOutcomeFromCode } from './provider/index.js';
5
5
  export { D as DataReadError, a as DataReadErrorOptions, R as ReadOutcome, i as isDataReadError, r as readFailureMessage } from './read-outcome-BnboMYOV.js';
6
6
  export { S as StorageAdapter } from './types-DKcxHXxq.js';
7
7
  export { createLocalStorageAdapter, createMemoryStorageAdapter, createNoopStorageAdapter } from './storage/index.js';
8
8
  export { UseResourceOptions, UseResourceReturn, useResource } from './hooks/use-resource.js';
9
9
  export { UseOneOptions, useOne } from './hooks/use-one.js';
10
- export { UseRelationLabelOptions, loadRelationLabel, useRelationLabel } from './hooks/use-relation-label.js';
10
+ export { UseRelationLabelOptions, loadRelationLabel, relationNamingField, useRelationLabel } from './hooks/use-relation-label.js';
11
+ export { LinkOption, LinkTarget, UseLinkOptionsOptions, UseLinkOptionsReturn, useLinkOptions } from './hooks/use-link-options.js';
11
12
  export { InfinitePageParam, UseInfiniteResourceOptions, UseInfiniteResourceReturn, useInfiniteResource } from './hooks/use-infinite-resource.js';
12
13
  export { useCapabilities } from './hooks/use-capabilities.js';
13
14
  export { UseWriteOptions, UseWriteReturn, WRITE_FAILED, useWrite } from './hooks/use-write.js';
@@ -20,8 +21,6 @@ export { UseResourceFormOptions, UseResourceFormReturn, blankValues, buildArrayI
20
21
  export { UseWizardReturn, WizardStep, useWizard } from './hooks/use-wizard.js';
21
22
  export { DEFAULT_UNDO_DELAY_MS, MutationMode, MutationModeOptions, UndoableWrite, dropPendingWrites, flushPendingWrites, pendingWriteCount } from './hooks/mutation-mode.js';
22
23
  export { DEFAULT_UNSAVED_CHANGES_MESSAGE, UseUnsavedChangesGuardOptions, UseUnsavedChangesGuardReturn, useUnsavedChangesGuard } from './hooks/use-unsaved-changes-guard.js';
23
- export { FieldType, ResourceFormFieldDef, SelectOption, FieldType as WidgetHint } from './form-types.js';
24
- export { A as AuditEntry, D as DataRow, a as FieldPermissions, b as FieldReference, F as FieldSchema, c as FilterOperator, P as ProviderCapabilities, R as RecordComment, d as ResourceAccess, e as ResourceContract, f as ResourceRelation, g as ResourceSchema, h as ResourceSummary, i as RowAction, j as RowOf, S as StorageType, V as VersionField, k as defineResource } from './types-o8j7g6O6.js';
25
24
  export { decodeRecordKey, encodeRecordKey, keyFields } from './schema/index.js';
26
25
  import { Query } from '@tanstack/react-query';
27
26
  export { isSafeUrl, normalizeLinkUrl } from './urls.js';
package/dist/index.js CHANGED
@@ -2,18 +2,19 @@ export { DEFAULT_RPC_MESSAGES, RPC_FAILED, callRpc, createOrAdopt, createSupabas
2
2
  export { defineResource } from './chunk-7FVTGKTX.js';
3
3
  export { decodeRecordKey, encodeRecordKey, keyFields } from './chunk-KV2HW4G4.js';
4
4
  import './chunk-XCX2TRBL.js';
5
- export { ViewerScope, WorkspaceScope, clearViewerCache, rememberedWorkspaceId, scopeClock, useOptionalViewerScope, useViewer, useViewerScope, useWorkspace } from './chunk-H2RGMX6L.js';
5
+ export { ViewerScope, WorkspaceScope, clearViewerCache, rememberedWorkspaceId, scopeClock, useOptionalViewerScope, useViewer, useViewerScope, useWorkspace } from './chunk-OWYX4BEI.js';
6
6
  export { useWizard } from './chunk-7KOLYF27.js';
7
7
  export { WRITE_FAILED, useWrite } from './chunk-52T2EYXH.js';
8
8
  export { NO_VIEWER } from './chunk-OZYF55E3.js';
9
9
  export { useDraft } from './chunk-DF2UWEEB.js';
10
+ export { useLinkOptions } from './chunk-LZVU5NGV.js';
10
11
  export { useInfiniteResource } from './chunk-2VVZ2KX3.js';
11
- export { loadRelationLabel, useRelationLabel } from './chunk-XMC4EJUE.js';
12
- export { blankValues, buildArrayItemDefaults, useResourceForm } from './chunk-X6EO3XBB.js';
12
+ export { loadRelationLabel, relationNamingField, useRelationLabel } from './chunk-EHFYSJJA.js';
13
+ export { blankValues, buildArrayItemDefaults, useResourceForm } from './chunk-OKCSGNCU.js';
14
+ export { DEFAULT_UNSAVED_CHANGES_MESSAGE, useUnsavedChangesGuard } from './chunk-XQO4OH2N.js';
13
15
  export { useOne } from './chunk-GWQHP3RC.js';
14
16
  export { useResource } from './chunk-CC37H7O2.js';
15
17
  export { DEFAULT_LIVE_DEBOUNCE_MS, DEFAULT_LIVE_RESYNC_MS } from './chunk-K4ZNAF3G.js';
16
- export { DEFAULT_UNSAVED_CHANGES_MESSAGE, useUnsavedChangesGuard } from './chunk-XQO4OH2N.js';
17
18
  import './chunk-UHOMTFBD.js';
18
19
  export { DEFAULT_DRAFT_DELAY_MS, DRAFT_NOT_SAVED, DraftController, isNetworkFailure, stableJson } from './chunk-HBAPYA5K.js';
19
20
  import './chunk-AUVKRXRC.js';
@@ -23,7 +24,7 @@ import './chunk-7NUL32W7.js';
23
24
  export { useCapabilities } from './chunk-LGTXQTHA.js';
24
25
  export { DataProviderRoot, GenesisProvider, createMockProvider, useDataProvider, useStorage } from './chunk-VDEW4AOS.js';
25
26
  export { createLocalStorageAdapter, createMemoryStorageAdapter, createNoopStorageAdapter } from './chunk-ZYJUEJ4Z.js';
26
- import './chunk-227N654S.js';
27
+ import './chunk-BIIENNTW.js';
27
28
  export { classifyError, defaultErrorReporter, errorMessages, getErrorReporter, reportError, setErrorReporter } from './chunk-37RWGNIO.js';
28
29
  export { fieldErrorsFromPostgrest, readOutcomeFromCode, toDataWriteError, writeOutcomeFromCode } from './chunk-PA6WJE5E.js';
29
30
  export { DataReadError, isDataReadError, readFailureMessage } from './chunk-HUNGCTRA.js';
@@ -1,15 +1,13 @@
1
- import { D as DataProvider, a as Identifier, B as BaseRecord, I as InvalidationKey, W as WriteEvent, C as CountMode, F as FilterParam } from '../types-CXhqXPN1.js';
2
- export { A as ArrayFilter, b as BulkChange, c as BulkResult, d as CreateParams, e as CreateResult, f as DeleteParams, g as DeleteResult, G as GetManyParams, h as GetManyResult, i as GetOneParams, j as GetOneResult, H as HistoryParams, k as ImportParams, L as ListParams, l as ListResult, N as NullFilter, P as PaginationParam, R as RangeFilter, m as ResourceChangeEvent, n as RowFailure, o as ScalarFilter, S as SortParam, p as SubscribeParams, U as UpdateParams, q as UpdateResult } from '../types-CXhqXPN1.js';
3
- import { D as DataWriteError, W as WriteOutcome } from '../write-outcome-CFnpciUI.js';
4
- export { a as DataWriteErrorOptions, i as isDataWriteError } from '../write-outcome-CFnpciUI.js';
1
+ import { D as DataProvider, b as Identifier, B as BaseRecord, I as InvalidationKey, W as WriteEvent, C as CountMode, a as FilterParam } from '../types-r_Rlw7BB.js';
2
+ export { A as ArrayFilter, d as BulkChange, e as BulkResult, f as CreateParams, g as CreateResult, i as DeleteParams, j as DeleteResult, G as GetManyParams, o as GetManyResult, p as GetOneParams, q as GetOneResult, H as HistoryParams, r as ImportParams, L as ListParams, s as ListResult, N as NullFilter, P as PaginationParam, R as RangeFilter, w as ResourceChangeEvent, M as RowFailure, Q as ScalarFilter, S as SortParam, V as SubscribeParams, X as UpdateParams, Y as UpdateResult } from '../types-r_Rlw7BB.js';
3
+ import { D as DataWriteError, W as WriteOutcome } from '../write-outcome-BWV34wh5.js';
4
+ export { a as DataWriteErrorOptions, i as isDataWriteError } from '../write-outcome-BWV34wh5.js';
5
5
  import { D as DataReadError, R as ReadOutcome } from '../read-outcome-BnboMYOV.js';
6
6
  export { a as DataReadErrorOptions, i as isDataReadError, r as readFailureMessage } from '../read-outcome-BnboMYOV.js';
7
7
  import * as react from 'react';
8
8
  import { ReactNode } from 'react';
9
9
  import { QueryClient } from '@tanstack/react-query';
10
10
  import { S as StorageAdapter } from '../types-DKcxHXxq.js';
11
- import '../types-o8j7g6O6.js';
12
- import '../form-types.js';
13
11
 
14
12
  interface MockProviderOptions {
15
13
  /** Simulated latency in ms (default 0). */