Module filter

Module filter 

Source
Expand description

Document subscription filtering Document subscription filtering

This module provides primitives to express and evaluate subscription filters for document state transitions. The main entry point is DriveDocumentQueryFilter, which holds a contract reference, a document type name, and action-specific match clauses (DocumentActionMatchClauses).

Filtering in brief:

  • Create: evaluates new_document_clauses on the transition’s data payload.
  • Replace: evaluates original_document_clauses on the original document and new_document_clauses on the replacement data.
  • Delete: evaluates original_document_clauses on the original document.
  • Transfer: evaluates original_document_clauses and a new owner_clause against the recipient_owner_id.
  • UpdatePrice: evaluates original_document_clauses and a price_clause against the new price in the transition.
  • Purchase: evaluates original_document_clauses and an owner_clause against the batch owner (purchaser) ID.

Usage:

  • First check: call matches_document_transition() per transition to evaluate applicable constraints before fetching the original document. Decide whether to fetch the original document (returns Pass/Fail/NeedsOriginal).
  • Second check: only if the first check returned NeedsOriginal, fetch the original Document and call matches_original_document() to evaluate original-dependent clauses.

Validation:

  • validate() performs structural checks: confirms the document type exists for the contract, enforces action-specific composition rules (e.g., at least one non-empty clause where required), and validates operator/value compatibility for scalar clauses like owner_clause and price_clause.

Structs§

DriveDocumentQueryFilter
Filter used to match document transitions for subscriptions.

Enums§

DocumentActionMatchClauses
Action-specific filter clauses for matching document transitions.
TransitionCheckResult
Result of evaluating constraints for a transition before potentially fetching the original document.