Skip to main content

drasi_source_mapping/
lib.rs

1// Copyright 2025 The Drasi Authors.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! Source payload mapping engine for Drasi.
16//!
17//! Transforms arbitrary JSON payloads into graph change events (`SourceChange`)
18//! using Handlebars templates. This crate provides a shared mapping mechanism
19//! used by sources that receive arbitrary payloads (HTTP webhooks, Kafka messages, etc.).
20//!
21//! # Overview
22//!
23//! The mapping engine takes:
24//! - A `SourceMapping` configuration defining how to extract graph elements from payloads
25//! - A `serde_json::Value` context containing the payload and any source-specific metadata
26//! - A source ID string
27//!
28//! And produces `SourceChange` events (Insert, Update, Delete) that can be dispatched
29//! to the Drasi query engine.
30
31mod config;
32mod dto;
33mod engine;
34
35pub use config::{
36    EffectiveFromConfig, ElementTemplate, ElementType, MappingCondition, OperationType,
37    SourceMapping, TimestampFormat,
38};
39pub use dto::{
40    EffectiveFromConfigDto, ElementTemplateDto, ElementTypeDto, MappingConditionDto,
41    OperationTypeDto, SourceMappingDto, TimestampFormatDto,
42};
43pub use engine::{json_to_element_value, SourceMappingEngine};