Skip to content

Commit e50eaf4

Browse files
committed
apply workaround for 2nd level include
1 parent 6aa6858 commit e50eaf4

6 files changed

Lines changed: 9 additions & 7 deletions

File tree

packages/hypergraph-react/src/HypergraphSpaceContext.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export function useHardDeleteEntity() {
7272
type QueryParams<S extends Entity.AnyNoContext> = {
7373
enabled: boolean;
7474
filter?: { [K in keyof Schema.Schema.Type<S>]?: Entity.EntityFieldFilter<Schema.Schema.Type<S>[K]> } | undefined;
75-
include?: { [K in keyof Schema.Schema.Type<S>]?: Record<string, never> } | undefined;
75+
include?: { [K in keyof Schema.Schema.Type<S>]?: Record<string, Record<string, never>> } | undefined;
7676
};
7777

7878
export function useQueryLocal<const S extends Entity.AnyNoContext>(type: S, params?: QueryParams<S>) {

packages/hypergraph-react/src/internal/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ import type * as Schema from 'effect/Schema';
33

44
export type QueryPublicParams<S extends Entity.AnyNoContext> = {
55
enabled: boolean;
6-
include?: { [K in keyof Schema.Schema.Type<S>]?: Record<string, never> } | undefined;
6+
// TODO: for multi-level nesting it should only allow the allowed properties instead of Record<string, Record<string, never>>
7+
include?: { [K in keyof Schema.Schema.Type<S>]?: Record<string, Record<string, never>> } | undefined;
78
};

packages/hypergraph-react/src/use-query.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import type { DiffEntry, PublishDiffInfo } from './types.js';
1212
type QueryParams<S extends Entity.AnyNoContext> = {
1313
mode?: 'merged' | 'public' | 'local';
1414
filter?: { [K in keyof Schema.Schema.Type<S>]?: Entity.EntityFieldFilter<Schema.Schema.Type<S>[K]> } | undefined;
15-
include?: { [K in keyof Schema.Schema.Type<S>]?: Record<string, never> } | undefined;
15+
// TODO: for multi-level nesting it should only allow the allowed properties instead of Record<string, Record<string, never>>
16+
include?: { [K in keyof Schema.Schema.Type<S>]?: Record<string, Record<string, never>> } | undefined;
1617
};
1718

1819
const mergeEntities = <S extends Entity.AnyNoContext>(

packages/hypergraph/src/entity/decodedEntitiesCache.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export type QueryEntry = {
55
data: Array<Entity<AnyNoContext>>; // holds the decoded entities of this query and must be a stable reference and use the same reference for the `entities` array
66
listeners: Array<() => void>; // listeners to this query
77
isInvalidated: boolean;
8-
include: { [K in keyof Schema.Schema.Type<AnyNoContext>]?: Record<string, never> };
8+
include: { [K in keyof Schema.Schema.Type<AnyNoContext>]?: Record<string, Record<string, never>> };
99
};
1010

1111
export type DecodedEntitiesCacheEntry = {

packages/hypergraph/src/entity/findMany.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ export function findMany<const S extends AnyNoContext>(
239239
handle: DocHandle<DocumentContent>,
240240
type: S,
241241
filter: EntityFilter<Schema.Schema.Type<S>> | undefined,
242-
include: { [K in keyof Schema.Schema.Type<S>]?: Record<string, never> } | undefined,
242+
include: { [K in keyof Schema.Schema.Type<S>]?: Record<string, Record<string, never>> } | undefined,
243243
): { entities: Readonly<Array<Entity<S>>>; corruptEntityIds: Readonly<Array<string>> } {
244244
const decode = Schema.decodeUnknownSync(type);
245245
// TODO: what's the right way to get the name of the type?
@@ -378,7 +378,7 @@ export function subscribeToFindMany<const S extends AnyNoContext>(
378378
handle: DocHandle<DocumentContent>,
379379
type: S,
380380
filter: { [K in keyof Schema.Schema.Type<S>]?: EntityFieldFilter<Schema.Schema.Type<S>[K]> } | undefined,
381-
include: { [K in keyof Schema.Schema.Type<S>]?: Record<string, never> } | undefined,
381+
include: { [K in keyof Schema.Schema.Type<S>]?: Record<string, Record<string, never>> } | undefined,
382382
): {
383383
subscribe: (callback: () => void) => () => void;
384384
getEntities: () => Readonly<Array<Entity<S>>>;

packages/hypergraph/src/entity/getEntityRelations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export const getEntityRelations = <const S extends AnyNoContext>(
66
entityId: string,
77
type: S,
88
doc: DocumentContent,
9-
include: { [K in keyof Schema.Schema.Type<S>]?: Record<string, never> } | undefined,
9+
include: { [K in keyof Schema.Schema.Type<S>]?: Record<string, Record<string, never>> } | undefined,
1010
) => {
1111
const relations: Record<string, Entity<AnyNoContext>> = {};
1212
for (const [fieldName, field] of Object.entries(type.fields)) {

0 commit comments

Comments
 (0)