import type { EntityRootType, QueryTemporalAxesUnresolved, Subgraph } from "../types.js"; import type { GraphResolveDepths } from "./subgraph/graph-resolve-depths.js"; import type { Entity, EntityId, EntityRecordId, LinkData, LinkEntity, PropertyObject, PropertyValue, Timestamp, VersionedUrl } from "@blockprotocol/type-system"; export type EntityRevisionId = Timestamp; export declare const isEntityRecordId: (recordId: unknown) => recordId is EntityRecordId; export type LinkEntityAndRightEntity = { linkEntity: LinkEntityImpl[]; rightEntity: EntityImpl[]; }; export type LinkEntityAndLeftEntity = { linkEntity: LinkEntityImpl[]; leftEntity: EntityImpl[]; }; export type CreateEntityData = { entityTypeIds: VersionedUrl[]; properties: PropertyObject; linkData?: LinkData; }; export type GetEntityData = { entityId: EntityId; graphResolveDepths?: Partial; temporalAxes: QueryTemporalAxesUnresolved; }; export type UpdateEntityData = { entityId: EntityId; entityTypeIds: VersionedUrl[]; properties: PropertyObject; }; export type DeleteEntityData = { entityId: EntityId; }; export type FilterOperatorType = FilterOperatorRequiringValue | FilterOperatorWithoutValue; export type FilterOperatorWithoutValue = "IS_DEFINED" | "IS_NOT_DEFINED"; export type FilterOperatorRequiringValue = "CONTAINS_SEGMENT" | "DOES_NOT_CONTAIN_SEGMENT" | "EQUALS" | "DOES_NOT_EQUAL" | "STARTS_WITH" | "ENDS_WITH"; export type MultiFilterOperatorType = "AND" | "OR"; export type MultiFilter = { filters: ({ field: (string | number)[]; operator: FilterOperatorRequiringValue; value: PropertyValue; } | { field: (string | number)[]; operator: FilterOperatorWithoutValue; })[]; operator: MultiFilterOperatorType; }; export type Sort = { field: (string | number)[]; desc?: boolean | undefined | null; }; export type MultiSort = Sort[]; export type QueryOperationInput = { multiSort?: MultiSort | null; multiFilter?: MultiFilter | null; }; export type QueryEntitiesData = { operation: QueryOperationInput; graphResolveDepths?: Partial; temporalAxes: QueryTemporalAxesUnresolved; }; export type QueryEntitiesResult> = { results: T; operation: QueryOperationInput; }; /** * A utility type that extracts the last segment of a string delimited by a separator */ type BeforeTrailingLast = CurrentString extends `${string}${Separator}${infer Segment}${Separator}` ? BeforeTrailingLast<`${Segment}${Separator}`, Separator, Segment> : PreviouslyExtractedSegment; /** * A properties object where the URL keys have been replaced by the last segment of the URL * To experiment with in block building – might be useful in patterns to make block building easier. * @todo remove this if we settle on a pattern that doesn't benefit from it */ export type SimpleProperties = { [Key in keyof Properties as BeforeTrailingLast, "/">]: Properties[Key]; }; export {};