Prometheus Entity Management API
    Preparing search index...
    • The graph imperative access should target right now.

      Precedence: request scope (ALS) → module-level active store → fallback. fallback is the package singleton, supplied by the caller to avoid a circular import with graph.ts.

      Parameters

      • fallback: Omit<
            Omit<StoreApi<GraphState>, "subscribe"> & {
                subscribe: {
                    (
                        listener: (
                            selectedState: GraphState,
                            previousSelectedState: GraphState,
                        ) => void,
                    ): () => void;
                    <U>(
                        selector: (state: GraphState) => U,
                        listener: (selectedState: U, previousSelectedState: U) => void,
                        options?: {
                            equalityFn?: (a: U, b: U) => boolean;
                            fireImmediately?: boolean;
                        },
                    ): () => void;
                };
            },
            "setState",
        > & {
            setState(
                nextStateOrUpdater:
                    | GraphState
                    | Partial<GraphState>
                    | (
                        (
                            state: {
                                appendListResult: (
                                    key: string,
                                    ids: string[],
                                    meta: Partial<
                                        Omit<
                                            ListState,
                                            "ids"
                                            | "isFetching"
                                            | "isFetchingMore"
                                            | "error"
                                            | "stale",
                                        >,
                                    >,
                                ) => void;
                                clearEntitySyncMetadata: (type: string, id: string) => void;
                                clearPatch: (type: string, id: string) => void;
                                entities: { [x: string]: { [x: string]: { [x: string]: unknown } } };
                                entityStates: {
                                    [x: string]: {
                                        error: string | null;
                                        isFetching: boolean;
                                        lastFetched: number | null;
                                        stale: boolean;
                                    };
                                };
                                ingestFetchedList: (
                                    type: string,
                                    entries: { data: Record<string, unknown>; id: string }[],
                                    options?: IngestFetchedListOptions,
                                ) => void;
                                insertIdInList: (
                                    key: string,
                                    id: string,
                                    position: number | "end" | "start",
                                ) => void;
                                invalidateEntity: (type: string, id?: string) => void;
                                invalidateLists: (
                                    matcher: string | ((key: string) => boolean),
                                ) => void;
                                invalidateType: (type: string) => void;
                                lists: {
                                    [x: string]: {
                                        currentPage: number | null;
                                        error: string | null;
                                        hasNextPage: boolean;
                                        hasPrevPage: boolean;
                                        ids: string[];
                                        isFetching: boolean;
                                        isFetchingMore: boolean;
                                        lastError:
                                            | {
                                                cause?: unknown;
                                                kind: "terminal";
                                                message: string;
                                                name: string;
                                                stack?: string;
                                                status?: number;
                                            }
                                            | {
                                                cause?: unknown;
                                                kind: "transient";
                                                message: string;
                                                name: string;
                                                stack?: string;
                                                status?: number;
                                            }
                                            | null;
                                        lastFetched: number
                                        | null;
                                        nextCursor: string | null;
                                        pageSize: number | null;
                                        prevCursor: string | null;
                                        stale: boolean;
                                        total: number | null;
                                    };
                                };
                                patchEntity: (
                                    type: string,
                                    id: string,
                                    patch: Record<string, unknown>,
                                ) => void;
                                patches: { [x: string]: { [x: string]: { [x: string]: unknown } } };
                                prependListResult: (
                                    key: string,
                                    ids: string[],
                                    meta?: Partial<ListState>,
                                ) => void;
                                readEntity: <T = Record<string, unknown>>(
                                    type: string,
                                    id: string,
                                ) => T | null;
                                readEntitySnapshot: <T = Record<string, unknown>>(
                                    type: string,
                                    id: string,
                                ) => EntitySnapshot<T & Record<string, unknown>> | null;
                                removeEntity: (type: string, id: string) => void;
                                removeIdFromAllLists: (type: string, id: string) => void;
                                replaceEntity: (
                                    type: string,
                                    id: string,
                                    data: Record<string, unknown>,
                                ) => void;
                                setEntityError: (
                                    type: string,
                                    id: string,
                                    error: string | null,
                                ) => void;
                                setEntityFetched: (type: string, id: string) => void;
                                setEntityFetching: (
                                    type: string,
                                    id: string,
                                    fetching: boolean,
                                ) => void;
                                setEntityStale: (type: string, id: string, stale: boolean) => void;
                                setEntitySyncMetadata: (
                                    type: string,
                                    id: string,
                                    metadata: Partial<EntitySyncMetadata>,
                                ) => void;
                                setListError: (
                                    key: string,
                                    error: string | null,
                                    typed?: EntityError | null,
                                ) => void;
                                setListFetching: (key: string, fetching: boolean) => void;
                                setListFetchingMore: (key: string, fetchingMore: boolean) => void;
                                setListResult: (
                                    key: string,
                                    ids: string[],
                                    meta: Partial<
                                        Omit<
                                            ListState,
                                            "ids"
                                            | "isFetching"
                                            | "isFetchingMore"
                                            | "error"
                                            | "stale",
                                        >,
                                    >,
                                ) => void;
                                setListStale: (key: string, stale: boolean) => void;
                                syncMetadata: {
                                    [x: string]: {
                                        origin: SyncOrigin;
                                        synced: boolean;
                                        updatedAt: number | null;
                                    };
                                };
                                unpatchEntity: (type: string, id: string, keys: string[]) => void;
                                upsertEntities: (
                                    type: string,
                                    entries: { data: Record<string, unknown>; id: string }[],
                                ) => void;
                                upsertEntity: (
                                    type: string,
                                    id: string,
                                    data: Record<string, unknown>,
                                ) => void;
                            },
                        ) => void
                    ),
                shouldReplace?: false,
            ): void;
            setState(
                nextStateOrUpdater:
                    | GraphState
                    | (
                        (
                            state: {
                                appendListResult: (
                                    key: string,
                                    ids: string[],
                                    meta: Partial<
                                        Omit<
                                            ListState,
                                            "ids"
                                            | "isFetching"
                                            | "isFetchingMore"
                                            | "error"
                                            | "stale",
                                        >,
                                    >,
                                ) => void;
                                clearEntitySyncMetadata: (type: string, id: string) => void;
                                clearPatch: (type: string, id: string) => void;
                                entities: { [x: string]: { [x: string]: { [x: string]: unknown } } };
                                entityStates: {
                                    [x: string]: {
                                        error: string | null;
                                        isFetching: boolean;
                                        lastFetched: number | null;
                                        stale: boolean;
                                    };
                                };
                                ingestFetchedList: (
                                    type: string,
                                    entries: { data: Record<string, unknown>; id: string }[],
                                    options?: IngestFetchedListOptions,
                                ) => void;
                                insertIdInList: (
                                    key: string,
                                    id: string,
                                    position: number | "end" | "start",
                                ) => void;
                                invalidateEntity: (type: string, id?: string) => void;
                                invalidateLists: (
                                    matcher: string | ((key: string) => boolean),
                                ) => void;
                                invalidateType: (type: string) => void;
                                lists: {
                                    [x: string]: {
                                        currentPage: number | null;
                                        error: string | null;
                                        hasNextPage: boolean;
                                        hasPrevPage: boolean;
                                        ids: string[];
                                        isFetching: boolean;
                                        isFetchingMore: boolean;
                                        lastError:
                                            | {
                                                cause?: unknown;
                                                kind: "terminal";
                                                message: string;
                                                name: string;
                                                stack?: string;
                                                status?: number;
                                            }
                                            | {
                                                cause?: unknown;
                                                kind: "transient";
                                                message: string;
                                                name: string;
                                                stack?: string;
                                                status?: number;
                                            }
                                            | null;
                                        lastFetched: number
                                        | null;
                                        nextCursor: string | null;
                                        pageSize: number | null;
                                        prevCursor: string | null;
                                        stale: boolean;
                                        total: number | null;
                                    };
                                };
                                patchEntity: (
                                    type: string,
                                    id: string,
                                    patch: Record<string, unknown>,
                                ) => void;
                                patches: { [x: string]: { [x: string]: { [x: string]: unknown } } };
                                prependListResult: (
                                    key: string,
                                    ids: string[],
                                    meta?: Partial<ListState>,
                                ) => void;
                                readEntity: <T = Record<string, unknown>>(
                                    type: string,
                                    id: string,
                                ) => T | null;
                                readEntitySnapshot: <T = Record<string, unknown>>(
                                    type: string,
                                    id: string,
                                ) => EntitySnapshot<T & Record<string, unknown>> | null;
                                removeEntity: (type: string, id: string) => void;
                                removeIdFromAllLists: (type: string, id: string) => void;
                                replaceEntity: (
                                    type: string,
                                    id: string,
                                    data: Record<string, unknown>,
                                ) => void;
                                setEntityError: (
                                    type: string,
                                    id: string,
                                    error: string | null,
                                ) => void;
                                setEntityFetched: (type: string, id: string) => void;
                                setEntityFetching: (
                                    type: string,
                                    id: string,
                                    fetching: boolean,
                                ) => void;
                                setEntityStale: (type: string, id: string, stale: boolean) => void;
                                setEntitySyncMetadata: (
                                    type: string,
                                    id: string,
                                    metadata: Partial<EntitySyncMetadata>,
                                ) => void;
                                setListError: (
                                    key: string,
                                    error: string | null,
                                    typed?: EntityError | null,
                                ) => void;
                                setListFetching: (key: string, fetching: boolean) => void;
                                setListFetchingMore: (key: string, fetchingMore: boolean) => void;
                                setListResult: (
                                    key: string,
                                    ids: string[],
                                    meta: Partial<
                                        Omit<
                                            ListState,
                                            "ids"
                                            | "isFetching"
                                            | "isFetchingMore"
                                            | "error"
                                            | "stale",
                                        >,
                                    >,
                                ) => void;
                                setListStale: (key: string, stale: boolean) => void;
                                syncMetadata: {
                                    [x: string]: {
                                        origin: SyncOrigin;
                                        synced: boolean;
                                        updatedAt: number | null;
                                    };
                                };
                                unpatchEntity: (type: string, id: string, keys: string[]) => void;
                                upsertEntities: (
                                    type: string,
                                    entries: { data: Record<string, unknown>; id: string }[],
                                ) => void;
                                upsertEntity: (
                                    type: string,
                                    id: string,
                                    data: Record<string, unknown>,
                                ) => void;
                            },
                        ) => void
                    ),
                shouldReplace: true,
            ): void;
        }

      Returns Omit<
          Omit<StoreApi<GraphState>, "subscribe"> & {
              subscribe: {
                  (
                      listener: (
                          selectedState: GraphState,
                          previousSelectedState: GraphState,
                      ) => void,
                  ): () => void;
                  <U>(
                      selector: (state: GraphState) => U,
                      listener: (selectedState: U, previousSelectedState: U) => void,
                      options?: {
                          equalityFn?: (a: U, b: U) => boolean;
                          fireImmediately?: boolean;
                      },
                  ): () => void;
              };
          },
          "setState",
      > & {
          setState(
              nextStateOrUpdater:
                  | GraphState
                  | Partial<GraphState>
                  | (
                      (
                          state: {
                              appendListResult: (
                                  key: string,
                                  ids: string[],
                                  meta: Partial<
                                      Omit<
                                          ListState,
                                          "ids"
                                          | "isFetching"
                                          | "isFetchingMore"
                                          | "error"
                                          | "stale",
                                      >,
                                  >,
                              ) => void;
                              clearEntitySyncMetadata: (type: string, id: string) => void;
                              clearPatch: (type: string, id: string) => void;
                              entities: { [x: string]: { [x: string]: { [x: string]: unknown } } };
                              entityStates: {
                                  [x: string]: {
                                      error: string | null;
                                      isFetching: boolean;
                                      lastFetched: number | null;
                                      stale: boolean;
                                  };
                              };
                              ingestFetchedList: (
                                  type: string,
                                  entries: { data: Record<string, unknown>; id: string }[],
                                  options?: IngestFetchedListOptions,
                              ) => void;
                              insertIdInList: (
                                  key: string,
                                  id: string,
                                  position: number | "end" | "start",
                              ) => void;
                              invalidateEntity: (type: string, id?: string) => void;
                              invalidateLists: (
                                  matcher: string | ((key: string) => boolean),
                              ) => void;
                              invalidateType: (type: string) => void;
                              lists: {
                                  [x: string]: {
                                      currentPage: number | null;
                                      error: string | null;
                                      hasNextPage: boolean;
                                      hasPrevPage: boolean;
                                      ids: string[];
                                      isFetching: boolean;
                                      isFetchingMore: boolean;
                                      lastError:
                                          | {
                                              cause?: unknown;
                                              kind: "terminal";
                                              message: string;
                                              name: string;
                                              stack?: string;
                                              status?: number;
                                          }
                                          | {
                                              cause?: unknown;
                                              kind: "transient";
                                              message: string;
                                              name: string;
                                              stack?: string;
                                              status?: number;
                                          }
                                          | null;
                                      lastFetched: number
                                      | null;
                                      nextCursor: string | null;
                                      pageSize: number | null;
                                      prevCursor: string | null;
                                      stale: boolean;
                                      total: number | null;
                                  };
                              };
                              patchEntity: (
                                  type: string,
                                  id: string,
                                  patch: Record<string, unknown>,
                              ) => void;
                              patches: { [x: string]: { [x: string]: { [x: string]: unknown } } };
                              prependListResult: (
                                  key: string,
                                  ids: string[],
                                  meta?: Partial<ListState>,
                              ) => void;
                              readEntity: <T = Record<string, unknown>>(
                                  type: string,
                                  id: string,
                              ) => T | null;
                              readEntitySnapshot: <T = Record<string, unknown>>(
                                  type: string,
                                  id: string,
                              ) => EntitySnapshot<T & Record<string, unknown>> | null;
                              removeEntity: (type: string, id: string) => void;
                              removeIdFromAllLists: (type: string, id: string) => void;
                              replaceEntity: (
                                  type: string,
                                  id: string,
                                  data: Record<string, unknown>,
                              ) => void;
                              setEntityError: (
                                  type: string,
                                  id: string,
                                  error: string | null,
                              ) => void;
                              setEntityFetched: (type: string, id: string) => void;
                              setEntityFetching: (
                                  type: string,
                                  id: string,
                                  fetching: boolean,
                              ) => void;
                              setEntityStale: (type: string, id: string, stale: boolean) => void;
                              setEntitySyncMetadata: (
                                  type: string,
                                  id: string,
                                  metadata: Partial<EntitySyncMetadata>,
                              ) => void;
                              setListError: (
                                  key: string,
                                  error: string | null,
                                  typed?: EntityError | null,
                              ) => void;
                              setListFetching: (key: string, fetching: boolean) => void;
                              setListFetchingMore: (key: string, fetchingMore: boolean) => void;
                              setListResult: (
                                  key: string,
                                  ids: string[],
                                  meta: Partial<
                                      Omit<
                                          ListState,
                                          "ids"
                                          | "isFetching"
                                          | "isFetchingMore"
                                          | "error"
                                          | "stale",
                                      >,
                                  >,
                              ) => void;
                              setListStale: (key: string, stale: boolean) => void;
                              syncMetadata: {
                                  [x: string]: {
                                      origin: SyncOrigin;
                                      synced: boolean;
                                      updatedAt: number | null;
                                  };
                              };
                              unpatchEntity: (type: string, id: string, keys: string[]) => void;
                              upsertEntities: (
                                  type: string,
                                  entries: { data: Record<string, unknown>; id: string }[],
                              ) => void;
                              upsertEntity: (
                                  type: string,
                                  id: string,
                                  data: Record<string, unknown>,
                              ) => void;
                          },
                      ) => void
                  ),
              shouldReplace?: false,
          ): void;
          setState(
              nextStateOrUpdater:
                  | GraphState
                  | (
                      (
                          state: {
                              appendListResult: (
                                  key: string,
                                  ids: string[],
                                  meta: Partial<
                                      Omit<
                                          ListState,
                                          "ids"
                                          | "isFetching"
                                          | "isFetchingMore"
                                          | "error"
                                          | "stale",
                                      >,
                                  >,
                              ) => void;
                              clearEntitySyncMetadata: (type: string, id: string) => void;
                              clearPatch: (type: string, id: string) => void;
                              entities: { [x: string]: { [x: string]: { [x: string]: unknown } } };
                              entityStates: {
                                  [x: string]: {
                                      error: string | null;
                                      isFetching: boolean;
                                      lastFetched: number | null;
                                      stale: boolean;
                                  };
                              };
                              ingestFetchedList: (
                                  type: string,
                                  entries: { data: Record<string, unknown>; id: string }[],
                                  options?: IngestFetchedListOptions,
                              ) => void;
                              insertIdInList: (
                                  key: string,
                                  id: string,
                                  position: number | "end" | "start",
                              ) => void;
                              invalidateEntity: (type: string, id?: string) => void;
                              invalidateLists: (
                                  matcher: string | ((key: string) => boolean),
                              ) => void;
                              invalidateType: (type: string) => void;
                              lists: {
                                  [x: string]: {
                                      currentPage: number | null;
                                      error: string | null;
                                      hasNextPage: boolean;
                                      hasPrevPage: boolean;
                                      ids: string[];
                                      isFetching: boolean;
                                      isFetchingMore: boolean;
                                      lastError:
                                          | {
                                              cause?: unknown;
                                              kind: "terminal";
                                              message: string;
                                              name: string;
                                              stack?: string;
                                              status?: number;
                                          }
                                          | {
                                              cause?: unknown;
                                              kind: "transient";
                                              message: string;
                                              name: string;
                                              stack?: string;
                                              status?: number;
                                          }
                                          | null;
                                      lastFetched: number
                                      | null;
                                      nextCursor: string | null;
                                      pageSize: number | null;
                                      prevCursor: string | null;
                                      stale: boolean;
                                      total: number | null;
                                  };
                              };
                              patchEntity: (
                                  type: string,
                                  id: string,
                                  patch: Record<string, unknown>,
                              ) => void;
                              patches: { [x: string]: { [x: string]: { [x: string]: unknown } } };
                              prependListResult: (
                                  key: string,
                                  ids: string[],
                                  meta?: Partial<ListState>,
                              ) => void;
                              readEntity: <T = Record<string, unknown>>(
                                  type: string,
                                  id: string,
                              ) => T | null;
                              readEntitySnapshot: <T = Record<string, unknown>>(
                                  type: string,
                                  id: string,
                              ) => EntitySnapshot<T & Record<string, unknown>> | null;
                              removeEntity: (type: string, id: string) => void;
                              removeIdFromAllLists: (type: string, id: string) => void;
                              replaceEntity: (
                                  type: string,
                                  id: string,
                                  data: Record<string, unknown>,
                              ) => void;
                              setEntityError: (
                                  type: string,
                                  id: string,
                                  error: string | null,
                              ) => void;
                              setEntityFetched: (type: string, id: string) => void;
                              setEntityFetching: (
                                  type: string,
                                  id: string,
                                  fetching: boolean,
                              ) => void;
                              setEntityStale: (type: string, id: string, stale: boolean) => void;
                              setEntitySyncMetadata: (
                                  type: string,
                                  id: string,
                                  metadata: Partial<EntitySyncMetadata>,
                              ) => void;
                              setListError: (
                                  key: string,
                                  error: string | null,
                                  typed?: EntityError | null,
                              ) => void;
                              setListFetching: (key: string, fetching: boolean) => void;
                              setListFetchingMore: (key: string, fetchingMore: boolean) => void;
                              setListResult: (
                                  key: string,
                                  ids: string[],
                                  meta: Partial<
                                      Omit<
                                          ListState,
                                          "ids"
                                          | "isFetching"
                                          | "isFetchingMore"
                                          | "error"
                                          | "stale",
                                      >,
                                  >,
                              ) => void;
                              setListStale: (key: string, stale: boolean) => void;
                              syncMetadata: {
                                  [x: string]: {
                                      origin: SyncOrigin;
                                      synced: boolean;
                                      updatedAt: number | null;
                                  };
                              };
                              unpatchEntity: (type: string, id: string, keys: string[]) => void;
                              upsertEntities: (
                                  type: string,
                                  entries: { data: Record<string, unknown>; id: string }[],
                              ) => void;
                              upsertEntity: (
                                  type: string,
                                  id: string,
                                  data: Record<string, unknown>,
                              ) => void;
                          },
                      ) => void
                  ),
              shouldReplace: true,
          ): void;
      }