1use crate::parser::ast::{self, Spanned};
7use crate::parser::ast_schema as schema;
8use crate::policy::Expression as CoreExpression;
9
10impl From<&ast::FileMetadata> for schema::FileMetadata {
15 fn from(m: &ast::FileMetadata) -> Self {
16 schema::FileMetadata {
17 namespace: m.namespace.clone(),
18 version: m.version.clone(),
19 owner: m.owner.clone(),
20 profile: m.profile.clone(),
21 imports: m.imports.iter().map(|i| i.into()).collect(),
22 }
23 }
24}
25
26impl From<&ast::ImportDecl> for schema::ImportDecl {
27 fn from(i: &ast::ImportDecl) -> Self {
28 schema::ImportDecl {
29 specifier: (&i.specifier).into(),
30 from_module: i.from_module.clone(),
31 }
32 }
33}
34
35impl From<&ast::ImportSpecifier> for schema::ImportSpecifier {
36 fn from(s: &ast::ImportSpecifier) -> Self {
37 match s {
38 ast::ImportSpecifier::Named(items) => schema::ImportSpecifier::Named {
39 items: items.iter().map(|i| i.into()).collect(),
40 },
41 ast::ImportSpecifier::Wildcard(alias) => schema::ImportSpecifier::Wildcard {
42 alias: alias.clone(),
43 },
44 }
45 }
46}
47
48impl From<&ast::ImportItem> for schema::ImportItem {
49 fn from(i: &ast::ImportItem) -> Self {
50 schema::ImportItem {
51 name: i.name.clone(),
52 alias: i.alias.clone(),
53 }
54 }
55}
56
57impl From<&ast::PolicyMetadata> for schema::PolicyMetadata {
62 fn from(m: &ast::PolicyMetadata) -> Self {
63 schema::PolicyMetadata {
64 kind: m.kind.as_ref().map(|k| k.into()),
65 modality: m.modality.as_ref().map(|m| m.into()),
66 priority: m.priority,
67 rationale: m.rationale.clone(),
68 tags: m.tags.clone(),
69 }
70 }
71}
72
73impl From<&ast::PolicyKind> for schema::PolicyKind {
74 fn from(k: &ast::PolicyKind) -> Self {
75 match k {
76 ast::PolicyKind::Constraint => schema::PolicyKind::Constraint,
77 ast::PolicyKind::Derivation => schema::PolicyKind::Derivation,
78 ast::PolicyKind::Obligation => schema::PolicyKind::Obligation,
79 }
80 }
81}
82
83impl From<&ast::PolicyModality> for schema::PolicyModality {
84 fn from(m: &ast::PolicyModality) -> Self {
85 match m {
86 ast::PolicyModality::Obligation => schema::PolicyModality::Obligation,
87 ast::PolicyModality::Prohibition => schema::PolicyModality::Prohibition,
88 ast::PolicyModality::Permission => schema::PolicyModality::Permission,
89 }
90 }
91}
92
93impl From<&ast::MetricMetadata> for schema::MetricMetadata {
98 fn from(m: &ast::MetricMetadata) -> Self {
99 schema::MetricMetadata {
100 refresh_interval: m
101 .refresh_interval
102 .map(|d| format!("PT{}S", d.num_seconds())),
103 unit: m.unit.clone(),
104 threshold: m.threshold.map(|d| d.to_string()),
105 severity: m.severity.as_ref().map(|s| s.into()),
106 target: m.target.map(|d| d.to_string()),
107 window: m.window.map(|d| format!("PT{}S", d.num_seconds())),
108 }
109 }
110}
111
112impl From<&crate::primitives::Severity> for schema::Severity {
113 fn from(s: &crate::primitives::Severity) -> Self {
114 match s {
115 crate::primitives::Severity::Info => schema::Severity::Info,
116 crate::primitives::Severity::Warning => schema::Severity::Warning,
117 crate::primitives::Severity::Error => schema::Severity::Error,
118 _ => schema::Severity::Error,
120 }
121 }
122}
123
124impl From<&ast::TargetFormat> for schema::TargetFormat {
129 fn from(t: &ast::TargetFormat) -> Self {
130 match t {
131 ast::TargetFormat::Calm => schema::TargetFormat::Calm,
132 ast::TargetFormat::Kg => schema::TargetFormat::Kg,
133 ast::TargetFormat::Sbvr => schema::TargetFormat::Sbvr,
134 ast::TargetFormat::Protobuf => schema::TargetFormat::Protobuf,
135 }
136 }
137}
138
139impl From<&ast::MappingRule> for schema::MappingRule {
140 fn from(r: &ast::MappingRule) -> Self {
141 schema::MappingRule {
142 primitive_type: r.primitive_type.clone(),
143 primitive_name: r.primitive_name.clone(),
144 target_type: r.target_type.clone(),
145 fields: r.fields.clone(),
146 }
147 }
148}
149
150impl From<&ast::ProjectionOverride> for schema::ProjectionOverride {
151 fn from(o: &ast::ProjectionOverride) -> Self {
152 schema::ProjectionOverride {
153 primitive_type: o.primitive_type.clone(),
154 primitive_name: o.primitive_name.clone(),
155 fields: o.fields.clone(),
156 }
157 }
158}
159
160impl From<&CoreExpression> for schema::Expression {
165 fn from(e: &CoreExpression) -> Self {
166 match e {
167 CoreExpression::Literal(v) => schema::Expression::Literal { value: v.clone() },
168 CoreExpression::QuantityLiteral { value, unit } => {
169 schema::Expression::QuantityLiteral {
170 value: value.to_string(),
171 unit: unit.clone(),
172 }
173 }
174 CoreExpression::TimeLiteral(ts) => schema::Expression::TimeLiteral {
175 timestamp: ts.clone(),
176 },
177 CoreExpression::IntervalLiteral { start, end } => schema::Expression::IntervalLiteral {
178 start: start.clone(),
179 end: end.clone(),
180 },
181 CoreExpression::Variable(name) => schema::Expression::Variable { name: name.clone() },
182 CoreExpression::GroupBy {
183 variable,
184 collection,
185 filter,
186 key,
187 condition,
188 } => schema::Expression::GroupBy {
189 variable: variable.clone(),
190 collection: Box::new(collection.as_ref().into()),
191 filter: filter.as_ref().map(|f| Box::new(f.as_ref().into())),
192 key: Box::new(key.as_ref().into()),
193 condition: Box::new(condition.as_ref().into()),
194 },
195 CoreExpression::Binary { op, left, right } => schema::Expression::Binary {
196 op: op.into(),
197 left: Box::new(left.as_ref().into()),
198 right: Box::new(right.as_ref().into()),
199 },
200 CoreExpression::Unary { op, operand } => schema::Expression::Unary {
201 op: op.into(),
202 operand: Box::new(operand.as_ref().into()),
203 },
204 CoreExpression::Cast {
205 operand,
206 target_type,
207 } => schema::Expression::Cast {
208 operand: Box::new(operand.as_ref().into()),
209 target_type: target_type.clone(),
210 },
211 CoreExpression::Quantifier {
212 quantifier,
213 variable,
214 collection,
215 condition,
216 } => schema::Expression::Quantifier {
217 quantifier: quantifier.into(),
218 variable: variable.clone(),
219 collection: Box::new(collection.as_ref().into()),
220 condition: Box::new(condition.as_ref().into()),
221 },
222 CoreExpression::MemberAccess { object, member } => schema::Expression::MemberAccess {
223 object: object.clone(),
224 member: member.clone(),
225 },
226 CoreExpression::Aggregation {
227 function,
228 collection,
229 field,
230 filter,
231 } => schema::Expression::Aggregation {
232 function: function.into(),
233 collection: Box::new(collection.as_ref().into()),
234 field: field.clone(),
235 filter: filter.as_ref().map(|f| Box::new(f.as_ref().into())),
236 },
237 CoreExpression::AggregationComprehension {
238 function,
239 variable,
240 collection,
241 window,
242 predicate,
243 projection,
244 target_unit,
245 } => schema::Expression::AggregationComprehension {
246 function: function.into(),
247 variable: variable.clone(),
248 collection: Box::new(collection.as_ref().into()),
249 window: window.as_ref().map(|w| w.into()),
250 predicate: Box::new(predicate.as_ref().into()),
251 projection: Box::new(projection.as_ref().into()),
252 target_unit: target_unit.clone(),
253 },
254 CoreExpression::RoleReference { role } => {
255 schema::Expression::RoleReference { role: role.clone() }
256 }
257 }
258 }
259}
260
261impl From<&crate::policy::BinaryOp> for schema::BinaryOp {
262 fn from(op: &crate::policy::BinaryOp) -> Self {
263 match op {
264 crate::policy::BinaryOp::And => schema::BinaryOp::And,
265 crate::policy::BinaryOp::Or => schema::BinaryOp::Or,
266 crate::policy::BinaryOp::Equal => schema::BinaryOp::Equal,
267 crate::policy::BinaryOp::NotEqual => schema::BinaryOp::NotEqual,
268 crate::policy::BinaryOp::GreaterThan => schema::BinaryOp::GreaterThan,
269 crate::policy::BinaryOp::LessThan => schema::BinaryOp::LessThan,
270 crate::policy::BinaryOp::GreaterThanOrEqual => schema::BinaryOp::GreaterThanOrEqual,
271 crate::policy::BinaryOp::LessThanOrEqual => schema::BinaryOp::LessThanOrEqual,
272 crate::policy::BinaryOp::Plus => schema::BinaryOp::Plus,
273 crate::policy::BinaryOp::Minus => schema::BinaryOp::Minus,
274 crate::policy::BinaryOp::Multiply => schema::BinaryOp::Multiply,
275 crate::policy::BinaryOp::Divide => schema::BinaryOp::Divide,
276 crate::policy::BinaryOp::Contains => schema::BinaryOp::Contains,
277 crate::policy::BinaryOp::StartsWith => schema::BinaryOp::StartsWith,
278 crate::policy::BinaryOp::EndsWith => schema::BinaryOp::EndsWith,
279 crate::policy::BinaryOp::Matches => schema::BinaryOp::Matches,
280 crate::policy::BinaryOp::HasRole => schema::BinaryOp::HasRole,
281 crate::policy::BinaryOp::Before => schema::BinaryOp::Before,
282 crate::policy::BinaryOp::After => schema::BinaryOp::After,
283 crate::policy::BinaryOp::During => schema::BinaryOp::During,
284 }
285 }
286}
287
288impl From<&crate::policy::UnaryOp> for schema::UnaryOp {
289 fn from(op: &crate::policy::UnaryOp) -> Self {
290 match op {
291 crate::policy::UnaryOp::Not => schema::UnaryOp::Not,
292 crate::policy::UnaryOp::Negate => schema::UnaryOp::Negate,
293 }
294 }
295}
296
297impl From<&crate::policy::Quantifier> for schema::Quantifier {
298 fn from(q: &crate::policy::Quantifier) -> Self {
299 match q {
300 crate::policy::Quantifier::ForAll => schema::Quantifier::ForAll,
301 crate::policy::Quantifier::Exists => schema::Quantifier::Exists,
302 crate::policy::Quantifier::ExistsUnique => schema::Quantifier::ExistsUnique,
303 }
304 }
305}
306
307impl From<&crate::policy::AggregateFunction> for schema::AggregateFunction {
308 fn from(f: &crate::policy::AggregateFunction) -> Self {
309 match f {
310 crate::policy::AggregateFunction::Count => schema::AggregateFunction::Count,
311 crate::policy::AggregateFunction::Sum => schema::AggregateFunction::Sum,
312 crate::policy::AggregateFunction::Min => schema::AggregateFunction::Min,
313 crate::policy::AggregateFunction::Max => schema::AggregateFunction::Max,
314 crate::policy::AggregateFunction::Avg => schema::AggregateFunction::Avg,
315 }
316 }
317}
318
319impl From<&crate::policy::WindowSpec> for schema::WindowSpec {
320 fn from(w: &crate::policy::WindowSpec) -> Self {
321 schema::WindowSpec {
322 duration: w.duration,
323 unit: "seconds".to_string(),
324 }
325 }
326}
327
328impl From<&Spanned<ast::AstNode>> for schema::SpannedAstNode {
333 fn from(s: &Spanned<ast::AstNode>) -> Self {
334 schema::SpannedAstNode {
335 node: (&s.node).into(),
336 line: s.line,
337 column: s.column,
338 }
339 }
340}
341
342impl From<&ast::AstNode> for schema::AstNode {
343 fn from(n: &ast::AstNode) -> Self {
344 match n {
345 ast::AstNode::Export(inner) => schema::AstNode::Export {
346 declaration: Box::new(inner.as_ref().into()),
347 },
348 ast::AstNode::Entity {
349 name,
350 version,
351 annotations,
352 domain,
353 body,
354 } => schema::AstNode::Entity {
355 name: name.clone(),
356 version: version.clone(),
357 annotations: annotations.clone(),
358 domain: domain.clone(),
359 body: body.as_ref().map(|b| b.into()),
360 },
361 ast::AstNode::Record(r) => schema::AstNode::Record {
362 declaration: r.into(),
363 },
364 ast::AstNode::Enum(e) => schema::AstNode::Enum {
365 declaration: e.into(),
366 },
367 ast::AstNode::Operation(o) => schema::AstNode::Operation {
368 declaration: o.into(),
369 },
370 ast::AstNode::Resource {
371 name,
372 annotations,
373 unit_name,
374 domain,
375 } => schema::AstNode::Resource {
376 name: name.clone(),
377 annotations: annotations.clone(),
378 unit_name: unit_name.clone(),
379 domain: domain.clone(),
380 },
381 ast::AstNode::Flow {
382 resource_name,
383 annotations,
384 from_entity,
385 to_entity,
386 quantity,
387 } => schema::AstNode::Flow {
388 resource_name: resource_name.clone(),
389 annotations: annotations.clone(),
390 from_entity: from_entity.clone(),
391 to_entity: to_entity.clone(),
392 quantity: quantity.map(|d| d.to_string()),
393 },
394 ast::AstNode::Pattern { name, regex } => schema::AstNode::Pattern {
395 name: name.clone(),
396 regex: regex.clone(),
397 },
398 ast::AstNode::Role { name, domain } => schema::AstNode::Role {
399 name: name.clone(),
400 domain: domain.clone(),
401 },
402 ast::AstNode::Relation {
403 name,
404 subject_role,
405 predicate,
406 object_role,
407 via_flow,
408 } => schema::AstNode::Relation {
409 name: name.clone(),
410 subject_role: subject_role.clone(),
411 predicate: predicate.clone(),
412 object_role: object_role.clone(),
413 via_flow: via_flow.clone(),
414 },
415 ast::AstNode::RoleBinding { role, entity } => schema::AstNode::RoleBinding {
416 role: role.clone(),
417 entity: entity.clone(),
418 },
419 ast::AstNode::Dimension { name } => schema::AstNode::Dimension { name: name.clone() },
420 ast::AstNode::UnitDeclaration {
421 symbol,
422 dimension,
423 factor,
424 base_unit,
425 } => schema::AstNode::UnitDeclaration {
426 symbol: symbol.clone(),
427 dimension: dimension.clone(),
428 factor: factor.to_string(),
429 base_unit: base_unit.clone(),
430 },
431 ast::AstNode::Policy {
432 name,
433 version,
434 metadata,
435 expression,
436 } => schema::AstNode::Policy {
437 name: name.clone(),
438 version: version.clone(),
439 metadata: metadata.into(),
440 expression: expression.into(),
441 },
442 ast::AstNode::Instance {
443 name,
444 entity_type,
445 fields,
446 } => schema::AstNode::Instance {
447 name: name.clone(),
448 entity_type: entity_type.clone(),
449 fields: fields.iter().map(|(k, v)| (k.clone(), v.into())).collect(),
450 },
451 ast::AstNode::ConceptChange {
452 name,
453 from_version,
454 to_version,
455 migration_policy,
456 breaking_change,
457 } => schema::AstNode::ConceptChange {
458 name: name.clone(),
459 from_version: from_version.clone(),
460 to_version: to_version.clone(),
461 migration_policy: migration_policy.clone(),
462 breaking_change: *breaking_change,
463 },
464 ast::AstNode::Metric {
465 name,
466 expression,
467 metadata,
468 } => schema::AstNode::Metric {
469 name: name.clone(),
470 expression: expression.into(),
471 metadata: metadata.into(),
472 },
473 ast::AstNode::MappingDecl {
474 name,
475 target,
476 rules,
477 } => schema::AstNode::MappingDecl {
478 name: name.clone(),
479 target: target.into(),
480 rules: rules.iter().map(|r| r.into()).collect(),
481 },
482 ast::AstNode::ProjectionDecl {
483 name,
484 target,
485 overrides,
486 } => schema::AstNode::ProjectionDecl {
487 name: name.clone(),
488 target: target.into(),
489 overrides: overrides.iter().map(|o| o.into()).collect(),
490 },
491 ast::AstNode::Cell { name, annotations } => schema::AstNode::Cell {
492 name: name.clone(),
493 annotations: annotations.clone(),
494 },
495 ast::AstNode::SystemDependency {
496 name,
497 version,
498 annotations,
499 } => schema::AstNode::SystemDependency {
500 name: name.clone(),
501 version: version.clone(),
502 annotations: annotations.clone(),
503 },
504 ast::AstNode::Runtime {
505 name,
506 version,
507 annotations,
508 } => schema::AstNode::Runtime {
509 name: name.clone(),
510 version: version.clone(),
511 annotations: annotations.clone(),
512 },
513 ast::AstNode::Tool {
514 name,
515 version,
516 annotations,
517 } => schema::AstNode::Tool {
518 name: name.clone(),
519 version: version.clone(),
520 annotations: annotations.clone(),
521 },
522 ast::AstNode::DependencySet { name, annotations } => schema::AstNode::DependencySet {
523 name: name.clone(),
524 annotations: annotations.clone(),
525 },
526 ast::AstNode::Service {
527 name,
528 version,
529 annotations,
530 } => schema::AstNode::Service {
531 name: name.clone(),
532 version: version.clone(),
533 annotations: annotations.clone(),
534 },
535 ast::AstNode::Mount { name, annotations } => schema::AstNode::Mount {
536 name: name.clone(),
537 annotations: annotations.clone(),
538 },
539 ast::AstNode::Endpoint { name, annotations } => schema::AstNode::Endpoint {
540 name: name.clone(),
541 annotations: annotations.clone(),
542 },
543 ast::AstNode::NetworkFlow {
544 name,
545 from_ref,
546 to_ref,
547 annotations,
548 } => schema::AstNode::NetworkFlow {
549 name: name.clone(),
550 from_ref: from_ref.clone(),
551 to_ref: to_ref.clone(),
552 annotations: annotations.clone(),
553 },
554 ast::AstNode::Credential { name, annotations } => schema::AstNode::Credential {
555 name: name.clone(),
556 annotations: annotations.clone(),
557 },
558 }
559 }
560}
561
562impl From<&ast::Ast> for schema::Ast {
567 fn from(a: &ast::Ast) -> Self {
568 schema::Ast {
569 metadata: (&a.metadata).into(),
570 declarations: a.declarations.iter().map(|d| d.into()).collect(),
571 }
572 }
573}
574
575impl From<ast::Ast> for schema::Ast {
576 fn from(a: ast::Ast) -> Self {
577 (&a).into()
578 }
579}
580
581impl From<&ast::EntityBody> for schema::EntityBody {
584 fn from(b: &ast::EntityBody) -> Self {
585 schema::EntityBody {
586 fields: b.fields.iter().map(|f| f.into()).collect(),
587 }
588 }
589}
590
591impl From<&ast::FieldDecl> for schema::FieldDecl {
592 fn from(f: &ast::FieldDecl) -> Self {
593 schema::FieldDecl {
594 is_key: f.is_key,
595 name: f.name.clone(),
596 field_type: (&f.field_type).into(),
597 is_optional: f.is_optional,
598 constraints: f.constraints.iter().map(|c| c.into()).collect(),
599 default: f.default.as_ref().map(|e| e.into()),
600 }
601 }
602}
603
604impl From<&ast::FieldType> for schema::FieldType {
605 fn from(t: &ast::FieldType) -> Self {
606 match t {
607 ast::FieldType::Scalar(s) => schema::FieldType::Scalar { symbol: s.into() },
608 ast::FieldType::Quantity(s) => schema::FieldType::Quantity { symbol: s.into() },
609 ast::FieldType::Ref(s) => schema::FieldType::Ref { symbol: s.into() },
610 ast::FieldType::Named(s) => schema::FieldType::Named { symbol: s.into() },
611 ast::FieldType::List(elem) => schema::FieldType::List {
612 element: Box::new(elem.as_ref().into()),
613 },
614 }
615 }
616}
617
618impl From<&ast::FieldTypeRef> for schema::FieldTypeRef {
619 fn from(r: &ast::FieldTypeRef) -> Self {
620 schema::FieldTypeRef {
621 alias: r.alias.clone(),
622 symbol: r.symbol.clone(),
623 }
624 }
625}
626
627impl From<&ast::FieldConstraintDecl> for schema::FieldConstraintDecl {
628 fn from(c: &ast::FieldConstraintDecl) -> Self {
629 match c {
630 ast::FieldConstraintDecl::MinLength(v) => {
631 schema::FieldConstraintDecl::MinLength { value: *v }
632 }
633 ast::FieldConstraintDecl::MaxLength(v) => {
634 schema::FieldConstraintDecl::MaxLength { value: *v }
635 }
636 ast::FieldConstraintDecl::MinItems(v) => {
637 schema::FieldConstraintDecl::MinItems { value: *v }
638 }
639 ast::FieldConstraintDecl::MaxItems(v) => {
640 schema::FieldConstraintDecl::MaxItems { value: *v }
641 }
642 ast::FieldConstraintDecl::ExclusiveMin(v) => {
643 schema::FieldConstraintDecl::ExclusiveMin {
644 value: v.to_string(),
645 }
646 }
647 ast::FieldConstraintDecl::ExclusiveMax(v) => {
648 schema::FieldConstraintDecl::ExclusiveMax {
649 value: v.to_string(),
650 }
651 }
652 ast::FieldConstraintDecl::Min(v) => schema::FieldConstraintDecl::Min {
653 value: v.to_string(),
654 },
655 ast::FieldConstraintDecl::Max(v) => schema::FieldConstraintDecl::Max {
656 value: v.to_string(),
657 },
658 ast::FieldConstraintDecl::Pattern(s) => {
659 schema::FieldConstraintDecl::Pattern { symbol: s.clone() }
660 }
661 }
662 }
663}
664
665impl From<&ast::RecordDecl> for schema::RecordDecl {
666 fn from(r: &ast::RecordDecl) -> Self {
667 schema::RecordDecl {
668 name: r.name.clone(),
669 fields: r.fields.iter().map(|f| f.into()).collect(),
670 }
671 }
672}
673
674impl From<&ast::EnumDecl> for schema::EnumDecl {
675 fn from(e: &ast::EnumDecl) -> Self {
676 schema::EnumDecl {
677 name: e.name.clone(),
678 members: e
679 .members
680 .iter()
681 .map(|m| schema::EnumMember {
682 name: m.name.clone(),
683 wire: m.wire.clone(),
684 })
685 .collect(),
686 }
687 }
688}
689
690impl From<&ast::OperationDecl> for schema::OperationDecl {
691 fn from(o: &ast::OperationDecl) -> Self {
692 schema::OperationDecl {
693 name: o.name.clone(),
694 clauses: o.clauses.iter().map(|c| c.into()).collect(),
695 }
696 }
697}
698
699impl From<&ast::OperationClause> for schema::OperationClause {
700 fn from(c: &ast::OperationClause) -> Self {
701 match c {
702 ast::OperationClause::Intent(text) => {
703 schema::OperationClause::Intent { text: text.clone() }
704 }
705 ast::OperationClause::Direction { kind } => {
706 schema::OperationClause::Direction { kind: kind.clone() }
707 }
708 ast::OperationClause::Actor { actor } => schema::OperationClause::Actor {
709 actor: actor.clone(),
710 },
711 ast::OperationClause::AccessPublic => schema::OperationClause::AccessPublic,
712 ast::OperationClause::AccessPolicyGoverned { bindings } => {
713 schema::OperationClause::AccessPolicyGoverned {
714 bindings: bindings.iter().map(|b| b.into()).collect(),
715 }
716 }
717 ast::OperationClause::Input { reference } => schema::OperationClause::Input {
718 reference: reference.clone(),
719 },
720 ast::OperationClause::Output { reference } => schema::OperationClause::Output {
721 reference: reference.clone(),
722 },
723 ast::OperationClause::State { reference } => schema::OperationClause::State {
724 reference: reference.clone(),
725 },
726 ast::OperationClause::Effect { kind, reference } => schema::OperationClause::Effect {
727 kind: kind.clone(),
728 reference: reference.clone(),
729 },
730 ast::OperationClause::Transaction { kind } => {
731 schema::OperationClause::Transaction { kind: kind.clone() }
732 }
733 ast::OperationClause::Failure {
734 code,
735 kinds,
736 message,
737 } => schema::OperationClause::Failure {
738 code: code.clone(),
739 kinds: kinds.clone(),
740 message: message.clone(),
741 },
742 ast::OperationClause::IdempotencyKeyed { field } => {
743 schema::OperationClause::IdempotencyKeyed {
744 field: field.clone(),
745 }
746 }
747 ast::OperationClause::IdempotencyInherent => {
748 schema::OperationClause::IdempotencyInherent
749 }
750 ast::OperationClause::IdempotencyNotApplicable {
751 reason,
752 explanation,
753 } => schema::OperationClause::IdempotencyNotApplicable {
754 reason: reason.clone(),
755 explanation: explanation.clone(),
756 },
757 ast::OperationClause::ConcurrencyUnique { field } => {
758 schema::OperationClause::ConcurrencyUnique {
759 field: field.clone(),
760 }
761 }
762 ast::OperationClause::ConcurrencyOptimistic { field } => {
763 schema::OperationClause::ConcurrencyOptimistic {
764 field: field.clone(),
765 }
766 }
767 ast::OperationClause::ConcurrencyReadSnapshot => {
768 schema::OperationClause::ConcurrencyReadSnapshot
769 }
770 ast::OperationClause::EvidenceOperationTrace => {
771 schema::OperationClause::EvidenceOperationTrace
772 }
773 ast::OperationClause::LifecycleSynchronousRequestResponse => {
774 schema::OperationClause::LifecycleSynchronousRequestResponse
775 }
776 }
777 }
778}
779
780impl From<&ast::PolicyBinding> for schema::PolicyBinding {
781 fn from(b: &ast::PolicyBinding) -> Self {
782 schema::PolicyBinding {
783 policy: b.policy.clone(),
784 enforcement_point: b.enforcement_point.clone(),
785 failure_code: b.failure_code.clone(),
786 }
787 }
788}