Prometheus Entity Management API
    Preparing search index...
    • Thin wrapper around the core graphStore that adds a change-listener bus. The SSE server subscribes once and fans out to connected clients.

      There is intentionally no class hierarchy here — the graph is still owned by the vanilla Zustand store from the core package. This module only adds the notification bus.

      Returns {
          getStore: () => 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: ..., b: ...) => ...;
                              fireImmediately?: boolean;
                          },
                      ): () => void;
                  };
              },
              "setState",
          > & {
              setState(
                  nextStateOrUpdater:
                      | GraphState
                      | Partial<GraphState>
                      | (
                          (
                              state: {
                                  appendListResult: (
                                      key: string,
                                      ids: string[],
                                      meta: Partial<
                                          Omit<ListState, (...) | (...) | (...) | (...) | (...)>,
                                      >,
                                  ) => 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<(...), (...)>; 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?: ...;
                                                  kind: ...;
                                                  message: ...;
                                                  name: ...;
                                                  stack?: ...;
                                                  status?: ...;
                                              }
                                              | {
                                                  cause?: ...;
                                                  kind: ...;
                                                  message: ...;
                                                  name: ...;
                                                  stack?: ...;
                                                  status?: ...;
                                              }
                                              | 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<(...) & (...)> | 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, (...) | (...) | (...) | (...) | (...)>,
                                      >,
                                  ) => 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<(...), (...)>; 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, (...) | (...) | (...) | (...) | (...)>,
                                      >,
                                  ) => 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<(...), (...)>; 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?: ...;
                                                  kind: ...;
                                                  message: ...;
                                                  name: ...;
                                                  stack?: ...;
                                                  status?: ...;
                                              }
                                              | {
                                                  cause?: ...;
                                                  kind: ...;
                                                  message: ...;
                                                  name: ...;
                                                  stack?: ...;
                                                  status?: ...;
                                              }
                                              | 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<(...) & (...)> | 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, (...) | (...) | (...) | (...) | (...)>,
                                      >,
                                  ) => 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<(...), (...)>; id: string }[],
                                  ) => void;
                                  upsertEntity: (
                                      type: string,
                                      id: string,
                                      data: Record<string, unknown>,
                                  ) => void;
                              },
                          ) => void
                      ),
                  shouldReplace: true,
              ): void;
          };
          onEntityChanged: (listener: ChangeListener) => () => void;
          readEntities: (type: string) => Record<string, unknown>[];
          readEntity: (
              type: string,
              id: string,
          ) => Record<string, unknown> | undefined;
          removeEntity: (type: string, id: string) => void;
          replaceEntity: (
              type: string,
              id: string,
              data: Record<string, unknown>,
          ) => void;
          upsertEntity: (
              type: string,
              id: string,
              data: Record<string, unknown>,
          ) => void;
      }