import { DocumentNode } from 'graphql'; import { Driver } from 'neo4j-driver'; import { ExecutionContext } from './execution/executor'; import type { ModelPolicyBinding, UnsafeOptions } from './model'; import { InterfaceDefinition, SchemaMetadata } from './schema/types'; interface FindOptions> { limit?: number; offset?: number; sort?: TSort[]; } import type { QueryCompilers } from './model'; /** * InterfaceModel only needs query compilers (no mutations). * Re-exported as a named type for backwards compatibility. */ export type InterfaceModelCompilers = QueryCompilers; /** * Public-facing interface for InterfaceModel — used in generated type aliases. * Excludes internal class properties so jest.Mocked only requires find/aggregate. */ export interface InterfaceModelInterface> { find(params?: { where?: TWhere; selectionSet?: string | DocumentNode; options?: FindOptions; labels?: string[]; context?: ExecutionContext; unsafe?: UnsafeOptions; }): Promise<(T & { __typename: string; })[]>; aggregate(params: { where?: TWhere; aggregate: { count?: boolean; [field: string]: boolean | undefined; }; labels?: string[]; context?: ExecutionContext; unsafe?: UnsafeOptions; }): Promise>; findFirst?(params?: { where?: TWhere; selectionSet?: string | DocumentNode; options?: Omit, 'limit'>; labels?: string[]; context?: ExecutionContext; unsafe?: UnsafeOptions; }): Promise<(T & { __typename: string; }) | null>; findUnique?(params: { where: TWhere; selectionSet?: string | DocumentNode; labels?: string[]; context?: ExecutionContext; unsafe?: UnsafeOptions; }): Promise<(T & { __typename: string; }) | null>; findFirstOrThrow?(params?: { where?: TWhere; selectionSet?: string | DocumentNode; options?: Omit, 'limit'>; labels?: string[]; context?: ExecutionContext; unsafe?: UnsafeOptions; }): Promise; findUniqueOrThrow?(params: { where: TWhere; selectionSet?: string | DocumentNode; labels?: string[]; context?: ExecutionContext; unsafe?: UnsafeOptions; }): Promise; count?(params?: { where?: TWhere; labels?: string[]; context?: ExecutionContext; unsafe?: UnsafeOptions; }): Promise; } export declare class InterfaceModel, TWhere = any, TSort = Record> implements InterfaceModelInterface { private interfaceDef; private schema; private whereCompiler; private selectionCompiler; private fulltextCompiler; private executor; private syntheticNodeDef; private _defaultSelection; private maxDepth; private _selectionSetStr; private policyBinding; private logger; constructor(interfaceDef: InterfaceDefinition, schema: SchemaMetadata, driver: Driver, compilers?: InterfaceModelCompilers, policyBinding?: ModelPolicyBinding); /** * Resolve the policy bundle for the interface itself. Per design * decision #1, the InterfaceModel uses a CASE-per-label expression * that AND's each implementer's `'read'` policy with the interface's * own — implemented in `compileInterfacePolicyClause`. */ private resolveInterfacePolicy; private withInterfaceAuditMetadata; /** * The interface's policy clause (v2.3.0): * `(CASE WHEN n:M THEN … ELSE false END)`, built by the shared * `WhereCompiler.compileTargetPolicyClause` — the same construction that * guards interface / union relationship targets. Each branch is exactly * the clause `Model(M)` compiles for the same context and operation * (M's resolution already folds in the interface's own policies); a * member without a policy for the operation, or whose override fires, is * `true`, and no clause is emitted when every member is `true`. * `aggregate` falls back to a member's `read` policies when it has no * `aggregate` policy, as `Model.aggregate` does. * * Pre-2.3.0 branches were composed here from the interface's and the * implementer's policy lists: an implementer whose permissives were all * gated off by `appliesWhen` got `THEN true` (while `Model(M).find` * denies it), and interface predicates appeared twice per branch. * * Shares `paramCounter` with the calling pipeline so params don't collide. */ private compileInterfacePolicyClause; /** * Throw `PolicyDeniedError` early when default-deny is `'throw'` and NO * implementer can yield rows — the per-member test `Model(M)` applies: * a member with no policy for the operation, a firing override, or an * applicable permissive is visible. */ private assertNotDeniedAtCompile; find(params?: { where?: TWhere; selectionSet?: string | DocumentNode; options?: FindOptions; labels?: string[]; context?: ExecutionContext; unsafe?: UnsafeOptions; }): Promise<(T & { __typename: string; })[]>; aggregate(params: { where?: TWhere; aggregate: { count?: boolean; [field: string]: boolean | undefined; }; labels?: string[]; context?: ExecutionContext; unsafe?: UnsafeOptions; }): Promise>; findFirst(params?: { where?: TWhere; selectionSet?: string | DocumentNode; options?: Omit, 'limit'>; labels?: string[]; context?: ExecutionContext; unsafe?: UnsafeOptions; }): Promise<(T & { __typename: string; }) | null>; findUnique(params: { where: TWhere; selectionSet?: string | DocumentNode; labels?: string[]; context?: ExecutionContext; unsafe?: UnsafeOptions; }): Promise<(T & { __typename: string; }) | null>; findFirstOrThrow(params?: { where?: TWhere; selectionSet?: string | DocumentNode; options?: Omit, 'limit'>; labels?: string[]; context?: ExecutionContext; unsafe?: UnsafeOptions; }): Promise; findUniqueOrThrow(params: { where: TWhere; selectionSet?: string | DocumentNode; labels?: string[]; context?: ExecutionContext; unsafe?: UnsafeOptions; }): Promise; count(params?: { where?: TWhere; labels?: string[]; context?: ExecutionContext; unsafe?: UnsafeOptions; }): Promise; private buildSyntheticNodeDef; set selectionSet(value: string); private defaultInterfaceSelection; } export {}; //# sourceMappingURL=interface-model.d.ts.map