Skip to content

FilterByInclude

reference
1 min readUpdated

Kind: Interface

Source: packages/core/discovery/discovery-service.ts

Part of: Core

FilterByInclude defines an inclusion filter used by the discovery service. Its include field contains predicate functions that determine which discovered items should be retained during discovery processing.

Properties

PropertyType
includeFunction[]

Diagram

mermaid
graph LR
  A[Discovery Service] --> B[FilterByInclude]
  B --> C[include: Function[]]
  C --> D[Inclusion Predicate 1]
  C --> E[Inclusion Predicate 2]
  D --> F[Discovered Items]
  E --> F
  F --> G[Included Results]

Usage

ts
import type { FilterByInclude } from './discovery-service';

const filter: FilterByInclude = {
  include: [
    (item) => item.enabled === true,
    (item) => item.name.startsWith('api-'),
  ],
};

// Pass the filter to the discovery workflow.
// Only items matching the configured inclusion predicates are retained.
discoveryService.discover({
  filter,
});

AI Coding Instructions

  • Provide inclusion logic as functions in the include array; keep each predicate focused on a single filtering concern.
  • Ensure predicate functions safely handle missing or optional properties on discovered items.
  • Use FilterByInclude when configuring discovery behavior that should explicitly retain matching items.
  • Avoid placing side effects in include predicates; they should only evaluate whether an item belongs in the results.

Relationships

  • IMPORTS → CustomDecorator
  • IMPORTS → flatten
  • IMPORTS → Injectable
  • IMPORTS → SetMetadata

Was this page helpful?

Download as PDF
FilterByInclude — NestJS head-to-head