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_clauseson the transition’s data payload. - Replace: evaluates
original_document_clauseson the original document andnew_document_clauseson the replacement data. - Delete: evaluates
original_document_clauseson the original document. - Transfer: evaluates
original_document_clausesand a newowner_clauseagainst therecipient_owner_id. - UpdatePrice: evaluates
original_document_clausesand aprice_clauseagainst the new price in the transition. - Purchase: evaluates
original_document_clausesand anowner_clauseagainst 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 originalDocumentand callmatches_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 likeowner_clauseandprice_clause.
Structs§
- Drive
Document Query Filter - Filter used to match document transitions for subscriptions.
Enums§
- Document
Action Match Clauses - Action-specific filter clauses for matching document transitions.
- Transition
Check Result - Result of evaluating constraints for a transition before potentially fetching the original document.