summaryrefslogtreecommitdiff
path: root/lib/model/path.mli
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@dailly.me>2026-11-19 13:26:42 +0100
committerSébastien Dailly <sebastien@dailly.me>2026-11-19 13:26:42 +0100
commitfb75994d097cb1d6a1a0ea871c2d2213aa4e3c31 (patch)
tree2e783d1472971c1823ec6e7a9cb484ebda2b0b43 /lib/model/path.mli
parentd1047791e9e25bc5a30ffc62f31c3d898843f042 (diff)
Path over contents evaluation
Diffstat (limited to 'lib/model/path.mli')
-rw-r--r--lib/model/path.mli35
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/model/path.mli b/lib/model/path.mli
new file mode 100644
index 0000000..50fd1b0
--- /dev/null
+++ b/lib/model/path.mli
@@ -0,0 +1,35 @@
+(** Evaluation of a path through the fields.
+
+ A path is a list of field names ({!Identifier.t}), like the ones parsed from
+ the DSL expressions ({!Dsl.ContentPath}, written [$a.b.c] in a
+ configuration).
+
+ Example: from a content [legalEntity], the path [entity; employee; country]
+ follows the reference field [entity], then the reference field [employee] of
+ its target, and resolves to the field [country] of the [employee] content —
+ whose target is the list [country_list]. A path can also end on a
+ non-reference field, e.g. [entity; country; code] resolves to the text field
+ [code] of the [country_list] list, usable in a rule like
+ [$entity.country.code = 'FR']. *)
+
+val resolve :
+ Reference.target -> Identifier.t list -> Reference.target Field.t option
+(** Resolve a path from a target (a content or a list).
+
+ Each segment is the name of a field of the current target. Intermediate
+ segments must be reference fields: the evaluation moves to their target. The
+ last segment can be any field.
+
+ The result is the field designated by the last segment. [None] when a
+ segment does not exist, or an intermediate segment is not a reference field.
+*)
+
+val resolve_from_content :
+ Reference.target Content.t ->
+ Identifier.t list ->
+ Reference.target Field.t option
+(** Resolve a path starting from a content *)
+
+val target_of_field : Reference.target Field.t -> Reference.target option
+(** The target of a reference field (the content or list it points to), [None]
+ for the other field types *)