Repository: directus/directus
File: api/src/permissions/modules/validate-access/lib/validate-item-access.ts (TypeScript)

Code before:
import type { Accountability, PermissionsAction, PrimaryKey } from '@directus/types';
import { toBoolean } from '@directus/utils';
import { fetchPermittedAstRootFields } from '../../../../database/run-ast/modules/fetch-permitted-ast-root-fields.js';
import type { AST } from '../../../../types/index.js';
import { fetchPermissions } from '../../../lib/fetch-permissions.js';
import { fetchPolicies } from '../../../lib/fetch-policies.js';
import type { Context } from '../../../types.js';
import { fetchAllowedFields } from '../../fetch-allowed-fields/fetch-allowed-fields.js';
import { injectCases } from '../../process-ast/lib/inject-cases.js';
import { processAst } from '../../process-ast/process-ast.js';

export interface ValidateItemAccessOptions {
	accountability: Accountability;
	action: PermissionsAction;
	collection: string;
	primaryKeys: PrimaryKey[];
	fields?: string[];
	returnAllowedRootFields?: boolean;
}

export interface ValidateItemAccessOptionsWithFields extends ValidateItemAccessOptions {
	returnAllowedRootFields: true;
}

export interface ValidateItemAccessResult {
	accessAllowed: boolean;
	allowedRootFields?: string[];
}

export interface ValidateItemAccessResultWithFields extends ValidateItemAccessResult {
	allowedRootFields: string[];
}

export async function validateItemAccess(
	options: ValidateItemAccessOptionsWithFields,
	context: Context,
): Promise<ValidateItemAccessResultWithFields>;

export async function validateItemAccess(
	options: ValidateItemAccessOptions,
	context: Context,
): Promise<ValidateItemAccessResult>;

export async function validateItemAccess(
	options: ValidateItemAccessOptions | ValidateItemAccessOptionsWithFields,
	context: Context,

Review comment (suggestion):
```suggestion
export interface ValidateItemAccessOptionsWithRootFields extends ValidateItemAccessOptions {
```

Code after:
import type { Accountability, PermissionsAction, PrimaryKey } from '@directus/types';
import { toBoolean } from '@directus/utils';
import { fetchPermittedAstRootFields } from '../../../../database/run-ast/modules/fetch-permitted-ast-root-fields.js';
import type { AST } from '../../../../types/index.js';
import { fetchPermissions } from '../../../lib/fetch-permissions.js';
import { fetchPolicies } from '../../../lib/fetch-policies.js';
import type { Context } from '../../../types.js';
import { fetchAllowedFields } from '../../fetch-allowed-fields/fetch-allowed-fields.js';
import { injectCases } from '../../process-ast/lib/inject-cases.js';
import { processAst } from '../../process-ast/process-ast.js';

export interface ValidateItemAccessOptions {
	accountability: Accountability;
	action: PermissionsAction;
	collection: string;
	primaryKeys: PrimaryKey[];
	fields?: string[];
	returnAllowedRootFields?: boolean;
}

export interface ValidateItemAccessOptionsWithRootFields extends ValidateItemAccessOptions {
	returnAllowedRootFields: true;
}

export interface ValidateItemAccessResult {
	accessAllowed: boolean;
	allowedRootFields?: string[];
}

export interface ValidateItemAccessResultWithRootFields extends ValidateItemAccessResult {
	allowedRootFields: string[];
}

export async function validateItemAccess(
	options: ValidateItemAccessOptionsWithRootFields,
	context: Context,
): Promise<ValidateItemAccessResultWithRootFields>;

export async function validateItemAccess(
	options: ValidateItemAccessOptions,
	context: Context,
): Promise<ValidateItemAccessResult>;

export async function validateItemAccess(
	options: ValidateItemAccessOptions | ValidateItemAccessOptionsWithRootFields,
	context: Context,